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