]> Creatis software - creaMaracasVisu.git/commitdiff
#3495 ShowNPoints Automatic add points
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 23 Nov 2022 09:50:10 +0000 (10:50 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 23 Nov 2022 09:50:10 +0000 (10:50 +0100)
bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx
bbtk/src/bbmaracasvisuShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h

index 65e9e5a670c94a6d73580bfb07041ad2928a0f29..621fe74a0a7f70bbee6c96f09bb52326ab622334 100644 (file)
@@ -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 ) )
index 51774935dff05bd65b8eb722e785db6b04ae4322..9292fd69f9240a4dd039b0b83e86e02b291a63cb 100644 (file)
@@ -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() );
index 5eb4406a8f8477494b1650a8fcb2f14236b9bb45..9b3a9436578a893008143d6a6e1ea2f52164562c 100644 (file)
 
           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           );
        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")        );
             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);
                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);
         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();
index 48f24353416bc0ffd29d82aa25b53fb37aa2af78..7e41319f4817938b49537ff0576452eecbbebeba 100644 (file)
@@ -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<ModelShowNPoints*>    lstModelShowNPoints;
          int                                                       mtype;
       int                               mActualCollection;