1 #include "manualViewPoint.h"
4 // ---------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6 // ----------------------------------------------------------------------------
8 //int manualViewPoint::range=1;
11 manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){
13 _posibleSelected = false;
16 _pointVtkActor = NULL;
18 _wxvtkbaseview = wxvtkbaseview;
26 // ----------------------------------------------------------------------------
27 manualViewPoint::~manualViewPoint(){
31 // ----------------------------------------------------------------------------
32 void manualViewPoint::SetWidthLine( double width)
37 // ----------------------------------------------------------------------------
38 void manualViewPoint::SetSelected(bool selected){
41 // ----------------------------------------------------------------------------
42 void manualViewPoint::SetPosibleSelected(bool posibleSelected){
43 _posibleSelected=posibleSelected;
45 // ----------------------------------------------------------------------------
46 bool manualViewPoint::GetSelected(){
49 // ----------------------------------------------------------------------------
50 bool manualViewPoint::GetPosibleSelected(){
51 return _posibleSelected;
53 // ----------------------------------------------------------------------------
54 void manualViewPoint::DeleteVtkObjects(){
55 if (_pointVtkActor !=NULL) { _pointVtkActor->Delete(); }
56 if (_bboxMapper !=NULL) { _bboxMapper ->Delete(); }
57 if (_pts !=NULL) { _pts ->Delete(); }
58 if (_pd !=NULL) { _pd ->Delete(); }
59 _pointVtkActor = NULL;
67 // ----------------------------------------------------------------------------
68 vtkActor* manualViewPoint::CreateVtkPointActor()
72 _pts = vtkPoints::New();
73 _pts->SetNumberOfPoints(8);
75 _pts->SetPoint(0, -1000 , -1000 , 0 );
76 _pts->SetPoint(1, 1000 , -1000 , 0 );
77 _pts->SetPoint(2, 1000 , 1000 , 0 );
78 _pts->SetPoint(3, -1000 , 1000 , 0 );
79 _pts->SetPoint(4, -1000 , 1000 , 0 );
80 _pts->SetPoint(5, -1000 , 1000 , 0 );
81 _pts->SetPoint(6, -1000 , 1000 , 0 );
82 _pts->SetPoint(7, -1000 , 1000 , 0 );
84 vtkCellArray *lines = vtkCellArray::New();
85 lines->InsertNextCell(17);
86 lines->InsertCellPoint(0);
87 lines->InsertCellPoint(1);
88 lines->InsertCellPoint(2);
89 lines->InsertCellPoint(3);
90 lines->InsertCellPoint(0);
91 lines->InsertCellPoint(4);
92 lines->InsertCellPoint(5);
93 lines->InsertCellPoint(6);
94 lines->InsertCellPoint(7);
95 lines->InsertCellPoint(4);
96 lines->InsertCellPoint(0);
97 lines->InsertCellPoint(3);
98 lines->InsertCellPoint(7);
99 lines->InsertCellPoint(6);
100 lines->InsertCellPoint(2);
101 lines->InsertCellPoint(1);
102 lines->InsertCellPoint(5);
104 _pd = vtkPolyData::New();
105 _pd->SetPoints( _pts );
106 _pd->SetLines( lines );
107 // lines->Delete(); //do not delete lines ??
109 _pointVtkActor = vtkActor::New();
110 _bboxMapper = vtkPolyDataMapper::New();
112 _bboxMapper->SetInput(_pd);
113 // _bboxMapper->ImmediateModeRenderingOn();
114 _pointVtkActor->SetMapper(_bboxMapper);
115 // _pointVtkActor->GetProperty()->BackfaceCullingOn();
117 // _pd->ComputeBounds();
119 return _pointVtkActor;
121 // ----------------------------------------------------------------------------
122 vtkActor* manualViewPoint::GetVtkActor(){
123 return _pointVtkActor;
125 // ----------------------------------------------------------------------------
126 void manualViewPoint::SetPositionXY(double x, double y,double i_range,double posZ)
128 // double range=0.2; // i_range;
129 // double range=(double)manualViewPoint::range;
131 double range=i_range;
136 posZ = posZ * _spc[2];
139 _pts->SetPoint(0, x-range, y+range, posZ-range);
140 _pts->SetPoint(1, x+range, y+range, posZ-range);
141 _pts->SetPoint(2, x+range, y-range, posZ-range);
142 _pts->SetPoint(3, x-range, y-range, posZ-range);
143 _pts->SetPoint(4, x-range, y+range, posZ+range);
144 _pts->SetPoint(5, x+range, y+range, posZ+range);
145 _pts->SetPoint(6, x+range, y-range, posZ+range);
146 _pts->SetPoint(7, x-range, y-range, posZ+range);
151 // ----------------------------------------------------------------------------
152 void manualViewPoint::UpdateColorActor()
154 if (_pointVtkActor!=NULL){
156 _pointVtkActor->GetProperty()->SetLineWidth( _widthline );
157 _pointVtkActor->GetProperty()->SetDiffuseColor(1,0,0);
158 if (_posibleSelected==true){
159 _pointVtkActor->GetProperty()->SetDiffuseColor(1,1,0);
163 // ----------------------------------------------------------------------------
164 void manualViewPoint::GetSpacing(double spc[3])
170 // ----------------------------------------------------------------------------
171 void manualViewPoint::SetSpacing(double spc[3])