1 /*=========================================================================
4 Module: $RCSfile: wxManualTree_MPRWidget.cxx,v $
6 Date: $Date: 2009/05/14 13:54:35 $
7 Version: $Revision: 1.2 $
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 =========================================================================*/
19 #include "wxManualTree_MPRWidget.h"
22 #include <wx/splitter.h>
23 #include <wx/notebook.h>
24 #include <wx/colordlg.h>
26 #include "vtkInteractorStyle3DView.h"
29 //-------------------------------------------------------------------
30 //-------------------------------------------------------------------
31 //-------------------------------------------------------------------
33 BEGIN_EVENT_TABLE( wxManualTree_MPRWidget, wxPanel )
34 EVT_MENU( 12121, wxManualTree_MPRWidget::OnRefreshView )
35 // EVT_MENU( 12122, wxManualTree_MPRWidget::OnDClickLeft )
39 wxManualTree_MPRWidget::wxManualTree_MPRWidget( wxWindow* parent,
40 marImageData *marimageData ,double voxelSize)
41 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
44 _voxelSize = voxelSize;
45 _marimageData = marimageData;
47 _wxvtk3Dbaseview_Clipping3D_C = NULL;
48 _wxvtkmpr3Dview_C = NULL;
49 _wxvtkclipping3Dview_C = NULL;
51 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
54 _MPRWidget2 = new wxMPRWidget2(pnlSplitter,_marimageData,voxelSize);
55 wxPanel * contour3DView = Create3DViewContour( pnlSplitter , _MPRWidget2->GetVtkMPRBaseData());
56 this->GetSize(&ww,&hh);
58 pnlSplitter -> SplitVertically( _MPRWidget2, contour3DView , 600);
59 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL );
60 sizer -> Add( pnlSplitter ,1,wxGROW ,0);
61 pnlSplitter -> SetMinimumPaneSize( 50 );
62 this -> SetSizer(sizer);
68 //----------------------------------------------------------------------------
70 wxManualTree_MPRWidget::~wxManualTree_MPRWidget( )
72 if (_wxvtk3Dbaseview_Clipping3D_C != NULL) { delete _wxvtk3Dbaseview_Clipping3D_C; }
73 if (_wxvtkmpr3Dview_C != NULL) { delete _wxvtkmpr3Dview_C; }
74 if (_wxvtkclipping3Dview_C != NULL) { delete _wxvtkclipping3Dview_C; }
78 //----------------------------------------------------------------------------
79 wxPanel* wxManualTree_MPRWidget::Create3DViewContour( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
82 wxPanel *panel=new wxPanel(parent,-1);
84 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
85 _wxvtk3Dbaseview_Clipping3D_C = new wxVtk3DBaseView( panelClipping3D );
87 _wxvtkclipping3Dview_C = new wxVtkClipping3DView(_wxvtk3Dbaseview_Clipping3D_C);
88 vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer();
89 vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
90 vtkclipping3Ddataviewer->Configure();
91 _wxvtkclipping3Dview_C->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
93 _wxvtkmpr3Dview_C = new wxVtkMPR3DView( _wxvtk3Dbaseview_Clipping3D_C );
94 vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer();
95 vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
96 vtkmpr3Ddataviewer->Configure();
97 _wxvtkmpr3Dview_C->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
99 wxWindow *window3D = _wxvtk3Dbaseview_Clipping3D_C->GetWxVTKRenderWindowInteractor();
101 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
102 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview_C->CreateControlPanel(panelControl);
103 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview_C->CreateControlPanel(panelControl);
105 // wxBoxSizer *sizerCtrol = new wxBoxSizer(wxVERTICAL);
106 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
108 sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
109 sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
110 panelControl->SetAutoLayout(true);
111 panelControl->SetSizer(sizerCtrol);
112 panelControl->SetSize(400,350);
113 panelControl->Layout();
117 while (pp->GetParent()!=NULL) pp=pp->GetParent();
118 pp->GetSize(&ww,&hh);
121 // panelClipping3D -> SetMinimumPaneSize( -50 );
122 panelClipping3D -> SplitHorizontally( panelControl,window3D, (int)(hh*0.20) );
123 wxwindow=panelClipping3D;
125 wxBoxSizer *sizerH1 = new wxBoxSizer(wxHORIZONTAL);
126 sizerH1->Add(wxwindow , 1, wxALL|wxEXPAND, 0);
127 panel->SetAutoLayout(true);
128 panel->SetSizer(sizerH1);
129 panel->SetSize(400,400);
133 // panel->FitInside();
138 //----------------------------------------------------------------------------
139 void wxManualTree_MPRWidget::ConfigureContour()
141 wxVtkBaseView *wxvtkbaseview;
142 wxvtkbaseview = _MPRWidget2->GetWxVtkBaseView(0,2);
146 wxvtkbaseview->GetSpacing(spc);
148 _manContourControl_2 = new manualContour3VControler(2);
149 _mContourModel_2 = new manualContourModel();
150 _mViewContour_2 = new manualView3VContour(2);
151 _mContourModel_2->SetCloseContour(false);
152 _mViewContour_2->SetModel( _mContourModel_2 );
153 _mViewContour_2->SetWxVtkBaseView( wxvtkbaseview );
154 _mViewContour_2->SetRange( 1 );
155 _mViewContour_2->SetMesureScale( _voxelSize );
158 _mViewContour_2->SetSpacing(spc);
160 ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_2 );
163 wxvtkbaseview = _MPRWidget2->GetWxVtkBaseView(0,0);
164 _manContourControl_0 = new manualContour3VControler(0);
165 _mViewContour_0 = new manualView3VContour(0);
166 _mViewContour_0->SetModel( _mContourModel_2 );
167 _mViewContour_0->SetWxVtkBaseView( wxvtkbaseview );
168 _mViewContour_0->SetRange( 1 );
169 _mViewContour_0->SetMesureScale( _voxelSize );
172 _mViewContour_0->SetSpacing(spc);
174 ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_0 );
177 wxvtkbaseview = _MPRWidget2->GetWxVtkBaseView(0,1);
178 _manContourControl_1 = new manualContour3VControler(1);
179 _mViewContour_1 = new manualView3VContour(1);
180 _mViewContour_1->SetModel( _mContourModel_2 );
181 _mViewContour_1->SetWxVtkBaseView( wxvtkbaseview );
182 _mViewContour_1->SetRange( 1 );
183 _mViewContour_1->SetMesureScale( _voxelSize );
186 _mViewContour_1->SetSpacing(spc);
188 ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_1 );
191 // perpendicular plane
192 wxvtkbaseview = _MPRWidget2->GetWxVtkBaseView(0,3);
193 _manContourControl_p = new manualContourPerpPlaneControler();
194 _mViewContour_p = new manualViewPerpPlaneContour();
195 _mViewContour_p -> SetModel( _mContourModel_2 );
196 _mViewContour_p -> SetWxVtkBaseView( wxvtkbaseview );
197 _mViewContour_p -> SetRange( 1 );
198 _mViewContour_p->SetMesureScale( _voxelSize );
201 _mViewContour_p->SetSpacing(spc);
203 // wxvtkbaseview->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContourControl_p );
204 ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->InsertInteractorStyleMaracas( 0, _manContourControl_p );
206 vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)wxvtkbaseview;
207 _manContourControl_p->SetVtkInteractorStylePlane2D( vtkplane2Dview->GetInteractorstyleplane2D() );
210 wxvtkbaseview = _wxvtkclipping3Dview_C->GetWxvtk3Dbaseview();
211 _manContourControl_3V3D = new manualContour3V3DControler();
212 _mViewContour_3D = new manualView3DContour();
213 _mViewContour_3D->SetModel( _mContourModel_2 );
214 _mViewContour_3D->SetWxVtkBaseView( wxvtkbaseview );
215 _mViewContour_3D->SetRange( 1 );
216 _mViewContour_3D->SetMesureScale(_voxelSize );
219 _mViewContour_3D->SetSpacing(spc);
222 this->_marimageData->GetImageData()->GetDimensions( dim ); // image t=0
223 _mViewContour_3D->SetDimensions( dim[0],dim[1],dim[2] );
224 _mViewContour_3D->SetVtkMPRBaseData( _wxvtkmpr3Dview_C->GetVtkMPR3DDataViewer()->GetVtkMPRBaseData() );
225 ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_3V3D );
228 _manContourControl_0 -> SetVtkMPRBaseData( _MPRWidget2->GetVtkMPRBaseData() );
229 _manContourControl_1 -> SetVtkMPRBaseData( _MPRWidget2->GetVtkMPRBaseData() );
230 _manContourControl_2 -> SetVtkMPRBaseData( _MPRWidget2->GetVtkMPRBaseData() );
231 _manContourControl_p -> SetVtkMPRBaseData( _MPRWidget2->GetVtkMPRBaseData() );
232 _manContourControl_3V3D -> SetVtkMPRBaseData( _MPRWidget2->GetVtkMPRBaseData() );
234 _manContourControl_0 -> SetModelView( _mContourModel_2 , _mViewContour_0 );
235 _manContourControl_0 -> AddManualViewBaseContour( _mViewContour_1 );
236 _manContourControl_0 -> AddManualViewBaseContour( _mViewContour_2 );
237 _manContourControl_0 -> AddManualViewBaseContour( _mViewContour_p );
238 _manContourControl_0 -> AddManualViewBaseContour( _mViewContour_3D );
240 _manContourControl_1 -> SetModelView( _mContourModel_2 , _mViewContour_1);
241 _manContourControl_1 -> AddManualViewBaseContour( _mViewContour_2 );
242 _manContourControl_1 -> AddManualViewBaseContour( _mViewContour_0 );
243 _manContourControl_1 -> AddManualViewBaseContour( _mViewContour_p );
244 _manContourControl_1 -> AddManualViewBaseContour( _mViewContour_3D );
246 _manContourControl_2 -> SetModelView( _mContourModel_2 , _mViewContour_2 );
247 _manContourControl_2 -> AddManualViewBaseContour( _mViewContour_0 );
248 _manContourControl_2 -> AddManualViewBaseContour( _mViewContour_1 );
249 _manContourControl_2 -> AddManualViewBaseContour( _mViewContour_p );
250 _manContourControl_2 -> AddManualViewBaseContour( _mViewContour_3D );
254 wxvtkbaseview = _wxvtkclipping3Dview_C->GetWxvtk3Dbaseview();
255 manualContour3VControler *_manContourControl_3V = new manualContour3VControler(-1);
256 _manContourControl_3V -> SetModelView( _mContourModel_2 , _mViewContour_3D );
257 _manContourControl_3V -> AddManualViewBaseContour( _mViewContour_2 );
258 _manContourControl_3V -> AddManualViewBaseContour( _mViewContour_0 );
259 _manContourControl_3V -> AddManualViewBaseContour( _mViewContour_1 );
260 _manContourControl_3V -> AddManualViewBaseContour( _mViewContour_p );
261 _manContourControl_3V -> SetVtkInteractorStyleBaseView ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView() );
262 _manContourControl_3V3D -> SetManualContour3VControler( _manContourControl_3V );
263 _manContourControl_3V3D -> SetModelView( _mContourModel_2 , _mViewContour_3D );
266 wxvtkbaseview = _MPRWidget2->GetWxVtkBaseView(0,3);
267 manualContour3VControler *_manContourControl_3V_p = new manualContour3VControler(-1);
268 _manContourControl_3V_p -> SetModelView( _mContourModel_2 , _mViewContour_p );
269 _manContourControl_3V_p -> AddManualViewBaseContour( _mViewContour_2 );
270 _manContourControl_3V_p -> AddManualViewBaseContour( _mViewContour_0 );
271 _manContourControl_3V_p -> AddManualViewBaseContour( _mViewContour_1 );
272 _manContourControl_3V_p -> AddManualViewBaseContour( _mViewContour_3D );
273 _manContourControl_3V_p -> SetVtkInteractorStyleBaseView ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView() );
274 _manContourControl_p -> SetManualContour3VControler( _manContourControl_3V_p );
275 _manContourControl_p -> SetModelView( _mContourModel_2 , _mViewContour_p );
279 _manContourControl_0 -> CreateNewManualContour();
280 _manContourControl_1 -> CreateNewManualContour();
281 _manContourControl_2 -> CreateNewManualContour();
282 _manContourControl_p -> CreateNewManualContour();
283 _manContourControl_3V3D -> CreateNewManualContour();
285 _manContourControl_0 -> SetActive(true);
286 _manContourControl_1 -> SetActive(true);
287 _manContourControl_2 -> SetActive(true);
288 _manContourControl_p -> SetActive(true);
289 _manContourControl_3V3D -> SetActive(true);
291 _manContourControl_0 -> SetEasyCreation(false);
292 _manContourControl_1 -> SetEasyCreation(false);
293 _manContourControl_2 -> SetEasyCreation(false);
294 _manContourControl_p -> SetEasyCreation(false);
295 _manContourControl_3V3D -> SetEasyCreation(false);
297 _mViewContour_0 -> RefreshContour();
298 _mViewContour_1 -> RefreshContour();
299 _mViewContour_2 -> RefreshContour();
300 _mViewContour_p -> RefreshContour();
301 _mViewContour_3D -> RefreshContour();
305 //----------------------------------------------------------------------------
306 void wxManualTree_MPRWidget::ConfigureVTK(){
307 _MPRWidget2->ConfigureVTK();
308 _wxvtk3Dbaseview_Clipping3D_C -> Configure();
309 _wxvtkmpr3Dview_C -> Configure();
310 _wxvtkclipping3Dview_C -> Configure();
312 vtkInteractorStyle3DView *vtkinteractorstyle3Dview = new vtkInteractorStyle3DView();
313 vtkinteractorstyle3Dview->SetWxVtkMPR3DView(_wxvtkmpr3Dview_C);
314 vtkinteractorstyle3Dview->SetWxVtkClipping3DView(_wxvtkclipping3Dview_C);
315 ((vtkInteractorStyleBaseView*)_wxvtk3Dbaseview_Clipping3D_C->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
320 //----------------------------------------------------------------------------
321 vtkMPRBaseData *wxManualTree_MPRWidget::GetVtkMPRBaseData(){
322 return _MPRWidget2->GetVtkMPRBaseData();
324 //----------------------------------------------------------------------------
325 vtkPlane2DView *wxManualTree_MPRWidget::GetVtkPlane2DView()
327 return _MPRWidget2->GetVtkPlane2DView();
329 //----------------------------------------------------------------------------
330 manualContourModel *wxManualTree_MPRWidget::GetManualContourModel()
332 return _mContourModel_2;
334 //----------------------------------------------------------------------------
335 void wxManualTree_MPRWidget::OnRefreshView(wxCommandEvent & event)
339 //----------------------------------------------------------------------------
340 void wxManualTree_MPRWidget::RefreshView()
342 this->_MPRWidget2->RefreshView();
343 _wxvtkmpr3Dview_C -> RefreshView();
344 _wxvtkclipping3Dview_C -> Refresh();
345 _wxvtk3Dbaseview_Clipping3D_C -> Refresh();
346 _mViewContour_p -> Refresh();
350 // EOF - wxManualTree_MPRWidget.cxx