]> Creatis software - creaMaracasVisu.git/commitdiff
#3524 TransformWidget2
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 21 Jul 2023 13:28:42 +0000 (15:28 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 21 Jul 2023 13:28:42 +0000 (15:28 +0200)
bbtk/src/bbcreaMaracasVisuTransformWidget2.cxx
bbtk/src/bbmaracasvisuShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx

index b19b40e0d19a97d8eefa32fc7d786ec78e97fc0c..9b7262c4f28f568e2c9b1d9541e23d5b4e4f59fa 100644 (file)
@@ -11,14 +11,15 @@ class TransformWidgetPanel : public wxPanel
 {
 public:
     TransformWidgetPanel(TransformWidget2* box, wxWindow *parent);
-    ~TransformWidgetPanel   ();
-    void OnSetPoint         (wxCommandEvent& event);
-    void ReleaseAngle       (wxSlider *slider);
-    void TrackAngle         (double angle ,int idVector);
-    void SetPossiblePoint   (std::vector<double> possiblePoint);
-    void _OnSetPoint        ();
-    void ReleaseCenter      (wxSlider *slider);
-    void TrackCenter        (double step);
+    ~TransformWidgetPanel           ();
+    void OnSetPoint                 (wxCommandEvent& event);
+    void ReleaseAngle               (wxSlider *slider);
+    void TrackAngle                 (double angle ,int idVector);
+    void SetPossiblePoint           (std::vector<double> possiblePoint);
+    void _OnSetPoint                ();
+    void _OnSetPointLocalReference  ();
+    void ReleaseCenter              (wxSlider *slider);
+    void TrackCenter                (double step);
 
     
     // Type : Module A
@@ -45,6 +46,7 @@ private:
     vtkTransform            *tt;
     std::vector<double>     mttActualPoint;
     std::vector<double>     mPossiblePoint;
+    std::vector<double>     mLastPossiblePoint_localReference;
     std::vector<double>     mActualPoint;
     TransformWidget2        *mBox;
     
@@ -55,6 +57,7 @@ private:
     // Type : Module B
     char                    mTool;
     wxSlider                *mSliderGeneral;
+    wxCheckBox              *cbLocalReference;
 };
 
 //------------------------------------------------------------------------
@@ -90,7 +93,7 @@ TransformWidgetPanel::TransformWidgetPanel(TransformWidget2* box, wxWindow *pare
         mSliderRotationY        = new wxSlider( this, -1, 0 , -180, 180     , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator   );
         mSliderRotationZ        = new wxSlider( this, -1, 0 , -180, 180     , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator   );
         wxButton *mBtnSetPoint  = new wxButton( this, -1, _T("Set Point")   , wxDefaultPosition, sizeButton                                             );
-        Connect(mBtnSetPoint->GetId()     , wxEVT_COMMAND_BUTTON_CLICKED    ,  (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSetPoint      );
+        Connect(mBtnSetPoint->GetId()     , wxEVT_COMMAND_BUTTON_CLICKED    , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSetPoint       );
         Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_THUMBRELEASE       , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseX );
         Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_THUMBTRACK         , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackX   );
         Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_CHANGED            , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackX   );
