wxWidgetMesure2D.cxx
Go to the documentation of this file.00001 #include "wxWidgetMesure2D.h"
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 wxWidgetMesure2D::wxWidgetMesure2D( wxWindow *parent )
00012 : wxSplitterWindow( parent , -1)
00013 {
00014 
00015         this->SplitHorizontally( new wxPanel(this,-1) ,  new wxPanel(this,-1), 2 );
00016         this->SetMinimumPaneSize(50);
00017 }
00018 
00019 wxWidgetMesure2D::~wxWidgetMesure2D()
00020 {
00021 }
00022 
00023 wxWindow *wxWidgetMesure2D::CreateWin1a(wxWindow *parent) 
00024 {
00025         wxPanel *panel = new wxPanel(parent,-1);
00026 
00027         _cb_messuretool  = new wxCheckBox(panel,-1,_T("Active messure tool     ")); 
00028         _cb_mt_visible   = new wxCheckBox(panel,-1,_T("Visibles    ")); 
00029         _cb_closeContour = new wxCheckBox(panel,-1,_T("Close/Open    ")); 
00030         _cb_visibleText  = new wxCheckBox(panel,-1,_T("Information    ")); 
00031 
00032         _cb_mt_visible->SetValue(true);
00033         _cb_closeContour->SetValue(true);
00034         _cb_visibleText->SetValue(true);
00035 
00036         wxFlexGridSizer *sizer = new wxFlexGridSizer(4);
00037 
00038         sizer->Add(_cb_messuretool);
00039         sizer->Add(_cb_mt_visible);
00040         sizer->Add(_cb_closeContour);
00041         sizer->Add(_cb_visibleText);
00042 
00043         panel->SetAutoLayout(true);
00044         panel->SetSizer(sizer);
00045         panel->SetSize(400,30);
00046         panel->Layout();
00047 
00048 
00049 
00050         Connect(_cb_messuretool->GetId()  , wxEVT_COMMAND_CHECKBOX_CLICKED        , (wxObjectEventFunction) &wxWidgetMesure2D::OnActiveMessureTool      );
00051         Connect(_cb_mt_visible->GetId()   , wxEVT_COMMAND_CHECKBOX_CLICKED        , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleMessureTool     );
00052         Connect(_cb_closeContour->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED        , (wxObjectEventFunction) &wxWidgetMesure2D::OnCloseContour           );
00053         Connect(_cb_visibleText->GetId()  , wxEVT_COMMAND_CHECKBOX_CLICKED        , (wxObjectEventFunction) &wxWidgetMesure2D::OnVisibleInformation     );
00054 
00055         return panel;
00056 }
00057 
00058 
00059 void wxWidgetMesure2D::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) 
00060 {
00061         _wxvtk2Dbaseview = wxvtk2Dbaseview;
00062 
00063         
00064         _manContourControl_1    = new manualContourControler();
00065         _mContourModel_1                = new manualContourModel();
00066         _mViewContour_1                 = new manualViewContour();
00067         _mViewContour_1->SetModel( _mContourModel_1 );
00068         _mViewContour_1->SetWxVtkBaseView( _wxvtk2Dbaseview );
00069         _mViewContour_1->SetRange( 1 );
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078         _manContourControl_1->SetZ( 1000 );
00079         _manContourControl_1->SetModelView( _mContourModel_1 , _mViewContour_1 );
00080         ((vtkInteractorStyleBaseView*)_wxvtk2Dbaseview->GetInteractorStyleBaseView())->AddInteractorStyleMaracas( _manContourControl_1 );
00081         _manContourControl_1->CreateNewManualContour();
00082         _manContourControl_1->SetActive( false );
00083         _mViewContour_1->RefreshContour();
00084 
00085 
00086         
00087 
00088 
00089 
00090 
00091         wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);      
00092         sizerA->Add(  CreateWin1a( this->GetWindow1()) ,1, wxGROW );
00093         this->GetWindow1()->SetSizer(sizerA);
00094         this->SetAutoLayout(true);
00095         this->Layout();
00096 
00097         wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);      
00098         sizerB->Add(  _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor()  ,1, wxGROW );
00099         this->GetWindow2()->SetSizer(sizerB);
00100         this->SetAutoLayout(true);
00101         this->Layout();
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 }
00110 
00111 
00112 
00113 void wxWidgetMesure2D::ActiveMessureTool(bool ok)
00114 {
00115         ((vtkInteractorStyleBaseView*)_wxvtk2Dbaseview->GetInteractorStyleBaseView())->SetActiveAllInteractors(!ok);
00116         _manContourControl_1->SetActive( ok );
00117 }
00118 
00119 
00120 void wxWidgetMesure2D::OnActiveMessureTool(wxCommandEvent& event)
00121 {
00122         ActiveMessureTool( _cb_messuretool->GetValue() );
00123         if ( _cb_messuretool->GetValue() == true )
00124         {
00125                 _cb_mt_visible->SetValue(true);
00126                 _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
00127                 _cb_closeContour->Enable(true);
00128                 _cb_visibleText->Enable(true);
00129         } else{
00130                 _cb_closeContour->Enable(false);
00131                 _cb_visibleText->Enable(false);
00132         }
00133         _wxvtk2Dbaseview->Refresh();
00134         _wxvtk2Dbaseview->RefreshView();
00135 }
00136 
00137 
00138 void wxWidgetMesure2D::OnVisibleMessureTool(wxCommandEvent& event)
00139 {
00140         _cb_messuretool->SetValue( _cb_mt_visible->GetValue() );
00141         if (_cb_messuretool->GetValue()==true)
00142         {
00143                 _cb_closeContour->Enable(true);
00144                 _cb_visibleText->Enable(true);
00145         }
00146         ActiveMessureTool( _cb_messuretool->GetValue() );       
00147         _mViewContour_1->SetVisible( _cb_mt_visible->GetValue() );
00148         _mViewContour_1->Refresh();
00149         _wxvtk2Dbaseview->Refresh();
00150         _wxvtk2Dbaseview->RefreshView();
00151 }
00152 
00153 
00154 void wxWidgetMesure2D::OnCloseContour(wxCommandEvent& event)
00155 {
00156         _mContourModel_1->SetCloseContour( _cb_closeContour->GetValue() );
00157         _mViewContour_1->Refresh();
00158         _wxvtk2Dbaseview->Refresh();
00159         _wxvtk2Dbaseview->RefreshView();
00160 
00161 }
00162 
00163 void wxWidgetMesure2D::OnVisibleInformation(wxCommandEvent& event)
00164 {
00165         _mViewContour_1->SetShowText( _cb_visibleText->GetValue() );
00166         _mViewContour_1->Refresh();
00167         _wxvtk2Dbaseview->Refresh();
00168         _wxvtk2Dbaseview->RefreshView();
00169 }
00170 
00171 void wxWidgetMesure2D::SetMesureScale(double mesureScale)
00172 {
00173         _mViewContour_1->SetMesureScale(mesureScale);
00174 }
00175 
00176 manualContourModel*     wxWidgetMesure2D::GetManualContourModel()
00177 {
00178         return _mContourModel_1;
00179 }