VTK
vtkLineRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLineRepresentation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
40 #ifndef __vtkLineRepresentation_h
41 #define __vtkLineRepresentation_h
42 
44 
45 class vtkActor;
46 class vtkPolyDataMapper;
47 class vtkLineSource;
48 class vtkSphereSource;
49 class vtkProperty;
50 class vtkPolyData;
53 class vtkBox;
54 class vtkFollower;
55 class vtkVectorText;
56 class vtkPolyDataMapper;
57 class vtkCellPicker;
58 
60 {
61 public:
63  static vtkLineRepresentation *New();
64 
66 
68  void PrintSelf(ostream& os, vtkIndent indent);
70 
72 
75  void GetPoint1WorldPosition(double pos[3]);
76  double* GetPoint1WorldPosition();
77  void GetPoint1DisplayPosition(double pos[3]);
78  double* GetPoint1DisplayPosition();
79  void SetPoint1WorldPosition(double pos[3]);
80  void SetPoint1DisplayPosition(double pos[3]);
81  void GetPoint2DisplayPosition(double pos[3]);
82  double* GetPoint2DisplayPosition();
83  void GetPoint2WorldPosition(double pos[3]);
84  double* GetPoint2WorldPosition();
85  void SetPoint2WorldPosition(double pos[3]);
86  void SetPoint2DisplayPosition(double pos[3]);
88 
90 
98  void SetHandleRepresentation(vtkPointHandleRepresentation3D *handle);
99  void InstantiateHandleRepresentation();
101 
103 
104  vtkGetObjectMacro(Point1Representation,vtkPointHandleRepresentation3D);
105  vtkGetObjectMacro(Point2Representation,vtkPointHandleRepresentation3D);
106  vtkGetObjectMacro(LineHandleRepresentation,vtkPointHandleRepresentation3D);
108 
110 
112  vtkGetObjectMacro(EndPointProperty,vtkProperty);
113  vtkGetObjectMacro(SelectedEndPointProperty,vtkProperty);
115 
117 
119  vtkGetObjectMacro(EndPoint2Property,vtkProperty);
120  vtkGetObjectMacro(SelectedEndPoint2Property,vtkProperty);
122 
124 
126  vtkGetObjectMacro(LineProperty,vtkProperty);
127  vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
129 
131 
134  vtkSetClampMacro(Tolerance,int,1,100);
135  vtkGetMacro(Tolerance,int);
137 
139 
142  void SetResolution(int res);
143  int GetResolution();
145 
152  void GetPolyData(vtkPolyData *pd);
153 
155 
156  virtual void PlaceWidget(double bounds[6]);
157  virtual void BuildRepresentation();
158  virtual int ComputeInteractionState(int X, int Y, int modify=0);
159  virtual void StartWidgetInteraction(double e[2]);
160  virtual void WidgetInteraction(double e[2]);
161  virtual double *GetBounds();
163 
165 
166  virtual void GetActors(vtkPropCollection *pc);
167  virtual void ReleaseGraphicsResources(vtkWindow*);
168  virtual int RenderOpaqueGeometry(vtkViewport*);
170  virtual int HasTranslucentPolygonalGeometry();
172 
173 //BTX - manage the state of the widget
174  enum {Outside=0,OnP1,OnP2,TranslatingP1,TranslatingP2,OnLine,Scaling};
175 //ETX
176 
178 
185  vtkSetClampMacro(InteractionState,int,Outside,Scaling);
187 
189 
191  virtual void SetRepresentationState(int);
192  vtkGetMacro(RepresentationState, int);
194 
197  virtual unsigned long GetMTime();
198 
200  virtual void SetRenderer(vtkRenderer *ren);
201 
203 
204  vtkSetMacro( DistanceAnnotationVisibility, int );
205  vtkGetMacro( DistanceAnnotationVisibility, int );
206  vtkBooleanMacro( DistanceAnnotationVisibility, int );
208 
210 
213  vtkSetStringMacro(DistanceAnnotationFormat);
214  vtkGetStringMacro(DistanceAnnotationFormat);
216 
218 
219  void SetDistanceAnnotationScale(double x, double y, double z)
220  {
221  double scale[3];
222  scale[0] = x;
223  scale[1] = y;
224  scale[2] = z;
225  this->SetDistanceAnnotationScale(scale);
226  }
227  virtual void SetDistanceAnnotationScale( double scale[3] );
228  virtual double * GetDistanceAnnotationScale();
230 
232  double GetDistance();
233 
234 
237  void SetLineColor(double r, double g, double b);
238 
240  virtual vtkProperty *GetDistanceAnnotationProperty();
241 
243 
244  vtkGetObjectMacro(TextActor, vtkFollower);
246 
247 protected:
250 
251  // The handle and the rep used to close the handles
256 
257  // Manage how the representation appears
259 
260  // the line
264 
265  // glyphs representing hot spots (e.g., handles)
269 
270  // Properties used to control the appearance of selected objects and
271  // the manipulator in general.
278  void CreateDefaultProperties();
279 
280  // Selection tolerance for the handles and the line
282 
283  // Helper members
285  void ClampPosition(double x[3]);
286  void HighlightPoint(int ptId, int highlight);
287  void HighlightLine(int highlight);
288  int InBounds(double x[3]);
289  void SizeHandles();
290 
291  // Ivars used during widget interaction to hold initial positions
292  double StartP1[3];
293  double StartP2[3];
294  double StartLineHandle[3];
295  double Length;
296  double LastEventPosition[3];
297 
298  // Support GetBounds() method
300 
301  // Need to keep track if we have successfully initialized the display position.
302  // The widget tends to do stuff in world coordinates, put if the renderer has
303  // not been assigned, then certain operations do not properly update the display
304  // position.
306 
307  // Format for the label
310 
314  double Distance;
316 
318 
319 private:
320  vtkLineRepresentation(const vtkLineRepresentation&); //Not implemented
321  void operator=(const vtkLineRepresentation&); //Not implemented
322 };
323 
324 #endif