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 #include "wxWidgetMesure2D.h"
30 BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
31 EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
34 //-------------------------------------------------------------------
36 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
37 : wxSplitterWindow( parent , -1)
40 this->SplitHorizontally( new wxPanel(this,-1) , new wxPanel(this,-1), 2 );
41 this->SetMinimumPaneSize(50);
43 //-------------------------------------------------------------------
44 wxWidgetMesure2D::~wxWidgetMesure2D()
47 //-------------------------------------------------------------------
48 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
50 wxPanel *panel = new wxPanel(parent,-1);
52 _cb_messuretool = new wxCheckBox(panel,-1,_T("Active messure tool "));
53 _cb_mt_visible = new wxCheckBox(panel,-1,_T("Visibles "));
54 _cb_closeContour = new wxCheckBox(panel,-1,_T("Close/Open "));
55 _cb_visibleText = new wxCheckBox(panel,-1,_T("Information "));
57 _cb_mt_visible->SetValue(true);
58 _cb_closeContour->SetValue(true);
59 _cb_visibleText->SetValue(true);
61 wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
63 sizer->Add(_cb_messuretool);
64 sizer->Add(_cb_mt_visible);
65 sizer->Add(_cb_closeContour);
66 sizer->Add(_cb_visibleText);
68 panel->SetAutoLayout(true);
69 panel->SetSizer(sizer);
70 panel->SetSize(400,30);
73 // panel->FitInside();
75 Connect(_cb_messuretool->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnActiveMessureTool );
76 Connect(_cb_mt_visible->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleMessureTool );
77 Connect(_cb_closeContour->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnCloseContour );
78 Connect(_cb_visibleText->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleInformation );
83 //-------------------------------------------------------------------
84 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
86 _wxvtk2Dbaseview = wxvtk2Dbaseview;
89 _manContourControl_1 = new manualContourControler();
90 _mContourModel_1 = new manualContourModel();
91 _mViewContour_1 = new manualViewContour();
92 _mViewContour_1->SetModel( _mContourModel_1 );
93 _mViewContour_1->SetWxVtkBaseView( _wxvtk2Dbaseview );
94 _mViewContour_1->SetRange( 1 );
98 // _wxvtk2Dbaseview->GetSpacing( spc );
99 // _mViewContour_1->SetSpacing( spc );
103 _manContourControl_1->SetZ( 1000 );
104 _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 );
105 ((vtkInteractorStyleBaseView*)_wxvtk2Dbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_1 );
106 _manContourControl_1->CreateNewManualContour();
107 _manContourControl_1->SetActive( false );
108 _mViewContour_1->RefreshContour();
112 // this->ReplaceWindow( this->GetWindow1() , CreateWin1a(this) );
113 // this->ReplaceWindow( this->GetWindow2() , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
114 // CreateWin1a(this->GetWindow1() );
116 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
117 sizerA->Add( CreateWin1a( this->GetWindow1()) ,1, wxGROW );
118 this->GetWindow1()->SetSizer(sizerA);
119 this->SetAutoLayout(true);
122 wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
123 sizerB->Add( _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() ,1, wxGROW );
124 this->GetWindow2()->SetSizer(sizerB);
125 this->SetAutoLayout(true);
129 // this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
133 // this->FitInside();
137 //-------------------------------------------------------------------
138 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
140 ((vtkInteractorStyleBaseView*)_wxvtk2Dbaseview->GetInteractorStyleBaseView())->SetActiveAllInteractors(!ok);
141 _manContourControl_1->SetActive( ok );
144 //-------------------------------------------------------------------
145 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
147 ActiveMessureTool( _cb_messuretool->GetValue() );
148 if ( _cb_messuretool->GetValue() == true )
150 _cb_mt_visible->SetValue(true);
151 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
152 _cb_closeContour->Enable(true);
153 _cb_visibleText->Enable(true);
155 _cb_closeContour->Enable(false);
156 _cb_visibleText->Enable(false);
158 _wxvtk2Dbaseview->Refresh();
159 _wxvtk2Dbaseview->RefreshView();
162 //-------------------------------------------------------------------
163 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
165 _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
166 if (_cb_messuretool->GetValue()==true)
168 _cb_closeContour->Enable(true);
169 _cb_visibleText->Enable(true);
171 ActiveMessureTool( _cb_messuretool->GetValue() );
172 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
173 _mViewContour_1->Refresh();
174 _wxvtk2Dbaseview->Refresh();
175 _wxvtk2Dbaseview->RefreshView();
178 //-------------------------------------------------------------------
179 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
181 _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
182 _mViewContour_1->Refresh();
183 _wxvtk2Dbaseview->Refresh();
184 _wxvtk2Dbaseview->RefreshView();
187 //-------------------------------------------------------------------
188 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
190 _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
191 _mViewContour_1->Refresh();
192 _wxvtk2Dbaseview->Refresh();
193 _wxvtk2Dbaseview->RefreshView();
195 //-------------------------------------------------------------------
196 manualContourModel* wxWidgetMesure2D::GetManualContourModel()
198 return _mContourModel_1;