00001 #include "manualViewPoint.h"
00002
00003
00004 manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){
00005 _selected = false;
00006 _posibleSelected = false;
00007 _pts = NULL;
00008 _pd = NULL;
00009 _pointVtkActor = NULL;
00010 _bboxMapper = NULL;
00011 _wxvtkbaseview = wxvtkbaseview;
00012 _spc[0] = 1;
00013 _spc[1] = 1;
00014 _spc[2] = 1;
00015 _widthline = 1;
00016
00017
00018 _colorNormal_r = 1.0;
00019 _colorNormal_g = 0.0;
00020 _colorNormal_b = 0.0;
00021
00022 _colorPosibleSelected_r = 1.0;
00023 _colorPosibleSelected_g = 1.0;
00024 _colorPosibleSelected_b = 0.0;
00025
00026 }
00027
00028 manualViewPoint::~manualViewPoint(){
00029 DeleteVtkObjects();
00030 }
00031
00032
00033
00034 manualViewPoint * manualViewPoint :: Clone()
00035 {
00036 manualViewPoint * clone = new manualViewPoint(_wxvtkbaseview);
00037 CopyAttributesTo(clone);
00038 return clone;
00039 }
00040
00041
00042
00043 void manualViewPoint::CopyAttributesTo( manualViewPoint * cloneObject)
00044 {
00045
00046 cloneObject->SetPosibleSelected(_posibleSelected);
00047 cloneObject->SetSelected(_selected);
00048 cloneObject->SetSpacing(_spc);
00049 cloneObject->SetWidthLine(_widthline);
00050 }
00051
00052
00053
00054 void manualViewPoint::SetWidthLine( double width)
00055 {
00056 _widthline = width;
00057 }
00058
00059
00060 void manualViewPoint::SetSelected(bool selected){
00061 _selected=selected;
00062 }
00063
00064 void manualViewPoint::SetPosibleSelected(bool posibleSelected){
00065 _posibleSelected=posibleSelected;
00066 }
00067
00068 bool manualViewPoint::GetSelected(){
00069 return _selected;
00070 }
00071
00072 bool manualViewPoint::GetPosibleSelected(){
00073 return _posibleSelected;
00074 }
00075
00076 void manualViewPoint::DeleteVtkObjects(){
00077 if (_pointVtkActor !=NULL) { _pointVtkActor->Delete(); }
00078 if (_bboxMapper !=NULL) { _bboxMapper ->Delete(); }
00079 if (_pts !=NULL) { _pts ->Delete(); }
00080 if (_pd !=NULL) { _pd ->Delete(); }
00081 _pointVtkActor = NULL;
00082 _bboxMapper = NULL;
00083 _pts = NULL;
00084 _pd = NULL;
00085 }
00086
00087
00088
00089
00090 vtkActor* manualViewPoint::CreateVtkPointActor()
00091 {
00092 DeleteVtkObjects();
00093
00094 _pts = vtkPoints::New();
00095 _pts->SetNumberOfPoints(8);
00096
00097 _pts->SetPoint(0, -1000 , -1000 , 0 );
00098 _pts->SetPoint(1, 1000 , -1000 , 0 );
00099 _pts->SetPoint(2, 1000 , 1000 , 0 );
00100 _pts->SetPoint(3, -1000 , 1000 , 0 );
00101 _pts->SetPoint(4, -1000 , 1000 , 0 );
00102 _pts->SetPoint(5, -1000 , 1000 , 0 );
00103 _pts->SetPoint(6, -1000 , 1000 , 0 );
00104 _pts->SetPoint(7, -1000 , 1000 , 0 );
00105
00106 vtkCellArray *lines = vtkCellArray::New();
00107 lines->InsertNextCell(17);
00108 lines->InsertCellPoint(0);
00109 lines->InsertCellPoint(1);
00110 lines->InsertCellPoint(2);
00111 lines->InsertCellPoint(3);
00112 lines->InsertCellPoint(0);
00113 lines->InsertCellPoint(4);
00114 lines->InsertCellPoint(5);
00115 lines->InsertCellPoint(6);
00116 lines->InsertCellPoint(7);
00117 lines->InsertCellPoint(4);
00118 lines->InsertCellPoint(0);
00119 lines->InsertCellPoint(3);
00120 lines->InsertCellPoint(7);
00121 lines->InsertCellPoint(6);
00122 lines->InsertCellPoint(2);
00123 lines->InsertCellPoint(1);
00124 lines->InsertCellPoint(5);
00125
00126 _pd = vtkPolyData::New();
00127 _pd->SetPoints( _pts );
00128 _pd->SetLines( lines );
00129
00130
00131 _pointVtkActor = vtkActor::New();
00132 _bboxMapper = vtkPolyDataMapper::New();
00133
00134 _bboxMapper->SetInput(_pd);
00135
00136 _pointVtkActor->SetMapper(_bboxMapper);
00137
00138 UpdateColorActor();
00139
00140
00141 return _pointVtkActor;
00142 }
00143
00144
00145
00146 vtkActor* manualViewPoint::GetVtkActor(){
00147 return _pointVtkActor;
00148 }
00149
00150 void manualViewPoint::SetPositionXY(double x, double y,double i_range,double posZ)
00151 {
00152 double range=i_range;
00153
00154
00155 x = x * _spc[0];
00156 y = y * _spc[1];
00157 posZ = posZ * _spc[2];
00158
00159 if (_pts!=NULL){
00160 _pts->SetPoint(0, x-range, y+range, posZ-range);
00161 _pts->SetPoint(1, x+range, y+range, posZ-range);
00162 _pts->SetPoint(2, x+range, y-range, posZ-range);
00163 _pts->SetPoint(3, x-range, y-range, posZ-range);
00164 _pts->SetPoint(4, x-range, y+range, posZ+range);
00165 _pts->SetPoint(5, x+range, y+range, posZ+range);
00166 _pts->SetPoint(6, x+range, y-range, posZ+range);
00167 _pts->SetPoint(7, x-range, y-range, posZ+range);
00168 }
00169 }
00170
00171
00172
00173 void manualViewPoint::UpdateColorActor()
00174 {
00175 if (_pointVtkActor!=NULL){
00176
00177 _pointVtkActor->GetProperty()->SetLineWidth( _widthline );
00178 _pointVtkActor->GetProperty()->SetDiffuseColor(_colorNormal_r,_colorNormal_g,_colorNormal_b);
00179 if (_posibleSelected==true){
00180 _pointVtkActor->GetProperty()->SetDiffuseColor(_colorPosibleSelected_r,_colorPosibleSelected_g,_colorPosibleSelected_b);
00181 }
00182 }
00183 }
00184
00185
00186 void manualViewPoint::UpdateColorActor(double nR, double nG, double nB)
00187 {
00188 _colorNormal_r = nR;
00189 _colorNormal_g = nG;
00190 _colorNormal_b = nB;
00191 UpdateColorActor();
00192 }
00193
00194
00195 void manualViewPoint::GetSpacing(double spc[3])
00196 {
00197 spc[0] = _spc[0];
00198 spc[1] = _spc[1];
00199 spc[2] = _spc[2];
00200 }
00201
00202 void manualViewPoint::SetSpacing(double spc[3])
00203 {
00204 _spc[0] = spc[0];
00205 _spc[1] = spc[1];
00206 _spc[2] = spc[2];
00207 }
00208