VTK  9.2.6
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 =========================================================================*/
60 #ifndef vtkLineRepresentation_h
61 #define vtkLineRepresentation_h
62 
63 #include "vtkInteractionWidgetsModule.h" // For export macro
65 
66 class vtkActor;
67 class vtkConeSource;
68 class vtkPolyDataMapper;
69 class vtkLineSource;
70 class vtkProperty;
71 class vtkPolyData;
74 class vtkBox;
75 class vtkFollower;
76 class vtkVectorText;
77 class vtkPolyDataMapper;
78 class vtkCellPicker;
79 
80 class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
81 {
82 public:
87 
89 
93  void PrintSelf(ostream& os, vtkIndent indent) override;
95 
97 
102  void GetPoint1WorldPosition(double pos[3]);
104  void GetPoint1DisplayPosition(double pos[3]);
105  double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
106  void SetPoint1WorldPosition(double pos[3]);
107  void SetPoint1DisplayPosition(double pos[3]);
108  void GetPoint2DisplayPosition(double pos[3]);
109  double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
110  void GetPoint2WorldPosition(double pos[3]);
111  double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
112  void SetPoint2WorldPosition(double pos[3]);
113  void SetPoint2DisplayPosition(double pos[3]);
115 
117 
127  void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
128  void InstantiateHandleRepresentation();
130 
132 
135  vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
136  vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
137  vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
139 
141 
145  vtkGetObjectMacro(EndPointProperty, vtkProperty);
146  vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
148 
150 
154  vtkGetObjectMacro(EndPoint2Property, vtkProperty);
155  vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
157 
159 
163  vtkGetObjectMacro(LineProperty, vtkProperty);
164  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
166 
168 
173  vtkSetClampMacro(Tolerance, int, 1, 100);
174  vtkGetMacro(Tolerance, int);
176 
178 
183  void SetResolution(int res);
184  int GetResolution();
186 
195  void GetPolyData(vtkPolyData* pd);
196 
198 
201  void PlaceWidget(double bounds[6]) override;
202  void BuildRepresentation() override;
203  int ComputeInteractionState(int X, int Y, int modify = 0) override;
204  void StartWidgetInteraction(double e[2]) override;
205  void WidgetInteraction(double e[2]) override;
206  double* GetBounds() VTK_SIZEHINT(6) override;
208 
210 
213  void GetActors(vtkPropCollection* pc) override;
214  void ReleaseGraphicsResources(vtkWindow*) override;
215  int RenderOpaqueGeometry(vtkViewport*) override;
216  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
217  vtkTypeBool HasTranslucentPolygonalGeometry() override;
219 
220  // Manage the state of the widget
221  enum
222  {
223  Outside = 0,
229  Scaling
230  };
231 
233 
242  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
244 
246 
250  virtual void SetRepresentationState(int);
251  vtkGetMacro(RepresentationState, int);
253 
255 
259  void SetDirectionalLine(bool val);
260  vtkGetMacro(DirectionalLine, bool);
261  vtkBooleanMacro(DirectionalLine, bool);
263 
268  vtkMTimeType GetMTime() override;
269 
273  void SetRenderer(vtkRenderer* ren) override;
274 
276 
279  vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
280  vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
281  vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
283 
285 
290  vtkSetStringMacro(DistanceAnnotationFormat);
291  vtkGetStringMacro(DistanceAnnotationFormat);
293 
295 
298  void SetDistanceAnnotationScale(double x, double y, double z)
299  {
300  double scale[3];
301  scale[0] = x;
302  scale[1] = y;
303  scale[2] = z;
304  this->SetDistanceAnnotationScale(scale);
305  }
306  virtual void SetDistanceAnnotationScale(double scale[3]);
309 
313  double GetDistance();
314 
319  void SetLineColor(double r, double g, double b);
320 
324  virtual vtkProperty* GetDistanceAnnotationProperty();
325 
327 
330  vtkGetObjectMacro(TextActor, vtkFollower);
332 
333  enum
334  {
335  RestrictNone = 0,
338  RestrictToZ
339  };
340 
341 protected:
344 
345  // The handle and the rep used to close the handles
350 
351  // Manage how the representation appears
354 
355  // the line
359 
360  // glyphs representing hot spots (e.g., handles)
364 
365  // Properties used to control the appearance of selected objects and
366  // the manipulator in general.
374 
375  // Selection tolerance for the handles and the line
377 
378  // Helper members
380  void ClampPosition(double x[3]);
381  void HighlightPoint(int ptId, int highlight);
382  void HighlightLine(int highlight);
383  int InBounds(double x[3]);
384  void SizeHandles();
385 
386  // Ivars used during widget interaction to hold initial positions
387  double StartP1[3];
388  double StartP2[3];
389  double StartLineHandle[3];
390  double Length;
391  double LastEventPosition[3];
392 
393  // Support GetBounds() method
395 
396  // Need to keep track if we have successfully initialized the display position.
397  // The widget tends to do stuff in world coordinates, put if the renderer has
398  // not been assigned, then certain operations do not properly update the display
399  // position.
401 
402  // Format for the label
405 
409  double Distance;
411 
413 
414 private:
416  void operator=(const vtkLineRepresentation&) = delete;
417 };
418 
419 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:161
implicit function for a bounding box
Definition: vtkBox.h:141
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
a subclass of actor that always faces the camera
Definition: vtkFollower.h:123
a simple class to control print indentation
Definition: vtkIndent.h:119
a class defining the representation for a vtkLineWidget2
void SetDirectionalLine(bool val)
Sets the representation to be a directional line with point 1 represented as a cone.
vtkTypeBool DistanceAnnotationVisibility
double * GetPoint1WorldPosition()
Methods to Set/Get the coordinates of the two points defining this representation.
vtkPolyDataMapper * TextMapper
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for the class.
static vtkLineRepresentation * New()
Instantiate the class.
virtual void SetDistanceAnnotationScale(double scale[3])
Scale text (font size along each dimension).
void SetDistanceAnnotationScale(double x, double y, double z)
Scale text (font size along each dimension).
vtkProperty * SelectedEndPointProperty
vtkPointHandleRepresentation3D * Point1Representation
void ClampPosition(double x[3])
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
vtkPolyDataMapper * LineMapper
vtkPointHandleRepresentation3D * LineHandleRepresentation
void SetRenderer(vtkRenderer *ren) override
Overridden to set the rendererer on the internal representations.
vtkPolyDataAlgorithm ** HandleGeometry
void HighlightLine(int highlight)
void HighlightPoint(int ptId, int highlight)
vtkPointHandleRepresentation3D * Point2Representation
virtual double * GetDistanceAnnotationScale()
Scale text (font size along each dimension).
vtkPointHandleRepresentation3D * HandleRepresentation
vtkPolyDataMapper ** HandleMapper
vtkProperty * SelectedEndPoint2Property
~vtkLineRepresentation() override
void GetPoint1WorldPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
vtkMTimeType GetMTime() override
Overload the superclasses' GetMTime() because internal classes are used to keep the state of the repr...
int InBounds(double x[3])
create a line defined by two end points
represent the position of a point in 3D space
Superclass for algorithms that produce only polydata as output.
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:177
abstract specification for renderers
Definition: vtkRenderer.h:182
create polygonal text
abstract specification for Viewports
Definition: vtkViewport.h:56
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:39
void GetBounds(T a, double bds[6])
@ scale
Definition: vtkX3D.h:235
int vtkTypeBool
Definition: vtkABI.h:69
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)