]> Creatis software - creaMaracasVisu.git/commitdiff
Changes with manualBaseModel. It improves the functionality with the new
authorRicardo Corredor <Ricardo.Corredor@creatis.insa-lyon.fr>
Tue, 13 Oct 2009 02:33:11 +0000 (02:33 +0000)
committerRicardo Corredor <Ricardo.Corredor@creatis.insa-lyon.fr>
Tue, 13 Oct 2009 02:33:11 +0000 (02:33 +0000)
 points contour and some saving and loading aspects of the contours

14 files changed:
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx
lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourBaseControler.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelBullEye.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelBullEye.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewPoint.h

index 974b1680c0bd83937490f92ac71dadefcd7dd8bb..10e04156dc251ce1914f30ecb440173da28a4e72 100644 (file)
@@ -34,7 +34,7 @@ void ContourExtractData::SetZtoBeAnalys( int z )
   }
 
 //------------------------------------------------------------------------
-  void ContourExtractData::SetLstManualContourModel( std::vector<manualContourModel*> lstManConMod)
+  void ContourExtractData::SetLstManualContourModel( std::vector<manualBaseModel*> 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 ; i<size ; i++)
        {
                GetMinMaxPoint(minPoint,maxPoint,lstManConMod[i]);
@@ -197,27 +198,71 @@ bool ContourExtractData::isInside(int x, int y, int typeOperation)
                {
                        for (i=0;i<size;i++)
                        {
-                               numberLeft =  AnalisisContourInsideV2(x,y, i );
+                               // To process the statistics of the Points contour the procedure is different
+                               // RaC 19-09-09
+                               manualBaseModel *mbm = lstManConMod[i];
+                               if(mbm->GetTypeModel()==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;i<size;i++)
                        {
-                               numberLeft =  AnalisisContourInsideV2(x,y, i );
+                               // To process the statistics of the Points contour the procedure is different
+                               // RaC 19-09-09
+                               manualBaseModel *mbm = lstManConMod[i];
+                               if(mbm->GetTypeModel()==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;i<size;i++)
                        {
-                               numberLeft = numberLeft + AnalisisContourInsideV2(x,y, i );
+                               // To process the statistics of the Points contour the procedure is different
+                               // RaC 19-09-09
+                               manualBaseModel *mbm = lstManConMod[i];
+                               if(mbm->GetTypeModel()==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<double> *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();
        //------------------------------------------------------------------------------------------------------
index 6196303879cbe1d8471acb1815b76daa103f7971..b463709d2c5cb94ce79d37f1587e5f424a065475 100644 (file)
@@ -18,7 +18,7 @@
        void SetImage( vtkImageData* imagedata);
        void SetZtoBeAnalys( int z );
 
-       void SetLstManualContourModel( std::vector<manualContourModel*> lstManConMod);
+       void SetLstManualContourModel( std::vector<manualBaseModel*> lstManConMod);
        void GetValuesInsideCrown(      std::vector<double> *pLstValue,
                                                                std::vector<double> *pLstValuePosX,
                                                                std::vector<double> *pLstValuePosY,
          
   private:
        bool                                                            okImagesResults;
-       std::vector<manualContourModel*>        lstManConMod;
+
+       //
+       // List of contours to obtain the respective statistics.
+       //
+       std::vector<manualBaseModel*>   lstManConMod;
+
+       //
+       // Operation Type (AND,OR,XOR...)
+       //
        int                                                                     _typeOperation;
 
        int                                                                     zImage;
        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);
 
index 5b610808e24e1b2dec9c3ffdc92bb726488b699a..0639b0c611e012aecb665b68f660aeae0fcafe3a 100644 (file)
@@ -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;
                }
index 1a04dff953397b50065dee064466edd4532c168f..2c5f8935ace4fc7e3a4f9725b8117abef21b1f2a 100644 (file)
@@ -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;
index d16b9c78d5f805fb32407bb0badd118ce27abc53..33665fb521d4844125a77f29b8aa448a3290b5af 100644 (file)
@@ -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();
index 3a4353a63c671e4cd88d6f4f376a557d4cbed75c..72999cfda745fb9fc6dc06e6981b90903bdc4ce8 100644 (file)
@@ -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<<tmp<<std::endl;
+       if(tmp != "NO_LABEL")
+               SetLabel(tmp);
+
+       fscanf(ff,"%s",tmp); // Real_size
+       fscanf(ff,"%s",tmp);// #
+
+       //tmp.ToDouble(&tmp);
+       SetRealSize(atof(tmp));
+}
 
+//------------------------------------------------------------------------------------------------------------
 
 // ---------------------------------------------------------------------------
 
@@ -672,9 +706,9 @@ void manualContourModel::AddManualPoint( manualPoint* theManualPoint )//private
        _lstPoints.push_back( theManualPoint );
 }
 
-std::vector<manualContourModel*> manualContourModel::ExploseModel(  )
+std::vector<manualBaseModel*> manualContourModel::ExploseModel(  )
 {
-       std::vector<manualContourModel*> lstTmp;
+       std::vector<manualBaseModel*> 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;
+}
+//----------------------------------------------------------------------------
index 4cb8cb995f7d48ca960b47ffeb339ed5f370024f..a4cccb9cada1d56008ff1d387f5600d51e3898ab 100644 (file)
@@ -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<manualContourModel*> ExploseModel(  );
+       virtual std::vector<manualBaseModel*> 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<manualPoint*>       _lstPoints;
+       //int                                                   _sizePointsContour;
+       //std::vector<manualPoint*>     _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;
+//--------------------------------------------------------------------------------
+
 }; 
 
 
index 491e3d4fa039b0ee309e3998f63cd4966e386b0c..5e35180288db0ad7e1b796639d4d63cb54238b97 100644 (file)
@@ -154,10 +154,10 @@ void manualContourModelBullEye::Open(FILE *ff) // virtual
 }
 
 // ----------------------------------------------------------------------------
-std::vector<manualContourModel*> manualContourModelBullEye::ExploseModel(  )
+std::vector<manualBaseModel*> manualContourModelBullEye::ExploseModel(  )
 {
 //EED004
-       std::vector<manualContourModel*> lstTmp;
+       std::vector<manualBaseModel*> lstTmp;
        int i,iSize=_lstModelBullEyeSector.size();
        for (i=0;i<iSize;i++)
        {
index 7bb58e13f8b84ae10b5419adf13398550b71cc73..ed00c7711d6ef07bd0dd42a0b571bea725a9c652 100644 (file)
@@ -32,7 +32,7 @@ public:
        void    ResetSectors();
        int             GetSizeOfSectorLst();
        virtual void UpdateSpline(); // virtual
-       virtual std::vector<manualContourModel*> ExploseModel(  );
+       virtual std::vector<manualBaseModel*> ExploseModel(  );
 
 
 
index e7e0bea99c93935d46a54d0ed684d997f52a815d..bc2cfd2ad133d8eb24b1f0032ebc7ec4d27cc761 100644 (file)
@@ -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 ; i<nps ; i++){
                _pts->SetPoint(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 ; i<nps+1 ; i++ ){
                lines->InsertCellPoint(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;
 }
 // ----------------------------------------------------------------------------
index 65a8b825c80b8f9b8dfc4db3bd4ff7fcc2f74c38..815a9db16fd1aee2a2b9a933097255095bb53338 100644 (file)
 
 
 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<manualViewPoint*>   _lstViewPoints;
+
+       //
+       // Spacing
+       //
        double                                                  _spc[3];
 
+       virtual void    RefreshText();
+
 };
 
 
index 4fcd7228798e90ea5acf0a56a9ba7205e52fb63f..7859143d17f4824c2514861c455a13db9c05c81c 100644 (file)
@@ -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;
index 61067b7cabf7457eb165b605e89f278fac579169..bcac67f98503038e7a79ff5a54b5a228bf6b90b2 100644 (file)
@@ -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])
 {
index b8f3f4e424a182cedea063c473e6aee3fc312179..6739be1741ea3d69dd7a9b884fa8945940920fe8 100644 (file)
@@ -14,8 +14,6 @@
 #include <vtkKochanekSpline.h> 
 
 #include <vtkCellPicker.h> 
-
-
 #include <vtkCamera.h> 
 #include <vtkPolyLine.h>
 #include <vtkDataSetMapper.h>
@@ -23,9 +21,6 @@
 
 #include "wxVTKRenderWindowInteractor.h"
 
-
-//--
-
 #include <vector>
 #include "wxVtkBaseView.h"
 #include "marTypes.h"
 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