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();
67 void wxWidgetVOI::initializeVOIWidget(){
68 wxSizer* sizer = this->GetSizer();
71 /// \TODO fix deprecated warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated (declared at /usr/include/wx-2.8/wx/sizer.h:513)
72 if(mcontourvoiwidget!=NULL){
73 sizer->Remove( mcontourvoiwidget );
74 mcontourvoiwidget->Destroy();
77 mcontourvoiwidget = new ContourVOIWidget( this, wxvtkbaseview, imagedata );
78 mcontourvoiwidget->ConfigureVTK();
80 sizer -> Add( mcontourvoiwidget,1,wxGROW );
81 // wxwidget = new wxMPRWidget2( panel, marimagedata , 1 );
82 // wxwidget->ConfigureVTK();
87 void wxWidgetVOI::setBaseView(wxVtkBaseView * wxvtkbaseview){
88 this->wxvtkbaseview = wxvtkbaseview;
90 void wxWidgetVOI::setImageData(vtkImageData * imagedata){
91 this->imagedata = imagedata;
95 //--------------------------------------------------------------------------
96 wxWidgetVOI::~wxWidgetVOI()
100 //--------------------------------------------------------------------------
101 void wxWidgetVOI::Refresh()
103 // wxwidget->RefreshView();
106 //--------------------------------------------------------------------------
110 void wxWidgetVOI::OnRefreshView(wxCommandEvent &event)
113 if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
116 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
117 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
118 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
119 mbbViewerMPR->bbSetOutputPoint(point);
120 mbbViewerMPR->bbSetModifiedStatus();
121 wxwidget->RefreshView();
126 //--------------------------------------------------------------------------
127 void wxWidgetVOI::OnDClickLeft(wxCommandEvent & event)
129 // wxwidget->RefreshView();
132 //------------------------------------------------------
133 ContourVOIWidget* wxWidgetVOI::GetContourVOIWidget()
135 return mcontourvoiwidget;
138 //--------------------------------------------------------------------------------------------------------------------------------
140 //------------------------------------------------------
141 //------------------------------------------------------
142 //------------------------------------------------------
145 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourVOI)
146 BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox);
148 //------------------------------------------------------
149 void ContourVOI::Process()
152 /*if (bbGetInputwxVtkBaseView()==NULL)
154 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
156 if (bbGetInputIn()==NULL)
158 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'In' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
161 vtkImageData* img = bbGetInputIn();
162 wxVtkBaseView* base = bbGetInputwxVtkBaseView();
164 wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget();
166 if(base !=NULL && img != NULL && _img != img){
171 wxwidgetvoi->setBaseView(base);
172 wxwidgetvoi->setImageData(img);
173 wxwidgetvoi->initializeVOIWidget();
176 if (wxwidgetvoi!=NULL && _img!=NULL && _base != NULL){
177 ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget();
180 contourvoiwidget->GetVOI(voi);
182 sprintf(buffer,"%d %d %d ", voi[0], voi[2], voi[4] );
183 std::string Index(buffer);
184 sprintf(buffer,"%d %d %d ", voi[1]-voi[0]+1, voi[3]-voi[2]+1, voi[5]-voi[4]+1 );
185 std::string Size(buffer);
187 std::cout<<"ContourVOI index "<<Index<<" size "<<Size<<std::endl;
190 This go out of the box ... see ExtractVtkImageFilter ...
196 _extract = vtkExtractVOI::New();
197 _extract->RemoveAllInputs();
198 _extract->SetInput(img);
199 _extract->SetVOI(voi);
200 _extract->UpdateWholeExtent();
202 bbSetOutputVOI(_extract->GetOutput());
206 bbSetOutputIndex( Index );
207 bbSetOutputSize( Size );
211 //------------------------------------------------------
212 void ContourVOI::CreateWidget(wxWindow* parent)
214 bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
215 wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
216 bbSetOutputWidget(mwxwidget);
217 bbtkDebugDecTab("Core",9);
218 this->bbSignalOutputModification();
223 //------------------------------------------------------
224 void ContourVOI::bbUserSetDefaultValues()
228 //EED 20Juin2011 _extract =NULL;
229 bbSetInputwxVtkBaseView(NULL);
231 bbSetOutputWidget(NULL);
232 bbSetOutputVOI(NULL);
235 bbSetInputwxVtkBaseView(NULL);
239 //-----------------------------------------------------------------
240 void ContourVOI::bbUserInitializeProcessing()
244 //-----------------------------------------------------------------
245 void ContourVOI::bbUserFinalizeProcessing()
249 //-----------------------------------------------------------------
252 // EO namespace bbcreaMaracasVisu