1 #include "manualViewPoint.h"
3 // ----------------------------------------------------------------------------
4 manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){
6 _posibleSelected = false;
11 _wxvtkbaseview = wxvtkbaseview;
22 _colorPosibleSelected_r = 1.0;
23 _colorPosibleSelected_g = 1.0;
24 _colorPosibleSelected_b = 0.0;
27 // ----------------------------------------------------------------------------
28 manualViewPoint::~manualViewPoint(){
33 // ----------------------------------------------------------------------------
34 manualViewPoint * manualViewPoint :: Clone()
36 manualViewPoint * clone = new manualViewPoint(_wxvtkbaseview);
37 CopyAttributesTo(clone);
41 // ---------------------------------------------------------------------------
43 void manualViewPoint::CopyAttributesTo( manualViewPoint * cloneObject)
46 cloneObject->SetPosibleSelected(_posibleSelected);
47 cloneObject->SetSelected(_selected);
48 cloneObject->SetSpacing(_spc);
49 cloneObject->SetWidthLine(_widthline);
53 // ----------------------------------------------------------------------------
54 void manualViewPoint::SetWidthLine( double width)
59 // ----------------------------------------------------------------------------
60 void manualViewPoint::SetSelected(bool selected){
63 // ----------------------------------------------------------------------------
64 void manualViewPoint::SetPosibleSelected(bool posibleSelected){
65 _posibleSelected=posibleSelected;
67 // ----------------------------------------------------------------------------
68 bool manualViewPoint::GetSelected(){
71 // ----------------------------------------------------------------------------
72 bool manualViewPoint::GetPosibleSelected(){
73 return _posibleSelected;
75 // ----------------------------------------------------------------------------
76 void manualViewPoint::DeleteVtkObjects(){
77 if (_pointVtkActor !=NULL) { _pointVtkActor->Delete(); }
78 if (_bboxMapper !=NULL) { _bboxMapper ->Delete(); }
79 if (_pts !=NULL) { _pts ->Delete(); }
80 if (_pd !=NULL) { _pd ->Delete(); }
81 _pointVtkActor = NULL;
89 // ----------------------------------------------------------------------------
90 vtkActor* manualViewPoint::CreateVtkPointActor()
94 _pts = vtkPoints::New();
95 _pts->SetNumberOfPoints(8);
97 _pts->SetPoint(0, -1000 , -1000 , 0 );
98 _pts->SetPoint(1, 1000 , -1000 , 0 );
99 _pts->SetPoint(2, 1000 , 1000 , 0 );
100 _pts->SetPoint(3, -1000 , 1000 , 0 );
101 _pts->SetPoint(4, -1000 , 1000 , 0 );
102 _pts->SetPoint(5, -1000 , 1000 , 0 );
103 _pts->SetPoint(6, -1000 , 1000 , 0 );
104 _pts->SetPoint(7, -1000 , 1000 , 0 );
106 vtkCellArray *lines = vtkCellArray::New();
107 lines->InsertNextCell(17);
108 lines->InsertCellPoint(0);
109 lines->InsertCellPoint(1);
110 lines->InsertCellPoint(2);
111 lines->InsertCellPoint(3);
112 lines->InsertCellPoint(0);
113 lines->InsertCellPoint(4);
114 lines->InsertCellPoint(5);
115 lines->InsertCellPoint(6);
116 lines->InsertCellPoint(7);
117 lines->InsertCellPoint(4);
118 lines->InsertCellPoint(0);
119 lines->InsertCellPoint(3);
120 lines->InsertCellPoint(7);
121 lines->InsertCellPoint(6);
122 lines->InsertCellPoint(2);
123 lines->InsertCellPoint(1);
124 lines->InsertCellPoint(5);
126 _pd = vtkPolyData::New();
127 _pd->SetPoints( _pts );
128 _pd->SetLines( lines );
129 // lines->Delete(); //do not delete lines ??
131 _pointVtkActor = vtkActor::New();
132 _bboxMapper = vtkPolyDataMapper::New();
134 _bboxMapper->SetInput(_pd);
135 // _bboxMapper->ImmediateModeRenderingOn();
136 _pointVtkActor->SetMapper(_bboxMapper);
137 // _pointVtkActor->GetProperty()->BackfaceCullingOn();
139 // _pd->ComputeBounds();
141 return _pointVtkActor;
145 // ----------------------------------------------------------------------------
146 vtkActor* manualViewPoint::GetVtkActor(){
147 return _pointVtkActor;
149 // ----------------------------------------------------------------------------
150 void manualViewPoint::SetPositionXY(double x, double y,double i_range,double posZ)
152 double range=i_range;
157 posZ = posZ * _spc[2];
160 _pts->SetPoint(0, x-range, y+range, posZ-range);
161 _pts->SetPoint(1, x+range, y+range, posZ-range);
162 _pts->SetPoint(2, x+range, y-range, posZ-range);
163 _pts->SetPoint(3, x-range, y-range, posZ-range);
164 _pts->SetPoint(4, x-range, y+range, posZ+range);
165 _pts->SetPoint(5, x+range, y+range, posZ+range);
166 _pts->SetPoint(6, x+range, y-range, posZ+range);
167 _pts->SetPoint(7, x-range, y-range, posZ+range);
172 // ----------------------------------------------------------------------------
173 void manualViewPoint::UpdateColorActor()
175 if (_pointVtkActor!=NULL){
177 _pointVtkActor->GetProperty()->SetLineWidth( _widthline );
178 _pointVtkActor->GetProperty()->SetDiffuseColor(_colorNormal_r,_colorNormal_g,_colorNormal_b);
179 if (_posibleSelected==true){
180 _pointVtkActor->GetProperty()->SetDiffuseColor(_colorPosibleSelected_r,_colorPosibleSelected_g,_colorPosibleSelected_b);
185 // ----------------------------------------------------------------------------
186 void manualViewPoint::UpdateColorActor(double nR, double nG, double nB)
194 // ----------------------------------------------------------------------------
195 void manualViewPoint::GetSpacing(double spc[3])
201 // ----------------------------------------------------------------------------
202 void manualViewPoint::SetSpacing(double spc[3])