@@ -111,43 +114,44 @@ TransformWidgetPanel::TransformWidgetPanel(TransformWidget2* box, wxWindow *pare
     if (mBox->bbGetInputType()==1)
     {
         sizeSliderWidget.Set(250,-1    );
-        sizeButton.Set( 65 , -1 );
+        sizeButton.Set( 45 , -1 );
         wxRadioButton *rBtnX    = new wxRadioButton( this, -1, _T("ri")      , wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
         wxRadioButton *rBtnY    = new wxRadioButton( this, -1, _T("rj")      , wxDefaultPosition, wxDefaultSize, 0);
         wxRadioButton *rBtnZ    = new wxRadioButton( this, -1, _T("rk")      , wxDefaultPosition, wxDefaultSize, 0);
-        wxRadioButton *rBtnC    = new wxRadioButton( this, -1, _T("C.")  , wxDefaultPosition, wxDefaultSize, 0);
-        rBtnC->SetValue(true);        mTool=3;
-        mSliderGeneral          = new wxSlider( this, -1, 0 , -180, 180      , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator                                   );
-        wxButton *mBtnMoveDown  = new wxButton( this, -1, _T("-")            , wxDefaultPosition, sizeButton                                                                             );
-        wxButton *mBtnMoveUp    = new wxButton( this, -1, _T("+")            , wxDefaultPosition, sizeButton                                                                             );
-        wxButton *mBtnReset     = new wxButton( this, -1, _T("Reset")          , wxDefaultPosition, sizeButton                                                                             );
-        Connect( rBtnX->GetId()         , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonX               );
-        Connect( rBtnY->GetId()         , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonY               );
-        Connect( rBtnZ->GetId()         , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonZ               );
-        Connect( rBtnC->GetId()         , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonN               );
-        Connect(mBtnReset->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED        , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnReset                 );
-        Connect(mBtnMoveDown->GetId()   , wxEVT_COMMAND_BUTTON_CLICKED       , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnMoveDown              );
-        Connect(mBtnMoveUp->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED      , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnMoveUp                );
-        Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_THUMBRELEASE          , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralRelease  );
-        Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_THUMBTRACK            , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralTrack    );
-        Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_CHANGED               , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralTrack    );
+        wxRadioButton *rBtnC    = new wxRadioButton( this, -1, _T("Center")      , wxDefaultPosition, wxDefaultSize, 0);
+        rBtnC->SetValue(true);        mTool = 3;
+        mSliderGeneral          = new wxSlider     ( this, -1, 0 , -180, 180, wxDefaultPosition,sizeSliderWidget ,wxSL_HORIZONTAL, wxDefaultValidator                                   );
+        cbLocalReference        = new wxCheckBox   ( this,-1, _T("Loc Ref"), wxDefaultPosition,wxDefaultSize    ,wxCHK_2STATE | wxALIGN_RIGHT                                          );
+        wxButton *mBtnMoveDown  = new wxButton     ( this, -1, _T("-")            , wxDefaultPosition, sizeButton                                                                       );
+        wxButton *mBtnMoveUp    = new wxButton     ( this, -1, _T("+")            , wxDefaultPosition, sizeButton                                                                       );
+        wxButton *mBtnReset     = new wxButton     ( this, -1, _T("Reset")        , wxDefaultPosition, sizeButton                                                                       );
+        Connect( rBtnX->GetId()         , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction)(void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonX               );
+        Connect( rBtnY->GetId()         , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction)(void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonY               );
+        Connect( rBtnZ->GetId()         , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction)(void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonZ               );
+        Connect( rBtnC->GetId()         , wxEVT_COMMAND_RADIOBUTTON_SELECTED , (wxObjectEventFunction)(void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonN               );
+        Connect(mBtnReset->GetId()      , wxEVT_COMMAND_BUTTON_CLICKED       , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnReset                );
+        Connect(mBtnMoveDown->GetId()   , wxEVT_COMMAND_BUTTON_CLICKED       , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnMoveDown             );
+        Connect(mBtnMoveUp->GetId()     , wxEVT_COMMAND_BUTTON_CLICKED       , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnMoveUp               );
+        Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_THUMBRELEASE          , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralRelease );
+        Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_THUMBTRACK            , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralTrack   );
+        Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_CHANGED               , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralTrack   );
         
-
         wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
-        sizerA->Add( rBtnC , 1 );
-        sizerA->Add( rBtnX , 1 );
-        sizerA->Add( rBtnY , 1 );
-        sizerA->Add( rBtnZ , 1 );
+        sizerA->Add( rBtnC              , 1 );
+        sizerA->Add( rBtnX              , 1 );
+        sizerA->Add( rBtnY              , 1 );
+        sizerA->Add( rBtnZ              , 1 );
         wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
-        sizerB->Add( mSliderGeneral , 0 );
+        sizerB->Add( mSliderGeneral     , 0 );
         wxBoxSizer *sizerC = new wxBoxSizer(wxHORIZONTAL);
