1 /*=========================================================================
4 Module: $RCSfile: wxMaracas_ViewerWidget.cxx,v $
6 Date: $Date: 2008/12/03 11:42:54 $
7 Version: $Revision: 1.3 $
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;
58 mvtk2Dbaseview = new wxVtk2DBaseView(panel);
59 mvtk2Dbaseview->SetVtkBaseData(mvtkmprbasedata);
60 wxwindow = mvtk2Dbaseview->GetWxVTKRenderWindowInteractor();
66 mvtkmpr2Dview_Z = new wxVtkMPR2DView(panel,0);
67 mvtkmpr2Dview_Z->SetVtkBaseData(mvtkmprbasedata);
68 wxwindow = mvtkmpr2Dview_Z->GetWxVTKRenderWindowInteractor();
72 mvtkmpr2Dview_X = new wxVtkMPR2DView(panel,1);
73 mvtkmpr2Dview_X->SetVtkBaseData(mvtkmprbasedata);
74 wxwindow = mvtkmpr2Dview_X->GetWxVTKRenderWindowInteractor();
78 mvtkmpr2Dview_Y = new wxVtkMPR2DView(panel,2);
79 mvtkmpr2Dview_Y->SetVtkBaseData(mvtkmprbasedata);
80 wxwindow = mvtkmpr2Dview_Y->GetWxVTKRenderWindowInteractor();
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;
95 mwxsphereview = new wxSphereView( panel , mvtkmprbasedata, mvtkmprbasedata->GetImageData() );
96 wxwindow=mwxsphereview->GetWxVTKRenderWindowInteractor();
102 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
103 mwxvtk3Dbaseview_Clipping3D = new wxVtk3DBaseView( panelClipping3D );
105 mwxvtkclipping3Dview = new wxVtkClipping3DView(mwxvtk3Dbaseview_Clipping3D);
106 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
107 vtkclipping3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
108 vtkclipping3Ddataviewer->Configure();
109 mwxvtkclipping3Dview->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
111 mwxvtkmpr3Dview = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D );
112 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
113 vtkmpr3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
114 vtkmpr3Ddataviewer->Configure();
115 mwxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
117 wxWindow *window3D = mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor();
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 );
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);
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;
141 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
142 mwxvtk3Dbaseview_Clipping3D = new wxVtk3DBaseView( panelClipping3D );
144 mwxvtkmpr3Dview = new wxVtkMPR3DView( mwxvtk3Dbaseview_Clipping3D );
145 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
146 vtkmpr3Ddataviewer->SetVtkMPRBaseData(mvtkmprbasedata);
147 vtkmpr3Ddataviewer->Configure();
148 mwxvtkmpr3Dview->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
150 wxWindow *window3D = mwxvtk3Dbaseview_Clipping3D->GetWxVTKRenderWindowInteractor();
152 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
153 wxPanel *controlPanelMPR3D = mwxvtkmpr3Dview->CreateControlPanel(panelControl);
155 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
156 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
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;
169 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
170 sizer->Add( wxwindow , 1, wxEXPAND, 0);
171 panel->SetSizer(sizer);
172 panel->SetAutoLayout(true);
175 // mbbtkViewerMaracas= NULL;
177 //-------------------------------------------------------------------------
179 wxMaracas_ViewerWidget::~wxMaracas_ViewerWidget()
184 //------------------------------------------------------------------------------------------------------------
186 //------------------------------------------------------------------------------------------------------------
188 //-------------------------------------------------------------------------
190 void wxMaracas_ViewerWidget::ConfigureVTK()
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(); }
205 if (mwxvtk3Dbaseview_Clipping3D !=NULL) { mwxvtk3Dbaseview_Clipping3D -> Configure(); }
206 if (mwxvtkmpr3Dview !=NULL) { mwxvtkmpr3Dview -> Configure(); }
207 if (mwxvtkclipping3Dview !=NULL) { mwxvtkclipping3Dview -> Configure(); }
209 if (mvtkmprbasedata!=NULL)
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 );
221 //-------------------------------------------------------------------------
223 void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) // virtual eraseBackground=true , rect=NULL
225 wxPanel::Refresh(false);
228 //-------------------------------------------------------------------------
229 void wxMaracas_ViewerWidget::RefreshView()
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(); }
238 if (mwxvtkmpr3Dview !=NULL ){ mwxvtkmpr3Dview -> RefreshView(); }
239 if (mwxvtkclipping3Dview !=NULL ){ mwxvtkclipping3Dview -> Refresh(); }
240 if (mwxvtk3Dbaseview_Clipping3D !=NULL ){ mwxvtk3Dbaseview_Clipping3D -> Refresh(); }
243 //-------------------------------------------------------------------------
245 wxVtkBaseView *wxMaracas_ViewerWidget::GetwxVtkBaseView()
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 ;
258 void wxMaracas_ViewerWidget::SetImage( vtkImageData *image )
260 //printf("EED wxMaracas_ViewerWidget::SetImage IMPORTANT this methode is missing \n");
261 marImageData* mar = mvtkmprbasedata->GetMarImageData();
262 mar->removeImageData(0);
263 mar->AddImageData(image);
272 double wxMaracas_ViewerWidget :: GetX()
274 return mvtkmprbasedata->GetX();
277 double wxMaracas_ViewerWidget :: GetY()
279 return mvtkmprbasedata->GetY();
282 double wxMaracas_ViewerWidget :: GetZ()
284 return mvtkmprbasedata->GetZ();
285 // return mvtk2Dbaseview->GetVtkBaseData()->GetZ();