~ubuntu-branches/ubuntu/precise/ginkgocadx/precise

« back to all changes in this revision

Viewing changes to src/cadxcore/main/tools/herramientainterpolate.cpp

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2011-09-09 08:39:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: package-import@ubuntu.com-20110909083926-iktecd132cnku5cd
Tags: 2.5.4.0~rc-1
New upstream version (patches were applied)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  
 
3
 *  $Id: herramientainterpolate.cpp 4090 2011-08-25 12:17:45Z tovar $
 
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
//#define _GINKGO_TRACE
 
15
#include <wx/menu.h>
 
16
 
 
17
#include <api/globals.h>
 
18
#include <api/iwidgetsmanager.h>
 
19
#include "herramientainterpolate.h"
 
20
#include <main/controllers/controladoreventos.h>
 
21
#include <eventos/eventosginkgo.h>
 
22
 
 
23
 
 
24
#ifdef __DEPRECATED
 
25
#undef __DEPRECATED
 
26
#endif
 
27
 
 
28
#include <vtkObject.h>
 
29
#include <vtkSmartPointer.h>
 
30
#include <vtkPointData.h>
 
31
#include <vtkImageData.h>
 
32
#include <vtkLookupTable.h>
 
33
#include <vtkImageActor.h>
 
34
#include <vtkRenderer.h>
 
35
#include <vtkRenderWindow.h>
 
36
#include <vtkRenderWindowInteractor.h>
 
37
#include <vtk/vtkginkgoimageviewer.h>
 
38
#include <resources/ginkgoresourcemanager.h>
 
39
 
 
40
#define SET_INTERPOLATE  1741
 
41
 
 
42
namespace GNC {
 
43
        namespace GUI {
 
44
                class EventHandlerInterpolate: public wxEvtHandler {
 
45
                public:
 
46
                        EventHandlerInterpolate(wxWindow* pParent, GNC::HerramientaInterpolate* pHerramienta):wxEvtHandler()
 
47
                        {
 
48
                                m_pParent = pParent;
 
49
                                m_pHerramienta=pHerramienta;
 
50
                                m_pParent->Connect(SET_INTERPOLATE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( EventHandlerInterpolate::OnSetIntepolateClick),NULL,this);
 
51
                                m_pParent->Connect(SET_INTERPOLATE, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(EventHandlerInterpolate::OnSetIntepolateUI),NULL,this);
 
52
 
 
53
                        }
 
54
                        ~EventHandlerInterpolate()
 
55
                        {
 
56
                                m_pParent->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( EventHandlerInterpolate::OnSetIntepolateClick),NULL,this);
 
57
                                m_pParent->Disconnect(wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(EventHandlerInterpolate::OnSetIntepolateUI),NULL,this);
 
58
                                m_pParent = NULL;
 
59
                                m_pHerramienta = NULL;
 
60
                        }
 
61
 
 
62
                        void OnSetIntepolateClick( wxCommandEvent& event )
 
63
                        {
 
64
                                m_pHerramienta->SolicitarActivacion();
 
65
                                event.Skip(false);
 
66
                        }
 
67
 
 
68
                        void OnSetIntepolateUI(wxUpdateUIEvent& event) {
 
69
                                if(m_pHerramienta->IsSet()) {
 
70
                                        event.SetText(_("Unset pixels bluring"));
 
71
                                } else {
 
72
                                        event.SetText(_("Set pixels bluring"));
 
73
                                }
 
74
                                event.Enable(m_pHerramienta->Habilitada());
 
75
                        }
 
76
 
 
77
                        GNC::HerramientaInterpolate* m_pHerramienta;
 
78
                        wxWindow* m_pParent;
 
79
                };
 
80
                class MenuHerramientaInterpolate : public wxMenuItem {
 
81
                public:
 
82
                        MenuHerramientaInterpolate(wxWindow* pParent, wxMenu* pMenuPadre, GNC::HerramientaInterpolate* pHerramienta):wxMenuItem(pMenuPadre,SET_INTERPOLATE,wxT("Mostrar las anotaciones de la ventana"),wxT("Mostrar las anotaciones de la ventana"),wxITEM_NORMAL) {
 
83
                                pEventHandler = new EventHandlerInterpolate(pParent,pHerramienta);
 
84
                                #ifdef __WXMSW__
 
85
                                SetBitmaps(GinkgoResourcesManager::IconosHerramientas::GetIcoCornerAnnotations());
 
86
                                #else
 
87
                                        SetBitmap(GinkgoResourcesManager::IconosHerramientas::GetIcoCornerAnnotations());
 
88
                                #endif
 
89
                        }
 
90
 
 
91
                        ~MenuHerramientaInterpolate() {
 
92
                                if(pEventHandler != NULL) {
 
93
                                        delete pEventHandler;
 
94
                                        pEventHandler = NULL;
 
95
                                }
 
96
                        }
 
97
 
 
98
                        EventHandlerInterpolate* pEventHandler;
 
99
                };
 
100
        }
 
