VTK  9.3.0
vtkLineRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
38 #ifndef vtkLineRepresentation_h
39 #define vtkLineRepresentation_h
40 
41 #include "vtkInteractionWidgetsModule.h" // For export macro
43 
44 VTK_ABI_NAMESPACE_BEGIN
45 class vtkActor;
46 class vtkConeSource;
47 class vtkPolyDataMapper;
48 class vtkLineSource;
49 class vtkProperty;
50 class vtkPolyData;
53 class vtkBox;
54 class vtkFollower;
55 class vtkVectorText;
56 class vtkPolyDataMapper;
57 class vtkCellPicker;
58 
59 class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
60 {
61 public:
66 
68 
72  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
76 
81  void GetPoint1WorldPosition(double pos[3]);
83  void GetPoint1DisplayPosition(double pos[3]);
84  double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
85  void SetPoint1WorldPosition(double pos[3]);
86  void SetPoint1DisplayPosition(double pos[3]);
87  void GetPoint2DisplayPosition(double pos[3]);
88  double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
89  void GetPoint2WorldPosition(double pos[3]);
90  double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
91  void SetPoint2WorldPosition(double pos[3]);
92  void SetPoint2DisplayPosition(double pos[3]);
94 
96 
106  void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
107  void InstantiateHandleRepresentation();
109 
111 
114  vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
115  vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
116  vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
118 
120 
124  vtkGetObjectMacro(EndPointProperty, vtkProperty);
125  vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
127 
129 
133  vtkGetObjectMacro(EndPoint2Property, vtkProperty);
134  vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
136 
138 
142  vtkGetObjectMacro(LineProperty, vtkProperty);
143  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
145 
147 
152  vtkSetClampMacro(Tolerance, int, 1, 100);
153  vtkGetMacro(Tolerance, int);
155 
157 
162  void SetResolution(int res);
163  int GetResolution();
165 
174  void GetPolyData(vtkPolyData* pd);
175 
177 
180  void PlaceWidget(double bounds[6]) override;
181  void BuildRepresentation() override;
182  int ComputeInteractionState(int X, int Y, int modify = 0) override;
183  void StartWidgetInteraction(double e[2]) override;
184  void WidgetInteraction(double e[2]) override;
185  double* GetBounds() VTK_SIZEHINT(6) override;
187 
189 
192  void GetActors(vtkPropCollection* pc) override;
193  void ReleaseGraphicsResources(vtkWindow*) override;
194  int RenderOpaqueGeometry(vtkViewport*) override;
195  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
196  vtkTypeBool HasTranslucentPolygonalGeometry() override;
198 
199  // Manage the state of the widget
200  enum
201  {
202  Outside = 0,
208  Scaling
209  };
210 
212 
221  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
223 
225 
229  virtual void SetRepresentationState(int);
230  vtkGetMacro(RepresentationState, int);
232 
234 
238  void SetDirectionalLine(bool val);
239  vtkGetMacro(DirectionalLine, bool);
240  vtkBooleanMacro(DirectionalLine, bool);
242 
247  vtkMTimeType GetMTime() override;
248 
252  void SetRenderer(vtkRenderer* ren) override;
253 
255 
258  vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
259  vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
260  vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
262 
264 
269  vtkSetStringMacro(DistanceAnnotationFormat);
270  vtkGetStringMacro(DistanceAnnotationFormat);
272 
274 
277  void SetDistanceAnnotationScale(double x, double y, double z)
278  {
279  double scale[3];
280  scale[0] = x;
281  scale[1] = y;
282  scale[2] = z;
283  this->SetDistanceAnnotationScale(scale);
284  }
285  virtual void SetDistanceAnnotationScale(double scale[3]);
288 
292  double GetDistance();
293 
298  void SetLineColor(double r, double g, double b);
299 
301 
304  void SetInteractionColor(double, double, double);
305  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
306  void SetForegroundColor(double, double, double);
307  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
309 
314 
316 
319  vtkGetObjectMacro(TextActor, vtkFollower);
321 
322  enum
323  {
324  RestrictNone = 0,
327  RestrictToZ
328  };
329 
330 protected:
333 
334  // The handle and the rep used to close the handles
339 
340  // Manage how the representation appears
343 
344  // the line
348 
349  // glyphs representing hot spots (e.g., handles)
353 
354  // Properties used to control the appearance of selected objects and
355  // the manipulator in general.
363 
364  // Selection tolerance for the handles and the line
366 
367  // Helper members
369  void ClampPosition(double x[3]);
370  void HighlightPoint(int ptId, int highlight);
371  void HighlightLine(int highlight);
372  int InBounds(double x[3]);
373  void SizeHandles();
374 
375  // Ivars used during widget interaction to hold initial positions
376  double StartP1[3];
377  double StartP2[3];
378  double StartLineHandle[3];
379  double Length;
380  double LastEventPosition[3];
381 
382  // Support GetBounds() method
384 
385  // Need to keep track if we have successfully initialized the display position.
386  // The widget tends to do stuff in world coordinates, put if the renderer has
387  // not been assigned, then certain operations do not properly update the display
388  // position.
390 
391  // Format for the label
394 
398  double Distance;
400 
402 
403 private:
405  void operator=(const vtkLineRepresentation&) = delete;
406 };
407 
408 VTK_ABI_NAMESPACE_END
409 #endif
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
implicit function for a bounding box
Definition: vtkBox.h:40
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:71
generate polygonal cone
Definition: vtkConeSource.h:43
a subclass of actor that always faces the camera
Definition: vtkFollower.h:42
a simple class to control print indentation
Definition: vtkIndent.h:38
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.
void SetInteractionColor(double c[3])
Set the widget color, and the color of interactive handles.
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 SetForegroundColor(double c[3])
Set the widget color, and the color of interactive handles.
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 vtkProperty * GetDistanceAnnotationProperty()
Get the distance annotation property.
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 SetForegroundColor(double, double, double)
Set the widget color, and the color of interactive handles.
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
Definition: vtkLineSource.h:62
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:89
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:66
abstract specification for renderers
Definition: vtkRenderer.h:71
create polygonal text
Definition: vtkVectorText.h:46
abstract specification for Viewports
Definition: vtkViewport.h:54
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
void GetBounds(T a, double bds[6])
@ scale
Definition: vtkX3D.h:229
int vtkTypeBool
Definition: vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_SIZEHINT(...)