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 # ------------------------------------------------------------------------ */
29 #include "bbmaracasvisuContourVOI.h"
30 #include "bbcreaMaracasVisuPackage.h"
34 namespace bbcreaMaracasVisu
37 //--------------------------------------------------------------------------
39 //--------------------------------------------------------------------------
40 BEGIN_EVENT_TABLE( wxWidgetVOI, wxPanel )
41 EVT_MENU( 12121, wxWidgetVOI::OnRefreshView )
42 EVT_MENU( 12122, wxWidgetVOI::OnDClickLeft )
48 wxWidgetVOI::wxWidgetVOI(wxWindow* parent, wxVtkBaseView *wxvtkbaseview, vtkImageData *imagedata)
49 : wxPanel( parent, -1 )
51 // wxPanel *panel = this;
53 wxFlexGridSizer *sizer=new wxFlexGridSizer(1);
54 sizer -> AddGrowableCol(0);
55 this -> SetSizer(sizer);
56 this -> SetAutoLayout(true);
57 this->wxvtkbaseview = NULL;
58 mcontourvoiwidget=NULL;
60 if(wxvtkbaseview!=NULL&&imagedata!=NULL){
62 setBaseView(wxvtkbaseview);
63 setImageData(imagedata);
64 initializeVOIWidget();
68 void wxWidgetVOI::initializeVOIWidget()
70 wxSizer* sizer = this->GetSizer();
73 /// \TODO fix deprecated warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated (declared at /usr/include/wx-2.8/wx/sizer.h:513)
74 if(mcontourvoiwidget!=NULL)
76 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
77 #if wxMAJOR_VERSION <= 2
78 sizer->Remove( mcontourvoiwidget );
80 sizer->Detach( mcontourvoiwidget );
82 mcontourvoiwidget->Destroy();
85 mcontourvoiwidget = new ContourVOIWidget( this, wxvtkbaseview, imagedata );
86 mcontourvoiwidget->ConfigureVTK();
88 sizer -> Add( mcontourvoiwidget,1,wxGROW );
89 // wxwidget = new wxMPRWidget2( panel, marimagedata , 1 );
90 // wxwidget->ConfigureVTK();
95 void wxWidgetVOI::setBaseView(wxVtkBaseView * wxvtkbaseview)
97 this->wxvtkbaseview = wxvtkbaseview;
100 void wxWidgetVOI::setImageData(vtkImageData * imagedata)
102 this->imagedata = imagedata;
106 //--------------------------------------------------------------------------
107 wxWidgetVOI::~wxWidgetVOI()
111 //--------------------------------------------------------------------------
112 void wxWidgetVOI::Refresh()
114 // wxwidget->RefreshView();
117 //--------------------------------------------------------------------------
121 void wxWidgetVOI::OnRefreshView(wxCommandEvent &event)
124 if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
127 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
128 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
129 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
130 mbbViewerMPR->bbSetOutputPoint(point);
131 mbbViewerMPR->bbSetModifiedStatus();
132 wxwidget->RefreshView();
137 //--------------------------------------------------------------------------
138 void wxWidgetVOI::OnDClickLeft(wxCommandEvent & event)
140 // wxwidget->RefreshView();
143 //------------------------------------------------------
144 ContourVOIWidget* wxWidgetVOI::GetContourVOIWidget()
146 return mcontourvoiwidget;
149 //--------------------------------------------------------------------------------------------------------------------------------
151 //------------------------------------------------------
152 //------------------------------------------------------
153 //------------------------------------------------------
156 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourVOI)
157 BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox);
159 //------------------------------------------------------
160 void ContourVOI::Process()
163 /*if (bbGetInputwxVtkBaseView()==NULL)
165 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
167 if (bbGetInputIn()==NULL)
169 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'In' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
172 vtkImageData* img = bbGetInputIn();
173 wxVtkBaseView* base = bbGetInputwxVtkBaseView();
175 wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget();
177 if(base !=NULL && img != NULL && _img != img){
182 wxwidgetvoi->setBaseView(base);
183 wxwidgetvoi->setImageData(img);
184 wxwidgetvoi->initializeVOIWidget();
187 if (wxwidgetvoi!=NULL && _img!=NULL && _base != NULL){
188 ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget();
191 contourvoiwidget->GetVOI(voi);
193 sprintf(buffer,"%d %d %d ", voi[0], voi[2], voi[4] );
194 std::string Index(buffer);
195 sprintf(buffer,"%d %d %d ", voi[1]-voi[0]+1, voi[3]-voi[2]+1, voi[5]-voi[4]+1 );
196 std::string Size(buffer);
198 std::cout<<"ContourVOI index "<<Index<<" size "<<Size<<std::endl;
201 This go out of the box ... see ExtractVtkImageFilter ...
207 _extract = vtkExtractVOI::New();
208 _extract->RemoveAllInputs();
209 _extract->SetInput(img);
210 _extract->SetVOI(voi);
211 _extract->UpdateWholeExtent();
213 bbSetOutputVOI(_extract->GetOutput());
217 bbSetOutputIndex( Index );
218 bbSetOutputSize( Size );
222 //------------------------------------------------------
223 void ContourVOI::CreateWidget(wxWindow* parent)
225 bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
226 wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
227 bbSetOutputWidget(mwxwidget);
228 bbtkDebugDecTab("Core",9);
229 this->bbSignalOutputModification();
234 //------------------------------------------------------
235 void ContourVOI::bbUserSetDefaultValues()
239 //EED 20Juin2011 _extract =NULL;
240 bbSetInputwxVtkBaseView(NULL);
242 bbSetOutputWidget(NULL);
243 bbSetOutputVOI(NULL);
246 bbSetInputwxVtkBaseView(NULL);
250 //-----------------------------------------------------------------
251 void ContourVOI::bbUserInitializeProcessing()
255 //-----------------------------------------------------------------
256 void ContourVOI::bbUserFinalizeProcessing()
260 //-----------------------------------------------------------------
263 // EO namespace bbcreaMaracasVisu