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 
43 #include "vtkInteractionWidgetsModule.h" // For export macro
45 
46 class vtkActor;
47 class vtkPolyDataMapper;
48 class vtkLineSource;
49 class vtkSphereSource;
50 class vtkProperty;
51 class vtkPolyData;
54 class vtkBox;
55 class vtkFollower;
56 class vtkVectorText;
57 class vtkPolyDataMapper;
58 class vtkCellPicker;
59 
61 {
62 public:
64  static vtkLineRepresentation *New();
65 
67 
69  void PrintSelf(ostream& os, vtkIndent indent);
71 
73 
76  void GetPoint1WorldPosition(double pos[3]);
77  double* GetPoint1WorldPosition();
78  void GetPoint1DisplayPosition(double pos[3]);
79  double* GetPoint1DisplayPosition();
80  void SetPoint1WorldPosition(double pos[3]);
81  void SetPoint1DisplayPosition(double pos[3]);
82  void GetPoint2DisplayPosition(double pos[3]);
83  double* GetPoint2DisplayPosition();
84  void GetPoint2WorldPosition(double pos[3]);
85  double* GetPoint2WorldPosition();
86  void SetPoint2WorldPosition(double pos[3]);
87  void SetPoint2DisplayPosition(double pos[3]);
89 
91 
99  void SetHandleRepresentation(vtkPointHandleRepresentation3D *handle);
100  void InstantiateHandleRepresentation();
102 
104 
105  vtkGetObjectMacro(Point1Representation,vtkPointHandleRepresentation3D);
106  vtkGetObjectMacro(Point2Representation,vtkPointHandleRepresentation3D);
107  vtkGetObjectMacro(LineHandleRepresentation,vtkPointHandleRepresentation3D);
109 
111 
113  vtkGetObjectMacro(EndPointProperty,vtkProperty);
114  vtkGetObjectMacro(SelectedEndPointProperty,vtkProperty);
116 
118 
120  vtkGetObjectMacro(EndPoint2Property,vtkProperty);
121  vtkGetObjectMacro(SelectedEndPoint2Property,vtkProperty);
123 
125 
127  vtkGetObjectMacro(LineProperty,vtkProperty);
128  vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
130 
132 
135  vtkSetClampMacro(Tolerance,int,1,100);
136  vtkGetMacro(Tolerance,int);
138 
140 
143  void SetResolution(int res);
144  int GetResolution();
146 
153  void GetPolyData(vtkPolyData *pd);
154 
156 
157  virtual void PlaceWidget(double bounds[6]);
158  virtual void BuildRepresentation();
159  virtual int ComputeInteractionState(int X, int Y, int modify=0);
160  virtual void StartWidgetInteraction(double e[2]);
161  virtual void WidgetInteraction(double e[2]);
162  virtual double *GetBounds();
164 
166 
167  virtual void GetActors(vtkPropCollection *pc);
168  virtual void ReleaseGraphicsResources(vtkWindow*);
169  virtual int RenderOpaqueGeometry(vtkViewport*);
171  virtual int HasTranslucentPolygonalGeometry();
173 
174  // Manage the state of the widget
175  enum {Outside=0,OnP1,OnP2,TranslatingP1,TranslatingP2,OnLine,Scaling};
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:50
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:46
represent surface properties of a geometric object
Definition: vtkProperty.h:63
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:62
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
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:36
vtkPointHandleRepresentation3D * HandleRepresentation
#define VTKINTERACTIONWIDGETS_EXPORT
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:38
virtual void WidgetInteraction(double newEventPos[2])
vtkPolyDataMapper * LineMapper
virtual void GetActors(vtkPropCollection *)
create a line defined by two end points
Definition: vtkLineSource.h:41
map vtkPolyData to graphics primitives
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
a subclass of actor that always faces the camera
Definition: vtkFollower.h:45
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
vtkSphereSource ** HandleGeometry
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
vtkPointHandleRepresentation3D * LineHandleRepresentation
implicit function for a bounding box
Definition: vtkBox.h:40
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
a class defining the representation for a vtkLineWidget2
create polygonal text
Definition: vtkVectorText.h:46