18 #include <QMainWindow>
19 #include <QPushButton>
23 assert(comboBox && dbRoot);
24 if (!comboBox || !dbRoot) {
30 int index = comboBox->currentIndex();
35 unsigned uniqueID = comboBox->itemData(index).toUInt();
46 : QDialog(app ? app->getMainWindow() : 0),
59 unsigned cloudCount = 0;
60 for (
size_t i = 0; i < clouds.size(); ++i) {
61 QString
name = clouds[i]->getName() +
62 QString(
" [%1]").arg(clouds[i]->getUniqueID());
63 QVariant uniqueID(clouds[i]->getUniqueID());
64 cloud1ComboBox->addItem(
name, uniqueID);
65 cloud2ComboBox->addItem(
name, uniqueID);
66 cloud3ComboBox->addItem(
name, uniqueID);
67 cloud4ComboBox->addItem(
name, uniqueID);
68 testCloudComboBox->addItem(
name, uniqueID);
72 testCloudComboBox->addItem(
"", 0);
76 cloud1ComboBox->setCurrentIndex(
78 connect(cloud1ComboBox, SIGNAL(currentIndexChanged(
int)),
this,
80 cloud2ComboBox->setCurrentIndex(
82 connect(cloud2ComboBox, SIGNAL(currentIndexChanged(
int)),
this,
84 cloud3ComboBox->setCurrentIndex( -1);
85 connect(cloud3ComboBox, SIGNAL(currentIndexChanged(
int)),
this,
87 cloud4ComboBox->setCurrentIndex( -1);
88 connect(cloud4ComboBox, SIGNAL(currentIndexChanged(
int)),
this,
90 testCloudComboBox->setCurrentIndex(-1);
92 if (cloudCount == 0 && app) {
93 app->
dispToConsole(QString(
"You need at least 1 loaded cloud to ") +
94 (trainMode ?
"train a classifier"
101 label->setText(tr(
"Trainer file"));
102 warningLabel->setVisible(
false);
103 warningLabel->setText(
104 "Assign each role to the right cloud, and select the cloud on "
105 "which to train the classifier");
117 settings.beginGroup(
"3DMASC");
118 bool keepAttributes = settings.value(
"keepAttributes",
false).toBool();
119 this->keepAttributesCheckBox->setChecked(keepAttributes);
124 settings.beginGroup(
"3DMASC");
125 settings.setValue(
"keepAttributes", keepAttributesCheckBox->isChecked());
129 const QMap<QString, QString>& rolesAndNames,
131 const QMap<QString, QVariant>& namesAndUniqueIds,
132 QComboBox* comboBox) {
133 QString
name = label == testLabel
138 QMap<QString, QVariant>::const_iterator it(namesAndUniqueIds.find(
name));
139 if (it != namesAndUniqueIds.end()) {
140 int index = comboBox->findData(it.value());
142 comboBox->setCurrentIndex(index);
148 const QList<QString>& roles,
149 QString& corePointsLabel,
150 const QMap<QString, QString>& rolesAndNames) {
152 for (
const QString& role : roles) {
153 if (role !=
"TEST") {
156 cloud1Label->setText(role);
163 corePointsLabel = role;
167 cloud2Label->setText(role);
170 cloud3Label->setText(role);
173 cloud4Label->setText(role);
184 cloud1ComboBox->setEnabled(
false);
187 cloud2ComboBox->setEnabled(
false);
188 cloud2ComboBox->setVisible(
false);
189 cloud2Label->setVisible(
false);
192 cloud3ComboBox->setEnabled(
false);
193 cloud3ComboBox->setVisible(
false);
194 cloud3Label->setVisible(
false);
197 cloud4ComboBox->setEnabled(
false);
198 cloud4ComboBox->setVisible(
false);
199 cloud4Label->setVisible(
false);
204 QMap<QString, QVariant> namesAndUniqueIds;
213 for (
size_t i = 0; i < clouds.size(); ++i) {
217 QVariant uniqueID(clouds[i]->getUniqueID());
218 namesAndUniqueIds[clouds[i]->getName().toUpper()] = uniqueID;
236 QMap<QString, ccPointCloud*>& clouds)
const {
242 if (cloud1ComboBox->isEnabled()) {
243 clouds.insert(cloud1Label->text(),
247 if (cloud2ComboBox->isEnabled()) {
248 clouds.insert(cloud2Label->text(),
252 if (cloud3ComboBox->isEnabled()) {
253 clouds.insert(cloud3Label->text(),
257 if (cloud4ComboBox->isEnabled()) {
258 clouds.insert(cloud4Label->text(),
262 if (testCloudComboBox->currentIndex() >= 0) {
269 if (!cloud1ComboBox->isEnabled()) {
271 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
275 buttonBox->button(QDialogButtonBox::Ok)
276 ->setEnabled(cloud1ComboBox->currentIndex() >= 0);
3DMASC plugin 'classify' dialog
void writeSettings()
write settings
void setCloudRoles(const QList< QString > &roles, QString &corePointsLabel, const QMap< QString, QString > &rolesAndNames)
Sets the clouds roles.
Classify3DMASCDialog(ecvMainAppInterface *app, bool trainMode=false)
Default constructor.
ecvMainAppInterface * m_app
Gives access to the application (data-base, UI, etc.)
void getClouds(QMap< QString, ccPointCloud * > &clouds) const
Returns the selected point clouds.
void setComboBoxIndex(const QMap< QString, QString > &rolesAndNames, QLabel *label, const QMap< QString, QVariant > &namesAndUniqueIds, QComboBox *comboBox)
void readSettings()
read settings
Hierarchical CLOUDVIEWER Object.
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
bool isA(CV_CLASS_ENUM type) const
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Main application interface (for plugins)
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
static ccPointCloud * GetCloudFromCombo(QComboBox *comboBox, ccHObject *dbRoot)