4 #include "bbmaracasvisuContourVOI.h"
5 #include "bbcreaMaracasVisuPackage.h"
9 namespace bbcreaMaracasVisu
12 //--------------------------------------------------------------------------
14 //--------------------------------------------------------------------------
15 BEGIN_EVENT_TABLE( wxWidgetVOI, wxPanel )
16 EVT_MENU( 12121, wxWidgetVOI::OnRefreshView )
17 EVT_MENU( 12122, wxWidgetVOI::OnDClickLeft )
23 wxWidgetVOI::wxWidgetVOI(wxWindow* parent, wxVtkBaseView *wxvtkbaseview, vtkImageData *imagedata)
24 : wxPanel( parent, -1 )
26 // wxPanel *panel = this;
28 wxFlexGridSizer *sizer=new wxFlexGridSizer(1);
29 sizer -> AddGrowableCol(0);
30 this -> SetSizer(sizer);
31 this -> SetAutoLayout(true);
32 this->wxvtkbaseview = NULL;
33 mcontourvoiwidget=NULL;
35 if(wxvtkbaseview!=NULL&&imagedata!=NULL){
37 setBaseView(wxvtkbaseview);
38 setImageData(imagedata);
39 initializeVOIWidget();
42 void wxWidgetVOI::initializeVOIWidget(){
43 wxSizer* sizer = this->GetSizer();
46 /// \TODO fix deprecated warning: virtual bool wxSizer::Remove(wxWindow*) is deprecated (declared at /usr/include/wx-2.8/wx/sizer.h:513)
47 if(mcontourvoiwidget!=NULL){
48 sizer->Remove( mcontourvoiwidget );
49 mcontourvoiwidget->Destroy();
52 mcontourvoiwidget = new ContourVOIWidget( this, wxvtkbaseview, imagedata );
53 mcontourvoiwidget->ConfigureVTK();
55 sizer -> Add( mcontourvoiwidget,1,wxGROW );
56 // wxwidget = new wxMPRWidget2( panel, marimagedata , 1 );
57 // wxwidget->ConfigureVTK();
62 void wxWidgetVOI::setBaseView(wxVtkBaseView * wxvtkbaseview){
63 this->wxvtkbaseview = wxvtkbaseview;
65 void wxWidgetVOI::setImageData(vtkImageData * imagedata){
66 this->imagedata = imagedata;
70 //--------------------------------------------------------------------------
71 wxWidgetVOI::~wxWidgetVOI()
75 //--------------------------------------------------------------------------
76 void wxWidgetVOI::Refresh()
78 // wxwidget->RefreshView();
81 //--------------------------------------------------------------------------
85 void wxWidgetVOI::OnRefreshView(wxCommandEvent &event)
88 if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
91 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
92 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
93 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
94 mbbViewerMPR->bbSetOutputPoint(point);
95 mbbViewerMPR->bbSetModifiedStatus();
96 wxwidget->RefreshView();
101 //--------------------------------------------------------------------------
102 void wxWidgetVOI::OnDClickLeft(wxCommandEvent & event)
104 // wxwidget->RefreshView();
107 //------------------------------------------------------
108 ContourVOIWidget* wxWidgetVOI::GetContourVOIWidget()
110 return mcontourvoiwidget;
113 //--------------------------------------------------------------------------------------------------------------------------------
115 //------------------------------------------------------
116 //------------------------------------------------------
117 //------------------------------------------------------
120 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourVOI)
121 BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox);
123 //------------------------------------------------------
124 void ContourVOI::Process()
127 /*if (bbGetInputwxVtkBaseView()==NULL)
129 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
131 if (bbGetInputIn()==NULL)
133 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'In' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
136 vtkImageData* img = bbGetInputIn();
137 wxVtkBaseView* base = bbGetInputwxVtkBaseView();
139 wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget();
141 if(base !=NULL && img != NULL && _img != img){
146 wxwidgetvoi->setBaseView(base);
147 wxwidgetvoi->setImageData(img);
148 wxwidgetvoi->initializeVOIWidget();
151 if (wxwidgetvoi!=NULL && _img!=NULL && _base != NULL){
152 ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget();
155 contourvoiwidget->GetVOI(voi);
157 sprintf(buffer,"%d %d %d ", voi[0], voi[2], voi[4] );
158 std::string Index(buffer);
159 sprintf(buffer,"%d %d %d ", voi[1]-voi[0]+1, voi[3]-voi[2]+1, voi[5]-voi[4]+1 );
160 std::string Size(buffer);
162 std::cout<<"ContourVOI index "<<Index<<" size "<<Size<<std::endl;
165 This go out of the box ... see ExtractVtkImageFilter ...
171 _extract = vtkExtractVOI::New();
172 _extract->RemoveAllInputs();
173 _extract->SetInput(img);
174 _extract->SetVOI(voi);
175 _extract->UpdateWholeExtent();
177 bbSetOutputVOI(_extract->GetOutput());
181 bbSetOutputIndex( Index );
182 bbSetOutputSize( Size );
186 //------------------------------------------------------
187 void ContourVOI::CreateWidget(wxWindow* parent)
189 bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
190 wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
191 bbSetOutputWidget(mwxwidget);
192 bbtkDebugDecTab("Core",9);
193 this->bbSignalOutputModification();
198 //------------------------------------------------------
199 void ContourVOI::bbUserSetDefaultValues()
203 //EED 20Juin2011 _extract =NULL;
204 bbSetInputwxVtkBaseView(NULL);
206 bbSetOutputWidget(NULL);
207 bbSetOutputVOI(NULL);
210 bbSetInputwxVtkBaseView(NULL);
214 //-----------------------------------------------------------------
215 void ContourVOI::bbUserInitializeProcessing()
219 //-----------------------------------------------------------------
220 void ContourVOI::bbUserFinalizeProcessing()
224 //-----------------------------------------------------------------
227 // EO namespace bbcreaMaracasVisu