4 #include "bbmaracasvisuContourVOI.h"
5 #include "bbcreaMaracasVisuPackage.h"
6 namespace bbcreaMaracasVisu
9 //--------------------------------------------------------------------------
11 //--------------------------------------------------------------------------
12 BEGIN_EVENT_TABLE( wxWidgetVOI, wxPanel )
13 EVT_MENU( 12121, wxWidgetVOI::OnRefreshView )
14 EVT_MENU( 12122, wxWidgetVOI::OnDClickLeft )
20 wxWidgetVOI::wxWidgetVOI(wxWindow* parent, wxVtkBaseView *wxvtkbaseview, vtkImageData *imagedata)
21 : wxPanel( parent, -1 )
23 // wxPanel *panel = this;
25 wxFlexGridSizer *sizer=new wxFlexGridSizer(1);
26 sizer -> AddGrowableCol(0);
27 this -> SetSizer(sizer);
28 this -> SetAutoLayout(true);
29 this->wxvtkbaseview = NULL;
30 mcontourvoiwidget=NULL;
33 if(wxvtkbaseview!=NULL&&imagedata!=NULL){
35 setBaseView(wxvtkbaseview);
36 setImageData(imagedata);
37 initializeVOIWidget();
43 void wxWidgetVOI::initializeVOIWidget(){
44 wxSizer* sizer = this->GetSizer();
47 if(mcontourvoiwidget!=NULL){
48 sizer->Remove( mcontourvoiwidget );
49 mcontourvoiwidget->Destroy();
52 mcontourvoiwidget = new ContourVOIWidget( this, wxvtkbaseview, imagedata );
53 mcontourvoiwidget->ConfigureVTK();
56 sizer -> Add( mcontourvoiwidget,1,wxGROW );
57 // wxwidget = new wxMPRWidget2( panel, marimagedata , 1 );
58 // wxwidget->ConfigureVTK();
63 void wxWidgetVOI::setBaseView(wxVtkBaseView * wxvtkbaseview){
64 this->wxvtkbaseview = wxvtkbaseview;
66 void wxWidgetVOI::setImageData(vtkImageData * imagedata){
67 this->imagedata = imagedata;
71 //--------------------------------------------------------------------------
72 wxWidgetVOI::~wxWidgetVOI()
76 //--------------------------------------------------------------------------
77 void wxWidgetVOI::Refresh()
79 // wxwidget->RefreshView();
82 //--------------------------------------------------------------------------
86 void wxWidgetVOI::OnRefreshView(wxCommandEvent &event)
89 if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
92 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
93 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
94 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
95 mbbViewerMPR->bbSetOutputPoint(point);
96 mbbViewerMPR->bbSetModifiedStatus();
97 wxwidget->RefreshView();
102 //--------------------------------------------------------------------------
103 void wxWidgetVOI::OnDClickLeft(wxCommandEvent & event)
105 // wxwidget->RefreshView();
108 //------------------------------------------------------
109 ContourVOIWidget* wxWidgetVOI::GetContourVOIWidget()
111 return mcontourvoiwidget;
114 //--------------------------------------------------------------------------------------------------------------------------------
116 //------------------------------------------------------
117 //------------------------------------------------------
118 //------------------------------------------------------
121 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourVOI)
122 BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox);
124 //------------------------------------------------------
125 void ContourVOI::Process()
128 /*if (bbGetInputwxVtkBaseView()==NULL)
130 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
132 if (bbGetInputIn()==NULL)
134 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'In' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
138 vtkImageData* img = bbGetInputIn();
139 wxVtkBaseView* base = bbGetInputwxVtkBaseView();
141 wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget();
143 if(base !=NULL && img != NULL && _img != img){
148 wxwidgetvoi->setBaseView(base);
149 wxwidgetvoi->setImageData(img);
150 wxwidgetvoi->initializeVOIWidget();
154 if (wxwidgetvoi!=NULL && _img!=NULL && _base != NULL){
155 ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget();
158 contourvoiwidget->GetVOI(voi);
160 sprintf(buffer,"%d %d %d ", voi[0], voi[2], voi[4] );
161 std::string Index(buffer);
162 sprintf(buffer,"%d %d %d ", voi[1]-voi[0]+1, voi[3]-voi[2]+1, voi[5]-voi[4]+1 );
163 std::string Size(buffer);
165 std::cout<<"ContourVOI index "<<Index<<" size "<<Size<<std::endl;
171 _extract = vtkExtractVOI::New();
172 _extract->RemoveAllInputs();
173 _extract->SetInput(img);
174 _extract->SetVOI(voi);
175 _extract->UpdateWholeExtent();
177 bbSetOutputVOI(_extract->GetOutput());
182 bbSetOutputIndex( Index );
183 bbSetOutputSize( Size );
188 //------------------------------------------------------
189 void ContourVOI::CreateWidget(wxWindow* parent)
191 bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
192 wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
193 bbSetOutputWidget(mwxwidget);
194 bbtkDebugDecTab("Core",9);
195 this->bbSignalOutputModification();
200 //------------------------------------------------------
201 void ContourVOI::bbUserSetDefaultValues()
207 bbSetInputwxVtkBaseView(NULL);
209 bbSetOutputWidget(NULL);
210 bbSetOutputVOI(NULL);
213 bbSetInputwxVtkBaseView(NULL);
217 //-----------------------------------------------------------------
218 void ContourVOI::bbUserInitializeProcessing()
222 //-----------------------------------------------------------------
223 void ContourVOI::bbUserFinalizeProcessing()
227 //-----------------------------------------------------------------
231 // EO namespace bbcreaMaracasVisu