VTK  9.3.20240424
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]);
95 void GetPoint1DisplayPosition(double pos[3]);
96 double* GetPoint1DisplayPosition() VTK_SIZEHINT(3);
97 void SetPoint1WorldPosition(double pos[3]);
98 void SetPoint1DisplayPosition(double pos[3]);
99 void GetPoint2DisplayPosition(double pos[3]);
100 double* GetPoint2DisplayPosition() VTK_SIZEHINT(3);
101 void GetPoint2WorldPosition(double pos[3]);
102 double* GetPoint2WorldPosition() VTK_SIZEHINT(3);
103 void SetPoint2WorldPosition(double pos[3]);
104 void SetPoint2DisplayPosition(double pos[3]);
106
108
118 void SetHandleRepresentation(vtkPointHandleRepresentation3D* handle);
119 void InstantiateHandleRepresentation();
121
123
126 vtkGetObjectMacro(Point1Representation, vtkPointHandleRepresentation3D);
127 vtkGetObjectMacro(Point2Representation, vtkPointHandleRepresentation3D);
128 vtkGetObjectMacro(LineHandleRepresentation, vtkPointHandleRepresentation3D);
130
132
136 vtkGetObjectMacro(EndPointProperty, vtkProperty);
137 vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
139
141
145 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
146 vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
148
150
154 vtkGetObjectMacro(LineProperty, vtkProperty);
155 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
157
159
164 vtkSetClampMacro(Tolerance, int, 1, 100);
165 vtkGetMacro(Tolerance, int);
167
169
174 void SetResolution(int res);
175 int GetResolution();
177
186 void GetPolyData(vtkPolyData* pd);
187
189
192 void PlaceWidget(double bounds[6]) override;
193 void BuildRepresentation() override;
194 int ComputeInteractionState(int X, int Y, int modify = 0) override;
195 void StartWidgetInteraction(double e[2]) override;
196 void WidgetInteraction(double e[2]) override;
197 double* GetBounds() VTK_SIZEHINT(6) override;
199
201
204 void GetActors(vtkPropCollection* pc) override;
205 void ReleaseGraphicsResources(vtkWindow*) override;
206 int RenderOpaqueGeometry(vtkViewport*) override;
207 int RenderTranslucentPolygonalGeometry(vtkViewport*) override;
208 vtkTypeBool HasTranslucentPolygonalGeometry() override;
210
211 // Manage the state of the widget
212 enum
213 {
214 Outside = 0,
220 Scaling
221 };
222
224
233 vtkSetClampMacro(InteractionState, int, Outside, Scaling);
235
237
241 virtual void SetRepresentationState(int);
242 vtkGetMacro(RepresentationState, int);
244
246
250 void SetDirectionalLine(bool val);
251 vtkGetMacro(DirectionalLine, bool);
252 vtkBooleanMacro(DirectionalLine, bool);
254
260
264 void SetRenderer(vtkRenderer* ren) override;
265
267
270 vtkSetMacro(DistanceAnnotationVisibility, vtkTypeBool);
271 vtkGetMacro(DistanceAnnotationVisibility, vtkTypeBool);
272 vtkBooleanMacro(DistanceAnnotationVisibility, vtkTypeBool);
274
276
281 vtkSetStringMacro(DistanceAnnotationFormat);
282 vtkGetStringMacro(DistanceAnnotationFormat);
284
286
289 void SetDistanceAnnotationScale(double x, double y, double z)
290 {
291 double scale[3];
292 scale[0] = x;
293 scale[1] = y;
294 scale[2] = z;
295 this->SetDistanceAnnotationScale(scale);
296 }
297 virtual void SetDistanceAnnotationScale(double scale[3]);
300
304 double GetDistance();
305
310 void SetLineColor(double r, double g, double b);
311
313
316 void SetInteractionColor(double, double, double);
317 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
318 void SetForegroundColor(double, double, double);
319 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
321
326
328
331 vtkGetObjectMacro(TextActor, vtkFollower);
333
334 enum
335 {
336 RestrictNone = 0,
339 RestrictToZ
340 };
341
342protected:
345
346 // The handle and the rep used to close the handles
351
352 // Manage how the representation appears
355
356 // the line
360
361 // glyphs representing hot spots (e.g., handles)
365
366 // Properties used to control the appearance of selected objects and
367 // the manipulator in general.
375
376 // Selection tolerance for the handles and the line
378
379 // Helper members
381 void ClampPosition(double x[3]);
382 void HighlightPoint(int ptId, int highlight);
383 void HighlightLine(int highlight);
384 int InBounds(double x[3]);
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
415private:
417 void operator=(const vtkLineRepresentation&) = delete;
418};
419
420VTK_ABI_NAMESPACE_END
421#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
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
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
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:65
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:270
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO