ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
qMPlane.cpp
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 #include <QtGui>
9 
10 // CV
12 #include "ecvHObject.h"
13 #include "ecvPickingHub.h"
14 #include "ecvPlane.h"
15 #include "ecvScalarField.h"
16 #include "qtablewidget.h"
17 
18 // Local dependencies
19 #include "qMPlane.h"
20 
21 qMPlane::qMPlane(QObject *parent)
22  : QObject(parent),
23  ccStdPluginInterface(":/CC/plugin/qMPlane/info.json"),
24  m_action(nullptr) {}
25 
26 QList<QAction *> qMPlane::getActions() {
27  if (!m_action) {
28  m_action = new QAction(getName(), this);
29  m_action->setToolTip(getDescription());
30  m_action->setIcon(getIcon());
31  connect(m_action, &QAction::triggered, this, &qMPlane::doAction);
32  }
33  return {m_action};
34 }
35 
36 // Called when an item is selected
37 void qMPlane::onNewSelection(const ccHObject::Container &selectedEntities) {
38  if (m_action == nullptr) {
39  return;
40  }
41 
42  m_action->setEnabled(false);
43  if (selectedEntities.size() == 1) {
44  ccHObject *object = selectedEntities.at(0);
45  if (object->isKindOf(CV_TYPES::POINT_CLOUD)) {
46  m_selectedCloud = static_cast<ccPointCloud *>(object);
47  m_action->setEnabled(true);
48  }
49  }
50 }
51 
52 // Called when plugin icon is clicked
54  if (m_app == nullptr) {
55  Q_ASSERT(false);
56  return;
57  }
58 
59  if (!m_controller) {
60  m_controller = std::make_unique<ccMPlaneDlgController>(m_app);
61  }
62  m_controller->openDialog(m_selectedCloud);
63 }
virtual QString getName() const override
Returns (short) name (for menu entry, etc.)
virtual QString getDescription() const override
Returns long name/description (for tooltip, etc.)
virtual QIcon getIcon() const override
Returns icon.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
Definition: ecvHObject.h:337
bool isKindOf(CV_CLASS_ENUM type) const
Definition: ecvObject.h:128
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Standard ECV plugin interface.
ecvMainAppInterface * m_app
Main application interface.
void onNewSelection(const ccHObject::Container &selectedEntities) override
Definition: qMPlane.cpp:37
void doAction()
Definition: qMPlane.cpp:53
qMPlane(QObject *parent=nullptr)
Definition: qMPlane.cpp:21
QList< QAction * > getActions() override
Get a list of actions for this plugin.
Definition: qMPlane.cpp:26
@ POINT_CLOUD
Definition: CVTypes.h:104