ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvPointPairRegistrationDlg.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 
10 // Local
11 #include "ecvOverlayDialog.h"
12 #include "ecvPickingListener.h"
13 
14 // CV_CORE_LIB
15 #include <PointProjectionTools.h>
16 
17 // CV_DB_LIB
18 #include <ecvPointCloud.h>
19 
20 #include "ecvMainAppInterface.h"
21 
22 // Qt generated dialog
23 #include <ui_pointPairRegistrationDlg.h>
24 
26 class cc2DLabel;
27 class ccPickingHub;
28 
29 // Dialog for the point-pair registration algorithm (Horn)
31  public ccPickingListener,
32  Ui::pointPairRegistrationDlg {
33  Q_OBJECT
34 
35 public:
37  explicit ccPointPairRegistrationDlg(ccPickingHub* pickingHub,
39  QWidget* parent = nullptr);
40 
41  // inherited from ccOverlayDialog
42  bool linkWith(QWidget* win) override;
43  bool start() override;
44  void stop(bool state) override;
45 
47  bool init(QWidget* win,
48  const ccHObject::Container& alignedEntities,
49  const ccHObject::Container* referenceEntities = nullptr);
50 
52  void clear();
53 
55  void pause(bool state);
56 
59  ccHObject* entity = nullptr,
60  bool shifted = true);
63  ccHObject* entity = nullptr,
64  bool shifted = true);
65 
67  void removeAlignedPoint(int index, bool autoRemoveDualPoint = true);
69  void removeRefPoint(int index, bool autoRemoveDualPoint = true);
70 
71  void updateRefMarkers(int index);
72 
74  void onItemPicked(const PickedItem& pi) override;
75 
76 protected slots:
77 
79  void showAlignedEntities(bool);
81  void showReferenceEntities(bool);
82 
84  void addManualAlignedPoint();
86  void addManualRefPoint();
87 
89  void unstackAligned();
90 
91  void updateSphereMarks(ccHObject* obj, bool remove);
92  void updateAlignedMarkers(int index);
94  void unstackRef();
95 
97  void onDelButtonPushed();
98 
100  void updateAlignInfo();
101 
102  void apply();
103  void align();
104  void reset();
105  void cancel();
106  void updateAllMarkers(float markerSize);
107 
108 protected slots:
109 
110  void label2DMove(int x, int y, int dx, int dy);
111 
112 protected:
114 
115  void transformAlignedEntity(const ccGLMatrix& transMat, bool apply = true);
116 
118  void onPointCountChanged();
119 
123  double& rms,
124  bool autoUpdateTab);
125 
127  void clearRMSColumns();
128 
130  void addPointToTable(QTableWidget* tableWidget,
131  int rowIndex,
132  const CCVector3d& P,
133  QString pointLabel);
134 
136 
142  ccHObject* entity,
143  PointCoordinateType& sphereRadius);
144 
146  void resetTitle();
147 
149  struct EntityContext {
151  explicit EntityContext(ccHObject* ent);
152 
154  void restore();
155 
160  };
161 
163  struct EntityContexts : public QMap<ccHObject*, EntityContext> {
164  void fill(const ccHObject::Container& entities);
165 
166  void restoreAll() {
167  for (EntityContext& ctx : *this) ctx.restore();
168  }
169 
170  bool isShifted;
172  };
173 
176 
179 
182 
185 
188 
190 
192  bool m_paused;
193 
196 
199 };
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
#define slots
2D label (typically attached to points)
Definition: ecv2DLabel.h:22
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
A 3D cloud interface with associated features (color, normals, octree, etc.)
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
Generic overlay dialog interface.
Point/triangle picking hub.
Definition: ecvPickingHub.h:29
Point/triangle picking listener interface.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool start() override
Starts process.
void label2DMove(int x, int y, int dx, int dy)
EntityContexts m_alignedEntities
Aligned entity.
bool m_paused
Whether the dialog is paused or not.
void stop(bool state) override
Stops process/dialog.
EntityContexts m_referenceEntities
Reference entity (if any)
void onItemPicked(const PickedItem &pi) override
Inherited from ccPickingListener.
void unstackAligned()
Slot called to remove the last point on the 'align' stack.
void removeRefPoint(int index, bool autoRemoveDualPoint=true)
Removes a point from the 'reference' set.
bool convertToSphereCenter(CCVector3d &P, ccHObject *entity, PointCoordinateType &sphereRadius)
Converts a picked point to a sphere center (if necessary)
bool linkWith(QWidget *win) override
Links the overlay dialog with a MDI window.
void addManualRefPoint()
Slot called to add a manual point to the 'reference' set.
void unstackRef()
Slot called to remove the last point on the 'reference' stack.
void updateAlignInfo()
Updates the registration info and buttons states.
ccPickingHub * m_pickingHub
Picking hub.
void onDelButtonPushed()
Slot called when a "delete" button is pushed.
void resetTitle()
Resets the displayed title (3D view)
void addPointToTable(QTableWidget *tableWidget, int rowIndex, const CCVector3d &P, QString pointLabel)
Adds a point to one of the table (ref./aligned)
bool addAlignedPoint(CCVector3d &P, ccHObject *entity=nullptr, bool shifted=true)
Adds a point to the 'align' set.
bool callHornRegistration(cloudViewer::PointProjectionTools::Transformation &trans, double &rms, bool autoUpdateTab)
Calls Horn registration (cloudViewer::HornRegistrationTools)
void updateSphereMarks(ccHObject *obj, bool remove)
void onPointCountChanged()
Enables (or not) buttons depending on the number of points in both lists.
ccPointPairRegistrationDlg(ccPickingHub *pickingHub, ecvMainAppInterface *app, QWidget *parent=nullptr)
Default constructor.
void removeAlignedPoint(int index, bool autoRemoveDualPoint=true)
Removes a point from the 'align' set.
void clearRMSColumns()
Clears the RMS rows.
ecvMainAppInterface * m_app
Main application interface.
void addManualAlignedPoint()
Slot called to add a manual point to the 'align' set.
void transformAlignedEntity(const ccGLMatrix &transMat, bool apply=true)
void showAlignedEntities(bool)
Slot called to change aligned cloud visibility.
ccPointCloud m_alignedPoints
Aligned points set.
bool init(QWidget *win, const ccHObject::Container &alignedEntities, const ccHObject::Container *referenceEntities=nullptr)
Inits dialog.
ccPointCloud m_refPoints
Reference points set.
bool addReferencePoint(CCVector3d &P, ccHObject *entity=nullptr, bool shifted=true)
Adds a point to the 'reference' set.
void showReferenceEntities(bool)
Slot called to change reference cloud visibility.
void pause(bool state)
Pauses the dialog.
Main application interface (for plugins)
EntityContext(ccHObject *ent)
Default constructor.
void fill(const ccHObject::Container &entities)
A scaled geometrical transformation (scale + rotation + translation)