]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuContourVOI.cxx
cf35763703d5f6485645762b29fd8ce0447db133
[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           printf("EED wxWidgetVOI::Refresh \n");
66 //        wxwidget->RefreshView();
67   }
68
69 //--------------------------------------------------------------------------
70   //---------------
71   //Handling events
72   //---------------
73   void wxWidgetVOI::OnRefreshView(wxCommandEvent &event)
74   {
75           printf("EED wxWidgetVOI::OnRefreshView \n");
76 /*
77           if((wxwidget!=NULL) && (mbbViewerMPR!=NULL))
78           {
79             point.clear();
80                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX());
81                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY());
82                 point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetZ());
83                 mbbViewerMPR->bbSetOutputPoint(point);
84                 mbbViewerMPR->bbSetModifiedStatus();
85                 wxwidget->RefreshView();
86           }
87 */
88   }
89
90 //--------------------------------------------------------------------------
91   void wxWidgetVOI::OnDClickLeft(wxCommandEvent & event) 
92   {
93           printf("EED wxWidgetVOI::OnDClickLeft \n");
94 //      wxwidget->RefreshView();
95   }
96
97 //------------------------------------------------------
98 ContourVOIWidget* wxWidgetVOI::GetContourVOIWidget()
99 {
100         return mcontourvoiwidget;
101 }
102
103 //--------------------------------------------------------------------------------------------------------------------------------
104
105 //------------------------------------------------------
106 //------------------------------------------------------
107 //------------------------------------------------------
108
109
110 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourVOI)
111 BBTK_BLACK_BOX_IMPLEMENTATION(ContourVOI,bbtk::WxBlackBox);
112
113 //------------------------------------------------------
114 void ContourVOI::Process()
115 {  
116
117         /*if (bbGetInputwxVtkBaseView()==NULL) 
118     {
119       wxMessageDialog(NULL,  bbtk::std2wx("(ContourVOI) Input 'wxVtkBaseView' is not set"),  bbtk::std2wx(bbGetFullName()) ).ShowModal();         
120     }
121         if (bbGetInputIn()==NULL) 
122     {
123       wxMessageDialog(NULL,  bbtk::std2wx("(ContourVOI) Input 'In' is not set"),  bbtk::std2wx(bbGetFullName()) ).ShowModal();
124     }*/
125
126
127         vtkImageData* img = bbGetInputIn();
128         wxVtkBaseView* base = bbGetInputwxVtkBaseView();
129
130         wxWidgetVOI* wxwidgetvoi = (wxWidgetVOI*)bbGetOutputWidget();
131
132         if(base !=NULL && img != NULL && _img != img && _base != base){
133
134                 _img = img;
135                 _base = base;
136                 
137                 wxwidgetvoi->setBaseView(base);
138                 wxwidgetvoi->setImageData(img);
139                 wxwidgetvoi->initializeVOIWidget();             
140         }
141
142         
143         if (wxwidgetvoi!=NULL){
144                 ContourVOIWidget* contourvoiwidget = wxwidgetvoi->GetContourVOIWidget();
145                 
146                 int voi[6];
147                 contourvoiwidget->GetVOI(voi);
148                 char buffer[40];
149                 sprintf(buffer,"%d %d %d ", voi[0], voi[2], voi[4] );
150                 std::string Index(buffer);
151                 sprintf(buffer,"%d %d %d ", voi[1]-voi[0]+1, voi[3]-voi[2]+1, voi[5]-voi[4]+1 );
152                 std::string Size(buffer);
153
154                 std::cout<<"ContourVOI index "<<Index<<" size "<<Size<<std::endl;
155
156                 bbSetOutputIndex( Index );
157                 bbSetOutputSize( Size );
158         } 
159
160 }
161
162 //------------------------------------------------------
163 void ContourVOI::CreateWidget(wxWindow*  parent)
164 {  
165         bbtkDebugMessageInc("Core",9,"ContourVOI::CreateWidget()"<<std::endl);
166         wxWidgetVOI *mwxwidget = new wxWidgetVOI( parent );
167         bbSetOutputWidget(mwxwidget);
168         bbtkDebugDecTab("Core",9);
169         this->bbSignalOutputModification();
170
171         //Process();
172 }
173
174 //------------------------------------------------------
175 void ContourVOI::bbUserConstructor()
176 {
177
178         _img = NULL;
179         _base = NULL;
180         bbSetInputwxVtkBaseView(NULL);
181         bbSetInputIn(NULL);
182         bbSetOutputWidget(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