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 if(wxvtkbaseview!=NULL&&imagedata!=NULL){
27 setBaseView(wxvtkbaseview);
28 setImageData(imagedata);
29 initializeVOIWidget();
36 void wxWidgetVOI::setBaseView(wxVtkBaseView * wxvtkbaseview){
37 this->wxvtkbaseview = wxvtkbaseview;
39 void wxWidgetVOI::setImageData(vtkImageData * imagedata){
40 this->imagedata = imagedata;
43 void wxWidgetVOI::initializeVOIWidget(){
44 mcontourvoiwidget = new ContourVOIWidget( this, wxvtkbaseview, imagedata );
45 mcontourvoiwidget->ConfigureVTK();
47 // wxwidget = new wxMPRWidget2( panel, marimagedata , 1 );
48 // wxwidget->ConfigureVTK();
49 wxFlexGridSizer *sizer=new wxFlexGridSizer(1);
50 sizer -> Add( mcontourvoiwidget,1,wxGROW );
51 sizer -> AddGrowableCol(0);
52 this -> SetSizer(sizer);
53 this -> SetAutoLayout(true);
57 //--------------------------------------------------------------------------
58 wxWidgetVOI::~wxWidgetVOI()
62 //--------------------------------------------------------------------------
63 void wxWidgetVOI::Refresh()
65 // wxwidget->RefreshView();
68 //--------------------------------------------------------------------------
72 void wxWidgetVOI::OnRefreshView(wxCommandEvent &event)
75 if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
78 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
79 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
80 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
81 mbbViewerMPR->bbSetOutputPoint(point);
82 mbbViewerMPR->bbSetModifiedStatus();
83 wxwidget->RefreshView();
88 //--------------------------------------------------------------------------
89 void wxWidgetVOI::OnDClickLeft(wxCommandEvent & event)
91 // wxwidget->RefreshView();
94 //------------------------------------------------------
95 ContourVOIWidget* wxWidgetVOI::GetContourVOIWidget()
97 return mcontourvoiwidget;
100 //--------------------------------------------------------------------------------------------------------------------------------
102 //------------------------------------------------------
103 //------------------------------------------------------
104 //------------------------------------------------------
107 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourVOI)
108 BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox);
110 //------------------------------------------------------
111 void ContourVOI::Process()
114 /*if (bbGetInputwxVtkBaseView()==NULL)
116 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
118 if (bbGetInputIn()==NULL)
120 wxMessageDialog(NULL, bbtk::std2wx("(ContourVOI) Input 'In' is not set"), bbtk::std2wx(bbGetFullName()) ).ShowModal();
124 vtkImageData* img = bbGetInputIn();
125 wxVtkBaseView* base = bbGetInputwxVtkBaseView();
127 wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget();
129 if(base !=NULL && img != NULL && _img != img){
134 wxwidgetvoi->setBaseView(base);
135 wxwidgetvoi->setImageData(img);
136 wxwidgetvoi->initializeVOIWidget();
140 if (wxwidgetvoi!=NULL && _img!=NULL && _base != NULL){
141 ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget();
144 contourvoiwidget->GetVOI(voi);
146 sprintf(buffer,"%d %d %d ", voi[0], voi[2], voi[4] );
147 std::string Index(buffer);
148 sprintf(buffer,"%d %d %d ", voi[1]-voi[0]+1, voi[3]-voi[2]+1, voi[5]-voi[4]+1 );
149 std::string Size(buffer);
151 std::cout<<"ContourVOI index "<<Index<<" size "<<Size<<std::endl;
153 bbSetOutputIndex( Index );
154 bbSetOutputSize( Size );
159 //------------------------------------------------------
160 void ContourVOI::CreateWidget(wxWindow* parent)
162 bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
163 wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
164 bbSetOutputWidget(mwxwidget);
165 bbtkDebugDecTab("Core",9);
166 this->bbSignalOutputModification();
171 //------------------------------------------------------
172 void ContourVOI::bbUserConstructor()
177 bbSetInputwxVtkBaseView(NULL);
179 bbSetOutputWidget(NULL);
182 bbSetInputwxVtkBaseView(NULL);
186 //------------------------------------------------------
187 void ContourVOI::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
194 //------------------------------------------------------
195 void ContourVOI::bbUserDestructor()
201 // EO namespace bbcreaMaracasVisu