]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
#3485 ShowNPionts for Multiple Groups
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / WidgetShowNPoints.cxx
index 47e7d41f228d335b7a00e786fcbbc0555d49a195..a536c3321030cc3f6b92e1ed2f71fd07a8be28b0 100644 (file)
@@ -7,7 +7,6 @@
 
 
 #include <wx/button.h>
-#include <wx/checkbox.h>
 #include <wx/sizer.h>
 #include <wx/filedlg.h>
 #include <wx/msgdlg.h>
                wxButton    *btnAddPoint                = new wxButton( panel, -1, _T("Add Point"));
                wxButton    *btnInsertPoint             = new wxButton( panel, -1, _T("Insert Point"));//CFT
                wxButton    *btnSetPositionPoint= new wxButton( panel, -1, _T("Set nearest point"));
-        wxCheckBox  *chkBox             = new wxCheckBox(panel, -1, _T("Track Point") );
+                     cbTrackPoint       = new wxCheckBox(panel,-1, _T("Track Point") );
         wxButton    *btnRenamePoint            = new wxButton( panel, -1, _T("Rename point"));
                wxButton    *btnEraseLastPoint  = new wxButton( panel, -1, _T("Erase Last point"));
                wxButton    *btnErasePoint              = new wxButton( panel, -1, _T("Erase point"));
                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_CHECKBOX  , (wxObjectEventFunction) &WidgetShowNPoints::OnTrackPoint);
 
 
         wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
                sizer1->Add(textCtrl);
                sizer1->Add(btnAddPoint);
                sizer1->Add(btnInsertPoint);//CFT
-        sizer1->Add(chkBox);
+        sizer1->Add(cbTrackPoint);
                sizer1->Add(btnSetPositionPoint);
                sizer1->Add(btnRenamePoint);
                sizer1->Add(btnErasePoint);
@@ -597,6 +597,7 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
                }       // dialog box
        }
 
+
        //------------------------------------------------------------------------
        void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
        {
@@ -619,7 +620,46 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
                } // if id
                SetOutputBox();
        }
-       
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
+{
+    idTrack         =   -1;
+//    trackPointFlag  =   cbTrackPoint->GetValue();
+    if ( cbTrackPoint->GetValue() == true )
+    {
+        idTrack = GetModelShowNPoints()->IdInsidePoint();
+    } // if trackPointFlag
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::TrackPoint( )
+{
+    if ( cbTrackPoint->GetValue() == true )
+    {
+        int id = GetModelShowNPoints()->IdInsidePoint();
+        if (id>=0)
+        {
+            idTrack=id;
+        }
+        
+        if (idTrack>=0)
+        {
+            GetModelShowNPoints()->SetPointId_mReferencePoint(idTrack);
+            GetViewShowNPoints()->RefreshPoint(idTrack);
+            GetViewShowNPoints()->Render();
+        } // if id
+    } // if trackPointFlag
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::StopTrackPoint( )
+{
+    cbTrackPoint->SetValue(false);
+    idTrack=-1;
+}
+
+
 //------------------------------------------------------------------------
        void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
        {
@@ -667,6 +707,7 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
         // EED 2022-05-19
                //renderer->GetRenderWindow()->Render();
         GetViewShowNPoints()->Render();
+        StopTrackPoint();
        }
 
 //------------------------------------------------------------------------
@@ -679,6 +720,7 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
         ErasePoint( id );
         GetViewShowNPoints()->Render();
         SetOutputBox();
+        StopTrackPoint();
        }
 
 //------------------------------------------------------------------------
@@ -819,6 +861,7 @@ void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
 {
     InsertCollection();
     RefreshColourCollection();
+    StopTrackPoint();
 }
 
 //------------------------------------------------------------------------
@@ -827,6 +870,7 @@ void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
     mActualCollection++;
     InsertCollection();
     RefreshColourCollection();
+    StopTrackPoint();
 }
 
 //------------------------------------------------------------------------
@@ -852,6 +896,7 @@ void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
     DeleteCollection_();
     RefreshCollectionText();
     RefreshColourCollection();
+    StopTrackPoint();
 }
 
 //------------------------------------------------------------------------
@@ -864,6 +909,7 @@ void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
     } //if <=0
     RefreshCollectionText();
     RefreshColourCollection();
+    StopTrackPoint();
 }
 
 //------------------------------------------------------------------------
@@ -876,6 +922,24 @@ void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
     } //if <=0
     RefreshCollectionText();
     RefreshColourCollection();
+    StopTrackPoint();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::DetectCollectionActive()
+{
+    int id;
+    int i,size=lstModelShowNPoints.size();
+    for (i=0;i<size;i++)
+    {
+        id = lstModelShowNPoints[i]->IdInsidePoint();
+        if (id>=0)
+        {
+            mActualCollection=i;
+        } // if id>=0
+    } // for i
+    RefreshCollectionText();
+    RefreshColourCollection();
 }
 
 //------------------------------------------------------------------------
@@ -959,6 +1023,7 @@ void WidgetShowNPoints::OnSaveCollections(wxCommandEvent &event)
 
                 
             }     // dialog box
+    StopTrackPoint();
 
 }
 
@@ -1030,6 +1095,7 @@ void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
                 RefreshCollectionText();
                 RefreshColourCollection();
             }     // dialog box
+    StopTrackPoint();
 }