VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
35 
36 VTK_ABI_NAMESPACE_BEGIN
37 class vtkActor;
38 class vtkConeSource;
39 class vtkPolyDataMapper;
40 class vtkLineSource;
41 class vtkProperty;
42 class vtkPolyData;
45 class vtkBox;
46 class vtkFollower;
47 class vtkVectorText;
48 class vtkPolyDataMapper;
49 class vtkCellPicker;
50 
51 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkLineRepresentation
53 {
54 public:
58  static vtkLineRepresentation* New();
59 
61 
65  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
69 
74  void GetPoint1WorldPosition(double pos[3]) VTK_FUTURE_CONST;
75  double* GetPoint1WorldPosition() VTK_SIZEHINT(3);
77  void GetPoint1DisplayPosition(double pos[3]) VTK_FUTURE_CONST;
79  double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
80  void SetPoint1WorldPosition(double pos[3]);
82  void SetPoint1DisplayPosition(double pos[3]);
84  void GetPoint2DisplayPosition(double pos[3]) VTK_FUTURE_CONST;
86  double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
87  void GetPoint2WorldPosition(double pos[3]) VTK_FUTURE_CONST;
88  double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
89  void SetPoint2WorldPosition(double pos[3]);
91  void SetPoint2DisplayPosition(double pos[3]);
93 
95 
105  void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
106  void InstantiateHandleRepresentation();
108 
110 
113  vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
114  vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
115  vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
117 
119 
123  vtkGetObjectMacro(EndPointProperty, vtkProperty);
124  vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
125  void SetEndPointProperty(vtkProperty* property);
126  void SetSelectedEndPointProperty(vtkProperty* property);
128 
130 
134  vtkGetObjectMacro(EndPoint2Property, vtkProperty);
135  vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
136  void SetEndPoint2Property(vtkProperty* property);
137  void SetSelectedEndPoint2Property(vtkProperty* property);
139 
141 
145  vtkGetObjectMacro(LineProperty, vtkProperty);
146  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
147  void SetLineProperty(vtkProperty* property);
148  void SetSelectedLineProperty(vtkProperty* property);
150 
152 
157  vtkSetClampMacro(Tolerance, int, 1, 100);
158  vtkGetMacro(Tolerance, int);
160 
162 
167  void SetResolution(int res);
168  int GetResolution();
170 
179  void GetPolyData(vtkPolyData* pd);
180 
182 
185  void PlaceWidget(double bounds[6]) override;
186  void BuildRepresentation() override;
187  int ComputeInteractionState(int X, int Y, int modify = 0) override;
188  void StartWidgetInteraction(double e[2]) override;
189  void WidgetInteraction(double e[2]) override;
190  double* GetBounds() VTK_SIZEHINT(6) override;
192 
194 
197  void GetActors(vtkPropCollection* pc) override;
198  void ReleaseGraphicsResources(vtkWindow*) override;
199  int RenderOpaqueGeometry(vtkViewport*) override;
200  int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
201  vtkTypeBool HasTranslucentPolygonalGeometry() override;
203 
204  // Manage the state of the widget
205  enum
206  {
207  Outside = 0,
213  Scaling
214  };
215 
217 
226  vtkSetClampMacro(InteractionState, int, Outside, Scaling);
228 
230 
234  virtual void SetRepresentationState(int);
235  vtkGetMacro(RepresentationState, int);
237 
239 
243  void SetDirectionalLine(bool val);
244  vtkGetMacro(DirectionalLine, bool);
245  vtkBooleanMacro(DirectionalLine, bool);
247 
252  vtkMTimeType GetMTime() override;
253 
257  void SetRenderer(vtkRenderer* ren) override;
258 
260 
263  vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
264  vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
265  vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
267 
269 
274  vtkSetStringMacro(DistanceAnnotationFormat);
275  vtkGetStringMacro(DistanceAnnotationFormat);
277 
279 
282  void SetDistanceAnnotationScale(double x, double y, double z)
283  {
284  double scale[3];
285  scale[0] = x;
286  scale[1] = y;
287  scale[2] = z;
288  this->SetDistanceAnnotationScale(scale);
289  }
290  virtual void SetDistanceAnnotationScale(double scale[3]);
291  virtual double* GetDistanceAnnotationScale() VTK_SIZEHINT(3);
293 
297  double GetDistance();
298 
303  void SetLineColor(double r, double g, double b);
304 
306 
309  void SetInteractionColor(double, double, double);
310  void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
311  void SetForegroundColor(double, double, double);
312  void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
314 
318  virtual vtkProperty* GetDistanceAnnotationProperty();
319 
321 
324  vtkGetObjectMacro(TextActor, vtkFollower);
326 
327  enum
328  {
329  RestrictNone = 0,
332  RestrictToZ
333  };
334 
335 protected:
337  ~vtkLineRepresentation() override;
338 
339  // The handle and the rep used to close the handles
344 
345  // Manage how the representation appears
348 
349  // the line
353 
354  // glyphs representing hot spots (e.g., handles)
358 
359  // Properties used to control the appearance of selected objects and
360  // the manipulator in general.
367  void CreateDefaultProperties();
368 
369  // Selection tolerance for the handles and the line
371 
372  // Helper members
374  void ClampPosition(double x[3]);
375 
377 
380  void HighlightPoint(int ptId, int highlight);
381  void HighlightLine(int highlight);
383 
384  int InBounds(double x[3]);
385  void SizeHandles();
386 
387  // Ivars used during widget interaction to hold initial positions
388  double StartP1[3];
389  double StartP2[3];
390  double StartLineHandle[3];
391  double Length;
392  double LastEventPosition[3];
393 
394  // Support GetBounds() method
396 
397  // Need to keep track if we have successfully initialized the display position.
398  // The widget tends to do stuff in world coordinates, put if the renderer has
399  // not been assigned, then certain operations do not properly update the display
400  // position.
402 
403  // Format for the label
406 
410  double Distance;
412 
414 
415 private:
416  void UpdatePointAndLineProperties();
417 
419  void operator=(const vtkLineRepresentation&) = delete;
420 };
421 
422 VTK_ABI_NAMESPACE_END
423 #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:41
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:318
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
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:63
generate polygonal cone
Definition: vtkConeSource.h:34
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
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:41
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(...)
#define VTK_MARSHALEXCLUDE(reason)
create a line defined by two end points
Definition: vtkLineSource.h:53
map vtkPolyData to graphics primitives
a subclass of actor that always faces the camera
Definition: vtkFollower.h:33
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
#define VTK_MARSHALAUTO
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
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL