3
* $Id: wregla.h 3535 2011-03-18 17:57:05Z carlos $
6
* Copyright 2008-10 MetaEmotion S.L. All rights reserved.
7
* http://ginkgo-cadx.com
9
* This file is licensed under LGPL v3 license.
10
* See License.txt for details
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>
26
#include <vtkSmartPointer.h>
27
#include <vtkImageData.h>
35
class WReglaBuilder : public GNC::GCS::Widgets::IWidgetBuilder {
38
typedef GNC::GCS::Vector TVector;
39
typedef GNC::GCS::Nodo TNodo;
40
typedef GNC::GCS::Matriz TMatriz;
42
WReglaBuilder(GNC::GCS::IWidgetsManager* pManager);
46
virtual void OnMouseEvents(GNC::GCS::Eventos::EventoRaton&);
48
virtual void OnKeyEvents(GNC::GCS::Eventos::EventoTeclado&);
50
virtual void Render(GNC::GCS::Contexto3D* c);
52
virtual GNC::GCS::Widgets::TipoCursor GetCursor();
61
class WRegla : public GNC::GCS::Widgets::IWidget, public GNC::GCS::Widgets::IWidgetSerializable, GNC::GCS::IObservador {
64
GNC::GCS::Nodo m_Vertices[2];
66
//region "Constructor y destructor"
70
typedef GNC::GCS::Vector TVector;
71
typedef GNC::GCS::Matriz TMatriz;
73
//static const unsigned int m_NumNodos = 100;
75
#define m_TamFuente 16.0f
76
#define m_AnchoMaximo 150.0f
78
GNC::GCS::Vector m_StartPointMov;
80
WRegla(IWidgetsManager* pManager, long vid, GNC::GCS::Nodo nodos[2], const char* nombre = "");
86
//region "Serializado y desserializado"
87
WRegla(IWidgetsManager* pManager, long vid, wxXmlNode* nodo);
89
wxXmlNode* Serializar(const std::string& nombreMedico);
94
//region "Interfaz especifica"
96
virtual bool SoportaAutoBorrado() const {
100
virtual void OnMouseEvents(GNC::GCS::Eventos::EventoRaton&);
102
virtual void OnKeyEvents(GNC::GCS::Eventos::EventoTeclado&);
104
virtual bool HitTest(float x, float y, float umbral);
106
virtual bool HitTest(GNC::GCS::Vector* vertices, int numVertices);
108
virtual void Render(GNC::GCS::Contexto3D* c);
110
virtual void OffscreenRender(Contexto3D* c);
112
virtual float Distancia() {
118
//region menu contextual
119
virtual bool GetMenuContextual(wxMenu* pMenu, wxWindow* pParent) ;
122
virtual void ProcesarEvento(GNC::GCS::Eventos::IEvento *evt);
124
//region "Estado interno"
129
//region "Propiedades geometricas"
131
GNC::GCS::Nodo m_Centro;
132
GNC::GCS::Vector m_CentroAntiguo;
136
GNC::GCS::Vector m_Escala;
137
GNC::GCS::Vector m_TamTexto;
139
typedef struct TexturaRegla {
141
TexturaCairo* m_textura;
144
m_textura = new GNC::GCS::TexturaCairo();
145
m_textura->ActivarInterpolacion();
150
m_textura->Descargar();
154
typedef std::map<void*,TexturaRegla*> TMapaRecursos;
155
TMapaRecursos m_mapaRecursos;
156
TexturaRegla* GetTextura(GNC::GCS::IWidgetsRenderer* renderer);
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 << " ]";
170
void Recalcular(GNC::GCS::IWidgetsRenderer* renderer);
172
virtual void LiberarRecursos(GNC::GCS::IWidgetsRenderer* pKey);
176
virtual void InsertarPropiedades(TListaMapasPropiedades &listaMapaPropiedades);