VTK  9.5.20251127
vtkMultiLineRepresentation.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
18
19#ifndef vtkMultiLineRepresentation_h
20#define vtkMultiLineRepresentation_h
21
22#include "vtkInteractionWidgetsModule.h" // For export macro
24#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
25
26VTK_ABI_NAMESPACE_BEGIN
27class vtkBox;
28class vtkDoubleArray;
30class vtkPolyData;
31class vtkProperty;
32
33class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkMultiLineRepresentation
35{
36public:
38
40 void PrintSelf(ostream& os, vtkIndent indent) override;
41
43
48 void GetPoint1WorldPosition(int index, double pos[3]) VTK_FUTURE_CONST;
49 double* GetPoint1WorldPosition(int index) VTK_SIZEHINT(3);
51 void GetPoint1DisplayPosition(int index, double pos[3]) VTK_FUTURE_CONST;
54 void SetPoint1WorldPosition(int index, double pos[3]);
56 void SetPoint1DisplayPosition(int index, double pos[3]);
58 void GetPoint2DisplayPosition(int index, double pos[3]) VTK_FUTURE_CONST;
61 void GetPoint2WorldPosition(int index, double pos[3]) VTK_FUTURE_CONST;
62 double* GetPoint2WorldPosition(int index) VTK_SIZEHINT(3);
63 void SetPoint2WorldPosition(int index, double pos[3]);
65 void SetPoint2DisplayPosition(int index, double pos[3]);
66
67 void SetPoint1WorldPosition(int index, double x, double y, double z);
68 void SetPoint1DisplayPosition(int index, double x, double y, double z);
69 void SetPoint2WorldPosition(int index, double x, double y, double z);
70 void SetPoint2DisplayPosition(int index, double x, double y, double z);
71
77
79
82 void SetLineCount(int n);
83 vtkGetMacro(LineCount, int)
85
87
91 vtkGetObjectMacro(EndPointProperty, vtkProperty);
92 vtkGetObjectMacro(SelectedEndPointProperty, vtkProperty);
94
96
100 vtkGetObjectMacro(EndPoint2Property, vtkProperty);
101 vtkGetObjectMacro(SelectedEndPoint2Property, vtkProperty);
103
105
109 vtkGetObjectMacro(LineProperty, vtkProperty);
110 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
112
114
119 void SetTolerance(int tol);
120 vtkGetMacro(Tolerance, int);
122
124
129 void SetResolution(int res);
130 vtkGetMacro(Resolution, int);
132
141 void GetPolyData(int index, vtkPolyData* pd);
142
144
147 void PlaceWidget(double bounds[6]) override;
148 void BuildRepresentation() override;
149 int ComputeInteractionState(int X, int Y, int modify = 0) override;
150 double* GetBounds() VTK_SIZEHINT(6) override;
152
153 // Manage the state of the widget (with his correspondent in vtkLineRepresentation next to him)
154 enum
155 {
156 MOUSE_OUTSIDE_LINES = 0, // Outside
157 MOUSE_ON_P1, // OnP1
158 MOUSE_ON_P2, // OnP2
159 TRANSLATING_P1, // TranslatingP1
160 TRANSLATING_P2, // TranslatingP2
161 MOUSE_ON_LINE, // OnLine
162 SCALING // Scaling
163 };
164
166
177
179
183 virtual void SetRepresentationState(int);
184 vtkGetMacro(RepresentationState, int);
186
188
191 void GetActors(vtkPropCollection* pc) override;
192 void ReleaseGraphicsResources(vtkWindow* window) override;
193 int RenderOpaqueGeometry(vtkViewport* viewport) override;
197
199
203 void SetDirectionalLine(bool val);
204 vtkGetMacro(DirectionalLine, bool);
205 vtkBooleanMacro(DirectionalLine, bool);
207
212
218
222 void SetRenderer(vtkRenderer* ren) override;
223
227 double GetDistance(int index);
228
233 void SetLineColor(double r, double g, double b);
234
236
239 void SetInteractionColor(double, double, double);
240 void SetInteractionColor(double c[3]) { this->SetInteractionColor(c[0], c[1], c[2]); }
241 void SetForegroundColor(double, double, double);
242 void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); }
244
245protected:
248
249private:
251 void operator=(const vtkMultiLineRepresentation&) = delete;
252
253 void CreateDefaultProperties();
254
255 // Helper methods
256 void AddNewLine(int index);
257 void ApplyProperties(int index);
258 void UpdatePoint1Positions();
259 void UpdatePoint2Positions();
260
261 // Manage how the representation appears
262 bool DirectionalLine = false;
263
264 int LineCount = 0;
265 std::vector<vtkSmartPointer<vtkLineRepresentation>> LineRepresentationVector;
266
267 vtkNew<vtkDoubleArray> Point1WorldPositions;
268 vtkNew<vtkDoubleArray> Point2WorldPositions;
269
270 vtkNew<vtkDoubleArray> Point1DisplayPositions;
271 vtkNew<vtkDoubleArray> Point2DisplayPositions;
272
273 // Properties used to control the appearance of selected objects and
274 // the manipulator in general.
275 vtkNew<vtkProperty> EndPointProperty;
276 vtkNew<vtkProperty> SelectedEndPointProperty;
277 vtkNew<vtkProperty> EndPoint2Property;
278 vtkNew<vtkProperty> SelectedEndPoint2Property;
279 vtkNew<vtkProperty> LineProperty;
280 vtkNew<vtkProperty> SelectedLineProperty;
281
282 // Support GetBounds() method
283 vtkNew<vtkBox> BoundingBox;
284
285 // Selection tolerance for the handles and the lines
286 int Tolerance = 5;
287
288 int Resolution = 5;
289
290 int RepresentationState = vtkMultiLineRepresentation::MOUSE_OUTSIDE_LINES;
291};
292
293VTK_ABI_NAMESPACE_END
294#endif
implicit function for a bounding box
Definition vtkBox.h:110
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
a class defining the representation for a vtkLineWidget2
virtual void SetRepresentationState(int)
Sets the visual appearance of the representation based on the state it is in.
void SetLineColor(double r, double g, double b)
Convenience method to set the lines color.
void SetPoint2WorldPosition(int index, double pos[3])
Methods to Set/Get the coordinates of the two points defining a line representation.
vtkMTimeType GetMTime() override
Overload the superclasses' GetMTime() because internal classes are used to keep the state of the repr...
vtkDoubleArray * GetPoint2DisplayPositions()
Methods to Set/Get the coordinates of the two points defining a line representation.
vtkDoubleArray * GetPoint2WorldPositions()
Methods to Set/Get the coordinates of the two points defining a line representation.
void SetResolution(int res)
Set/Get the resolution (number of subdivisions, minimum 1) of the line.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Methods supporting the rendering process.
void SetTolerance(int tol)
The tolerance representing the distance to a line (in pixels) in which the cursor is considered near ...
vtkDoubleArray * GetPoint1DisplayPositions()
Methods to Set/Get the coordinates of the two points defining a line representation.
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
~vtkMultiLineRepresentation() override
double * GetPoint1WorldPosition(int index)
Methods to Set/Get the coordinates of the two points defining a line representation.
static vtkMultiLineRepresentation * New()
double * GetBounds() override
These are methods that satisfy vtkWidgetRepresentation's API.
void GetPolyData(int index, vtkPolyData *pd)
Retrieve the polydata (including points) that defines the line.
void GetActors(vtkPropCollection *pc) override
Methods supporting the rendering process.
void SetInteractionColor(double, double, double)
Set the widget color, and the color of interactive handles.
void SetRenderer(vtkRenderer *ren) override
Overridden to set the rendererer on the internal representations.
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
void SetPoint2DisplayPosition(int index, double pos[3])
Methods to Set/Get the coordinates of the two points defining a line representation.
void ReleaseGraphicsResources(vtkWindow *window) override
Methods supporting the rendering process.
vtkDoubleArray * GetPoint1WorldPositions()
Methods to Set/Get the coordinates of the two points defining a line representation.
void SetForegroundColor(double c[3])
Set the widget color, and the color of interactive handles.
void PlaceWidget(double bounds[6]) override
These are methods that satisfy vtkWidgetRepresentation's API.
void GetPoint1DisplayPosition(int index, double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining a line representation.
void SetPoint1DisplayPosition(int index, double pos[3])
Methods to Set/Get the coordinates of the two points defining a line representation.
void SetInteractionColor(double c[3])
Set the widget color, and the color of interactive handles.
void GetPoint2WorldPosition(int index, double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining a line representation.
void SetDirectionalLine(bool val)
Sets the representation of each line to be a directional line with point 1 represented as a cone.
void GetPoint1WorldPosition(int index, double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining a line representation.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetPoint2DisplayPosition(int index, double pos[3]) VTK_FUTURE_CONST
Methods to Set/Get the coordinates of the two points defining a line representation.
void SetLineCount(int n)
Set/Get the number of vtkLineRepresentation in this widget.
vtkLineRepresentation * GetLineRepresentation(int index)
Gets the individual representation of a specific line as a vtkLineRepresentation.
int RenderOpaqueGeometry(vtkViewport *viewport) override
Methods supporting the rendering process.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
Methods supporting the rendering process.
double GetDistance(int index)
Get the distance between the points of the line at the provided index.
void SetPoint1WorldPosition(int index, double pos[3])
Methods to Set/Get the coordinates of the two points defining a line representation.
void SetForegroundColor(double, double, double)
Set the widget color, and the color of interactive handles.
Allocate and hold a VTK object.
Definition vtkNew.h:167
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
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)