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