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)
50 //-------------------------------------------------------------
51 bbwxMaracas_N_ViewersWidget::~bbwxMaracas_N_ViewersWidget()
55 //-------------------------------------------------------------
56 void bbwxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event)
58 //printf("CPR: bbwxMaracas_N_ViewersWidget::OnRefreshView -> actualiza X, Y y Z\n");
59 mbbViewerNV->_point.clear();
61 mbbViewerNV->_point.push_back( (int)GetX() );
62 mbbViewerNV->_point.push_back( (int)GetY() );
63 mbbViewerNV->_point.push_back( (int)GetZ() );
64 mbbViewerNV->bbSetOutputPoint( mbbViewerNV->_point );
65 mbbViewerNV->bbSignalOutputModification(std::string("Point"));
67 wxMaracas_N_ViewersWidget::OnRefreshView(event);
70 //-------------------------------------------------------------
71 void bbwxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event)
73 wxMaracas_N_ViewersWidget::OnDClickLeft(event);
74 mbbViewerNV->bbSignalOutputModification(std::string("Point"));
77 //-------------------------------------------------------------
78 //-------------------------------------------------------------
79 //-------------------------------------------------------------
83 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ViewerNV)
84 BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNV,bbtk::WxBlackBox);
85 //-------------------------------------------------------------
86 void ViewerNV::Process()
88 vtkImageData* img = bbGetInputIn();
91 std::vector<int> type = bbGetInputnTypeView();
94 if(img != NULL && _mwxwidget != NULL){
95 if(!compareVectors(type, _currenttype)){
96 _mwxwidget->SetType(&type);
97 _mwxwidget->UpdateLayout(img);
98 }else if (img != _currentimg){
99 _mwxwidget->SetImage(img);
101 _mwxwidget->RefreshView();
107 _point.push_back((int)_mwxwidget->GetX());
108 _point.push_back((int)_mwxwidget->GetY());
109 _point.push_back((int)_mwxwidget->GetZ());
110 bbSetOutputPoint(_point);
112 // WxBlackBox::Process();
113 // mwxwidget->SetImage(img );
114 wxVtkBaseView *wvbv1 = _mwxwidget->GetwxVtkBaseView(1);
115 wxVtkBaseView *wvbv2 = _mwxwidget->GetwxVtkBaseView(2);
116 wxVtkBaseView *wvbv3 = _mwxwidget->GetwxVtkBaseView(3);
117 wxVtkBaseView *wvbv4 = _mwxwidget->GetwxVtkBaseView(4);
119 //wxwidget->RefreshView();
121 bbSetOutputwxVtkBaseView1( wvbv1 );
122 bbSetOutputwxVtkBaseView2( wvbv2 );
123 bbSetOutputwxVtkBaseView3( wvbv3 );
124 bbSetOutputwxVtkBaseView4( wvbv4 );
125 if (wvbv1!=NULL) { bbSetOutputRenderer1( wvbv1->GetRenderer() ); }
126 if (wvbv2!=NULL) { bbSetOutputRenderer2( wvbv2->GetRenderer() ); }
127 if (wvbv3!=NULL) { bbSetOutputRenderer3( wvbv3->GetRenderer() ); }
128 if (wvbv4!=NULL) { bbSetOutputRenderer4( wvbv4->GetRenderer() ); }
132 bbSetOutputInteractor1( wvbv1->GetWxVTKRenderWindowInteractor() );
136 if(bbGetInputColorFunction()!=NULL)
138 _mwxwidget->setColorTransferFunction(bbGetInputColorFunction());
142 if( (bbGetInputColorLevel()!=-1) && (bbGetInputWindowLevel()!=-1))
144 if(bbGetInputColorLevel() == 0)
146 _mwxwidget->SetColorWindowLevel( bbGetInputWindowLevel() , 0.1 );
148 _mwxwidget->SetColorWindowLevel( bbGetInputWindowLevel() , bbGetInputColorLevel() );
151 }// mwxwidget != NULL
154 //-------------------------------------------------------------
155 void ViewerNV::CreateWidget(wxWindow* parent)
157 bbtkDebugMessageInc("Core",9,"ViewerNV::CreateWidget()"<<std::endl);
158 _mwxwidget = new bbwxMaracas_N_ViewersWidget( this, parent );
159 bbtkDebugDecTab("Core",9);
160 bbSetOutputWidget( _mwxwidget );
161 //this->bbSignalOutputModification();
165 //-------------------------------------------------------------
166 void ViewerNV::bbUserSetDefaultValues()
172 bbSetInputObs1(NULL);
173 bbSetInputObs2(NULL);
174 bbSetInputObs3(NULL);
175 bbSetInputObs4(NULL);
176 bbSetInputObs5(NULL);
178 std::vector<int> vecNTypeViwer;
179 vecNTypeViwer.push_back(5);
180 vecNTypeViwer.push_back(1);
181 vecNTypeViwer.push_back(2);
182 vecNTypeViwer.push_back(0);
183 bbSetInputnTypeView(vecNTypeViwer);
185 bbSetOutputwxVtkBaseView1( NULL );
186 bbSetOutputwxVtkBaseView2( NULL );
187 bbSetOutputwxVtkBaseView3( NULL );
188 bbSetOutputwxVtkBaseView4( NULL );
189 bbSetOutputRenderer1( NULL );
190 bbSetOutputRenderer2( NULL );
191 bbSetOutputRenderer3( NULL );
192 bbSetOutputRenderer4( NULL );
193 bbSetInputColorFunction(NULL);
194 bbSetInputWindowLevel(-1);
195 bbSetInputColorLevel(-1);
198 //-----------------------------------------------------------------
199 void ViewerNV::bbUserInitializeProcessing()
203 //-----------------------------------------------------------------
204 void ViewerNV::bbUserFinalizeProcessing()
208 //-----------------------------------------------------------------
212 bool ViewerNV::compareVectors(std::vector<int> type,std::vector<int> currenttype){
216 if(type.size()==currenttype.size()){
217 for(int i = 0; i < (int)(type.size()) && ret; i++){
218 if(type[i]!=currenttype[i]){
228 void ViewerNV::updateObservers(){
229 vtkRenderWindowInteractor* interactor;
230 interactor = bbGetOutputInteractor1();
232 if (bbGetInputObs1()!=NULL){
233 bbGetInputObs1()->SetInteractor(interactor);
234 bbGetInputObs1()->EnabledOn();
236 if (bbGetInputObs2()!=NULL)
238 bbGetInputObs2()->SetInteractor(interactor);
239 bbGetInputObs2()->EnabledOn();
241 if (bbGetInputObs3()!=NULL)
243 bbGetInputObs3()->SetInteractor(interactor);
244 bbGetInputObs3()->EnabledOn();
246 if (bbGetInputObs4()!=NULL)
248 bbGetInputObs4()->SetInteractor(interactor);
249 bbGetInputObs4()->EnabledOn();
251 if (bbGetInputObs5()!=NULL)
253 bbGetInputObs5()->SetInteractor(interactor);
254 bbGetInputObs5()->EnabledOn();
260 // EO namespace bbcreaMaracasVisu