]> 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 a536c3321030cc3f6b92e1ed2f71fd07a8be28b0..796ffb333de505f1ab5fdb137a465a110b4e2040 100644 (file)
@@ -453,9 +453,30 @@ void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
         AddPoint(x,y,z,label);
     }
     GetViewShowNPoints()->RefreshPoints();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnInsertPoint_()
+{
+    // EED 2022-05-19
+    //if (this->renderer==NULL)
+    if (GetViewShowNPoints()->renderer==NULL)
+    {
+        return;
+    }
 
+    std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
+    if (point.size()==3)
+    {
+        InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
+        SetOutputBox();
+    } else {//mpoint.size
+        printf("creaMaracasVisu::ShowNPoints (not match point) \n");
+    }
 }
 
+
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
 {      
@@ -481,22 +502,8 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
 
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
-{      
-    // EED 2022-05-19
-    //if (this->renderer==NULL)
-    if (GetViewShowNPoints()->renderer==NULL)
-       {
-               return;
-       }
-
-       std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
-       if (point.size()==3)
-       {
-               InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
-               SetOutputBox();
-       } else {//mpoint.size
-               printf("creaMaracasVisu::ShowNPoints (not match point) \n");
-       }
+{
+    OnInsertPoint_();
 }
 
 
@@ -597,43 +604,36 @@ void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
                }       // dialog box
        }
 
-
-       //------------------------------------------------------------------------
-       void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
-       {
-               int id=GetModelShowNPoints()->GetNearestPoint();
-               if((id==-1) && (mtype==1))
-               {
-                       id=0;
-                       AddPoint(0,0,0,"");
-                       SetOutputBox();
-               }
-       
-               if (id>=0)
-               {
-                       GetModelShowNPoints()->SetPointId_mReferencePoint(id);
-            // EED 2022-05-19
-                       //RefreshPoint(id);
-                       //renderer->GetRenderWindow()->Render();
-            GetViewShowNPoints()->RefreshPoint(id);
-            GetViewShowNPoints()->Render();
-               } // if id
-               SetOutputBox();
-       }
-
 //------------------------------------------------------------------------
-void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
+void WidgetShowNPoints::OnSetPoint_()
 {
-    idTrack         =   -1;
-//    trackPointFlag  =   cbTrackPoint->GetValue();
-    if ( cbTrackPoint->GetValue() == true )
+    int id=GetModelShowNPoints()->GetNearestPoint();
+    if((id==-1) && (mtype==1))
     {
-        idTrack = GetModelShowNPoints()->IdInsidePoint();
-    } // if trackPointFlag
+        id=0;
+        AddPoint(0,0,0,"");
+        SetOutputBox();
+    }
+    if (id>=0)
+    {
+        GetModelShowNPoints()->SetPointId_mReferencePoint(id);
+        // EED 2022-05-19
+        //RefreshPoint(id);
+        //renderer->GetRenderWindow()->Render();
+        GetViewShowNPoints()->RefreshPoint(id);
+        GetViewShowNPoints()->Render();
+    } // if id
+    SetOutputBox();
 }
 
 //------------------------------------------------------------------------
