ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
BasePclModule.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 // Qt
11 #include <QIcon>
12 #include <QObject>
13 #include <QString>
14 
15 // CV_DB_LIB
16 #include <ecvHObject.h>
17 
18 // ECV_PLUGINS
19 #include <ecvPluginInterface.h>
20 
21 class QAction;
22 class ccPointCloud;
24 
27 public:
28  QString m_module_name;
29  QString m_entry_name;
30  QString m_status_tip;
31  QIcon m_icon;
32 
34  : m_module_name("PCLModule"),
35  m_entry_name("module"),
36  m_status_tip("Compute something with PCL"),
37  m_icon(QIcon(QString::fromUtf8(":/toolbar/pcl.png"))) {}
38 
39  PclModuleDescription(QString filterName,
40  QString entryName,
41  QString statusTip,
42  QString icon)
43  : m_module_name(filterName),
44  m_entry_name(entryName),
45  m_status_tip(statusTip),
46  m_icon(QIcon(icon)) {}
47 };
48 
50 
53 class BasePclModule : public QObject {
54  Q_OBJECT
55 
56 public:
62  ccPluginInterface* parent_plugin = 0);
63 
67  QAction* getAction();
68 
70 
75  virtual QString getErrorMessage(int errorCode);
76 
78 
81  QString getStatusTip() const;
82 
84  QString getModuleName() const;
85 
87 
89  QString getEntryName() const;
90 
92  QIcon getIcon() const;
93 
95  void setShowProgressBar(bool status) { m_show_progress = status; }
96 
99 
101  std::vector<std::string> getSelectedAvailableScalarFields();
102 
104 
107 
109 
112 
114  ccHObject::Container getSelectedThatHaveMetaData(const QString key) const;
115 
118  ccHObject::Container& entities);
119 
122 
124  void getAllEntitiesThatHaveMetaData(QString key,
125  ccHObject::Container& entities);
126 
129 
133  ccHObject::Container& entities);
134 
136  int hasSelectedRGB();
137 
140 
143  int hasSelectedScalarField(std::string field_name);
144 
147 
149 
151  virtual void updateSelectedEntities(
152  const ccHObject::Container& selectedEntities);
153 
155 
158  virtual int compute() = 0;
159 
162 
166 
169 
170 protected slots:
171 
173 
178  // DGM: useless as dialogs are always modal
179  // virtual int dialogAccepted();
180 
182 
184  int performAction();
185 
186 signals:
187 
190 
193 
195  void newErrorMessage(QString);
196 
197 protected:
199 
205  virtual int checkSelected();
206 
209 
215  virtual int openInputDialog() { return 1; }
216 
219 
225  virtual int openOutputDialog() { return 1; }
226 
228 
231  virtual void getParametersFromDialog() {}
232 
235 
239  virtual int checkParameters() { return 1; }
240 
242 
247  virtual int start();
248 
250 
252  virtual void initAction();
253 
256 
260  void throwError(int errCode);
261 
263 
265  // DGM: dirty! library has no access to GUI (see MVC architecture)
266  // virtual void updateUi();
267 
269  QAction* m_action;
270 
272 
274  // DGM: dirty! library has no access to GUI (see MVC architecture)
275  // MainWindow * m_q_parent;
276 
278 
282 
284 
286  // DGM: dirty! some siblings must define the same variable with a different
287  // type! QFileDialog * m_dialog;
288 
290 
294 
297 
300 
303 };
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
char type
#define slots
#define signals
Base abstract class for each implemented PCL filter.
Definition: BasePclModule.h:53
virtual void initAction()
Initializes the corresponding action.
std::vector< std::string > getSelectedAvailableScalarFields()
ccPluginInterface * m_parent_plugin
associated parent plugin of the filter
int hasSelectedRGB()
Returns 1 if the first selected entity has RGB info.
QAction * getAction()
Get the action associated with the button used in menu and toolbar creation.
QString getStatusTip() const
Returns the status tip.
void throwError(int errCode)
int isFirstSelectedCcPointCloud()
Returns 1 if the first selected object is a ccPointCloud.
virtual void updateSelectedEntities(const ccHObject::Container &selectedEntities)
Updates the internal copy of selected entities.
ecvMainAppInterface * getMainAppInterface()
PclModuleDescription m_desc
Associated dialog.
QString getEntryName() const
Returns the entry name.
void newEntity(ccHObject *)
Signal emitted when a new entity is created by the filter.
QString getModuleName() const
Returns the name of the filter.
virtual int checkParameters()
void getAllEntitiesThatHaveMetaData(QString key, ccHObject::Container &entities)
ccHObject::Container getSelectedThatHaveMetaData(const QString key) const
Get selected object that also have the provided metadata key.
virtual int openOutputDialog()
void getSelectedEntitiesThatAre(CV_CLASS_ENUM kind, ccHObject::Container &entities)
ecvMainAppInterface * m_app
Associated application interface.
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
QAction * m_action
Forces the Ui to be updated.
virtual int compute()=0
Performs the actual filter job.
void getAllEntitiesOfType(CV_CLASS_ENUM type, ccHObject::Container &entities)
Returns all the objects in db tree of type "type".
int performAction()
Returns is called when the dialog window is accepted.
BasePclModule(PclModuleDescription desc=PclModuleDescription(), ccPluginInterface *parent_plugin=0)
Default constructor.
int hasSelectedScalarField()
Returns 1 if the first selected entity has at least one scalar field.
void newErrorMessage(QString)
Signal emitted when a new error message is produced.
void setShowProgressBar(bool status)
Sets whether to show a progressbar while computing or not.
Definition: BasePclModule.h:95
virtual int start()
Starts computation.
void getSelectedEntitiesThatAreCCPointCloud(ccHObject::Container &entities)
get all entities that are selected and that also are cc_point_cloud
bool m_show_progress
Do we want to show a progress bar when the filter works?
ccPointCloud * getSelectedEntityAsCCPointCloud() const
Returns the first selected entity as a ccPointCloud.
QIcon getIcon() const
Returns the icon associated with the button.
ccPluginInterface * getParentPlugin() const
Returns the associated parent plugin interface.
ccHObject::Container m_selected
Pointer to the main window.
void setMainAppInterface(ecvMainAppInterface *app)
Sets associated CC application interface (to access DB)
virtual int openInputDialog()
ccHObject * getSelectedEntityAsCCHObject() const
Returns the first selected entity as a ccHObject.
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual int checkSelected()
Checks if current selection is compliant with the filter.
void entityHasChanged(ccHObject *)
Signal emitted when an entity is (visually) modified.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
Standard ECV plugin interface.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Main application interface (for plugins)
PCL filter description.
Definition: BasePclModule.h:26
PclModuleDescription(QString filterName, QString entryName, QString statusTip, QString icon)
Definition: BasePclModule.h:39