]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/wxWidgetMesure2D.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / wxWidgetMesure2D.cxx
1 #include "wxWidgetMesure2D.h"
2
3
4 /*
5 BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
6         EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
7 END_EVENT_TABLE( );
8 */
9 //-------------------------------------------------------------------
10
11 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
12 : wxSplitterWindow( parent , -1)
13 {
14 // EED 27 oct 2007
15         this->SplitHorizontally( new wxPanel(this,-1) ,  new wxPanel(this,-1), 2 );
16         this->SetMinimumPaneSize(50);
17 }
18 //-------------------------------------------------------------------
19 wxWidgetMesure2D::~wxWidgetMesure2D()
20 {
21 }
22 //-------------------------------------------------------------------
23 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
24 {
25         wxPanel *panel = new wxPanel(parent,-1);
26
27         _cb_messuretool  = new wxCheckBox(panel,-1,_T("Active messure tool     ")); 
28         _cb_mt_visible   = new wxCheckBox(panel,-1,_T("Visibles    ")); 
29         _cb_closeContour = new wxCheckBox(panel,-1,_T("Close/Open    ")); 
30         _cb_visibleText  = new wxCheckBox(panel,-1,_T("Information    ")); 
31
32         _cb_mt_visible->SetValue(true);
33         _cb_closeContour->SetValue(true);
34         _cb_visibleText->SetValue(true);
35
36         wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
37
38         sizer->Add(_cb_messuretool);
39         sizer->Add(_cb_mt_visible);
40         sizer->Add(_cb_closeContour);
41         sizer->Add(_cb_visibleText);
42
43         panel->SetAutoLayout(true);
44         panel->SetSizer(sizer);
45         panel->SetSize(400,30);
46         panel->Layout();
47 //EEDxx2.4
48 //      panel->FitInside();
49
50         Connect(_cb_messuretool->GetId()  , wxEVT_COMMAND_CHECKBOX_CLICKED        , (wxObjectEventFunction) &wxWidgetMesure2D::OnActiveMessureTool      );
51         Connect(_cb_mt_visible->GetId()   , wxEVT_COMMAND_CHECKBOX_CLICKED        , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleMessureTool     );
52         Connect(_cb_closeContour->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED        , (wxObjectEventFunction) &wxWidgetMesure2D::OnCloseContour           );
53         Connect(_cb_visibleText->GetId()  , wxEVT_COMMAND_CHECKBOX_CLICKED        , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleInformation     );
54
55         return panel;
56 }
57
58 //-------------------------------------------------------------------
59 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
60 {
61         _wxvtk2Dbaseview = wxvtk2Dbaseview;
62
63         // Contorno 1
64         _manContourControl_1    = new manualContourControler();
65         _mContourModel_1                = new manualContourModel();
66         _mViewContour_1                 = new manualViewContour();
67         _mViewContour_1->SetModel( _mContourModel_1 );
68         _mViewContour_1->SetWxVtkBaseView( _wxvtk2Dbaseview );
69         _mViewContour_1->SetRange( 1 );
70
71 // EED 3 oct 2006
72 //      double spc[3];
73 //      _wxvtk2Dbaseview->GetSpacing( spc );
74 //      _mViewContour_1->SetSpacing( spc );
75
76
77
78         _manContourControl_1->SetZ( 1000 );
79         _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 );
80         ((vtkInteractorStyleBaseView*)_wxvtk2Dbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_1 );
81         _manContourControl_1->CreateNewManualContour();
82         _manContourControl_1->SetActive( false );
83         _mViewContour_1->RefreshContour();
84
85 //EED 27 Oct 2007
86         
87 //      this->ReplaceWindow( this->GetWindow1() ,  CreateWin1a(this) );
88 //      this->ReplaceWindow( this->GetWindow2() ,  _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
89 //      CreateWin1a(this->GetWindow1() );
90
91         wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);      
92         sizerA->Add(  CreateWin1a( this->GetWindow1()) ,1, wxGROW );
93         this->GetWindow1()->SetSizer(sizerA);
94         this->SetAutoLayout(true);
95         this->Layout();
96
97         wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);      
98         sizerB->Add(  _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor()  ,1, wxGROW );
99         this->GetWindow2()->SetSizer(sizerB);
100         this->SetAutoLayout(true);
101         this->Layout();
102
103
104 //      this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
105
106
107 //EEDxx2.4 
108 //      this->FitInside();
109 }
110
111
112 //-------------------------------------------------------------------
113 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
114 {
115         ((vtkInteractorStyleBaseView*)_wxvtk2Dbaseview->GetInteractorStyleBaseView())->SetActiveAllInteractors(!ok);
116         _manContourControl_1->SetActive( ok );
117 }
118
119 //-------------------------------------------------------------------
120 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
121 {
122         ActiveMessureTool( _cb_messuretool->GetValue() );
123         if ( _cb_messuretool->GetValue() == true )
124         {
125                 _cb_mt_visible->SetValue(true);
126                 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
127                 _cb_closeContour->Enable(true);
128                 _cb_visibleText->Enable(true);
129         } else{
130                 _cb_closeContour->Enable(false);
131                 _cb_visibleText->Enable(false);
132         }
133         _wxvtk2Dbaseview->Refresh();
134         _wxvtk2Dbaseview->RefreshView();
135 }
136
137 //-------------------------------------------------------------------
138 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
139 {
140         _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
141         if (_cb_messuretool->GetValue()==true)
142         {
143                 _cb_closeContour->Enable(true);
144                 _cb_visibleText->Enable(true);
145         }
146         ActiveMessureTool( _cb_messuretool->GetValue() );       
147         _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
148         _mViewContour_1->Refresh();
149         _wxvtk2Dbaseview->Refresh();
150         _wxvtk2Dbaseview->RefreshView();
151 }
152
153 //-------------------------------------------------------------------
154 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
155 {
156         _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
157         _mViewContour_1->Refresh();
158         _wxvtk2Dbaseview->Refresh();
159         _wxvtk2Dbaseview->RefreshView();
160
161 }
162 //-------------------------------------------------------------------
163 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
164 {
165         _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
166         _mViewContour_1->Refresh();
167         _wxvtk2Dbaseview->Refresh();
168         _wxvtk2Dbaseview->RefreshView();
169 }
170 //-------------------------------------------------------------------
171 void wxWidgetMesure2D::SetMesureScale(double mesureScale)
172 {
173         _mViewContour_1->SetMesureScale(mesureScale);
174 }
175 //-------------------------------------------------------------------
176 manualContourModel*     wxWidgetMesure2D::GetManualContourModel()
177 {
178         return _mContourModel_1;
179 }