1 /*=========================================================================
4 Module: $RCSfile: wxMaracas_ViewerWidget.cxx,v $
6 Date: $Date: 2008/10/31 16:32:42 $
7 Version: $Revision: 1.1 $
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;
139 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
140 sizer->Add( wxwindow , 1, wxEXPAND, 0);
141 panel->SetSizer(sizer);
142 panel->SetAutoLayout(true);
145 // mbbtkViewerMaracas= NULL;
147 //-------------------------------------------------------------------------
149 wxMaracas_ViewerWidget::~wxMaracas_ViewerWidget()
154 //------------------------------------------------------------------------------------------------------------
156 //------------------------------------------------------------------------------------------------------------
158 //-------------------------------------------------------------------------
160 void wxMaracas_ViewerWidget::ConfigureVTK()
164 if ( mvtk2Dbaseview !=NULL ) { mvtk2Dbaseview -> Configure(); }
165 if ( mvtkmpr2Dview_X !=NULL ) { mvtkmpr2Dview_X -> Configure(); }
166 if ( mvtkmpr2Dview_Y !=NULL ) { mvtkmpr2Dview_Y -> Configure(); }
167 if ( mvtkmpr2Dview_Z !=NULL ) { mvtkmpr2Dview_Z -> Configure(); }
168 if ( mvtkplane2Dview !=NULL ) { mvtkplane2Dview -> Configure(); }
169 if ( mwidgetMesure !=NULL ) { mwidgetMesure -> ConfigureA(mvtkplane2Dview);}
170 if ( mwidgetMesure !=NULL ) { mwidgetMesure -> ConfigureA(mvtkplane2Dview);}
171 if ( mwidgetMesure !=NULL ) { mwidgetMesure -> SetActiveLink(true); }
172 if ( mwidgetMesure !=NULL ) { mwidgetMesure -> SetMesureScale( 1 ); }
173 if ( mwxsphereview !=NULL ) { mwxsphereview -> Configure(); }
175 if (mwxvtk3Dbaseview_Clipping3D !=NULL) { mwxvtk3Dbaseview_Clipping3D -> Configure(); }
176 if (mwxvtkmpr3Dview !=NULL) { mwxvtkmpr3Dview -> Configure(); }
177 if (mwxvtkclipping3Dview !=NULL) { mwxvtkclipping3Dview -> Configure(); }
179 if (mvtkmprbasedata!=NULL)
181 x = mvtkmprbasedata -> GetMaxPositionX()/2;
182 y = mvtkmprbasedata -> GetMaxPositionY()/2;
183 z = mvtkmprbasedata -> GetMaxPositionZ()/2;
184 mvtkmprbasedata->SetX( x );
185 mvtkmprbasedata->SetY( y );
186 mvtkmprbasedata->SetZ( z );
191 //-------------------------------------------------------------------------
193 void wxMaracas_ViewerWidget::Refresh(bool eraseBackground ,const wxRect* rect ) // virtual eraseBackground=true , rect=NULL
195 wxPanel::Refresh(false);
198 //-------------------------------------------------------------------------
199 void wxMaracas_ViewerWidget::RefreshView()
201 if (mvtk2Dbaseview !=NULL ){ mvtk2Dbaseview -> Refresh(); }
202 if (mvtkmpr2Dview_X !=NULL ){ mvtkmpr2Dview_X -> Refresh(); }
203 if (mvtkmpr2Dview_Y !=NULL ){ mvtkmpr2Dview_Y -> Refresh(); }
204 if (mvtkmpr2Dview_Z !=NULL ){ mvtkmpr2Dview_Z -> Refresh(); }
205 if (mvtkplane2Dview !=NULL ){ mvtkplane2Dview -> Refresh(); }
206 if (mwxsphereview !=NULL ){ mwxsphereview -> Refresh(); }
208 if (mwxvtkmpr3Dview !=NULL ){ mwxvtkmpr3Dview -> RefreshView(); }
209 if (mwxvtkclipping3Dview !=NULL ){ mwxvtkclipping3Dview -> Refresh(); }
210 if (mwxvtk3Dbaseview_Clipping3D !=NULL ){ mwxvtk3Dbaseview_Clipping3D -> Refresh(); }
213 //-------------------------------------------------------------------------
215 wxVtkBaseView *wxMaracas_ViewerWidget::GetwxVtkBaseView()
217 wxVtkBaseView *wxvtkbaseview=NULL;
218 if (mvtk2Dbaseview!=NULL) { wxvtkbaseview = mvtk2Dbaseview; }
219 if (mvtkmpr2Dview_X!=NULL) { wxvtkbaseview = mvtkmpr2Dview_X; }
220 if (mvtkmpr2Dview_Y!=NULL) { wxvtkbaseview = mvtkmpr2Dview_Y; }
221 if (mvtkmpr2Dview_Z!=NULL) { wxvtkbaseview = mvtkmpr2Dview_Z; }
222 if (mvtkplane2Dview!=NULL) { wxvtkbaseview = mvtkplane2Dview; }
223 if (mwxsphereview!=NULL) { wxvtkbaseview = mwxsphereview; }
224 if (mwxvtk3Dbaseview_Clipping3D!=NULL) { wxvtkbaseview = mwxvtk3Dbaseview_Clipping3D;}
225 return wxvtkbaseview ;
228 void wxMaracas_ViewerWidget::SetImage( vtkImageData *image )
230 printf("EED wxMaracas_ViewerWidget::SetImage IMPORTANT this methode is missing \n");
233 double wxMaracas_ViewerWidget :: GetX()
235 return mvtkmprbasedata->GetX();
238 double wxMaracas_ViewerWidget :: GetY()
240 return mvtkmprbasedata->GetY();
243 double wxMaracas_ViewerWidget :: GetZ()
245 return mvtkmprbasedata->GetZ();
246 // return mvtk2Dbaseview->GetVtkBaseData()->GetZ();