VTK  9.3.1
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
29 #ifndef vtkLineRepresentation_h
30 #define vtkLineRepresentation_h
31 
32 #include "vtkInteractionWidgetsModule.h" // For export macro
34 
35 VTK_ABI_NAMESPACE_BEGIN
36 class vtkActor;
37 class vtkConeSource;
38 class vtkPolyDataMapper;
39 class vtkLineSource;
40 class vtkProperty;
41 class vtkPolyData;
44 class vtkBox;
45 class vtkFollower;
46 class vtkVectorText;
47 class vtkPolyDataMapper;
48 class vtkCellPicker;
49 
50 class VTKINTERACTIONWIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
51 {
52 public:
56  static vtkLineRepresentation* New();
57 
59 
63  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
67 
72  void GetPoint1WorldPosition(double pos[3]);
73  double* GetPoint1WorldPosition() VTK_SIZEHINT(3);
74  void GetPoint1DisplayPosition(double pos[3]);
75  double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
76  void SetPoint1WorldPosition(double pos[3]);
77  void SetPoint1DisplayPosition(double pos[3]);
78  void GetPoint2DisplayPosition(double pos[3]);
79  double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
80  void GetPoint2WorldPosition(double pos[3]);
81  double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
82  void SetPoint2WorldPosition(double pos[3]);
83  void SetPoint2DisplayPosition(double pos[3]);
85 
87 
97  void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
98  void InstantiateHandleRepresentation();
100 
102 
105  vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
106  vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
107  vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
109 
111 
115  vtkGetObjectMacro(EndPointProperty, vtkProperty);
116  vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
118 
120 
124  vtkGetObjectMacro(EndPoint2Property, vtkProperty);
125  vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
127 
129 
133  vtkGetObjectMacro(LineProperty, vtkProperty);
134  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
136 
138 
143  vtkSetClampMacro(Tolerance, int, 1, 100);
144  vtkGetMacro(Tolerance, int);
146 
148 
153  void SetResolution(int res);
154  int GetResolution();
156 
165  void GetPolyData(vtkPolyData* pd);
166 
168 
171  void PlaceWidget(double bounds[6]) override;
172  void BuildRepresentation() override;
173  int ComputeInteractionState(int X, int Y, int modify = 0) override;
174  void StartWidgetInteraction(double e[2]) override;
175  void WidgetInteraction(double e[2]) override;
176  double* GetBounds() VTK_SIZEHINT(6) override;
178 
180 
183  void GetActors(vtkPropCollection* pc) override;
184  void ReleaseGraphicsResources(vtkWindow*) override;
185  int RenderOpaqueGeometry(vtkViewport*) override;
186  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
187  vtkTypeBool HasTranslucentPolygonalGeometry() override;
189 
190  // Manage the state of the widget
191  enum
192  {
193  Outside = 0,
199  Scaling
200  };
201 
203 
212  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
214 
216 
220  virtual void SetRepresentationState(int);
221  vtkGetMacro(RepresentationState, int);
223 
225 
229  void SetDirectionalLine(bool val);
230  vtkGetMacro(DirectionalLine, bool);
231  vtkBooleanMacro(DirectionalLine, bool);
233 
238  vtkMTimeType GetMTime() override;
239 
243  void SetRenderer(vtkRenderer* ren) override;
244 
246 
249  vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
250  vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
251  vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
253 
255 
260  vtkSetStringMacro(DistanceAnnotationFormat);
261  vtkGetStringMacro(DistanceAnnotationFormat);
263 
265 
268  void SetDistanceAnnotationScale(double x, double y, double z)
269  {
270  double scale[3];
271  scale[0] = x;
272  scale[1] = y;
273  scale[2] = z;
274  this->SetDistanceAnnotationScale(scale);
275  }
276  virtual void SetDistanceAnnotationScale(double scale[3]);
277  virtual double* GetDistanceAnnotationScale() VTK_SIZEHINT(3);
279 
283  double GetDistance();
284 
289  void SetLineColor(double r, double g, double b);
290 
292 
295  void SetInteractionColor(double, double, double);
296  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
297  void SetForegroundColor(double, double, double);
298  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
300 
304  virtual vtkProperty* GetDistanceAnnotationProperty();
305 
307 
310  vtkGetObjectMacro(TextActor, vtkFollower);
312 
313  enum
314  {
315  RestrictNone = 0,
318  RestrictToZ
319  };
320 
321 protected:
323  ~vtkLineRepresentation() override;
324 
325  // The handle and the rep used to close the handles
330 
331  // Manage how the representation appears
334 
335  // the line
339 
340  // glyphs representing hot spots (e.g., handles)
344 
345  // Properties used to control the appearance of selected objects and
346  // the manipulator in general.
353  void CreateDefaultProperties();
354 
355  // Selection tolerance for the handles and the line
357 
358  // Helper members
360  void ClampPosition(double x[3]);
361  void HighlightPoint(int ptId, int highlight);
362  void HighlightLine(int highlight);
363  int InBounds(double x[3]);
364  void SizeHandles();
365 
366  // Ivars used during widget interaction to hold initial positions
367  double StartP1[3];
368  double StartP2[3];
369  double StartLineHandle[3];
370  double Length;
371  double LastEventPosition[3];
372 
373  // Support GetBounds() method
375 
376  // Need to keep track if we have successfully initialized the display position.
377  // The widget tends to do stuff in world coordinates, put if the renderer has
378  // not been assigned, then certain operations do not properly update the display
379  // position.
381 
382  // Format for the label
385 
389  double Distance;
391 
393 
394 private:
396  void operator=(const vtkLineRepresentation&) = delete;
397 };
398 
399 VTK_ABI_NAMESPACE_END
400 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
vtkTypeBool DistanceAnnotationVisibility
void GetBounds(T a, double bds[6])
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
void SetForegroundColor(double c[3])
Set the widget color, and the color of interactive handles.
void SetInteractionColor(double c[3])
Set the widget color, and the color of interactive handles.
represent the position of a point in 3D space
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
abstract specification for Viewports
Definition: vtkViewport.h:44
represent surface properties of a geometric object
Definition: vtkProperty.h:56
vtkPointHandleRepresentation3D * Point2Representation
virtual void SetRenderer(vtkRenderer *ren)
Subclasses of vtkWidgetRepresentation must implement these methods.
vtkPolyDataMapper ** HandleMapper
void SetDistanceAnnotationScale(double x, double y, double z)
Scale text (font size along each dimension).
vtkProperty * SelectedEndPoint2Property
vtkProperty * SelectedEndPointProperty
abstract specification for renderers
Definition: vtkRenderer.h:61
generate polygonal cone
Definition: vtkConeSource.h:33
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkPolyDataMapper * TextMapper
abstract class defines interface between the widget and widget representation classes ...
an ordered list of Props
vtkPointHandleRepresentation3D * Point1Representation
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
vtkPointHandleRepresentation3D * HandleRepresentation
vtkPolyDataAlgorithm ** HandleGeometry
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkPolyDataMapper * LineMapper
#define VTK_SIZEHINT(...)
create a line defined by two end points
Definition: vtkLineSource.h:52
map vtkPolyData to graphics primitives
a subclass of actor that always faces the camera
Definition: vtkFollower.h:32
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:61
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkPointHandleRepresentation3D * LineHandleRepresentation
implicit function for a bounding box
Definition: vtkBox.h:30
a class defining the representation for a vtkLineWidget2
create polygonal text
Definition: vtkVectorText.h:36