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;
36 if(wxvtkbaseview!=NULL&&imagedata!=NULL){
38 setBaseView(wxvtkbaseview);
39 setImageData(imagedata);
40 initializeVOIWidget();
46 void wxWidgetVOI::initializeVOIWidget(){
47 wxSizer* sizer = this->GetSizer();
50 if(mcontourvoiwidget!=NULL){
51 sizer->Remove( mcontourvoiwidget );
52 mcontourvoiwidget->Destroy();
55 mcontourvoiwidget = new ContourVOIWidget( this, wxvtkbaseview, imagedata );
56 mcontourvoiwidget->ConfigureVTK();
59 sizer -> Add( mcontourvoiwidget,1,wxGROW );
60 // wxwidget = new wxMPRWidget2( panel, marimagedata , 1 );
61 // wxwidget->ConfigureVTK();
66 void wxWidgetVOI::setBaseView(wxVtkBaseView * wxvtkbaseview){
67 this->wxvtkbaseview = wxvtkbaseview;
69 void wxWidgetVOI::setImageData(vtkImageData * imagedata){
70 this->imagedata = imagedata;
74 //--------------------------------------------------------------------------
75 wxWidgetVOI::~wxWidgetVOI()
79 //--------------------------------------------------------------------------
80 void wxWidgetVOI::Refresh()
82 // wxwidget->RefreshView();
85 //--------------------------------------------------------------------------
89 void wxWidgetVOI::OnRefreshView(wxCommandEvent &event)
92 if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
95 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
96 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
97 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
98 mbbViewerMPR->bbSetOutputPoint(point);
99 mbbViewerMPR->bbSetModifiedStatus();
100 wxwidget->RefreshView();
105 //--------------------------------------------------------------------------
106 void wxWidgetVOI::OnDClickLeft(wxCommandEvent & event)
108 // wxwidget->RefreshView();
111 //------------------------------------------------------
112 ContourVOIWidget* wxWidgetVOI::GetContourVOIWidget()
114 return mcontourvoiwidget;
117 //--------------------------------------------------------------------------------------------------------------------------------
119 //------------------------------------------------------
120 //------------------------------------------------------
121 //------------------------------------------------------
124 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourVOI)
125 BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox);
127 //------------------------------------------------------
128 void ContourVOI::Process()
131 /*if (bbGetInputwxVtkBaseView()==NULL)
133 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
135 if (bbGetInputIn()==NULL)
137 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'In' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
141 vtkImageData* img = bbGetInputIn();
142 wxVtkBaseView* base = bbGetInputwxVtkBaseView();
144 wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget();
146 if(base !=NULL && img != NULL && _img != img){
151 wxwidgetvoi->setBaseView(base);
152 wxwidgetvoi->setImageData(img);
153 wxwidgetvoi->initializeVOIWidget();
157 if (wxwidgetvoi!=NULL && _img!=NULL && _base != NULL){
158 ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget();
161 contourvoiwidget->GetVOI(voi);
163 sprintf(buffer,"%d %d %d ", voi[0], voi[2], voi[4] );
164 std::string Index(buffer);
165 sprintf(buffer,"%d %d %d ", voi[1]-voi[0]+1, voi[3]-voi[2]+1, voi[5]-voi[4]+1 );
166 std::string Size(buffer);
168 std::cout<<"ContourVOI index "<<Index<<" size "<<Size<<std::endl;
171 This go out of the box ... see ExtractVtkImageFilter ...
177 _extract = vtkExtractVOI::New();
178 _extract->RemoveAllInputs();
179 _extract->SetInput(img);
180 _extract->SetVOI(voi);
181 _extract->UpdateWholeExtent();
183 bbSetOutputVOI(_extract->GetOutput());
188 bbSetOutputIndex( Index );
189 bbSetOutputSize( Size );
194 //------------------------------------------------------
195 void ContourVOI::CreateWidget(wxWindow* parent)
197 bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
198 wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
199 bbSetOutputWidget(mwxwidget);
200 bbtkDebugDecTab("Core",9);
201 this->bbSignalOutputModification();
206 //------------------------------------------------------
207 void ContourVOI::bbUserSetDefaultValues()
212 //EED 20Juin2011 _extract =NULL;
213 bbSetInputwxVtkBaseView(NULL);
215 bbSetOutputWidget(NULL);
216 bbSetOutputVOI(NULL);
219 bbSetInputwxVtkBaseView(NULL);
223 //-----------------------------------------------------------------
224 void ContourVOI::bbUserInitializeProcessing()
228 //-----------------------------------------------------------------
229 void ContourVOI::bbUserFinalizeProcessing()
233 //-----------------------------------------------------------------
237 // EO namespace bbcreaMaracasVisu