]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuwxVtkBaseView_Info.cxx
92a82d12de265f68b18d8cf2167b8334f03a03e6
[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    OnMiddleButtonDown();
46         virtual bool    OnMiddleButtonUp();
47         virtual bool    OnLeftDClick();
48         virtual bool    OnRightDClick();
49 private:
50         wxVtkBaseView_Info      *_box;
51         bool                    flagDrag;
52 };
53
54 InteractorwxVtkBaseView::InteractorwxVtkBaseView( wxVtkBaseView_Info *box  )
55 {
56     _box            = box;
57     flagDrag        = false;
58 }
59
60 InteractorwxVtkBaseView::~InteractorwxVtkBaseView()
61 {
62 }
63
64 bool InteractorwxVtkBaseView::OnLeftButtonDown()
65 {
66     if (_box!=NULL)
67     {
68         if ( _box->bbGetInputInteractionType()==8 )
69         {
70             flagDrag=true;
71         }
72         if ( (_box->bbGetInputInteractionType()==1 ) && (_wxvtkbaseview!=NULL) )
73         {
74             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
75             _box->bbSignalOutputModification();
76             return false;
77         } // if _vtkbaseview
78     } // if _box
79     return true;
80 }
81
82 bool InteractorwxVtkBaseView::OnLeftButtonUp()
83 {
84     if (_box!=NULL)
85     {
86         if ( _box->bbGetInputInteractionType()==8 )
87         {
88             flagDrag=false;
89         }
90         if ( (_box->bbGetInputInteractionType()==2 ) && (_wxvtkbaseview!=NULL) )
91         {
92             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
93             _box->bbSignalOutputModification();
94             return false;
95         } // if _vtkbaseview
96     } // if _box
97     return true;
98 }
99
100
101 bool InteractorwxVtkBaseView::OnMiddleButtonDown()
102 {
103     if (_box!=NULL)
104     {
105         if ( _box->bbGetInputInteractionType()==12 ) // MiddleDrag
106         {
107             flagDrag=true;
108         }
109         if ( (_box->bbGetInputInteractionType()==10 ) && (_wxvtkbaseview!=NULL) )   // MiddleButton Down
110         {
111             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
112             _box->bbSignalOutputModification();
113             return false;
114         } // if _vtkbaseview
115     } // if _box
116     return true;
117 }
118
119 bool InteractorwxVtkBaseView::OnMiddleButtonUp()
120 {
121     if (_box!=NULL)
122     {
123         if ( _box->bbGetInputInteractionType()==12 )  // MiddleDrag
124         {
125             flagDrag=false;
126         }
127         if ( (_box->bbGetInputInteractionType()==11 ) && (_wxvtkbaseview!=NULL) )  // MiddleButton Up
128         {
129             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
130             _box->bbSignalOutputModification();
131             return false;
132         } // if _vtkbaseview
133     } // if _box
134     return true;
135 }
136
137
138
139 bool InteractorwxVtkBaseView::OnMouseMove()
140 {
141     if (_box!=NULL)
142     {
143         int intFlag;
144         if (flagDrag==true) intFlag=1; else intFlag=0;
145         bool ok=false;
146         if ( (_box->bbGetInputInteractionType()==3 ) && (_wxvtkbaseview!=NULL) )
147         {
148             ok=true;
149         } // if InteractionType 3
150         if (( _box->bbGetInputInteractionType()==8 ) && (flagDrag==true) )
151         {
152             ok=true;
153         } // if InteractionType 8
154         if (( _box->bbGetInputInteractionType()==9 ) && (flagDrag==true) )
155         {
156             ok=true;
157         } // if InteractionType 9
158         if (( _box->bbGetInputInteractionType()==12 ) && (flagDrag==true) )
159         {
160             ok=true;
161         } // if InteractionType 9
162
163         if (ok==true)
164         {
165 //EED 2023-08-05
166             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
167             
168             _box->bbSignalOutputModification();
169 //            _box->bbSignalOutputModification(std::string("BoxChange"),false);
170             
171             return false;
172         } // if ok
173     } // if _box
174     return true;
175 }
176
177 bool InteractorwxVtkBaseView::OnRightButtonDown()
178 {
179     if (_box!=NULL)
180     {
181         if ( _box->bbGetInputInteractionType()==9 )
182         {
183             flagDrag=true;
184         }
185         if ( (_box->bbGetInputInteractionType()==4 ) && (_wxvtkbaseview!=NULL) )
186         {
187             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
188             _box->bbSignalOutputModification();
189             return false;
190         } // if _vtkbaseview
191     } // if _box
192     return true;
193 }
194
195 bool InteractorwxVtkBaseView::OnRightButtonUp()
196 {
197     if (_box!=NULL)
198     {
199         if ( _box->bbGetInputInteractionType()==9 )
200         {
201             flagDrag=false;
202         }
203         if ( (_box->bbGetInputInteractionType()==5 ) && (_wxvtkbaseview!=NULL) )
204         {
205             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
206             _box->bbSignalOutputModification();
207             return false;
208         } // if _vtkbaseview
209     } // if _box
210     return true;
211 }
212
213
214 bool InteractorwxVtkBaseView::OnLeftDClick()
215 {
216     if (_box!=NULL)
217     {
218         if ( (_box->bbGetInputInteractionType()==6 ) && (_wxvtkbaseview!=NULL) )
219         {
220             printf("EED InteractorwxVtkBaseView::OnLeftDClick type=6 \n");
221             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
222             _box->bbSignalOutputModification();
223             return false;
224         } // if _vtkbaseview
225     } // if _box
226     return true;
227 }
228
229 bool InteractorwxVtkBaseView::OnRightDClick()
230 {
231     if (_box!=NULL)
232     {
233         if ( (_box->bbGetInputInteractionType()==7 ) && (_wxvtkbaseview!=NULL) )
234         {
235             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
236             _box->bbSignalOutputModification();
237             return false;
238         } // if _vtkbaseview
239     } // if _box
240     return true;
241 }
242
243 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,wxVtkBaseView_Info)
244 BBTK_BLACK_BOX_IMPLEMENTATION(wxVtkBaseView_Info,bbtk::AtomicBlackBox);
245
246 void wxVtkBaseView_Info::SetwxVtkBaseViewOutputs(wxVtkBaseView *wxvtkbaseview )
247 {
248     if (wxvtkbaseview!=NULL)
249     {
250         bbSetOutputvtkRenderer( wxvtkbaseview->GetRenderer() );
251         bbSetOutputDirection( wxvtkbaseview->GetDirection() );
252         bbSetOutputwxVtkBaseView(wxvtkbaseview);
253         vtkBaseData *vtkbasedata = wxvtkbaseview->GetVtkBaseData();
254         if (vtkbasedata!=NULL)
255         {
256             marImageData *marimagedata = vtkbasedata->GetMarImageData();
257             if (marimagedata!=NULL)
258             {
259                 bbSetOutputImage( marimagedata->GetImageData() );
260             } // MarImageData
261             std::vector<double> LstWindowColorLevel;
262             LstWindowColorLevel.push_back( vtkbasedata->GetColorWindow() );
263             LstWindowColorLevel.push_back( vtkbasedata->GetColorLevel() );
264             bbSetOutputWindowColorLevel( LstWindowColorLevel );
265             
266             std::vector<double> lstPoint;
267             lstPoint.push_back( vtkbasedata->GetX() );
268             lstPoint.push_back( vtkbasedata->GetY() );
269             lstPoint.push_back( vtkbasedata->GetZ() );
270             bbSetOutputPoint( lstPoint );
271
272             int pointMouseX,pointMouseY,pointMouseZ;
273             vtkbasedata->GetPointMouse(pointMouseX,pointMouseY,pointMouseZ); 
274             std::vector<double> lstPointMouse;
275             lstPointMouse.push_back( pointMouseX );
276             lstPointMouse.push_back( pointMouseY );
277             lstPointMouse.push_back( pointMouseZ );
278             bbSetOutputPointMouse( lstPointMouse );
279
280             double normal[3];
281             std::vector<double> lstNormal;
282             wxvtkbaseview->GetNormal( normal );
283             lstNormal.push_back( normal[0] );
284             lstNormal.push_back( normal[1] );
285             lstNormal.push_back( normal[2] );
286             bbSetOutputNormal( lstNormal );
287             
288             bbSetOutputInterpolation( vtkbasedata->GetInterpolate() );
289         }  // BaseData
290     } // if wxvtkbaseview
291 }
292
293 //===== 
294 // 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)
295 //===== 
296 void wxVtkBaseView_Info::Process()
297 {
298 // THE MAIN PROCESSING METHOD BODY
299 //   Here we simply set the input 'In' value to the output 'Out'
300 //   And print out the output value
301 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
302 //    void bbSet{Input|Output}NAME(const TYPE&)
303 //    const TYPE& bbGet{Input|Output}NAME() const 
304 //    Where :
305 //    * NAME is the name of the input/output
306 //      (the one provided in the attribute 'name' of the tag 'input')
307 //    * TYPE is the C++ type of the input/output
308 //      (the one provided in the attribute 'type' of the tag 'input')
309     if (bbGetInputInteractionType()==0)
310     {
311         SetwxVtkBaseViewOutputs( bbGetInputwxVtkBaseView() );
312     }
313     
314     if (firsttime==true)
315     {
316         firsttime=false;
317         if (bbGetInputInteractionType()!=0)
318         {
319             SetwxVtkBaseViewOutputs( bbGetInputwxVtkBaseView() );
320             
321             interactorwxvtkbaseview    = new InteractorwxVtkBaseView( this  );
322             if (bbGetInputwxVtkBaseView()!=NULL)
323             {
324                 interactorwxvtkbaseview->SetwxVtkBaseView(  bbGetInputwxVtkBaseView() );
325                 interactorwxvtkbaseview->AddThisInteractor();
326             } // if wxVtkBaseView
327             
328             interactorwxvtkbaseview1    = new InteractorwxVtkBaseView( this  );
329             if (bbGetInputwxVtkBaseView1()!=NULL)
330             {
331                 interactorwxvtkbaseview1->SetwxVtkBaseView(  bbGetInputwxVtkBaseView1() );
332                 interactorwxvtkbaseview1->AddThisInteractor();
333             } // if wxVtkBaseView2
334             
335             interactorwxvtkbaseview2    = new InteractorwxVtkBaseView( this  );
336             if (bbGetInputwxVtkBaseView2()!=NULL)
337             {
338                 interactorwxvtkbaseview2->SetwxVtkBaseView(  bbGetInputwxVtkBaseView2() );
339                 interactorwxvtkbaseview2->AddThisInteractor();
340             } // if wxVtkBaseView2
341
342             interactorwxvtkbaseview3    = new InteractorwxVtkBaseView( this  );
343             if (bbGetInputwxVtkBaseView3()!=NULL)
344             {
345                 interactorwxvtkbaseview3->SetwxVtkBaseView(  bbGetInputwxVtkBaseView3() );
346                 interactorwxvtkbaseview3->AddThisInteractor();
347             } // if wxVtkBaseView3
348             
349             bbSetOutputInteractorwxVtkBaseView_model(   interactorwxvtkbaseview  );
350             bbSetOutputInteractorwxVtkBaseView_model1(  interactorwxvtkbaseview1 );
351             bbSetOutputInteractorwxVtkBaseView_model2(  interactorwxvtkbaseview2 );
352             bbSetOutputInteractorwxVtkBaseView_model3(  interactorwxvtkbaseview3 );
353         } // if InteractionType !=0
354     } // if firsttime
355     
356     bbSetOutputBox_wxVtkBaseView_Info( this );
357 }
358
359 //===== 
360 // 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)
361 //===== 
362 void wxVtkBaseView_Info::bbUserSetDefaultValues()
363 {
364 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
365 //    Here we initialize the input 'In' to 0
366     firsttime=true;
367         std::vector<double> LstWindowColorLevel;
368         LstWindowColorLevel.push_back( 1000 );
369         LstWindowColorLevel.push_back( 500 );
370     bbSetInputwxVtkBaseView( NULL );
371     bbSetInputwxVtkBaseView2( NULL );
372     bbSetInputwxVtkBaseView3( NULL );
373     bbSetInputInteractionType(0);
374     bbSetOutputWindowColorLevel( LstWindowColorLevel );
375     bbSetOutputDirection(2);
376     bbSetOutputInterpolation(true);
377     bbSetOutputvtkRenderer(NULL);
378     interactorwxvtkbaseview=NULL;
379     interactorwxvtkbaseview2=NULL;
380     interactorwxvtkbaseview3=NULL;
381     bbSetOutputInteractorwxVtkBaseView_model(   interactorwxvtkbaseview  );
382     bbSetOutputInteractorwxVtkBaseView_model1(  interactorwxvtkbaseview1 );
383     bbSetOutputInteractorwxVtkBaseView_model2(  interactorwxvtkbaseview2 );
384     bbSetOutputInteractorwxVtkBaseView_model3(  interactorwxvtkbaseview3 );
385 }
386
387 //===== 
388 // 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)
389 //===== 
390 void wxVtkBaseView_Info::bbUserInitializeProcessing()
391 {
392 //  THE INITIALIZATION METHOD BODY :
393 //    Here does nothing 
394 //    but this is where you should allocate the internal/output pointers 
395 //    if any
396     bbSetOutputInteractorwxVtkBaseView_model(NULL);
397     bbSetOutputInteractorwxVtkBaseView_model1(NULL);
398     bbSetOutputInteractorwxVtkBaseView_model2(NULL);
399     bbSetOutputInteractorwxVtkBaseView_model3(NULL);
400 }
401
402 //===== 
403 // 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)
404 //===== 
405 void wxVtkBaseView_Info::bbUserFinalizeProcessing()
406 {
407 //  THE FINALIZATION METHOD BODY :
408 //    Here does nothing 
409 //    but this is where you should desallocate the internal/output pointers 
410 //    if any
411 }
412
413 }// EO namespace bbcreaMaracasVisu
414
415