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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
//##########################################################################
//# #
//# CLOUDCOMPARE PLUGIN: qM3C2 #
//# #
//# 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 or later 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: UNIVERSITE EUROPEENNE DE BRETAGNE #
//# #
//##########################################################################
#include "qM3C2.h"
//local
#include "qM3C2Tools.h"
#include "qM3C2Dialog.h"
#include "qM3C2DisclaimerDialog.h"
#include "qM3C2Commands.h"
#include "qM3C2Process.h"
//qCC_db
#include <ccPointCloud.h>
qM3C2Plugin::qM3C2Plugin(QObject* parent)
: QObject(parent)
, ccStdPluginInterface( ":/CC/plugin/qM3C2Plugin/info.json" )
, m_action(nullptr)
{
}
void qM3C2Plugin::onNewSelection(const ccHObject::Container& selectedEntities)
{
if (m_action)
{
m_action->setEnabled( selectedEntities.size() == 2
&& selectedEntities[0]->isA(CC_TYPES::POINT_CLOUD)
&& selectedEntities[1]->isA(CC_TYPES::POINT_CLOUD) );
}
m_selectedEntities = selectedEntities;
}
QList<QAction *> qM3C2Plugin::getActions()
{
if (!m_action)
{
m_action = new QAction(getName(),this);
m_action->setToolTip(getDescription());
m_action->setIcon(getIcon());
connect(m_action, &QAction::triggered, this, &qM3C2Plugin::doAction);
}
return QList<QAction *>{ m_action };
}
void qM3C2Plugin::doAction()
{
//disclaimer accepted?
if (!ShowDisclaimer(m_app))
return;
//m_app should have already been initialized by CC when plugin is loaded!
assert(m_app);
if (!m_app)
return;
if (m_selectedEntities.size() != 2
|| !m_selectedEntities[0]->isA(CC_TYPES::POINT_CLOUD)
|| !m_selectedEntities[1]->isA(CC_TYPES::POINT_CLOUD))
{
m_app->dispToConsole("Select two point clouds!", ccMainAppInterface::ERR_CONSOLE_MESSAGE);
return;
}
ccPointCloud* cloud1 = ccHObjectCaster::ToPointCloud(m_selectedEntities[0]);
ccPointCloud* cloud2 = ccHObjectCaster::ToPointCloud(m_selectedEntities[1]);
//display dialog
qM3C2Dialog dlg(cloud1, cloud2, m_app);
if (!dlg.exec())
{
//process cancelled by the user
return;
}
QString errorMessage;
ccPointCloud* outputCloud = nullptr; //only necessary for the command line version in fact
if (!qM3C2Process::Compute(dlg, errorMessage, outputCloud, true, m_app->getMainWindow(), m_app))
{
m_app->dispToConsole(errorMessage, ccMainAppInterface::ERR_CONSOLE_MESSAGE);
}
//'Compute' may change some parameters of the dialog
dlg.saveParamsToPersistentSettings();
}
void qM3C2Plugin::registerCommands(ccCommandLineInterface* cmd)
{
if (!cmd)
{
assert(false);
return;
}
cmd->registerCommand(ccCommandLineInterface::Command::Shared(new CommandM3C2));
}
|