From 13c391070ecd5972ade59f91d3c1b5d9e275d56d Mon Sep 17 00:00:00 2001 From: Paul Leroy Date: Tue, 25 Oct 2022 16:47:19 +0200 Subject: [PATCH] wip --- CMakeLists.txt | 2 +- Classify3DMASCDialog.ui | 168 ++++++++++++++++---------------------- q3DMASC.cpp | 9 +- q3DMASCTools.cpp | 3 +- qClassify3DMASCDialog.cpp | 71 ++++++++-------- qTrain3DMASCDialog.cpp | 4 +- 6 files changed, 119 insertions(+), 138 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a561041..dbfa161 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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} diff --git a/Classify3DMASCDialog.ui b/Classify3DMASCDialog.ui index ac5f726..418e01f 100644 --- a/Classify3DMASCDialog.ui +++ b/Classify3DMASCDialog.ui @@ -7,7 +7,7 @@ 0 0 700 - 343 + 365 @@ -51,52 +51,82 @@ Data - - - + + + + + + 0 + 0 + + + + + + - Cloud + PC2 + + + + + + + CTX + + + + + + + color:red; + + + Assign each role to the right cloud, and select the role of the cloud to be classified Qt::AlignCenter - - + + - + CLASSIFY + + + + + + + TEST on (optional) + + + + + + + + + + <html><head/><body><p>Role as defined in the parameter file.</p></body></html> + + + Label - + - + PC1 - + - - - - - - - - - - - - - - - - 0 - 0 - + PCX @@ -110,40 +140,27 @@ - - - - - - - CLASSIFY + + + + + 0 + 0 + - - - - color:red; - + + - Assign each role to the right cloud, and select the role of the cloud to be classified + Cloud Qt::AlignCenter - - - - - 0 - 0 - - - - - + @@ -153,51 +170,6 @@ - - - - PC1 - - - - - - - PC2 - - - - - - - CTX - - - - - - - PCX - - - - - - - <html><head/><body><p>Role as defined in the parameter file.</p></body></html> - - - Role - - - - - - - TEST on (optional) - - - diff --git a/q3DMASC.cpp b/q3DMASC.cpp index 12a6239..66f7c3f 100644 --- a/q3DMASC.cpp +++ b/q3DMASC.cpp @@ -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); } diff --git a/q3DMASCTools.cpp b/q3DMASCTools.cpp index c264afa..adbba3e 100644 --- a/q3DMASCTools.cpp +++ b/q3DMASCTools.cpp @@ -22,6 +22,7 @@ #include "NeighborhoodFeature.h" #include "DualCloudFeature.h" #include "ContextBasedFeature.h" +#include "ccMainAppInterface.h" //qCC_io #include @@ -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) diff --git a/qClassify3DMASCDialog.cpp b/qClassify3DMASCDialog.cpp index 3bce0df..caafcc1 100644 --- a/qClassify3DMASCDialog.cpp +++ b/qClassify3DMASCDialog.cpp @@ -126,23 +126,24 @@ void Classify3DMASCDialog::setCloudRoles(const QList& 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& 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& 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& 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); diff --git a/qTrain3DMASCDialog.cpp b/qTrain3DMASCDialog.cpp index 889c9dc..be62efe 100644 --- a/qTrain3DMASCDialog.cpp +++ b/qTrain3DMASCDialog.cpp @@ -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; } }