forked from hvs-ait/mplane-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqMPlane.cpp
86 lines (75 loc) · 2.56 KB
/
qMPlane.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//##########################################################################
//# #
//# CLOUDCOMPARE PLUGIN: qMPlane #
//# #
//# This program is free software; you can redistribute it and/or modify #
//# it under the terms of the GNU General Public License as published by #
//# the Free Software Foundation; version 2 of the License. #
//# #
//# This program is distributed in the hope that it will be useful, #
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
//# GNU General Public License for more details. #
//# #
//# COPYRIGHT: AIT Austrian Institute of Technology GmbH #
//# #
//##########################################################################
// Qt
#include <QtGui>
#include <QTableWidget>
// CC
#include <ccPickingHub.h>
// qCC_db
#include <ccHObject.h>
#include <ccScalarField.h>
#include <ccPlane.h>
// CCCoreLib
#include <DistanceComputationTools.h>
// Local dependencies
#include "qMPlane.h"
qMPlane::qMPlane( QObject *parent )
: QObject( parent )
, ccStdPluginInterface( ":/CC/plugin/qMPlane/info.json" )
, m_action( nullptr )
{
}
QList<QAction *> qMPlane::getActions()
{
if (!m_action)
{
m_action = new QAction(getName(), this);
m_action->setToolTip(getDescription());
m_action->setIcon(getIcon());
connect(m_action, &QAction::triggered, this, &qMPlane::doAction);
}
return{ m_action };
}
// Called when an item is selected
void qMPlane::onNewSelection( const ccHObject::Container &selectedEntities )
{
if ( m_action == nullptr )
{
return;
}
m_action->setEnabled(false);
if(selectedEntities.size() == 1) {
ccHObject *object = selectedEntities.at(0);
if (object->getClassID() == static_cast<CC_CLASS_ENUM>(CC_TYPES::POINT_CLOUD)) {
m_selectedCloud = static_cast<ccPointCloud*>(object);
m_action->setEnabled(true);
}
}
}
// Called when plugin icon is clicked
void qMPlane::doAction()
{
if (m_app == nullptr)
{
Q_ASSERT(false);
return;
}
if (!m_controller) {
m_controller = std::make_unique<ccMPlaneDlgController>(m_app);
}
m_controller->openDialog(m_selectedCloud);
}