]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuwxVtkBaseView_Info.cxx
b70dd458beeb84b071ccae2f346845c91df36f7a
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuwxVtkBaseView_Info.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbcreaMaracasVisuwxVtkBaseView_Info.h"
5 #include "bbcreaMaracasVisuPackage.h"
6 #include <vtkInteractorStyleBaseView.h>
7
8 namespace bbcreaMaracasVisu
9 {
10
11 InteractorwxVtkBaseView_model::InteractorwxVtkBaseView_model()
12 {
13     _wxvtkbaseview = NULL;
14 }
15
16 InteractorwxVtkBaseView_model::~InteractorwxVtkBaseView_model()
17 {
18 }
19
20 void InteractorwxVtkBaseView_model::SetwxVtkBaseView( wxVtkBaseView *wxvtkbaseview)
21 {
22     _wxvtkbaseview = wxvtkbaseview;
23 }
24
25 void InteractorwxVtkBaseView_model::AddThisInteractor()
26 {
27     vtkInteractorStyleBaseView  *vtkinteractorstylebaseview = (vtkInteractorStyleBaseView*) (_wxvtkbaseview->GetInteractorStyleBaseView() );
28     vtkinteractorstylebaseview->AddInteractorStyleMaracas( this );
29 }
30
31
32
33
34
35 class InteractorwxVtkBaseView : public InteractorwxVtkBaseView_model
36 {
37     public:
38         InteractorwxVtkBaseView( wxVtkBaseView_Info *box );
39         ~InteractorwxVtkBaseView();
40         virtual bool    OnLeftButtonDown();
41         virtual bool    OnLeftButtonUp();
42         virtual bool    OnMouseMove();
43         virtual bool    OnRightButtonDown();
44         virtual bool    OnRightButtonUp();
45         virtual bool    OnLeftDClick();
46         virtual bool    OnRightDClick();
47 private:
48         wxVtkBaseView_Info      *_box;
49         bool                    flagDrag;
50 };
51
52 InteractorwxVtkBaseView::InteractorwxVtkBaseView( wxVtkBaseView_Info *box  )
53 {
54     _box            = box;
55     flagDrag        = false;
56 }
57
58 InteractorwxVtkBaseView::~InteractorwxVtkBaseView()
59 {
60 }
61
62 bool InteractorwxVtkBaseView::OnLeftButtonDown()
63 {
64     if (_box!=NULL)
65     {
66         if ( _box->bbGetInputInteractionType()==8 )
67         {
68             flagDrag=true;
69         }
70         if ( (_box->bbGetInputInteractionType()==1 ) && (_wxvtkbaseview!=NULL) )
71         {
72             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
73             _box->bbSignalOutputModification();
74             return false;
75         } // if _vtkbaseview
76     } // if _box
77     return true;
78 }
79
80 bool InteractorwxVtkBaseView::OnLeftButtonUp()
81 {
82     if (_box!=NULL)
83     {
84         if ( _box->bbGetInputInteractionType()==8 )
85         {
86             flagDrag=false;
87         }
88         if ( (_box->bbGetInputInteractionType()==2 ) && (_wxvtkbaseview!=NULL) )
89         {
90             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
91             _box->bbSignalOutputModification();
92             return false;
93         } // if _vtkbaseview
94     } // if _box
95     return true;
96 }
97
98 bool InteractorwxVtkBaseView::OnMouseMove()
99 {
100     if (_box!=NULL)
101     {
102         int intFlag;
103         if (flagDrag==true) intFlag=1; else intFlag=0;
104         bool ok=false;
105         if ( (_box->bbGetInputInteractionType()==3 ) && (_wxvtkbaseview!=NULL) )
106         {
107             ok=true;
108         } // if InteractionType 3
109         if (( _box->bbGetInputInteractionType()==8 ) && (flagDrag==true) )
110         {
111             ok=true;
112         } // if InteractionType 8
113         if (( _box->bbGetInputInteractionType()==9 ) && (flagDrag==true) )
114         {
115             ok=true;
116         } // if InteractionType 9
117         if (ok==true)
118         {
119             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
120             _box->bbSignalOutputModification();
121             return false;
122         } // if ok
123     } // if _box
124     return true;
125 }
126
127 bool InteractorwxVtkBaseView::OnRightButtonDown()
128 {
129     if (_box!=NULL)
130     {
131         if ( _box->bbGetInputInteractionType()==9 )
132         {
133             flagDrag=true;
134         }
135         if ( (_box->bbGetInputInteractionType()==4 ) && (_wxvtkbaseview!=NULL) )
136         {
137             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
138             _box->bbSignalOutputModification();
139             return false;
140         } // if _vtkbaseview
141     } // if _box
142     return true;
143 }
144
145 bool InteractorwxVtkBaseView::OnRightButtonUp()
146 {
147     if (_box!=NULL)
148     {
149         if ( _box->bbGetInputInteractionType()==9 )
150         {
151             flagDrag=false;
152         }
153         if ( (_box->bbGetInputInteractionType()==5 ) && (_wxvtkbaseview!=NULL) )
154         {
155             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
156             _box->bbSignalOutputModification();
157             return false;
158         } // if _vtkbaseview
159     } // if _box
160     return true;
161 }
162
163
164 bool InteractorwxVtkBaseView::OnLeftDClick()
165 {
166     if (_box!=NULL)
167     {
168         if ( (_box->bbGetInputInteractionType()==6 ) && (_wxvtkbaseview!=NULL) )
169         {
170             printf("EED InteractorwxVtkBaseView::OnLeftDClick type=6 \n");
171             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
172             _box->bbSignalOutputModification();
173             return false;
174         } // if _vtkbaseview
175     } // if _box
176     return true;
177 }
178
179 bool InteractorwxVtkBaseView::OnRightDClick()
180 {
181     if (_box!=NULL)
182     {
183         if ( (_box->bbGetInputInteractionType()==7 ) && (_wxvtkbaseview!=NULL) )
184         {
185             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
186             _box->bbSignalOutputModification();
187             return false;
188         } // if _vtkbaseview
189     } // if _box
190     return true;
191 }
192
193 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,wxVtkBaseView_Info)
194 BBTK_BLACK_BOX_IMPLEMENTATION(wxVtkBaseView_Info,bbtk::AtomicBlackBox);
195
196 void wxVtkBaseView_Info::SetwxVtkBaseViewOutputs(wxVtkBaseView *wxvtkbaseview )
197 {
198     if (wxvtkbaseview!=NULL)
199     {
200         bbSetOutputvtkRenderer( wxvtkbaseview->GetRenderer() );
201         bbSetOutputDirection( wxvtkbaseview->GetDirection() );
202         bbSetOutputwxVtkBaseView(wxvtkbaseview);
203         vtkBaseData *vtkbasedata = wxvtkbaseview->GetVtkBaseData();
204         if (vtkbasedata!=NULL)
205         {
206             marImageData *marimagedata = vtkbasedata->GetMarImageData();
207             if (marimagedata!=NULL)
208             {
209                 bbSetOutputImage( marimagedata->GetImageData() );
210             } // MarImageData
211             std::vector<double> LstWindowColorLevel;
212             LstWindowColorLevel.push_back( vtkbasedata->GetColorWindow() );
213             LstWindowColorLevel.push_back( vtkbasedata->GetColorLevel() );
214             bbSetOutputWindowColorLevel( LstWindowColorLevel );
215             
216             std::vector<double> lstPoint;
217             lstPoint.push_back( vtkbasedata->GetX() );
218             lstPoint.push_back( vtkbasedata->GetY() );
219             lstPoint.push_back( vtkbasedata->GetZ() );
220             bbSetOutputPoint( lstPoint );
221
222             int pointMouseX,pointMouseY,pointMouseZ;
223             vtkbasedata->GetPointMouse(pointMouseX,pointMouseY,pointMouseZ); 
224             std::vector<double> lstPointMouse;
225             lstPointMouse.push_back( pointMouseX );
226             lstPointMouse.push_back( pointMouseY );
227             lstPointMouse.push_back( pointMouseZ );
228             bbSetOutputPointMouse( lstPointMouse );
229
230             double normal[3];
231             std::vector<double> lstNormal;
232             wxvtkbaseview->GetNormal( normal );
233             lstNormal.push_back( normal[0] );
234             lstNormal.push_back( normal[1] );
235             lstNormal.push_back( normal[2] );
236             bbSetOutputNormal( lstNormal );
237             
238             bbSetOutputInterpolation( vtkbasedata->GetInterpolate() );
239         }  // BaseData
240     } // if wxvtkbaseview
241 }
242
243 //===== 
244 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
245 //===== 
246 void wxVtkBaseView_Info::Process()
247 {
248 // THE MAIN PROCESSING METHOD BODY
249 //   Here we simply set the input 'In' value to the output 'Out'
250 //   And print out the output value
251 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
252 //    void bbSet{Input|Output}NAME(const TYPE&)
253 //    const TYPE& bbGet{Input|Output}NAME() const 
254 //    Where :
255 //    * NAME is the name of the input/output
256 //      (the one provided in the attribute 'name' of the tag 'input')
257 //    * TYPE is the C++ type of the input/output
258 //      (the one provided in the attribute 'type' of the tag 'input')
259     if (bbGetInputInteractionType()==0)
260     {
261         SetwxVtkBaseViewOutputs( bbGetInputwxVtkBaseView() );
262     }
263     
264     if (firsttime==true)
265     {
266         firsttime=false;
267         if (bbGetInputInteractionType()!=0)
268         {
269             SetwxVtkBaseViewOutputs( bbGetInputwxVtkBaseView() );
270             
271             interactorwxvtkbaseview    = new InteractorwxVtkBaseView( this  );
272             if (bbGetInputwxVtkBaseView()!=NULL)
273             {
274                 interactorwxvtkbaseview->SetwxVtkBaseView(  bbGetInputwxVtkBaseView() );
275                 interactorwxvtkbaseview->AddThisInteractor();
276             } // if wxVtkBaseView
277             
278             interactorwxvtkbaseview2    = new InteractorwxVtkBaseView( this  );
279             if (bbGetInputwxVtkBaseView2()!=NULL)
280             {
281                 interactorwxvtkbaseview2->SetwxVtkBaseView(  bbGetInputwxVtkBaseView2() );
282                 interactorwxvtkbaseview2->AddThisInteractor();
283
284 //                vtkInteractorStyleBaseView  *vtkinteractorstylebaseview = (vtkInteractorStyleBaseView*) (bbGetInputwxVtkBaseView2()->GetInteractorStyleBaseView() );
285 //                vtkinteractorstylebaseview->AddInteractorStyleMaracas( interactorwxvtkbaseview2 );
286             } // if wxVtkBaseView2
287             
288             interactorwxvtkbaseview3    = new InteractorwxVtkBaseView( this  );
289             if (bbGetInputwxVtkBaseView3()!=NULL)
290             {
291                 interactorwxvtkbaseview3->SetwxVtkBaseView(  bbGetInputwxVtkBaseView3() );
292                 interactorwxvtkbaseview3->AddThisInteractor();
293
294 //                vtkInteractorStyleBaseView  *vtkinteractorstylebaseview = (vtkInteractorStyleBaseView*) (bbGetInputwxVtkBaseView3()->GetInteractorStyleBaseView() );
295 //                vtkinteractorstylebaseview->AddInteractorStyleMaracas( interactorwxvtkbaseview3 );
296             } // if wxVtkBaseView3
297             
298             bbSetOutputInteractorwxVtkBaseView_model(   interactorwxvtkbaseview  );
299             bbSetOutputInteractorwxVtkBaseView_model2(  interactorwxvtkbaseview2 );
300             bbSetOutputInteractorwxVtkBaseView_model3(  interactorwxvtkbaseview3 );
301         } // if InteractionType !=0
302     } // if firsttime
303     
304     bbSetOutputBox_wxVtkBaseView_Info( this );
305 }
306
307 //===== 
308 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
309 //===== 
310 void wxVtkBaseView_Info::bbUserSetDefaultValues()
311 {
312 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
313 //    Here we initialize the input 'In' to 0
314     firsttime=true;
315         std::vector<double> LstWindowColorLevel;
316         LstWindowColorLevel.push_back( 1000 );
317         LstWindowColorLevel.push_back( 500 );
318     bbSetInputwxVtkBaseView( NULL );
319     bbSetInputwxVtkBaseView2( NULL );
320     bbSetInputwxVtkBaseView3( NULL );
321     bbSetInputInteractionType(0);
322     bbSetOutputWindowColorLevel( LstWindowColorLevel );
323     bbSetOutputDirection(2);
324     bbSetOutputInterpolation(true);
325     bbSetOutputvtkRenderer(NULL);
326     interactorwxvtkbaseview=NULL;
327     interactorwxvtkbaseview2=NULL;
328     interactorwxvtkbaseview3=NULL;
329     bbSetOutputInteractorwxVtkBaseView_model(   interactorwxvtkbaseview  );
330     bbSetOutputInteractorwxVtkBaseView_model2(  interactorwxvtkbaseview2 );
331     bbSetOutputInteractorwxVtkBaseView_model3(  interactorwxvtkbaseview3 );
332 }
333
334 //===== 
335 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
336 //===== 
337 void wxVtkBaseView_Info::bbUserInitializeProcessing()
338 {
339 //  THE INITIALIZATION METHOD BODY :
340 //    Here does nothing 
341 //    but this is where you should allocate the internal/output pointers 
342 //    if any
343     bbSetOutputInteractorwxVtkBaseView_model(NULL);
344     bbSetOutputInteractorwxVtkBaseView_model2(NULL);
345     bbSetOutputInteractorwxVtkBaseView_model3(NULL);
346 }
347
348 //===== 
349 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
350 //===== 
351 void wxVtkBaseView_Info::bbUserFinalizeProcessing()
352 {
353 //  THE FINALIZATION METHOD BODY :
354 //    Here does nothing 
355 //    but this is where you should desallocate the internal/output pointers 
356 //    if any
357 }
358
359 }// EO namespace bbcreaMaracasVisu
360
361