From 5b48f9a5462110a1400b510b897b7d6a1758dca6 Mon Sep 17 00:00:00 2001 From: Ricardo Corredor Date: Tue, 13 Oct 2009 02:33:11 +0000 Subject: [PATCH] Changes with manualBaseModel. It improves the functionality with the new points contour and some saving and loading aspects of the contours --- .../wxWindows/Contour/ContourExtractData.cxx | 60 ++++++++++-- .../wxWindows/Contour/ContourExtractData.h | 27 +++++- .../manualContourBaseControler.cpp | 13 ++- .../manualContourBaseControler.h | 18 +++- .../manualContour/manualContourControler.cpp | 2 +- .../manualContour/manualContourModel.cpp | 61 +++++++++++- .../manualContour/manualContourModel.h | 92 ++++++++++++++----- .../manualContourModelBullEye.cpp | 4 +- .../manualContour/manualContourModelBullEye.h | 2 +- .../manualContour/manualViewBaseContour.cpp | 32 ++++--- .../manualContour/manualViewBaseContour.h | 69 ++++++++++---- .../manualContour/manualViewContour.cpp | 24 +++-- .../widgets/manualContour/manualViewPoint.cpp | 57 +++++++++--- .../widgets/manualContour/manualViewPoint.h | 75 +++++++++++++-- 14 files changed, 430 insertions(+), 106 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx index 974b168..10e0415 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx @@ -34,7 +34,7 @@ void ContourExtractData::SetZtoBeAnalys( int z ) } //------------------------------------------------------------------------ - void ContourExtractData::SetLstManualContourModel( std::vector lstManConMod) + void ContourExtractData::SetLstManualContourModel( std::vector lstManConMod) { this->lstManConMod = lstManConMod; } @@ -43,12 +43,12 @@ void ContourExtractData::SetZtoBeAnalys( int z ) //------------------------------------------------------------------------ void ContourExtractData::GetMinMaxPoint(int *minPoint, int *maxPoint, - manualContourModel *manualcontourmodel + manualBaseModel *manualcontourmodel ) { int i; //int np = manualcontourmodel->GetSizeLstPoints( ); // number of control points // JPRx - + // JSTG 26-02-08 --------------------------------------------------------------------------------------- //int nps = manualviewbaseecontour->GetNumberOfPointsSpline(); // number of points in the spline int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline @@ -83,6 +83,7 @@ void ContourExtractData::GetMinMaxPoint_Of_LstManConMod( int *minPoint, { int i,size = lstManConMod.size(); + for(i=0 ; iGetTypeModel()==7) + { + if(mbm->IsPoint(x,y)==true) + { + numberLeft=1; + } + }//if + else + { + numberLeft = AnalisisContourInsideV2(x,y, i ); + }//else + if ( (numberLeft % 2) ==1){ numberInside++; } } if ( numberInside == (size) ){ result=true; } } // AND Intersection + numberLeft=0; if (typeOperation==1) // OR All { for (i=0;iGetTypeModel()==7) + { + if(mbm->IsPoint(x,y)==true) + { + numberLeft=1; + } + }//if + else + { + numberLeft = AnalisisContourInsideV2(x,y, i ); + }//else if ( (numberLeft % 2) ==1){ result=true; } } } // OR All + numberLeft=0; + if (typeOperation==2) // XOR crown { for (i=0;iGetTypeModel()==7) + { + if(mbm->IsPoint(x,y)==true) + { + numberLeft=1; + } + }//if + else + { + numberLeft = numberLeft + AnalisisContourInsideV2(x,y, i ); + }//else + } if ( numberLeft % 2 ==1){ result = true; } }// XOR crown @@ -425,7 +470,6 @@ void ContourExtractData::GetValuesInsideCrown(std::vector *pLstValue, } // for } // for - // Borrame // if (this->okImagesResults==true){ // imagedataValueResult->Modified(); @@ -606,7 +650,7 @@ void ContourExtractData::Fill_lstlstlstVecXY(int iContour, int sizeY) { int i,y; double x1,y1,z1,x2,y2,z2; - manualContourModel *manualcontourmodel= lstManConMod[iContour]; + manualBaseModel *manualcontourmodel= lstManConMod[iContour]; int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline manualcontourmodel->UpdateSpline(); //------------------------------------------------------------------------------------------------------ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h index 6196303..b463709 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h @@ -18,7 +18,7 @@ void SetImage( vtkImageData* imagedata); void SetZtoBeAnalys( int z ); - void SetLstManualContourModel( std::vector lstManConMod); + void SetLstManualContourModel( std::vector lstManConMod); void GetValuesInsideCrown( std::vector *pLstValue, std::vector *pLstValuePosX, std::vector *pLstValuePosY, @@ -49,7 +49,15 @@ private: bool okImagesResults; - std::vector lstManConMod; + + // + // List of contours to obtain the respective statistics. + // + std::vector lstManConMod; + + // + // Operation Type (AND,OR,XOR...) + // int _typeOperation; int zImage; @@ -58,9 +66,22 @@ vtkImageData *imagedataMaskResult; bool isInside(int x, int y, int typeOperation ); + + // + // Asigns the minimum and maximum points of the contour model in parameter. + // @param *minPoint - int + // @param *maxPoint - int + // @param *manualcontourmodel - manualBaseModel + // void GetMinMaxPoint(int *minPoint, int *maxPoint, - manualContourModel *manualcontourmodel ); + manualBaseModel *manualcontourmodel ); + // + // Obtain the minimum and maximum point among the contours. The value is saved in the parameter + // pointers + // @param *minPoint - int pointer to the minPoint + // @param *maxPoint - int pointer to the maxPoint + // void GetMinMaxPoint_Of_LstManConMod( int *minPoint, int *maxPoint); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp index 5b61080..0639b0c 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp @@ -237,13 +237,13 @@ bool manualContourBaseControler::OnRightButtonUp() return true; } // ---------------------------------------------------------------------------- -void manualContourBaseControler::SetModelView(manualContourModel *manContModel, manualViewBaseContour *manViewBaseCont){ +void manualContourBaseControler::SetModelView(manualBaseModel *manContModel, manualViewBaseContour *manViewBaseCont){ _manContModel = manContModel; _manViewBaseCont = manViewBaseCont; _manViewBaseCont->SetEditable( &_editable ); } // ---------------------------------------------------------------------------- -manualContourModel* manualContourBaseControler::GetManualContourModel() +manualBaseModel* manualContourBaseControler::GetManualContourModel() { return _manContModel; } @@ -289,10 +289,13 @@ void manualContourBaseControler::MouseDLeft(int x, int y ) { if (_state==0) { + int z=GetZ(); - GetManualViewBaseContour()->SelectPosibleContour(x,y,z); - GetManualViewBaseContour()->SelectPosiblePoint(x,y,z); - if ( GetManualViewBaseContour()->GetPosibleSelected() ) + bool temp = _manViewBaseCont->SelectPosibleContour(x,y,z); + + _manViewBaseCont->SelectPosiblePoint(x,y,z); + + if ( _manViewBaseCont->GetPosibleSelected() ) { _editable = true; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h index 1a04dff..2c5f893 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h @@ -72,8 +72,8 @@ public: virtual bool OnRightButtonDown(); virtual bool OnRightButtonUp(); - void SetModelView(manualContourModel *manContModel, manualViewBaseContour *manViewBaseCont); - manualContourModel * GetManualContourModel(); + void SetModelView(manualBaseModel *manContModel, manualViewBaseContour *manViewBaseCont); + manualBaseModel * GetManualContourModel(); manualViewBaseContour * GetManualViewBaseContour(); @@ -87,7 +87,7 @@ public: void SetState(int state); int GetState(); bool IsEditable(); - void SetEditable( bool condition ); + virtual void SetEditable( bool condition ); bool GetPosibleToMove(); void SetPosibleToMove( bool condition ); bool IsMoving(); @@ -109,6 +109,10 @@ public: void SetZ(int z); virtual int GetZ(); + // VIRTUAL - Adds a point in an specified position + // @param x - int + // @param y - int + // @param z - int virtual void AddPoint(int x, int y, int z); virtual void InsertPoint(int x, int y, int z); @@ -127,9 +131,13 @@ public: // virtual manualContourBaseControler * Clone( manualViewBaseContour * cloneView = NULL, manualContourModel * cloneModel = NULL ); -private: +protected: + + // Reference to the contour or element view manualViewBaseContour *_manViewBaseCont; - manualContourModel *_manContModel; + + // Reference to the model contour or element model + manualBaseModel *_manContModel; int _z; int _state; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp index d16b9c7..33665fb 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp @@ -43,7 +43,6 @@ void manualContourControler::Configure() //virtual // ---------------------------------------------------------------------------- void manualContourControler::MouseClickLeft(int x, int y){ - bool ok = false; int z = GetZ(); int size= GetManualViewBaseContour()->GetNumberOfPoints(); @@ -145,6 +144,7 @@ void manualContourControler::MouseDLeft( int x, int y)//virtual manualContourBaseControler::MouseDLeft( x, y); if ( IsEditable() ) { + GetManualViewBaseContour()->AddControlPoints(); GetManualViewBaseContour()->AddTextActor(); GetManualViewBaseContour()->Refresh(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp index 3a4353a..72999cf 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp @@ -31,6 +31,12 @@ manualContourModel::manualContourModel() _delta_JSTG = 0.0; //--------------------------------------------------------------------------------------------------------------- + +//CMRU 17-08-09 ------------------------------------------------------------------------------------------------- + _realSize = 0.0; + _label = ""; +//--------------------------------------------------------------------------------------------------------------- + } // ---------------------------------------------------------------------------- @@ -645,7 +651,35 @@ void manualContourModel::Save(FILE *ff) // virtual fprintf(ff,"%f %f %f\n", mp->GetX(), mp->GetY(), mp->GetZ() ); } } +//CMRU 03-09-09----------------------------------------------------------------------------------------------- +void manualContourModel::SaveData(FILE *ff) +{ + std::string etiqueta = GetLabel(); + if(etiqueta.empty()) + fprintf(ff,"Label: NO_LABEL\n"); + else + fprintf(ff,"Label: %s\n",etiqueta.c_str()); + fprintf(ff,"Real_Size: %f\n",GetRealSize()); +} + +void manualContourModel::OpenData(FILE *ff) +{ + char tmp[255]; + + fscanf(ff,"%s",tmp); // Label: + fscanf(ff,"%s",tmp); // value + std::cout< manualContourModel::ExploseModel( ) +std::vector manualContourModel::ExploseModel( ) { - std::vector lstTmp; + std::vector lstTmp; lstTmp.push_back(this); return lstTmp; } @@ -695,3 +729,26 @@ void manualContourModel::Transform_Ax_Plus_B (double Ax, double Bx, double Ay, d mp->SetPointY( mp->GetY()*Ay + By ); } } + + +//CMRU 17-08-09---------------------------------------------------------------------------- +void manualContourModel::SetLabel(std::string newLabel) +{ + _label = newLabel; +} + +void manualContourModel::SetRealSize(double newRealSize) +{ + _realSize = newRealSize; +} + +double manualContourModel::GetRealSize() +{ + return _realSize; +} + +std::string manualContourModel::GetLabel() +{ + return _label; +} +//---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.h index 4cb8cb9..a4cccb9 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.h @@ -30,6 +30,7 @@ #include "wxVtkBaseView.h" #include "marTypes.h" #include "manualPoint.h" +#include "manualBaseModel.h" // ---------------------------------------------------------------------------- @@ -37,7 +38,7 @@ // ---------------------------------------------------------------------------- -class creaMaracasVisu_EXPORT manualContourModel +class creaMaracasVisu_EXPORT manualContourModel : public manualBaseModel { public: manualContourModel(); @@ -45,30 +46,30 @@ public: virtual manualContourModel * Clone(); void CopyAttributesTo( manualContourModel *cloneObject ); - virtual void Open(FILE *ff); // virtual + void Open(FILE *ff); // virtual virtual void Save(FILE *ff); // virtual virtual int GetTypeModel(); // virtual - int AddPoint(double x,double y,double z); - int InsertPoint(double x,double y,double z); + virtual int AddPoint(double x,double y,double z); + virtual int InsertPoint(double x,double y,double z); //JSTG 25-04-08 ------------------------------------------------------- - void InsertPoint_id(int id, double x,double y,double z); + virtual void InsertPoint_id(int id, double x,double y,double z); //--------------------------------------------------------------------- - void AddManualPoint( manualPoint* theManualPoint ); - void Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By); + virtual void AddManualPoint( manualPoint* theManualPoint ); + virtual void Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By); - void DeletePoint(int i); - void DeleteAllPoints(); + virtual void DeletePoint(int i); + virtual void DeleteAllPoints(); - void MovePoint(int i,double dx,double dy,double dz); - void MoveLstPoints(double dx,double dy,double dz); - void MoveAllPoints(double dx,double dy,double dz); + virtual void MovePoint(int i,double dx,double dy,double dz); + virtual void MoveLstPoints(double dx,double dy,double dz); + virtual void MoveAllPoints(double dx,double dy,double dz); - int GetIdPoint(double x, double y, double z, int i_range,int type); - manualPoint* GetManualPoint(int id); - int GetSizeLstPoints(); + virtual int GetIdPoint(double x, double y, double z, int i_range,int type); + virtual manualPoint* GetManualPoint(int id); + virtual int GetSizeLstPoints(); int GetNumberOfPointsSpline(); - void SetNumberOfPointsSpline(int size); + virtual void SetNumberOfPointsSpline(int size); virtual void UpdateSpline(); void SetCloseContour(bool closeContour); @@ -77,8 +78,8 @@ public: //void GetSplinePoint(double t, double &x, double &y, double &z); //Method Original //void GetSplineiPoint(int i, double &x, double &y, double &z); //Method Original //------------------------------------------------------------------------------- - double GetPathSize(); - double GetPathArea(); + virtual double GetPathSize(); + virtual double GetPathArea(); void GetNearestPointAndNormal(double *p, double *rp, double *rn); @@ -87,11 +88,48 @@ public: void GetSpline_t_Point(double t, double *x, double *y, double *z); //-------------------------------------------------------------------------------- - virtual std::vector ExploseModel( ); + virtual std::vector ExploseModel( ); + +// CMRU 17-08-09 ----------------------------------------------------------------- + + /* + * Assigns the parameter value to the label + * @param newLabel New label of the contour + */ + void SetLabel(std::string newLabel); + + /* + * Assigns the parameter value to the real size + * @param newRealSize New real size in milimeters of the contour + */ + void SetRealSize(double newRealSize); + + /** + * Returns the label of the contour + */ + std::string GetLabel(); + + /** + * Returns the real size in milimeters of the contour + */ + double GetRealSize(); + + /* + * Saves the label and the real size of the contour + * @param ff File where the information is stored + */ + void SaveData(FILE *ff); + + /* + * Reads and interprets the information of the label and the real size + * @param ff File where the information is readed + */ + void OpenData(FILE *ff); +//-------------------------------------------------------------------------------- private: - int _sizePointsContour; - std::vector _lstPoints; + //int _sizePointsContour; + //std::vector _lstPoints; bool _closeContour; vtkKochanekSpline *_cntSplineX; vtkKochanekSpline *_cntSplineY; @@ -101,6 +139,18 @@ private: double _delta_JSTG; //------------------------------------------------------ +//CMRU 17-08-09 ----------------------------------------------------------------- + /** + * Represents the real size in milimeters of the contour + */ + double _realSize; + + /** + * Represents the label associated with the contour + */ + std::string _label; +//-------------------------------------------------------------------------------- + }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelBullEye.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelBullEye.cpp index 491e3d4..5e35180 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelBullEye.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelBullEye.cpp @@ -154,10 +154,10 @@ void manualContourModelBullEye::Open(FILE *ff) // virtual } // ---------------------------------------------------------------------------- -std::vector manualContourModelBullEye::ExploseModel( ) +std::vector manualContourModelBullEye::ExploseModel( ) { //EED004 - std::vector lstTmp; + std::vector lstTmp; int i,iSize=_lstModelBullEyeSector.size(); for (i=0;i ExploseModel( ); + virtual std::vector ExploseModel( ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp index e7e0bea..bc2cfd2 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp @@ -60,6 +60,7 @@ int manualViewBaseContour::GetType() // virtual //int manualViewCircle::GetType() 3; //int manualViewStar::GetType() 4; //int manualViewLine::GetType() 6; +//int manualViewPoints::GetType() 7; return 0; @@ -230,33 +231,33 @@ double manualViewBaseContour::GetWidthLine() // ---------------------------------------------------------------------------- void manualViewBaseContour::ConstructVTKObjects() { + + //JSTG 29-02-08 ----------------------------------------------- //int i , nps = _sizePointsContour; int i; int nps = _manContModel->GetNumberOfPointsSpline(); //------------------------------------------------------------- + DeleteVtkObjects(); _pts = vtkPoints::New(); _pts->SetNumberOfPoints(nps); - for (i=0 ; iSetPoint(i, 0 , 0 , 0 ); } // This is for the boundaring inicialisation //EED 29Mars2009 - _pts->SetPoint(0, 0 , 0 , -1000 ); - _pts->SetPoint(1, 0 , 0 , 1000 ); -// _pts->SetPoint(0, -1000 , -1000 , -1000 ); -// _pts->SetPoint(1, 1000 , 1000 , 1000 ); - + //_pts->SetPoint(0, 0 , 0 , -1000 ); + //_pts->SetPoint(1, 0 , 0 , 1000 ); + _pts->SetPoint(0, -1000 , -1000 , -1000 ); + _pts->SetPoint(1, 1000 , 1000 , 1000 ); vtkCellArray *lines = vtkCellArray::New(); lines->InsertNextCell( nps /* +1 */ ); for ( i=0 ; iInsertCellPoint(i % nps ); } - _pd = vtkPolyData::New(); _pd->SetPoints( _pts ); _pd->SetLines( lines ); @@ -266,15 +267,24 @@ void manualViewBaseContour::ConstructVTKObjects() _bboxMapper = vtkPolyDataMapper::New(); _bboxMapper->ScalarVisibilityOff( ); + _bboxMapper->SetInput(_pd); _bboxMapper->ImmediateModeRenderingOn(); _contourVtkActor->SetMapper(_bboxMapper); _contourVtkActor->GetProperty()->BackfaceCullingOff(); + UpdateColorActor(); _pd->ComputeBounds(); + InitTextActor(); + + +} + +void manualViewBaseContour::InitTextActor() +{ // Text _textActor = vtkTextActor::New(); // _textActor->SetDisplayPosition(200, 200); @@ -290,6 +300,7 @@ void manualViewBaseContour::ConstructVTKObjects() tprop->SetFontFamilyToArial(); tprop->SetColor(0, 0, 1); } + // ---------------------------------------------------------------------------- void manualViewBaseContour::CreateNewContour() { @@ -495,11 +506,11 @@ bool manualViewBaseContour::SelectPosibleContour(int x, int y, int z) bool result=false; SetPosibleSelected(result); int id = GetIdPoint(x,y,z); - + if( !GetEditable() && !_selected && id!= -1) { result=true; - SetPosibleSelected(result); + _posibleSelected=true; } else { @@ -521,7 +532,6 @@ bool manualViewBaseContour::SelectPosibleContour(int x, int y, int z) } } - } return result; } @@ -548,7 +558,7 @@ void manualViewBaseContour::UnSelectAllPoints(){ Refresh(); } // ---------------------------------------------------------------------------- -void manualViewBaseContour::SetModel(manualContourModel *manContModel){ +void manualViewBaseContour::SetModel(manualBaseModel *manContModel){ _manContModel=manContModel; } // ---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h index 65a8b82..815a9db 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h @@ -50,6 +50,11 @@ class creaMaracasVisu_EXPORT manualViewBaseContour{ + +//--------------------------------------------------- +// PUBLIC METHODS & ATTS +//--------------------------------------------------- + public: manualViewBaseContour(); virtual ~manualViewBaseContour(); @@ -59,7 +64,7 @@ public: virtual void Open(FILE *pFile); void AddPoint(); - void AddPoint( manualViewPoint * manualViewPoint ); + virtual void AddPoint( manualViewPoint * manualViewPoint ); void InsertPoint(int id); void DeleteContour(); void DeletePoint(int x, int y,int z); @@ -95,7 +100,7 @@ public: void UnSelectLstPoints(); void UnSelectAllPoints(); - void SetModel(manualContourModel *manContModel); + void SetModel(manualBaseModel *manContModel); void SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview); virtual void Refresh(); @@ -145,10 +150,11 @@ public: void RemoveCompleteContourActor(); virtual void AddSplineActor(); virtual void RemoveSplineActor(); - void AddControlPoints(); - void RemoveControlPoints(); + virtual void AddControlPoints(); + virtual void RemoveControlPoints(); void AddTextActor(); void RemoveTextActor(); + void InitTextActor(); virtual manualViewBaseContour * Clone(); void CopyAttributesTo( manualViewBaseContour *cloneObject ); @@ -158,20 +164,27 @@ public: virtual void ConstructVTKObjects(); -private: - double _range; - - wxVtkBaseView *_wxvtkbaseview; - bool _selected; - bool *_editable; - bool _posibleSelected; - bool _viewControlPoints; +//--------------------------------------------------- +// PRIVATE METHODS & ATTS +//--------------------------------------------------- +private: vtkPolyData *_pd; vtkActor *_contourVtkActor; vtkPolyDataMapper *_bboxMapper; + void DeleteVtkObjects(); + + +//--------------------------------------------------- +// PROTECTED METHODS & ATTS +//--------------------------------------------------- + +protected: + + double _range; + double _coulorEdit_r; double _coulorEdit_g; double _coulorEdit_b; @@ -183,24 +196,46 @@ private: double _coulorSelection_b; double _widthline; - void DeleteVtkObjects(); - virtual void RefreshText(); - + // + // Reference to VTKBaseView + // + wxVtkBaseView *_wxvtkbaseview; -protected: + // + // Is the contour selected + // + bool _selected; + bool *_editable; + bool _posibleSelected; + bool _viewControlPoints; // text bool _show_text; int _id_viewPoint_for_text; vtkTextActor *_textActor; - manualContourModel *_manContModel; + + // + // Contour model + // + manualBaseModel *_manContModel; + vtkPoints *_pts; // JSTG 25-02-08 -------------------------------------------- int _sizePointsContour; //----------------------------------------------------------- + + // + // Control points list + // std::vector _lstViewPoints; + + // + // Spacing + // double _spc[3]; + virtual void RefreshText(); + }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp index 4fcd722..7859143 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp @@ -109,11 +109,22 @@ void manualViewContour::RefreshText() // virtual char text[50]; char resultText[50]; strcpy(resultText," "); + +//CMRU 19-08-09 ---------------------------------- + std::string label; + label = _manContModel->GetLabel(); +// ------------------------------------ + if (size==2) { strcpy(resultText,"L= "); gcvt ( _mesureScale * this->_manContModel->GetPathSize() , 5, text ); strcat(resultText,text); + +//CMRU 19-08-09 ---------------------------------- + strcat(resultText," "); + strcat(resultText,label.c_str()); +//------------------------------------------------ } if (size>2) { @@ -130,6 +141,9 @@ void manualViewContour::RefreshText() // virtual gcvt ( _mesureScale * this->_manContModel->GetPathSize() , 5, text ); strcat(resultText,text); } +//CMRU 19-08-09 ---------------------------------- + strcat(resultText,label.c_str()); +//------------------------------------------------ } _textActor->SetInput(resultText); @@ -161,7 +175,6 @@ void manualViewContour::RefreshText() // virtual // ---------------------------------------------------------------------------- bool manualViewContour::ifTouchContour(int x,int y,int z){ - bool result=false; double xx=x; double yy=y; @@ -195,19 +208,12 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){ d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz)); d3= sqrt( (ppB[0]-ppA[0])*(ppB[0]-ppA[0]) + (ppB[1]-ppA[1])*(ppB[1]-ppA[1]) + (ppB[2]-ppA[2])*(ppB[2]-ppA[2])); + if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) - { - result=true; - i=nps; - } - - //EED 25 Sep 2009 - if ((d1<=1) || (d2<=1)) { result=true; i=nps; } - } return result; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp index 61067b7..bcac67f 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp @@ -1,13 +1,6 @@ #include "manualViewPoint.h" - -// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- - -//int manualViewPoint::range=1; - - manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){ _selected = false; _posibleSelected = false; @@ -19,8 +12,16 @@ manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){ _spc[0] = 1; _spc[1] = 1; _spc[2] = 1; - _widthline = 1; + + //Colors + _colorNormal_r = 1.0; + _colorNormal_g = 0.0; + _colorNormal_b = 0.0; + + _colorPosibleSelected_r = 1.0; + _colorPosibleSelected_g = 1.0; + _colorPosibleSelected_b = 0.0; } // ---------------------------------------------------------------------------- @@ -28,6 +29,27 @@ manualViewPoint::~manualViewPoint(){ DeleteVtkObjects(); } + +// ---------------------------------------------------------------------------- +manualViewPoint * manualViewPoint :: Clone() +{ + manualViewPoint * clone = new manualViewPoint(_wxvtkbaseview); + CopyAttributesTo(clone); + return clone; +} + +// --------------------------------------------------------------------------- + +void manualViewPoint::CopyAttributesTo( manualViewPoint * cloneObject) +{ + // Fathers object + cloneObject->SetPosibleSelected(_posibleSelected); + cloneObject->SetSelected(_selected); + cloneObject->SetSpacing(_spc); + cloneObject->SetWidthLine(_widthline); +} + + // ---------------------------------------------------------------------------- void manualViewPoint::SetWidthLine( double width) { @@ -118,6 +140,8 @@ vtkActor* manualViewPoint::CreateVtkPointActor() return _pointVtkActor; } + + // ---------------------------------------------------------------------------- vtkActor* manualViewPoint::GetVtkActor(){ return _pointVtkActor; @@ -125,9 +149,6 @@ vtkActor* manualViewPoint::GetVtkActor(){ // ---------------------------------------------------------------------------- void manualViewPoint::SetPositionXY(double x, double y,double i_range,double posZ) { -// double range=0.2; // i_range; -// double range=(double)manualViewPoint::range; - double range=i_range; //EED 27 sep 2006 @@ -154,12 +175,22 @@ void manualViewPoint::UpdateColorActor() if (_pointVtkActor!=NULL){ //EED03 _pointVtkActor->GetProperty()->SetLineWidth( _widthline ); - _pointVtkActor->GetProperty()->SetDiffuseColor(1,0,0); + _pointVtkActor->GetProperty()->SetDiffuseColor(_colorNormal_r,_colorNormal_g,_colorNormal_b); if (_posibleSelected==true){ - _pointVtkActor->GetProperty()->SetDiffuseColor(1,1,0); + _pointVtkActor->GetProperty()->SetDiffuseColor(_colorPosibleSelected_r,_colorPosibleSelected_g,_colorPosibleSelected_b); } } } + +// ---------------------------------------------------------------------------- +void manualViewPoint::UpdateColorActor(double nR, double nG, double nB) +{ + _colorNormal_r = nR; + _colorNormal_g = nG; + _colorNormal_b = nB; + UpdateColorActor(); +} + // ---------------------------------------------------------------------------- void manualViewPoint::GetSpacing(double spc[3]) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h index b8f3f4e..6739be1 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h @@ -14,8 +14,6 @@ #include #include - - #include #include #include @@ -23,9 +21,6 @@ #include "wxVTKRenderWindowInteractor.h" - -//-- - #include #include "wxVtkBaseView.h" #include "marTypes.h" @@ -35,35 +30,99 @@ class manualViewPoint{ public: -// static int range; - manualViewPoint(wxVtkBaseView *wxvtkbaseview); ~manualViewPoint(); + + virtual manualViewPoint * Clone(); + void CopyAttributesTo( manualViewPoint *cloneObject ); void SetSelected(bool selected); void SetPosibleSelected(bool posibleSelected); bool GetSelected(); bool GetPosibleSelected(); void DeleteVtkObjects(); vtkActor* CreateVtkPointActor(); + + // + // Sets the x,y,z position to the actual point. Establishes a range of the points respect + // to the final coordinate. + // @param x - double + // @param y - double + // @param z - double + // @param range - double + // void SetPositionXY(double x, double y, double range, double posZ); + + // + // Get ViewPoint VtkActor + // @return vtkActor* + // vtkActor* GetVtkActor(); + + // + // Updates the color and width of the actual point if the VTK Actor has been created + // void UpdateColorActor(); + + // + // Updates the point normal color of the actual point. + // + void UpdateColorActor(double nR, double nG, double nB); + void GetSpacing(double spc[3]); void SetSpacing(double spc[3]); void SetWidthLine( double width); private: + + // + // Is point selected + // bool _selected; bool _posibleSelected; + vtkPoints *_pts; + + // + // Point VTK PolyData object + // vtkPolyData *_pd; + + // + // Point VTK Actor + // vtkActor *_pointVtkActor; + + // + // Point VTK PolyData mapper + // vtkPolyDataMapper *_bboxMapper; + + // + // Reference to VtkBaseView + // wxVtkBaseView *_wxvtkbaseview; + + // + // Line Width (def=1) + // double _widthline; protected: - double _spc[3]; + + // + // Point spacing (def=1) + // + double _spc[3]; + + // Point normal color + double _colorNormal_r; + double _colorNormal_g; + double _colorNormal_b; + + // Posible selected point color + double _colorPosibleSelected_r; + double _colorPosibleSelected_g; + double _colorPosibleSelected_b; }; #endif // manualViewPoint_h -- 2.46.0