#include "manualViewPoint.h" // --------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- //int manualViewPoint::range=1; manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){ _selected = false; _posibleSelected = false; _pts = NULL; _pd = NULL; _pointVtkActor = NULL; _bboxMapper = NULL; _wxvtkbaseview = wxvtkbaseview; _spc[0] = 1; _spc[1] = 1; _spc[2] = 1; _widthline = 1; } // ---------------------------------------------------------------------------- manualViewPoint::~manualViewPoint(){ DeleteVtkObjects(); } // ---------------------------------------------------------------------------- void manualViewPoint::SetWidthLine( double width) { _widthline = width; } // ---------------------------------------------------------------------------- void manualViewPoint::SetSelected(bool selected){ _selected=selected; } // ---------------------------------------------------------------------------- void manualViewPoint::SetPosibleSelected(bool posibleSelected){ _posibleSelected=posibleSelected; } // ---------------------------------------------------------------------------- bool manualViewPoint::GetSelected(){ return _selected; } // ---------------------------------------------------------------------------- bool manualViewPoint::GetPosibleSelected(){ return _posibleSelected; } // ---------------------------------------------------------------------------- void manualViewPoint::DeleteVtkObjects(){ if (_pointVtkActor !=NULL) { _pointVtkActor->Delete(); } if (_bboxMapper !=NULL) { _bboxMapper ->Delete(); } if (_pts !=NULL) { _pts ->Delete(); } if (_pd !=NULL) { _pd ->Delete(); } _pointVtkActor = NULL; _bboxMapper = NULL; _pts = NULL; _pd = NULL; } // ---------------------------------------------------------------------------- vtkActor* manualViewPoint::CreateVtkPointActor() { DeleteVtkObjects(); _pts = vtkPoints::New(); _pts->SetNumberOfPoints(8); _pts->SetPoint(0, -1000 , -1000 , 0 ); _pts->SetPoint(1, 1000 , -1000 , 0 ); _pts->SetPoint(2, 1000 , 1000 , 0 ); _pts->SetPoint(3, -1000 , 1000 , 0 ); _pts->SetPoint(4, -1000 , 1000 , 0 ); _pts->SetPoint(5, -1000 , 1000 , 0 ); _pts->SetPoint(6, -1000 , 1000 , 0 ); _pts->SetPoint(7, -1000 , 1000 , 0 ); vtkCellArray *lines = vtkCellArray::New(); lines->InsertNextCell(17); lines->InsertCellPoint(0); lines->InsertCellPoint(1); lines->InsertCellPoint(2); lines->InsertCellPoint(3); lines->InsertCellPoint(0); lines->InsertCellPoint(4); lines->InsertCellPoint(5); lines->InsertCellPoint(6); lines->InsertCellPoint(7); lines->InsertCellPoint(4); lines->InsertCellPoint(0); lines->InsertCellPoint(3); lines->InsertCellPoint(7); lines->InsertCellPoint(6); lines->InsertCellPoint(2); lines->InsertCellPoint(1); lines->InsertCellPoint(5); _pd = vtkPolyData::New(); _pd->SetPoints( _pts ); _pd->SetLines( lines ); // lines->Delete(); //do not delete lines ?? _pointVtkActor = vtkActor::New(); _bboxMapper = vtkPolyDataMapper::New(); _bboxMapper->SetInput(_pd); // _bboxMapper->ImmediateModeRenderingOn(); _pointVtkActor->SetMapper(_bboxMapper); // _pointVtkActor->GetProperty()->BackfaceCullingOn(); UpdateColorActor(); // _pd->ComputeBounds(); return _pointVtkActor; } // ---------------------------------------------------------------------------- vtkActor* manualViewPoint::GetVtkActor(){ return _pointVtkActor; } // ---------------------------------------------------------------------------- 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 x = x * _spc[0]; y = y * _spc[1]; posZ = posZ * _spc[2]; if (_pts!=NULL){ _pts->SetPoint(0, x-range, y+range, posZ-range); _pts->SetPoint(1, x+range, y+range, posZ-range); _pts->SetPoint(2, x+range, y-range, posZ-range); _pts->SetPoint(3, x-range, y-range, posZ-range); _pts->SetPoint(4, x-range, y+range, posZ+range); _pts->SetPoint(5, x+range, y+range, posZ+range); _pts->SetPoint(6, x+range, y-range, posZ+range); _pts->SetPoint(7, x-range, y-range, posZ+range); } } // ---------------------------------------------------------------------------- void manualViewPoint::UpdateColorActor() { if (_pointVtkActor!=NULL){ //EED03 _pointVtkActor->GetProperty()->SetLineWidth( _widthline ); _pointVtkActor->GetProperty()->SetDiffuseColor(1,0,0); if (_posibleSelected==true){ _pointVtkActor->GetProperty()->SetDiffuseColor(1,1,0); } } } // ---------------------------------------------------------------------------- void manualViewPoint::GetSpacing(double spc[3]) { spc[0] = _spc[0]; spc[1] = _spc[1]; spc[2] = _spc[2]; } // ---------------------------------------------------------------------------- void manualViewPoint::SetSpacing(double spc[3]) { _spc[0] = spc[0]; _spc[1] = spc[1]; _spc[2] = spc[2]; }