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
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:
57 
59 
63  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
67 
72  void GetPoint1WorldPosition(double pos[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]);
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 
305 
307 
310  vtkGetObjectMacro(TextActor, vtkFollower);
312 
313  enum
314  {
315  RestrictNone = 0,
318  RestrictToZ
319  };
320 
321 protected:
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.
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
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
implicit function for a bounding box
Definition: vtkBox.h:31
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
generate polygonal cone
Definition: vtkConeSource.h:34
a subclass of actor that always faces the camera
Definition: vtkFollower.h:33
a simple class to control print indentation
Definition: vtkIndent.h:29
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:53
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:80
an ordered list of Props
represent surface properties of a geometric object
Definition: vtkProperty.h:57
abstract specification for renderers
Definition: vtkRenderer.h:62
create polygonal text
Definition: vtkVectorText.h:37
abstract specification for Viewports
Definition: vtkViewport.h:45
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition: vtkWindow.h:28
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(...)