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
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:49
virtual int ComputeInteractionState(int X, int Y, int modify=0)
represent the position of a point in 3D space
abstract specification for Viewports
Definition: vtkViewport.h:45
represent surface properties of a geometric object
Definition: vtkProperty.h:61
virtual void StartWidgetInteraction(double eventPos[2])
vtkPointHandleRepresentation3D * Point2Representation
virtual void SetRenderer(vtkRenderer *ren)
vtkPolyDataMapper ** HandleMapper
void SetDistanceAnnotationScale(double x, double y, double z)
vtkProperty * SelectedEndPoint2Property
vtkProperty * SelectedEndPointProperty
abstract specification for renderers
Definition: vtkRenderer.h:69
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:81
vtkPolyDataMapper * TextMapper
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract class defines interface between the widget and widget representation classes ...
virtual void BuildRepresentation()=0
a list of Props
vtkPointHandleRepresentation3D * Point1Representation
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
vtkPointHandleRepresentation3D * HandleRepresentation
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
virtual int HasTranslucentPolygonalGeometry()
virtual unsigned long GetMTime()
a simple class to control print indentation
Definition: vtkIndent.h:37
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * LineMapper
#define VTK_WIDGETS_EXPORT
virtual void GetActors(vtkPropCollection *)
create a line defined by two end points
Definition: vtkLineSource.h:34
map vtkPolyData to graphics primitives
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
a subclass of actor that always faces the camera
Definition: vtkFollower.h:44
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
vtkSphereSource ** HandleGeometry
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
vtkPointHandleRepresentation3D * LineHandleRepresentation
implicit function for a bounding box
Definition: vtkBox.h:39
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
a class defining the representation for a vtkLineWidget2
create polygonal text
Definition: vtkVectorText.h:45