]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbcreaMaracasVisuTransformWidget2.cxx
#3524 TransformWidget2
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuTransformWidget2.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
 }