]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
#3544 Mesh Application - Smooth - Refresh contours bug
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / WidgetShowNPoints.cxx
index ee698ca65d79678f7cf6e4703a562199d9ab88e2..6ded36556bad12a53083a732a9b35bb2b686a7b3 100644 (file)
@@ -694,25 +694,40 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
 
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnAddPoint__()
-{      
+{
     // EED 2022-05-19
        //if (this->renderer==NULL)
     if (GetViewShowNPoints()->renderer==NULL)
        {
                return;
        }
-       std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
-       if (point.size()==3)
+       std::vector<double> refPoint = GetModelShowNPoints()->GetReferencePoint();
+       if (refPoint.size()==3)
        {
-        UndoRedo_SaveCollection(); //A
-               AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
-        SetOutputBox();
-        // EED 2022-05-19
-        //renderer->GetRenderWindow()->Render();
-        GetViewShowNPoints()->Render();
-        UndoRedo_SaveCollection(); //B
+        std::vector<double> lastPoint;
+        bool                ok          = true;
+        int                 lastId      = GetModelShowNPoints()->GetLstPointsSize()-1;
+        if (lastId>=0)
+        {
+            lastPoint=GetModelShowNPoints()->GetPointById( lastId );
+            if (lastPoint.size()==3) printf("WidgetShowNPoints::OnAddPoint__  lastPoint %f %f %f\n" ,  lastPoint[0],lastPoint[1],lastPoint[2] );
+            if ((lastPoint[0]==refPoint[0]) && (lastPoint[1]==refPoint[1]) && (lastPoint[2]==refPoint[2]))
+            {
+                ok=false;
+            } // if lastPoint == refPoint
+        } // if lastId
+        if (ok==true)
+        {
+            UndoRedo_SaveCollection(); //A
+            AddPoint(refPoint[0],refPoint[1],refPoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
+            SetOutputBox();
+            // EED 2022-05-19
+            //renderer->GetRenderWindow()->Render();
+            GetViewShowNPoints()->Render();
+            UndoRedo_SaveCollection(); //B
+        } // if ok
        } else {//mpoint.size
-               printf("creaMaracasVisu::ShowNPoints (not match point) \n");
+               printf("creaMaracasVisu::ShowNPoints OnAddPoint__ (not match point) \n");
        }
 }