]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxManualTree_MPRWidget.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxManualTree_MPRWidget.cxx
1 /*=========================================================================
2
3   Program:   wxMaracas
4   Module:    $RCSfile: wxManualTree_MPRWidget.cxx,v $
5   Language:  C++
6   Date:      $Date: 2009/05/14 13:54:35 $
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 #include "wxManualTree_MPRWidget.h"
20
21 #include <wx/wx.h>
22 #include <wx/splitter.h>
23 #include <wx/notebook.h>
24 #include <wx/colordlg.h>
25
26 #include "vtkInteractorStyle3DView.h"
27
28
29 //-------------------------------------------------------------------
30 //-------------------------------------------------------------------
31 //-------------------------------------------------------------------
32
33 BEGIN_EVENT_TABLE( wxManualTree_MPRWidget, wxPanel )
34         EVT_MENU( 12121, wxManualTree_MPRWidget::OnRefreshView )
35 //      EVT_MENU( 12122, wxManualTree_MPRWidget::OnDClickLeft  )
36 END_EVENT_TABLE( );
37
38
39 wxManualTree_MPRWidget::wxManualTree_MPRWidget( wxWindow* parent,
40                           marImageData *marimageData ,double voxelSize)
41 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
42 {
43
44         _voxelSize                                                      = voxelSize;
45         _marimageData                                                   = marimageData;
46
47         _wxvtk3Dbaseview_Clipping3D_C           = NULL;
48         _wxvtkmpr3Dview_C                                       = NULL;
49         _wxvtkclipping3Dview_C                          = NULL;
50
51     wxSplitterWindow    *pnlSplitter    = new wxSplitterWindow( this , -1);
52         
53         int ww,hh;
54         _MPRWidget2                                     = new wxMPRWidget2(pnlSplitter,_marimageData,voxelSize);
55         wxPanel *       contour3DView   = Create3DViewContour( pnlSplitter , _MPRWidget2->GetVtkMPRBaseData());
56         this->GetSize(&ww,&hh);
57
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);
63 //EEDxx2.4
64 //      FitInside();
65
66 }
67
68 //----------------------------------------------------------------------------
69
70 wxManualTree_MPRWidget::~wxManualTree_MPRWidget( )
71 {
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;                 }
75 }
76
77
78 //----------------------------------------------------------------------------
79 wxPanel* wxManualTree_MPRWidget::Create3DViewContour( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
80 {
81         wxWindow *wxwindow;
82         wxPanel *panel=new wxPanel(parent,-1);
83
84         wxSplitterWindow        *panelClipping3D        = new wxSplitterWindow( panel , -1);
85         _wxvtk3Dbaseview_Clipping3D_C = new wxVtk3DBaseView( panelClipping3D );
86
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);
92
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);
98
99         wxWindow        *window3D                               = _wxvtk3Dbaseview_Clipping3D_C->GetWxVTKRenderWindowInteractor();
100
101         wxPanel         *panelControl                   = new wxPanel(panelClipping3D,-1);      
102         wxPanel         *controlPanelMPR3D              = _wxvtkmpr3Dview_C->CreateControlPanel(panelControl);
103         wxPanel         *controlPanelClipping3D = _wxvtkclipping3Dview_C->CreateControlPanel(panelControl);
104
105 //      wxBoxSizer  *sizerCtrol             = new wxBoxSizer(wxVERTICAL);
106         wxFlexGridSizer  *sizerCtrol             = new wxFlexGridSizer(1);
107
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();
114
115         int ww,hh;
116         wxWindow *pp=this;
117         while (pp->GetParent()!=NULL) pp=pp->GetParent();
118         pp->GetSize(&ww,&hh);
119
120 //EEDxx2.4
121 //              panelClipping3D -> SetMinimumPaneSize( -50 );
122         panelClipping3D -> SplitHorizontally( panelControl,window3D, (int)(hh*0.20) );
123         wxwindow=panelClipping3D;
124
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);
130         panel->Layout();
131
132 //EEDxx2.4
133 //      panel->FitInside();
134 //      FitInside();
135
136         return panel;
137 }
138 //----------------------------------------------------------------------------
139 void wxManualTree_MPRWidget::ConfigureContour()
140 {       
141         wxVtkBaseView *wxvtkbaseview;
142         wxvtkbaseview                   = _MPRWidget2->GetWxVtkBaseView(0,2);
143
144 //EED 3 oct 2006
145         double spc[3];
146         wxvtkbaseview->GetSpacing(spc);
147
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     );
156
157 //EED 3 oct 2006
158         _mViewContour_2->SetSpacing(spc);
159
160         ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_2 );
161
162         //
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     );
170
171 //EED 3 oct 2006
172         _mViewContour_0->SetSpacing(spc);
173
174         ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_0 );
175
176         //
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     );
184
185 //EED 3 oct 2006
186         _mViewContour_1->SetSpacing(spc);
187
188         ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_1 );
189
190
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     );
199
200 //EED 3 oct 2006
201         _mViewContour_p->SetSpacing(spc);
202
203 //      wxvtkbaseview->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( _manContourControl_p );
204         ((vtkInteractorStyleBaseView*)wxvtkbaseview->GetInteractorStyleBaseView())->InsertInteractorStyleMaracas( 0, _manContourControl_p );
205
206         vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)wxvtkbaseview;
207         _manContourControl_p->SetVtkInteractorStylePlane2D( vtkplane2Dview->GetInteractorstyleplane2D() );
208
209         //
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     );
217
218 //EED 3 oct 2006
219         _mViewContour_3D->SetSpacing(spc);
220
221         int dim[3];
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 );
226
227         //
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() );
233
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   );
239
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   );
245
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   );
251
252
253         //
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 );
264
265         //
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 );
276
277
278         //
279         _manContourControl_0    -> CreateNewManualContour();
280         _manContourControl_1    -> CreateNewManualContour();
281         _manContourControl_2    -> CreateNewManualContour();
282         _manContourControl_p    -> CreateNewManualContour();
283         _manContourControl_3V3D -> CreateNewManualContour();
284
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);
290
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);
296
297         _mViewContour_0                 -> RefreshContour();
298         _mViewContour_1                 -> RefreshContour();
299         _mViewContour_2                 -> RefreshContour();
300         _mViewContour_p                 -> RefreshContour();
301         _mViewContour_3D                -> RefreshContour();
302
303 }
304
305 //----------------------------------------------------------------------------
306 void wxManualTree_MPRWidget::ConfigureVTK(){
307         _MPRWidget2->ConfigureVTK();
308         _wxvtk3Dbaseview_Clipping3D_C   ->  Configure();
309         _wxvtkmpr3Dview_C                               ->      Configure();
310         _wxvtkclipping3Dview_C                  ->      Configure();
311
312         vtkInteractorStyle3DView *vtkinteractorstyle3Dview      = new vtkInteractorStyle3DView();
313         vtkinteractorstyle3Dview->SetWxVtkMPR3DView(_wxvtkmpr3Dview_C);
314         vtkinteractorstyle3Dview->SetWxVtkClipping3DView(_wxvtkclipping3Dview_C);
315         ((vtkInteractorStyleBaseView*)_wxvtk3Dbaseview_Clipping3D_C->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
316
317         ConfigureContour();
318 }
319
320 //----------------------------------------------------------------------------
321 vtkMPRBaseData  *wxManualTree_MPRWidget::GetVtkMPRBaseData(){
322         return _MPRWidget2->GetVtkMPRBaseData();
323 }
324 //----------------------------------------------------------------------------
325 vtkPlane2DView *wxManualTree_MPRWidget::GetVtkPlane2DView()
326 {
327         return _MPRWidget2->GetVtkPlane2DView();
328 }
329 //----------------------------------------------------------------------------
330 manualContourModel *wxManualTree_MPRWidget::GetManualContourModel()
331 {
332         return _mContourModel_2;
333 }
334 //----------------------------------------------------------------------------
335 void wxManualTree_MPRWidget::OnRefreshView(wxCommandEvent & event)
336 {
337         RefreshView();
338 }
339 //----------------------------------------------------------------------------
340 void wxManualTree_MPRWidget::RefreshView()
341 {
342         this->_MPRWidget2->RefreshView();
343         _wxvtkmpr3Dview_C                               -> RefreshView();
344         _wxvtkclipping3Dview_C                  -> Refresh();
345         _wxvtk3Dbaseview_Clipping3D_C   -> Refresh();
346         _mViewContour_p                                 -> Refresh();
347 }
348
349
350 // EOF - wxManualTree_MPRWidget.cxx
351
352
353
354