22 #include <qtconcurrentrun.h>
25 #include <QApplication>
27 #include <QProgressDialog>
30 #if defined(CV_WINDOWS)
39 : m_action(nullptr), m_desc(desc), m_show_progress(true) {
71 if (check_result != 1) {
78 if (dialog_result < 1) {
79 if (dialog_result < 0)
92 if (par_status != 1) {
98 int start_status =
start();
99 if (start_status != 1) {
106 if (out_dialog_result < 1) {
107 if (out_dialog_result < 0)
110 out_dialog_result = 1;
112 return out_dialog_result;
168 QProgressDialog progressCb(tr(
"Operation in progress"), QString(), 0, 0);
173 QApplication::processEvents();
181 QFuture<void> future = QtConcurrent::run(
doCompute);
182 while (!future.isFinished()) {
183 #if defined(CV_WINDOWS)
197 QApplication::processEvents();
223 errorMsg = QString(tr(
"No entity selected in tree."));
227 errorMsg = QString(tr(
"Too many entities selected."));
231 errorMsg = QString(tr(
"Wrong type of entity selected"));
236 errorMsg = QString(tr(
"Dialog was not correctly filled in"));
241 errorMsg = QString(tr(
"Errors while computing"));
244 errorMsg = QString(tr(
"Thread already in use!"));
249 errorMsg = tr(
"Undefined error in %1 module").arg(
getModuleName());
274 const QString key)
const {
277 for (
size_t i = 0; i <
m_selected.size(); ++i) {
298 for (ccHObject::Container::const_iterator it = tempContainer.begin();
299 it != tempContainer.end(); ++it) {
300 if ((*it)->hasMetaData(key)) entities.push_back(*it);
307 for (
size_t i = 0; i < selected.size(); ++i) {
310 entities.push_back(this_obj);
318 for (
size_t i = 0; i < selected.size(); ++i) {
320 if (this_obj->
isA(kind)) {
321 entities.push_back(this_obj);
328 if (!cloud)
return -1;
332 return (
result >= 0 ? 1 : 0);
339 if (!cloud)
return -1;
345 std::vector<std::string> field_names;
348 if (!cloud)
return field_names;
351 field_names.reserve(n_fields);
352 for (
unsigned i = 0; i < n_fields; i++)
static int s_computeStatus
static BasePclModule * s_module
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Base abstract class for each implemented PCL filter.
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.
PclModuleDescription m_desc
Associated dialog.
QString getEntryName() const
Returns the entry name.
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.
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.
ccHObject::Container m_selected
Pointer to the main window.
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.
static ccPointCloud * ToPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccPointCloud.
Hierarchical CLOUDVIEWER Object.
QString getViewId() const
void applyGLTransformation_recursive(const ccGLMatrix *trans=nullptr)
Applies the active OpenGL transformation to the entity (recursive)
void setRedrawFlagRecursive(bool redraw=false)
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
bool isA(CV_CLASS_ENUM type) const
bool hasMetaData(const QString &key) const
Returns whether a meta-data element with the given key exists or not.
Standard ECV plugin interface.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool hasColors() const override
Returns whether colors are enabled or not.
bool hasScalarFields() const override
Returns whether one or more scalar fields are instantiated.
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
unsigned getNumberOfScalarFields() const
Returns the number of associated (and active) scalar fields.
const char * getScalarFieldName(int index) const
Returns the name of a specific scalar field.
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual void putObjectBackIntoDBTree(ccHObject *obj, const ccHObjectContext &context)=0
Adds back object to DB tree.
virtual ccHObjectContext removeObjectTemporarilyFromDBTree(ccHObject *obj)=0
Removes object temporarily from DB tree.
void Sleep(int milliseconds)
Backup "context" for an object.