101
}
 
102
 
 
103
//----------------------------------------------------------------------
 
104
 
 
105
GNC::HerramientaInterpolate::HerramientaInterpolate()
 
106
{
 
107
        m_Descripcion = _Std("Pixels bluring");
 
108
        m_IsMenu = true;
 
109
        m_Icono = GinkgoResourcesManager::IconosHerramientas::GetIcoCornerAnnotations();
 
110
}
 
111
 
 
112
GNC::HerramientaInterpolate::~HerramientaInterpolate()
 
113
{
 
114
}
 
115
 
 
116
bool GNC::HerramientaInterpolate::AppendInMenu(wxWindow* pParent, wxMenu* pMenuParent)
 
117
{
 
118
        pMenuParent->Append(new GNC::GUI::MenuHerramientaInterpolate(pParent,pMenuParent,this));
 
119
        return true;
 
120
}
 
121
 
 
122
//region "Realizacion de la interfaz IHerramienta"
 
123
 
 
124
void GNC::HerramientaInterpolate::CrearPaneles( wxPanel* /*panel*/ )
 
125
{
 
126
        m_pAbstractPanelHerramientaOpciones =  NULL;
 
127
}
 
128
 
 
129
bool GNC::HerramientaInterpolate::IsSet()
 
130
{
 
131
        bool isSet = false;
 
132
        if(TContratableWidgets::m_pVistaActiva != NULL && TContratableWidgets::m_pListaActiva != NULL) {
 
133
                for (TContratableWidgets::IteradorListaContratos it1 = TContratableWidgets::m_pListaActiva->begin(); it1 != TContratableWidgets::m_pListaActiva->end(); it1++) {
 
134
                        TContratoWidgets* pCW = (*it1);
 
135
                        isSet = pCW->GetViewer()->GetInterpolationMode() == VTK_LINEAR_INTERPOLATION;
 
136
                }
 
137
        }
 
138
        return isSet;
 
139
}
 
140
 
 
141
void GNC::HerramientaInterpolate::SolicitarActivacion()
 
142
{
 
143
        GTRACE("GNC::HerramientaInterpolate::Resetear()");
 
144
        for (TContratableWidgets::IteradorListaContratos it1 = TContratableWidgets::m_pListaActiva->begin(); it1 != TContratableWidgets::m_pListaActiva->end(); it1++) {
 
145
                TContratoWidgets* pCW = (*it1);
 
146
                // Copio la lista
 
147
                if (pCW->Inicializado()) {
 
148
                        if (pCW->GetViewer()->GetInterpolationMode() == VTK_LINEAR_INTERPOLATION) {
 
149
                                pCW->GetViewer()->SetInterpolationMode(VTK_NEAREST_INTERPOLATION);
 
150
                        } else {
 
151
                                pCW->GetViewer()->SetInterpolationMode(VTK_LINEAR_INTERPOLATION);
 
152
                        }
 
153
                        GNC::GCS::ControladorEventos::Instance()->ProcesarEvento(new GNC::GCS::Eventos::EventoRender(TContratableWidgets::m_pVistaActiva));
 
154
                }
 
155
        }
 
156
}
 
157
 
 
158
void GNC::HerramientaInterpolate::ConectarContratoFalso(bool ) {
 
159
        if (TContratableWidgets::m_pListaActiva == NULL) {
 
160
                //std::cerr << "Error: Se trato de activar el modo deshabilitado de una vista sin haber asignado la vista activa. Error en la logica de activacion. Accion ignorada" << std::endl;
 
161
                return;
 
162
        }
 
163
 
 
164
}
 
165
 
 
166
void GNC::HerramientaInterpolate::SetVistaActiva(GNC::GCS::IVista* pVista) {
 
167
        TContratableWidgets::EstablecerVistaActiva(pVista);
 
168
        GTRACE("GNC::HerramientaReset::EstablecerVistaActiva(pVista);::SetVistaActiva(" <<  pVista << ")");
 
169
}
 
170
 
 
171
// FIXME: Aviso!!!! para que funcione deben contratarse contratos pareados obligatorios y en el mismo orden
 
172
void GNC::HerramientaInterpolate::ConectarContratos(bool )
 
173
{
 
174
        if (TContratableWidgets::m_pListaActiva == NULL) {
 
175
                std::cerr << "Error: Se trataron de conectar contratos sin haber asignado la vista activa. Error en la logica de activacion. Accion ignorada" << std::endl;
 
176
                return;
 
177
        }
 
178
 
 
179
}
 
180
 
 
181
//endregion
 
182
 
 
183
 
 
184