]> Creatis software - creaMaracasVisu.git/commitdiff
#3591 Bug ShowNPoints widget (one point option) vtk9itk5wx3-macos
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Fri, 21 Aug 2026 15:57:54 +0000 (17:57 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Fri, 21 Aug 2026 15:57:54 +0000 (17:57 +0200)
bbtk/src/bbmaracasvisuShowNPoints.cxx
bbtk/src/bbmaracasvisuShowNPoints.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h

index f6dfd072af8547f0fbbf879610bad0b4614b8da4..deb6e69bb377c859e6feda2f9cedb8f4f03fed13 100644 (file)
 #include "bbmaracasvisuShowNPoints.h"
 #include "bbcreaMaracasVisuPackage.h"
 
-
 namespace bbcreaMaracasVisu
 {
 
-
 //------------------------------------------------------------------------
 //------------------------------------------------------------------------
 //------------------------------------------------------------------------
 //------------------------------------------------------------------------
-WidgetShowNPointsBox::WidgetShowNPointsBox(wxWindow *parent,  bbcreaMaracasVisu::ShowNPoints *box, int type)
-: WidgetShowNPoints( parent, type)
+WidgetShowNPointsBox::WidgetShowNPointsBox(wxWindow *parent,  bbcreaMaracasVisu::ShowNPoints *box, int type, std::string labelTitle)
+: WidgetShowNPoints( parent, type, labelTitle)
 {
     mbbShowNPoints=box;
 }
@@ -46,7 +44,6 @@ WidgetShowNPointsBox::~WidgetShowNPointsBox()
 {
 }
 
-
 //------------------------------------------------------------------------
 void WidgetShowNPointsBox::UpdatePoints(wxCommandEvent &event)
 {
@@ -125,6 +122,7 @@ void ShowNPoints::Process()
                 _mwxwidget->GetModelShowNPoints()->SetFirstTime(false);
                 _mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() ,  bbGetInputInitLstIndexs() );
             }
+
         } // if onshowwidget
         _mwxwidget->AutoAddPoints();
         _mwxwidget->TrackingPoint();
@@ -142,7 +140,7 @@ void ShowNPoints::Process()
 //-----------------------------------------------------------------
 void ShowNPoints::CreateWidget(wxWindow* parent)
 {
-    _mwxwidget = new WidgetShowNPointsBox( parent, this, bbGetInputType() );
+    _mwxwidget = new WidgetShowNPointsBox( parent, this, bbGetInputType(), bbGetInputLabel() );
     bbSetOutputWidget( _mwxwidget );
 }
 
