28 #include <type_traits>
32 #include <IceUtil/Time.h>
35 #include <VisionX/interface/core/PointCloudProviderInterface.h>
46 #include <QMainWindow>
53 qRegisterMetaType<IceGrid::ObjectInfoSeq>(
"IceGrid::ObjectInfoSeq");
81 QMetaObject::invokeMethod(widget.refreshButton,
"setEnabled", Q_ARG(
bool,
true));
86 QMetaObject::invokeMethod(widget.refreshButton,
"setEnabled", Q_ARG(
bool,
false));
87 QMetaObject::invokeMethod(
this,
"disconnectQt");
90 void WidgetController::disconnectQt()
98 for (
int row = 0; row < widget.providerList->count(); row++)
100 QListWidgetItem* item = widget.providerList->item(row);
101 const std::string subscriber = item->text().toStdString();
103 ARMARX_LOG << subscriber <<
" has state " << icemanager->getIceGridSession()->getComponentState(subscriber) << std::endl;
112 delete this->widget.providerList->takeItem(this->widget.providerList->row(item));
139 widget.pointCloudDisplay->getDisplay()->getRootNode()->addChild(manager);
142 widget.tableWidget->verticalHeader()->setVisible(
false);
145 widget.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
154 connect(widget.backgroundButton, SIGNAL(clicked()),
this, SLOT(
selectColor()));
157 connect(widget.providerList, SIGNAL(itemPressed(QListWidgetItem*)),
this, SLOT(
showPointCloudInfo(QListWidgetItem*)));
160 connect(widget.providerList, SIGNAL(itemChanged(QListWidgetItem*)),
this, SLOT(
pointCloudChecked(QListWidgetItem*)));
163 connect(widget.saveButton, SIGNAL(clicked()),
this, SLOT(
savePointCloud()));
166 connect(widget.doubleSpinBoxPointSize, SIGNAL(valueChanged(
double)),
this, SLOT(setPointSize(
double)));
171 std::lock_guard<std::mutex> lock(mutex);
183 pcl::PointCloud<PointT>::Ptr providerBuffer(
new pcl::PointCloud<PointT>());
187 const visionx::PointContentType pointContentType = info->type;
189 bool colorFromLabel =
tools::isLabeled(pointContentType) && this->widget.colorMode_label->isChecked();
191 switch (pointContentType)
193 case visionx::PointContentType::ePoints:
194 getPointCloudAs(providerName, *providerBuffer);
196 case visionx::PointContentType::eColoredPoints:
197 getPointCloudAs(providerName, *providerBuffer);
199 case visionx::PointContentType::eColoredLabeledPoints:
200 getPointCloudAs(providerName, *providerBuffer);
202 case visionx::PointContentType::eLabeledPoints:
203 getPointCloudAs(providerName, *providerBuffer);
207 <<
"Unexpected point cloud content type: " <<
tools::toString(pointContentType);
216 template <
class Po
intCloudT>
217 void WidgetController::getPointCloudAs(
const std::string& providerName,
PointCloudT& targetPointCloud)
221 typename pcl::PointCloud<InputPointT>::Ptr inputCloudPtr(
new pcl::PointCloud<InputPointT>());
224 pcl::copyPointCloud(*inputCloudPtr, targetPointCloud);
233 widget.pointCloudDisplay->getDisplay()->cameraViewAll();
234 recenterCamera =
false;
237 auto* item = widget.providerList->currentItem();
238 if (item && providerName == item->text())
249 widget.loadingStatusLabel->setText(QString::fromStdString(
"Loading..."));
255 for (
const auto&
object : objects)
257 const std::string name = this->
getIceManager()->getCommunicator()->proxyToString(
object.proxy);
258 const std::string shortName = name.substr(0, name.find(
' '));
262 if (widget.providerList->findItems(QString::fromStdString(shortName), Qt::MatchExactly).count() == 0)
265 QListWidgetItem* item =
new QListWidgetItem(QString::fromStdString(shortName), widget.providerList);
266 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
267 item->setCheckState(Qt::Unchecked);
278 widget.loadingStatusLabel->setText(QString::fromStdString(
"Loading complete: " +
std::to_string(counter) +
" provider found"));
286 IceGrid::ObjectInfoSeq objects = admin->getRegisteredObjects<PointCloudProviderInterfacePrx>(widget.lineEditPointCloudFilter->text().toStdString());
287 QMetaObject::invokeMethod(
this,
"updateProviderList", Q_ARG(IceGrid::ObjectInfoSeq, objects));
293 const std::string providerName = item->text().toStdString();
296 widget.tableWidget->setRowCount(8);
297 widget.tableWidget->setColumnCount(2);
300 widget.tableWidget->setItem(0, 0,
new QTableWidgetItem(
"Name"));
301 widget.tableWidget->setItem(0, 1,
new QTableWidgetItem(item->text()));
304 widget.tableWidget->setItem(1, 0,
new QTableWidgetItem(
"Type"));
305 widget.tableWidget->setItem(1, 1,
new QTableWidgetItem(QString::fromStdString(
visionx::tools::toString(info->type))));
308 widget.tableWidget->setItem(2, 0,
new QTableWidgetItem(
"Width"));
309 widget.tableWidget->setItem(2, 1,
new QTableWidgetItem(QString::fromStdString(
std::to_string(info->width))));
312 widget.tableWidget->setItem(3, 0,
new QTableWidgetItem(
"Height"));
313 widget.tableWidget->setItem(3, 1,
new QTableWidgetItem(QString::fromStdString(
std::to_string(info->height))));
316 widget.tableWidget->setItem(4, 0,
new QTableWidgetItem(
"Size"));
317 widget.tableWidget->setItem(4, 1,
new QTableWidgetItem(QString::fromStdString(
std::to_string(info->size))));
320 widget.tableWidget->setItem(5, 0,
new QTableWidgetItem(
"Capacity"));
321 widget.tableWidget->setItem(5, 1,
new QTableWidgetItem(QString::fromStdString(
std::to_string(info->capacity))));
324 widget.tableWidget->setItem(6, 0,
new QTableWidgetItem(
"Sequence"));
325 widget.tableWidget->setItem(6, 1,
new QTableWidgetItem(QString::fromStdString(
std::to_string(info->seq))));
328 widget.tableWidget->setItem(7, 0,
new QTableWidgetItem(
"Time Provided"));
330 const bool showRawTimestamp =
false;
331 const std::string timeProvided = showRawTimestamp
333 : IceUtil::Time::microSeconds(info->timeProvided).toDateTime();
334 widget.tableWidget->setItem(7, 1,
new QTableWidgetItem(QString::fromStdString(timeProvided)));
339 std::lock_guard<std::mutex> lock(mutex);
341 const std::string providerName = item->text().toStdString();
343 if (item->checkState())
351 recenterCamera =
true;
356 QColor selectedColor = this->colorDialog.getColor();
358 widget.pointCloudDisplay->getDisplay()->setBackgroundColor(
359 SbColor(selectedColor.red() / 255.0f, selectedColor.green() / 255.0f, selectedColor.blue() / 255.0f));
364 if (widget.providerList->selectedItems().size() == 1)
367 const std::string providerID = widget.providerList->selectedItems()[0]->text().toStdString();
369 if (std::find(clouds.begin(), clouds.end(), providerID) != clouds.end())
372 int result = saveDialog.exec();
374 if (result == QDialog::Accepted)
377 const pcl::PointCloud<PointT>& originalCloud = *coinCloud.
getPCLCloud();
382 case visionx::PointContentType::ePoints:
383 storePointCloudAs(fileName, originalCloud);
385 case visionx::PointContentType::eColoredPoints:
386 storePointCloudAs(fileName, originalCloud);
388 case visionx::PointContentType::eColoredLabeledPoints:
389 storePointCloudAs(fileName, originalCloud);
391 case visionx::PointContentType::eLabeledPoints:
392 storePointCloudAs(fileName, originalCloud);
406 template <
class Po
intCloudT>
407 void WidgetController::storePointCloudAs(
const std::string&
filename,
const PointCloudT& pointCloud)
411 if (std::is_same<StoredPointT, PointT>())
413 pcl::io::savePCDFile(
filename, pointCloud);
417 pcl::PointCloud<StoredPointT> stored;
418 pcl::copyPointCloud(pointCloud, stored);
419 pcl::io::savePCDFile(
filename, stored);
425 widget.configColumn->setVisible(
false);
430 widget.configColumn->setVisible(
true);
434 void visionx::WidgetController::setPointSize(
double value)
437 pointSize =
static_cast<float>(
value);