]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxWidgetMesure2D.cxx
#3093 creaMaracasVisu Feature New Normal - Contour Information in pixels and image...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxWidgetMesure2D.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 #include "wxWidgetMesure2D.h"
27
28
29 /*
30 BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
31         EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
32 END_EVENT_TABLE( );
33 */
34 //-------------------------------------------------------------------
35
36 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
37 : wxSplitterWindow( parent , -1)
38 {
39 // EED 27 oct 2007
40         this->SplitHorizontally( new wxPanel(this,-1) ,  new wxPanel(this,-1), 2 );
41         this->SetMinimumPaneSize(50);
42 }
43 //-------------------------------------------------------------------
44 wxWidgetMesure2D::~wxWidgetMesure2D()
45 {
46 }
47 //-------------------------------------------------------------------
48 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
49 {
50         wxPanel *panel = new wxPanel(parent,-1);
51
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    ")); 
56
57         _cb_mt_visible->SetValue(true);
58         _cb_closeContour->SetValue(true);
59         _cb_visibleText->SetValue(true);
60
61         wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
62
63         sizer->Add(_cb_messuretool);
64         sizer->Add(_cb_mt_visible);
65         sizer->Add(_cb_closeContour);
66         sizer->Add(_cb_visibleText);
67
68         panel->SetAutoLayout(true);
69         panel->SetSizer(sizer);
70         panel->SetSize(400,30);
71         panel->Layout();
72 //EEDxx2.4
73 //      panel->FitInside();
74
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     );
79
80         return panel;
81 }
82
83 //-------------------------------------------------------------------
84 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
85 {
86         _wxvtk2Dbaseview = wxvtk2Dbaseview;
87
88         // Contorno 1
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 );
95
96 // EED 3 oct 2006
97 //      double spc[3];
98 //      _wxvtk2Dbaseview->GetSpacing( spc );
99 //      _mViewContour_1->SetSpacing( spc );
100
101
102
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();
109
110 //EED 27 Oct 2007
111         
112 //      this->ReplaceWindow( this->GetWindow1() ,  CreateWin1a(this) );
113 //      this->ReplaceWindow( this->GetWindow2() ,  _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
114 //      CreateWin1a(this->GetWindow1() );
115
116         wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);      
117         sizerA->Add(  CreateWin1a( this->GetWindow1()) ,1, wxGROW );
118         this->GetWindow1()->SetSizer(sizerA);
119         this->SetAutoLayout(true);
120         this->Layout();
121
122         wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);      
123         sizerB->Add(  _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor()  ,1, wxGROW );
124         this->GetWindow2()->SetSizer(sizerB);
125         this->SetAutoLayout(true);
126         this->Layout();
127
128
129 //      this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
130
131
132 //EEDxx2.4 
133 //      this->FitInside();
134 }
135
136
137 //-------------------------------------------------------------------
138 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
139 {
140         ((vtkInteractorStyleBaseView*)_wxvtk2Dbaseview->GetInteractorStyleBaseView())->SetActiveAllInteractors(!ok);
141         _manContourControl_1->SetActive( ok );
142 }
143
144 //-------------------------------------------------------------------
145 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
146 {
147         ActiveMessureTool( _cb_messuretool->GetValue() );
148         if ( _cb_messuretool->GetValue() == true )
149         {
150                 _cb_mt_visible->SetValue(true);
151                 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
152                 _cb_closeContour->Enable(true);
153                 _cb_visibleText->Enable(true);
154         } else{
155                 _cb_closeContour->Enable(false);
156                 _cb_visibleText->Enable(false);
157         }
158         _wxvtk2Dbaseview->Refresh();
159         _wxvtk2Dbaseview->RefreshView();
160 }
161
162 //-------------------------------------------------------------------
163 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
164 {
165         _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
166         if (_cb_messuretool->GetValue()==true)
167         {
168                 _cb_closeContour->Enable(true);
169                 _cb_visibleText->Enable(true);
170         }
171         ActiveMessureTool( _cb_messuretool->GetValue() );       
172         _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
173         _mViewContour_1->Refresh();
174         _wxvtk2Dbaseview->Refresh();
175         _wxvtk2Dbaseview->RefreshView();
176 }
177
178 //-------------------------------------------------------------------
179 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
180 {
181         _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
182         _mViewContour_1->Refresh();
183         _wxvtk2Dbaseview->Refresh();
184         _wxvtk2Dbaseview->RefreshView();
185
186 }
187 //-------------------------------------------------------------------
188 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
189 {
190         _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
191         _mViewContour_1->Refresh();
192         _wxvtk2Dbaseview->Refresh();
193         _wxvtk2Dbaseview->RefreshView();
194 }
195 //-------------------------------------------------------------------
196 manualContourModel*     wxWidgetMesure2D::GetManualContourModel()
197 {
198         return _mContourModel_1;
199 }