]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxMaracas_ViewerWidget.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxMaracas_ViewerWidget.cxx
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: wxMaracas_ViewerWidget.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/11/24 15:11:25 $
7   Version:   $Revision: 1.2 $
8
9   Copyright: (c) 2002, 2003
10   License:
11   
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notice for more information.
15
16 =========================================================================*/
17
18 //------------------------------------------------------------------------------------------------------------
19 // Definition includes
20 //------------------------------------------------------------------------------------------------------------
21 #include "wxMaracas_ViewerWidget.h"
22
23 //------------------------------------------------------------------------------------------------------------
24 // Other includes
25 //------------------------------------------------------------------------------------------------------------
26
27
28         //------------------------------------------------------------------------------------------------------------
29         // Constructors & Destructors
30         //------------------------------------------------------------------------------------------------------------
31
32
33         wxMaracas_ViewerWidget::wxMaracas_ViewerWidget(wxWindow *parent, vtkImageData* imagedata, int type)
34                 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
35         {
36                 wxPanel *panel = this;
37                 wxWindow *wxwindow = NULL;
38
39                 mType = type;
40
41         marImageData    *marimagedata   = new marImageData( imagedata );                        
42                 mvtkmprbasedata                                 = new vtkMPRBaseData(); 
43                 mvtkmprbasedata->SetMarImageData(marimagedata);
44
45                 mvtk2Dbaseview                          = NULL;
46                 mvtkmpr2Dview_X                         = NULL;
47                 mvtkmpr2Dview_Y                         = NULL;
48                 mvtkmpr2Dview_Z                         = NULL;
49                 mvtkplane2Dview                         = NULL;
50                 mwidgetMesure                           = NULL;
51                 mwxsphereview                           = NULL;
52                 mwxvtkclipping3Dview            = NULL;
53                 mwxvtk3Dbaseview_Clipping3D     = NULL;
54                 mwxvtkmpr3Dview                         = NULL; 
55
56                 if (type==-1)
57                 {
58                         mvtk2Dbaseview  = new wxVtk2DBaseView(panel);
59                         mvtk2Dbaseview->SetVtkBaseData(mvtkmprbasedata);
60                         wxwindow                = mvtk2Dbaseview->GetWxVTKRenderWindowInteractor();
61                 }
62
63
64                 if (type==0)
65                 {
66                         mvtkmpr2Dview_Z = new wxVtkMPR2DView(panel,0);
67                         mvtkmpr2Dview_Z->SetVtkBaseData(mvtkmprbasedata);
68                         wxwindow                = mvtkmpr2Dview_Z->GetWxVTKRenderWindowInteractor();
69                 }
70                 if (type==1)
71                 {
72                         mvtkmpr2Dview_X = new wxVtkMPR2DView(panel,1);
73                         mvtkmpr2Dview_X->SetVtkBaseData(mvtkmprbasedata);
74                         wxwindow                =       mvtkmpr2Dview_X->GetWxVTKRenderWindowInteractor();
75                 }
76                 if (type==2)
77                 {
78                         mvtkmpr2Dview_Y = new wxVtkMPR2DView(panel,2);
79                         mvtkmpr2Dview_Y->SetVtkBaseData(mvtkmprbasedata);
80                         wxwindow                = mvtkmpr2Dview_Y->GetWxVTKRenderWindowInteractor();
81                 }
82
83
84                 if (type==3)
85                 {
86                         mwidgetMesure           = new wxWidgetMesure2D_Plane_in_MPR(panel);
87                         mvtkplane2Dview         = new vtkPlane2DView( mwidgetMesure->GetWindow2());
88                         mwidgetMesure   -> SetVtkPlane2DView( mvtkplane2Dview );
89                         mvtkplane2Dview -> SetImgSize( 200 );
90                         mvtkplane2Dview -> SetVtkBaseData(mvtkmprbasedata);
91                         wxwindow                        = mwidgetMesure;
92                 }
93                 if (type==4)
94                 {
95                         mwxsphereview           = new wxSphereView( panel , mvtkmprbasedata, mvtkmprbasedata->GetImageData() );
96                         wxwindow=mwxsphereview->GetWxVTKRenderWindowInteractor();
97                 }
98
99
100                 if (type==5)
101                 {
102                         wxSplitterWindow        *panelClipping3D        = new wxSplitterWindow( panel , -1);
103                         mwxvtk3Dbaseview_Clipping3D                             = new wxVtk3DBaseView( panelClipping3D );
104
105                         mwxvtkclipping3Dview                                            = new wxVtkClipping3DView(mwxvtk3Dbaseview_Clipping3D);
106                         vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer(); 
107                         vtkclipping3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
108                         vtkclipping3Ddataviewer->Configure();
109                         mwxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
110
111                         mwxvtkmpr3Dview                                                 = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D );
112                         vtkMPR3DDataViewer *vtkmpr3Ddataviewer  = new vtkMPR3DDataViewer(); 
113                         vtkmpr3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
114                         vtkmpr3Ddataviewer->Configure();
115                         mwxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
116
117                         wxWindow        *window3D                                       = mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor();
118
119                         wxPanel                 *panelControl                   = new wxPanel(panelClipping3D,-1);      
120                         wxPanel                 *controlPanelMPR3D              = mwxvtkmpr3Dview->CreateControlPanel(panelControl);
121                         wxPanel                 *controlPanelClipping3D = mwxvtkclipping3Dview->CreateControlPanel(panelControl);
122         //                               mbtnCutImageData               = new wxCheckBox(panelControl,-1,_T("Cut Module"));
123         //              Connect(_btnCutImageData->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED  , (wxObjectEventFunction) &wxMPRWidget::OnCutImagaData );
124
125                         wxFlexGridSizer  *sizerCtrol             = new wxFlexGridSizer(1);
126                         sizerCtrol->Add(controlPanelMPR3D               , 1, wxALL|wxEXPAND, 2);
127                         sizerCtrol->Add(controlPanelClipping3D  , 1, wxALL|wxEXPAND, 2);
128         //              sizerCtrol->Add( mbtnCutImageData               , 1, wxALL, 2);
129
130                         panelControl->SetAutoLayout(true);
131                         panelControl->SetSizer(sizerCtrol);
132                         panelControl->SetSize(400,350);
133                         panelControl->Layout();
134                         panelClipping3D -> SetMinimumPaneSize( 5 );
135                         panelClipping3D -> SplitHorizontally( panelControl , window3D , 10  );
136                         wxwindow=panelClipping3D;
137                 }
138
139                 if (type==6)
140                 {
141                         wxSplitterWindow        *panelClipping3D        = new wxSplitterWindow( panel , -1);
142                         mwxvtk3Dbaseview_Clipping3D                             = new wxVtk3DBaseView( panelClipping3D );
143
144                         mwxvtkmpr3Dview                                                 = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D );
145                         vtkMPR3DDataViewer *vtkmpr3Ddataviewer  = new vtkMPR3DDataViewer(); 
146                         vtkmpr3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
147                         vtkmpr3Ddataviewer->Configure();
148                         mwxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
149
150                         wxWindow        *window3D                                       = mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor();
151
152                         wxPanel                 *panelControl                   = new wxPanel(panelClipping3D,-1);      
153                         wxPanel                 *controlPanelMPR3D              = mwxvtkmpr3Dview->CreateControlPanel(panelControl);
154
155                         wxFlexGridSizer  *sizerCtrol             = new wxFlexGridSizer(1);
156                         sizerCtrol->Add(controlPanelMPR3D               , 1, wxALL|wxEXPAND, 2);
157
158                         panelControl->SetAutoLayout(true);
159                         panelControl->SetSizer(sizerCtrol);
160                         panelControl->SetSize(400,350);
161                         panelControl->Layout();
162                         panelClipping3D -> SetMinimumPaneSize( 5 );
163                         panelClipping3D -> SplitHorizontally( panelControl , window3D , 10  );
164                         wxwindow=panelClipping3D;
165                 }
166
167
168
169         wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
170         sizer->Add( wxwindow , 1, wxEXPAND, 0);
171         panel->SetSizer(sizer);
172         panel->SetAutoLayout(true);
173         panel->Layout();
174
175         //   mbbtkViewerMaracas= NULL;
176         }
177         //-------------------------------------------------------------------------
178           
179         wxMaracas_ViewerWidget::~wxMaracas_ViewerWidget()
180         {
181
182         }
183             
184         //------------------------------------------------------------------------------------------------------------
185         // Methods
186         //------------------------------------------------------------------------------------------------------------
187
188         //-------------------------------------------------------------------------
189
190         void wxMaracas_ViewerWidget::ConfigureVTK()
191         {
192                 int x=0,y=0,z=0;
193
194                 if ( mvtk2Dbaseview                             !=NULL ) { mvtk2Dbaseview                               ->      Configure();                            }
195                 if ( mvtkmpr2Dview_X                    !=NULL ) { mvtkmpr2Dview_X                              ->      Configure();                            }
196                 if ( mvtkmpr2Dview_Y                    !=NULL ) { mvtkmpr2Dview_Y                              ->      Configure();                            }
197                 if ( mvtkmpr2Dview_Z                    !=NULL ) { mvtkmpr2Dview_Z                              ->      Configure();                            }
198                 if ( mvtkplane2Dview                    !=NULL ) { mvtkplane2Dview                              ->      Configure();                            }
199                 if ( mwidgetMesure                              !=NULL ) { mwidgetMesure                                ->      ConfigureA(mvtkplane2Dview);}
200                 if ( mwidgetMesure                              !=NULL ) { mwidgetMesure                                ->      ConfigureA(mvtkplane2Dview);}
201                 if ( mwidgetMesure                              !=NULL ) { mwidgetMesure                                ->      SetActiveLink(true);            }
202                 if ( mwidgetMesure                              !=NULL ) { mwidgetMesure                                ->      SetMesureScale( 1 );            }
203                 if ( mwxsphereview                              !=NULL ) { mwxsphereview                                ->      Configure();                            }
204
205                 if (mwxvtk3Dbaseview_Clipping3D !=NULL) { mwxvtk3Dbaseview_Clipping3D   ->      Configure();                            }
206                 if (mwxvtkmpr3Dview                             !=NULL) { mwxvtkmpr3Dview                               ->      Configure();                            }
207                 if (mwxvtkclipping3Dview                !=NULL) { mwxvtkclipping3Dview                  ->      Configure();                            }
208
209                 if (mvtkmprbasedata!=NULL)
210                 {
211                         x = mvtkmprbasedata     ->      GetMaxPositionX()/2;
212                         y = mvtkmprbasedata     ->      GetMaxPositionY()/2;
213                         z = mvtkmprbasedata     ->      GetMaxPositionZ()/2;
214                         mvtkmprbasedata->SetX( x );
215                         mvtkmprbasedata->SetY( y );
216                         mvtkmprbasedata->SetZ( z );
217                 }
218                 RefreshView();
219         }
220
221         //-------------------------------------------------------------------------
222
223   void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect  )  // virtual  eraseBackground=true , rect=NULL
224   {
225     wxPanel::Refresh(false);
226   }
227
228         //-------------------------------------------------------------------------
229         void wxMaracas_ViewerWidget::RefreshView()
230         {
231                         if (mvtk2Dbaseview                              !=NULL ){ mvtk2Dbaseview                                -> Refresh();           }
232                         if (mvtkmpr2Dview_X                             !=NULL ){ mvtkmpr2Dview_X                               -> Refresh();           }
233                         if (mvtkmpr2Dview_Y                             !=NULL ){ mvtkmpr2Dview_Y                               -> Refresh();           }
234                         if (mvtkmpr2Dview_Z                             !=NULL ){ mvtkmpr2Dview_Z                               -> Refresh();           }
235                         if (mvtkplane2Dview                             !=NULL ){ mvtkplane2Dview                               -> Refresh();           }
236                         if (mwxsphereview                               !=NULL ){ mwxsphereview                                 -> Refresh();           }
237
238                         if (mwxvtkmpr3Dview                             !=NULL ){ mwxvtkmpr3Dview                               -> RefreshView();       }
239                         if (mwxvtkclipping3Dview                !=NULL ){ mwxvtkclipping3Dview                  -> Refresh();           }
240                         if (mwxvtk3Dbaseview_Clipping3D !=NULL ){ mwxvtk3Dbaseview_Clipping3D   -> Refresh();           }
241         }
242
243         //-------------------------------------------------------------------------
244
245         wxVtkBaseView *wxMaracas_ViewerWidget::GetwxVtkBaseView()
246         {
247                 wxVtkBaseView *wxvtkbaseview=NULL;
248                 if (mvtk2Dbaseview!=NULL)                               { wxvtkbaseview = mvtk2Dbaseview;                       }
249                 if (mvtkmpr2Dview_X!=NULL)                              { wxvtkbaseview = mvtkmpr2Dview_X;                      }
250                 if (mvtkmpr2Dview_Y!=NULL)                              { wxvtkbaseview = mvtkmpr2Dview_Y;                      }
251                 if (mvtkmpr2Dview_Z!=NULL)                              { wxvtkbaseview = mvtkmpr2Dview_Z;                      }
252                 if (mvtkplane2Dview!=NULL)                              { wxvtkbaseview = mvtkplane2Dview;                      }
253                 if (mwxsphereview!=NULL)                                { wxvtkbaseview = mwxsphereview;                        }
254                 if (mwxvtk3Dbaseview_Clipping3D!=NULL)  { wxvtkbaseview = mwxvtk3Dbaseview_Clipping3D;}
255                 return wxvtkbaseview   ;
256         }
257
258         void wxMaracas_ViewerWidget::SetImage( vtkImageData *image      )
259         {
260                 printf("EED wxMaracas_ViewerWidget::SetImage   IMPORTANT this methode is missing \n");
261         }
262
263         double wxMaracas_ViewerWidget :: GetX()
264         {
265                 return mvtkmprbasedata->GetX();
266         }
267
268         double wxMaracas_ViewerWidget :: GetY()
269         {
270                 return mvtkmprbasedata->GetY();
271         }
272
273         double wxMaracas_ViewerWidget :: GetZ()
274         {
275                 return mvtkmprbasedata->GetZ();
276 //              return mvtk2Dbaseview->GetVtkBaseData()->GetZ();
277         }
278