1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "manualViewPoint.h"
28 // ----------------------------------------------------------------------------
29 manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){
31 _posibleSelected = false;
34 _pointVtkActor = NULL;
36 _wxvtkbaseview = wxvtkbaseview;
47 _colorPosibleSelected_r = 1.0;
48 _colorPosibleSelected_g = 1.0;
49 _colorPosibleSelected_b = 0.0;
52 // ----------------------------------------------------------------------------
53 manualViewPoint::~manualViewPoint(){
58 // ----------------------------------------------------------------------------
59 manualViewPoint * manualViewPoint :: Clone()
61 manualViewPoint * clone = new manualViewPoint(_wxvtkbaseview);
62 CopyAttributesTo(clone);
66 // ---------------------------------------------------------------------------
68 void manualViewPoint::CopyAttributesTo( manualViewPoint * cloneObject)
71 cloneObject->SetPosibleSelected(_posibleSelected);
72 cloneObject->SetSelected(_selected);
73 cloneObject->SetSpacing(_spc);
74 cloneObject->SetWidthLine(_widthline);
78 // ----------------------------------------------------------------------------
79 void manualViewPoint::SetWidthLine( double width)
84 // ----------------------------------------------------------------------------
85 void manualViewPoint::SetSelected(bool selected){
88 // ----------------------------------------------------------------------------
89 void manualViewPoint::SetPosibleSelected(bool posibleSelected){
90 _posibleSelected=posibleSelected;
92 // ----------------------------------------------------------------------------
93 bool manualViewPoint::GetSelected(){
96 // ----------------------------------------------------------------------------
97 bool manualViewPoint::GetPosibleSelected(){
98 return _posibleSelected;
100 // ----------------------------------------------------------------------------
101 void manualViewPoint::DeleteVtkObjects(){
102 if (_pointVtkActor !=NULL) { _pointVtkActor->Delete(); }
103 if (_bboxMapper !=NULL) { _bboxMapper ->Delete(); }
104 if (_pts !=NULL) { _pts ->Delete(); }
105 if (_pd !=NULL) { _pd ->Delete(); }
106 _pointVtkActor = NULL;
114 // ----------------------------------------------------------------------------
115 vtkActor* manualViewPoint::CreateVtkPointActor()
119 _pts = vtkPoints::New();
120 _pts->SetNumberOfPoints(8);
123 // _pts->SetPoint(0, -1000 , -1000 , 0 );
124 // _pts->SetPoint(1, 1000 , -1000 , 0 );
125 // _pts->SetPoint(2, 1000 , 1000 , 0 );
126 // _pts->SetPoint(3, -1000 , 1000 , 0 );
127 // _pts->SetPoint(4, -1000 , 1000 , 0 );
128 // _pts->SetPoint(5, -1000 , 1000 , 0 );
129 // _pts->SetPoint(6, -1000 , 1000 , 0 );
130 // _pts->SetPoint(7, -1000 , 1000 , 0 );
132 vtkCellArray *lines = vtkCellArray::New();
133 lines->InsertNextCell(17);
134 lines->InsertCellPoint(0);
135 lines->InsertCellPoint(1);
136 lines->InsertCellPoint(2);
137 lines->InsertCellPoint(3);
138 lines->InsertCellPoint(0);
139 lines->InsertCellPoint(4);
140 lines->InsertCellPoint(5);
141 lines->InsertCellPoint(6);
142 lines->InsertCellPoint(7);
143 lines->InsertCellPoint(4);
144 lines->InsertCellPoint(0);
145 lines->InsertCellPoint(3);
146 lines->InsertCellPoint(7);
147 lines->InsertCellPoint(6);
148 lines->InsertCellPoint(2);
149 lines->InsertCellPoint(1);
150 lines->InsertCellPoint(5);
152 _pd = vtkPolyData::New();
153 _pd->SetPoints( _pts );
154 _pd->SetLines( lines );
155 // lines->Delete(); //do not delete lines ??
157 _pointVtkActor = vtkActor::New();
158 _bboxMapper = vtkPolyDataMapper::New();
162 //EED 2017-01-01 Migration VTK7
163 #if VTK_MAJOR_VERSION <= 5
164 _bboxMapper->SetInput(_pd);
166 _bboxMapper->SetInputData(_pd);
170 // _bboxMapper->ImmediateModeRenderingOn();
171 _pointVtkActor->SetMapper(_bboxMapper);
172 // _pointVtkActor->GetProperty()->BackfaceCullingOn();
174 // _pd->ComputeBounds();
176 return _pointVtkActor;
180 // ----------------------------------------------------------------------------
181 vtkActor* manualViewPoint::GetVtkActor(){
182 return _pointVtkActor;
184 // ----------------------------------------------------------------------------
185 void manualViewPoint::SetPositionXY(double x, double y,double i_range,double posZ)
187 double range=i_range;
192 posZ = posZ * _spc[2];
195 _pts->SetPoint(0, x-range, y+range, posZ-range);
196 _pts->SetPoint(1, x+range, y+range, posZ-range);
197 _pts->SetPoint(2, x+range, y-range, posZ-range);
198 _pts->SetPoint(3, x-range, y-range, posZ-range);
199 _pts->SetPoint(4, x-range, y+range, posZ+range);
200 _pts->SetPoint(5, x+range, y+range, posZ+range);
201 _pts->SetPoint(6, x+range, y-range, posZ+range);
202 _pts->SetPoint(7, x-range, y-range, posZ+range);
210 // ----------------------------------------------------------------------------
211 void manualViewPoint::UpdateColorActor()
213 if (_pointVtkActor!=NULL){
215 _pointVtkActor->GetProperty()->SetLineWidth( _widthline );
216 _pointVtkActor->GetProperty()->SetDiffuseColor(_colorNormal_r,_colorNormal_g,_colorNormal_b);
217 if (_posibleSelected==true){
218 _pointVtkActor->GetProperty()->SetDiffuseColor(_colorPosibleSelected_r,_colorPosibleSelected_g,_colorPosibleSelected_b);
223 // ----------------------------------------------------------------------------
224 void manualViewPoint::UpdateColorActor(double nR, double nG, double nB)
232 // ----------------------------------------------------------------------------
233 void manualViewPoint::GetSpacing(double spc[3])
239 // ----------------------------------------------------------------------------
240 void manualViewPoint::SetSpacing(double spc[3])