ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvGraphicalSegmentationTool.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 
13 // CV_DB_LIB
14 #include <ecvHObject.h>
15 
16 // QT
17 #include <QSet>
18 
19 // GUI
20 #include <ui_graphicalSegmentationDlg.h>
21 
22 class ccPolyline;
23 class ccPointCloud;
25 
28  public Ui::GraphicalSegmentationDlg {
29  Q_OBJECT
30 
31 public:
33  explicit ccGraphicalSegmentationTool(QWidget* parent);
36 
38 
42  bool addEntity(ccHObject* anObject, bool silent = false);
43 
46  unsigned getNumberOfValidEntities() const;
47 
50 
52  QSet<ccHObject*>& entities() { return m_toSegment; }
54  const QSet<ccHObject*>& entities() const { return m_toSegment; }
55 
56  // inherited from ccOverlayDialog
57  virtual bool linkWith(QWidget* win) override;
58  virtual bool start() override;
59  virtual void stop(bool accepted) override;
60 
62  bool deleteHiddenParts() const { return m_deleteHiddenParts; }
63 
65 
68  void removeAllEntities();
69 
72  ccHObject::Container& newEntities);
73 
74 protected slots:
75 
76  void segmentIn();
77  void segmentOut();
78  void segment(bool);
79  void reset();
80  void apply();
81  void applyAndDelete();
82  void cancel();
83  void addPointToPolyline(int x, int y);
84  void closePolyLine(int x = 0,
85  int y = 0); // arguments for compatibility with
86  // ccGlWindow::rightButtonClicked signal
87  void updateSegmentation();
88  void closeRectangle();
89  void updatePolyLine(int x, int y, Qt::MouseButtons buttons);
90  void pauseSegmentationMode(bool state, bool only2D = true);
91  inline void pauseSegmentation(bool state) { pauseSegmentationMode(state); }
92  void resetSegmentation();
97 
99  void onShortcutTriggered(int);
100 
102  void prepareEntityForRemoval(ccHObject* entity,
103  bool unallocateVisibilityArrays);
104 
106  void allowPolylineExport(bool state);
107 
108 protected:
109  void setDrawFlag(bool state = true);
110 
112  QSet<ccHObject*> m_toSegment;
113 
116 
119  POLYLINE = 1,
121  //... = 4,
122  //... = 8,
123  //... = 16,
124  PAUSED = 32,
125  STARTED = 64,
126  RUNNING = 128,
127  };
128 
130  unsigned m_state;
131 
136 
139 
142 };
#define slots
Graphical segmentation mechanism (with polyline)
virtual bool linkWith(QWidget *win) override
Links the overlay dialog with a MDI window.
void removeAllEntities()
Remove entities from the 'to be segmented' pool.
void allowPolylineExport(bool state)
Whether to allow or not to exort the current segmentation polyline.
const QSet< ccHObject * > & entities() const
Returns the active 'to be segmented' set (const version)
bool addEntity(ccHObject *anObject, bool silent=false)
Adds an entity (and/or its children) to the 'to be segmented' pool.
bool applySegmentation(ecvMainAppInterface *app, ccHObject::Container &newEntities)
Apply segmentation and update the database (helper)
void prepareEntityForRemoval(ccHObject *entity, bool unallocateVisibilityArrays)
Prepare entity before removal.
void pauseSegmentationMode(bool state, bool only2D=true)
QSet< ccHObject * > m_toSegment
Set of entities to be segmented.
bool deleteHiddenParts() const
Returns whether hidden parts should be delete after segmentation.
ccPolyline * getPolyLine()
Get a pointer to the polyline that has been segmented.
bool m_somethingHasChanged
Whether something has changed or not (for proper 'cancel')
ccPolyline * m_segmentationPoly
Segmentation polyline.
ccGraphicalSegmentationTool(QWidget *parent)
Default constructor.
unsigned m_state
Current process state.
bool m_deleteHiddenParts
Whether to delete hidden parts after segmentation.
void updatePolyLine(int x, int y, Qt::MouseButtons buttons)
virtual void stop(bool accepted) override
Stops process/dialog.
virtual bool start() override
Starts process.
void onShortcutTriggered(int)
To capture overridden shortcuts (pause button, etc.)
QSet< ccHObject * > & entities()
Returns the active 'to be segmented' set.
ccPointCloud * m_polyVertices
Segmentation polyline vertices.
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.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Colored polyline.
Definition: ecvPolyline.h:24
Main application interface (for plugins)