manualViewPoint.cpp

Go to the documentation of this file.
00001 #include "manualViewPoint.h"
00002 
00003 
00004 // ---------------------------------------------------------------------------
00005 // ----------------------------------------------------------------------------
00006 // ----------------------------------------------------------------------------
00007 
00008 //int manualViewPoint::range=1;
00009 
00010 
00011 manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){
00012         _selected                = false;
00013         _posibleSelected = false;
00014         _pts                     = NULL;
00015         _pd                              = NULL;
00016         _pointVtkActor   = NULL;
00017         _bboxMapper              = NULL;
00018         _wxvtkbaseview   = wxvtkbaseview;
00019         _spc[0]                  = 1;
00020         _spc[1]                  = 1;
00021         _spc[2]                  = 1;
00022 
00023         _widthline               = 1;
00024 
00025 }
00026 // ----------------------------------------------------------------------------
00027 manualViewPoint::~manualViewPoint(){
00028         DeleteVtkObjects();
00029 }
00030 
00031 // ----------------------------------------------------------------------------
00032 void manualViewPoint::SetWidthLine( double width)
00033 {
00034         _widthline = width;
00035 }
00036 
00037 // ----------------------------------------------------------------------------
00038 void manualViewPoint::SetSelected(bool selected){
00039         _selected=selected;
00040 }
00041 // ----------------------------------------------------------------------------
00042 void manualViewPoint::SetPosibleSelected(bool posibleSelected){
00043         _posibleSelected=posibleSelected;
00044 }
00045 // ----------------------------------------------------------------------------
00046 bool manualViewPoint::GetSelected(){
00047         return _selected;
00048 }
00049 // ----------------------------------------------------------------------------
00050 bool manualViewPoint::GetPosibleSelected(){
00051         return _posibleSelected;
00052 }
00053 // ----------------------------------------------------------------------------
00054 void manualViewPoint::DeleteVtkObjects(){
00055         if (_pointVtkActor      !=NULL)         { _pointVtkActor->Delete(); }
00056         if (_bboxMapper         !=NULL)         { _bboxMapper   ->Delete();     }
00057         if (_pts                        !=NULL)         { _pts                  ->Delete();     }
00058         if (_pd                         !=NULL)         { _pd                   ->Delete();     }
00059         _pointVtkActor  =       NULL;
00060         _bboxMapper             =       NULL;
00061         _pts                    =       NULL;
00062         _pd                             =       NULL;
00063 }
00064 
00065 
00066 
00067 // ----------------------------------------------------------------------------
00068 vtkActor* manualViewPoint::CreateVtkPointActor()
00069 {
00070         DeleteVtkObjects();
00071 
00072         _pts = vtkPoints::New();
00073         _pts->SetNumberOfPoints(8);
00074 
00075         _pts->SetPoint(0, -1000 , -1000 , 0 );
00076         _pts->SetPoint(1,  1000 , -1000 , 0 );
00077         _pts->SetPoint(2,  1000 ,  1000 , 0 );
00078         _pts->SetPoint(3, -1000 ,  1000 , 0 );
00079         _pts->SetPoint(4, -1000 ,  1000 , 0 );
00080         _pts->SetPoint(5, -1000 ,  1000 , 0 );
00081         _pts->SetPoint(6, -1000 ,  1000 , 0 );
00082         _pts->SetPoint(7, -1000 ,  1000 , 0 );
00083         
00084         vtkCellArray *lines = vtkCellArray::New();
00085         lines->InsertNextCell(17);
00086         lines->InsertCellPoint(0);
00087         lines->InsertCellPoint(1);
00088         lines->InsertCellPoint(2);
00089         lines->InsertCellPoint(3);
00090         lines->InsertCellPoint(0);
00091         lines->InsertCellPoint(4);
00092         lines->InsertCellPoint(5);
00093         lines->InsertCellPoint(6);
00094         lines->InsertCellPoint(7);
00095         lines->InsertCellPoint(4);
00096         lines->InsertCellPoint(0);
00097         lines->InsertCellPoint(3);
00098         lines->InsertCellPoint(7);
00099         lines->InsertCellPoint(6);
00100         lines->InsertCellPoint(2);
00101         lines->InsertCellPoint(1);
00102         lines->InsertCellPoint(5);
00103 
00104         _pd = vtkPolyData::New();
00105         _pd->SetPoints( _pts );
00106         _pd->SetLines( lines );
00107 //      lines->Delete();  //do not delete lines ??
00108 
00109         _pointVtkActor  =       vtkActor::New();
00110     _bboxMapper         =       vtkPolyDataMapper::New();
00111 
00112         _bboxMapper->SetInput(_pd);
00113 //      _bboxMapper->ImmediateModeRenderingOn();
00114         _pointVtkActor->SetMapper(_bboxMapper);
00115 //      _pointVtkActor->GetProperty()->BackfaceCullingOn();
00116         UpdateColorActor();
00117 //      _pd->ComputeBounds();
00118 
00119         return _pointVtkActor;
00120 }
00121 // ----------------------------------------------------------------------------
00122 vtkActor* manualViewPoint::GetVtkActor(){
00123         return _pointVtkActor;
00124 }
00125 // ----------------------------------------------------------------------------
00126 void manualViewPoint::SetPositionXY(double x, double y,double i_range,double posZ)
00127 {
00128 //      double range=0.2; // i_range;
00129 //      double range=(double)manualViewPoint::range;
00130 
00131         double range=i_range;
00132 
00133 //EED 27 sep 2006
00134         x        = x * _spc[0];
00135         y        = y * _spc[1];
00136         posZ = posZ * _spc[2];
00137 
00138         if (_pts!=NULL){
00139                 _pts->SetPoint(0, x-range, y+range, posZ-range);
00140                 _pts->SetPoint(1, x+range, y+range, posZ-range);
00141                 _pts->SetPoint(2, x+range, y-range, posZ-range);
00142                 _pts->SetPoint(3, x-range, y-range, posZ-range);
00143                 _pts->SetPoint(4, x-range, y+range, posZ+range);
00144                 _pts->SetPoint(5, x+range, y+range, posZ+range);
00145                 _pts->SetPoint(6, x+range, y-range, posZ+range);
00146                 _pts->SetPoint(7, x-range, y-range, posZ+range);
00147         }
00148 }
00149 
00150 
00151 // ----------------------------------------------------------------------------
00152 void manualViewPoint::UpdateColorActor()
00153 {
00154         if (_pointVtkActor!=NULL){
00155 //EED03
00156                 _pointVtkActor->GetProperty()->SetLineWidth( _widthline );
00157                 _pointVtkActor->GetProperty()->SetDiffuseColor(1,0,0);
00158                 if (_posibleSelected==true){
00159                         _pointVtkActor->GetProperty()->SetDiffuseColor(1,1,0);
00160                 }
00161         }
00162 }
00163 // ----------------------------------------------------------------------------
00164 void manualViewPoint::GetSpacing(double spc[3])
00165 {
00166         spc[0] = _spc[0];
00167         spc[1] = _spc[1];
00168         spc[2] = _spc[2];
00169 }
00170 // ----------------------------------------------------------------------------
00171 void manualViewPoint::SetSpacing(double spc[3])
00172 {
00173         _spc[0] = spc[0];
00174         _spc[1] = spc[1];
00175         _spc[2] = spc[2];
00176 }
00177 

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