manualViewBaseContour.cpp

Go to the documentation of this file.
00001 #include "manualViewBaseContour.h"
00002 
00003 
00004 // ----------------------------------------------------------------------------
00005 // ----------------------------------------------------------------------------
00006 // ----------------------------------------------------------------------------
00007 
00008 manualViewBaseContour::manualViewBaseContour()
00009 {
00010         _show_text                      = true;
00011         _textActor                      = NULL;
00012         _manContModel           = NULL;
00013         _wxvtkbaseview          = NULL;
00014         _selected                       = false;
00015         _posibleSelected        = false;
00016         _viewControlPoints      = false;
00017         _pts                            = NULL;
00018         _pd                                     = NULL;
00019         _contourVtkActor        = NULL;
00020         _bboxMapper                     = NULL;
00021         _range                          = 1;
00022         _sizePointsContour      = 100;
00023         _spc[0]                         = 1;
00024         _spc[1]                         = 1;
00025         _spc[2]                         = 1;
00026 
00027         _coulorEdit_r           = 1;
00028         _coulorEdit_g           = 1;
00029         _coulorEdit_b           = 0;
00030 
00031         _coulorNormal_r         = 1;
00032         _coulorNormal_g         = 0;
00033         _coulorNormal_b         = 1;
00034 
00035         _coulorSelection_r      = 0;
00036         _coulorSelection_g      = 1;
00037         _coulorSelection_b      = 0;
00038 
00039         _widthline                      = 1;
00040 
00041 }
00042 // ----------------------------------------------------------------------------
00043 manualViewBaseContour::~manualViewBaseContour()
00044 {
00045         int i,size=_lstViewPoints.size();
00046         for (i=0;i<size; i++){
00047                 delete _lstViewPoints[i];
00048         }
00049         _lstViewPoints.clear();
00050 }
00051 // ----------------------------------------------------------------------------
00052 
00053 
00054 int manualViewBaseContour::GetType() // virtual
00055 {
00056 // Information...
00057 //int manualViewBaseContour::GetType()          0;
00058 //int manualViewContour::GetType()                      1;
00059 //int manualViewRoi::GetType()                          2;
00060 //int manualViewCircle::GetType()                       3;
00061 //int manualViewStar::GetType()                         4;
00062 //int manualViewLine::GetType()                         6;
00063 
00064 
00065         return 0;
00066 }
00067 // ----------------------------------------------------------------------------
00068 
00069 void manualViewBaseContour::Save(FILE *pFile)
00070 {
00071         fprintf(pFile,"TypeView %d\n", GetType() );
00072 }
00073 
00074 // ----------------------------------------------------------------------------
00075 void manualViewBaseContour::Open(FILE *pFile)
00076 {
00077 }
00078 
00079 // ----------------------------------------------------------------------------
00080 void manualViewBaseContour :: AddCompleteContourActor(  bool ifControlPoints )
00081 {
00082         _viewControlPoints = ifControlPoints;
00083          /*vtkRenderer * theRenderer = */  _wxvtkbaseview->GetRenderer();  // JPRx ??
00084          //Adding the spline
00085          AddSplineActor();
00086 
00087          AddTextActor();
00088          //Adding each control point
00089          if( ifControlPoints )
00090                 AddControlPoints();
00091          RefreshContour();
00092          Refresh();
00093 }
00094 // ---------------------------------------------------------------------------
00095 
00096 void manualViewBaseContour :: RemoveCompleteContourActor()
00097 {
00098         /*vtkRenderer * theRenderer =*/  _wxvtkbaseview->GetRenderer(); // JPRx ??
00099          //Removing the spline
00100         RemoveSplineActor();
00101         RemoveTextActor();
00102 
00103         //Removing each point
00104         RemoveControlPoints();
00105         RefreshContour();
00106         Refresh();
00107 }
00108 // ---------------------------------------------------------------------------
00109 manualViewBaseContour *  manualViewBaseContour :: Clone( )//virtual
00110 {
00111         manualViewBaseContour * clone = new manualViewBaseContour();
00112         CopyAttributesTo(clone);
00113         return clone;
00114 
00115 }
00116 
00117 // ---------------------------------------------------------------------------
00118 
00119 void manualViewBaseContour::CopyAttributesTo( manualViewBaseContour * cloneObject)
00120 {
00121         // Fathers object
00122         //XXXX::CopyAttributesTo(cloneObject);
00123 
00124         cloneObject-> SetWxVtkBaseView( this->_wxvtkbaseview );
00125         cloneObject-> SetSelected( this->GetSelected() );
00126         cloneObject-> SetPosibleSelected( this->GetPosibleSelected() );
00127         cloneObject-> SetIfViewControlPoints( this->GetIfViewControlPoints() );
00128         cloneObject-> SetRange( this->GetRange() );
00129         cloneObject-> SetZ( this->GetZ() );
00130         cloneObject-> SetSpacing( _spc );
00131         cloneObject-> SetColorNormalContour( _coulorNormal_r, _coulorNormal_g, _coulorNormal_b );
00132         cloneObject-> SetColorEditContour( _coulorEdit_r, _coulorEdit_g, _coulorEdit_b );
00133         cloneObject-> SetColorSelectContour( _coulorSelection_r, _coulorSelection_g, _coulorSelection_b );
00134 
00135         int i, size = _lstViewPoints.size();
00136         for ( i=0; i<size; i++ )
00137         {
00138                 cloneObject->AddPoint(  );
00139         }
00140 }
00141 
00142 // ----------------------------------------------------------------------------
00143 void manualViewBaseContour :: AddSplineActor()
00144 {
00145         vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
00146         if (_contourVtkActor!=NULL)
00147                 theRenderer->AddActor( _contourVtkActor  );
00148 }
00149 // ----------------------------------------------------------------------------
00150 void manualViewBaseContour :: RemoveSplineActor() // virtual
00151 {
00152         vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
00153         if (_contourVtkActor!=NULL)
00154                 theRenderer->RemoveActor( _contourVtkActor );
00155 }
00156 // ----------------------------------------------------------------------------
00157 void manualViewBaseContour :: RemoveControlPoints()
00158 {
00159         if (_wxvtkbaseview!=NULL){
00160                 vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
00161                 int i,size=_lstViewPoints.size();
00162                 for (i=0;i<size; i++)
00163                 {
00164                         vtkActor * pointActor = _lstViewPoints[i]->GetVtkActor();
00165                         theRenderer->RemoveActor( pointActor );
00166                 } // for
00167         } // if
00168         SetIfViewControlPoints( false );
00169 }
00170 // ----------------------------------------------------------------------------
00171 void manualViewBaseContour::AddControlPoints()
00172 {
00173         vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
00174         SetIfViewControlPoints( true );
00175          if( _viewControlPoints )
00176          {
00177                 int i,size=_lstViewPoints.size();
00178                 for (i=0;i<size; i++)
00179                 {
00180                         vtkActor * pointActor = _lstViewPoints[i]->GetVtkActor();
00181                         theRenderer->AddActor( pointActor );
00182                 }
00183          }
00184 }
00185 // ----------------------------------------------------------------------------
00186 void manualViewBaseContour::AddTextActor()
00187 {
00188         _wxvtkbaseview->GetRenderer()->AddActor2D( _textActor );
00189 }
00190 // ----------------------------------------------------------------------------
00191 void manualViewBaseContour::RemoveTextActor()
00192 {
00193         _wxvtkbaseview->GetRenderer()->RemoveActor2D( _textActor );
00194 }
00195 // ----------------------------------------------------------------------------
00196 void manualViewBaseContour::DeleteVtkObjects()
00197 {
00198         if ( _contourVtkActor   != NULL )       { _contourVtkActor  -> Delete(); }
00199         if ( _bboxMapper                != NULL )       { _bboxMapper           -> Delete(); }
00200         if ( _pts                               != NULL )       { _pts                          -> Delete(); }
00201         if ( _pd                                != NULL )       { _pd                           -> Delete(); }
00202         _contourVtkActor        = NULL;
00203         _bboxMapper                     = NULL;
00204         _pts                            = NULL;
00205         _pd                                     = NULL;
00206 }
00207 
00208 
00209 // ----------------------------------------------------------------------------
00210 void manualViewBaseContour::SetWidthLine(double width)
00211 {
00212         _widthline = width;
00213         this->UpdateColorActor();
00214 
00215         // for the control points
00216         int id, size = _lstViewPoints.size();
00217         for( id=0; id<size; id++)
00218         {
00219                 this->_lstViewPoints[id]->SetWidthLine(_widthline);
00220         }
00221 
00222 }
00223 
00224 // ----------------------------------------------------------------------------
00225 double manualViewBaseContour::GetWidthLine()
00226 {
00227         return _widthline;
00228 }
00229 
00230 // ----------------------------------------------------------------------------
00231 void manualViewBaseContour::ConstructVTKObjects()
00232 {
00233 //JSTG 29-02-08 -----------------------------------------------
00234         //int i , nps = _sizePointsContour;
00235         int i;
00236         int nps = _manContModel->GetNumberOfPointsSpline();
00237 //-------------------------------------------------------------
00238         DeleteVtkObjects();
00239         _pts = vtkPoints::New();
00240         _pts->SetNumberOfPoints(nps);
00241 
00242         for (i=0 ; i<nps ; i++){
00243                 _pts->SetPoint(i,       0       , 0     , 0 );
00244         }
00245         // This is for the boundaring inicialisation
00246 
00247 //EED 29Mars2009        
00248         _pts->SetPoint(0,       0       , 0     , -1000 );
00249         _pts->SetPoint(1,       0       , 0     ,  1000 );
00250 //      _pts->SetPoint(0,       -1000   , -1000 , -1000 );
00251 //      _pts->SetPoint(1,       1000    , 1000  , 1000  );
00252 
00253 
00254         vtkCellArray *lines = vtkCellArray::New();
00255         lines->InsertNextCell( nps /* +1 */ );
00256         for ( i=0 ; i<nps+1 ; i++ ){
00257                 lines->InsertCellPoint(i % nps );
00258         }
00259 
00260         _pd = vtkPolyData::New();
00261         _pd->SetPoints( _pts );
00262         _pd->SetLines( lines );
00263         lines->Delete();  //do not delete lines ??
00264 
00265         _contourVtkActor        =       vtkActor::New();
00266     _bboxMapper                 =       vtkPolyDataMapper::New();
00267     _bboxMapper->ScalarVisibilityOff( );
00268 
00269         _bboxMapper->SetInput(_pd);
00270         _bboxMapper->ImmediateModeRenderingOn();
00271         _contourVtkActor->SetMapper(_bboxMapper);
00272         _contourVtkActor->GetProperty()->BackfaceCullingOff();
00273 
00274         UpdateColorActor();
00275 
00276         _pd->ComputeBounds();
00277 
00278         //      Text
00279         _textActor = vtkTextActor::New();
00280 //      _textActor->SetDisplayPosition(200, 200);
00281         _textActor->SetInput("00");
00282         // Set coordinates to match the old vtkScaledTextActor default value
00283 //      _textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
00284 //      _textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 );
00285         _textActor->GetPositionCoordinate()->SetCoordinateSystemToWorld ();
00286 //      _textActor->GetPositionCoordinate()->SetValue( 0.8 , 0.8 );
00287 
00288         vtkTextProperty *tprop = _textActor->GetTextProperty();
00289         tprop->SetFontSize(14);
00290         tprop->SetFontFamilyToArial();
00291         tprop->SetColor(0, 0, 1);
00292 }
00293 // ----------------------------------------------------------------------------
00294 void manualViewBaseContour::CreateNewContour()
00295 {
00296         ConstructVTKObjects();
00297         /*
00298         _wxvtkbaseview->GetRenderer()->AddActor( _contourVtkActor );
00299         _wxvtkbaseview->GetRenderer()->AddActor2D(_textActor);*/
00300         AddCompleteContourActor();
00301 }
00302 // ----------------------------------------------------------------------------
00303 void manualViewBaseContour::UpdateViewPoint(int id) // virtual
00304 {
00305         manualPoint             *mp             = _manContModel->GetManualPoint(id);
00306 
00307 //EEDx6
00308                         double XX=mp->GetX(),YY=mp->GetY(),ZZ=mp->GetZ();
00309 //                      wxVtk2DBaseView *wxvtk2Dbasevie = (wxVtk2DBaseView*)this->GetWxVtkBaseView();
00310 //                      wxvtk2Dbasevie->TransformCoordinate_spacing_ModelToView(XX,YY,ZZ);
00311 
00312         _lstViewPoints[id]->SetPositionXY( XX , YY ,_range, ZZ );
00313 }
00314 
00315 // ----------------------------------------------------------------------------
00316 void manualViewBaseContour::UpdateViewPoints()
00317 {
00318         int id, size = _lstViewPoints.size();
00319         for( id=0; id<size; id++)
00320         {
00321                 UpdateViewPoint( id );
00322         }
00323 }
00324 
00325 // ----------------------------------------------------------------------------
00326 void manualViewBaseContour::AddPoint()
00327 {
00328         manualViewPoint *mvp    = new manualViewPoint( this->GetWxVtkBaseView() );
00329         AddPoint( mvp );
00330 }
00331 // ----------------------------------------------------------------------------
00332 void manualViewBaseContour::AddPoint( manualViewPoint * manualViewPoint )
00333 {
00334         _lstViewPoints.push_back( manualViewPoint );
00335 
00336         // EED 3 oct 2006
00337         manualViewPoint->SetSpacing(_spc);
00338 
00339         vtkActor *actor = manualViewPoint->CreateVtkPointActor();
00340         _wxvtkbaseview->GetRenderer()->AddActor( actor );       
00341 }
00342 
00343 // ----------------------------------------------------------------------------
00344 void manualViewBaseContour::InsertPoint(int id)
00345 {
00346         manualViewPoint         *mvp    = new manualViewPoint( this->GetWxVtkBaseView() );
00347 
00348 // EED 3 oct 2006
00349         mvp->SetSpacing(_spc);
00350 
00351         std::vector<manualViewPoint*>::iterator itNum = _lstViewPoints.begin() + id;
00352         _lstViewPoints.insert(itNum,mvp);
00353         _wxvtkbaseview->GetRenderer()->AddActor( mvp->CreateVtkPointActor() );
00354 }
00355 // ----------------------------------------------------------------------------
00356 void manualViewBaseContour::DeleteContour()
00357 {
00358         RemoveCompleteContourActor();
00359         /*if (_contourVtkActor!=NULL){
00360                 _wxvtkbaseview->GetRenderer()->RemoveActor( _contourVtkActor );
00361         }*/
00362         DeleteVtkObjects();
00363         int i,size=_lstViewPoints.size();
00364         for (i=0;i<size;i++){
00365                 manualViewBaseContour::DeletePoint(0);
00366         }
00367         Refresh();
00368 }
00369 // ----------------------------------------------------------------------------
00370 void manualViewBaseContour::DeletePoint(int id) // virtual
00371 {
00372         int size=_lstViewPoints.size();
00373         if ( (id>=0) && (id<size) ){
00374                 manualViewPoint         *mvp    =_lstViewPoints[id];
00375 //EED ups1
00376 //              _handlePicker->DeletePickList(mvp->GetVtkActor());
00377                 _wxvtkbaseview->GetRenderer()->RemoveActor( mvp->GetVtkActor() );
00378                 std::vector<manualViewPoint*>::iterator itNum = _lstViewPoints.begin() + id;
00379                 _lstViewPoints.erase(itNum);
00380                 delete mvp;
00381                 Refresh();
00382         }
00383 }
00384 // ----------------------------------------------------------------------------
00385 void manualViewBaseContour::DeletePoint(int x, int y, int z)
00386 {
00387         int id=GetIdPoint(x,y,z);
00388         if (id!=-1){
00389                 DeletePoint(id);
00390         }
00391 }
00392 // ----------------------------------------------------------------------------
00393 void manualViewBaseContour::SetSelected(bool selected)
00394 {
00395         _selected=selected;
00396 }
00397 // ----------------------------------------------------------------------------
00398 void manualViewBaseContour::SetPosibleSelected(bool posibleSelected)
00399 {
00400         _posibleSelected=posibleSelected;
00401 }
00402 // ----------------------------------------------------------------------------
00403 bool manualViewBaseContour::GetEditable()
00404 {
00405         return *_editable;
00406 }
00407 // ----------------------------------------------------------------------------
00408 void manualViewBaseContour::SetEditable( bool * condition )
00409 {
00410         _editable = condition;
00411 }
00412 // ----------------------------------------------------------------------------
00413 bool manualViewBaseContour::GetSelected()
00414 {
00415         return _selected;
00416 }
00417 // ----------------------------------------------------------------------------
00418 bool manualViewBaseContour::GetPosibleSelected()
00419 {
00420         return _posibleSelected;
00421 }
00422 // ----------------------------------------------------------------------------
00423 void manualViewBaseContour::DeleteSelectedPoints()
00424 {
00425         int i,size=_lstViewPoints.size();
00426         for (i=size-1;i>=0;i--){
00427                 if (_lstViewPoints[i]->GetSelected()==true){
00428                         DeletePoint(i);
00429                 }
00430         }
00431         Refresh();
00432 }
00433 // ----------------------------------------------------------------------------
00434 void manualViewBaseContour::SelectPoint(int i, bool select)
00435 {
00436         _lstViewPoints[i]->SetSelected(select);
00437 }
00438 // ----------------------------------------------------------------------------
00439 void manualViewBaseContour::SelectLstPoints()
00440 {
00441         // ToDo
00442 }
00443 // ----------------------------------------------------------------------------
00444 void manualViewBaseContour::SelectAllPoints(bool select)
00445 {
00446         int i,size=_lstViewPoints.size();
00447         for (i=0;i<size;i++){
00448                 SelectPoint(i,select);
00449         }
00450 }
00451 //-----------------------------------------------------------------------------
00452 void manualViewBaseContour:: SetIfViewControlPoints(bool ifShow)
00453 {
00454         _viewControlPoints = ifShow;
00455 }
00456 // ----------------------------------------------------------------------------
00457 bool manualViewBaseContour:: GetIfViewControlPoints()
00458 {
00459         return _viewControlPoints;
00460 }
00461 
00462 // ----------------------------------------------------------------------------
00463 void manualViewBaseContour::SetPointPosibleSelected(int id,bool select)
00464 {
00465         _lstViewPoints[id]->SetPosibleSelected(select);
00466 }
00467 // ----------------------------------------------------------------------------
00468 void manualViewBaseContour::SetPointSelected(int id,bool select)
00469 {
00470         _lstViewPoints[id]->SetSelected(select);
00471 }
00472 // ----------------------------------------------------------------------------
00473 void manualViewBaseContour::SelectAllPossibleSelected(bool select)
00474 {
00475         int i,size=_lstViewPoints.size();
00476         for (i=0;i<size;i++){
00477                 SetPointPosibleSelected(i,select);
00478         }
00479 }
00480 // ----------------------------------------------------------------------------
00481 int manualViewBaseContour::SelectPosiblePoint(int x, int y, int z)  // virtual
00482 {
00483         SelectAllPossibleSelected(false);
00484 
00485     int id = GetIdPoint(x,y,z);
00486         if (id!=-1)
00487         {
00488                 SetPointPosibleSelected(id,true);
00489         }
00490         return id;
00491 }
00492 // ----------------------------------------------------------------------------
00493 bool manualViewBaseContour::SelectPosibleContour(int x, int y, int z)
00494 {
00495         bool result=false;
00496         SetPosibleSelected(result);
00497     int id = GetIdPoint(x,y,z);
00498         if( !GetEditable() && !_selected && id!= -1)
00499         {
00500                 result=true;
00501                 SetPosibleSelected(result);
00502         }
00503         else
00504         {
00505                 if ( (GetEditable()==true) && (id==-1 ) && (this->_lstViewPoints.size()>=2) )
00506                 {
00507                         if (ifTouchContour(x,y,z)==true)
00508                         {
00509                                 result=true;
00510                                 SetPosibleSelected(result);
00511                         }
00512                 }
00513 
00514                 if (GetEditable()==false)
00515                 {
00516                         if (ifTouchContour(x,y,z)==true)
00517                         {
00518                                 result=true;
00519                                 SetPosibleSelected(result);
00520                         }
00521                 }
00522 
00523 
00524         }
00525         return result;
00526 }
00527 // ----------------------------------------------------------------------------
00528 bool manualViewBaseContour::ifTouchContour(int x,int y, int z) // virtual
00529 {
00530         return false;
00531 }
00532 // ----------------------------------------------------------------------------
00533 void manualViewBaseContour::UnSelectPoint(int i){
00534         _lstViewPoints[i]->SetSelected(false);
00535         Refresh();
00536 }
00537 // ----------------------------------------------------------------------------
00538 void manualViewBaseContour::UnSelectLstPoints(){
00539         // ToDo
00540 }
00541 // ----------------------------------------------------------------------------
00542 void manualViewBaseContour::UnSelectAllPoints(){
00543         int i,size=_lstViewPoints.size();
00544         for (i=0;i<size;i++){
00545                 UnSelectPoint(i);
00546         }
00547         Refresh();
00548 }
00549 // ----------------------------------------------------------------------------
00550 void manualViewBaseContour::SetModel(manualContourModel *manContModel){
00551         _manContModel=manContModel;
00552 }
00553 // ----------------------------------------------------------------------------
00554 void manualViewBaseContour::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview){
00555         _wxvtkbaseview = wxvtkbaseview;
00556 }
00557 // ----------------------------------------------------------------------------
00558 void manualViewBaseContour::RefreshContour()  // Virtual
00559 {
00560 }
00561 // ----------------------------------------------------------------------------
00562 double* manualViewBaseContour::GetVectorPointsXManualContour(){
00563         double pp[3];
00564         int i,size = _sizePointsContour;
00565         double *vx = (double*)malloc(sizeof(double)*size);
00566         for (i=0;i<size;i++){
00567                 _pts->GetPoint(i,pp);
00568                 vx[i]=pp[0];
00569         }
00570         return vx;
00571 }
00572 // ----------------------------------------------------------------------------
00573 double* manualViewBaseContour::GetVectorPointsYManualContour()
00574 {
00575         double pp[3];
00576         int i,size = _sizePointsContour;
00577         double *vy = (double*)malloc(sizeof(double)*size);
00578         for (i=0;i<size;i++){
00579                 _pts->GetPoint(i,pp);
00580                 vy[i]=pp[1];
00581         }
00582         return vy;
00583 }
00584 // ----------------------------------------------------------------------------
00585 double* manualViewBaseContour::GetVectorPointsZManualContour()
00586 {
00587         double pp[3];
00588         int i,size = _sizePointsContour;
00589         double *vz = (double*)malloc(sizeof(double)*size);
00590         for (i=0;i<size;i++){
00591                 _pts->GetPoint(i,pp);
00592                 vz[i]=pp[2];
00593         }
00594         return vz;
00595 }
00596 // ----------------------------------------------------------------------------
00597 void manualViewBaseContour::Refresh() // virtual
00598 {
00599         if (_contourVtkActor!=NULL){
00600                 RefreshContour();
00601         }
00602         int i,size=_lstViewPoints.size();
00603         for (i=0;i<size;i++){
00604                 UpdateViewPoint(i);
00605                 _lstViewPoints[i]->UpdateColorActor();
00606         }
00607         UpdateColorActor();
00608 
00609         if (_show_text==true)
00610         {
00611                 RefreshText();
00612         }
00613 
00614         vtkRenderWindowInteractor *vri = _wxvtkbaseview->GetWxVTKRenderWindowInteractor ();
00615         if (vri==NULL)
00616         {
00617                 _wxvtkbaseview->GetRenWin()->Render();
00618                 printf("EED %p How to optimize manualViewBaseContour::Refresh() \n",this);
00619         }
00620 
00621 }
00622 // ----------------------------------------------------------------------------
00623 void manualViewBaseContour::RefreshText()  // virtual
00624 {
00625         if( _textActor!=NULL)
00626                 _textActor -> SetInput("00");
00627 }
00628 // ----------------------------------------------------------------------------
00629 void manualViewBaseContour::SetColorNormalContour(double r, double g, double b)
00630 {
00631         _coulorNormal_r = r;
00632         _coulorNormal_g = g;
00633         _coulorNormal_b = b;
00634 }
00635 // ----------------------------------------------------------------------------
00636 void manualViewBaseContour::GetColorNormalContour(double &r, double &g, double &b)
00637 {
00638         r = _coulorNormal_r;
00639         g = _coulorNormal_g;
00640         b = _coulorNormal_b;
00641 }
00642 // ----------------------------------------------------------------------------
00643 void manualViewBaseContour::SetColorEditContour(double r, double g, double b)
00644 {
00645         _coulorEdit_r = r;
00646         _coulorEdit_g = g;
00647         _coulorEdit_b = b;
00648 }
00649 // ----------------------------------------------------------------------------
00650 void manualViewBaseContour::GetColorEditContour(double &r, double &g, double &b)
00651 {
00652         r = _coulorEdit_r;
00653         g = _coulorEdit_g;
00654         b = _coulorEdit_b;
00655 }
00656 // ----------------------------------------------------------------------------
00657 void manualViewBaseContour::SetColorSelectContour(double r, double g, double b)
00658 {
00659         _coulorSelection_r = r;
00660         _coulorSelection_g = g;
00661         _coulorSelection_b = b;
00662 }
00663 // ----------------------------------------------------------------------------
00664 void manualViewBaseContour::GetColorSelectContour(double &r, double &g, double &b)
00665 {
00666         r = _coulorSelection_r;
00667         g = _coulorSelection_g;
00668         b = _coulorSelection_b;
00669 }
00670 // ----------------------------------------------------------------------------
00671 void manualViewBaseContour::UpdateColorActor()
00672 {
00673         if (_contourVtkActor!=NULL)
00674         {
00675                 _contourVtkActor->GetProperty()->SetLineWidth( _widthline );
00676                 _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
00677                 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
00678                 {
00679                         _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
00680                 }
00681                 if( _selected )
00682                 {
00683                         _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
00684                 }
00685         }
00686 }
00687 // ----------------------------------------------------------------------------
00688 int     manualViewBaseContour::GetIdPoint(int x, int y, int z) // virtual
00689 {
00690         int ii = -1;
00691         if (_manContModel!=NULL){
00692                 double xx = x;
00693                 double yy = y;
00694                 double zz = z;
00695                 TransfromCoordViewWorld(xx,yy,zz);
00696                 ii=_manContModel->GetIdPoint(xx,yy,zz,_range,-1);
00697         }
00698         return ii;
00699 }
00700 
00701 // ----------------------------------------------------------------------------
00702 
00703 
00704 int manualViewBaseContour::GetNumberOfPoints()
00705 {
00706         return _lstViewPoints.size();
00707 }
00708 
00709 // ----------------------------------------------------------------------------
00710 
00711 //JSTG 25-02-08 ---------------------------------------------------------------
00712 /*int manualViewBaseContour::GetNumberOfPointsSpline()
00713 {
00714         return _sizePointsContour;
00715 }*/
00716 //----------------------------------------------------------------------------
00717 
00718 //JSTG 25-02-08 ---------------------------------------------------------------
00719 /*void manualViewBaseContour::SetNumberOfPointsSpline(int size)
00720 {
00721         _sizePointsContour = size;
00722 }*/
00723 //----------------------------------------------------------------------------
00724 // virtual
00725 void manualViewBaseContour::TransfromCoordViewWorld(double &X, double &Y, double &Z, int type)  // Virtual
00726 {
00727         _wxvtkbaseview->TransFromCoordScreenToWorld(X, Y, Z,false, type);
00728 
00729 
00730 //EED 27 sep 2007
00731 //   //EEDx6
00732 //      wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*)_wxvtkbaseview;
00733 //      wxvtk2Dbaseview->TransformCoordinate_spacing_ModelToView(X,Y,Z);
00734 
00735 }
00736 // ----------------------------------------------------------------------------
00737 void manualViewBaseContour::SetRange(double range)
00738 {
00739         _range=range;
00740 }
00741 // ----------------------------------------------------------------------------
00742 double  manualViewBaseContour::GetRange()
00743 {
00744         return _range;
00745 }
00746 // ----------------------------------------------------------------------------
00747 void manualViewBaseContour::SetZ(int z)
00748 {
00749 //      _Z=z;
00750 }
00751 // ----------------------------------------------------------------------------
00752 int     manualViewBaseContour::GetZ()
00753 {
00754 //      return _Z;
00755         return 0;
00756 }
00757 // ----------------------------------------------------------------------------
00758 void manualViewBaseContour::InitMove(int x, int y, int z) // virtual
00759 {
00760 
00761 }
00762 // ----------------------------------------------------------------------------
00763 void manualViewBaseContour::MoveContour(int x, int y, int z) // virtual
00764 {
00765 }
00766 // ----------------------------------------------------------------------------
00767 void manualViewBaseContour::MoveContour(int horizontalUnits, int verticalUnits )// virtual
00768 {
00769 
00770 }
00771 // ----------------------------------------------------------------------------
00772 void manualViewBaseContour::GetMinMax( double &minX,double &minY, double &minZ, double &maxX, double &maxY, double &maxZ )// virtual
00773 {
00774         double  pp[3];
00775         manualPoint *mp;
00776         int i;
00777         int size=_manContModel->GetSizeLstPoints();
00778         minX=99999;
00779         minY=99999;
00780         maxX=-99999;
00781         maxY=-99999;
00782         bool ifFindZ = minZ!=-1.0 && maxZ!=-1.0;
00783         if ( ifFindZ )
00784         {
00785                 minZ=99999;
00786                 maxZ=-99999;
00787         }
00788         for( i = 0; i < size; i++ )
00789         {
00790                 mp=_manContModel->GetManualPoint(i);
00791                 pp[0]=mp->GetX();
00792                 pp[1]=mp->GetY();
00793                 if ( ifFindZ )
00794                         pp[2]=mp->GetZ();
00795 
00796                 // min X
00797                 if (pp[0]<minX)
00798                 {
00799                         minX=pp[0];
00800                 }
00801                 //min Y
00802                 if (pp[1]<minY)
00803                 {
00804                         minY=pp[1];
00805                 }
00806                 //max X
00807                 if (pp[0]>maxX)
00808                 {
00809                         maxX=pp[0];
00810                 }
00811                 // max Y
00812                 if (pp[1]>maxY)
00813                 {
00814                         maxY=pp[1];
00815                 }
00816                 if ( ifFindZ )
00817                 {
00818                         // min Z
00819                         if (pp[2]<minZ)
00820                         {
00821                                 minZ=pp[2];
00822                         }
00823                         // max Z
00824                         if (pp[2]>maxZ)
00825                         {
00826                                 maxZ=pp[2];
00827                         }
00828                 }
00829         }
00830         if ( size<1 )
00831         {
00832                 minX = 0;
00833                 maxX = 0;
00834 
00835                 minY = 0;
00836                 maxY = 0;
00837 
00838                 minZ = 0;
00839                 maxZ = 0;
00840         }
00841 }
00842 // ----------------------------------------------------------------------------
00843 void manualViewBaseContour::ClearContour()
00844 {
00845         if (_contourVtkActor!=NULL){
00846                 _wxvtkbaseview->GetRenderer()->RemoveActor( _contourVtkActor );
00847         }
00848         DeleteVtkObjects();
00849         int i,size=_lstViewPoints.size();
00850         for (i=0;i<size;i++){
00851                 ClearPoint(0);
00852         }
00853         Refresh();
00854 }
00855 // ----------------------------------------------------------------------------
00856 void manualViewBaseContour::ClearPoint(int id)
00857 {
00858         DeletePoint(id);
00859 }
00860 // ----------------------------------------------------------------------------
00861 void manualViewBaseContour::SetVisible(bool ok)
00862 {
00863         double opacity;
00864         if (ok==true)
00865         {
00866                 opacity=1;
00867         } else {
00868                 opacity=0.5;
00869         }
00870         vtkActor *actor;
00871         int i,size=_lstViewPoints.size();
00872         for (i=0;i<size;i++){
00873                 actor = _lstViewPoints[i]->GetVtkActor();
00874                 actor->GetProperty()->SetOpacity( opacity );
00875         }
00876         _contourVtkActor->GetProperty()->SetOpacity( opacity );
00877         _textActor->GetProperty()->SetOpacity( opacity );
00878         _textActor->SetInput("00");
00879 
00880 }
00881 // ----------------------------------------------------------------------------
00882 void manualViewBaseContour::SetShowText(bool ok)
00883 {
00884         _show_text = ok;
00885         if (_show_text==false)
00886         {
00887                 _textActor->SetInput("00");
00888         }
00889 }
00890 // ----------------------------------------------------------------------------
00891 wxVtkBaseView *manualViewBaseContour::GetWxVtkBaseView()
00892 {
00893         return this->_wxvtkbaseview;
00894 }
00895 // ----------------------------------------------------------------------------
00896 void manualViewBaseContour::GetSpacing(double spc[3])
00897 {
00898         spc[0] = _spc[0];
00899         spc[1] = _spc[1];
00900         spc[2] = _spc[2];
00901 }
00902 // ----------------------------------------------------------------------------
00903 void manualViewBaseContour::SetSpacing(double spc[3])
00904 {
00905         _spc[0] = spc[0];
00906         _spc[1] = spc[1];
00907         _spc[2] = spc[2];
00908 }

Generated on Wed Jul 29 16:35:28 2009 for creaMaracasVisu_lib by  doxygen 1.5.3