-void WidgetShowNPoints::TrackPoint( )
+void WidgetShowNPoints::OnSetPoint(wxCommandEvent& event)
+{
+    OnSetPoint_();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::TrackingPoint( )
 {
     if ( cbTrackPoint->GetValue() == true )
     {
@@ -652,6 +652,29 @@ void WidgetShowNPoints::TrackPoint( )
     } // if trackPointFlag
 }
 
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnTrackPoint_tool()
+{
+    cbTrackPoint->SetValue( !cbTrackPoint->GetValue() );
+    OnTrackPoint_();
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnTrackPoint_()
+{
+    idTrack         =   -1;
+    if ( cbTrackPoint->GetValue() == true )
+    {
+        idTrack = GetModelShowNPoints()->IdInsidePoint();
+    } // if trackPointFlag
+}
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
+{
+    OnTrackPoint_();
+}
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::StopTrackPoint( )
 {
@@ -659,7 +682,6 @@ void WidgetShowNPoints::StopTrackPoint( )
     idTrack=-1;
 }
 
-
 //------------------------------------------------------------------------
        void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
        {
@@ -700,14 +722,20 @@ void WidgetShowNPoints::StopTrackPoint( )
        }
 
 //------------------------------------------------------------------------
-       void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
-       {
-               ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
-               SetOutputBox();
+    void WidgetShowNPoints::OnErasePoint_()
+    {
+        ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
+        SetOutputBox();
         // EED 2022-05-19
-               //renderer->GetRenderWindow()->Render();
+        //renderer->GetRenderWindow()->Render();
         GetViewShowNPoints()->Render();
         StopTrackPoint();
+    }
+
+//------------------------------------------------------------------------
+       void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
+       {
+               OnErasePoint_();
        }
 
 //------------------------------------------------------------------------
@@ -727,18 +755,19 @@ void WidgetShowNPoints::StopTrackPoint( )
 void WidgetShowNPoints::DeleteAllPoints()
 {
     // EED 2022-05-19
-       //int id,size=lstActorsSphere.size();
+    //int id,size=lstActorsSphere.size();
     int id,size=GetViewShowNPoints()->lstActorsSphere.size();
-       for (id=size-1;id>=0;id--)
-       {
-               ErasePoint(id);
-       }
-       SetOutputBox();
+    for (id=size-1;id>=0;id--)
+    {
+        ErasePoint(id);
+    }
+    SetOutputBox();
     // EED 2022-05-19
-       //renderer->GetRenderWindow()->Render();
+    //renderer->GetRenderWindow()->Render();
     GetViewShowNPoints()->Render();
 }
 
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
 {
@@ -865,7 +894,7 @@ void WidgetShowNPoints::OnInsertCollectionBefore(wxCommandEvent &event)
 }
 
 //------------------------------------------------------------------------
-void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
+void WidgetShowNPoints::OnInsertCollectionAfter_()
 {
     mActualCollection++;
     InsertCollection();
@@ -873,6 +902,12 @@ void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
     StopTrackPoint();
 }
 
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
+{
+    OnInsertCollectionAfter_();
+}
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::DeleteCollection_()
 {
@@ -891,7 +926,7 @@ void WidgetShowNPoints::DeleteCollection_()
 }
 
 //------------------------------------------------------------------------
-void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
+void WidgetShowNPoints::OnDeleteCollection_()
 {
     DeleteCollection_();
     RefreshCollectionText();
@@ -899,6 +934,12 @@ void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
     StopTrackPoint();
 }
 
+//------------------------------------------------------------------------
+void WidgetShowNPoints::OnDeleteCollection(wxCommandEvent &event)
+{
+    OnDeleteCollection_();
+}
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnBackCollection(wxCommandEvent &event)
 {
@@ -1209,3 +1250,78 @@ std::vector<int> WidgetShowNPoints::GetLstIndexs()
     return lstIndexs;
 }
 
+
+void WidgetShowNPoints::CreatePatch01()
+{
+    if ( (lstModelShowNPoints.size()==1) && (GetModelShowNPoints()->GetLstPointsSize()==4) )
+    {
+        StopTrackPoint();
+        double px,py,pz;
+        double dx,dy,dz,s;
+        std::vector<int> lstX = GetModelShowNPoints()->GetLstPointsX();
+        std::vector<int> lstY = GetModelShowNPoints()->GetLstPointsY();
+        std::vector<int> lstZ = GetModelShowNPoints()->GetLstPointsZ();
+        
+        // --- Group 0 ---
+        ErasePoint( 2 );
+        ErasePoint( 2 );
+        dx=lstX[1]-lstX[0];
+        dy=lstY[1]-lstY[0];
+        dz=lstZ[1]-lstZ[0];
+        s=0.33333;
+        px = lstX[0] + dx*s;
+        py = lstY[0] + dy*s;
+        pz = lstZ[0] + dz*s;
+        InsertPoint(px ,py, pz,"");
+        s=s*2;
+        px = lstX[0] + dx*s;
+        py = lstY[0] + dy*s;
+        pz = lstZ[0] + dz*s;
+        InsertPoint(px ,py, pz,"");
+
+        // --- Group 1 ---
+        OnInsertCollectionAfter_();
+          px = (lstX[0]+lstX[3])/2;
+          py = (lstY[0]+lstY[3])/2;
+          pz = (lstZ[0]+lstZ[3])/2;
+          InsertPoint(px ,py, pz,"");
+          px = (lstX[1]+lstX[2])/2;
+          py = (lstY[1]+lstY[2])/2;
+          pz = (lstZ[1]+lstZ[2])/2;
+          InsertPoint(px ,py, pz,"");
+          px = (lstX[0]+lstX[1]+lstX[2]+lstX[3])/4;
+          py = (lstY[0]+lstY[1]+lstY[2]+lstY[3])/4;
+          pz = (lstZ[0]+lstZ[1]+lstZ[2]+lstZ[3])/4;
+          InsertPoint(px ,py, pz,"");
+
+        
+        // --- Group 2 ---
+        OnInsertCollectionAfter_();
+          px = lstX[3];
+          py = lstY[3];
+          pz = lstZ[3];
+          InsertPoint(px ,py, pz,"");
+          px = lstX[2];
+          py = lstY[2];
+          pz = lstZ[2];
+          InsertPoint(px ,py, pz,"");
+          dx=lstX[2]-lstX[3];
+          dy=lstY[2]-lstY[3];
+          dz=lstZ[2]-lstZ[3];
+          s=0.33333;
+          px = lstX[3] + dx*s;
+          py = lstY[3] + dy*s;
+          pz = lstZ[3] + dz*s;
+          InsertPoint(px ,py, pz,"");
+          s=s*2;
+          px = lstX[3] + dx*s;
+          py = lstY[3] + dy*s;
+          pz = lstZ[3] + dz*s;
+          InsertPoint(px ,py, pz,"");
+
+        
+        SetOutputBox();
+    } else {
+            printf("EED WidgetShowNPoints::CreatePatch01  Warning patch not apply. Need juste one group with four points\n");
+    } // if
+}