From 9ddb986351031e03fb400a02d76e06ce51c12c85 Mon Sep 17 00:00:00 2001 From: Paul Leroy Date: Fri, 28 Oct 2022 17:05:36 +0200 Subject: [PATCH] scale selection It is possible to select/deselect all features related to a scale in the interface --- Train3DMASCDialog.ui | 27 +++++++-------------------- q3DMASC.cpp | 1 + qTrain3DMASCDialog.cpp | 18 ++++++++++++++++++ qTrain3DMASCDialog.h | 2 ++ 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Train3DMASCDialog.ui b/Train3DMASCDialog.ui index 3d32dd7..19d5193 100644 --- a/Train3DMASCDialog.ui +++ b/Train3DMASCDialog.ui @@ -228,6 +228,13 @@ + + + + export + + + @@ -237,26 +244,6 @@ - - - - Qt::Vertical - - - - 20 - 190 - - - - - - - - export - - - diff --git a/q3DMASC.cpp b/q3DMASC.cpp index 306e655..74bf945 100644 --- a/q3DMASC.cpp +++ b/q3DMASC.cpp @@ -382,6 +382,7 @@ void q3DMASCPlugin::doTrainAction() } for(double scale : scales) trainDlg.addScale(scale, true); + trainDlg.connectScaleSelectionToFeatureSelection(); std::vector originalFeaturesTest; if (testCloud && needTestSuite) diff --git a/qTrain3DMASCDialog.cpp b/qTrain3DMASCDialog.cpp index c77e55d..75f19ab 100644 --- a/qTrain3DMASCDialog.cpp +++ b/qTrain3DMASCDialog.cpp @@ -75,6 +75,24 @@ int Train3DMASCDialog::addScale(double scale, bool isChecked/*=true*/) return index; } +void Train3DMASCDialog::scaleStateChanged(QTableWidgetItem* item) +{ + // if the scale is not checked, remove automatically features based on this scale + QString scale = "_SC" + item->text() + "_"; + for (int row = 0; row < tableWidget->rowCount(); row++) + { + QTableWidgetItem* nameItem = tableWidget->item(row, 0); + QString name = nameItem->text(); + if (name.contains(scale)) + nameItem->setCheckState(item->checkState()); + } +} + +void Train3DMASCDialog::connectScaleSelectionToFeatureSelection() +{ + connect(tableWidgetScales, &QTableWidget::itemChanged, this, &Train3DMASCDialog::scaleStateChanged); +} + void Train3DMASCDialog::setResultText(QString text) { resultLabel->setText(text); diff --git a/qTrain3DMASCDialog.h b/qTrain3DMASCDialog.h index 153eb3b..56f5bf9 100644 --- a/qTrain3DMASCDialog.h +++ b/qTrain3DMASCDialog.h @@ -39,6 +39,8 @@ public: **/ int addFeature(QString name, float importance, bool isChecked = true); int addScale(double scale, bool isChecked = true); + void scaleStateChanged(QTableWidgetItem* item); + void connectScaleSelectionToFeatureSelection(); void setResultText(QString text); void setFirstRunDone(); inline void setClassifierSaved() { classifierSaved = true; saveRequested = false; }