1 /*=========================================================================
4 Module: $RCSfile: wxMaracas_ViewerWidget.cxx,v $
6 Date: $Date: 2009/04/24 15:26:02 $
7 Version: $Revision: 1.9 $
9 Copyright: (c) 2002, 2003
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.
16 =========================================================================*/
18 //------------------------------------------------------------------------------------------------------------
19 // Definition includes
20 //------------------------------------------------------------------------------------------------------------
21 #include "wxMaracas_ViewerWidget.h"
23 //------------------------------------------------------------------------------------------------------------
25 //------------------------------------------------------------------------------------------------------------
28 //------------------------------------------------------------------------------------------------------------
29 // Constructors & Destructors
30 //------------------------------------------------------------------------------------------------------------
33 wxMaracas_ViewerWidget::wxMaracas_ViewerWidget(wxWindow *parent, vtkImageData* imagedata, int type)
34 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
36 wxPanel *panel = this;
37 wxWindow *wxwindow = NULL;
41 marImageData *marimagedata = new marImageData( imagedata );
42 mvtkmprbasedata = new vtkMPRBaseData();
43 mvtkmprbasedata->SetMarImageData(marimagedata);
45 mvtk2Dbaseview = NULL;
46 mvtkmpr2Dview_X = NULL;
47 mvtkmpr2Dview_Y = NULL;
48 mvtkmpr2Dview_Z = NULL;
49 mvtkplane2Dview = NULL;
52 mwxvtkclipping3Dview = NULL;
53 mwxvtk3Dbaseview_Clipping3D = NULL;
54 mwxvtkmpr3Dview = NULL;
59 mvtk2Dbaseview = new wxVtk2DBaseView(panel);
60 mvtk2Dbaseview->SetVtkBaseData(mvtkmprbasedata);
61 wxwindow = mvtk2Dbaseview->GetWxVTKRenderWindowInteractor();
67 mvtkmpr2Dview_Z = new wxVtkMPR2DView(panel,2);
68 mvtkmpr2Dview_Z->SetVtkBaseData(mvtkmprbasedata);
69 wxwindow = mvtkmpr2Dview_Z->GetWxVTKRenderWindowInteractor();
73 mvtkmpr2Dview_X = new wxVtkMPR2DView(panel,0);
74 mvtkmpr2Dview_X->SetVtkBaseData(mvtkmprbasedata);
75 wxwindow = mvtkmpr2Dview_X->GetWxVTKRenderWindowInteractor();
80 mvtkmpr2Dview_Y = new wxVtkMPR2DView(panel,1);
81 mvtkmpr2Dview_Y->SetVtkBaseData(mvtkmprbasedata);
82 wxwindow = mvtkmpr2Dview_Y->GetWxVTKRenderWindowInteractor();
88 mwidgetMesure = new wxWidgetMesure2D_Plane_in_MPR(panel);
89 mvtkplane2Dview = new vtkPlane2DView( mwidgetMesure->GetWindow2());
90 mwidgetMesure -> SetVtkPlane2DView( mvtkplane2Dview );
91 mvtkplane2Dview -> SetImgSize( 200 );
92 mvtkplane2Dview -> SetVtkBaseData(mvtkmprbasedata);
93 wxwindow = mwidgetMesure;
97 mwxsphereview = new wxSphereView( panel , mvtkmprbasedata, mvtkmprbasedata->GetImageData() );
98 wxwindow=mwxsphereview->GetWxVTKRenderWindowInteractor();
104 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
105 mwxvtk3Dbaseview_Clipping3D = new wxVtk3DBaseView( panelClipping3D );
107 mwxvtkclipping3Dview = new wxVtkClipping3DView(mwxvtk3Dbaseview_Clipping3D);
108 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
109 vtkclipping3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
110 vtkclipping3Ddataviewer->Configure();
111 mwxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
113 mwxvtkmpr3Dview = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D );
114 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
115 vtkmpr3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
116 vtkmpr3Ddataviewer->Configure();
117 mwxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
119 wxWindow *window3D = mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor();
121 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
122 wxPanel *controlPanelMPR3D = mwxvtkmpr3Dview->CreateControlPanel(panelControl);
123 wxPanel *controlPanelClipping3D = mwxvtkclipping3Dview->CreateControlPanel(panelControl);
124 // mbtnCutImageData = new wxCheckBox(panelControl,-1,_T("Cut Module"));
125 // Connect(_btnCutImageData->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxMPRWidget::OnCutImagaData );
127 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
128 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
129 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
130 // sizerCtrol->Add( mbtnCutImageData , 1, wxALL, 2);
132 panelControl->SetAutoLayout(true);
133 panelControl->SetSizer(sizerCtrol);
134 panelControl->SetSize(400,350);
135 panelControl->Layout();
136 panelClipping3D -> SetMinimumPaneSize( 5 );
137 panelClipping3D -> SplitHorizontally( panelControl , window3D , 10 );
138 wxwindow=panelClipping3D;
143 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
144 mwxvtk3Dbaseview_Clipping3D = new wxVtk3DBaseView( panelClipping3D );
146 mwxvtkmpr3Dview = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D );
147 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
148 vtkmpr3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
149 vtkmpr3Ddataviewer->Configure();
150 mwxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
152 wxWindow *window3D = mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor();
154 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
155 wxPanel *controlPanelMPR3D = mwxvtkmpr3Dview->CreateControlPanel(panelControl);
157 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
158 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
160 panelControl->SetAutoLayout(true);
161 panelControl->SetSizer(sizerCtrol);
162 panelControl->SetSize(400,350);
163 panelControl->Layout();
164 panelClipping3D -> SetMinimumPaneSize( 5 );
165 panelClipping3D -> SplitHorizontally( panelControl , window3D , 10 );
166 wxwindow=panelClipping3D;
171 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
172 sizer->Add( wxwindow , 1, wxGROW);
173 panel->SetSizer(sizer);
174 panel->SetAutoLayout(true);
179 // mbbtkViewerMaracas= NULL;
181 //-------------------------------------------------------------------------
183 wxMaracas_ViewerWidget::~wxMaracas_ViewerWidget()
185 if (mvtkmprbasedata) { delete mvtkmprbasedata; }
186 if (mvtk2Dbaseview) { delete mvtk2Dbaseview; }
187 if (mvtkmpr2Dview_X) { delete mvtkmpr2Dview_X; }
188 if (mvtkmpr2Dview_Y) { delete mvtkmpr2Dview_Y; }
189 if (mvtkmpr2Dview_Z) { delete mvtkmpr2Dview_Z; }
190 if (mwidgetMesure) { delete mwidgetMesure; }
191 if (mvtkplane2Dview) { delete mvtkplane2Dview; }
192 if (mwxsphereview) { delete mwxsphereview; }
193 if (mwxvtkclipping3Dview) { delete mwxvtkclipping3Dview; }
194 if (mwxvtk3Dbaseview_Clipping3D){ delete mwxvtk3Dbaseview_Clipping3D; }
195 if (mwxvtkmpr3Dview) { delete mwxvtkmpr3Dview; }
198 //------------------------------------------------------------------------------------------------------------
200 //------------------------------------------------------------------------------------------------------------
202 //-------------------------------------------------------------------------
204 void wxMaracas_ViewerWidget::ConfigureVTK()
208 if ( mvtk2Dbaseview !=NULL ) { mvtk2Dbaseview -> Configure(); }
209 if ( mvtkmpr2Dview_X !=NULL ) { mvtkmpr2Dview_X -> Configure(); }
210 if ( mvtkmpr2Dview_Y !=NULL ) { mvtkmpr2Dview_Y -> Configure(); }
211 if ( mvtkmpr2Dview_Z !=NULL ) { mvtkmpr2Dview_Z -> Configure(); }
212 if ( mvtkplane2Dview !=NULL ) { mvtkplane2Dview -> Configure(); }
213 if ( mwidgetMesure !=NULL ) { mwidgetMesure -> ConfigureA(mvtkplane2Dview);}
214 if ( mwidgetMesure !=NULL ) { mwidgetMesure -> ConfigureA(mvtkplane2Dview);}
215 if ( mwidgetMesure !=NULL ) { mwidgetMesure -> SetActiveLink(true); }
216 if ( mwidgetMesure !=NULL ) { mwidgetMesure -> SetMesureScale( 1 ); }
217 if ( mwxsphereview !=NULL ) { mwxsphereview -> Configure(); }
219 if (mwxvtk3Dbaseview_Clipping3D !=NULL) { mwxvtk3Dbaseview_Clipping3D -> Configure(); }
220 if (mwxvtkmpr3Dview !=NULL) { mwxvtkmpr3Dview -> Configure(); }
221 if (mwxvtkclipping3Dview !=NULL) { mwxvtkclipping3Dview -> Configure(); }
223 if (mvtkmprbasedata!=NULL)
225 x = mvtkmprbasedata -> GetMaxPositionX()/2;
226 y = mvtkmprbasedata -> GetMaxPositionY()/2;
227 z = mvtkmprbasedata -> GetMaxPositionZ()/2;
228 mvtkmprbasedata->SetX( x );
229 mvtkmprbasedata->SetY( y );
230 mvtkmprbasedata->SetZ( z );
235 //-------------------------------------------------------------------------
237 void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) // virtual eraseBackground=true , rect=NULL
239 wxPanel::Refresh(false);
242 //-------------------------------------------------------------------------
243 void wxMaracas_ViewerWidget::RefreshView()
246 if (mvtk2Dbaseview !=NULL ){ mvtk2Dbaseview -> Refresh(); }
247 if (mvtkmpr2Dview_X !=NULL ){ mvtkmpr2Dview_X -> Refresh(); }
248 if (mvtkmpr2Dview_Y !=NULL ){ mvtkmpr2Dview_Y -> Refresh(); }
249 if (mvtkmpr2Dview_Z !=NULL ){ mvtkmpr2Dview_Z -> Refresh(); }
250 if (mvtkplane2Dview !=NULL ){ mvtkplane2Dview -> Refresh(); }
251 if (mwxsphereview !=NULL ){ mwxsphereview -> Refresh(); }
253 if (mwxvtkmpr3Dview !=NULL ){ mwxvtkmpr3Dview -> RefreshView(); }
254 if (mwxvtkclipping3Dview !=NULL ){ mwxvtkclipping3Dview -> Refresh(); }
255 if (mwxvtk3Dbaseview_Clipping3D !=NULL ){ mwxvtk3Dbaseview_Clipping3D -> Refresh(); }
259 //-------------------------------------------------------------------------
261 wxVtkBaseView *wxMaracas_ViewerWidget::GetwxVtkBaseView()
263 wxVtkBaseView *wxvtkbaseview=NULL;
264 if (mvtk2Dbaseview!=NULL) { wxvtkbaseview = mvtk2Dbaseview; }
265 if (mvtkmpr2Dview_X!=NULL) { wxvtkbaseview = mvtkmpr2Dview_X; }
266 if (mvtkmpr2Dview_Y!=NULL) { wxvtkbaseview = mvtkmpr2Dview_Y; }
267 if (mvtkmpr2Dview_Z!=NULL) { wxvtkbaseview = mvtkmpr2Dview_Z; }
268 if (mvtkplane2Dview!=NULL) { wxvtkbaseview = mvtkplane2Dview; }
269 if (mwxsphereview!=NULL) { wxvtkbaseview = mwxsphereview; }
270 if (mwxvtk3Dbaseview_Clipping3D!=NULL) { wxvtkbaseview = mwxvtk3Dbaseview_Clipping3D;}
271 return wxvtkbaseview ;
274 void wxMaracas_ViewerWidget::SetImage( vtkImageData *image )
276 marImageData* mar = mvtkmprbasedata->GetMarImageData();
277 mar->removeImageData(0);
278 mar->AddImageData(image);
287 double wxMaracas_ViewerWidget :: GetX()
289 return mvtkmprbasedata->GetX();
292 double wxMaracas_ViewerWidget :: GetY()
294 return mvtkmprbasedata->GetY();
297 double wxMaracas_ViewerWidget :: GetZ()
299 return mvtkmprbasedata->GetZ();
300 // return mvtk2Dbaseview->GetVtkBaseData()->GetZ();