1 #include "wxWidgetMesure2D.h"
5 BEGIN_EVENT_TABLE( wxWidgetMesure2D , wxSplitterWindow )
6 EVT_MENU( 12121, wxWidgetMesure2D::OnRefreshView )
9 //-------------------------------------------------------------------
11 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
12 : wxSplitterWindow( parent , -1)
15 this->SplitHorizontally( new wxPanel(this,-1) , new wxPanel(this,-1), 2 );
16 this->SetMinimumPaneSize(50);
18 //-------------------------------------------------------------------
19 wxWidgetMesure2D::~wxWidgetMesure2D()
22 //-------------------------------------------------------------------
23 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) // virtual
25 wxPanel *panel = new wxPanel(parent,-1);
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 "));
32 _cb_mt_visible->SetValue(true);
33 _cb_closeContour->SetValue(true);
34 _cb_visibleText->SetValue(true);
36 wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
38 sizer->Add(_cb_messuretool);
39 sizer->Add(_cb_mt_visible);
40 sizer->Add(_cb_closeContour);
41 sizer->Add(_cb_visibleText);
43 panel->SetAutoLayout(true);
44 panel->SetSizer(sizer);
45 panel->SetSize(400,30);
48 // panel->FitInside();
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 );
58 //-------------------------------------------------------------------
59 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
61 _wxvtk2Dbaseview = wxvtk2Dbaseview;
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 );
73 // _wxvtk2Dbaseview->GetSpacing( spc );
74 // _mViewContour_1->SetSpacing( spc );
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();
87 // this->ReplaceWindow( this->GetWindow1() , CreateWin1a(this) );
88 // this->ReplaceWindow( this->GetWindow2() , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() );
89 // CreateWin1a(this->GetWindow1() );
91 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
92 sizerA->Add( CreateWin1a( this->GetWindow1()) ,1, wxGROW );
93 this->GetWindow1()->SetSizer(sizerA);
94 this->SetAutoLayout(true);
97 wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
98 sizerB->Add( _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() ,1, wxGROW );
99 this->GetWindow2()->SetSizer(sizerB);
100 this->SetAutoLayout(true);
104 // this->SplitHorizontally( CreateWin1a(this) , _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor() , 2 );
108 // this->FitInside();
112 //-------------------------------------------------------------------
113 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
115 ((vtkInteractorStyleBaseView*)_wxvtk2Dbaseview->GetInteractorStyleBaseView())->SetActiveAllInteractors(!ok);
116 _manContourControl_1->SetActive( ok );
119 //-------------------------------------------------------------------
120 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
122 ActiveMessureTool( _cb_messuretool->GetValue() );
123 if ( _cb_messuretool->GetValue() == true )
125 _cb_mt_visible->SetValue(true);
126 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
127 _cb_closeContour->Enable(true);
128 _cb_visibleText->Enable(true);
130 _cb_closeContour->Enable(false);
131 _cb_visibleText->Enable(false);
133 _wxvtk2Dbaseview->Refresh();
134 _wxvtk2Dbaseview->RefreshView();
137 //-------------------------------------------------------------------
138 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
140 _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
141 if (_cb_messuretool->GetValue()==true)
143 _cb_closeContour->Enable(true);
144 _cb_visibleText->Enable(true);
146 ActiveMessureTool( _cb_messuretool->GetValue() );
147 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
148 _mViewContour_1->Refresh();
149 _wxvtk2Dbaseview->Refresh();
150 _wxvtk2Dbaseview->RefreshView();
153 //-------------------------------------------------------------------
154 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
156 _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
157 _mViewContour_1->Refresh();
158 _wxvtk2Dbaseview->Refresh();
159 _wxvtk2Dbaseview->RefreshView();
162 //-------------------------------------------------------------------
163 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
165 _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
166 _mViewContour_1->Refresh();
167 _wxvtk2Dbaseview->Refresh();
168 _wxvtk2Dbaseview->RefreshView();
170 //-------------------------------------------------------------------
171 void wxWidgetMesure2D::SetMesureScale(double mesureScale)
173 _mViewContour_1->SetMesureScale(mesureScale);
175 //-------------------------------------------------------------------
176 manualContourModel* wxWidgetMesure2D::GetManualContourModel()
178 return _mContourModel_1;