26 #include <QTableWidget>
27 #include <QTableWidgetItem>
30 #include <QMetaObject>
39 updateTimer.setInterval(100);
40 updateTimer.setSingleShot(
false);
52 visualizerName = settings->value(
"visualizerName",
"").toString().toStdString();
57 settings->setValue(
"visualizerName", QString::fromStdString(visualizerName));
67 return qobject_cast<PointCloudVisualizationConfigDialog*>(configDialog);
72 visualizerName = configDialog->pointCloudVisualizationProxyFinder->getSelectedProxyName().toStdString();
82 visualizer = getProxy<visionx::PointCloudVisualizationInterfacePrx>(visualizerName);
85 ARMARX_ERROR <<
"Could not obtain point cloud visualizer proxy";
93 QMetaObject::invokeMethod(&updateTimer,
"start", Qt::QueuedConnection);
98 QMetaObject::invokeMethod(&updateTimer,
"stop", Qt::QueuedConnection);
105 providers = visualizer->getAvailableProviders();
107 std::sort(providers.begin(), providers.end());
114 bool rebuild =
static_cast<unsigned int>(widget.tableWidgetProviders->rowCount()) != providers.size();
117 for (
unsigned int i = 0; i < providers.size(); i++)
119 if (
static_cast<QCheckBox*
>(widget.tableWidgetProviders->cellWidget(
static_cast<int>(i), 0))->text().toStdString() != providers[i].name)
128 rebuildProviderTable();
131 for (
unsigned int i = 0; i < providers.size(); i++)
133 auto info = visualizer->getCurrentPointCloudVisualizationInfo(providers[i].name);
134 static_cast<QCheckBox*
>(widget.tableWidgetProviders->cellWidget(
static_cast<int>(i), 0))->setCheckState(info.enabled ? Qt::Checked : Qt::Unchecked);
136 if (providers[i].type == visionx::ePoints)
140 else if (providers[i].type == visionx::eColoredPoints || providers[i].type == visionx::eColoredOrientedPoints)
142 static_cast<QComboBox*
>(widget.tableWidgetProviders->cellWidget(
static_cast<int>(i), 1))->setCurrentIndex(info.type == visionx::eColoredPoints ? 1 : 0);
144 else if (providers[i].type == visionx::eLabeledPoints)
146 static_cast<QComboBox*
>(widget.tableWidgetProviders->cellWidget(
static_cast<int>(i), 1))->setCurrentIndex(info.type == visionx::eLabeledPoints ? 1 : 0);
148 else if (providers[i].type == visionx::eColoredLabeledPoints)
150 static_cast<QComboBox*
>(widget.tableWidgetProviders->cellWidget(
static_cast<int>(i), 1))->setCurrentIndex(info.type == visionx::eLabeledPoints ? 2 : (info.type == visionx::eColoredPoints ? 1 : 0));
158 void PointCloudVisualizationWidgetController::rebuildProviderTable()
162 widget.tableWidgetProviders->clear();
164 widget.tableWidgetProviders->setColumnCount(2);
165 widget.tableWidgetProviders->setRowCount(
static_cast<int>(providers.size()));
167 for (
unsigned int i = 0; i < providers.size(); i++)
169 QCheckBox* cb =
new QCheckBox(QString::fromStdString(providers[i].name));
171 widget.tableWidgetProviders->setCellWidget(
static_cast<int>(i), 0, cb);
173 if (providers[i].type == visionx::ePoints)
175 widget.tableWidgetProviders->setItem(
static_cast<int>(i), 1,
new QTableWidgetItem(
"Plain"));
177 else if (providers[i].type == visionx::eColoredPoints || providers[i].type == visionx::eColoredOrientedPoints)
179 QComboBox* combo =
new QComboBox();
180 combo->addItem(
"Plain");
181 combo->addItem(
"Colors");
182 combo->setCurrentIndex(1);
184 widget.tableWidgetProviders->setCellWidget(
static_cast<int>(i), 1, combo);
186 else if (providers[i].type == visionx::eLabeledPoints)
188 QComboBox* combo =
new QComboBox();
189 combo->addItem(
"Plain");
190 combo->addItem(
"Labels");
191 combo->setCurrentIndex(1);
193 widget.tableWidgetProviders->setCellWidget(
static_cast<int>(i), 1, combo);
195 else if (providers[i].type == visionx::eColoredLabeledPoints)
197 QComboBox* combo =
new QComboBox();
198 combo->addItem(
"Plain");
199 combo->addItem(
"Colors");
200 combo->addItem(
"Labels");
201 combo->setCurrentIndex(1);
203 widget.tableWidgetProviders->setCellWidget(
static_cast<int>(i), 1, combo);
207 cb->setEnabled(
false);
208 widget.tableWidgetProviders->setItem(
static_cast<int>(i), 1,
new QTableWidgetItem(
"Unsupported"));
215 for (
unsigned int i = 0; i < providers.size(); i++)
217 visionx::PointContentType type;
219 QCheckBox* check =
dynamic_cast<QCheckBox*
>(widget.tableWidgetProviders->cellWidget(i, 0));
221 if (
dynamic_cast<QComboBox*
>(widget.tableWidgetProviders->cellWidget(i, 1)) !=
nullptr)
223 QComboBox* combo =
dynamic_cast<QComboBox*
>(widget.tableWidgetProviders->cellWidget(i, 1));
225 if (combo->currentText() ==
"Colors")
227 type = visionx::eColoredPoints;
229 else if (combo->currentText() ==
"Labels")
231 type = visionx::eLabeledPoints;
235 type = visionx::ePoints;
240 type = providers[i].type;
243 visualizer->begin_enablePointCloudVisualization(providers[i].name, type, check->isChecked());