-        sizerC->Add( mBtnReset      , 1 );
-        sizerC->Add( mBtnMoveDown   , 1 );
-        sizerC->Add( mBtnMoveUp     , 1 );
+        sizerC->Add( cbLocalReference   , 1 );
+        sizerC->Add( mBtnReset          , 1 );
+        sizerC->Add( mBtnMoveDown       , 1 );
+        sizerC->Add( mBtnMoveUp         , 1 );
         wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
-        sizer->Add( sizerA          , 0 );
-        sizer->Add( sizerB          , 0 );
-        sizer->Add( sizerC          , 0 );
+        sizer->Add( sizerA              , 0 );
+        sizer->Add( sizerB              , 0 );
+        sizer->Add( sizerC              , 0 );
 
         SetSizer(sizer);
     } // if
@@ -233,11 +237,22 @@ void TransformWidgetPanel::SetPossiblePoint(std::vector<double> possiblePoint)
 
 void TransformWidgetPanel::_OnSetPoint()
 {
-    mActualPoint = mPossiblePoint;
+    mActualPoint                        = mPossiblePoint;
+    mLastPossiblePoint_localReference   = mPossiblePoint;
     mBox->bbSetOutputActualPoint( mActualPoint );
     mBox->bbSignalOutputModification(std::string("ActualPoint"));
 }
 
+void TransformWidgetPanel::_OnSetPointLocalReference()
+{
+    mActualPoint        = mLastPossiblePoint_localReference;
+//    mLastPossiblePoint  = mPossiblePoint;
+    mBox->bbSetOutputActualPoint( mActualPoint );
+    mBox->bbSignalOutputModification(std::string("ActualPoint"));
+}
+
+
+
 void TransformWidgetPanel::OnSetPoint(wxCommandEvent& event)
 {
     _OnSetPoint();
@@ -269,26 +284,40 @@ void TransformWidgetPanel::OnReset(wxCommandEvent& event)
 {
     if ((mTool>=0) && (mTool<=2))
     {
-        tt->GetMatrix()->Identity(); tt->Update();
-        t->GetMatrix()->Identity();  t->Update();
-        if (mTool==0)
-        {
-            ReleaseAngle( NULL );
-        } // if
-        if (mTool==1)
-        {
-            t->RotateWXYZ( 90 , 1,0,0);  tt->Update();
-            ReleaseAngle( NULL );
-        } // if
-        if (mTool==2)
+        
+        if (cbLocalReference->GetValue()==false)
         {
-            t->RotateWXYZ( 90 , 0,1,0);  tt->Update();
+            tt->GetMatrix()->Identity(); tt->Update();
+            t->GetMatrix()->Identity();  t->Update();
+            if (mTool==0)
+            {
+                ReleaseAngle( NULL );
+            } // if
+            if (mTool==1)
+            {
+                t->RotateWXYZ( 90 , 1,0,0);  tt->Update();
+                ReleaseAngle( NULL );
+            } // if
+            if (mTool==2)
+            {
+                t->RotateWXYZ( 90 , 0,1,0);  tt->Update();
+                ReleaseAngle( NULL );
+            } // if
+        } else {
+            TrackAngle(45, mTool );
             ReleaseAngle( NULL );
-        } // if
+        } // if cbLocalReference
+
+        
     } // if mTool >=0   <=2
     if (mTool==3)
     {
-        _OnSetPoint();
+        if (cbLocalReference->GetValue()==false)
+        {
+            _OnSetPoint();
+        } else {
+            _OnSetPointLocalReference();
+        } // if cbLocalReference
     } // if mTool == 3
 }
 
index 0d7d0ddf8e99366dbd9feffa60778d6360a92ea6..b9a032a25a5d4ed067909ae1385da83c32e42915 100644 (file)
@@ -110,14 +110,13 @@ void ShowNPoints::Process()
                mwxwidget->SetColour( bbGetInputColour() );
 //             mwxwidget->SetOpacity( bbGetInputOpacity() );
                mwxwidget->SetRadio( bbGetInputRadio() );
