]> Creatis software - creaMaracasVisu.git/commitdiff
#3485 ShowNPionts for Multiple Groups
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 24 Jun 2022 14:39:02 +0000 (16:39 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 24 Jun 2022 14:39:02 +0000 (16:39 +0200)
bbtk/bbs/boxes/SliceImage-3DVisu.bbg
bbtk/bbs/boxes/SliceImage-3DVisu.bbs
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
bbtk/src/bbmaracasvisuShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h

index a75cf0eaa5b0844f4cfa18e81e6d704822b73b17..af66f84d8fbe262e6538dfe6d6c077dbaa783703 100644 (file)
@@ -60,7 +60,7 @@ COMPLEX_PORT
 transparenceBeforeAboveRange
 -386.966824:85.119355:-900.000000
 FIN_COMPLEX_PORT
-BOXES:47
+BOXES:48
 BOX
 creaMaracasVisu:SliceImage:Box00
 ISEXEC:FALSE
@@ -449,7 +449,13 @@ ISEXEC:FALSE
 -375.478516:-89.335399:-900.000000
 -342.158516:-91.835399:-900.000000
 FIN_BOX
-CONNECTIONS:74
+BOX
+std:MagicBox:Box89
+ISEXEC:FALSE
+-105.296409:65.122911:-900.000000
+-83.696409:62.622911:-900.000000
+FIN_BOX
+CONNECTIONS:76
 CONNECTION
 Box22:LookupTable:Box04:LookupTable
 NumberOfControlPoints:0
@@ -538,9 +544,6 @@ CONNECTION
 SliceDeep:SliceDeep:Box60:In1
 NumberOfControlPoints:0
 CONNECTION
-SliceOpacity:SliceOpacity:Box04:Opacity
-NumberOfControlPoints:0
-CONNECTION
 Render:Render:Box61:In
 NumberOfControlPoints:0
 CONNECTION
@@ -672,4 +675,13 @@ NumberOfControlPoints:0
 CONNECTION
 Box32:Out:Box26:Transform
 NumberOfControlPoints:0
+CONNECTION
+SliceOpacity:SliceOpacity:Box89:In
+NumberOfControlPoints:0
+CONNECTION
+Box89:Out:Box04:Opacity
+NumberOfControlPoints:0
+CONNECTION
+Box89:Out:Box26:Opacity
+NumberOfControlPoints:0
 APP_END
index 1c9a7b96eeed8e895f18d2bea99003ac5388e7d8..119769235dd0292ae008d28dfe827dff08f68916 100644 (file)
@@ -165,6 +165,8 @@ new wx:OutputText Box87
 
 new wx:LayoutLine Box88
 
+new std:MagicBox Box89
+
 
 connect Box22.LookupTable Box04.LookupTable
 connect Box32.Out Box04.Transform
@@ -228,19 +230,21 @@ connect Box37.Out Box87.In
 connect Box86.Widget Box88.Widget1
 connect Box87.Widget Box88.Widget2
 connect Box32.Out Box26.Transform
+connect Box89.Out Box04.Opacity
+connect Box89.Out Box26.Opacity
 
 # Complex input ports
 input Direction Box40.In1 " "
 input ColorBorder Box62.In1 " "
 input Image Box38.In " "
 input SliceDeep Box60.In1 " "
-input SliceOpacity Box04.Opacity " "
 input Render Box61.In " "
 input WindowColorLevel Box65.In1 " "
 input BorderActive Box83.In " "
 input Interpolation_mode Box78.In " "
 input TypeTransparence Box84.In " "
 input transparenceBeforeAboveRange Box85.In " "
+input SliceOpacity Box89.In " "
 
 # Complex output ports
 output BoxChangeImageSlice Box04.BoxChange " "
index e38abef92783b2aa9d365e538049843354774582..4cbce728c44f5617225f33242a73909ddf36c00d 100644 (file)
@@ -876,9 +876,9 @@ void ManualContourModel_Box::Process()
         } // for i
         
        // Step 1.  All contours the same clockwise direction (Control Points)
-               if (bbGetInputDoubleContour()==1)
+               if ((bbGetInputDoubleContour()==1) && (bbGetInputOpenClose()==true))
                {
-                       ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
+                       ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );  // wich is the plane base XY? XZ ZY  ??????
        //              ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
                } // DoubleContour
                size    = lstIndexsIn.size();
