~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/widgets/wregla.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
ImportĀ upstreamĀ versionĀ 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  
 
3
 *  $Id: wregla.h 3535 2011-03-18 17:57:05Z carlos $
 
4
 *  Ginkgo CADx Project
 
5
 *
 
6
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
 
7
 *  http://ginkgo-cadx.com
 
8
 *
 
9
 *  This file is licensed under LGPL v3 license.
 
10
 *  See License.txt for details
 
11
 *
 
12
 *
 
13
 */
 
14
#pragma once
 
15
#include <api/iwidgets.h>
 
16
#include <api/iwidgetsmanager.h>
 
17
#include <api/widgetserializable.h>
 
18
#include <api/icontroladoreventos.h>
 
19
#include <widgets/openglhelper.h>
 
20
 
 
21
class wxXmlNode;
 
22
 
 
23
#ifdef __DEPRECATED
 
24
#undef __DEPRECATED
 
25
#endif
 
26
#include <vtkSmartPointer.h>
 
27
#include <vtkImageData.h>
 
28
 
 
29
namespace GNC {
 
30
        namespace GCS {
 
31
                namespace Widgets {
 
32
 
 
33
                        class WRegla;
 
34
 
 
35
                        class WReglaBuilder : public GNC::GCS::Widgets::IWidgetBuilder {
 
36
                        public:
 
37
 
 
38
                                typedef GNC::GCS::Vector TVector;
 
39
                                typedef GNC::GCS::Nodo   TNodo;
 
40
                                typedef GNC::GCS::Matriz TMatriz;
 
41
 
 
42
                                WReglaBuilder(GNC::GCS::IWidgetsManager* pManager);
 
43
 
 
44
                                ~WReglaBuilder();
 
45
 
 
46
                                virtual void OnMouseEvents(GNC::GCS::Eventos::EventoRaton&);
 
47
 
 
48
                                virtual void OnKeyEvents(GNC::GCS::Eventos::EventoTeclado&);
 
49
 
 
50
                                virtual void Render(GNC::GCS::Contexto3D* c);
 
51
 
 
52
                                virtual GNC::GCS::Widgets::TipoCursor GetCursor();
 
53
 
 
54
                        protected:
 
55
 
 
56
                                bool                           m_MouseDown;
 
57
                                WRegla*                       m_pReglaTemp;
 
58
 
 
59
                        };
 
60
 
 
61
                        class WRegla : public GNC::GCS::Widgets::IWidget, public GNC::GCS::Widgets::IWidgetSerializable, GNC::GCS::IObservador {
 
62
 
 
63
                        public:
 
64
                                GNC::GCS::Nodo                           m_Vertices[2];
 
65
 
 
66
//region "Constructor y destructor"
 
67
 
 
68
                        public:
 
69
 
 
70
                                typedef GNC::GCS::Vector TVector;
 
71
                                typedef GNC::GCS::Matriz TMatriz;
 
72
 
 
73
                                //static const unsigned int m_NumNodos = 100;
 
74
 
 
75
                                #define m_TamFuente 16.0f
 
76
                                #define m_AnchoMaximo 150.0f
 
77
 
 
78
                                GNC::GCS::Vector m_StartPointMov;
 
79
 
 
80
                                WRegla(IWidgetsManager* pManager, long vid, GNC::GCS::Nodo nodos[2], const char* nombre = "");
 
81
 
 
82
                                ~WRegla();
 
83
 
 
84
//endregion
 
85
 
 
86
                                //region "Serializado y desserializado"
 
87
                                WRegla(IWidgetsManager* pManager, long vid, wxXmlNode* nodo);
 
88
 
 
89
                                wxXmlNode* Serializar(const std::string& nombreMedico);
 
90
 
 
91
                                //endregion
 
92
 
 
93
 
 
94
                                //region "Interfaz especifica"
 
95
 
 
96
                                virtual bool SoportaAutoBorrado() const {
 
97
                                        return true;
 
98
                                }
 
99
 
 
100
                                virtual void OnMouseEvents(GNC::GCS::Eventos::EventoRaton&);
 
101
 
 
102
                                virtual void OnKeyEvents(GNC::GCS::Eventos::EventoTeclado&);
 
103
 
 
104
                                virtual bool HitTest(float x, float y, float umbral);
 
105
 
 
106
                                virtual bool HitTest(GNC::GCS::Vector* vertices, int numVertices);
 
107
 
 
108
                                virtual void Render(GNC::GCS::Contexto3D* c);
 
109
 
 
110
                                virtual void OffscreenRender(Contexto3D* c);
 
111
 
 
112
                                virtual float Distancia() {
 
113
                                        return m_Distancia;
 
114
                                }
 
115
 
 
116
                                //endregion
 
117
 
 
118
                                //region menu contextual
 
119
                                virtual bool GetMenuContextual(wxMenu* pMenu, wxWindow* pParent) ;
 
120
                                //endregion
 
121
 
 
122
                                virtual void ProcesarEvento(GNC::GCS::Eventos::IEvento *evt);
 
123
 
 
124
                                //region "Estado interno"
 
125
                        private:
 
126
                                bool            m_MouseDown;
 
127
                                //endregion
 
128
 
 
129
                                //region "Propiedades geometricas"
 
130
                        private:
 
131
                                GNC::GCS::Nodo   m_Centro;
 
132
                                GNC::GCS::Vector m_CentroAntiguo;
 
133
                                float            m_Angulo;
 
134
                                float            m_Pendiente;
 
135
 
 
136
                                GNC::GCS::Vector m_Escala;
 
137
                                GNC::GCS::Vector m_TamTexto;
 
138
                                std::string      m_Texto;
 
139
                                typedef struct TexturaRegla {
 
140
                                        std::string texto;
 
141
                                        TexturaCairo* m_textura;
 
142
                                        TexturaRegla()
 
143
                                        {
 
144
                                                m_textura = new GNC::GCS::TexturaCairo();
 
145
                                                m_textura->ActivarInterpolacion();
 
146
                                                texto = "";
 
147
                                        }
 
148
                                        ~TexturaRegla()
 
149
                                        {
 
150
                                                m_textura->Descargar();
 
151
                                                delete m_textura;
 
152
                                        }
 
153
                                } TexturaRegla;
 
154
                                typedef std::map<void*,TexturaRegla*> TMapaRecursos;
 
155
                                TMapaRecursos m_mapaRecursos;
 
156
                                TexturaRegla* GetTextura(GNC::GCS::IWidgetsRenderer* renderer);
 
157
 
 
158
                                friend std::ostream& operator<<(std::ostream& out, const WRegla& w) {
 
159
                                        out << "[ P0=" << w.m_Vertices[0] << ", P1=" << w.m_Vertices[1] <<
 
160
                                        ", Centro=" << w.m_Centro << ", Angulo=" << w.m_Angulo << "=" << w.m_Angulo*180.0f/M_PI <<
 
161
                                        ", Pendiente=" << w.m_Pendiente << ", Longitud=" << w.m_Distancia << ", CursorPoint=" << w.m_PosCursor << " ]";
 
162
                                        return out;
 
163
                                }
 
164
 
 
165
                        public:
 
166
                                float            m_Distancia;
 
167
 
 
168
                        public:
 
169
 
 
170
                                void Recalcular(GNC::GCS::IWidgetsRenderer* renderer);
 
171
 
 
172
                                virtual void LiberarRecursos(GNC::GCS::IWidgetsRenderer* pKey);
 
173
 
 
174
                        public:
 
175
                                //endregion
 
176
                                virtual void InsertarPropiedades(TListaMapasPropiedades &listaMapaPropiedades);
 
177
                        };
 
178
                }
 
179
        }
 
180
}