@@ -156,10 +154,10 @@ void  ShowNPoints::OnShowWidget()
 //-----------------------------------------------------------------
 void ShowNPoints::bbUserSetDefaultValues()
 {
-    _onshowwidget= false;
-    _firsttime   = true;
-    _backOpacity = -1;
-    _mwxwidget   = NULL;
+    _onshowwidget   = false;
+    _firsttime      = true;
+    _backOpacity    = -1;
+    _mwxwidget      = NULL;
     bbSetInputRadio(10);
     bbSetInputOpacity(1);
     std::vector<double> colour;
@@ -167,6 +165,7 @@ void ShowNPoints::bbUserSetDefaultValues()
     colour.push_back(1.0);
     colour.push_back(0.0);
     bbSetInputColour(colour);
+    bbSetInputLabel("Points");
     bbSetInputImage(NULL);
     bbSetInputType(0);
     bbSetInputRenderer(NULL);
index 529999074fb88f122b3a46a2c8b19a7108259f98..fcdb5717de10897a46ea2ea9fb09018e09a4e50c 100644 (file)
@@ -48,7 +48,7 @@ class ShowNPoints;
 class WidgetShowNPointsBox : public WidgetShowNPoints
 {
 public:
-       WidgetShowNPointsBox( wxWindow *parent,  ShowNPoints *box, int type);
+       WidgetShowNPointsBox( wxWindow *parent,  ShowNPoints *box, int type, std::string labelTitle);
        ~WidgetShowNPointsBox(); 
        void UpdatePoints(wxCommandEvent &event);
 private:
@@ -72,7 +72,8 @@ class /*BBTK_EXPORT*/ ShowNPoints
   BBTK_DECLARE_INPUT(InitLstPointsZ     , std::vector<double>       );
   BBTK_DECLARE_INPUT(InitLstLabels      , std::vector<std::string>  );
   BBTK_DECLARE_INPUT(InitLstIndexs      , std::vector<int>          );
-  BBTK_DECLARE_INPUT(Type, int );
+  BBTK_DECLARE_INPUT(Label              , std::string               );
+  BBTK_DECLARE_INPUT(Type               , int                       );
 
   BBTK_DECLARE_OUTPUT( lstPointsX       , std::vector<double>       );
   BBTK_DECLARE_OUTPUT( lstPointsY       , std::vector<double>       );
@@ -80,7 +81,7 @@ class /*BBTK_EXPORT*/ ShowNPoints
   BBTK_DECLARE_OUTPUT( lstLabels        , std::vector<std::string>  );
   BBTK_DECLARE_OUTPUT( lstIndexs        , std::vector<int>          );
   BBTK_DECLARE_OUTPUT( lstSelectedIndexs, std::vector<int>          );
-  BBTK_DECLARE_OUTPUT( lstSelectedIdCurrentPoints, std::vector<int>    );
+  BBTK_DECLARE_OUTPUT( lstSelectedIdCurrentPoints, std::vector<int> );
 
     
     
@@ -117,6 +118,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox);
   BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector<double>,"");
   BBTK_INPUT(ShowNPoints,InitLstLabels,"Initial lst of labels",std::vector<std::string>,"");
   BBTK_INPUT(ShowNPoints,InitLstIndexs,"Initial lst of indexs sizes",std::vector<int>,"");
+  BBTK_INPUT(ShowNPoints,Label,"(default 'Points') Label title of the widget",std::string,"");
   BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point, 2:Add/DeleteAll points, 3:As 0 with out save/load option, 4 Multiple NPoints",int,"");
 
   BBTK_OUTPUT(ShowNPoints , lstPointsX                  , " list of points X "          , std::vector<double> ,""       );
index 6ef7c20e65d348fba6eb29f9614da29b5232cc58..4292926bc10511cd6fcb28bef056df3f2d85406b 100644 (file)
@@ -25,7 +25,7 @@
 //----------------------------------------------------------------------
 //----------------------------------------------------------------------
 //----------------------------------------------------------------------
