]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuContourVOI.cxx
55d64736a473973fe99aab4d9c2a1ff683025635
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuContourVOI.cxx
1 //HOLA!!!
2 //HOLA!!!
3
4 #include "bbmaracasvisuContourVOI.h"
5 #include "bbcreaMaracasVisuPackage.h"
6 namespace bbcreaMaracasVisu
7 {
8
9   //--------------------------------------------------------------------------
10   // wxWidgetMPR
11   //--------------------------------------------------------------------------
12 BEGIN_EVENT_TABLE( wxWidgetVOI, wxPanel )
13         EVT_MENU( 12121, wxWidgetVOI::OnRefreshView )
14         EVT_MENU( 12122, wxWidgetVOI::OnDClickLeft  )
15 END_EVENT_TABLE( );
16
17   //-----------
18   //Constructor
19   //-----------
20   wxWidgetVOI::wxWidgetVOI(wxWindow* parent,  wxVtkBaseView *wxvtkbaseview, vtkImageData *imagedata)
21           : wxPanel( parent, -1 )
22   {
23 //              wxPanel *panel  = this;
24
25                 if(wxvtkbaseview!=NULL&&imagedata!=NULL){
26
27                         setBaseView(wxvtkbaseview);
28                         setImageData(imagedata);
29                         initializeVOIWidget();
30
31                 }
32
33                                 
34   }
35
36   void wxWidgetVOI::setBaseView(wxVtkBaseView * wxvtkbaseview){
37           this->wxvtkbaseview = wxvtkbaseview;
38   }
39   void wxWidgetVOI::setImageData(vtkImageData * imagedata){
40           this->imagedata = imagedata;
41   }
42
43   void wxWidgetVOI::initializeVOIWidget(){
44                 mcontourvoiwidget = new ContourVOIWidget( this, wxvtkbaseview, imagedata );
45                 mcontourvoiwidget->ConfigureVTK();
46
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);
54                 this    -> Layout();
55                 this->Refresh();
56   }
57 //--------------------------------------------------------------------------
58   wxWidgetVOI::~wxWidgetVOI()
59   {
60   }
61         
62 //--------------------------------------------------------------------------
63   void wxWidgetVOI::Refresh()
64   { 
65 //        wxwidget->RefreshView();
66   }
67
68 //--------------------------------------------------------------------------
69   //---------------
70   //Handling events
71   //---------------
72   void wxWidgetVOI::OnRefreshView(wxCommandEvent &event)
73   {
74 /*
75           if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
76           {
77             point.clear();
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();
84           }
85 */
86   }
87
88 //--------------------------------------------------------------------------
89   void wxWidgetVOI::OnDClickLeft(wxCommandEvent & event) 
90   {
91 //      wxwidget->RefreshView();
92   }
93
94 //------------------------------------------------------
95 ContourVOIWidget* wxWidgetVOI::GetContourVOIWidget()
96 {
97         return mcontourvoiwidget;
98 }
99
100 //--------------------------------------------------------------------------------------------------------------------------------
101
102 //------------------------------------------------------
103 //------------------------------------------------------
104 //------------------------------------------------------
105
106
107 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourVOI)
108 BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox);
109
110 //------------------------------------------------------
111 void ContourVOI::Process()
112 {  
113
114         /*if (bbGetInputwxVtkBaseView()==NULL) 
115     {
116       wxMessageDialog(NULL,  bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"),  bbtk::std2wx(bbGetFullName()) ).ShowModal();         
117     }
118         if (bbGetInputIn()==NULL) 
119     {
120       wxMessageDialog(NULL,  bbtk::std2wx("(ContourVOI) Input 'In' is not set"),  bbtk::std2wx(bbGetFullName()) ).ShowModal();
121     }*/
122
123
124         vtkImageData* img = bbGetInputIn();
125         wxVtkBaseView* base = bbGetInputwxVtkBaseView();
126
127         wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget();
128
129         if(base !=NULL && img != NULL && _img != img){
130
131                 _img = img;
132                 _base = base;
133                 
134                 wxwidgetvoi->setBaseView(base);
135                 wxwidgetvoi->setImageData(img);
136                 wxwidgetvoi->initializeVOIWidget();             
137         }
138
139         
140         if (wxwidgetvoi!=NULL && _img!=NULL && _base != NULL){
141                 ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget();
142                 
143                 int voi[6];
144                 contourvoiwidget->GetVOI(voi);
145                 char buffer[40];
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);
150
151                 std::cout<<"ContourVOI index "<<Index<<" size "<<Size<<std::endl;
152
153                 bbSetOutputIndex( Index );
154                 bbSetOutputSize( Size );
155         } 
156
157 }
158
159 //------------------------------------------------------
160 void ContourVOI::CreateWidget(wxWindow*  parent)
161 {  
162         bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
163         wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
164         bbSetOutputWidget(mwxwidget);
165         bbtkDebugDecTab("Core",9);
166         this->bbSignalOutputModification();
167
168         //Process();
169 }
170
171 //------------------------------------------------------
172 void ContourVOI::bbUserConstructor()
173 {
174
175         _img = NULL;
176         _base = NULL;
177         bbSetInputwxVtkBaseView(NULL);
178         bbSetInputIn(NULL);
179         bbSetOutputWidget(NULL);
180
181         bbSetInputIn(NULL);
182         bbSetInputwxVtkBaseView(NULL);
183
184 }
185
186 //------------------------------------------------------
187 void ContourVOI::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
188 {
189         _img = NULL;
190         _base = NULL;
191
192 }
193
194 //------------------------------------------------------
195 void ContourVOI::bbUserDestructor()
196 {
197 }
198
199
200 }
201 // EO namespace bbcreaMaracasVisu
202
203