VTK  9.5.20251213
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
47
48#ifndef vtkLineRepresentation_h
49#define vtkLineRepresentation_h
50
51#include "vtkInteractionWidgetsModule.h" // For export macro
53#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
54
55VTK_ABI_NAMESPACE_BEGIN
56class vtkActor;
57class vtkConeSource;
59class vtkLineSource;
60class vtkProperty;
61class vtkPolyData;
64class vtkBox;
65class vtkFollower;
66class vtkVectorText;
68class vtkCellPicker;
69
70class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkLineRepresentation
72{
73public:
78
80
84 void PrintSelf(ostream& os, vtkIndent indent) override;
86
88
93 void GetPoint1WorldPosition(double pos[3]) VTK_FUTURE_CONST;
96 void GetPoint1DisplayPosition(double pos[3]) VTK_FUTURE_CONST;
99 void SetPoint1WorldPosition(double pos[3]);
101 void SetPoint1DisplayPosition(double pos[3]);
103 void GetPoint2DisplayPosition(double pos[3]) VTK_FUTURE_CONST;
106 void GetPoint2WorldPosition(double pos[3]) VTK_FUTURE_CONST;
108 void SetPoint2WorldPosition(double pos[3]);
110 void SetPoint2DisplayPosition(double pos[3]);
112
114
127
129
136
138
142 vtkGetObjectMacro(EndPointProperty, vtkProperty);
147
149
153 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
158
160
164 vtkGetObjectMacro(LineProperty, vtkProperty);
169
171
176 vtkSetClampMacro(Tolerance, int, 1, 100);
177 vtkGetMacro(Tolerance, int);
179
181
186 void SetResolution(int res);
189
199
201
204 void PlaceWidget(double bounds[6]) override;
205 void BuildRepresentation() override;
206 int ComputeInteractionState(int X, int Y, int modify = 0) override;
207 void StartWidgetInteraction(double e[2]) override;
208 void WidgetInteraction(double e[2]) override;
209 double* GetBounds() VTK_SIZEHINT(6) override;
211
213
216 void GetActors(vtkPropCollection* pc) override;
222
223 // Manage the state of the widget
224 enum
225 {
233 };
234
236
245 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
247
249
253 virtual void SetRepresentationState(int);
254 vtkGetMacro(RepresentationState, int);
256
258
262 void SetDirectionalLine(bool val);
263 vtkGetMacro(DirectionalLine, bool);
264 vtkBooleanMacro(DirectionalLine, bool);
266
272
276 void SetRenderer(vtkRenderer* ren) override;
277
279
286
288
293 vtkSetStringMacro(DistanceAnnotationFormat);
294 vtkGetStringMacro(DistanceAnnotationFormat);
296
298
301 void SetDistanceAnnotationScale(double x, double y, double z)
302 {
303 double scale[3];
304 scale[0] = x;
305 scale[1] = y;
306 scale[2] = z;
307 this->SetDistanceAnnotationScale(scale);
308 }
309 virtual void SetDistanceAnnotationScale(double scale[3]);
312
316 double GetDistance();
317
322 void SetLineColor(double r, double g, double b);
323
325
328 void SetInteractionColor(double, double, double);
329 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
330 void SetForegroundColor(double, double, double);
331 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
333
338
340
343 vtkGetObjectMacro(TextActor, vtkFollower);
345
346 enum
347 {
352 };
353
354protected:
357
358 // The handle and the rep used to close the handles
363
364 // Manage how the representation appears
367
368 // the line
372
373 // glyphs representing hot spots (e.g., handles)
377
378 // Properties used to control the appearance of selected objects and
379 // the manipulator in general.
387
388 // Selection tolerance for the handles and the line
390
391 // Helper members
393 void ClampPosition(double x[3]);
394
396
399 void HighlightPoint(int ptId, int highlight);
400 void HighlightLine(int highlight);
402
403 int InBounds(double x[3]);
405
406 // Ivars used during widget interaction to hold initial positions
407 double StartP1[3];
408 double StartP2[3];
410 double Length;
412
413 // Support GetBounds() method
415
416 // Need to keep track if we have successfully initialized the display position.
417 // The widget tends to do stuff in world coordinates, put if the renderer has
418 // not been assigned, then certain operations do not properly update the display
419 // position.
421
422 // Format for the label
425
429 double Distance;
431
433
434private:
435 void UpdatePointAndLineProperties();
436
438 void operator=(const vtkLineRepresentation&) = delete;
439};
440
441VTK_ABI_NAMESPACE_END
442#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
implicit function for a bounding box
Definition vtkBox.h:110
ray-cast cell picker for all kinds of Prop3Ds
generate polygonal cone
a subclass of actor that always faces the camera
Definition vtkFollower.h:93
a simple class to control print indentation
Definition vtkIndent.h:108
void SetDirectionalLine(bool val)
Sets the representation to be a directional line with point 1 represented as a cone.
void InstantiateHandleRepresentation()
This method is used to specify the type of handle representation to use for the three internal vtkHan...
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting the rendering process.
void SetInteractionColor(double c[3])
Set the widget color, and the color of interactive handles.
vtkPolyDataMapper * TextMapper
void SetEndPoint2Property(vtkProperty *property)
Set/Get the end-point (sphere) properties.
void ReleaseGraphicsResources(vtkWindow *) override
Methods supporting the rendering process.
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 PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
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).
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.
void SetPoint1DisplayPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
void SetResolution(int res)
Set/Get the resolution (number of subdivisions) of the line.
vtkPolyDataMapper * LineMapper
vtkPointHandleRepresentation3D * LineHandleRepresentation
void SetSelectedEndPoint2Property(vtkProperty *property)
Set/Get the end-point (sphere) properties.
void SetPoint1WorldPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
int RenderOpaqueGeometry(vtkViewport *) override
Methods supporting the rendering process.
void GetPoint1WorldPosition(double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining this representation.
double * GetPoint1WorldPosition()
Methods to Set/Get the coordinates of the two points defining this representation.
void SetSelectedEndPointProperty(vtkProperty *property)
Set/Get the end-point (sphere) properties.
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetRenderer(vtkRenderer *ren) override
Overridden to set the rendererer on the internal representations.
void GetPoint1DisplayPosition(double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining this representation.
void SetSelectedLineProperty(vtkProperty *property)
Set/Get the line properties.
void GetActors(vtkPropCollection *pc) override
Methods supporting the rendering process.
void SetHandleRepresentation(vtkPointHandleRepresentation3D *handle)
This method is used to specify the type of handle representation to use for the three internal vtkHan...
void SetLineColor(double r, double g, double b)
Convenience method to set the line color.
vtkPolyDataAlgorithm ** HandleGeometry
void SetForegroundColor(double, double, double)
Set the widget color, and the color of interactive handles.
virtual double * GetDistanceAnnotationScale()
Scale text (font size along each dimension).
virtual vtkProperty * GetDistanceAnnotationProperty()
Get the distance annotation property.
void GetPoint2DisplayPosition(double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining this representation.
void HighlightLine(int highlight)
These methods are just changing the properties of actors and representations.
void HighlightPoint(int ptId, int highlight)
These methods are just changing the properties of actors and representations.
void GetPolyData(vtkPolyData *pd)
Retrieve the polydata (including points) that defines the line.
double GetDistance()
Get the distance between the points.
vtkPointHandleRepresentation3D * Point2Representation
void SetEndPointProperty(vtkProperty *property)
Set/Get the end-point (sphere) properties.
vtkPointHandleRepresentation3D * HandleRepresentation
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetInteractionColor(double, double, double)
Set the widget color, and the color of interactive handles.
void GetPoint2WorldPosition(double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining this representation.
vtkPolyDataMapper ** HandleMapper
int GetResolution()
Set/Get the resolution (number of subdivisions) of the line.
void SetPoint2DisplayPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
void SetPoint2WorldPosition(double pos[3])
Methods to Set/Get the coordinates of the two points defining this representation.
vtkProperty * SelectedEndPoint2Property
~vtkLineRepresentation() override
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Methods supporting the rendering process.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkMTimeType GetMTime() override
Overload the superclasses' GetMTime() because internal classes are used to keep the state of the repr...
void SetLineProperty(vtkProperty *property)
Set/Get the line properties.
int InBounds(double x[3])
create a line defined by two end points
represent the position of a point in 3D space
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
an ordered list of Props
represent surface properties of a geometric object
abstract specification for renderers
create polygonal text
abstract specification for Viewports
Definition vtkViewport.h:66
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:322
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)
#define vtkPolyDataAlgorithm