]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/include/wxManualSegmentation_MPRWidget.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / include / wxManualSegmentation_MPRWidget.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 /*=========================================================================
27
28   Program:   wxMaracas
29   Module:    $RCSfile: wxManualSegmentation_MPRWidget.cxx,v $
30   Language:  C++
31   Date:      $Date: 2012/11/15 14:15:18 $
32   Version:   $Revision: 1.2 $
33
34   Copyright: (c) 2002, 2003
35   License:
36
37      This software is distributed WITHOUT ANY WARRANTY; without even
38      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39      PURPOSE.  See the above copyright notice for more information.
40
41 =========================================================================*/
42
43
44 #include "wxManualSegmentation_MPRWidget.h"
45
46 #include <wx/wx.h>
47 #include <wx/splitter.h>
48 #include <wx/notebook.h>
49 #include <wx/colordlg.h>
50
51 //EED 6 aout 2007
52 //#include "../tools/MaracasTools.h"
53
54
55
56 //-------------------------------------------------------------------
57 //-------------------------------------------------------------------
58 //-------------------------------------------------------------------
59
60 BEGIN_EVENT_TABLE( wxManualSegmentation_MPRWidget, wxPanel )
61         EVT_MENU( 12121, wxManualSegmentation_MPRWidget::OnRefreshView )
62 //      EVT_MENU( 12122, wxManualSegmentation_MPRWidget::OnDClickLeft  )
63 END_EVENT_TABLE( );
64
65
66 wxManualSegmentation_MPRWidget::wxManualSegmentation_MPRWidget( wxWindow* parent,
67                           marImageData *marimageData ,double voxelSize)
68 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
69 {
70
71         _voxelSize                                                      = voxelSize;
72         _marimageData                                                   = marimageData;
73
74         _wxvtk3Dbaseview_Clipping3D_C           = NULL;
75         _wxvtkmpr3Dview_C                                       = NULL;
76         _wxvtkclipping3Dview_C                          = NULL;
77
78     wxSplitterWindow    *pnlSplitter    = new wxSplitterWindow( this , -1);
79         
80         int ww,hh;
81         _MPRWidget2                                     = new wxMPRWidget2(pnlSplitter,_marimageData,voxelSize);
82         wxPanel *       contour3DView   = Create3DViewContour( pnlSplitter , _MPRWidget2->GetVtkMPRBaseData());
83         this->GetSize(&ww,&hh);
84
85     pnlSplitter -> SplitVertically( _MPRWidget2, contour3DView , 600);
86         wxBoxSizer      *sizer  = new wxBoxSizer(wxVERTICAL  );
87         sizer           -> Add( pnlSplitter ,1,wxGROW  ,0);
88         pnlSplitter     -> SetMinimumPaneSize( 50 );
89         this            -> SetSizer(sizer);
90         //EEDxx2.4
91         //      FitInside();
92         
93
94         
95         //TEST
96
97 //EED 6 aout 2007
98 /*
99         MaracasTools* maracasTools = MaracasTools::GetInstance();
100         maracasTools->SetMPRWidget(this);
101         wxFrame* maracasToolsFrame = maracasTools->GetToolbox(this);
102         maracasToolsFrame->Show();
103 */
104         
105         
106
107 }
108
109 //----------------------------------------------------------------------------
110
111 wxManualSegmentation_MPRWidget::~wxManualSegmentation_MPRWidget( )
112 {
113         if (_wxvtk3Dbaseview_Clipping3D_C       != NULL) { delete       _wxvtk3Dbaseview_Clipping3D_C;  }
114         if (_wxvtkmpr3Dview_C                           != NULL) { delete       _wxvtkmpr3Dview_C;                              }
115         if (_wxvtkclipping3Dview_C                      != NULL) { delete       _wxvtkclipping3Dview_C;                 }
116 }
117
118
119 //----------------------------------------------------------------------------
120 wxPanel* wxManualSegmentation_MPRWidget::Create3DViewContour( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
121 {
122         wxWindow *wxwindow;
123         wxPanel *panel=new wxPanel(parent,-1);
124
125         wxSplitterWindow        *panelClipping3D        = new wxSplitterWindow( panel , -1);
126         _wxvtk3Dbaseview_Clipping3D_C = new wxVtk3DBaseView( panelClipping3D );
127
128         _wxvtkclipping3Dview_C = new wxVtkClipping3DView(_wxvtk3Dbaseview_Clipping3D_C);
129         vtkClipping3DDataViewer *vtkclipping3Ddataviewer = new vtkClipping3DDataViewer(); 
130         vtkclipping3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
131         vtkclipping3Ddataviewer->Configure();
132         _wxvtkclipping3Dview_C->SetVtkClipping3DDataViewer(vtkclipping3Ddataviewer);
133
134         _wxvtkmpr3Dview_C = new wxVtkMPR3DView( _wxvtk3Dbaseview_Clipping3D_C );
135         vtkMPR3DDataViewer *vtkmpr3Ddataviewer = new vtkMPR3DDataViewer(); 
136         vtkmpr3Ddataviewer->SetVtkMPRBaseData(vtkmprbasedata);
137         vtkmpr3Ddataviewer->Configure();
138         _wxvtkmpr3Dview_C->SetVtkMPR3DDataViewer(vtkmpr3Ddataviewer);
139
140         wxWindow        *window3D                               = _wxvtk3Dbaseview_Clipping3D_C->GetWxVTKRenderWindowInteractor();
141
142         wxPanel         *panelControl                   = new wxPanel(panelClipping3D,-1);      
143         wxPanel         *controlPanelMPR3D              = _wxvtkmpr3Dview_C->CreateControlPanel(panelControl);
144         wxPanel         *controlPanelClipping3D = _wxvtkclipping3Dview_C->CreateControlPanel(panelControl);
145
146 //      wxBoxSizer  *sizerCtrol             = new wxBoxSizer(wxVERTICAL);
147         wxFlexGridSizer  *sizerCtrol        = new wxFlexGridSizer(1);
148
149         sizerCtrol->Add(controlPanelMPR3D , 1, wxALL|wxEXPAND, 2);
150         sizerCtrol->Add(controlPanelClipping3D , 1, wxALL|wxEXPAND, 2);
151         panelControl->SetAutoLayout(true);
152         panelControl->SetSizer(sizerCtrol);
153         panelControl->SetSize(400,350);
154         panelControl->Layout();
155
156         int ww,hh;
157         wxWindow *pp=this;
158         while (pp->GetParent()!=NULL) pp=pp->GetParent();
159         pp->GetSize(&ww,&hh);
160
161 //EEDxx2.4
162 //              panelClipping3D -> SetMinimumPaneSize( -50 );
163         panelClipping3D -> SplitHorizontally( panelControl,window3D, (int)(hh*0.20) );
164         wxwindow=panelClipping3D;
165
166     wxBoxSizer *sizerH1 = new wxBoxSizer(wxHORIZONTAL);
167         sizerH1->Add(wxwindow , 1, wxALL|wxEXPAND, 0);
168         panel->SetAutoLayout(true);
169         panel->SetSizer(sizerH1);
170         panel->SetSize(400,400);
171         panel->Layout();
172
173 //EEDxx2.4
174 //      panel->FitInside();
175 //      FitInside();
176
177
178
179
180         return panel;
181 }
182
183
184 //----------------------------------------------------------------------------
185 void wxManualSegmentation_MPRWidget::ConfigureVTK(){
186         _MPRWidget2->ConfigureVTK();
187         _wxvtk3Dbaseview_Clipping3D_C   ->  Configure();
188         _wxvtkmpr3Dview_C                               ->      Configure();
189         _wxvtkclipping3Dview_C                  ->      Configure();
190
191         vtkInteractorStyle3DView *vtkinteractorstyle3Dview      = new vtkInteractorStyle3DView();
192         vtkinteractorstyle3Dview->SetWxVtkMPR3DView(_wxvtkmpr3Dview_C);
193         vtkinteractorstyle3Dview->SetWxVtkClipping3DView(_wxvtkclipping3Dview_C);
194         _wxvtk3Dbaseview_Clipping3D_C->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
195
196 }
197
198 //----------------------------------------------------------------------------
199 vtkMPRBaseData  *wxManualSegmentation_MPRWidget::GetVtkMPRBaseData(){
200         return _MPRWidget2->GetVtkMPRBaseData();
201 }
202 //----------------------------------------------------------------------------
203 vtkPlane2DView *wxManualSegmentation_MPRWidget::GetVtkPlane2DView()
204 {
205         return _MPRWidget2->GetVtkPlane2DView();
206 }
207 //----------------------------------------------------------------------------
208 void wxManualSegmentation_MPRWidget::OnRefreshView(wxCommandEvent & event)
209 {
210         RefreshView();
211 }
212 //----------------------------------------------------------------------------
213 void wxManualSegmentation_MPRWidget::RefreshView()
214 {
215         this->_MPRWidget2->RefreshView();
216         _wxvtkmpr3Dview_C                               -> RefreshView();
217         _wxvtkclipping3Dview_C                  -> Refresh();
218         _wxvtk3Dbaseview_Clipping3D_C   -> Refresh();
219 }
220
221
222 vtkRenderer* wxManualSegmentation_MPRWidget::GetRenderer(){
223         return _wxvtkmpr3Dview_C->GetWxvtk3Dbaseview()->GetRenderer();
224 }
225
226
227
228 // EOF - wxManualSegmentation_MPRWidget.cxx
229
230
231
232