VTK  9.4.20250328
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
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;
98 double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
99 void SetPoint1WorldPosition(double pos[3]);
101 void SetPoint1DisplayPosition(double pos[3]);
103 void GetPoint2DisplayPosition(double pos[3]) VTK_FUTURE_CONST;
105 double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
106 void GetPoint2WorldPosition(double pos[3]) VTK_FUTURE_CONST;
107 double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
108 void SetPoint2WorldPosition(double pos[3]);
110 void SetPoint2DisplayPosition(double pos[3]);
112
114
124 void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
125 void InstantiateHandleRepresentation();
127
129
132 vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
133 vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
134 vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
136
138
142 vtkGetObjectMacro(EndPointProperty, vtkProperty);
143 vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
145
147
151 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
152 vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
154
156
160 vtkGetObjectMacro(LineProperty, vtkProperty);
161 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
163
165
170 vtkSetClampMacro(Tolerance, int, 1, 100);
171 vtkGetMacro(Tolerance, int);
173
175
180 void SetResolution(int res);
181 int GetResolution();
183
192 void GetPolyData(vtkPolyData* pd);
193
195
198 void PlaceWidget(double bounds[6]) override;
199 void BuildRepresentation() override;
200 int ComputeInteractionState(int X, int Y, int modify = 0) override;
201 void StartWidgetInteraction(double e[2]) override;
202 void WidgetInteraction(double e[2]) override;
203 double* GetBounds() VTK_SIZEHINT(6) override;
205
207
210 void GetActors(vtkPropCollection* pc) override;
211 void ReleaseGraphicsResources(vtkWindow*) override;
212 int RenderOpaqueGeometry(vtkViewport*) override;
213 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
214 vtkTypeBool HasTranslucentPolygonalGeometry() override;
216
217 // Manage the state of the widget
218 enum
219 {
220 Outside = 0,
226 Scaling
227 };
228
230
239 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
241
243
247 virtual void SetRepresentationState(int);
248 vtkGetMacro(RepresentationState, int);
250
252
256 void SetDirectionalLine(bool val);
257 vtkGetMacro(DirectionalLine, bool);
258 vtkBooleanMacro(DirectionalLine, bool);
260
266
270 void SetRenderer(vtkRenderer* ren) override;
271
273
276 vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
277 vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
278 vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
280
282
287 vtkSetStringMacro(DistanceAnnotationFormat);
288 vtkGetStringMacro(DistanceAnnotationFormat);
290
292
295 void SetDistanceAnnotationScale(double x, double y, double z)
296 {
297 double scale[3];
298 scale[0] = x;
299 scale[1] = y;
300 scale[2] = z;
301 this->SetDistanceAnnotationScale(scale);
302 }
303 virtual void SetDistanceAnnotationScale(double scale[3]);
306
310 double GetDistance();
311
316 void SetLineColor(double r, double g, double b);
317
319
322 void SetInteractionColor(double, double, double);
323 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
324 void SetForegroundColor(double, double, double);
325 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
327
332
334
337 vtkGetObjectMacro(TextActor, vtkFollower);
339
340 enum
341 {
342 RestrictNone = 0,
345 RestrictToZ
346 };
347
348protected:
351
352 // The handle and the rep used to close the handles
357
358 // Manage how the representation appears
361
362 // the line
366
367 // glyphs representing hot spots (e.g., handles)
371
372 // Properties used to control the appearance of selected objects and
373 // the manipulator in general.
381
382 // Selection tolerance for the handles and the line
384
385 // Helper members
387 void ClampPosition(double x[3]);
388 void HighlightPoint(int ptId, int highlight);
389 void HighlightLine(int highlight);
390 int InBounds(double x[3]);
392
393 // Ivars used during widget interaction to hold initial positions
394 double StartP1[3];
395 double StartP2[3];
396 double StartLineHandle[3];
397 double Length;
398 double LastEventPosition[3];
399
400 // Support GetBounds() method
402
403 // Need to keep track if we have successfully initialized the display position.
404 // The widget tends to do stuff in world coordinates, put if the renderer has
405 // not been assigned, then certain operations do not properly update the display
406 // position.
408
409 // Format for the label
412
416 double Distance;
418
420
421private:
423 void operator=(const vtkLineRepresentation&) = delete;
424};
425
426VTK_ABI_NAMESPACE_END
427#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:92
a simple class to control print indentation
Definition vtkIndent.h:108
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.
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).
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.
vtkPolyDataMapper * LineMapper
vtkPointHandleRepresentation3D * LineHandleRepresentation
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 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.
virtual double * GetDistanceAnnotationScale()
Scale text (font size along each dimension).
virtual vtkProperty * GetDistanceAnnotationProperty()
Get the distance annotation property.
void HighlightLine(int highlight)
void HighlightPoint(int ptId, int highlight)
vtkPointHandleRepresentation3D * Point2Representation
vtkPointHandleRepresentation3D * HandleRepresentation
vtkPolyDataMapper ** HandleMapper
vtkProperty * SelectedEndPoint2Property
~vtkLineRepresentation() override
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
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
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
abstract class defines interface between the widget and widget representation classes
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)