3
* $Id: herramientainterpolate.cpp 4090 2011-08-25 12:17:45Z tovar $
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
14
//#define _GINKGO_TRACE
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>
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>
40
#define SET_INTERPOLATE 1741
44
class EventHandlerInterpolate: public wxEvtHandler {
46
EventHandlerInterpolate(wxWindow* pParent, GNC::HerramientaInterpolate* pHerramienta):wxEvtHandler()
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);
54
~EventHandlerInterpolate()
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);
59
m_pHerramienta = NULL;
62
void OnSetIntepolateClick( wxCommandEvent& event )
64
m_pHerramienta->SolicitarActivacion();
68
void OnSetIntepolateUI(wxUpdateUIEvent& event) {
69
if(m_pHerramienta->IsSet()) {
70
event.SetText(_("Unset pixels bluring"));
72
event.SetText(_("Set pixels bluring"));
74
event.Enable(m_pHerramienta->Habilitada());
77
GNC::HerramientaInterpolate* m_pHerramienta;
80
class MenuHerramientaInterpolate : public wxMenuItem {
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);
85
SetBitmaps(GinkgoResourcesManager::IconosHerramientas::GetIcoCornerAnnotations());
87
SetBitmap(GinkgoResourcesManager::IconosHerramientas::GetIcoCornerAnnotations());
91
~MenuHerramientaInterpolate() {
92
if(pEventHandler != NULL) {
98
EventHandlerInterpolate* pEventHandler;
103
//----------------------------------------------------------------------
105
GNC::HerramientaInterpolate::HerramientaInterpolate()
107
m_Descripcion = _Std("Pixels bluring");
109
m_Icono = GinkgoResourcesManager::IconosHerramientas::GetIcoCornerAnnotations();
112
GNC::HerramientaInterpolate::~HerramientaInterpolate()
116
bool GNC::HerramientaInterpolate::AppendInMenu(wxWindow* pParent, wxMenu* pMenuParent)
118
pMenuParent->Append(new GNC::GUI::MenuHerramientaInterpolate(pParent,pMenuParent,this));
122
//region "Realizacion de la interfaz IHerramienta"
124
void GNC::HerramientaInterpolate::CrearPaneles( wxPanel* /*panel*/ )
126
m_pAbstractPanelHerramientaOpciones = NULL;
129
bool GNC::HerramientaInterpolate::IsSet()
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;
141
void GNC::HerramientaInterpolate::SolicitarActivacion()
143
GTRACE("GNC::HerramientaInterpolate::Resetear()");
144
for (TContratableWidgets::IteradorListaContratos it1 = TContratableWidgets::m_pListaActiva->begin(); it1 != TContratableWidgets::m_pListaActiva->end(); it1++) {
145
TContratoWidgets* pCW = (*it1);
147
if (pCW->Inicializado()) {
148
if (pCW->GetViewer()->GetInterpolationMode() == VTK_LINEAR_INTERPOLATION) {
149
pCW->GetViewer()->SetInterpolationMode(VTK_NEAREST_INTERPOLATION);
151
pCW->GetViewer()->SetInterpolationMode(VTK_LINEAR_INTERPOLATION);
153
GNC::GCS::ControladorEventos::Instance()->ProcesarEvento(new GNC::GCS::Eventos::EventoRender(TContratableWidgets::m_pVistaActiva));
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;
166
void GNC::HerramientaInterpolate::SetVistaActiva(GNC::GCS::IVista* pVista) {
167
TContratableWidgets::EstablecerVistaActiva(pVista);
168
GTRACE("GNC::HerramientaReset::EstablecerVistaActiva(pVista);::SetVistaActiva(" << pVista << ")");
171
// FIXME: Aviso!!!! para que funcione deben contratarse contratos pareados obligatorios y en el mismo orden
172
void GNC::HerramientaInterpolate::ConectarContratos(bool )
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;