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();
92 printf ("EED ViewerNV::Process A %f %f %f \n", spc[0], spc[1], spc[2] );
93 img->SetSpacing( 1,1,1 );
96 img->PrintSelf(std::cout,(vtkIndent)2);
97 img->Print(std::cout);
98 printf ("EED ViewerNV::Process B %f %f %f \n", spc[0], spc[1], spc[2] );
100 std::vector<int> type = bbGetInputnTypeView();
103 if(img != NULL && _mwxwidget != NULL){
104 if(!compareVectors(type, _currenttype)){
105 _mwxwidget->SetType(&type);
106 _mwxwidget->UpdateLayout(img);
107 }else if (img != _currentimg){
108 _mwxwidget->SetImage(img);
111 _mwxwidget->RefreshView();
117 _point.push_back((int)_mwxwidget->GetX());
118 _point.push_back((int)_mwxwidget->GetY());
119 _point.push_back((int)_mwxwidget->GetZ());
120 bbSetOutputPoint(_point);
122 // WxBlackBox::Process();
123 // mwxwidget->SetImage(img );
124 wxVtkBaseView *wvbv1 = _mwxwidget->GetwxVtkBaseView(1);
125 wxVtkBaseView *wvbv2 = _mwxwidget->GetwxVtkBaseView(2);
126 wxVtkBaseView *wvbv3 = _mwxwidget->GetwxVtkBaseView(3);
127 wxVtkBaseView *wvbv4 = _mwxwidget->GetwxVtkBaseView(4);
129 //wxwidget->RefreshView();
131 bbSetOutputwxVtkBaseView1( wvbv1 );
132 bbSetOutputwxVtkBaseView2( wvbv2 );
133 bbSetOutputwxVtkBaseView3( wvbv3 );
134 bbSetOutputwxVtkBaseView4( wvbv4 );
135 if (wvbv1!=NULL) { bbSetOutputRenderer1( wvbv1->GetRenderer() ); }
136 if (wvbv2!=NULL) { bbSetOutputRenderer2( wvbv2->GetRenderer() ); }
137 if (wvbv3!=NULL) { bbSetOutputRenderer3( wvbv3->GetRenderer() ); }
138 if (wvbv4!=NULL) { bbSetOutputRenderer4( wvbv4->GetRenderer() ); }
142 bbSetOutputInteractor1( wvbv1->GetWxVTKRenderWindowInteractor() );
146 if(bbGetInputColorFunction()!=NULL)
148 _mwxwidget->setColorTransferFunction(bbGetInputColorFunction());
152 if( (bbGetInputColorLevel()!=-1) && (bbGetInputWindowLevel()!=-1))
154 if(bbGetInputColorLevel() == 0)
156 _mwxwidget->SetColorWindowLevel( bbGetInputWindowLevel() , 0.1 );
158 _mwxwidget->SetColorWindowLevel( bbGetInputWindowLevel() , bbGetInputColorLevel() );
161 }// mwxwidget != NULL
164 //-------------------------------------------------------------
165 void ViewerNV::CreateWidget(wxWindow* parent)
167 bbtkDebugMessageInc("Core",9,"ViewerNV::CreateWidget()"<<std::endl);
168 _mwxwidget = new bbwxMaracas_N_ViewersWidget( this, parent );
169 bbtkDebugDecTab("Core",9);
170 bbSetOutputWidget( _mwxwidget );
171 //this->bbSignalOutputModification();
175 //-------------------------------------------------------------
176 void ViewerNV::bbUserSetDefaultValues()
182 bbSetInputObs1(NULL);
183 bbSetInputObs2(NULL);
184 bbSetInputObs3(NULL);
185 bbSetInputObs4(NULL);
186 bbSetInputObs5(NULL);
188 std::vector<int> vecNTypeViwer;
189 vecNTypeViwer.push_back(5);
190 vecNTypeViwer.push_back(1);
191 vecNTypeViwer.push_back(2);
192 vecNTypeViwer.push_back(0);
193 bbSetInputnTypeView(vecNTypeViwer);
195 bbSetOutputwxVtkBaseView1( NULL );
196 bbSetOutputwxVtkBaseView2( NULL );
197 bbSetOutputwxVtkBaseView3( NULL );
198 bbSetOutputwxVtkBaseView4( NULL );
199 bbSetOutputRenderer1( NULL );
200 bbSetOutputRenderer2( NULL );
201 bbSetOutputRenderer3( NULL );
202 bbSetOutputRenderer4( NULL );
203 bbSetInputColorFunction(NULL);
204 bbSetInputWindowLevel(-1);
205 bbSetInputColorLevel(-1);
208 //-----------------------------------------------------------------
209 void ViewerNV::bbUserInitializeProcessing()
213 //-----------------------------------------------------------------
214 void ViewerNV::bbUserFinalizeProcessing()
218 //-----------------------------------------------------------------
222 bool ViewerNV::compareVectors(std::vector<int> type,std::vector<int> currenttype){
226 if(type.size()==currenttype.size()){
227 for(int i = 0; i < (int)(type.size()) && ret; i++){
228 if(type[i]!=currenttype[i]){
238 void ViewerNV::updateObservers(){
239 vtkRenderWindowInteractor* interactor;
240 interactor = bbGetOutputInteractor1();
242 if (bbGetInputObs1()!=NULL){
243 bbGetInputObs1()->SetInteractor(interactor);
244 bbGetInputObs1()->EnabledOn();
246 if (bbGetInputObs2()!=NULL)
248 bbGetInputObs2()->SetInteractor(interactor);
249 bbGetInputObs2()->EnabledOn();
251 if (bbGetInputObs3()!=NULL)
253 bbGetInputObs3()->SetInteractor(interactor);
254 bbGetInputObs3()->EnabledOn();
256 if (bbGetInputObs4()!=NULL)
258 bbGetInputObs4()->SetInteractor(interactor);
259 bbGetInputObs4()->EnabledOn();
261 if (bbGetInputObs5()!=NULL)
263 bbGetInputObs5()->SetInteractor(interactor);
264 bbGetInputObs5()->EnabledOn();
270 // EO namespace bbcreaMaracasVisu