From 960b3634c0944e390dd3251c1000a44aa07666a6 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 23 Nov 2022 10:50:10 +0100 Subject: [PATCH] #3495 ShowNPoints Automatic add points --- .../bbcreaMaracasVisuShowNPoints_Tools.cxx | 4 + bbtk/src/bbmaracasvisuShowNPoints.cxx | 2 + .../wxWindows/widgets/WidgetShowNPoints.cxx | 105 ++++++++++++++---- .../wxWindows/widgets/WidgetShowNPoints.h | 13 ++- 4 files changed, 102 insertions(+), 22 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx index 65e9e5a..621fe74 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx @@ -32,6 +32,10 @@ void ShowNPoints_Tools::NearestPointToMesh( vtkPoints *points,vtkStaticPointLoca void ShowNPoints_Tools::CreatePatch01() { WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); + + wsp->StopAutoAddPoints(); + wsp->StopTrackPoint(); + if ( (wsp->GetLstModelShowNPointsSize()==1) && (wsp->GetModelShowNPoints()->GetLstPointsSize()==4) && (bbGetInputMesh()!=NULL ) ) diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index 5177493..9292fd6 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -120,6 +120,8 @@ void ShowNPoints::Process() mwxwidget->GetModelShowNPoints()->SetFirstTime(false); mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() ); } + + mwxwidget->AutoAddPoints(); mwxwidget->TrackingPoint(); bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() ); bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx index 5eb4406..9b3a943 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx @@ -123,7 +123,6 @@ sdrRadio -> SetToolTip( _T("Radio") ); sdrOpacity -> SetToolTip( _T("Opacity") ); - Connect(btnBackCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnBackCollection ); Connect(btnNextCollection->GetId() , wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnNextCollection ); @@ -166,21 +165,23 @@ if ( (mtype==0) || (mtype==3) || (mtype==4) ) { // Widget interface -// askPointLabel = new wxStaticText(panel, -1, _T("Label:")); // JPR - textCtrl = new wxTextCtrl(panel, -1, wxEmptyString , wxDefaultPosition, sizeButton); - wxButton *btnAddPoint = new wxButton( panel, -1, _T("+") , wxDefaultPosition, sizeButton ); - wxButton *btnInsertPoint = new wxButton( panel, -1, _T("(+)") , wxDefaultPosition, sizeButton );//CFT - wxButton *btnSetPositionPoint= new wxButton( panel, -1, _T("Set") , wxDefaultPosition, sizeButton ); - cbTrackPoint = new wxCheckBox(panel,-1, _T("Tra.") , wxDefaultPosition, sizeButton ); - wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Ren.") , wxDefaultPosition, sizeButton ); - wxButton *btnErasePoint = new wxButton( panel, -1, _T("-") , wxDefaultPosition, sizeButton ); - wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("- lst") , wxDefaultPosition, sizeButton ); - wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("--") , wxDefaultPosition, sizeButton ); - wxButton *btnUndo = new wxButton( panel, -1, _T("Undo") , wxDefaultPosition, sizeButton ); - wxButton *btnRedo = new wxButton( panel, -1, _T("Redo") , wxDefaultPosition, sizeButton ); - wxButton *btnSavePoints = NULL; - wxButton *btnLoadPoints = NULL; +// askPointLabel = new wxStaticText(panel, -1, _T("Label:")); // JPR + textCtrl = new wxTextCtrl(panel, -1, wxEmptyString , wxDefaultPosition, sizeButton); + cbAutoAddPoints = new wxCheckBox(panel,-1, _T("Auto") , wxDefaultPosition, sizeButton ); + wxButton *btnAddPoint = new wxButton( panel, -1, _T("+") , wxDefaultPosition, sizeButton ); + wxButton *btnInsertPoint = new wxButton( panel, -1, _T("(+)") , wxDefaultPosition, sizeButton );//CFT + wxButton *btnSetPositionPoint = new wxButton( panel, -1, _T("Set") , wxDefaultPosition, sizeButton ); + cbTrackPoint = new wxCheckBox(panel,-1, _T("Tra.") , wxDefaultPosition, sizeButton ); + wxButton *btnRenamePoint = new wxButton( panel, -1, _T("Ren.") , wxDefaultPosition, sizeButton ); + wxButton *btnErasePoint = new wxButton( panel, -1, _T("-") , wxDefaultPosition, sizeButton ); + wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("- lst") , wxDefaultPosition, sizeButton ); + wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("--") , wxDefaultPosition, sizeButton ); + wxButton *btnUndo = new wxButton( panel, -1, _T("Undo") , wxDefaultPosition, sizeButton ); + wxButton *btnRedo = new wxButton( panel, -1, _T("Redo") , wxDefaultPosition, sizeButton ); + wxButton *btnSavePoints = NULL; + wxButton *btnLoadPoints = NULL; + cbAutoAddPoints -> SetToolTip( _T("Auto Add point") ); btnAddPoint -> SetToolTip( _T("+ Add point") ); btnInsertPoint -> SetToolTip( _T("(-) Insert point") ); btnErasePoint -> SetToolTip( _T("- Erase point") ); @@ -209,6 +210,7 @@ Connect(sdrOpacity->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints); Connect(sdrRadio->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints); } // if mtype 0 3 + Connect(cbAutoAddPoints->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnAutoAddPoints); Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint); Connect(btnInsertPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnInsertPoint);//CFT Connect(btnSetPositionPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint); @@ -216,7 +218,7 @@ Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint); Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint); Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints); - Connect(cbTrackPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint); + Connect(cbTrackPoint->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint); Connect(btnUndo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnUndo); Connect(btnRedo->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnRedo); wxFlexGridSizer *sizer0 = new wxFlexGridSizer(1); @@ -227,6 +229,8 @@ wxFlexGridSizer *sizer5 = new wxFlexGridSizer(2); sizer1->Add( textCtrl ); sizer1->Add( btnRenamePoint ); + sizer2->Add( cbAutoAddPoints ); + sizer2->Add( new wxStaticText(panel, -1, _T(" ")) ); sizer2->Add( btnAddPoint ); sizer2->Add( btnInsertPoint );//CFT sizer3->Add( btnSetPositionPoint ); @@ -536,6 +540,9 @@ void WidgetShowNPoints::OnInsertPoint_() { // EED 2022-05-19 //if (this->renderer==NULL) + + StopAutoAddPoints(); + StopTrackPoint(); if (GetViewShowNPoints()->renderer==NULL) { return; @@ -552,7 +559,13 @@ void WidgetShowNPoints::OnInsertPoint_() } //------------------------------------------------------------------------ -void WidgetShowNPoints::OnAddPoint_() +void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT +{ + OnInsertPoint_(); +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnAddPoint__() { // EED 2022-05-19 //if (this->renderer==NULL) @@ -574,6 +587,13 @@ void WidgetShowNPoints::OnAddPoint_() UndoRedo_SaveCollection(); } +void WidgetShowNPoints::OnAddPoint_() +{ + StopAutoAddPoints(); + StopTrackPoint(); + OnAddPoint__(); +} + //------------------------------------------------------------------------ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) { @@ -581,11 +601,40 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event) } //------------------------------------------------------------------------ -void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT +void WidgetShowNPoints::AutoAddPoints() { - OnInsertPoint_(); + if ( cbAutoAddPoints->GetValue() == true ) + { + OnAddPoint__(); + } // if cbAutoAddPoints } +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnAutoAddPoints_tool() +{ + cbAutoAddPoints->SetValue( !cbAutoAddPoints->GetValue() ); + OnTrackPoint_(); +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnAutoAddPoints_() +{ + StopTrackPoint(); + printf("EED WidgetShowNPoints::OnAutoAddPoints_ \n"); +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event) +{ + StopTrackPoint(); + printf("EED WidgetShowNPoints::OnAutoAddPoints \n"); +} + +//------------------------------------------------------------------------ +void WidgetShowNPoints::StopAutoAddPoints( ) +{ + cbAutoAddPoints->SetValue(false); +} //------------------------------------------------------------------------ void WidgetShowNPoints::SetOutputBox() @@ -687,6 +736,9 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT //------------------------------------------------------------------------ void WidgetShowNPoints::OnSetPoint_() { + StopAutoAddPoints(); + StopTrackPoint(); + int id=GetModelShowNPoints()->GetNearestPoint(); if((id==-1) && (mtype==1)) { @@ -744,6 +796,8 @@ void WidgetShowNPoints::OnTrackPoint_tool() //------------------------------------------------------------------------ void WidgetShowNPoints::OnTrackPoint_() { + StopAutoAddPoints(); + idTrack = -1; if ( cbTrackPoint->GetValue() == true ) { @@ -754,6 +808,7 @@ void WidgetShowNPoints::OnTrackPoint_() //------------------------------------------------------------------------ void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event) { + printf("WidgetShowNPoints::OnTrackPoint \n"); OnTrackPoint_(); } @@ -807,6 +862,9 @@ void WidgetShowNPoints::StopTrackPoint( ) //------------------------------------------------------------------------ void WidgetShowNPoints::OnErasePoint_() { + StopAutoAddPoints(); + StopTrackPoint(); + ErasePoint( GetModelShowNPoints()->IdInsidePoint() ); SetOutputBox(); // EED 2022-05-19 @@ -828,6 +886,9 @@ void WidgetShowNPoints::StopTrackPoint( ) // EED 2022-05-19 //ErasePoint( lstActorsSphere.size()-1 ); //renderer->GetRenderWindow()->Render(); + StopAutoAddPoints(); + StopTrackPoint(); + int id = GetViewShowNPoints()->lstActorsSphere.size()-1; ErasePoint( id ); UndoRedo_SaveCollection(); @@ -850,6 +911,9 @@ void WidgetShowNPoints::DeleteAllPoints_() void WidgetShowNPoints::OnDeleteAllPoints_() { + StopAutoAddPoints(); + StopTrackPoint(); + DeleteAllPoints_(); UndoRedo_SaveCollection(); } @@ -1447,6 +1511,9 @@ void WidgetShowNPoints::InvertLstPoints_() //------------------------------------------------------------------------ void WidgetShowNPoints::OnInvertLstPoints_() { + StopAutoAddPoints(); + StopTrackPoint(); + InvertLstPoints_(); SetOutputBox(); UndoRedo_SaveCollection(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h index 48f2435..7e41319 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h @@ -16,9 +16,15 @@ class WidgetShowNPoints : public wxPanel { public: WidgetShowNPoints( wxWindow *parent , int type ); - ~WidgetShowNPoints(); - void OnAddPoint(wxCommandEvent &event); + ~WidgetShowNPoints(); + void StopAutoAddPoints(); + void AutoAddPoints(); + void OnAutoAddPoints_tool(); + void OnAutoAddPoints_(); + void OnAutoAddPoints(wxCommandEvent& event); + void OnAddPoint(wxCommandEvent &event); void OnAddPoint_(); + void OnAddPoint__(); void OnInsertPoint(wxCommandEvent& event);//CFT void OnSetPoint_(); void OnSetPoint(wxCommandEvent& event); @@ -134,7 +140,8 @@ class WidgetShowNPoints : public wxPanel wxSlider * sdrOpacity; wxSlider * sdrRadio; wxCheckBox * cbTrackPoint; - + wxCheckBox * cbAutoAddPoints; + std::vector lstModelShowNPoints; int mtype; int mActualCollection; -- 2.47.1