]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuwxVtkBaseView_Info.cxx
#3537 Mesh_tool_ApplyDeformation optimization
[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             _box->bbSignalOutputModification();            
168             return false;
169         } // if ok
170     } // if _box
171     return true;
172 }
173
174 bool InteractorwxVtkBaseView::OnRightButtonDown()
175 {
176     if (_box!=NULL)
177     {
178         if ( _box->bbGetInputInteractionType()==9 )
179         {
180             flagDrag=true;
181         }
182         if ( (_box->bbGetInputInteractionType()==4 ) && (_wxvtkbaseview!=NULL) )
183         {
184             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
185             _box->bbSignalOutputModification();
186             return false;
187         } // if _vtkbaseview
188     } // if _box
189     return true;
190 }
191
192 bool InteractorwxVtkBaseView::OnRightButtonUp()
193 {
194     if (_box!=NULL)
195     {
196         if ( _box->bbGetInputInteractionType()==9 )
197         {
198             flagDrag=false;
199         }
200         if ( (_box->bbGetInputInteractionType()==5 ) && (_wxvtkbaseview!=NULL) )
201         {
202             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
203             _box->bbSignalOutputModification();
204             return false;
205         } // if _vtkbaseview
206     } // if _box
207     return true;
208 }
209
210
211 bool InteractorwxVtkBaseView::OnLeftDClick()
212 {
213     if (_box!=NULL)
214     {
215         if ( (_box->bbGetInputInteractionType()==6 ) && (_wxvtkbaseview!=NULL) )
216         {
217             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
218             _box->bbSignalOutputModification();
219             return false;
220         } // if _vtkbaseview
221     } // if _box
222     return true;
223 }
224
225 bool InteractorwxVtkBaseView::OnRightDClick()
226 {
227     if (_box!=NULL)
228     {
229         if ( (_box->bbGetInputInteractionType()==7 ) && (_wxvtkbaseview!=NULL) )
230         {
231             _box->SetwxVtkBaseViewOutputs( _wxvtkbaseview );
232             _box->bbSignalOutputModification();
233             return false;
234         } // if _vtkbaseview
235     } // if _box
236     return true;
237 }
238
239 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,wxVtkBaseView_Info)
240 BBTK_BLACK_BOX_IMPLEMENTATION(wxVtkBaseView_Info,bbtk::AtomicBlackBox);
241
242 void wxVtkBaseView_Info::SetwxVtkBaseViewOutputs(wxVtkBaseView *wxvtkbaseview )
243 {
244     if (wxvtkbaseview!=NULL)
245     {
246         bbSetOutputvtkRenderer( wxvtkbaseview->GetRenderer() );
247         bbSetOutputDirection( wxvtkbaseview->GetDirection() );
248         bbSetOutputwxVtkBaseView(wxvtkbaseview);
249         vtkBaseData *vtkbasedata = wxvtkbaseview->GetVtkBaseData();
250         if (vtkbasedata!=NULL)
251         {
252             marImageData *marimagedata = vtkbasedata->GetMarImageData();
253             if (marimagedata!=NULL)
254             {
255                 bbSetOutputImage( marimagedata->GetImageData() );
256             } // MarImageData
257             std::vector<double> LstWindowColorLevel;
258             LstWindowColorLevel.push_back( vtkbasedata->GetColorWindow() );
259             LstWindowColorLevel.push_back( vtkbasedata->GetColorLevel() );
260             bbSetOutputWindowColorLevel( LstWindowColorLevel );
261             
262             std::vector<double> lstPoint;
263             lstPoint.push_back( vtkbasedata->GetX() );
264             lstPoint.push_back( vtkbasedata->GetY() );
265             lstPoint.push_back( vtkbasedata->GetZ() );
266             bbSetOutputPoint( lstPoint );
267
268             int pointMouseX,pointMouseY,pointMouseZ;
269             vtkbasedata->GetPointMouse(pointMouseX,pointMouseY,pointMouseZ); 
270             std::vector<double> lstPointMouse;
271             lstPointMouse.push_back( pointMouseX );
272             lstPointMouse.push_back( pointMouseY );
273             lstPointMouse.push_back( pointMouseZ );
274             bbSetOutputPointMouse( lstPointMouse );
275
276             double normal[3];
277             std::vector<double> lstNormal;
278             wxvtkbaseview->GetNormal( normal );
279             lstNormal.push_back( normal[0] );
280             lstNormal.push_back( normal[1] );
281             lstNormal.push_back( normal[2] );
282             bbSetOutputNormal( lstNormal );
283             
284             bbSetOutputInterpolation( vtkbasedata->GetInterpolate() );
285         }  // BaseData
286     } // if wxvtkbaseview
287 }
288
289 //===== 
290 // 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)
291 //===== 
292 void wxVtkBaseView_Info::Process()
293 {
294 // THE MAIN PROCESSING METHOD BODY
295 //   Here we simply set the input 'In' value to the output 'Out'
296 //   And print out the output value
297 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
298 //    void bbSet{Input|Output}NAME(const TYPE&)
299 //    const TYPE& bbGet{Input|Output}NAME() const 
300 //    Where :
301 //    * NAME is the name of the input/output
302 //      (the one provided in the attribute 'name' of the tag 'input')
303 //    * TYPE is the C++ type of the input/output
304 //      (the one provided in the attribute 'type' of the tag 'input')
305     if (bbGetInputInteractionType()==0)
306     {
307         SetwxVtkBaseViewOutputs( bbGetInputwxVtkBaseView() );
308     }
309     
310     if (firsttime==true)
311     {
312         firsttime=false;
313         if (bbGetInputInteractionType()!=0)
314         {
315             SetwxVtkBaseViewOutputs( bbGetInputwxVtkBaseView() );
316             
317             interactorwxvtkbaseview    = new InteractorwxVtkBaseView( this  );
318             if (bbGetInputwxVtkBaseView()!=NULL)
319             {
320                 interactorwxvtkbaseview->SetwxVtkBaseView(  bbGetInputwxVtkBaseView() );
321                 interactorwxvtkbaseview->AddThisInteractor();
322             } // if wxVtkBaseView
323             
324             interactorwxvtkbaseview1    = new InteractorwxVtkBaseView( this  );
325             if (bbGetInputwxVtkBaseView1()!=NULL)
326             {
327                 interactorwxvtkbaseview1->SetwxVtkBaseView(  bbGetInputwxVtkBaseView1() );
328                 interactorwxvtkbaseview1->AddThisInteractor();
329             } // if wxVtkBaseView2
330             
331             interactorwxvtkbaseview2    = new InteractorwxVtkBaseView( this  );
332             if (bbGetInputwxVtkBaseView2()!=NULL)
333             {
334                 interactorwxvtkbaseview2->SetwxVtkBaseView(  bbGetInputwxVtkBaseView2() );
335                 interactorwxvtkbaseview2->AddThisInteractor();
336             } // if wxVtkBaseView2
337
338             interactorwxvtkbaseview3    = new InteractorwxVtkBaseView( this  );
339             if (bbGetInputwxVtkBaseView3()!=NULL)
340             {
341                 interactorwxvtkbaseview3->SetwxVtkBaseView(  bbGetInputwxVtkBaseView3() );
342                 interactorwxvtkbaseview3->AddThisInteractor();
343             } // if wxVtkBaseView3
344             
345             bbSetOutputInteractorwxVtkBaseView_model(   interactorwxvtkbaseview  );
346             bbSetOutputInteractorwxVtkBaseView_model1(  interactorwxvtkbaseview1 );
347             bbSetOutputInteractorwxVtkBaseView_model2(  interactorwxvtkbaseview2 );
348             bbSetOutputInteractorwxVtkBaseView_model3(  interactorwxvtkbaseview3 );
349         } // if InteractionType !=0
350     } // if firsttime
351     
352     bbSetOutputBox_wxVtkBaseView_Info( this );
353 }
354
355 //===== 
356 // 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)
357 //===== 
358 void wxVtkBaseView_Info::bbUserSetDefaultValues()
359 {
360 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
361 //    Here we initialize the input 'In' to 0
362     firsttime=true;
363         std::vector<double> LstWindowColorLevel;
364         LstWindowColorLevel.push_back( 1000 );
365         LstWindowColorLevel.push_back( 500 );
366     bbSetInputwxVtkBaseView( NULL );
367     bbSetInputwxVtkBaseView2( NULL );
368     bbSetInputwxVtkBaseView3( NULL );
369     bbSetInputInteractionType(0);
370     bbSetOutputWindowColorLevel( LstWindowColorLevel );
371     bbSetOutputDirection(2);
372     bbSetOutputInterpolation(true);
373     bbSetOutputvtkRenderer(NULL);
374     interactorwxvtkbaseview=NULL;
375     interactorwxvtkbaseview2=NULL;
376     interactorwxvtkbaseview3=NULL;
377     bbSetOutputInteractorwxVtkBaseView_model(   interactorwxvtkbaseview  );
378     bbSetOutputInteractorwxVtkBaseView_model1(  interactorwxvtkbaseview1 );
379     bbSetOutputInteractorwxVtkBaseView_model2(  interactorwxvtkbaseview2 );
380     bbSetOutputInteractorwxVtkBaseView_model3(  interactorwxvtkbaseview3 );
381 }
382
383 //===== 
384 // 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)
385 //===== 
386 void wxVtkBaseView_Info::bbUserInitializeProcessing()
387 {
388 //  THE INITIALIZATION METHOD BODY :
389 //    Here does nothing 
390 //    but this is where you should allocate the internal/output pointers 
391 //    if any
392     bbSetOutputInteractorwxVtkBaseView_model(NULL);
393     bbSetOutputInteractorwxVtkBaseView_model1(NULL);
394     bbSetOutputInteractorwxVtkBaseView_model2(NULL);
395     bbSetOutputInteractorwxVtkBaseView_model3(NULL);
396 }
397
398 //===== 
399 // 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)
400 //===== 
401 void wxVtkBaseView_Info::bbUserFinalizeProcessing()
402 {
403 //  THE FINALIZATION METHOD BODY :
404 //    Here does nothing 
405 //    but this is where you should desallocate the internal/output pointers 
406 //    if any
407 }
408
409 }// EO namespace bbcreaMaracasVisu
410
411