ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvProtractorTool.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 #pragma once
9 
11 #include "ui_cvProtractorToolDlg.h"
12 
13 // Forward declarations for VTK classes
15 
16 // Include the custom constrained widgets and representations
19 
21  Q_OBJECT
22 
23 public:
24  explicit cvProtractorTool(QWidget* parent = nullptr);
25  ~cvProtractorTool() override;
26 
27  virtual void start() override;
28  virtual void reset() override;
29  virtual void showWidget(bool state) override;
30  virtual ccHObject* getOutput() override;
31 
32  virtual double getMeasurementValue() const override;
33  virtual void getPoint1(double pos[3]) const override;
34  virtual void getPoint2(double pos[3]) const override;
35  virtual void getCenter(double pos[3]) const override;
36  virtual void setPoint1(double pos[3]) override;
37  virtual void setPoint2(double pos[3]) override;
38  virtual void setCenter(double pos[3]) override;
39  virtual void setColor(double r, double g, double b) override;
40  virtual bool getColor(double& r, double& g, double& b) const override;
41  virtual void lockInteraction() override;
42  virtual void unlockInteraction() override;
43  virtual void setInstanceLabel(const QString& label) override;
44  // Font property setters are now implemented in base class
45  // Only applyFontProperties() needs to be overridden
46 
47 protected:
48  virtual void initTool() override;
49  virtual void createUi() override;
50  virtual void setupPointPickingShortcuts(QWidget* vtkWidget) override;
51 
52 private slots:
54  void pickKeyboardPoint1(double x, double y, double z);
55  void pickKeyboardCenter(double x, double y, double z);
56  void pickKeyboardPoint2(double x, double y, double z);
57 
58  void on_point1XSpinBox_valueChanged(double arg1);
59  void on_point1YSpinBox_valueChanged(double arg1);
60  void on_point1ZSpinBox_valueChanged(double arg1);
61  void on_centerXSpinBox_valueChanged(double arg1);
62  void on_centerYSpinBox_valueChanged(double arg1);
63  void on_centerZSpinBox_valueChanged(double arg1);
64  void on_point2XSpinBox_valueChanged(double arg1);
65  void on_point2YSpinBox_valueChanged(double arg1);
66  void on_point2ZSpinBox_valueChanged(double arg1);
67  void onAngleChanged(double angle);
68  void onWorldPoint1Changed(double* pos);
69  void onWorldPoint2Changed(double* pos);
70  void onWorldCenterChanged(double* pos);
71  void on_pickPoint1_toggled(bool checked);
72  void on_pickCenter_toggled(bool checked);
73  void on_pickPoint2_toggled(bool checked);
74  void on_widgetVisibilityCheckBox_toggled(bool checked);
75  void on_arcVisibilityCheckBox_toggled(bool checked);
76 
77 private:
78  void hookWidget(const vtkSmartPointer<cvConstrainedPolyLineWidget>& widget);
79  void updateAngleDisplay();
80 
82  void applyTextPropertiesToLabel();
83 
84  Ui::ProtractorToolDlg* m_configUi = nullptr;
86  m_widget; // Using PolyLineWidget (100% ParaView consistency)
88  m_rep; // PolyLine with 3 handles for angle measurement
89 
91  double m_currentColor[3] = {0.0, 1.0, 0.0}; // Default green
92 
94  QString m_instanceLabel;
95 
98  void applyFontProperties() override;
99 };
cc2DLabel::addPickedPoint
bool addPickedPoint(ccGenericPointCloud *cloud, unsigned pointIndex, bool entityCenter=false)
Adds a point to this label.
Definition: ecv2DLabel.cpp:400
cvMeasurementToolsCommon.h
cvProtractorTool::~cvProtractorTool
~cvProtractorTool() override
Definition: cvProtractorTool.cpp:111
cvProtractorTool
Definition: cvProtractorTool.h:20
cvGenericMeasurementTool::m_fontOpacity
double m_fontOpacity
Definition: cvGenericMeasurementTool.h:238
cvGenericMeasurementTool::m_ui
Ui::GenericMeasurementToolDlg * m_ui
Definition: cvGenericMeasurementTool.h:215
ccObject::isKindOf
bool isKindOf(CV_CLASS_ENUM type) const
Definition: ecvObject.h:128
cvPointPickingHelper::setRenderer
void setRenderer(vtkRenderer *renderer)
Set the VTK renderer for picking.
Definition: cvPointPickingHelper.cpp:104
cc2DLabel::setDisplayedIn2D
void setDisplayedIn2D(bool state)
Whether to display the label in 2D.
Definition: ecv2DLabel.h:114
cvGenericMeasurementTool.h
cvGenericMeasurementTool::m_fontSize
int m_fontSize
Definition: cvGenericMeasurementTool.h:233
cvGenericMeasurementTool::m_pickingHelpers
QList< cvPointPickingHelper * > m_pickingHelpers
List of point picking helpers for keyboard shortcuts.
Definition: cvGenericMeasurementTool.h:226
x
normal_z x
Definition: my_point_types.h:165
cloudViewer::BoundingBoxTpl::getCenter
Vector3Tpl< T > getCenter() const
Returns center.
Definition: BoundingBox.h:164
Tuple3Tpl::x
Type x
Definition: CVGeom.h:137
VtkUtils::SignalBlocker
Definition: signalblocker.h:16
cloudViewer::GenericCloud::size
virtual unsigned size() const =0
Returns the number of points.
cc2DLabel::displayPointLegend
void displayPointLegend(bool state)
Whether to display the point(s) legend (title only)
Definition: ecv2DLabel.h:108
offset
int offset
Definition: FileIOFactory.cpp:135
Vector3Tpl::norm
Type norm() const
Returns vector norm.
Definition: CVGeom.h:424
cvProtractorTool::getPoint2
virtual void getPoint2(double pos[3]) const override
Get point 2 coordinates.
Definition: cvProtractorTool.cpp:803
cvPointPickingHelper::pick
void pick(double x, double y, double z)
Emitted when a point is picked.
ccHObjectCaster::ToPointCloud
static ccPointCloud * ToPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccPointCloud.
Definition: ecvHObjectCaster.cpp:54
cvGenericMeasurementTool::m_fontBold
bool m_fontBold
Definition: cvGenericMeasurementTool.h:235
CV_TYPES::MESH
@ MESH
Definition: CVTypes.h:105
CVLog::PrintVerbose
static bool PrintVerbose(const char *format,...)
Prints out a verbose formatted message in console.
Definition: CVLog.cpp:103
cvProtractorTool::getMeasurementValue
virtual double getMeasurementValue() const override
Get measurement value (distance or angle)
Definition: cvProtractorTool.cpp:786
ccBBox
Bounding box structure.
Definition: ecvBBox.h:25
CVLog::Print
static bool Print(const char *format,...)
Prints out a formatted message in console.
Definition: CVLog.cpp:113
CV_TYPES::POINT_CLOUD
@ POINT_CLOUD
Definition: CVTypes.h:104
cvGenericMeasurementTool::m_entity
ccHObject * m_entity
Definition: cvGenericMeasurementTool.h:218
ccGenericMesh::getAssociatedCloud
virtual ccGenericPointCloud * getAssociatedCloud() const =0
Returns the vertices cloud.
ecvBBox.h
cvProtractorTool::setColor
virtual void setColor(double r, double g, double b) override
Set measurement color (RGB values in range [0.0, 1.0])
Definition: cvProtractorTool.cpp:922
signalblocker.h
CVLog.h
cloudViewer::PointCloudTpl::size
unsigned size() const override
Definition: PointCloudTpl.h:38
cloudViewer::core::Minimum
Tensor Minimum(const Tensor &input, const Tensor &other)
Computes the element-wise minimum of input and other. The tensors must have same data type and device...
Definition: TensorFunction.cpp:136
ccPointCloud
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ecvPointCloud.h:146
cvProtractorTool::createUi
virtual void createUi() override
Definition: cvProtractorTool.cpp:254
cc2DLabel
2D label (typically attached to points)
Definition: ecv2DLabel.h:22
vtkSmartPointer
Definition: WidgetMap.h:20
CVLog::PrintDebug
static bool PrintDebug(const char *format,...)
Same as Print, but works only in Debug mode.
Definition: CVLog.cpp:153
cvProtractorTool::setInstanceLabel
virtual void setInstanceLabel(const QString &label) override
Set instance label suffix (e.g., "#1", "#2") for display in 3D view.
Definition: cvProtractorTool.cpp:1191
cvGenericMeasurementTool::m_fontColor
double m_fontColor[3]
Definition: cvGenericMeasurementTool.h:234
cvGenericMeasurementTool::m_horizontalJustification
QString m_horizontalJustification
Definition: cvGenericMeasurementTool.h:239
cc2DLabel::setPosition
void setPosition(float x, float y)
Sets relative position.
Definition: ecv2DLabel.cpp:225
ecvGenericMesh.h
VtkUtils::vtkInitOnce
void vtkInitOnce(T **obj)
Definition: vtkutils.h:44
cvGenericMeasurementTool::measurementValueChanged
void measurementValueChanged()
Signal sent when the measurement value changes.
CVLog::Error
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Definition: CVLog.cpp:143
slots
#define slots
Definition: PythonPlugin.cpp:25
y
normal_z y
Definition: my_point_types.h:168
ccGenericPointCloud
A 3D cloud interface with associated features (color, normals, octree, etc.)
Definition: ecvGenericPointCloud.h:45
cvProtractorTool::setPoint1
virtual void setPoint1(double pos[3]) override
Set point 1 coordinates.
Definition: cvProtractorTool.cpp:823
Vector3Tpl< PointCoordinateType >
cc2DLabel::setCollapsed
void setCollapsed(bool state)
Whether to collapse label or not.
Definition: ecv2DLabel.h:102
ecv2DLabel.h
ecvGenericPointCloud.h
cvGenericMeasurementTool
Definition: cvGenericMeasurementTool.h:40
cvPointPickingHelper::setContextWidget
void setContextWidget(QWidget *widget)
Set the context widget for the shortcut.
Definition: cvPointPickingHelper.cpp:109
cvProtractorTool::start
virtual void start() override
Definition: cvProtractorTool.cpp:392
cvMeasurementTools::RAY_COLOR
constexpr double RAY_COLOR[3]
Definition: cvMeasurementToolsCommon.h:21
cloudViewer::BoundingBoxTpl::isValid
bool isValid() const
Returns whether bounding box is valid or not.
Definition: BoundingBox.h:203
ccPointCloud::reserve
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
Definition: ecvPointCloud.cpp:1452
cvConstrainedPolyLineWidget.h
cvGenericMeasurementTool::pointPickingRequested
void pointPickingRequested(int pointIndex)
anglewidgetobserver.h
cvGenericMeasurementTool::update
virtual void update()
Definition: cvGenericMeasurementTool.cpp:175
cvGenericMeasurementTool::m_renderer
vtkRenderer * m_renderer
Definition: cvGenericMeasurementTool.h:221
ccGenericMesh
Generic mesh interface.
Definition: ecvGenericMesh.h:28
cvProtractorTool::unlockInteraction
virtual void unlockInteraction() override
Unlock tool interaction (enable VTK widget interaction and UI controls)
Definition: cvProtractorTool.cpp:1048
cvProtractorTool::getCenter
virtual void getCenter(double pos[3]) const override
Get center point coordinates (for angle/protractor)
Definition: cvProtractorTool.cpp:813
callback
std::function< void(std::shared_ptr< core::Tensor >)> callback
Definition: FilamentRenderer.cpp:183
ccDrawableObject::setVisible
virtual void setVisible(bool state)
Sets entity visibility.
Definition: ecvDrawableObject.h:40
vtkutils.h
Tuple3Tpl::z
Type z
Definition: CVGeom.h:137
cvProtractorTool::setPoint2
virtual void setPoint2(double pos[3]) override
Set point 2 coordinates.
Definition: cvProtractorTool.cpp:856
cvGenericMeasurementTool::disableShortcuts
void disableShortcuts()
Disable all keyboard shortcuts (call before tool destruction)
Definition: cvGenericMeasurementTool.cpp:245
cvMeasurementTools::INTERACTION_COLOR
constexpr double INTERACTION_COLOR[3]
Definition: cvMeasurementToolsCommon.h:19
cvProtractorTool::initTool
virtual void initTool() override
Definition: cvProtractorTool.cpp:141
cvPointPickingHelper.h
ccHObject::getBB_recursive
virtual ccBBox getBB_recursive(bool withGLFeatures=false, bool onlyEnabledChildren=true)
Returns the bounding-box of this entity and it's children.
Definition: ecvHObject.cpp:759
cvProtractorTool::setupPointPickingShortcuts
virtual void setupPointPickingShortcuts(QWidget *vtkWidget) override
Definition: cvProtractorTool.cpp:478
ecvHObjectCaster.h
cloudViewer::GenericIndexedCloud::getPoint
virtual const CCVector3 * getPoint(unsigned index) const =0
Returns the ith point.
cvGenericMeasurementTool::pointPickingCancelled
void pointPickingCancelled()
Signal sent when point picking is cancelled.
cvProtractorTool.h
cvGenericMeasurementTool::m_interactor
vtkRenderWindowInteractor * m_interactor
Definition: cvGenericMeasurementTool.h:220
cvGenericMeasurementTool::start
virtual void start()
Definition: cvGenericMeasurementTool.cpp:75
cvProtractorTool::lockInteraction
virtual void lockInteraction() override
Lock tool interaction (disable VTK widget interaction and UI controls)
Definition: cvProtractorTool.cpp:955
cvProtractorTool::getOutput
virtual ccHObject * getOutput() override
Definition: cvProtractorTool.cpp:571
CVLog::Warning
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
cvProtractorTool::reset
virtual void reset() override
Definition: cvProtractorTool.cpp:399
cvGenericMeasurementTool::m_fontShadow
bool m_fontShadow
Definition: cvGenericMeasurementTool.h:237
cloudViewer::BoundingBoxTpl::getDiagVec
Vector3Tpl< T > getDiagVec() const
Returns diagonal vector.
Definition: BoundingBox.h:169
ccHObject
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
Tuple3Tpl::y
Type y
Definition: CVGeom.h:137
cvMeasurementTools
Definition: cvMeasurementToolsCommon.h:14
cvConstrainedPolyLineRepresentation.h
cvGenericMeasurementTool::m_verticalJustification
QString m_verticalJustification
Definition: cvGenericMeasurementTool.h:240
cvProtractorTool::cvProtractorTool
cvProtractorTool(QWidget *parent=nullptr)
Definition: cvProtractorTool.cpp:102
cvPointPickingHelper::setInteractor
void setInteractor(vtkRenderWindowInteractor *interactor)
Set the VTK interactor for picking.
Definition: cvPointPickingHelper.cpp:98
cvGenericMeasurementTool::updatePickingHelpers
void updatePickingHelpers()
Update point picking helpers with current interactor/renderer.
Definition: cvGenericMeasurementTool.cpp:236
cloudViewer::PointCloudTpl::addPoint
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
Definition: PointCloudTpl.h:246
cvGenericMeasurementTool::m_vtkWidget
QWidget * m_vtkWidget
VTK widget reference for creating shortcuts (saved from linkWith)
Definition: cvGenericMeasurementTool.h:229
cvProtractorTool::getPoint1
virtual void getPoint1(double pos[3]) const override
Get point 1 coordinates.
Definition: cvProtractorTool.cpp:793
PointCoordinateType
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
z
normal_z z
Definition: my_point_types.h:165
cvGenericMeasurementTool::m_fontFamily
QString m_fontFamily
Font properties for measurement labels (shared by all tools)
Definition: cvGenericMeasurementTool.h:232
cvProtractorTool::getColor
virtual bool getColor(double &r, double &g, double &b) const override
Definition: cvProtractorTool.cpp:948
cvGenericMeasurementTool::setupShortcuts
void setupShortcuts(QWidget *vtkWidget)
Definition: cvGenericMeasurementTool.cpp:95
ccObject::setEnabled
virtual void setEnabled(bool state)
Sets the "enabled" property.
Definition: ecvObject.h:102
ecvHObject.h
cvPointPickingHelper
cvPointPickingHelper is a helper class for supporting keyboard shortcut-based point picking in measur...
Definition: cvPointPickingHelper.h:43
ecvPointCloud.h
cvMeasurementTools::FOREGROUND_COLOR
constexpr double FOREGROUND_COLOR[3]
Definition: cvMeasurementToolsCommon.h:17
cvProtractorTool::showWidget
virtual void showWidget(bool state) override
Definition: cvProtractorTool.cpp:542
cvGenericMeasurementTool::m_fontItalic
bool m_fontItalic
Definition: cvGenericMeasurementTool.h:236
cvConstrainedPolyLineRepresentation
Extended PolyLineRepresentation adding angle display functionality.
Definition: cvConstrainedPolyLineRepresentation.h:35
cvProtractorTool::setCenter
virtual void setCenter(double pos[3]) override
Set center point coordinates (for angle/protractor)
Definition: cvProtractorTool.cpp:889