1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 /*=========================================================================
29 Module: $RCSfile: wxManualSegmentation_MPRWidget.cxx,v $
31 Date: $Date: 2012/11/15 14:15:18 $
32 Version: $Revision: 1.2 $
34 Copyright: (c) 2002, 2003
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.
41 =========================================================================*/
44 #include "wxManualSegmentation_MPRWidget.h"
47 #include <wx/splitter.h>
48 #include <wx/notebook.h>
49 #include <wx/colordlg.h>
52 //#include "../tools/MaracasTools.h"
56 //-------------------------------------------------------------------
57 //-------------------------------------------------------------------
58 //-------------------------------------------------------------------
60 BEGIN_EVENT_TABLE( wxManualSegmentation_MPRWidget, wxPanel )
61 EVT_MENU( 12121, wxManualSegmentation_MPRWidget::OnRefreshView )
62 // EVT_MENU( 12122, wxManualSegmentation_MPRWidget::OnDClickLeft )
66 wxManualSegmentation_MPRWidget::wxManualSegmentation_MPRWidget( wxWindow* parent,
67 marImageData *marimageData ,double voxelSize)
68 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
71 _voxelSize = voxelSize;
72 _marimageData = marimageData;
74 _wxvtk3Dbaseview_Clipping3D_C = NULL;
75 _wxvtkmpr3Dview_C = NULL;
76 _wxvtkclipping3Dview_C = NULL;
78 wxSplitterWindow *pnlSplitter = new wxSplitterWindow( this , -1);
81 _MPRWidget2 = new wxMPRWidget2(pnlSplitter,_marimageData,voxelSize);
82 wxPanel * contour3DView = Create3DViewContour( pnlSplitter , _MPRWidget2->GetVtkMPRBaseData());
83 this->GetSize(&ww,&hh);
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);
99 MaracasTools* maracasTools = MaracasTools::GetInstance();
100 maracasTools->SetMPRWidget(this);
101 wxFrame* maracasToolsFrame = maracasTools->GetToolbox(this);
102 maracasToolsFrame->Show();
109 //----------------------------------------------------------------------------
111 wxManualSegmentation_MPRWidget::~wxManualSegmentation_MPRWidget( )
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; }
119 //----------------------------------------------------------------------------
120 wxPanel* wxManualSegmentation_MPRWidget::Create3DViewContour( wxWindow *parent, vtkMPRBaseData *vtkmprbasedata)
123 wxPanel *panel=new wxPanel(parent,-1);
125 wxSplitterWindow *panelClipping3D = new wxSplitterWindow( panel , -1);
126 _wxvtk3Dbaseview_Clipping3D_C = new wxVtk3DBaseView( panelClipping3D );
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);
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);
140 wxWindow *window3D = _wxvtk3Dbaseview_Clipping3D_C->GetWxVTKRenderWindowInteractor();
142 wxPanel *panelControl = new wxPanel(panelClipping3D,-1);
143 wxPanel *controlPanelMPR3D = _wxvtkmpr3Dview_C->CreateControlPanel(panelControl);
144 wxPanel *controlPanelClipping3D = _wxvtkclipping3Dview_C->CreateControlPanel(panelControl);
146 // wxBoxSizer *sizerCtrol = new wxBoxSizer(wxVERTICAL);
147 wxFlexGridSizer *sizerCtrol = new wxFlexGridSizer(1);
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();
158 while (pp->GetParent()!=NULL) pp=pp->GetParent();
159 pp->GetSize(&ww,&hh);
162 // panelClipping3D -> SetMinimumPaneSize( -50 );
163 panelClipping3D -> SplitHorizontally( panelControl,window3D, (int)(hh*0.20) );
164 wxwindow=panelClipping3D;
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);
174 // panel->FitInside();
184 //----------------------------------------------------------------------------
185 void wxManualSegmentation_MPRWidget::ConfigureVTK(){
186 _MPRWidget2->ConfigureVTK();
187 _wxvtk3Dbaseview_Clipping3D_C -> Configure();
188 _wxvtkmpr3Dview_C -> Configure();
189 _wxvtkclipping3Dview_C -> Configure();
191 vtkInteractorStyle3DView *vtkinteractorstyle3Dview = new vtkInteractorStyle3DView();
192 vtkinteractorstyle3Dview->SetWxVtkMPR3DView(_wxvtkmpr3Dview_C);
193 vtkinteractorstyle3Dview->SetWxVtkClipping3DView(_wxvtkclipping3Dview_C);
194 _wxvtk3Dbaseview_Clipping3D_C->GetInteractorStyleBaseView()->AddInteractorStyleMaracas( vtkinteractorstyle3Dview );
198 //----------------------------------------------------------------------------
199 vtkMPRBaseData *wxManualSegmentation_MPRWidget::GetVtkMPRBaseData(){
200 return _MPRWidget2->GetVtkMPRBaseData();
202 //----------------------------------------------------------------------------
203 vtkPlane2DView *wxManualSegmentation_MPRWidget::GetVtkPlane2DView()
205 return _MPRWidget2->GetVtkPlane2DView();
207 //----------------------------------------------------------------------------
208 void wxManualSegmentation_MPRWidget::OnRefreshView(wxCommandEvent & event)
212 //----------------------------------------------------------------------------
213 void wxManualSegmentation_MPRWidget::RefreshView()
215 this->_MPRWidget2->RefreshView();
216 _wxvtkmpr3Dview_C -> RefreshView();
217 _wxvtkclipping3Dview_C -> Refresh();
218 _wxvtk3Dbaseview_Clipping3D_C -> Refresh();
222 vtkRenderer* wxManualSegmentation_MPRWidget::GetRenderer(){
223 return _wxvtkmpr3Dview_C->GetWxvtk3Dbaseview()->GetRenderer();
228 // EOF - wxManualSegmentation_MPRWidget.cxx