index c60e495ab9c2fb8bf50c7734a47efe42b1b01e93..3221c6d22bfb662ba648b1f8d9e481772cb5eaca 100644 (file)
@@ -104,18 +104,24 @@ void ShowNPoints::Process()
 {
        if (mwxwidget!=NULL)
        {
-        printf("EED  ShowNPoints::Process  point: %d %d %d\n", bbGetInputIn()[0], bbGetInputIn()[1], bbGetInputIn()[2] );
                mwxwidget->SetRenderer( bbGetInputRenderer() );
                mwxwidget->SetReferencePoint( bbGetInputIn() );
                mwxwidget->SetImage( bbGetInputImage() );
                mwxwidget->SetColour( bbGetInputColour() );
                mwxwidget->SetOpacity( bbGetInputOpacity() );
                mwxwidget->SetRadio( bbGetInputRadio() );
+        
+        if ( mwxwidget->GetModelShowNPoints()->GetFirstTime()==false )
+        {
+            mwxwidget->DetectCollectionActive();
+        }
+        
                if ( mwxwidget->GetModelShowNPoints()->GetFirstTime()==true )
                {
                        mwxwidget->GetModelShowNPoints()->SetFirstTime(false);
                        mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() );
                }
+        mwxwidget->TrackPoint();
         bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() );
         bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
         bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() );
index feacc8d983d7375ce7f6fbd99d426d9cbe98c053..c3c06720d1118ffa3a4e6783644cfe738f64429f 100644 (file)
@@ -295,6 +295,7 @@ int ModelShowNPoints::IdInsidePoint()
        int id=-1;
        int i, size=(int)( lstPointsX.size() );
     double spc[3];
+    double radio2=(mradio+1)*(mradio+1);
        if(mimage ==NULL)
        {
                printf("WidgetShowNPoints::IdInsidePoint  image not set\n");
@@ -306,7 +307,7 @@ int ModelShowNPoints::IdInsidePoint()
                        double rx =  spc[0]*(mReferencePoint[0] - lstPointsX [i]);
                        double ry =  spc[1]*(mReferencePoint[1] - lstPointsY [i]);
                        double rz =  spc[2]*(mReferencePoint[2] - lstPointsZ [i]);
-                       if ( rx*rx + ry*ry + rz*rz <= mradio*mradio)
+                       if ( rx*rx + ry*ry + rz*rz <= radio2)
                        {
                                id=i;
                        }       // if
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();
 }
 
 
index 66fa2d1eb5e7b24ce42e9d7b62215f410291c466..6520d5f3700a0669342107e06987517d2aedac6d 100644 (file)
@@ -9,6 +9,8 @@
 #include <wx/textctrl.h>
 #include <wx/slider.h>
 #include <wx/stattext.h>
+#include <wx/checkbox.h>
+
 
 class WidgetShowNPoints : public wxPanel
 {
@@ -18,10 +20,16 @@ class WidgetShowNPoints : public wxPanel
          void OnAddPoint(wxCommandEvent &event);   
          void OnInsertPoint(wxCommandEvent& event);//CFT
          void OnSetPoint(wxCommandEvent& event);
+      void OnTrackPoint(wxCommandEvent& event);
+      void TrackPoint();
+      void StopTrackPoint();
+      void DetectCollectionActive();
+
          void OnRenamePoint(wxCommandEvent& event);
          void OnErasePoint(wxCommandEvent& event);
          void OnEraseLastPoint(wxCommandEvent &event); 
-         void OnDeleteAllPoints(wxCommandEvent &event);   
+         void OnDeleteAllPoints(wxCommandEvent &event);
+    
          void OnSavePoints(wxCommandEvent &event);   
          void OnLoadPoints(wxCommandEvent &event);
 
@@ -93,6 +101,7 @@ class WidgetShowNPoints : public wxPanel
       //double                            mopacity;
       std::vector<ViewShowNPoints*>       lstViewShowNPoints;
 
+    
          //NTU: For updating points
          wxStaticText                              * askPointLabel;
          wxTextCtrl                                * textCtrl;
@@ -100,10 +109,13 @@ class WidgetShowNPoints : public wxPanel
       wxStaticText                         * txtNrPoints;
          wxSlider                                  * sdrOpacity;
          wxSlider                                  * sdrRadio;
+      wxCheckBox                        * cbTrackPoint;
     
       std::vector<ModelShowNPoints*>    lstModelShowNPoints;
          int                                                       mtype;
       int                               mActualCollection;
+//      bool                              trackPointFlag;
+      int                               idTrack;
 };