-
+        
         if ( backOpacity!=bbGetInputOpacity() )
         {
             backOpacity = bbGetInputOpacity();
             mwxwidget->SetOpacity( bbGetInputOpacity() );
         } // if backOpacity
         
-        
 //        if (firsttime==true)
 //        {
 //            firsttime=false;
@@ -130,8 +129,8 @@ void ShowNPoints::Process()
                 mwxwidget->GetModelShowNPoints()->SetFirstTime(false);
                 mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() ,  bbGetInputInitLstIndexs() );
             }
-//        } // firsttime OJO machete Eduardo pour Adreas a verificar
-        
+//        } // firsttime OJO machete Eduardo pour ANDREAS a verificar
+
         mwxwidget->AutoAddPoints();
         mwxwidget->TrackingPoint();
         bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() );
@@ -139,7 +138,6 @@ void ShowNPoints::Process()
         bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() );
         bbSetOutputlstLabels( mwxwidget->GetLstLabels() );
         bbSetOutputlstIndexs( mwxwidget->GetLstIndexs() );
-
 //        bbSetOutputlstPointsX( mwxwidget->GetModelShowNPoints()->GetLstPointsX() );
 //        bbSetOutputlstPointsY( mwxwidget->GetModelShowNPoints()->GetLstPointsY() );
 //        bbSetOutputlstPointsZ( mwxwidget->GetModelShowNPoints()->GetLstPointsZ() );
index cd1aace00afb8165a6fd981ba63a5f97a474dac7..f42c078d8d738fae2f0f21a1b5481395ba92b30b 100644 (file)
@@ -29,7 +29,6 @@
   WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
     : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
   {
-      printf("WidgetShowNPoints::WidgetShowNPoints Start\n");
       aux_mesh      =   NULL;
       aux_mesh_spc.push_back(1);
       aux_mesh_spc.push_back(1);
       
     mtype                                                      = type;
     SetType(mtype);
-    wxPanel*    panelParent         = this;
-    wxSizer*    sizer                          = NULL;
-    wxSizer*    MNPsizer            = NULL;
-    wxNotebook* bookSetPoints       = NULL;
-    wxNotebook* bookGroupManager    = NULL;
-    wxPanel*    panel               = NULL;
-    wxPanel*    panel2              = NULL;
-                txtNrCollections    = NULL;
-                txtNrPoints         = NULL;
-      bookSetPoints     = new wxNotebook(panelParent,
-                          -1,
-                          wxDefaultPosition,
-                          wxDefaultSize,
-                          wxNB_TOP );
-      panel  = new wxPanel(bookSetPoints);
+    wxPanel*        panelParent         = this;
+    wxSizer*        sizer                              = NULL;
+    wxSizer*        MNPsizer            = NULL;
+    wxNotebook*     bookSetPoints       = NULL;
+    wxNotebook*     bookGroupManager    = NULL;
+    wxPanel*        panel               = NULL;
+    wxPanel*        panel2              = NULL;
+                    txtNrCollections    = NULL;
+                    txtNrPoints         = NULL;
+                cbVisuActualCollection  = NULL;
+                    bookSetPoints       = new wxNotebook(panelParent, -1, wxDefaultPosition, wxDefaultSize, wxNB_TOP );
+                    panel               = new wxPanel(bookSetPoints);
 
       wxSize sizeButton( 50  ,  -1 );
       wxSize sizeSlider( 90  ,  -1 );
             panelParent->Layout();
         } // if sizer
     } // if mtype 4
-      
-      printf("WidgetShowNPoints::WidgetShowNPoints End\n");
-
 }
 
 //------------------------------------------------------------------------
@@ -1708,7 +1701,7 @@ void WidgetShowNPoints::RefreshColourCollection()
     {
         lstViewShowNPoints[i] -> mcolour    = colourAll;
         lstViewShowNPoints[i] -> ratioRadio = 1;
-        if (cbVisuActualCollection->GetValue()==true)
+        if ((cbVisuActualCollection!=NULL) && (cbVisuActualCollection->GetValue()==true))
         {
             lstViewShowNPoints[i] -> mopacity   = 0.0;
         } else {