From 356dc9619b5a5d3691752f2064a063c06659a9b9 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Wed, 30 Oct 2024 11:09:49 +0100 Subject: [PATCH] #3563 Group Selection Points in manual contour --- .../manualContourBaseControler.cpp | 112 ++++++++++++++---- .../manualContourBaseControler.h | 80 +++++-------- .../manualContour/manualContourControler.cpp | 53 +++++++-- .../manualContour/manualContourControler.h | 1 - .../widgets/manualContour/manualPoint.cpp | 12 +- .../manualContour/manualViewBaseContour.cpp | 59 ++++++++- .../manualContour/manualViewBaseContour.h | 109 ++++++++--------- .../manualContour/manualViewContour.cpp | 101 ++++++++++++++-- .../widgets/manualContour/manualViewContour.h | 44 ++++--- .../widgets/manualContour/manualViewPoint.cpp | 42 +++++-- .../widgets/manualContour/manualViewPoint.h | 5 +- 11 files changed, 437 insertions(+), 181 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp index d0e98d0..e4e1d35 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp @@ -94,16 +94,14 @@ bool manualContourBaseControler::OnChar() // Delete Point if ((keyCode==8) || (keyCode==127)) { - if (!GetManualViewBaseContour()->GetPosibleSelected()==true) { DeleteActualMousePoint(X,Y); - } + DeleteGroupSelectedPoints(); + } GetManualViewBaseContour()->Refresh(); this->_vtkInteractorStyleBaseView->SetRefresh_waiting(); - } - else - { + } else { // Magnet if (keyCode==32) { @@ -157,12 +155,13 @@ bool manualContourBaseControler::OnChar() { GetManualViewBaseContour()->Refresh(); this->_vtkInteractorStyleBaseView->SetRefresh_waiting(); - } - } - } + } // if + } // if !Editable + } // if code 8 or 127 } return true; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnMouseMove() { @@ -180,6 +179,7 @@ bool manualContourBaseControler::OnMouseMove() } return true; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnLeftButtonDown() { @@ -195,6 +195,7 @@ bool manualContourBaseControler::OnLeftButtonDown() } return true; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnLeftButtonUp() { @@ -208,6 +209,7 @@ bool manualContourBaseControler::OnLeftButtonUp() } return true; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnLeftDClick() { @@ -222,6 +224,7 @@ bool manualContourBaseControler::OnLeftDClick() } return true; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnMiddleButtonDown() { @@ -236,11 +239,13 @@ bool manualContourBaseControler::OnMiddleButtonDown() } return true; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnMiddleButtonUp() { return true; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnRightButtonDown() { @@ -255,22 +260,26 @@ bool manualContourBaseControler::OnRightButtonDown() } return true; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnRightButtonUp() { return true; } + // ---------------------------------------------------------------------------- void manualContourBaseControler::SetModelView(manualBaseModel *manContModel, manualViewBaseContour *manViewBaseCont){ _manContModel = manContModel; _manViewBaseCont = manViewBaseCont; _manViewBaseCont->SetEditable( &_editable ); } + // ---------------------------------------------------------------------------- manualBaseModel* manualContourBaseControler::GetManualContourModel() { return _manContModel; } + // ---------------------------------------------------------------------------- manualViewBaseContour* manualContourBaseControler::GetManualViewBaseContour() { @@ -279,15 +288,15 @@ manualViewBaseContour* manualContourBaseControler::GetManualViewBaseContour() // ---------------------------------------------------------------------------- void manualContourBaseControler::MouseClickLeft(int x, int y) // virtual { - } + // ---------------------------------------------------------------------------- void manualContourBaseControler::MouseClickRight(int x, int y) { SetCompleteCreation( true ); SetKeyBoardMoving( false ); this->GetManualContourModel()->SetCloseContour(true); - + this->GetManualViewBaseContour()->SetAllGroupSelectedPoint(false); // if (_state==1) // { // _state=0; @@ -295,23 +304,40 @@ void manualContourBaseControler::MouseClickRight(int x, int y) SetEditable( false ); SetPosibleToMove( false ); _state = 0; - //EED 24Avril2009 _state=7; } + // ---------------------------------------------------------------------------- void manualContourBaseControler::MouseReleaseLeft(int x, int y) { if (_state==5){ _state = 0; } if (_state==6){ _state = 0; } - if (_state==7){ _state = 0; } - SetMoving( false ); - GetManualViewBaseContour()->SelectPosibleContour(x,y,GetZ()); - if( GetIfCompleteCreation() && IsEditable() && !GetManualViewBaseContour()->GetPosibleSelected() && (GetManualViewBaseContour()->GetIdPoint(x,y,GetZ())==-1) ) - { - SetEditable( false ); - SetPosibleToMove( false ); - } + if (_state==9){ _state = 8; } + + if ((_state!=7) && (_state!=8)) + { + SetMoving( false ); + GetManualViewBaseContour()->SelectPosibleContour(x,y,GetZ()); + if( GetIfCompleteCreation() && IsEditable() && !GetManualViewBaseContour()->GetPosibleSelected() && (GetManualViewBaseContour()->GetIdPoint(x,y,GetZ())==-1) ) + { + SetEditable( false ); + SetPosibleToMove( false ); + } + } else { + _state = 0; + int id, manualPointsSZ; + manualPointsSZ = _manContModel->GetSizeLstPoints(); + for ( id=0; idGetGroupSelectedPoint( id ) == true ) + { + _state = 8; + id = manualPointsSZ; + } + } // for + } // if _state !=7 !=8 } + // ---------------------------------------------------------------------------- void manualContourBaseControler::MouseDLeft(int x, int y ) { @@ -326,25 +352,30 @@ void manualContourBaseControler::MouseDLeft(int x, int y ) } } // if _state==0 } + // ---------------------------------------------------------------------------- void manualContourBaseControler::MouseMove(int x, int y) // virtual { } + // ---------------------------------------------------------------------------- void manualContourBaseControler::SetState(int state) { _state=state; } + // ---------------------------------------------------------------------------- int manualContourBaseControler::GetState() { return _state; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::IsEditable( ) { return _editable; } + // ---------------------------------------------------------------------------- void manualContourBaseControler::SetEditable( bool condition ) { @@ -363,16 +394,19 @@ bool manualContourBaseControler::GetPosibleToMove() { return _posibleToMove; } + // ---------------------------------------------------------------------------- void manualContourBaseControler::SetPosibleToMove( bool condition ) { _posibleToMove = condition; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::IsMoving() { return _moving; } + // ---------------------------------------------------------------------------- void manualContourBaseControler::SetMoving( bool condition ) { @@ -383,11 +417,13 @@ void manualContourBaseControler::SetCompleteCreation( bool condition ) { _created = condition; } + // ---------------------------------------------------------------------------- bool manualContourBaseControler::GetIfCompleteCreation ( ) { return _created; } + // ---------------------------------------------------------------------------- void manualContourBaseControler::SetKeyBoardMoving( bool condition ) { @@ -398,6 +434,7 @@ bool manualContourBaseControler::GetKeyBoardMoving( ) { return _keyBoardMoving; } + // ---------------------------------------------------------------------------- void manualContourBaseControler::CreateNewManualContour(){ _manViewBaseCont->CreateNewContour(); @@ -406,8 +443,8 @@ void manualContourBaseControler::CreateNewManualContour(){ int manualContourBaseControler::GetNumberOfPointsManualContour(){ return _manViewBaseCont->GetNumberOfPoints(); } -// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- //JSTG - 25-02-08 ------------------------------------------------------------- int manualContourBaseControler::GetNumberOfPointsSplineManualContour(){ //return _manViewBaseCont->GetNumberOfPointsSpline(); @@ -422,11 +459,13 @@ double* manualContourBaseControler::GetVectorPointsXManualContour(){ double* manualContourBaseControler::GetVectorPointsYManualContour(){ return _manViewBaseCont->GetVectorPointsYManualContour(); } + // ---------------------------------------------------------------------------- void manualContourBaseControler::DeleteContour(){ _manViewBaseCont->DeleteContour(); _manContModel->DeleteAllPoints(); } + // ---------------------------------------------------------------------------- void manualContourBaseControler::DeleteActualMousePoint(int x, int y)// virtual { @@ -441,6 +480,39 @@ void manualContourBaseControler::DeleteActualMousePoint(int x, int y)// virtual _state = 0; } +// ---------------------------------------------------------------------------- +void manualContourBaseControler::DeleteGroupSelectedPoints() +{ + if ((_manContModel!=NULL) && (_manViewBaseCont!=NULL) ) + { + // Erasing points (leaving minimum 2 points) + bool groupSelected; + int id, manualPointsSZ; + manualPointsSZ = _manContModel->GetSizeLstPoints(); + for ( id=manualPointsSZ-1; id>=0 ; id-- ) + { + groupSelected = _manViewBaseCont->GetGroupSelectedPoint( id ); + if (groupSelected == true) + { + if (_manContModel->GetSizeLstPoints()>2) + { + _manContModel->DeletePoint( id ); + _manViewBaseCont->DeletePoint( id ); + } // if > 2 + } // if groupSelected + } // for + + // change state of GroupSelectionPoing + manualPointsSZ = _manContModel->GetSizeLstPoints(); + for ( id=0; idSetGroupSelectedPoint( id,false ); + } // for + + } + _state = 0; +} + // ---------------------------------------------------------------------------- void manualContourBaseControler::Magnet(int x, int y) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h index 4fece95..01d3596 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h @@ -36,19 +36,14 @@ #include "vtkPolyDataMapper.h" #include "vtkInteractorObserver.h" #include "vtkInteractorStyleImage.h" -#include - -#include - - +#include +#include #include #include #include #include - #include #include - #include #include #include @@ -59,21 +54,16 @@ //#include "widgets/UtilVtk3DGeometriSelection.h" #include "UtilVtk3DGeometriSelection.h" //#include "widgets/InteractorStyleMaracas.h" -#include "InteractorStyleMaracas.h" +#include "InteractorStyleMaracas.h" #include "creawxVTKRenderWindowInteractor.h" - - //-- - #include #include "wxVtkBaseView.h" #include "marTypes.h" - #include "manualContourModel.h" #include "manualViewBaseContour.h" - // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- @@ -109,29 +99,30 @@ public: virtual void MouseMove(int x, int y); virtual void MouseReleaseLeft(int x, int y); - void SetState(int state); - int GetState(); - bool IsEditable(); + void SetState(int state); + int GetState(); + bool IsEditable(); virtual void SetEditable( bool condition ); - bool GetPosibleToMove(); - void SetPosibleToMove( bool condition ); - bool IsMoving(); - void SetMoving( bool condition ); - void SetCompleteCreation( bool condition ); - bool GetIfCompleteCreation ( ); - void SetKeyBoardMoving( bool condition ); - bool GetKeyBoardMoving( ); + bool GetPosibleToMove(); + void SetPosibleToMove( bool condition ); + bool IsMoving(); + void SetMoving( bool condition ); + void SetCompleteCreation( bool condition ); + bool GetIfCompleteCreation ( ); + void SetKeyBoardMoving( bool condition ); + bool GetKeyBoardMoving( ); - void CreateNewManualContour(); - int GetNumberOfPointsManualContour(); - int GetNumberOfPointsSplineManualContour(); - void DeleteContour(); + void CreateNewManualContour(); + int GetNumberOfPointsManualContour(); + int GetNumberOfPointsSplineManualContour(); + void DeleteContour(); virtual void DeleteActualMousePoint(int x, int y ); - double* GetVectorPointsXManualContour(); - double* GetVectorPointsYManualContour(); + void DeleteGroupSelectedPoints(); + double* GetVectorPointsXManualContour(); + double* GetVectorPointsYManualContour(); - void SetZ(int z); + void SetZ(int z); virtual int GetZ(); // VIRTUAL - Adds a point in an specified position @@ -148,31 +139,22 @@ public: void Magnet(int x, int y); virtual void ResetContour(); - - virtual void Configure(); - + virtual void Configure(); //EED Borrame // virtual manualContourBaseControler * Clone( manualViewBaseContour * cloneView = NULL, manualContourModel * cloneModel = NULL ); - - protected: - // Reference to the contour or element view manualViewBaseContour *_manViewBaseCont; - // Reference to the model contour or element model manualBaseModel *_manContModel; - - int _z; - int _state; - bool _editable; - bool _posibleToMove; - bool _moving; - bool _created; - bool _keyBoardMoving; - -}; - + int _z; + int _state; + bool _editable; + bool _posibleToMove; + bool _moving; + bool _created; + bool _keyBoardMoving; +}; #endif // manualContourBaseControler_h diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp index 863d6d9..0f61932 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp @@ -33,7 +33,9 @@ // _state = 1 // move with add point // _state = 5 // move // _state = 6 // move with insert point -// _state = 7 // move with non selection +// _state = 7 // mouse down moving for select group of points +// _state = 8 // After (7) waiting with group of points all ready selected +// _state = 9 // After (8) moving group of points manualContourControler::manualContourControler() { @@ -99,7 +101,7 @@ void manualContourControler::MouseClickLeft(int x, int y) AddPoint(x,y,z); _bakIdPoint=GetNumberOfPointsManualContour() - 1; } - // Insert Control Points IF Contour si Selected + // Insert Control Points IF Contour is Selected if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() ) { ok=true; @@ -120,7 +122,22 @@ void manualContourControler::MouseClickLeft(int x, int y) //ok=true; _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); SetState(7); + GetManualViewBaseContour()->InitRectangleSelection(x,y,z); } + + // If nothing selected _state=8 + if (GetState()==8) + { + _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); + if (_bakIdPoint==-1 ) + { + SetState(7); + GetManualViewBaseContour()->InitRectangleSelection(x,y,z); + } else { + SetState(9); + GetManualViewBaseContour()->InitGroupSelectionPointsToBeMove(_bakIdPoint); + } // point selected + } }else{ SetPosibleToMove( true ); GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() ); @@ -138,6 +155,7 @@ void manualContourControler::MouseClickLeft(int x, int y) GetManualViewBaseContour()->Refresh(); } } + // ---------------------------------------------------------------------------- void manualContourControler::MouseMove(int x, int y) // virtual { @@ -146,22 +164,37 @@ void manualContourControler::MouseMove(int x, int y) // virtual GetManualViewBaseContour()->SelectPosibleContour(x,y,z); if (GetState()==1){ SetPoint( _bakIdPoint , x , y ,z); } if (GetState()==5){ SetPoint( _bakIdPoint , x , y ,z); } + + if (GetState()==9){ GetManualViewBaseContour()->SetNewPositionGroupSelectedPoints( x,y,z ); } + + if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() ) { GetManualViewBaseContour()->MoveContour(x,y,z); - } - if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){ + } // if State 6 + + if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ) + { GetManualViewBaseContour()->Refresh(); this->_vtkInteractorStyleBaseView->SetRefresh_waiting(); - } - if (!IsEditable()) + } /// if State !=7 + + if (GetState()==7 ) + { + GetManualViewBaseContour()->SelectPointsInRectangleRegion(x,y,z); + GetManualViewBaseContour()->Refresh(); + this->_vtkInteractorStyleBaseView->SetRefresh_waiting(); + } /// if State ==7 + + + if (!IsEditable()) { GetManualViewBaseContour()->RemoveControlPoints(); // GetManualViewBaseContour()->RemoveTextActor(); GetManualViewBaseContour()->Refresh(); this->_vtkInteractorStyleBaseView->SetRefresh_waiting(); - } - + } // if editable + } // ---------------------------------------------------------------------------- @@ -170,21 +203,21 @@ void manualContourControler::MouseDLeft( int x, int y)//virtual manualContourBaseControler::MouseDLeft( x, y); if ( IsEditable() ) { - GetManualViewBaseContour()->AddControlPoints(); GetManualViewBaseContour()->AddTextActor(); GetManualViewBaseContour()->Refresh(); this->_vtkInteractorStyleBaseView->SetRefresh_waiting(); } } + // ---------------------------------------------------------------------------- void manualContourControler::SetEasyCreation(bool easyCreation) { _easyCreation=easyCreation; } + // ---------------------------------------------------------------------------- bool manualContourControler::GetEasyCreation() { return _easyCreation; } - diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.h index ee9c76f..cde4cf9 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.h @@ -53,7 +53,6 @@ public: protected: bool _easyCreation; -private: }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualPoint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualPoint.cpp index 82990a6..6a532b1 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualPoint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualPoint.cpp @@ -39,21 +39,21 @@ manualPoint::~manualPoint() } // ---------------------------------------------------------------------------- void manualPoint::SetPoint(double x,double y,double z){ - _x=x; - _y=y; - _z=z; + _x = x; + _y = y; + _z = z; } // ---------------------------------------------------------------------------- void manualPoint::SetPointX(double x){ - _x=x; + _x = x; } // ---------------------------------------------------------------------------- void manualPoint::SetPointY(double y){ - _y=y; + _y = y; } // ---------------------------------------------------------------------------- void manualPoint::SetPointZ(double z){ - _z=z; + _z = z; } // ---------------------------------------------------------------------------- double manualPoint::GetX(){ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp index f356db2..09c847b 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp @@ -527,6 +527,35 @@ void manualViewBaseContour::SelectPoint(int i, bool select) _lstViewPoints[i]->SetSelected(select); } +// ---------------------------------------------------------------------------- +void manualViewBaseContour::SetGroupSelectedPoint(int i, bool select) +{ + _lstViewPoints[i]->SetGroupSelected(select); +} + +// ---------------------------------------------------------------------------- +bool manualViewBaseContour::GetGroupSelectedPoint(int i) +{ + if ( (i>=0) && (i<_lstViewPoints.size()) ) + { + return _lstViewPoints[i]->GetGroupSelected(); + } else { + return false; + } +} + + +// ---------------------------------------------------------------------------- +void manualViewBaseContour::SetAllGroupSelectedPoint( bool select) +{ int i,size=_lstViewPoints.size(); + for (i=0; iSetGroupSelectedPoint( i, select ); + } +} + + + // ---------------------------------------------------------------------------- void manualViewBaseContour::SelectLstPoints() { @@ -828,15 +857,15 @@ void manualViewBaseContour::UpdateColorActor() // ---------------------------------------------------------------------------- int manualViewBaseContour::GetIdPoint(int x, int y, int z) // virtual { - int ii = -1; + int id = -1; if (_manContModel!=NULL){ double xx = x; double yy = y; double zz = z; TransfromCoordViewWorld(xx,yy,zz); - ii=_manContModel->GetIdPoint(xx,yy,zz,_range,-1); + id=_manContModel->GetIdPoint(xx,yy,zz,_range,-1); } - return ii; + return id; } // ---------------------------------------------------------------------------- @@ -1061,3 +1090,27 @@ void manualViewBaseContour::SetSpacing(double spc[3]) _spc[1] = spc[1]; _spc[2] = spc[2]; } + +//EED 2024-10-25 +//------------------------------------------------------------------- +void manualViewBaseContour::InitRectangleSelection(int x, int y, int z) +{ + _RectangleStartX = x; + _RectangleStartY = y; + _RectangleStartZ = z; +} + +//------------------------------------------------------------------- +void manualViewBaseContour::SelectPointsInRectangleRegion(int x,int y,int z) // virtual +{ +} + +//------------------------------------------------------------------- +void manualViewBaseContour::InitGroupSelectionPointsToBeMove(int id) // virtual +{ +} + +//------------------------------------------------------------------- +void manualViewBaseContour::SetNewPositionGroupSelectedPoints( int x , int y ,int z) // virtual +{ +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h index be5976a..20870f4 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h @@ -27,7 +27,6 @@ #define manualViewBaseContour_h #include "vtkRenderWindow.h" - #include "vtkRenderer.h" #include "vtkRenderWindowInteractor.h" //extremely important with VC++ don't remove ! #include "vtkCommand.h" @@ -37,7 +36,6 @@ #include "vtkInteractorObserver.h" #include "vtkInteractorStyleImage.h" #include - #include #include #include @@ -49,9 +47,7 @@ #include //#include "widgets/UtilVtk3DGeometriSelection.h" #include "UtilVtk3DGeometriSelection.h" -#include - - +#include #include #include #include @@ -59,13 +55,10 @@ #include "creawxVTKRenderWindowInteractor.h" - //-- - #include #include "wxVtkBaseView.h" #include "marTypes.h" - #include "manualViewPoint.h" #include "manualContourModel.h" @@ -84,55 +77,49 @@ class creaMaracasVisu_EXPORT manualViewBaseContour public: manualViewBaseContour(); virtual ~manualViewBaseContour(); - - virtual int GetType(); - virtual void Save(FILE *pFile); - virtual void Open(FILE *pFile); - - void AddPoint(); + virtual int GetType(); + virtual void Save(FILE *pFile); + virtual void Open(FILE *pFile); + void AddPoint(); virtual void AddPoint( manualViewPoint * manualViewPoint ); - void InsertPoint(int id); - void DeleteContour(); - void DeletePoint(int x, int y,int z); + void InsertPoint(int id); + void DeleteContour(); + void DeletePoint(int x, int y,int z); virtual void DeletePoint(int id); - virtual void UpdateViewPoint(int id); virtual void UpdateViewPoints(); - - void SetSelected(bool selected); - void SetPosibleSelected(bool posibleSelected); - bool GetSelected(); - bool GetPosibleSelected(); - void DeleteSelectedPoints(); - bool GetEditable(); - void SetEditable( bool * condition ); - - - + void SetSelected(bool selected); + void SetPosibleSelected(bool posibleSelected); + void SetGroupSelectedPoint(int i, bool select); + void SetAllGroupSelectedPoint(bool select); + + bool GetSelected(); + bool GetPosibleSelected(); + bool GetGroupSelectedPoint(int i); + + void DeleteSelectedPoints(); + bool GetEditable(); + void SetEditable( bool * condition ); virtual int GetIdPoint(int x, int y, int z); - - void SelectPoint(int i,bool select); - void SelectLstPoints(); - void SelectAllPoints(bool select); + void SelectPoint(int i,bool select); + void SelectLstPoints(); + void SelectAllPoints(bool select); virtual int SelectPosiblePoint(int x, int y ,int z); - bool SelectPosibleContour(int x, int y ,int z); - void SelectAllPossibleSelected(bool select); - void SetPointSelected(int id,bool select); - void SetPointPosibleSelected(int id,bool select); - void SetIfViewControlPoints(bool ifShow); - bool GetIfViewControlPoints(); - - void UnSelectPoint(int i); - void UnSelectLstPoints(); - void UnSelectAllPoints(); - - void SetModel(manualBaseModel *manContModel); - void SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview); - + bool SelectPosibleContour(int x, int y ,int z); + void SelectAllPossibleSelected(bool select); + void SetPointSelected(int id,bool select); + void SetPointPosibleSelected(int id,bool select); + void SetIfViewControlPoints(bool ifShow); + bool GetIfViewControlPoints(); + void UnSelectPoint(int i); + void UnSelectLstPoints(); + void UnSelectAllPoints(); + void SetModel(manualBaseModel *manContModel); + void SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview); virtual void Refresh(); - int GetNumberOfPoints(); // ??? - //int GetNumberOfPointsSpline(); //JSTG 25-02-08 In ContourModel is the same method - //void SetNumberOfPointsSpline(int size); //JSTG 25-02-08 In ContourModel is the same method + int GetNumberOfPoints(); // ??? + //int GetNumberOfPointsSpline(); //JSTG 25-02-08 In ContourModel is the same method + //void SetNumberOfPointsSpline(int size); //JSTG 25-02-08 In ContourModel is the same method void CreateNewContour(); double* GetVectorPointsXManualContour(); @@ -172,15 +159,15 @@ public: void GetColorSelectContour(double &r, double &g, double &b); //Addinging and removing from visualization specific actors included in the viewer contour - void AddCompleteContourActor( bool ifControlPoints = false); - void RemoveCompleteContourActor(); + void AddCompleteContourActor( bool ifControlPoints = false); + void RemoveCompleteContourActor(); virtual void AddSplineActor(); virtual void RemoveSplineActor(); virtual void AddControlPoints(); virtual void RemoveControlPoints(); - void AddTextActor(); - void RemoveTextActor(); - void InitTextActor(); + void AddTextActor(); + void RemoveTextActor(); + void InitTextActor(); virtual manualViewBaseContour * Clone(); void CopyAttributesTo( manualViewBaseContour *cloneObject ); @@ -190,7 +177,13 @@ public: virtual void ConstructVTKObjects(); - void SetCellArray(bool type); + void SetCellArray(bool type); + + void InitRectangleSelection(int x, int y, int z); + virtual void SelectPointsInRectangleRegion(int x,int y,int z); + virtual void InitGroupSelectionPointsToBeMove(int id); + virtual void SetNewPositionGroupSelectedPoints( int x , int y ,int z); + //--------------------------------------------------- // PRIVATE METHODS & ATTS //--------------------------------------------------- @@ -205,7 +198,6 @@ private: void DeleteVtkObjects(); - //--------------------------------------------------- // PROTECTED METHODS & ATTS //--------------------------------------------------- @@ -266,6 +258,9 @@ protected: virtual void RefreshText(); + int _RectangleStartX; + int _RectangleStartY; + int _RectangleStartZ; }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp index 17df8e8..24dada5 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp @@ -399,19 +399,17 @@ void manualViewContour::ClearPoint(int id) void manualViewContour::InitMove(int x, int y, int z) { _initialConoturModel->DeleteAllPoints(); - manualPoint *mp = NULL; - double XX=x; - double YY=y; - double ZZ=z; - TransfromCoordViewWorld(XX,YY,ZZ); - + double XX = x; + double YY = y; + double ZZ = z; + TransfromCoordViewWorld( XX , YY , ZZ ); int i, manualPointsSZ = _manContModel->GetSizeLstPoints(); for ( i=0; iGetManualPoint( i ); this->_initialConoturModel->AddPoint( mp->GetX() - XX, mp->GetY() - YY, mp->GetZ() ); - } + } // for } //------------------------------------------------------------------- @@ -448,3 +446,92 @@ void manualViewContour::MoveContour(int horizontalUnits, int verticalUnits ) } UpdateViewPoints(); } + +//EED 2024-10-25 +//------------------------------------------------------------------- +void manualViewContour::SelectPointsInRectangleRegion(int x,int y,int z) // virtual +{ + manualPoint *mp = NULL; + double XX1 = _RectangleStartX; + double YY1 = _RectangleStartY; + double ZZ1 = _RectangleStartZ; + double XX2 = x; + double YY2 = y; + double ZZ2 = z; + double tmp; + TransfromCoordViewWorld( XX1 , YY1 , ZZ1 ); + TransfromCoordViewWorld( XX2 , YY2 , ZZ2 ); + if (XX2GetSizeLstPoints(); + for ( i=0; iGetManualPoint( i ); + if ( (mp->GetX()>XX1) && (mp->GetX()GetY()>YY1) && (mp->GetY()SetGroupSelectedPoint(i,true); + } else { + this->SetGroupSelectedPoint(i,false); + }// if inside rectangle + } // for +} + +//------------------------------------------------------------------- +void manualViewContour::InitGroupSelectionPointsToBeMove(int id) +{ + manualPoint *mp = NULL; + manualPoint *mpRef = NULL; + mpRef = _manContModel->GetManualPoint( id ); + lstPointsGroupSelectedToMoveId.clear(); + lstPointsGroupSelectedToMoveX.clear(); + lstPointsGroupSelectedToMoveY.clear(); +// lstPointsGroupSelectedToMoveZ.clear(); + int i, manualPointsSZ = _manContModel->GetSizeLstPoints(); + for ( i=0; iGetGroupSelectedPoint(i)==true) + { + mp = _manContModel->GetManualPoint( i ); + lstPointsGroupSelectedToMoveId.push_back(i); + lstPointsGroupSelectedToMoveX.push_back( mp->GetX() - mpRef->GetX() ); + lstPointsGroupSelectedToMoveY.push_back( mp->GetY() - mpRef->GetY() ); +// lstPointsGroupSelectedToMoveZ.push_back( mpRef->GetZ() - mp->GetZ() ); + } // if GetGroupSelectedPoint + } // for i +} + +//------------------------------------------------------------------- +void manualViewContour::SetNewPositionGroupSelectedPoints( int x , int y , int z) // virtual +{ + int id; + manualPoint *mp; + double xx1 = x; + double yy1 = y; + double zz1 = z; + double xx2; + double yy2; + double zz2; + TransfromCoordViewWorld(xx1,yy1,zz1); + int i,size = lstPointsGroupSelectedToMoveId.size(); + for ( i=0 ; iGetManualPoint(id); + mp->SetPoint(xx2,yy2,zz2); + UpdateViewPoint(id); + } // for i +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h index 8e1c143..3f61b55 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h @@ -37,23 +37,27 @@ class creaMaracasVisu_EXPORT manualViewContour: public manualViewBaseContour { public: manualViewContour(); - virtual ~manualViewContour(); - virtual manualViewContour * Clone(); - void CopyAttributesTo( manualViewContour *cloneObject ); - virtual int GetType(); - virtual void Save(FILE *pFile); - virtual void Open(FILE *pFile); - virtual bool ShowLineVersion(); - virtual void RefreshContour(); - virtual bool ifTouchContour(int x,int y, int z); - virtual void InitMove(int x, int y, int z); - virtual void MoveContour(int x, int y, int z); - virtual void MoveContour(int horizontalUnits, int verticalUnits ); - virtual void DeletePoint(int id); - virtual void ClearPoint(int id); + virtual ~manualViewContour(); + virtual manualViewContour * Clone(); + void CopyAttributesTo( manualViewContour *cloneObject ); + virtual int GetType(); + virtual void Save(FILE *pFile); + virtual void Open(FILE *pFile); + virtual bool ShowLineVersion(); + virtual void RefreshContour(); + virtual bool ifTouchContour(int x,int y, int z); + virtual void InitMove(int x, int y, int z); + virtual void MoveContour(int x, int y, int z); + virtual void MoveContour(int horizontalUnits, int verticalUnits ); + virtual void DeletePoint(int id); + virtual void ClearPoint(int id); + virtual void SelectPointsInRectangleRegion(int x,int y,int z); + virtual void InitGroupSelectionPointsToBeMove(int id); + virtual void SetNewPositionGroupSelectedPoints( int x , int y ,int z); + private: - std::vector< std::vector > _initialMovingPoints; - manualContourModel * _initialConoturModel; + std::vector< std::vector > _initialMovingPoints; + manualContourModel *_initialConoturModel; virtual void RefreshText(); protected: double _minX; @@ -61,7 +65,13 @@ protected: double _minZ; double _maxX; double _maxY; - double _maxZ; + double _maxZ; + + //2024-10-25 + std::vector lstPointsGroupSelectedToMoveId; + std::vector lstPointsGroupSelectedToMoveX; + std::vector lstPointsGroupSelectedToMoveY; +// std::vector lstPointsGroupSelectedToMoveZ; }; #endif // manualViewContour_h diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp index 001bb8e..79bd5ab 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp @@ -29,6 +29,7 @@ manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){ _selected = false; _posibleSelected = false; + _groupSelected = false; _pts = NULL; _pd = NULL; _pointVtkActor = NULL; @@ -74,7 +75,6 @@ void manualViewPoint::CopyAttributesTo( manualViewPoint * cloneObject) cloneObject->SetWidthLine(_widthline); } - // ---------------------------------------------------------------------------- void manualViewPoint::SetWidthLine( double width) { @@ -83,20 +83,39 @@ void manualViewPoint::SetWidthLine( double width) // ---------------------------------------------------------------------------- void manualViewPoint::SetSelected(bool selected){ - _selected=selected; + _selected = selected; +} + +// ---------------------------------------------------------------------------- +void manualViewPoint::SetPosibleSelected(bool posibleSelected) +{ + _posibleSelected = posibleSelected; } + +// ---------------------------------------------------------------------------- +void manualViewPoint::SetGroupSelected(bool groupSelected) +{ + _groupSelected = groupSelected; +} + // ---------------------------------------------------------------------------- -void manualViewPoint::SetPosibleSelected(bool posibleSelected){ - _posibleSelected=posibleSelected; +bool manualViewPoint::GetGroupSelected() +{ + return _groupSelected; } + + + // ---------------------------------------------------------------------------- bool manualViewPoint::GetSelected(){ return _selected; } + // ---------------------------------------------------------------------------- bool manualViewPoint::GetPosibleSelected(){ return _posibleSelected; } + // ---------------------------------------------------------------------------- void manualViewPoint::DeleteVtkObjects(){ if (_pointVtkActor !=NULL) { _pointVtkActor->Delete(); } @@ -109,8 +128,6 @@ void manualViewPoint::DeleteVtkObjects(){ _pd = NULL; } - - // ---------------------------------------------------------------------------- vtkActor* manualViewPoint::CreateVtkPointActor() { @@ -211,7 +228,6 @@ void manualViewPoint::SetPositionXY(double x, double y,double i_range,double pos } } - // ---------------------------------------------------------------------------- void manualViewPoint::UpdateColorActor() { @@ -219,10 +235,16 @@ void manualViewPoint::UpdateColorActor() //EED03 _pointVtkActor->GetProperty()->SetLineWidth( _widthline ); _pointVtkActor->GetProperty()->SetDiffuseColor(_colorNormal_r,_colorNormal_g,_colorNormal_b); - if (_posibleSelected==true){ + if (_posibleSelected==true) + { _pointVtkActor->GetProperty()->SetDiffuseColor(_colorPosibleSelected_r,_colorPosibleSelected_g,_colorPosibleSelected_b); - } - } + } // if _posibleSelected +// EED 2024-10-25 + if (_groupSelected==true) + { + _pointVtkActor->GetProperty()->SetDiffuseColor(_colorPosibleSelected_r,_colorPosibleSelected_g,_colorPosibleSelected_b); + } // if _groupSelected + } // if _pointVtkActor } // ---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h index 7da674e..5943aa0 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h @@ -62,8 +62,10 @@ public: void CopyAttributesTo( manualViewPoint *cloneObject ); void SetSelected(bool selected); void SetPosibleSelected(bool posibleSelected); - bool GetSelected(); + void SetGroupSelected(bool groupSelected); + bool GetSelected(); bool GetPosibleSelected(); + bool GetGroupSelected(); void DeleteVtkObjects(); vtkActor* CreateVtkPointActor(); @@ -105,6 +107,7 @@ private: // bool _selected; bool _posibleSelected; + bool _groupSelected; vtkPoints *_pts; -- 2.47.1