VTK  9.7.1
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
19 #ifndef vtkMultiLineRepresentation_h
20 #define vtkMultiLineRepresentation_h
21 
22 #include "vtkInteractionWidgetsModule.h" // For export macro
24 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkBox;
28 class vtkDoubleArray;
30 class vtkPolyData;
31 class vtkProperty;
32 
33 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkMultiLineRepresentation
35 {
36 public:
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;
53  double* GetPoint1DisplayPosition(int index) VTK_SIZEHINT(3);
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;
60  double* GetPoint2DisplayPosition(int index) VTK_SIZEHINT(3);
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 
72  vtkDoubleArray* GetPoint1WorldPositions();
73  vtkDoubleArray* GetPoint2WorldPositions();
74  vtkDoubleArray* GetPoint1DisplayPositions();
75  vtkDoubleArray* GetPoint2DisplayPositions();
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 
175  vtkSetClampMacro(InteractionState, int, MOUSE_OUTSIDE_LINES, MOUSE_ON_LINE);
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;
194  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
197 
199 
203  void SetDirectionalLine(bool val);
204  vtkGetMacro(DirectionalLine, bool);
205  vtkBooleanMacro(DirectionalLine, bool);
207 
211  vtkLineRepresentation* GetLineRepresentation(int index);
212 
217  vtkMTimeType GetMTime() override;
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 
245 protected:
247  ~vtkMultiLineRepresentation() override;
248 
249 private:
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 
293 VTK_ABI_NAMESPACE_END
294 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instances of this class.
void GetBounds(T a, double bds[6])
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
virtual void SetRenderer(vtkRenderer *ren)
Subclasses of vtkWidgetRepresentation must implement these methods.
abstract specification for renderers
Definition: vtkRenderer.h:63
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
int RenderOpaqueGeometry(vtkViewport *viewport) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
abstract class defines interface between the widget and widget representation classes ...
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
dynamic, self-adjusting array of double
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
void SetInteractionColor(double c[3])
Set the widget color, and the color of interactive handles.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
a simple class to control print indentation
Definition: vtkIndent.h:28
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual vtkMTimeType GetMTime()
Return this object's modified time.
void SetForegroundColor(double c[3])
Set the widget color, and the color of interactive handles.
#define VTK_SIZEHINT(...)
#define VTK_MARSHALEXCLUDE(reason)
vtkTypeBool HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
a class defining the representation for a vtkMultiLineWidget
#define VTK_MARSHALAUTO
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
implicit function for a bounding box
Definition: vtkBox.h:30
a class defining the representation for a vtkLineWidget2
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL