From: Eduardo DAVILA Date: Fri, 21 Jul 2023 13:28:42 +0000 (+0200) Subject: #3524 TransformWidget2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e730fab3b9174dbfbddff85c60824ebe1d762f7e;p=creaMaracasVisu.git #3524 TransformWidget2 --- diff --git a/bbtk/src/bbcreaMaracasVisuTransformWidget2.cxx b/bbtk/src/bbcreaMaracasVisuTransformWidget2.cxx index b19b40e..9b7262c 100644 --- a/bbtk/src/bbcreaMaracasVisuTransformWidget2.cxx +++ b/bbtk/src/bbcreaMaracasVisuTransformWidget2.cxx @@ -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 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 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 mttActualPoint; std::vector mPossiblePoint; + std::vector mLastPossiblePoint_localReference; std::vector 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 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 } diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index 0d7d0dd..b9a032a 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -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() ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx index cd1aace..f42c078 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx @@ -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); @@ -80,21 +79,18 @@ 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 ); @@ -454,9 +450,6 @@ 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 {