1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "bbmaracasvisuViewerNV.h"
27 #include "bbcreaMaracasVisuPackage.h"
28 namespace bbcreaMaracasVisu
31 BEGIN_EVENT_TABLE( bbwxMaracas_N_ViewersWidget, wxPanel )
32 EVT_MENU( 12121, bbwxMaracas_N_ViewersWidget::OnRefreshView )
33 EVT_MENU( 12122, bbwxMaracas_N_ViewersWidget::OnDClickLeft )
37 //-------------------------------------------------------------
38 //-------------------------------------------------------------
39 //-------------------------------------------------------------
41 bbwxMaracas_N_ViewersWidget::bbwxMaracas_N_ViewersWidget(ViewerNV* box,
43 vtkImageData* imagedata,
44 std::vector<int> *nTypeView)
45 :wxMaracas_N_ViewersWidget(parent,imagedata,nTypeView)
53 //-------------------------------------------------------------
54 bbwxMaracas_N_ViewersWidget::~bbwxMaracas_N_ViewersWidget()
58 //-------------------------------------------------------------
59 void bbwxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event)
61 if ( (backX!=(int)GetX()) || (backY!=(int)GetY()) || (backZ!=(int)GetZ()) )
66 mbbViewerNV->_point.clear();
67 mbbViewerNV->_point.push_back( (int)GetX() );
68 mbbViewerNV->_point.push_back( (int)GetY() );
69 mbbViewerNV->_point.push_back( (int)GetZ() );
70 mbbViewerNV->bbSetOutputPoint( mbbViewerNV->_point );
71 mbbViewerNV->bbSignalOutputModification(std::string("Point"));
73 wxMaracas_N_ViewersWidget::OnRefreshView(event);
76 //-------------------------------------------------------------
77 void bbwxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event)
79 printf("EED bbwxMaracas_N_ViewersWidget::OnDClickLeft 1\n");
80 wxMaracas_N_ViewersWidget::OnDClickLeft(event);
81 printf("EED bbwxMaracas_N_ViewersWidget::OnDClickLeft 2\n");
82 mbbViewerNV->bbSignalOutputModification(std::string("Point"));
83 printf("EED bbwxMaracas_N_ViewersWidget::OnDClickLeft 3\n");
86 //-------------------------------------------------------------
87 //-------------------------------------------------------------
88 //-------------------------------------------------------------
92 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerNV)
93 BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNV,bbtk::WxBlackBox);
94 //-------------------------------------------------------------
95 void ViewerNV::Process()
97 vtkImageData* img = bbGetInputIn();
98 std::vector<int> type = bbGetInputnTypeView();
99 if(img != NULL && _mwxwidget != NULL)
101 if(!compareVectors(type, _currenttype))
103 _mwxwidget->SetType(&type);
104 _mwxwidget->SetTDxWindow( bbGetInputTDxWindow() );
105 _mwxwidget->UpdateLayout(img);
106 }else if (img != _currentimg){
107 _mwxwidget->SetImage(img);
109 // _mwxwidget->RefreshView();
113 _point.push_back( (int)_mwxwidget->GetX() );
114 _point.push_back( (int)_mwxwidget->GetY() );
115 _point.push_back( (int)_mwxwidget->GetZ() );
116 bbSetOutputPoint( _point );
118 wxVtkBaseView *wvbv1 = _mwxwidget->GetwxVtkBaseView( 1 );
119 wxVtkBaseView *wvbv2 = _mwxwidget->GetwxVtkBaseView( 2 );
120 wxVtkBaseView *wvbv3 = _mwxwidget->GetwxVtkBaseView( 3 );
121 wxVtkBaseView *wvbv4 = _mwxwidget->GetwxVtkBaseView( 4 );
122 //wxwidget->RefreshView();
123 bbSetOutputwxVtkBaseView1( wvbv1 );
124 bbSetOutputwxVtkBaseView2( wvbv2 );
125 bbSetOutputwxVtkBaseView3( wvbv3 );
126 bbSetOutputwxVtkBaseView4( wvbv4 );
127 if (wvbv1!=NULL) { bbSetOutputRenderer1( wvbv1->GetRenderer() ); }
128 if (wvbv2!=NULL) { bbSetOutputRenderer2( wvbv2->GetRenderer() ); }
129 if (wvbv3!=NULL) { bbSetOutputRenderer3( wvbv3->GetRenderer() ); }
130 if (wvbv4!=NULL) { bbSetOutputRenderer4( wvbv4->GetRenderer() ); }
133 bbSetOutputInteractor1( wvbv1->GetWxVTKRenderWindowInteractor() );
136 if(bbGetInputColorFunction()!=NULL)
138 _mwxwidget->setColorTransferFunction(bbGetInputColorFunction());
140 if( (bbGetInputColorLevel()!=-1) && (bbGetInputWindowLevel()!=-1))
142 if(bbGetInputColorLevel() == 0)
144 _mwxwidget->SetColorWindowLevel( bbGetInputWindowLevel() , 0.1 );
146 _mwxwidget->SetColorWindowLevel( bbGetInputWindowLevel() , bbGetInputColorLevel() );
149 _mwxwidget->SetInterpolate( bbGetInputInterpolate() );
153 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
154 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
155 #if wxMAJOR_VERSION <= 2
156 wvbv1->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessEvent( newevent );
158 wvbv1->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessWindowEvent( newevent );
163 }// mwxwidget != NULL
166 //-------------------------------------------------------------
167 void ViewerNV::CreateWidget(wxWindow* parent)
169 bbtkDebugMessageInc("Core",9,"ViewerNV::CreateWidget()"<<std::endl);
170 _mwxwidget = new bbwxMaracas_N_ViewersWidget( this, parent );
171 bbtkDebugDecTab("Core",9);
172 bbSetOutputWidget( _mwxwidget );
173 //this->bbSignalOutputModification();
177 //-------------------------------------------------------------
178 void ViewerNV::bbUserSetDefaultValues()
184 bbSetInputObs1(NULL);
185 bbSetInputObs2(NULL);
186 bbSetInputObs3(NULL);
187 bbSetInputObs4(NULL);
188 bbSetInputObs5(NULL);
189 bbSetInputInterpolate(true);
191 std::vector<int> vecNTypeViwer;
192 vecNTypeViwer.push_back(5);
193 vecNTypeViwer.push_back(1);
194 vecNTypeViwer.push_back(2);
195 vecNTypeViwer.push_back(0);
196 bbSetInputnTypeView(vecNTypeViwer);
197 bbSetInputTDxWindow( -1 );
199 bbSetOutputwxVtkBaseView1( NULL );
200 bbSetOutputwxVtkBaseView2( NULL );
201 bbSetOutputwxVtkBaseView3( NULL );
202 bbSetOutputwxVtkBaseView4( NULL );
203 bbSetOutputRenderer1( NULL );
204 bbSetOutputRenderer2( NULL );
205 bbSetOutputRenderer3( NULL );
206 bbSetOutputRenderer4( NULL );
207 bbSetInputColorFunction(NULL);
208 bbSetInputWindowLevel(-1);
209 bbSetInputColorLevel(-1);
212 //-----------------------------------------------------------------
213 void ViewerNV::bbUserInitializeProcessing()
217 //-----------------------------------------------------------------
218 void ViewerNV::bbUserFinalizeProcessing()
222 //-----------------------------------------------------------------
224 bool ViewerNV::compareVectors(std::vector<int> type,std::vector<int> currenttype)
227 if(type.size()==currenttype.size())
229 for(int i = 0; i < (int)(type.size()) && ret; i++)
231 if(type[i]!=currenttype[i])
242 void ViewerNV::updateObservers()
244 vtkRenderWindowInteractor* interactor;
245 interactor = bbGetOutputInteractor1();
248 if (bbGetInputObs1()!=NULL)
250 bbGetInputObs1()->SetInteractor(interactor);
251 bbGetInputObs1()->EnabledOn();
253 if (bbGetInputObs2()!=NULL)
255 bbGetInputObs2()->SetInteractor(interactor);
256 bbGetInputObs2()->EnabledOn();
258 if (bbGetInputObs3()!=NULL)
260 bbGetInputObs3()->SetInteractor(interactor);
261 bbGetInputObs3()->EnabledOn();
263 if (bbGetInputObs4()!=NULL)
265 bbGetInputObs4()->SetInteractor(interactor);
266 bbGetInputObs4()->EnabledOn();
268 if (bbGetInputObs5()!=NULL)
270 bbGetInputObs5()->SetInteractor(interactor);
271 bbGetInputObs5()->EnabledOn();
277 // EO namespace bbcreaMaracasVisu