ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvConstrainedPolyLineRepresentation.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #ifndef CV_CONSTRAINED_POLYLINE_REPRESENTATION_H
9 #define CV_CONSTRAINED_POLYLINE_REPRESENTATION_H
10 
11 #include <vtkPolyLineRepresentation.h>
12 
13 class vtkTextActor;
14 class vtkActor2D;
15 class vtkPolyData;
16 class vtkPolyDataMapper2D;
17 class vtkHandleRepresentation;
18 
35 class cvConstrainedPolyLineRepresentation : public vtkPolyLineRepresentation {
36 public:
39  vtkPolyLineRepresentation);
40 
49  void BuildRepresentation() override;
50 
57  void SetRenderer(vtkRenderer* ren) override;
58 
67  double GetAngle();
68 
70 
81  void SetPoint1WorldPosition(double pos[3]) {
82  this->SetHandlePosition(0, pos);
83  }
84  void GetPoint1WorldPosition(double pos[3]) {
85  this->GetHandlePosition(0, pos);
86  }
87  void SetPoint1DisplayPosition(double pos[3]);
88  void GetPoint1DisplayPosition(double pos[3]);
89 
90  void SetCenterWorldPosition(double pos[3]) {
91  this->SetHandlePosition(1, pos);
92  }
93  void GetCenterWorldPosition(double pos[3]) {
94  this->GetHandlePosition(1, pos);
95  }
96  void SetCenterDisplayPosition(double pos[3]);
97  void GetCenterDisplayPosition(double pos[3]);
98 
99  void SetPoint2WorldPosition(double pos[3]) {
100  this->SetHandlePosition(2, pos);
101  }
102  void GetPoint2WorldPosition(double pos[3]) {
103  this->GetHandlePosition(2, pos);
104  }
105  void SetPoint2DisplayPosition(double pos[3]);
106  void GetPoint2DisplayPosition(double pos[3]);
107 
114  vtkHandleRepresentation* GetPoint1Representation();
115  vtkHandleRepresentation* GetCenterRepresentation();
116  vtkHandleRepresentation* GetPoint2Representation();
117 
125  // vtkPolyLineRepresentation automatically creates handles
126  // when SetNumberOfHandles is called
127  }
128 
132  void SetVisibility(vtkTypeBool visible) override;
134 
136 
143 
145 
151 
153 
156  vtkSetMacro(ShowAngleArc, vtkTypeBool);
157  vtkGetMacro(ShowAngleArc, vtkTypeBool);
160 
162 
165  vtkSetClampMacro(ArcRadius, double, 0.0, VTK_DOUBLE_MAX);
168 
173 
178 
182  void ReleaseGraphicsResources(vtkWindow* w) override;
183 
187  void GetActors2D(vtkPropCollection* pc) override;
188  int RenderOverlay(vtkViewport* viewport) override;
189  int RenderOpaqueGeometry(vtkViewport* viewport) override;
190  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
191  vtkTypeBool HasTranslucentPolygonalGeometry() override;
192 
193 protected:
196 
200  void BuildAngleArc();
201 
202  // Display properties
203  vtkTypeBool ShowAngleLabel;
204  vtkTypeBool ShowAngleArc;
205  double ArcRadius;
206  double Angle; // Stored angle in degrees
207  char* LabelSuffix; // Instance label suffix (e.g., " #1", " #2")
208 
209  // Angle label (text)
210  vtkTextActor* AngleLabelActor;
211 
212  // Angle arc (visual indicator)
213  vtkActor2D* AngleArcActor;
214  vtkPolyDataMapper2D* AngleArcMapper;
215  vtkPolyData* AngleArcPolyData;
216 
217 private:
219  const cvConstrainedPolyLineRepresentation&) = delete;
220  void operator=(const cvConstrainedPolyLineRepresentation&) = delete;
221 };
222 
223 #endif // CV_CONSTRAINED_POLYLINE_REPRESENTATION_H
Extended PolyLineRepresentation adding angle display functionality.
void SetVisibility(vtkTypeBool visible) override
Override SetVisibility to also control arc and label actors.
vtkSetMacro(ShowAngleArc, vtkTypeBool)
Control visibility of the angle arc.
int RenderOpaqueGeometry(vtkViewport *viewport) override
vtkTypeMacro(cvConstrainedPolyLineRepresentation, vtkPolyLineRepresentation)
vtkHandleRepresentation * GetPoint1Representation()
Compatibility: Get handle representations.
vtkBooleanMacro(ShowAngleLabel, vtkTypeBool)
void SetRenderer(vtkRenderer *ren) override
Set the renderer for this representation.
vtkSetClampMacro(ArcRadius, double, 0.0, VTK_DOUBLE_MAX)
Set/Get the radius of the angle arc.
vtkSetMacro(ShowAngleLabel, vtkTypeBool)
Control visibility of the angle label.
vtkBooleanMacro(ShowAngleArc, vtkTypeBool)
double GetAngle()
Calculate the angle formed by the three handles.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
void GetActors2D(vtkPropCollection *pc) override
Render the angle representation.
vtkGetMacro(ShowAngleArc, vtkTypeBool)
void InstantiateHandleRepresentation()
Compatibility: Instantiate handle representations.
void BuildRepresentation() override
Build the representation for the angle measurement.
void ReleaseGraphicsResources(vtkWindow *w) override
Release graphics resources.
vtkSetStringMacro(LabelSuffix)
Set/Get angle label suffix (e.g., " #1", " #2")
vtkGetObjectMacro(AngleLabelActor, vtkTextActor)
Get the angle label actor for custom styling.
static cvConstrainedPolyLineRepresentation * New()
vtkGetObjectMacro(AngleArcActor, vtkActor2D)
Get the angle arc actor for custom styling.
void SetPoint1WorldPosition(double pos[3])
Compatibility API for vtkAngleRepresentation.
vtkGetMacro(ShowAngleLabel, vtkTypeBool)