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"));
72 wxMaracas_N_ViewersWidget::OnRefreshView(event);
76 //-------------------------------------------------------------
77 void bbwxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event)
79 wxMaracas_N_ViewersWidget::OnDClickLeft(event);
80 mbbViewerNV->bbSignalOutputModification(std::string("Point"));
83 //-------------------------------------------------------------
84 //-------------------------------------------------------------
85 //-------------------------------------------------------------
89 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerNV)
90 BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNV,bbtk::WxBlackBox);
91 //-------------------------------------------------------------
92 void ViewerNV::Process()
94 vtkImageData* img = bbGetInputIn();
95 std::vector<int> type = bbGetInputnTypeView();
96 if(img != NULL && _mwxwidget != NULL)
98 if(!compareVectors(type, _currenttype))
100 _mwxwidget->SetType(&type);
101 _mwxwidget->UpdateLayout(img);
102 }else if (img != _currentimg){
103 _mwxwidget->SetImage(img);
105 // _mwxwidget->RefreshView();
109 _point.push_back( (int)_mwxwidget->GetX() );
110 _point.push_back( (int)_mwxwidget->GetY() );
111 _point.push_back( (int)_mwxwidget->GetZ() );
112 bbSetOutputPoint( _point );
114 wxVtkBaseView *wvbv1 = _mwxwidget->GetwxVtkBaseView( 1 );
115 wxVtkBaseView *wvbv2 = _mwxwidget->GetwxVtkBaseView( 2 );
116 wxVtkBaseView *wvbv3 = _mwxwidget->GetwxVtkBaseView( 3 );
117 wxVtkBaseView *wvbv4 = _mwxwidget->GetwxVtkBaseView( 4 );
118 //wxwidget->RefreshView();
119 bbSetOutputwxVtkBaseView1( wvbv1 );
120 bbSetOutputwxVtkBaseView2( wvbv2 );
121 bbSetOutputwxVtkBaseView3( wvbv3 );
122 bbSetOutputwxVtkBaseView4( wvbv4 );
123 if (wvbv1!=NULL) { bbSetOutputRenderer1( wvbv1->GetRenderer() ); }
124 if (wvbv2!=NULL) { bbSetOutputRenderer2( wvbv2->GetRenderer() ); }
125 if (wvbv3!=NULL) { bbSetOutputRenderer3( wvbv3->GetRenderer() ); }
126 if (wvbv4!=NULL) { bbSetOutputRenderer4( wvbv4->GetRenderer() ); }
129 bbSetOutputInteractor1( wvbv1->GetWxVTKRenderWindowInteractor() );
132 if(bbGetInputColorFunction()!=NULL)
134 _mwxwidget->setColorTransferFunction(bbGetInputColorFunction());
136 if( (bbGetInputColorLevel()!=-1) && (bbGetInputWindowLevel()!=-1))
138 if(bbGetInputColorLevel() == 0)
140 _mwxwidget->SetColorWindowLevel( bbGetInputWindowLevel() , 0.1 );
142 _mwxwidget->SetColorWindowLevel( bbGetInputWindowLevel() , bbGetInputColorLevel() );
145 _mwxwidget->SetInterpolate( bbGetInputInterpolate() );
149 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh
150 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
151 #if wxMAJOR_VERSION <= 2
152 wvbv1->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessEvent( newevent );
154 wvbv1->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessWindowEvent( newevent );
159 }// mwxwidget != NULL
162 //-------------------------------------------------------------
163 void ViewerNV::CreateWidget(wxWindow* parent)
165 bbtkDebugMessageInc("Core",9,"ViewerNV::CreateWidget()"<<std::endl);
166 _mwxwidget = new bbwxMaracas_N_ViewersWidget( this, parent );
167 bbtkDebugDecTab("Core",9);
168 bbSetOutputWidget( _mwxwidget );
169 //this->bbSignalOutputModification();
173 //-------------------------------------------------------------
174 void ViewerNV::bbUserSetDefaultValues()
180 bbSetInputObs1(NULL);
181 bbSetInputObs2(NULL);
182 bbSetInputObs3(NULL);
183 bbSetInputObs4(NULL);
184 bbSetInputObs5(NULL);
185 bbSetInputInterpolate(true);
187 std::vector<int> vecNTypeViwer;
188 vecNTypeViwer.push_back(5);
189 vecNTypeViwer.push_back(1);
190 vecNTypeViwer.push_back(2);
191 vecNTypeViwer.push_back(0);
192 bbSetInputnTypeView(vecNTypeViwer);
194 bbSetOutputwxVtkBaseView1( NULL );
195 bbSetOutputwxVtkBaseView2( NULL );
196 bbSetOutputwxVtkBaseView3( NULL );
197 bbSetOutputwxVtkBaseView4( NULL );
198 bbSetOutputRenderer1( NULL );
199 bbSetOutputRenderer2( NULL );
200 bbSetOutputRenderer3( NULL );
201 bbSetOutputRenderer4( NULL );
202 bbSetInputColorFunction(NULL);
203 bbSetInputWindowLevel(-1);
204 bbSetInputColorLevel(-1);
207 //-----------------------------------------------------------------
208 void ViewerNV::bbUserInitializeProcessing()
212 //-----------------------------------------------------------------
213 void ViewerNV::bbUserFinalizeProcessing()
217 //-----------------------------------------------------------------
219 bool ViewerNV::compareVectors(std::vector<int> type,std::vector<int> currenttype)
222 if(type.size()==currenttype.size())
224 for(int i = 0; i < (int)(type.size()) && ret; i++)
226 if(type[i]!=currenttype[i])
237 void ViewerNV::updateObservers()
239 vtkRenderWindowInteractor* interactor;
240 interactor = bbGetOutputInteractor1();
243 if (bbGetInputObs1()!=NULL)
245 bbGetInputObs1()->SetInteractor(interactor);
246 bbGetInputObs1()->EnabledOn();
248 if (bbGetInputObs2()!=NULL)
250 bbGetInputObs2()->SetInteractor(interactor);
251 bbGetInputObs2()->EnabledOn();
253 if (bbGetInputObs3()!=NULL)
255 bbGetInputObs3()->SetInteractor(interactor);
256 bbGetInputObs3()->EnabledOn();
258 if (bbGetInputObs4()!=NULL)
260 bbGetInputObs4()->SetInteractor(interactor);
261 bbGetInputObs4()->EnabledOn();
263 if (bbGetInputObs5()!=NULL)
265 bbGetInputObs5()->SetInteractor(interactor);
266 bbGetInputObs5()->EnabledOn();
272 // EO namespace bbcreaMaracasVisu