36 #include <QAbstractItemView>
51 #include <vtkProperty.h>
52 #include <vtkPointPicker.h>
53 #include <vtkPointData.h>
54 #include <vtkAreaPicker.h>
55 #include <vtkCamera.h>
56 #include <vtkDefaultPass.h>
57 #include <vtkCubeSource.h>
59 #include "../vtkBridge/LVRChunkedMeshBridge.hpp"
60 #include "../vtkBridge/LVRChunkedMeshCuller.hpp"
65 #include <boost/filesystem.hpp>
66 #include <boost/tokenizer.hpp>
75 using Vec = BaseVector<float>;
88 Ui::AboutDialog aboutDialog;
92 Ui::TooltipDialog tooltipDialog;
98 QHeaderView* v = this->treeWidget->header();
99 v->resizeSection(0, 175);
101 treeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
102 treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
110 #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
118 #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
158 this->dockWidgetSpectralSliderSettings->close();
159 this->dockWidgetSpectralColorGradientSettings->close();
160 this->dockWidgetPointPreview->close();
161 this->dockWidgetLabel->close();
246 vtkSmartPointer<vtkPointPicker> pointPicker = vtkSmartPointer<vtkPointPicker>::New();
247 qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(pointPicker);
251 m_axes = vtkSmartPointer<vtkAxesActor>::New();
253 m_axesWidget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
254 m_axesWidget->SetOutlineColor( 0.9300, 0.5700, 0.1300 );
263 #ifndef LVR2_USE_VTK_GE_7_1
264 actionRenderEDM->setEnabled(
false);
286 qvtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(
nullptr);
332 QObject::connect(this->actionOpenLabeledPointcloud, SIGNAL(triggered()),
this, SLOT(
loadLabels()));
333 QObject::connect(this->actionExportLabeledPointcloud, SIGNAL(triggered()),
this, SLOT(
exportLabels()));
334 QObject::connect(treeWidget, SIGNAL(customContextMenuRequested(
const QPoint&)),
this, SLOT(
showTreeContextMenu(
const QPoint&)));
335 QObject::connect(treeWidget, SIGNAL(itemSelectionChanged()),
this, SLOT(
restoreSliders()));
337 QObject::connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this, SLOT(
setModelVisibility(QTreeWidgetItem*,
int)));
339 QObject::connect(labelTreeWidget, SIGNAL(customContextMenuRequested(
const QPoint&)),
this, SLOT(
showLabelTreeContextMenu(
const QPoint&)));
342 QObject::connect(
m_actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
354 QObject::connect(selectedInstanceComboBox, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
comboBoxIndexChanged(
int)));
382 QObject::connect(actionRenderEDM, SIGNAL(toggled(
bool)),
this, SLOT(
toogleEDL(
bool)));
404 for (
int i = 0; i < 3; i++)
420 QObject::connect(comboBox_colorgradient, SIGNAL(currentIndexChanged(
int)),
this, SLOT(
changeGradientColor()));
421 QObject::connect(checkBox_normcolors, SIGNAL(stateChanged(
int)),
this, SLOT(
changeGradientColor()));
422 QObject::connect(checkBox_NDVI, SIGNAL(stateChanged(
int)),
this, SLOT(
changeGradientColor()));
438 QObject::connect(labelTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,
int)),
this, SLOT(
visibilityChanged(QTreeWidgetItem*,
int)));
442 QObject::connect(labelTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,
int)),
this, SLOT(
cellSelected(QTreeWidgetItem*,
int)));
446 QObject::connect(this->doubleSpinBoxDollySpeed, SIGNAL(valueChanged(
double)),
m_pickingInteractor, SLOT(setMotionFactor(
double)));
447 QObject::connect(this->doubleSpinBoxRotationSpeed, SIGNAL(valueChanged(
double)),
m_pickingInteractor, SLOT(setRotationFactor(
double)));
448 QObject::connect(this->checkBoxShowFocal, SIGNAL(stateChanged(
int)),
m_pickingInteractor, SLOT(setFocalPointRendering(
int)));
449 QObject::connect(this->checkBoxStereo, SIGNAL(stateChanged(
int)),
m_pickingInteractor, SLOT(setStereoMode(
int)));
450 QObject::connect(this->buttonPickFocal, SIGNAL(pressed()),
m_pickingInteractor, SLOT(pickFocalPoint()));
451 QObject::connect(this->pushButtonTerrain, SIGNAL(pressed()),
m_pickingInteractor, SLOT(modeTerrain()));
452 QObject::connect(this->buttonResetCamera, SIGNAL(pressed()),
m_pickingInteractor, SLOT(resetCamera()));
453 QObject::connect(this->pushButtonTrackball, SIGNAL(pressed()),
m_pickingInteractor, SLOT(modeTrackball()));
454 QObject::connect(this->pushButtonFly , SIGNAL(pressed()),
m_pickingInteractor, SLOT(modeShooter()));
457 QObject::connect(this->actionSelected_Lasso, SIGNAL(triggered()),
this, SLOT(
manualLabeling()));
458 QObject::connect(this->actionSelected_Polygon, SIGNAL(triggered()),
this, SLOT(
manualLabeling()));
485 if(dialog.exec() == QDialog::Accepted)
489 float r1, r2, g1, g2, b1, b2;
503 this->qvtkWidget->GetRenderWindow()->Render();
509 #ifndef LVR2_USE_VTK8
511 QSurfaceFormat surfaceFormat = qvtkWidget->windowHandle()->format();
512 surfaceFormat.setStencilBufferSize(8);
513 qvtkWidget->windowHandle()->setFormat(surfaceFormat);
517 m_renderer = vtkSmartPointer<vtkRenderer>::New();
519 #ifdef LVR2_USE_VTK_GE_7_1
530 vtkSmartPointer<vtkRenderWindow> renderWindow = this->qvtkWidget->GetRenderWindow();
537 m_camera = vtkSmartPointer<vtkCamera>::New();
549 vtkSmartPointer<vtkAreaPicker> pointPicker = vtkSmartPointer<vtkAreaPicker>::New();
550 qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(pointPicker);
553 m_pathCamera = vtkSmartPointer<vtkCameraRepresentation>::New();
554 vtkSmartPointer<vtkCameraInterpolator> cameraInterpolator = vtkSmartPointer<vtkCameraInterpolator>::New();
555 cameraInterpolator->SetInterpolationTypeToSpline();
560 #ifdef LVR2_USE_VTK_GE_7_1
562 qvtkWidget->GetRenderWindow()->SetMultiSamples(0);
564 m_basicPasses = vtkRenderStepsPass::New();
565 m_edl = vtkEDLShading::New();
566 m_edl->SetDelegatePass(m_basicPasses);
567 vtkOpenGLRenderer *glrenderer = vtkOpenGLRenderer::SafeDownCast(
m_renderer);
569 glrenderer->SetPass(m_edl);
579 #ifdef LVR2_USE_VTK_GE_7_1
580 vtkOpenGLRenderer *glrenderer = vtkOpenGLRenderer::SafeDownCast(
m_renderer);
584 glrenderer->SetPass(m_basicPasses);
588 glrenderer->SetPass(m_edl);
590 this->qvtkWidget->GetRenderWindow()->Render();
599 this->qvtkWidget->GetRenderWindow()->Render();
603 vtkCamera* cam =
m_renderer->GetActiveCamera();
604 double step = cam->GetDistance() / 100;
606 this->doubleSpinBoxDollySpeed->setValue(
step);
614 this->qvtkWidget->GetRenderWindow()->Render();
641 this->qvtkWidget->GetRenderWindow()->Render();
652 this->qvtkWidget->GetRenderWindow()->Render();
660 if (!pointCloudItems.empty())
666 int transparency = ((float)1 - pointCloudItem->
getOpacity()) * 100;
672 size_t n_channels, gradient_channel;
673 bool use_ndvi, normalize_gradient;
677 pointCloudItem->
getPointBufferBridge()->getSpectralColorGradient(gradient_type, gradient_channel, normalize_gradient, use_ndvi);
684 n_channels = spec_channels->width();
685 int wavelength_min = *
p->getIntAtomic(
"spectral_wavelength_min");
686 int wavelength_max = *
p->getIntAtomic(
"spectral_wavelength_max");
688 this->dockWidgetSpectralSliderSettingsContents->setEnabled(
false);
689 for (
int i = 0; i < 3; i++)
703 this->dockWidgetSpectralSliderSettingsContents->setEnabled(
true);
705 this->dockWidgetSpectralColorGradientSettingsContents->setEnabled(
false);
712 this->checkBox_NDVI->setChecked(use_ndvi);
713 this->checkBox_normcolors->setChecked(normalize_gradient);
714 this->comboBox_colorgradient->setCurrentIndex((
int)gradient_type);
716 this->dockWidgetSpectralColorGradientSettingsContents->setEnabled(
true);
720 this->dockWidgetSpectralSliderSettingsContents->setEnabled(
false);
721 this->dockWidgetSpectralColorGradientSettingsContents->setEnabled(
false);
729 this->dockWidgetSpectralSliderSettingsContents->setEnabled(
false);
730 this->dockWidgetSpectralColorGradientSettingsContents->setEnabled(
false);
733 if (!meshItems.empty())
737 int transparency = ((float)1 - meshItem->
getOpacity()) * 100;
742 if (pointCloudItems.empty() && meshItems.empty())
752 bool selected = item->isSelected();
754 for (
int i = 0; i < item->childCount() && !selected; i++)
764 QTreeWidgetItemIterator it(treeWidget);
775 QTreeWidgetItem *parent = item->parent();
789 QTreeWidgetItem *parent = item->parent();
798 color.setRgbF(1.0, 1.0, 0.0);
812 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
815 QTreeWidgetItem* item = items.first();
820 QString qFileName = QFileDialog::getSaveFileName(
this,
tr(
"Export Point Cloud As..."),
"",
tr(
"Point cloud Files(*.ply *.3d)"));
831 size_t n = points->numPoints();
832 floatArr transformedPoints(
new float[3 * n]);
833 floatArr pointArray = points->getPointArray();
834 for(
size_t i = 0; i < n; i++)
836 Vec v(pointArray[3 * i], pointArray[3 * i + 1], pointArray[3 * i + 2]);
839 transformedPoints[3 * i ] = vt[0];
840 transformedPoints[3 * i + 1] = vt[1];
841 transformedPoints[3 * i + 2] = vt[2];
846 trans->setPointArray(transformedPoints, n);
864 if (!dataItem || !modelItem) {
871 angles *=
M_PI / 180.0;
872 Transformf mat = poseToMatrix<float>(pos, angles);
875 if (correspondence.is_initialized())
877 mat *= correspondence.get();
879 angles *= 180.0 /
M_PI;
882 pos.
x(), pos.y(), pos.z(),
883 angles.x(), angles.y(), angles.z()
895 angles /= 180.0 /
M_PI;
896 Transformf modelTransform = poseToMatrix<float>(pos, angles);
921 QList<QTreeWidgetItem*> items = labelTreeWidget->selectedItems();
922 QPoint globalPos = labelTreeWidget->mapToGlobal(
p);
926 QTreeWidgetItem* item = items.first();
942 auto topLevelItem = item->parent();
945 topLevelItem->removeChild(item);
961 QString className = QInputDialog::getText(
this,
tr(
"Choose name for new Label class"),
963 tr(
"Labelname") , &accepted);
964 if (!accepted || className.isEmpty())
970 QColor label_color = QColorDialog::getColor(Qt::red,
this,
tr(
"Choose default Label Color for label Class(willbe used for first isntance)"));
971 if (!label_color.isValid())
977 if (labelTreeWidget->topLevelItemCount() == 0)
982 item->setText(0, QString::fromStdString(
UNKNOWNNAME));
995 item->addChild(childItem);
996 labelTreeWidget->addTopLevelItem(item);
1005 item->setText(0, className);
1018 item->addChild(childItem);
1020 labelTreeWidget->addTopLevelItem(item);
1029 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1030 if(items.size() > 0)
1032 QTreeWidgetItem* item = items.first();
1035 QPoint globalPos = treeWidget->mapToGlobal(
p);
1040 QPoint globalPos = treeWidget->mapToGlobal(
p);
1045 QPoint globalPos = treeWidget->mapToGlobal(
p);
1048 QMenu *con_menu =
new QMenu;
1065 con_menu->exec(globalPos);
1071 QPoint globalPos = treeWidget->mapToGlobal(
p);
1072 QMenu *con_menu =
new QMenu;
1077 con_menu->exec(globalPos);
1083 QPoint globalPos = treeWidget->mapToGlobal(
p);
1084 QMenu *con_menu =
new QMenu;
1089 con_menu->exec(globalPos);
1098 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1099 if(items.size() > 0)
1101 QTreeWidgetItem* item = items.first();
1109 std::cout <<
"model loaded" << std::endl;
1116 QFileInfo info(name);
1117 QString base = info.fileName();
1119 this->treeWidget->addTopLevelItem(item);
1120 item->setExpanded(
true);
1123 boost::filesystem::path poseFile = name.toStdString();
1125 for (
auto& extension : {
"pose",
"dat",
"frames" })
1127 poseFile.replace_extension(extension);
1128 if (boost::filesystem::exists(poseFile))
1130 cout <<
"Found Pose file: " << poseFile << endl;
1131 Transformf mat = getTransformationFromFile<float>(poseFile);
1133 getPoseFromMatrix<float>(pos, angles, mat.transpose());
1135 angles *= 180.0 /
M_PI;
1138 pos.
x, pos.
y, pos.
z,
1139 angles.
x, angles.
y, angles.
z
1150 if(filenames.size() > 0)
1152 QTreeWidgetItem* lastItem =
nullptr;
1154 QStringList::const_iterator it = filenames.begin();
1155 while(it != filenames.end())
1157 QFileInfo info((*it));
1158 QString base = info.fileName();
1160 std::cout << base.toStdString() << std::endl;
1162 if (info.suffix() ==
"h5")
1165 std::cout << info.absoluteFilePath().toStdString() << std::endl;
1171 qRegisterMetaType<actorMap > (
"actorMap");
1176 Qt::QueuedConnection);
1186 if(filenames.size() > 0)
1188 QTreeWidgetItem* lastItem =
nullptr;
1190 QStringList::const_iterator it = filenames.begin();
1191 while(it != filenames.end())
1194 QFileInfo info((*it));
1195 QString base = info.fileName();
1197 if (info.suffix() ==
"h5")
1202 QTreeWidgetItem *root =
new QTreeWidgetItem(treeWidget);
1203 root->setText(0, base);
1206 icon.addFile(QString::fromUtf8(
":/qv_scandata_tree_icon.png"), QSize(),
QIcon::Normal, QIcon::Off);
1207 root->setIcon(0, icon);
1209 std::shared_ptr<ScanDataManager> sdm(
new ScanDataManager(info.absoluteFilePath().toStdString()));
1213 root->setExpanded(
true);
1217 std::shared_ptr<HDF5IO> h5_io_ptr(
new HDF5IO(info.absoluteFilePath().toStdString()));
1218 if(h5_io_ptr->readMesh(model_ptr))
1225 root->addChild(item);
1226 item->setExpanded(
false);
1237 if (lastItem !=
nullptr)
1239 for(QTreeWidgetItem* selected : treeWidget->selectedItems())
1241 selected->setSelected(
false);
1243 lastItem->setSelected(
true);
1252 vtkSmartPointer<vtkPoints> points =
1253 vtkSmartPointer<vtkPoints>::New();
1254 QTreeWidgetItemIterator itu(treeWidget);
1259 QTreeWidgetItem* item = *itu;
1264 points->SetData(citem->
getPointBufferBridge()->getPointCloudActor()->GetMapper()->GetInput()->GetPointData()->GetScalars());
1277 QStringList filenames = QFileDialog::getOpenFileNames(
this,
tr(
"Open Model"),
"",
tr(
"Model Files (*.ply *.obj *.pts *.3d *.txt *.h5)"));
1284 QStringList filenames = QFileDialog::getOpenFileNames(
this,
tr(
"Open chunked mesh"),
"",
tr(
"Chunked meshes (*.h5)"));
1286 QString text = QInputDialog::getText(0,
"Enter layers",
1289 std::vector<std::string> layers;
1290 std::string unseperated = text.toStdString();
1298 boost::tokenizer<boost::char_separator<char>> tokens(unseperated, boost::char_separator<char>());
1299 layers = std::vector<std::string>(tokens.begin(), tokens.end());
1303 std::cout <<
"LAYERS " ;
1304 for(
auto &layer : layers)
1306 std::cout << layer <<
" ";
1309 std::cout << std::endl;
1310 double highResDistance = QInputDialog::getDouble(0,
"highResDistance",
"highResDistance");
1312 if(highResDistance < 0)
1314 highResDistance = 0.0;
1318 int cacheSize = QInputDialog::getInt(0,
"cacheSize",
"cache size");
1330 std::cout <<
"loaded points" << std::endl;
1331 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1332 if(items.size() > 0)
1334 QTreeWidgetItem* item = items.first();
1358 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1359 if(items.size() > 0)
1361 QTreeWidgetItem* item = items.first();
1383 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1385 if(items.size() > 0)
1387 QTreeWidgetItem* item = items.first();
1400 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1402 if(items.size() > 0)
1404 QTreeWidgetItem* item = items.first();
1419 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1420 if(items.size() > 0)
1422 QTreeWidgetItem* item = items.first();
1426 QTreeWidgetItemIterator it(item);
1430 QTreeWidgetItem* child_item = *it;
1443 else if(child_item->type() ==
LVRMeshItemType && child_item->parent() == item)
1446 if(mesh_item !=
NULL)
1498 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1500 if(items.size() > 0)
1502 QTreeWidgetItem* to_item = items.first();
1506 std::cout <<
"copy " << from_item->text(0).toStdString() << std::endl;
1507 QString name = from_item->text(0);
1510 bool child_name_exists =
false;
1511 bool recheck =
true;
1518 std::cout <<
"Change name to " << name.toStdString() << std::endl;
1522 QTreeWidgetItem* insert_item = from_item->clone();
1523 insert_item->setText(0, name);
1524 insert_item->setToolTip(0, name);
1528 to_item->addChild(insert_item);
1543 bool child_name_exists =
false;
1545 const int num_children = item->childCount();
1547 for(
int i=0; i<num_children; i++)
1549 const QTreeWidgetItem* child = item->child(i);
1550 const QString child_name = child->text(0);
1551 if(name == child_name)
1553 child_name_exists =
true;
1558 return child_name_exists;
1563 QRegExp rx(
"(\\d+)$");
1568 number = rx.cap(1).toInt();
1570 filename.replace(rx, QString::number(number));
1592 QList<LVRPointCloudItem*> pcs;
1594 for(QTreeWidgetItem* item : items)
1601 QTreeWidgetItemIterator it(item);
1604 QTreeWidgetItem* child_item = *it;
1606 && child_item->parent() == item)
1615 QTreeWidgetItemIterator it(item);
1618 QTreeWidgetItem* child_item = *it;
1620 && child_item->parent() == item)
1641 QTreeWidgetItemIterator it(item);
1645 QTreeWidgetItem* child_item = *it;
1661 QTreeWidgetItemIterator it(item);
1665 QTreeWidgetItem* child_item = *it;
1666 if(child_item->type() ==
LVRMeshItemType && child_item->parent() == item)
1678 std::set<LVRModelItem*> items;
1679 for (QTreeWidgetItem* item : treeWidget->selectedItems())
1684 items.insert(modelItem);
1691 std::set<LVRPointCloudItem*> items;
1692 for (QTreeWidgetItem* item : treeWidget->selectedItems())
1697 items.insert(pointCloudItem);
1704 std::set<LVRMeshItem*> items;
1705 for (QTreeWidgetItem* item : treeWidget->selectedItems())
1710 items.insert(modelItem);
1728 QTreeWidgetItemIterator it(treeWidgetItem);
1732 QTreeWidgetItem* child_item = *it;
1769 else if (treeWidgetItem->parent() && treeWidgetItem->parent()->type() ==
LVRScanDataItemType)
1779 for (QTreeWidgetItem* item : treeWidget->selectedItems())
1783 QTreeWidgetItemIterator it(item);
1787 QTreeWidgetItem* child_item = *it;
1808 for (QTreeWidgetItem* item : treeWidget->selectedItems())
1810 float opacityValue = 1 - ((float)transparencyValue / (
float)100);
1814 QTreeWidgetItemIterator it(item);
1818 QTreeWidgetItem* child_item = *it;
1824 else if(child_item->type() ==
LVRMeshItemType && child_item->parent()->isSelected())
1849 for (QTreeWidgetItem* item : treeWidget->selectedItems())
1862 QTreeWidgetItemIterator it(treeWidget);
1866 QTreeWidgetItem* item = *it;
1888 QTreeWidgetItemIterator it(treeWidget);
1892 QTreeWidgetItem* item = *it;
1899 model_item->
getModelBridge()->setNormalsVisibility(checkboxState);
1911 QTreeWidgetItemIterator it(treeWidget);
1915 QTreeWidgetItem* item = *it;
1931 QTreeWidgetItemIterator it(treeWidget);
1935 QTreeWidgetItem* item = *it;
1958 QTreeWidgetItem *lastItem =
nullptr;
1959 std::vector<ScanPtr> scans = sdm->getScans();
1960 std::vector<std::vector<ScanImage> > camData = sdm->getCameraData();
1962 bool cam_data_available = camData.size() > 0;
1964 for (
size_t i = 0; i < scans.size(); i++)
1967 std::sprintf(buf,
"%05d", scans[i]->positionNumber);
1970 if(cam_data_available && camData[i].size() > 0)
1973 cameras_item->setText(0, QString(
"Photos"));
1976 for(
int j=0; j < camData[i].size(); j++)
1979 std::sprintf(buf2,
"%05d", j);
1983 lastItem = cam_item;
1996 QStringList filenames;
2003 std::vector<std::string> files;
2004 files.push_back(
options.getInputFileName());
2005 for(
int i = 0; i < files.size(); i++)
2007 std::cout <<
"filename " << files[i] << std::endl;
2008 filenames << files[i].c_str();
2014 options.getHighResDistance());
2026 vtkSmartPointer<vtkAreaPicker> AreaPicker = vtkSmartPointer<vtkAreaPicker>::New();
2027 qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(AreaPicker);
2030 vtkSmartPointer<vtkPointPicker> pointPicker = vtkSmartPointer<vtkPointPicker>::New();
2031 qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(pointPicker);
2058 QColor c = QColorDialog::getColor();
2061 for (QTreeWidgetItem* item : treeWidget->selectedItems())
2087 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2088 if(items.size() > 0)
2090 QTreeWidgetItem* item = items.first();
2119 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2121 if(items.size() > 0)
2125 QList<QTreeWidgetItem*> parent_items;
2128 parent_items.append(pc_item->parent());
2131 if(pc_items.size() > 0)
2138 qvtkWidget->GetRenderWindow()->Render();
2145 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2146 if(items.size() > 0)
2149 QTreeWidgetItem* parent_item = pc_item->parent();
2163 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2164 if(items.size() > 0)
2181 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2182 if(items.size() > 0)
2199 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2200 if(items.size() > 0)
2204 if(mesh_item !=
NULL)
2217 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2218 if(items.size() > 0)
2222 if(mesh_item !=
NULL)
2235 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2236 if(items.size() > 0)
2253 QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2254 if(items.size() > 0)
2270 string titleString = str(boost::format(
"Unsupported Item for %1%.") % actionName);
2271 QString title = QString::fromStdString(titleString);
2272 string bodyString =
"Only %2% are applicable to %1%.";
2276 bodyString = str(boost::format(bodyString) % actionName %
"whole models");
2278 bodyString = str(boost::format(bodyString) % actionName %
"point clouds");
2280 bodyString = str(boost::format(bodyString) % actionName %
"meshes");
2282 bodyString = str(boost::format(bodyString) % actionName %
"point clouds and model items containing point clouds");
2284 bodyString = str(boost::format(bodyString) % actionName %
"meshes and model items containing meshes");
2286 bodyString = str(boost::format(bodyString) % actionName %
"point clouds, meshes and whole models");
2288 body = QString::fromStdString(bodyString);
2304 if(pointCloudItems.empty())
2313 if (!points->getUCharChannel(
"spectral_channels"))
2329 if (actor ==
nullptr || point < 0)
2335 QTreeWidgetItemIterator it(treeWidget);
2342 if (pbuf->getPointCloudActor() == actor)
2344 pointBridge = pbuf.get();
2351 if (pointBridge ==
nullptr)
2373 case QAbstractSlider::SliderSingleStepAdd:
2374 case QAbstractSlider::SliderSingleStepSub:
2375 case QAbstractSlider::SliderPageStepAdd:
2376 case QAbstractSlider::SliderPageStepSub:
2383 for (
int i = 0; i < 3; i++)
2413 int min = *points->getIntAtomic(
"spectral_wavelength_min");
2414 int max = *points->getIntAtomic(
"spectral_wavelength_max");
2419 int wavelength = test.toUInt(&ok);
2426 if (wavelength < min)
2428 else if (wavelength >= max)
2438 if (!this->dockWidgetSpectralSliderSettingsContents->isEnabled())
2455 for (
int i = 0; i < 3; i++)
2469 item->getPointBufferBridge()->setSpectralChannels(channels, use_channel);
2480 int min = *points->getIntAtomic(
"spectral_wavelength_min");
2481 int max = *points->getIntAtomic(
"spectral_wavelength_max");
2483 for (
int i = 0; i < 3; i++)
2487 int wavelength = test.toUInt(&ok);
2493 if (wavelength < min)
2495 else if (wavelength >= max)
2507 case QAbstractSlider::SliderSingleStepAdd:
2508 case QAbstractSlider::SliderSingleStepSub:
2509 case QAbstractSlider::SliderPageStepAdd:
2510 case QAbstractSlider::SliderPageStepSub:
2528 if (!this->dockWidgetSpectralColorGradientSettingsContents->isEnabled())
2547 bool useNDVI = this->checkBox_NDVI->isChecked();
2548 bool normalized = this->checkBox_normcolors->isChecked();
2549 int type = this->comboBox_colorgradient->currentIndex();
2553 item->getPointBufferBridge()->setSpectralColorGradient((
GradientType)type, channel,
normalized, useNDVI);
2563 size_t n = points->numPoints();
2564 points->getPointArray();
2565 if (pointId < 0 || pointId >= n)
2570 size_t n_spec, n_channels;
2573 if (spectral_channels)
2575 size_t n_spec = spectral_channels->numElements();
2576 unsigned n_channels = spectral_channels->width();
2578 if (pointId >= n_spec)
2584 floatArr data(
new float[n_channels]);
2585 for (
int i = 0; i < n_channels; i++)
2587 data[i] = (*spectral_channels)[pointId][i] / 255.0;
2597 if (checked == this->frameSpectralSlidersArea->isEnabled())
2604 item->getPointBufferBridge()->useGradient(!checked);
2608 this->frameSpectralSlidersArea->setEnabled(checked);
2609 this->frameSpectralGradientArea->setEnabled(!checked);
2610 this->radioButtonUseSpectralGradient->setChecked(!checked);
2615 if (checked == this->frameSpectralGradientArea->isEnabled())
2622 item->getPointBufferBridge()->useGradient(checked);
2626 this->frameSpectralGradientArea->setEnabled(checked);
2627 this->frameSpectralSlidersArea->setEnabled(!checked);
2628 this->radioButtonUseSpectralSlider->setChecked(!checked);
2639 for(
auto& it: lowRes)
2642 it.second->ReleaseGraphicsResources(
m_renderer->GetRenderWindow());
2645 for(
auto& it: highRes)
2657 int topItemCount = labelTreeWidget->topLevelItemCount();
2658 for (
int i = 0; i < topItemCount; i++)
2660 QTreeWidgetItem* topLevelItem = labelTreeWidget->topLevelItem(i);
2661 int childCount = topLevelItem->childCount();
2662 for (
int j = 0; j < childCount; j++)
2666 int pointCountDifference = selectedPointCount - topLevelItem->child(j)->text(
LABELED_POINT_COLUMN).toInt();
2681 QString label_name = QInputDialog::getText(
this,
tr(
"Select Label Name"),
2684 if (accepted && !label_name.isEmpty())
2687 if (!item->parent())
2704 QColor label_color = QColorDialog::getColor(Qt::red,
this,
tr(
"Choose Label Color"));
2705 if (label_color.isValid())
2717 QMessageBox colorUpdateDialog;
2718 colorUpdateDialog.setText(
"Labelclass default color changed. Shall all instance colors be updated?");
2719 colorUpdateDialog.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
2720 colorUpdateDialog.setDefaultButton(QMessageBox::Yes);
2721 int returnValue = colorUpdateDialog.exec();
2722 if (returnValue == QMessageBox::Yes)
2725 for (
int i = 0; i < item->childCount(); i++)
2755 if (changedItem->parent())
2762 for (
int i = 0; i < changedItem->childCount(); i++)
2764 QTreeWidgetItem* childItem = changedItem->child(i);
2780 QString instance_name = QInputDialog::getText(
this,
tr(
"Choose Name for new Instance"),
2782 QString(choosenLabel + QString::number(selectedTopLevelItem->childCount() + 1)) , &accepted);
2783 if (!accepted || instance_name.isEmpty())
2789 QColor label_color = QColorDialog::getColor(selectedTopLevelItem->data(
LABEL_ID_COLUMN, 1).value<QColor>(),
this,
tr(
"Choose Label Color for first instance"));
2790 if (!label_color.isValid())
2803 selectedTopLevelItem->addChild(childItem);
2816 QString fileName = QFileDialog::getOpenFileName(
this,
2817 tr(
"Open HDF5 File"), QDir::homePath(),
tr(
"HDF5 files (*.h5)"));
2818 if(!QFile::exists(fileName))
2824 std::vector<std::string> pointCloudNames;
2826 for (
auto pointcloudName : pointCloudNames)
2829 boost::filesystem::path classGroup = (boost::filesystem::path(
"pointclouds") / boost::filesystem::path(pointcloudName) / boost::filesystem::path(
"labels"));
2830 std::vector<std::string> labelClasses;
2832 for (
auto labelClass : labelClasses)
2835 QTreeWidgetItem * item =
new QTreeWidgetItem();
2836 item->setText(0, QString::fromStdString(labelClass));
2840 labelTreeWidget->addTopLevelItem(item);
2844 boost::filesystem::path instanceGroup = (classGroup / boost::filesystem::path(labelClass));
2845 std::vector<std::string> labelInstances;
2846 kernel.
subGroupNames(instanceGroup.string(), labelInstances);
2847 for (
auto instance : labelInstances)
2851 boost::filesystem::path finalGroup = instanceGroup;
2853 finalGroup = (instanceGroup / boost::filesystem::path(instance));
2861 boost::shared_array<int> rgbData;
2862 std::vector<size_t> rgbDim;
2863 boost::shared_array<int> idData;
2864 std::vector<size_t> idDim;
2865 idData = kernel.
loadArray<
int>(finalGroup.string(),
"IDs", idDim);
2866 rgbData = kernel.
loadArray<
int>(finalGroup.string(),
"Color", rgbDim);
2869 QTreeWidgetItem * childItem =
new QTreeWidgetItem();
2871 childItem->setText(0, QString::fromStdString(instance));
2872 QColor label_color(rgbData[0], rgbData[1], rgbData[2]);
2875 item->addChild(childItem);
2877 std::vector<int> out(idData.get(), idData.get() + idDim[0]);
2888 vtkSmartPointer<vtkPolyData> points;
2889 std::map<uint16_t,std::vector<int>> idMap;
2891 for (
int i = 0; i < labeledPoints.size(); i++)
2894 if(idMap.find(labeledPoints[i]) == idMap.end())
2897 idMap[labeledPoints[i]] = {};
2899 idMap[labeledPoints[i]].push_back(i);
2903 dialog.setDirectory(QDir::homePath());
2904 dialog.setFileMode(QFileDialog::AnyFile);
2905 QString strFile = dialog.getSaveFileName(
this,
"Creat New HDF5 File",
"",
"");
2907 HDF5Kernel label_hdf5kernel((strFile + QString(
".h5")).toStdString());
2908 int topItemCount = labelTreeWidget->topLevelItemCount();
2912 boost::filesystem::path pointcloudName;
2913 QTreeWidgetItemIterator itu(treeWidget);
2917 QTreeWidgetItem* item = *itu;
2922 pointcloudName = item->parent()->text(0).toStdString();
2928 double* pointsData =
new double[points->GetNumberOfPoints() * 3];
2930 for (
int i = 0; i < points->GetNumberOfPoints(); i++)
2932 auto point = points->GetPoint(i);
2933 pointsData[(3 * i)] = point[0];
2934 pointsData[(3 * i) + 1] = point[1];
2935 pointsData[(3 * i) + 2] = point[2];
2939 std::vector<size_t> pointsDimension = {3, points->GetNumberOfPoints()};
2940 boost::shared_array<double> sharedPoints(pointsData);
2943 QTreeWidgetItem* unlabeledItem;
2945 boost::filesystem::path pointGroup = (boost::filesystem::path(
"pointclouds") / pointcloudName);
2946 label_hdf5kernel.
saveDoubleArray(pointGroup.string(),
"Points" , pointsDimension, sharedPoints);
2947 for (
int i = 0; i < topItemCount; i++)
2949 QTreeWidgetItem* topLevelItem = labelTreeWidget->topLevelItem(i);
2952 unlabeledItem = topLevelItem;
2954 boost::filesystem::path topLabel = topLevelItem->text(
LABEL_NAME_COLUMN).toStdString();
2955 int childCount = topLevelItem->childCount();
2956 for (
int j = 0; j < childCount; j++)
2958 int childID = topLevelItem->child(j)->data(
LABEL_ID_COLUMN, 0).toInt();
2959 int* sharedArrayData =
new int[idMap[childID].size()];
2960 std::memcpy(sharedArrayData, idMap[childID].data(), idMap[childID].size() *
sizeof(
int));
2961 boost::shared_array<int> data(sharedArrayData);
2962 std::vector<size_t> dimension = {idMap[childID].size()};
2963 if(idMap.find(childID) != idMap.end())
2965 boost::filesystem::path childLabel = (topLevelItem->child(j)->text(
LABEL_NAME_COLUMN)).toStdString();
2966 boost::filesystem::path completeGroup = (pointGroup / boost::filesystem::path(
"labels") / topLabel / childLabel);
2968 label_hdf5kernel.
saveArray(completeGroup.string(),
"IDs" , dimension, data);
2969 int* rgbSharedData =
new int[3];
2970 (topLevelItem->child(j)->data(
LABEL_ID_COLUMN, 1)).value<QColor>().getRgb(&rgbSharedData[0], &rgbSharedData[1], &rgbSharedData[2]);
2971 boost::shared_array<int> rgbData(rgbSharedData);
2972 std::vector<size_t> rgbDimension = {3};
2973 label_hdf5kernel.
saveArray(completeGroup.string(),
"Color" , rgbDimension, rgbData);
2981 Q_EMIT(
labelChanged(selectedInstanceComboBox->itemData(index).toInt()));