-  WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
+  WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type, std::string labelTitle)
     : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
   {
       aux_mesh      =   NULL;
@@ -90,7 +90,9 @@
                 cbVisuActualCollection  = NULL;
                     bookSetPoints       = new wxNotebook(panelParent, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP );
                     panel               = new wxPanel(bookSetPoints);
-
+                    cbAutoAddPoints     = NULL;
+                    cbTrackPoint        = NULL;
+      
       wxSize sizeButton( 50  ,  -1 );
       wxSize sizeSlider( 90  ,  -1 );
 
           wxButton *btnRedo                     = new wxButton      ( panel2, -1, _T("Redo")  ,   wxDefaultPosition, sizeButton );
 
          sCtrlRadio = new wxSpinCtrl( panel2, -1  , wxEmptyString, wxDefaultPosition, sizeButton );
-         sCtrlRadio->SetRange(1,10);
+         sCtrlRadio->SetRange(1,20);
          sCtrlRadio->SetValue( 6 );
          sCtrlOpacity= new wxSpinCtrl( panel2, -1  , wxEmptyString, wxDefaultPosition, sizeButton );
          sCtrlOpacity->SetRange(0,10);
 //            Connect(sdrRadio->GetId()            , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
             
             sCtrlRadio = new wxSpinCtrl( panel, -1  , wxEmptyString, wxDefaultPosition, sizeButton );
-            sCtrlRadio->SetRange(1,10);
+            sCtrlRadio->SetRange(1,20);
             sCtrlRadio->SetValue( 6 );
             sCtrlOpacity= new wxSpinCtrl( panel, -1  , wxEmptyString, wxDefaultPosition, sizeButton );
             sCtrlOpacity->SetRange(0,10);
          if (mtype==1)
          {
                  // Widget interface
-                 wxButton *btnSetPositionPoint         = new wxButton( panel, -1, _T("Set nearest point"));
-                 txtNrPoints                                           = new wxStaticText(panel,-1, _T("-/-"));
+                 wxButton *btnSetPositionPoint         = new wxButton( panel, -1, _T("Set point"));
+//               txtNrPoints                                           = new wxStaticText(panel,-1, _T("-/-"));
 
                  //NTU: Sliders for opacity and radio change
 //          sdrRadio                            = new wxSlider(panel, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
 //          sdrOpacity                        = new wxSlider(panel, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
 //          Connect(sdrOpacity->GetId()           , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
 //          Connect(sdrRadio->GetId()             , wxEVT_COMMAND_SLIDER_UPDATED    , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
-                 wxStaticText* txOpacity                       = new wxStaticText(panel, -1, wxString(_T("  Points Opacity  ")));
-                 wxStaticText* txRadio                         = new wxStaticText(panel, -1, wxString(_T("  Points Radio  ")));
+          
+//               wxStaticText* txOpacity                       = new wxStaticText(panel, -1, wxString(_T("  Points Opacity  ")));
+          
+//               wxStaticText* txRadio                         = new wxStaticText(panel, -1, wxString(_T("  Points Radio  ")));
           
           sCtrlRadio = new wxSpinCtrl( panel, -1  , wxEmptyString, wxDefaultPosition, sizeButton );
-          sCtrlRadio->SetRange(1,10);
+          sCtrlRadio->SetRange(1,20);
           sCtrlRadio->SetValue( 6 );
           sCtrlOpacity= new wxSpinCtrl( panel, -1  , wxEmptyString, wxDefaultPosition, sizeButton );
           sCtrlOpacity->SetRange(0,10);
           Connect( sCtrlOpacity->GetId()            ,wxEVT_COMMAND_SPINCTRL_UPDATED,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &WidgetShowNPoints::UpdatePoints);
                  Connect(btnSetPositionPoint->GetId()  , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
           wxFlexGridSizer *sizer1           = new wxFlexGridSizer(1);
+          wxFlexGridSizer *sizer2H          = new wxFlexGridSizer(2);
                  sizer1->Add(btnSetPositionPoint);
-                 sizer1->Add(txtNrPoints);
-                 sizer1->Add(txRadio);
+//               sizer1->Add(txtNrPoints);
+//               sizer1->Add(txRadio);
                  //sizer1->Add(sdrRadio,1,wxGROW );
           //sizer1->Add(sdrOpacity,1,wxGROW );
-          sizer1->Add(sCtrlRadio );
-          sizer1->Add(sCtrlOpacity);
+          sizer2H->Add(sCtrlRadio );
+          sizer2H->Add(sCtrlOpacity);
+          sizer1->Add(sizer2H);
                  sizer = sizer1;
          }
     
     panel->SetSizer(sizer);
     panel->SetAutoLayout(true);
     panel->Layout();
-    bookSetPoints->AddPage(panel , _T("Points") );
+            
+      wxString strTmp;
+      strTmp.Printf(_T("%s") , labelTitle );
+//    bookSetPoints->AddPage(panel , _T("Point") );
+    bookSetPoints->AddPage(panel , strTmp );
 
     if ((mtype >= 0) && (mtype <= 3) )
     {
@@ -748,7 +758,7 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::AutoAddPoints()
 {
-    if ( cbAutoAddPoints->GetValue() == true )
+    if ( (cbAutoAddPoints!=NULL) && (cbAutoAddPoints->GetValue() == true) )
     {
         OnAddPoint__();
         RefreshCollectionText();
@@ -778,7 +788,10 @@ void WidgetShowNPoints::OnAutoAddPoints(wxCommandEvent& event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::StopAutoAddPoints( )
 {
-    cbAutoAddPoints->SetValue(false);
+    if (cbAutoAddPoints!=NULL)
+    {
+        cbAutoAddPoints->SetValue(false);
+    }
 }
 
 //------------------------------------------------------------------------
@@ -791,9 +804,11 @@ void WidgetShowNPoints::StopAutoAddPoints( )
         } else {
             strTmp.Printf(_T("   %d/%d"), GetModelShowNPoints()->GetIdCurrentPoint()+1 , GetModelShowNPoints()->GetLstPointsSize() );
         }// if IdCurrent<0
-               txtNrPoints->SetLabel( strTmp );
+        if (txtNrPoints!=NULL)
+        {
+            txtNrPoints->SetLabel( strTmp );
+        }
                //--BBTK
-
 //EED 2017-06-03
 //             mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
 //             mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
@@ -886,13 +901,10 @@ void WidgetShowNPoints::StopAutoAddPoints( )
 void WidgetShowNPoints::OnSetPoint_()
 {
     UndoRedo_SaveCollection(); //A
-
     StopAutoAddPoints();
     StopTrackPoint();
-
     //int id=GetModelShowNPoints()->GetNearestPoint();
     int id=GetModelShowNPoints()->GetIdCurrentPoint();
-
     if((id==-1) && (mtype==1))
     {
         id=0;
@@ -1046,7 +1058,7 @@ void WidgetShowNPoints::OnMovePointDown(wxCommandEvent& event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::TrackingPoint( )
 {
-    if ( cbTrackPoint->GetValue() == true )
+    if ( (cbTrackPoint!=NULL) && (cbTrackPoint->GetValue() == true) )
     {
 //        int id = GetModelShowNPoints()->IdInsidePoint();
 //        if (id>=0)
@@ -1104,7 +1116,10 @@ void WidgetShowNPoints::OnTrackPoint(wxCommandEvent& event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::StopTrackPoint( )
 {
-    cbTrackPoint->SetValue(false);
+    if (cbTrackPoint!=NULL)
+    {
+        cbTrackPoint->SetValue(false);
+    } //
 //    idTrack=-1;
 }
 
@@ -1694,6 +1709,7 @@ void WidgetShowNPoints::OnNextCollection(wxCommandEvent &event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::DetectCollectionActive()
 {
+    printf("EED WidgetShowNPoints::DetectCollectionActive Start\n");
     int id;
     if ( (cbVisuActualCollection!=NULL) && (cbVisuActualCollection->GetValue()==false ) )
     {
@@ -1709,9 +1725,10 @@ void WidgetShowNPoints::DetectCollectionActive()
     } else {
         id = GetModelShowNPoints()->IdInsidePoint();   // forcing the selection of the point 
     } // if cbVisuActualCollection
-    
+    printf("EED WidgetShowNPoints::DetectCollectionActive 1 \n");
     RefreshCollectionText();
     RefreshColourCollection();
+    printf("EED WidgetShowNPoints::DetectCollectionActive End \n");
 }
 
 //------------------------------------------------------------------------
index 9679b9cc3d6af68a446fa11fe1a010057db42530..7d503b3186e26de05d42e4e3df1e02aa32ef1c32 100644 (file)
@@ -19,7 +19,7 @@
 class WidgetShowNPoints : public wxPanel
 {
   public:
-         WidgetShowNPoints( wxWindow *parent , int type );
+         WidgetShowNPoints( wxWindow *parent , int type, std::string labelTitle );
          ~WidgetShowNPoints();
       void SetCurrentPoint(int idCurrentPoint );
       void OnBackPoint(wxCommandEvent &event);