This commit is contained in:
Paul Leroy
2022-10-25 16:47:19 +02:00
parent 2412b3f765
commit 13c391070e
6 changed files with 119 additions and 138 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ if (INSTALL_Q3DMASC_PLUGIN)
AUTOUIC_SEARCH_PATHS "${CloudCompare_SOURCE_DIR}/ui_templates;${CMAKE_CURRENT_SOURCE_DIR}/ui"
)
# FIXME These are required becaue we have dependencies outside of the api
# FIXME These are required because we have dependencies outside of the api
target_include_directories( ${PROJECT_NAME}
PRIVATE
${CloudCompare_SOURCE_DIR}
+70 -98
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>700</width>
<height>343</height>
<height>365</height>
</rect>
</property>
<property name="windowTitle">
@@ -51,52 +51,82 @@
<property name="title">
<string>Data</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,1">
<item row="0" column="2">
<widget class="QLabel" name="label_4">
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0">
<item row="3" column="2">
<widget class="QComboBox" name="cloud1ComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="cloud2Label">
<property name="text">
<string>Cloud</string>
<string>PC2</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="cloud3Label">
<property name="text">
<string>CTX</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLabel" name="warningLabel">
<property name="styleSheet">
<string notr="true">color:red;</string>
</property>
<property name="text">
<string>Assign each role to the right cloud, and select the role of the cloud to be classified</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QRadioButton" name="cloud3RadioButton">
<item row="7" column="0">
<widget class="QLabel" name="label_trainOrClassify">
<property name="text">
<string/>
<string>CLASSIFY</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="testLabel">
<property name="text">
<string>TEST on (optional)</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QComboBox" name="cloud4ComboBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Role as defined in the parameter file.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="cloud1RadioButton">
<widget class="QLabel" name="cloud1Label">
<property name="text">
<string/>
<string>PC1</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QRadioButton" name="cloud4RadioButton">
<widget class="QLabel" name="cloud4Label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QRadioButton" name="cloud2RadioButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QComboBox" name="cloud3ComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<string>PCX</string>
</property>
</widget>
</item>
@@ -110,40 +140,27 @@
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QComboBox" name="cloud4ComboBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>CLASSIFY</string>
<item row="5" column="2">
<widget class="QComboBox" name="cloud3ComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="warningLabel">
<property name="styleSheet">
<string notr="true">color:red;</string>
</property>
<item row="0" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Assign each role to the right cloud, and select the role of the cloud to be classified</string>
<string>Cloud</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="cloud1ComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="7" column="2">
<item row="8" column="2">
<widget class="QComboBox" name="testCloudComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -153,51 +170,6 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="cloud1Label">
<property name="text">
<string>PC1</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="cloud2Label">
<property name="text">
<string>PC2</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="cloud3Label">
<property name="text">
<string>CTX</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="cloud4Label">
<property name="text">
<string>PCX</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_8">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Role as defined in the parameter file.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Role</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="testLabel">
<property name="text">
<string>TEST on (optional)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
+6 -3
View File
@@ -138,6 +138,7 @@ void q3DMASCPlugin::doClassifyAction()
//now show a dialog where the user will be able to set the cloud roles
Classify3DMASCDialog classifDlg(m_app);
classifDlg.setCloudRoles(cloudLabels, corePointsLabel);
classifDlg.label_trainOrClassify->setText("CLASSIFY " + corePointsLabel);
classifDlg.classifierFileLineEdit->setText(inputFilename);
static bool s_keepAttributes = false;
classifDlg.keepAttributesCheckBox->setChecked(s_keepAttributes);
@@ -272,8 +273,8 @@ void q3DMASCPlugin::doTrainAction()
//now show a dialog where the user will be able to set the cloud roles
Classify3DMASCDialog classifDlg(m_app, true);
classifDlg.setWindowTitle("3DMASC Train");
classifDlg.label_3->setText("TRAIN on");
classifDlg.setCloudRoles(cloudLabels, corePointsLabel);
classifDlg.label_trainOrClassify->setText("TRAIN on " + corePointsLabel);
classifDlg.classifierFileLineEdit->setText(inputFilename);
classifDlg.keepAttributesCheckBox->setChecked(s_keepAttributes);
if (!classifDlg.exec())
@@ -291,7 +292,7 @@ void q3DMASCPlugin::doTrainAction()
static masc::TrainParameters s_params;
masc::Feature::Set features;
if (!masc::Tools::LoadTrainingFile(inputFilename, features, loadedClouds, s_params, &corePoints, m_app->getMainWindow()))
if (!masc::Tools:: LoadTrainingFile(inputFilename, features, loadedClouds, s_params, &corePoints, m_app->getMainWindow()))
{
m_app->dispToConsole("Failed to load the training file", ccMainAppInterface::ERR_CONSOLE_MESSAGE);
return;
@@ -308,6 +309,8 @@ void q3DMASCPlugin::doTrainAction()
mainCloudLabel = corePoints.role;
}
if (!masc::Tools::GetClassificationSF(corePoints.origin))
{
m_app->dispToConsole("Missing 'Classification' field on core points cloud", ccMainAppInterface::ERR_CONSOLE_MESSAGE);
@@ -324,7 +327,7 @@ void q3DMASCPlugin::doTrainAction()
}
}
for (masc::Tools::NamedClouds::const_iterator it = loadedClouds.begin(); it != loadedClouds.end(); ++it)
for (masc::Tools::NamedClouds::iterator it = loadedClouds.begin(); it != loadedClouds.end(); ++it)
{
m_app->dispToConsole(it.key() + " = " + it.value()->getName(), ccMainAppInterface::STD_CONSOLE_MESSAGE);
}
+2 -1
View File
@@ -22,6 +22,7 @@
#include "NeighborhoodFeature.h"
#include "DualCloudFeature.h"
#include "ContextBasedFeature.h"
#include "ccMainAppInterface.h"
//qCC_io
#include <FileIOFilter.h>
@@ -606,7 +607,7 @@ static bool ReadCorePoints(const QString& command, const Tools::NamedClouds& clo
return true;
}
static bool ReadCloud(const QString& command, Tools::NamedClouds& clouds, QDir& defaultDir, int lineNumber, FileIOFilter::LoadParameters& loadParameters)
static bool ReadCloud(const QString& command, Tools::NamedClouds& clouds, const QDir& defaultDir, int lineNumber, FileIOFilter::LoadParameters& loadParameters)
{
QStringList tokens = command.split('=');
if (tokens.size() != 2)
+38 -33
View File
@@ -126,23 +126,24 @@ void Classify3DMASCDialog::setCloudRoles(const QList<QString>& roles, QString co
{
case 0:
cloud1Label->setText(role);
if (corePointsLabel.isEmpty() || corePointsLabel == role)
cloud1RadioButton->setChecked(true);
if (corePointsLabel.isEmpty()) // if "core_points:" is not in the parameter file, the corePointsLabel is the first encountered role
corePointsLabel = role;
// cloud1RadioButton->setChecked(true);
break;
case 1:
cloud2Label->setText(role);
if (corePointsLabel == role)
cloud2RadioButton->setChecked(true);
// cloud2RadioButton->setChecked(true);
break;
case 2:
cloud3Label->setText(role);
if (corePointsLabel == role)
cloud3RadioButton->setChecked(true);
// cloud3RadioButton->setChecked(true);
break;
case 3:
cloud4Label->setText(role);
if (corePointsLabel == role)
cloud4RadioButton->setChecked(true);
// cloud4RadioButton->setChecked(true);
break;
default:
//this dialog can't handle more than 3 roles!
@@ -153,27 +154,27 @@ void Classify3DMASCDialog::setCloudRoles(const QList<QString>& roles, QString co
if (index < 1)
{
cloud1RadioButton->setEnabled(false);
// cloud1RadioButton->setEnabled(false);
cloud1ComboBox->setEnabled(false);
}
if (index < 2)
{
cloud2RadioButton->setEnabled(false);
cloud2RadioButton->setVisible(false);
// cloud2RadioButton->setEnabled(false);
// cloud2RadioButton->setVisible(false);
cloud2ComboBox->setVisible(false);
cloud2Label->setVisible(false);
}
if (index < 3)
{
cloud3RadioButton->setEnabled(false);
cloud3RadioButton->setVisible(false);
// cloud3RadioButton->setEnabled(false);
// cloud3RadioButton->setVisible(false);
cloud3ComboBox->setVisible(false);
cloud3Label->setVisible(false);
}
if (index < 4)
{
cloud4RadioButton->setEnabled(false);
cloud4RadioButton->setVisible(false);
// cloud4RadioButton->setEnabled(false);
// cloud4RadioButton->setVisible(false);
cloud4ComboBox->setVisible(false);
cloud4Label->setVisible(false);
}
@@ -187,37 +188,41 @@ void Classify3DMASCDialog::getClouds(QMap<QString, ccPointCloud*>& clouds, QStri
return;
}
if (cloud1RadioButton->isEnabled())
// if (cloud1RadioButton->isEnabled())
if (cloud1ComboBox->isEnabled())
{
clouds.insert(cloud1Label->text(), GetCloudFromCombo(cloud1ComboBox, m_app->dbRootObject()));
if (cloud1RadioButton->isChecked())
{
mainCloud = cloud1Label->text();
}
// if (cloud1RadioButton->isChecked())
// {
// mainCloud = cloud1Label->text();
// }
}
if (cloud2RadioButton->isEnabled())
// if (cloud2RadioButton->isEnabled())
if (cloud2ComboBox->isVisible())
{
clouds.insert(cloud2Label->text(), GetCloudFromCombo(cloud2ComboBox, m_app->dbRootObject()));
if (cloud2RadioButton->isChecked())
{
mainCloud = cloud2Label->text();
}
// if (cloud2RadioButton->isChecked())
// {
// mainCloud = cloud2Label->text();
// }
}
if (cloud3RadioButton->isEnabled())
// if (cloud3RadioButton->isEnabled())
if (cloud3ComboBox->isVisible())
{
clouds.insert(cloud3Label->text(), GetCloudFromCombo(cloud3ComboBox, m_app->dbRootObject()));
if (cloud3RadioButton->isChecked())
{
mainCloud = cloud3Label->text();
}
// if (cloud3RadioButton->isChecked())
// {
// mainCloud = cloud3Label->text();
// }
}
if (cloud4RadioButton->isEnabled())
// if (cloud4RadioButton->isEnabled())
if (cloud4ComboBox->isVisible())
{
clouds.insert(cloud4Label->text(), GetCloudFromCombo(cloud4ComboBox, m_app->dbRootObject()));
if (cloud4RadioButton->isChecked())
{
mainCloud = cloud4Label->text();
}
// if (cloud4RadioButton->isChecked())
// {
// mainCloud = cloud4Label->text();
// }
}
if (testCloudComboBox->currentIndex() >= 0)
{
@@ -227,7 +232,7 @@ void Classify3DMASCDialog::getClouds(QMap<QString, ccPointCloud*>& clouds, QStri
void Classify3DMASCDialog::onCloudChanged(int dummy)
{
if (!cloud1RadioButton->isEnabled())
if (!cloud1ComboBox->isEnabled())
{
//this means that no role has been defined yet
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
+2 -2
View File
@@ -57,7 +57,7 @@ int Train3DMASCDialog::addFeature(QString name, float importance, bool isChecked
nameItem->setCheckState(isChecked ? Qt::Checked : Qt::Unchecked);
tableWidget->setItem(index, 0, nameItem);
QTableWidgetItem* importanceItem = new QTableWidgetItem(std::isnan(importance) ? QString() : QString::number(importance));
QTableWidgetItem* importanceItem = new QTableWidgetItem(isnan(importance) ? QString() : QString::number(importance));
tableWidget->setItem(index, 1, importanceItem);
return index;
@@ -113,7 +113,7 @@ void Train3DMASCDialog::setFeatureImportance(QString featureName, float importan
if (tableWidget->item(index, 0)->text() == featureName)
{
QTableWidgetItem* item = tableWidget->item(index, FeatureImportanceColumn);
item->setText(std::isnan(importance) ? QString() : QString::number(importance, 'f', 6));
item->setText(isnan(importance) ? QString() : QString::number(importance, 'f', 6));
return;
}
}