LVRMainWindow.cpp
Go to the documentation of this file.
1 
35 #include <QFileInfo>
36 #include <QAbstractItemView>
37 #include <QtGui>
38 
39 #include "LVRMainWindow.hpp"
40 
41 #include "lvr2/io/ModelFactory.hpp"
42 #include "lvr2/io/DataStruct.hpp"
43 #include "lvr2/io/IOUtils.hpp"
45 
48 #include "lvr2/util/Util.hpp"
49 
50 #include <vtkActor.h>
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>
58 
59 #include "../vtkBridge/LVRChunkedMeshBridge.hpp"
60 #include "../vtkBridge/LVRChunkedMeshCuller.hpp"
61 
62 
63 #include <QString>
64 
65 #include <boost/filesystem.hpp>
66 #include <boost/tokenizer.hpp>
67 
68 #include <QMetaType>
69 
70 #include "Options.hpp"
71 
72 namespace lvr2
73 {
74 
75 using Vec = BaseVector<float>;
76 const string LVRMainWindow::UNKNOWNNAME = "Unlabeled";
77 
79 {
80  setupUi(this);
81  setupQVTK();
82 
83  // Init members
85  m_labelDialog = new LVRLabelDialog(treeWidget);
86  m_incompatibilityBox = new QMessageBox();
87  m_aboutDialog = new QDialog(this);
88  Ui::AboutDialog aboutDialog;
89  aboutDialog.setupUi(m_aboutDialog);
90 
91  m_errorDialog = new QDialog(this);
92  Ui::TooltipDialog tooltipDialog;
93  tooltipDialog.setupUi(m_errorDialog);
94 
95  m_previewPointBuffer = nullptr;
96 
97  // Setup specific properties
98  QHeaderView* v = this->treeWidget->header();
99  v->resizeSection(0, 175);
100 
101  treeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
102  treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
103 
104  m_treeWidgetHelper = new LVRTreeWidgetHelper(treeWidget);
105 
106 
107  m_actionCopyModelItem = new QAction("Copy item", this);
108  m_actionCopyModelItem->setShortcut(QKeySequence::Copy);
109  m_actionCopyModelItem->setShortcutContext(Qt::ApplicationShortcut);
110 #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
111  m_actionCopyModelItem->setShortcutVisibleInContextMenu(true);
112 #endif
113 
114 
115  m_actionPasteModelItem = new QAction("Paste item", this);
116  m_actionPasteModelItem->setShortcut(QKeySequence::Paste);
117  m_actionPasteModelItem->setShortcutContext(Qt::ApplicationShortcut);
118 #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
119  m_actionPasteModelItem->setShortcutVisibleInContextMenu(true);
120 #endif
121 
122 
123  m_actionRenameModelItem = new QAction("Rename item", this);
124  m_actionDeleteModelItem = new QAction("Delete item", this);
125  m_actionExportModelTransformed = new QAction("Export item with transformation", this);
126  m_actionShowColorDialog = new QAction("Select base color...", this);
127  m_actionLoadPointCloudData = new QAction("load PointCloud", this);
128  m_actionUnloadPointCloudData = new QAction("unload PointCloud", this);
129 
130  m_actionAddLabelClass = new QAction("Add label class", this);
131  m_actionAddNewInstance = new QAction("Add new instance", this);
132  m_actionRemoveInstance = new QAction("Remove instance", this);
133 
134  m_actionShowImage = new QAction("Show Image", this);
135  m_actionSetViewToCamera = new QAction("Set view to camera", this);
136 
137  this->addAction(m_actionCopyModelItem);
138  this->addAction(m_actionPasteModelItem);
139 
140  m_labelTreeParentItemContextMenu = new QMenu();
143  m_labelTreeChildItemContextMenu = new QMenu();
145 
146  m_treeParentItemContextMenu = new QMenu;
150 
151  m_treeChildItemContextMenu = new QMenu;
156 
157  m_PointPreviewPlotter = this->plotter;
158  this->dockWidgetSpectralSliderSettings->close();
159  this->dockWidgetSpectralColorGradientSettings->close();
160  this->dockWidgetPointPreview->close();
161  this->dockWidgetLabel->close();
162 
163  // Toolbar item "File"
164  m_actionOpen = this->actionOpen;
165  m_actionOpenChunkedMesh = this->actionOpenChunkedMesh;
166  m_actionExport = this->actionExport;
167  m_actionQuit = this->actionQuit;
168  // Toolbar item "Views"
169  m_actionReset_Camera = this->actionReset_Camera;
170  m_actionStore_Current_View = this->actionStore_Current_View;
171  m_actionRecall_Stored_View = this->actionRecall_Stored_View;
172  m_actionCameraPathTool = this->actionCameraPathTool;
173  // Toolbar item "Reconstruction"
174  m_actionEstimate_Normals = this->actionEstimate_Normals; // TODO: fix normal estimation
175  m_actionMarching_Cubes = this->actionMarching_Cubes;
176  m_actionPlanar_Marching_Cubes = this->actionPlanar_Marching_Cubes;
177  m_actionExtended_Marching_Cubes = this->actionExtended_Marching_Cubes;
178  m_actionCompute_Textures = this->actionCompute_Textures; // TODO: Compute textures
179  m_actionMatch_Textures_from_Package = this->actionMatch_Textures_from_Package; // TODO: Match textures from package
180  m_actionExtract_and_Rematch_Patterns = this->actionExtract_and_Rematch_Patterns; // TODO: Extract and rematch patterns
181  // Toolbar item "Mesh Optimization"
182  m_actionPlanar_Optimization = this->actionPlanar_Optimization;
183  m_actionRemove_Artifacts = this->actionRemove_Artifacts;
184  // Toolbar item "Filtering"
185  m_actionRemove_Outliers = this->actionRemove_Outliers;
186  m_actionMLS_Projection = this->actionMLS_Projection;
187  // Toolbar item "Registration"
188  m_actionICP_Using_Manual_Correspondance = this->actionICP_Using_Manual_Correspondance;
189  m_actionICP_Using_Pose_Estimations = this->actionICP_Using_Pose_Estimations; // TODO: implement ICP registration
190  m_actionGlobal_Relaxation = this->actionGlobal_Relaxation; // TODO: implement global relaxation
191  // Toolbar item "Classification"
192  m_actionSimple_Plane_Classification = this->actionSimple_Plane_Classification;
193  m_actionFurniture_Recognition = this->actionFurniture_Recognition;
194 
195  //Toolbar item "Labeling"
196  m_actionStart_labeling = this->actionLabeling_Start;
197  m_actionStop_labeling = this->actionLabeling_Stop;
198  m_actionExtract_labeling = this->actionLabeling_Export;
199 
200  // Toolbar item "About"
201  // TODO: Replace "About"-QMenu with "About"-QAction
202  m_menuAbout = this->menuAbout;
203  // QToolbar below toolbar
204  m_actionShow_Points = this->actionShow_Points;
205  m_actionShow_Normals = this->actionShow_Normals;
206  m_actionShow_Mesh = this->actionShow_Mesh;
207  m_actionShow_Wireframe = this->actionShow_Wireframe;
208  m_actionShowBackgroundSettings = this->actionShowBackgroundSettings;
209  m_actionShowSpectralSlider = this->actionShow_SpectralSlider;
210  m_actionShowSpectralColorGradient = this->actionShow_SpectralColorGradient;
211  m_actionShowSpectralPointPreview = this->actionShow_SpectralPointPreview;
212  m_actionShowSpectralHistogram = this->actionShow_SpectralHistogram;
213 
214  // Slider below tree widget
215 // m_horizontalSliderPointSize = this->horizontalSliderPointSize;
216 // m_horizontalSliderTransparency = this->horizontalSliderTransparency;
217 // // Combo boxes
218 // m_comboBoxGradient = this->comboBoxGradient; // TODO: implement gradients
219 // m_comboBoxShading = this->comboBoxShading; // TODO: fix shading
220  // Buttons below combo boxes
221  m_buttonCameraPathTool = this->buttonCameraPathTool;
222  m_buttonCreateMesh = this->buttonCreateMesh;
223  m_buttonExportData = this->buttonExportData;
224  m_buttonTransformModel = this->buttonTransformModel;
225 
226  // Spectral Settings
227  m_spectralSliders[0] = this->horizontalSlider_Hyperspectral_red;
228  m_spectralSliders[1] = this->horizontalSlider_Hyperspectral_green;
229  m_spectralSliders[2] = this->horizontalSlider_Hyperspectral_blue;
230  m_spectralCheckboxes[0] = this->checkBox_hred;
231  m_spectralCheckboxes[1] = this->checkBox_hgreen;
232  m_spectralCheckboxes[2] = this->checkBox_hblue;
233  m_spectralLabels[0] = this->label_hred;
234  m_spectralLabels[1] = this->label_hgreen;
235  m_spectralLabels[2] = this->label_hblue;
236  m_spectralLineEdits[0] = this->lineEdit_hred;
237  m_spectralLineEdits[1] = this->lineEdit_hgreen;
238  m_spectralLineEdits[2] = this->lineEdit_hblue;
239 
240  m_gradientSlider = this->sliderGradientWavelength;
241  m_gradientLineEdit = this->lineEditGradientWavelength;
242 
243 
244  //vtkSmartPointer<vtkAreaPicker> areaPicker = vtkSmartPointer<vtkAreaPicker>::New();
245  //qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(areaPicker);
246  vtkSmartPointer<vtkPointPicker> pointPicker = vtkSmartPointer<vtkPointPicker>::New();
247  qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(pointPicker);
248 
249 
250  // Widget to display the coordinate system
251  m_axes = vtkSmartPointer<vtkAxesActor>::New();
252 
253  m_axesWidget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
254  m_axesWidget->SetOutlineColor( 0.9300, 0.5700, 0.1300 );
255  m_axesWidget->SetOrientationMarker( m_axes );
256  m_axesWidget->SetInteractor( m_renderer->GetRenderWindow()->GetInteractor() );
257  m_axesWidget->SetDefaultRenderer(m_renderer);
258  m_axesWidget->SetViewport( 0.0, 0.0, 0.3, 0.3 );
259  m_axesWidget->SetEnabled( 1 );
260  m_axesWidget->InteractiveOff();
261 
262  // Disable action if EDL is not available
263 #ifndef LVR2_USE_VTK_GE_7_1
264  actionRenderEDM->setEnabled(false);
265 #endif
266 
268 
269 }
270 
272 {
273 // this->qvtkWidget->GetRenderWindow()->RemoveRenderer(m_renderer);
274 
276  {
277  delete m_correspondanceDialog;
278  }
279  if(m_labelDialog)
280  {
281  delete m_labelDialog;
282  }
283 
285  {
286  qvtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(nullptr);
287  m_pickingInteractor->Delete();
288  }
289 
291  {
293  }
294 
296  {
298  }
299  if (m_treeWidgetHelper)
300  {
301  delete m_treeWidgetHelper;
302  }
303 
304  if (m_aboutDialog)
305  {
306  delete m_aboutDialog;
307  }
308  if (m_errorDialog)
309  {
310  delete m_errorDialog;
311  }
312  delete m_incompatibilityBox;
313 
316  delete m_actionCopyModelItem;
317  delete m_actionPasteModelItem;
322  delete m_actionShowImage;
324 
325 }
326 
328 {
329  QObject::connect(m_actionOpen, SIGNAL(triggered()), this, SLOT(loadModel()));
330  QObject::connect(m_actionOpenChunkedMesh, SIGNAL(triggered()), this, SLOT(loadChunkedMesh()));
331  QObject::connect(m_actionExport, SIGNAL(triggered()), this, SLOT(exportSelectedModel()));
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()));
336  QObject::connect(treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(highlightBoundingBoxes()));
337  QObject::connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(setModelVisibility(QTreeWidgetItem*, int)));
338 
339  QObject::connect(labelTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showLabelTreeContextMenu(const QPoint&)));
340 
341 
342  QObject::connect(m_actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
343 
344  QObject::connect(m_actionShowColorDialog, SIGNAL(triggered()), this, SLOT(showColorDialog()));
345  QObject::connect(m_actionRenameModelItem, SIGNAL(triggered()), this, SLOT(renameModelItem()));
346  QObject::connect(m_actionDeleteModelItem, SIGNAL(triggered()), this, SLOT(deleteModelItem()));
347  QObject::connect(m_actionCopyModelItem, SIGNAL(triggered()), this, SLOT(copyModelItem()));
348  QObject::connect(m_actionPasteModelItem, SIGNAL(triggered()), this, SLOT(pasteModelItem()));
349  QObject::connect(m_actionLoadPointCloudData, SIGNAL(triggered()), this, SLOT(loadPointCloudData()));
350  QObject::connect(m_actionUnloadPointCloudData, SIGNAL(triggered()), this, SLOT(unloadPointCloudData()));
351 
352  QObject::connect(m_actionAddLabelClass, SIGNAL(triggered()), this, SLOT(addLabelClass()));
353 
354  QObject::connect(selectedInstanceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(comboBoxIndexChanged(int)));
355 
356  QObject::connect(m_actionShowImage, SIGNAL(triggered()), this, SLOT(showImage()));
357  QObject::connect(m_actionSetViewToCamera, SIGNAL(triggered()), this, SLOT(setViewToCamera()));
358 
359 
360  QObject::connect(m_actionExportModelTransformed, SIGNAL(triggered()), this, SLOT(exportSelectedModel()));
361 
362  QObject::connect(m_actionReset_Camera, SIGNAL(triggered()), this, SLOT(updateView()));
363  QObject::connect(m_actionStore_Current_View, SIGNAL(triggered()), this, SLOT(saveCamera()));
364  QObject::connect(m_actionRecall_Stored_View, SIGNAL(triggered()), this, SLOT(loadCamera()));
365  QObject::connect(m_actionCameraPathTool, SIGNAL(triggered()), this, SLOT(openCameraPathTool()));
366 
367  QObject::connect(m_actionEstimate_Normals, SIGNAL(triggered()), this, SLOT(estimateNormals()));
368  QObject::connect(m_actionMarching_Cubes, SIGNAL(triggered()), this, SLOT(reconstructUsingMarchingCubes()));
369  QObject::connect(m_actionPlanar_Marching_Cubes, SIGNAL(triggered()), this, SLOT(reconstructUsingPlanarMarchingCubes()));
370  QObject::connect(m_actionExtended_Marching_Cubes, SIGNAL(triggered()), this, SLOT(reconstructUsingExtendedMarchingCubes()));
371 
372  QObject::connect(m_actionPlanar_Optimization, SIGNAL(triggered()), this, SLOT(optimizePlanes()));
373  QObject::connect(m_actionRemove_Artifacts, SIGNAL(triggered()), this, SLOT(removeArtifacts()));
374 
375  QObject::connect(m_actionRemove_Outliers, SIGNAL(triggered()), this, SLOT(removeOutliers()));
376  QObject::connect(m_actionMLS_Projection, SIGNAL(triggered()), this, SLOT(applyMLSProjection()));
377 
378  QObject::connect(m_actionICP_Using_Manual_Correspondance, SIGNAL(triggered()), this, SLOT(manualICP()));
379 
380  QObject::connect(m_menuAbout, SIGNAL(triggered(QAction*)), m_aboutDialog, SLOT(show()));
381 
382  QObject::connect(actionRenderEDM, SIGNAL(toggled(bool)), this, SLOT(toogleEDL(bool)));
383 
384  QObject::connect(m_actionShow_Points, SIGNAL(toggled(bool)), this, SLOT(togglePoints(bool)));
385  QObject::connect(m_actionShow_Normals, SIGNAL(toggled(bool)), this, SLOT(toggleNormals(bool)));
386  QObject::connect(m_actionShow_Mesh, SIGNAL(toggled(bool)), this, SLOT(toggleMeshes(bool)));
387  QObject::connect(m_actionShow_Wireframe, SIGNAL(toggled(bool)), this, SLOT(toggleWireframe(bool)));
388  QObject::connect(m_actionShowBackgroundSettings, SIGNAL(triggered()), this, SLOT(showBackgroundDialog()));
389  QObject::connect(m_actionShowSpectralSlider, SIGNAL(triggered()), dockWidgetSpectralSliderSettings, SLOT(show()));
390  QObject::connect(m_actionShowSpectralColorGradient, SIGNAL(triggered()), dockWidgetSpectralColorGradientSettings, SLOT(show()));
391  QObject::connect(m_actionShowSpectralPointPreview, SIGNAL(triggered()), dockWidgetPointPreview, SLOT(show()));
392  QObject::connect(m_actionShowSpectralHistogram, SIGNAL(triggered()), this, SLOT(showHistogramDialog()));
393 
394 // QObject::connect(m_horizontalSliderPointSize, SIGNAL(valueChanged(int)), this, SLOT(changePointSize(int)));
395 // QObject::connect(m_horizontalSliderTransparency, SIGNAL(valueChanged(int)), this, SLOT(changeTransparency(int)));
396 
397 // QObject::connect(m_comboBoxShading, SIGNAL(currentIndexChanged(int)), this, SLOT(changeShading(int)));
398 
399  QObject::connect(m_buttonCameraPathTool, SIGNAL(pressed()), this, SLOT(openCameraPathTool()));
400  QObject::connect(m_buttonCreateMesh, SIGNAL(pressed()), this, SLOT(reconstructUsingMarchingCubes()));
401  QObject::connect(m_buttonExportData, SIGNAL(pressed()), this, SLOT(exportSelectedModel()));
402  QObject::connect(m_buttonTransformModel, SIGNAL(pressed()), this, SLOT(showTransformationDialog()));
403 
404  for (int i = 0; i < 3; i++)
405  {
406  QObject::connect(m_spectralSliders[i], SIGNAL(valueChanged(int)), this, SLOT(onSpectralSliderChanged()));
407  QObject::connect(m_spectralSliders[i], SIGNAL(actionTriggered(int)), this, SLOT(onSpectralSliderChanged(int)));
408  QObject::connect(m_spectralSliders[i], SIGNAL(sliderReleased()), this, SLOT(changeSpectralColor()));
409  QObject::connect(m_spectralCheckboxes[i], SIGNAL(stateChanged(int)), this, SLOT(changeSpectralColor()));
410  QObject::connect(m_spectralLineEdits[i], SIGNAL(textChanged(QString)), this, SLOT(onSpectralLineEditChanged()));
411  QObject::connect(m_spectralLineEdits[i], SIGNAL(editingFinished()), this, SLOT(onSpectralLineEditSubmit()));
412  }
413 
414  QObject::connect(m_gradientLineEdit, SIGNAL(textChanged(QString)), this, SLOT(onGradientLineEditChanged()));
415  QObject::connect(m_gradientLineEdit, SIGNAL(editingFinished()), this, SLOT(onGradientLineEditSubmit()));
416  QObject::connect(m_gradientSlider, SIGNAL(valueChanged(int)), this, SLOT(onGradientSliderChanged()));
417  QObject::connect(m_gradientSlider, SIGNAL(actionTriggered(int)), this, SLOT(onGradientSliderChanged(int)));
418  QObject::connect(m_gradientSlider, SIGNAL(sliderReleased()), this, SLOT(changeGradientColor()));
419 
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()));
423 
424  QObject::connect(m_pickingInteractor, SIGNAL(firstPointPicked(double*)),m_correspondanceDialog, SLOT(firstPointPicked(double*)));
425  QObject::connect(m_pickingInteractor, SIGNAL(secondPointPicked(double*)),m_correspondanceDialog, SLOT(secondPointPicked(double*)));
426  QObject::connect(m_pickingInteractor, SIGNAL(pointSelected(vtkActor*, int)), this, SLOT(showPointPreview(vtkActor*, int)));
427  QObject::connect(m_pickingInteractor, SIGNAL(pointsLabeled(uint16_t, int)), m_labelDialog, SLOT(updatePointCount(uint16_t, int)));
428  QObject::connect(m_pickingInteractor, SIGNAL(pointsLabeled(const uint16_t, const int)), this, SLOT(updatePointCount(const uint16_t, const int)));
429  QObject::connect(m_pickingInteractor, SIGNAL(responseLabels(std::vector<uint16_t>)), m_labelDialog, SLOT(responseLabels(std::vector<uint16_t>)));
430 
431  QObject::connect(this, SIGNAL(labelAdded(QTreeWidgetItem*)), m_pickingInteractor, SLOT(newLabel(QTreeWidgetItem*)));
432  QObject::connect(m_labelDialog, SIGNAL(labelAdded(QTreeWidgetItem*)), m_pickingInteractor, SLOT(newLabel(QTreeWidgetItem*)));
433  QObject::connect(m_labelDialog, SIGNAL(labelLoaded(int, std::vector<int>)), m_pickingInteractor, SLOT(setLabel(int, std::vector<int>)));
434  QObject::connect(m_labelDialog->m_ui->exportLabelButton, SIGNAL(pressed()), m_pickingInteractor, SLOT(requestLabels()));
435  QObject::connect(m_labelDialog, SIGNAL(hidePoints(int, bool)), m_pickingInteractor, SLOT(setLabeledPointVisibility(int, bool)));
436  QObject::connect(this, SIGNAL(hidePoints(int, bool)), m_pickingInteractor, SLOT(setLabeledPointVisibility(int, bool)));
437 
438  QObject::connect(labelTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(visibilityChanged(QTreeWidgetItem*, int)));
439  QObject::connect(m_labelDialog, SIGNAL(labelChanged(uint16_t)), m_pickingInteractor, SLOT(labelSelected(uint16_t)));
440  QObject::connect(this, SIGNAL(labelChanged(uint16_t)), m_pickingInteractor, SLOT(labelSelected(uint16_t)));
441 
442  QObject::connect(labelTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(cellSelected(QTreeWidgetItem*, int)));
443  QObject::connect(m_labelDialog->m_ui->lassotoolButton, SIGNAL(toggled(bool)), m_pickingInteractor, SLOT(setLassoTool(bool)));
444 
445  // Interaction with interactor
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()));
455 
456 
457  QObject::connect(this->actionSelected_Lasso, SIGNAL(triggered()), this, SLOT(manualLabeling()));
458  QObject::connect(this->actionSelected_Polygon, SIGNAL(triggered()), this, SLOT(manualLabeling()));
459  QObject::connect(m_actionStop_labeling, SIGNAL(triggered()), this, SLOT(manualLabeling()));
460 // QObject::connect(m_labelInteractor, SIGNAL(pointsSelected()), this, SLOT(manualLabeling()));
461  // QObject::connect(m_labelInteractor, SIGNAL(pointsSelected()), m_labelDialog, SLOT(labelPoints()));
462 // QObject::connect(m_actionExtract_labeling, SIGNAL(triggered()), m_labelInteractor, SLOT(extractLabel()));
463  QObject::connect(m_correspondanceDialog, SIGNAL(disableCorrespondenceSearch()), m_pickingInteractor, SLOT(correspondenceSearchOff()));
464  QObject::connect(m_pickingInteractor, SIGNAL(labelingStarted(bool)), this, SLOT(changePicker(bool)));
465  QObject::connect(m_correspondanceDialog, SIGNAL(enableCorrespondenceSearch()), m_pickingInteractor, SLOT(correspondenceSearchOn()));
466  QObject::connect(m_correspondanceDialog->m_dialog, SIGNAL(accepted()), m_pickingInteractor, SLOT(correspondenceSearchOff()));
467  QObject::connect(m_correspondanceDialog->m_dialog, SIGNAL(rejected()), m_pickingInteractor, SLOT(correspondenceSearchOff()));
468  QObject::connect(m_correspondanceDialog->m_dialog, SIGNAL(accepted()), this, SLOT(alignPointClouds()));
469 
470  QObject::connect(m_correspondanceDialog, SIGNAL(addArrow(LVRVtkArrow*)), this, SLOT(addArrow(LVRVtkArrow*)));
471  QObject::connect(m_correspondanceDialog, SIGNAL(removeArrow(LVRVtkArrow*)), this, SLOT(removeArrow(LVRVtkArrow*)));
472 
473 
474  QObject::connect(plotter, SIGNAL(mouseRelease()), this, SLOT(showPointInfoDialog()));
475 
476  QObject::connect(radioButtonUseSpectralSlider, SIGNAL(toggled(bool)), this, SLOT(updateSpectralSlidersEnabled(bool)));
477  QObject::connect(radioButtonUseSpectralGradient, SIGNAL(toggled(bool)), this, SLOT(updateSpectralGradientEnabled(bool)));
478 
479  QObject::connect(this, SIGNAL(correspondenceDialogOpened()), m_pickingInteractor, SLOT(correspondenceSearchOn()));
480 }
481 
483 {
484  LVRBackgroundDialog dialog(qvtkWidget->GetRenderWindow());
485  if(dialog.exec() == QDialog::Accepted)
486  {
487  if(dialog.renderGradient())
488  {
489  float r1, r2, g1, g2, b1, b2;
490  dialog.getColor1(r1, g1, b1);
491  dialog.getColor2(r2, g2, b2);
492  m_renderer->GradientBackgroundOn();
493  m_renderer->SetBackground(r1, g1, b1);
494  m_renderer->SetBackground2(r2, g2, b2);
495  }
496  else
497  {
498  float r, g, b;
499  dialog.getColor1(r, g, b);
500  m_renderer->GradientBackgroundOff();
501  m_renderer->SetBackground(r, g, b);
502  }
503  this->qvtkWidget->GetRenderWindow()->Render();
504  }
505 }
506 
508 {
509 #ifndef LVR2_USE_VTK8
510  // z buffer fix
511  QSurfaceFormat surfaceFormat = qvtkWidget->windowHandle()->format();
512  surfaceFormat.setStencilBufferSize(8);
513  qvtkWidget->windowHandle()->setFormat(surfaceFormat);
514 #endif
515 
516  // Grab relevant entities from the qvtk widget
517  m_renderer = vtkSmartPointer<vtkRenderer>::New();
518 
519 #ifdef LVR2_USE_VTK_GE_7_1
520  m_renderer->TwoSidedLightingOn ();
521  m_renderer->UseHiddenLineRemovalOff();
522  m_renderer->RemoveAllLights();
523 #endif
524 
525  // Setup decent background colors
526  m_renderer->GradientBackgroundOn();
527  m_renderer->SetBackground(0.8, 0.8, 0.9);
528  m_renderer->SetBackground2(1.0, 1.0, 1.0);
529 
530  vtkSmartPointer<vtkRenderWindow> renderWindow = this->qvtkWidget->GetRenderWindow();
531 
532  m_renderWindowInteractor = this->qvtkWidget->GetInteractor();
533  m_renderWindowInteractor->Initialize();
534 
535 
536  // Camera that saves a position that can be loaded
537  m_camera = vtkSmartPointer<vtkCamera>::New();
538 
539  // Custom interactor to handle picking actions
540  //m_pickingInteractor = new LVRPickingInteractor();
541  //m_labelInteractor = LVRLabelInteractorStyle::New();
544 
545  qvtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle( m_pickingInteractor );
546  // qvtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle( m_labelInteractor );
547 
548  //vtkSmartPointer<vtkPointPicker> pointPicker = vtkSmartPointer<vtkPointPicker>::New();
549  vtkSmartPointer<vtkAreaPicker> pointPicker = vtkSmartPointer<vtkAreaPicker>::New();
550  qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(pointPicker);
551 
552  // Camera and camera interpolator to be used for camera paths
553  m_pathCamera = vtkSmartPointer<vtkCameraRepresentation>::New();
554  vtkSmartPointer<vtkCameraInterpolator> cameraInterpolator = vtkSmartPointer<vtkCameraInterpolator>::New();
555  cameraInterpolator->SetInterpolationTypeToSpline();
556  m_pathCamera->SetInterpolator(cameraInterpolator);
557  m_pathCamera->SetCamera(m_renderer->GetActiveCamera());
558 
559 
560 #ifdef LVR2_USE_VTK_GE_7_1
561  // Enable EDL per default
562  qvtkWidget->GetRenderWindow()->SetMultiSamples(0);
563 
564  m_basicPasses = vtkRenderStepsPass::New();
565  m_edl = vtkEDLShading::New();
566  m_edl->SetDelegatePass(m_basicPasses);
567  vtkOpenGLRenderer *glrenderer = vtkOpenGLRenderer::SafeDownCast(m_renderer);
568 
569  glrenderer->SetPass(m_edl);
570 #endif
571 
572  // Finalize QVTK setup by adding the renderer to the window
573  renderWindow->AddRenderer(m_renderer);
574 
575 }
576 
577 void LVRMainWindow::toogleEDL(bool state)
578 {
579 #ifdef LVR2_USE_VTK_GE_7_1
580  vtkOpenGLRenderer *glrenderer = vtkOpenGLRenderer::SafeDownCast(m_renderer);
581 
582  if(state == false)
583  {
584  glrenderer->SetPass(m_basicPasses);
585  }
586  else
587  {
588  glrenderer->SetPass(m_edl);
589  }
590  this->qvtkWidget->GetRenderWindow()->Render();
591 #endif
592 }
593 
594 
596 {
597  m_renderer->ResetCamera();
598  m_renderer->ResetCameraClippingRange();
599  this->qvtkWidget->GetRenderWindow()->Render();
600 
601  // Estimate cam speed -> imagine a plausible number
602  // of move operations to reach the focal point
603  vtkCamera* cam = m_renderer->GetActiveCamera();
604  double step = cam->GetDistance() / 100;
605 
606  this->doubleSpinBoxDollySpeed->setValue(step);
607 
608  // Signal that focal point of camera may have changed
610 }
611 
613 {
614  this->qvtkWidget->GetRenderWindow()->Render();
615 }
616 
618 {
619  m_camera->DeepCopy(m_renderer->GetActiveCamera());
620 }
621 
623 {
624  m_renderer->GetActiveCamera()->DeepCopy(m_camera);
625  refreshView();
626 }
627 
629 {
631 }
632 
634 {
635  if(a)
636  {
637  m_renderer->AddActor(a->getArrowActor());
638  m_renderer->AddActor(a->getStartActor());
639  m_renderer->AddActor(a->getEndActor());
640  }
641  this->qvtkWidget->GetRenderWindow()->Render();
642 }
643 
645 {
646  if(a)
647  {
648  m_renderer->RemoveActor(a->getArrowActor());
649  m_renderer->RemoveActor(a->getStartActor());
650  m_renderer->RemoveActor(a->getEndActor());
651  }
652  this->qvtkWidget->GetRenderWindow()->Render();
653 }
654 
656 {
657  std::set<LVRPointCloudItem*> pointCloudItems = getSelectedPointCloudItems();
658  std::set<LVRMeshItem*> meshItems = getSelectedMeshItems();
659 
660  if (!pointCloudItems.empty())
661  {
662  LVRPointCloudItem* pointCloudItem = *pointCloudItems.begin();
663 
664 // m_horizontalSliderPointSize->setEnabled(true);
665 // m_horizontalSliderPointSize->setValue(pointCloudItem->getPointSize());
666  int transparency = ((float)1 - pointCloudItem->getOpacity()) * 100;
667 // m_horizontalSliderTransparency->setEnabled(true);
668 // m_horizontalSliderTransparency->setValue(transparency);
669 
670  color<size_t> channels;
671  color<bool> use_channel;
672  size_t n_channels, gradient_channel;
673  bool use_ndvi, normalize_gradient;
674  GradientType gradient_type;
675 
676  pointCloudItem->getPointBufferBridge()->getSpectralChannels(channels, use_channel);
677  pointCloudItem->getPointBufferBridge()->getSpectralColorGradient(gradient_type, gradient_channel, normalize_gradient, use_ndvi);
678 
679  PointBufferPtr p = pointCloudItem->getPointBuffer();
680  UCharChannelOptional spec_channels = p->getUCharChannel("spectral_channels");
681 
682  if (spec_channels)
683  {
684  n_channels = spec_channels->width();
685  int wavelength_min = *p->getIntAtomic("spectral_wavelength_min");
686  int wavelength_max = *p->getIntAtomic("spectral_wavelength_max");
687 
688  this->dockWidgetSpectralSliderSettingsContents->setEnabled(false); // disable to stop changeSpectralColor from re-rendering 6 times
689  for (int i = 0; i < 3; i++)
690  {
691  m_spectralSliders[i]->setMaximum(wavelength_max - 1);
692  m_spectralSliders[i]->setMinimum(wavelength_min);
693  m_spectralSliders[i]->setSingleStep(Util::wavelengthPerChannel(p));
694  m_spectralSliders[i]->setPageStep(10 * Util::wavelengthPerChannel(p));
695  m_spectralSliders[i]->setValue(Util::getSpectralWavelength(channels[i], p));
696  m_spectralSliders[i]->setEnabled(use_channel[i]);
697  m_spectralLineEdits[i]->setEnabled(use_channel[i]);
698 
699  m_spectralCheckboxes[i]->setChecked(use_channel[i]);
700 
701  m_spectralLineEdits[i]->setText(QString("%1").arg(Util::getSpectralWavelength(channels[i], p)));
702  }
703  this->dockWidgetSpectralSliderSettingsContents->setEnabled(true);
704 
705  this->dockWidgetSpectralColorGradientSettingsContents->setEnabled(false);
706  m_gradientSlider->setMaximum(wavelength_max - 1);
707  m_gradientSlider->setMinimum(wavelength_min);
708  m_gradientSlider->setValue(Util::getSpectralWavelength(gradient_channel, p));
709  m_gradientSlider->setEnabled(!use_ndvi);
710  m_gradientLineEdit->setEnabled(!use_ndvi);
711 
712  this->checkBox_NDVI->setChecked(use_ndvi);
713  this->checkBox_normcolors->setChecked(normalize_gradient);
714  this->comboBox_colorgradient->setCurrentIndex((int)gradient_type);
715  m_gradientLineEdit->setText(QString("%1").arg(Util::getSpectralWavelength(gradient_channel, p)));
716  this->dockWidgetSpectralColorGradientSettingsContents->setEnabled(true);
717  }
718  else
719  {
720  this->dockWidgetSpectralSliderSettingsContents->setEnabled(false);
721  this->dockWidgetSpectralColorGradientSettingsContents->setEnabled(false);
722  }
723  }
724  else
725  {
726 // m_horizontalSliderPointSize->setEnabled(false);
727 // m_horizontalSliderPointSize->setValue(1);
728 
729  this->dockWidgetSpectralSliderSettingsContents->setEnabled(false);
730  this->dockWidgetSpectralColorGradientSettingsContents->setEnabled(false);
731  }
732 
733  if (!meshItems.empty())
734  {
735  LVRMeshItem* meshItem = *meshItems.begin();
736 
737  int transparency = ((float)1 - meshItem->getOpacity()) * 100;
738 // m_horizontalSliderTransparency->setEnabled(true);
739 // m_horizontalSliderTransparency->setValue(transparency);
740  }
741 
742  if (pointCloudItems.empty() && meshItems.empty())
743  {
744 // m_horizontalSliderTransparency->setEnabled(false);
745 // m_horizontalSliderTransparency->setValue(0);
746  }
747 }
748 
749 bool isSelfOrChildSelected(QTreeWidgetItem *item)
750 {
751 
752  bool selected = item->isSelected();
753 
754  for (int i = 0; i < item->childCount() && !selected; i++)
755  {
756  selected = isSelfOrChildSelected(item->child(i));
757  }
758 
759  return selected;
760 }
761 
763 {
764  QTreeWidgetItemIterator it(treeWidget);
765 
766  while (*it)
767  {
768  if ((*it)->type() == LVRBoundingBoxItemType)
769  {
770  LVRBoundingBoxItem *item = static_cast<LVRBoundingBoxItem *>(*it);
771  item->getBoundingBoxBridge()->setColor(1.0, 1.0, 1.0);
772 
773  if (item->parent() && item->parent()->type() == LVRScanDataItemType)
774  {
775  QTreeWidgetItem *parent = item->parent();
776 
777  if (isSelfOrChildSelected(parent))
778  {
779  item->getBoundingBoxBridge()->setColor(1.0, 1.0, 0.0);
780  }
781  }
782  }
783 
784  if ((*it)->type() == LVRPointCloudItemType)
785  {
786  LVRPointCloudItem *item = static_cast<LVRPointCloudItem *>(*it);
787  item->resetColor();
788 
789  QTreeWidgetItem *parent = item->parent();
790  if (!parent || (parent->type() != LVRScanDataItemType && parent->type() != LVRModelItemType))
791  {
792  parent = *it;
793  }
794 
795  if (isSelfOrChildSelected(parent))
796  {
797  QColor color;
798  color.setRgbF(1.0, 1.0, 0.0);
799  item->setSelectionColor(color);
800  }
801  }
802 
803  it++;
804  }
805 
806  refreshView();
807 }
808 
810 {
811  // Get selected point cloud
812  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
813  if(items.size() > 0)
814  {
815  QTreeWidgetItem* item = items.first();
816  if(item->type() == LVRPointCloudItemType)
817  {
818  if(item->parent() && item->parent()->type() == LVRModelItemType)
819  {
820  QString qFileName = QFileDialog::getSaveFileName(this, tr("Export Point Cloud As..."), "", tr("Point cloud Files(*.ply *.3d)"));
821 
822  LVRModelItem* model_item = static_cast<LVRModelItem*>(item->parent());
823  LVRPointCloudItem* pc_item = static_cast<LVRPointCloudItem*>(item);
824  PointBufferPtr points = pc_item->getPointBuffer();
825 
826  // Get transformation matrix
827  Pose p = model_item->getPose();
828  Matrix4<Vec> mat(Vec(p.x, p.y, p.z), Vec(p.r, p.t, p.p));
829 
830  // Allocate target buffer and insert transformed points
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++)
835  {
836  Vec v(pointArray[3 * i], pointArray[3 * i + 1], pointArray[3 * i + 2]);
837  Vec vt = mat * v;
838 
839  transformedPoints[3 * i ] = vt[0];
840  transformedPoints[3 * i + 1] = vt[1];
841  transformedPoints[3 * i + 2] = vt[2];
842  }
843 
844  // Save transformed points
845  PointBufferPtr trans(new PointBuffer);
846  trans->setPointArray(transformedPoints, n);
847  ModelPtr model(new Model(trans));
848  ModelFactory::saveModel(model, qFileName.toStdString());
849  }
850  }
851  }
852 }
853 
855 {
856  QString dataName = m_correspondanceDialog->getDataName();
857  QString modelName = m_correspondanceDialog->getModelName();
858 
859  PointBufferPtr modelBuffer = m_treeWidgetHelper->getPointBuffer(modelName);
860  PointBufferPtr dataBuffer = m_treeWidgetHelper->getPointBuffer(dataName);
861 
862  LVRModelItem* dataItem = m_treeWidgetHelper->getModelItem(dataName);
863  LVRModelItem* modelItem = m_treeWidgetHelper->getModelItem(modelName);
864  if (!dataItem || !modelItem) {
865  return;
866  }
867 
868  Pose dataPose = dataItem->getPose();
869  Eigen::Vector3f pos(dataPose.x, dataPose.y, dataPose.z);
870  Eigen::Vector3f angles(dataPose.r, dataPose.t, dataPose.p);
871  angles *= M_PI / 180.0; // degrees -> radians
872  Transformf mat = poseToMatrix<float>(pos, angles);
873 
874  boost::optional<Transformf> correspondence = m_correspondanceDialog->getTransformation();
875  if (correspondence.is_initialized())
876  {
877  mat *= correspondence.get();
878  matrixToPose(mat, pos, angles);
879  angles *= 180.0 / M_PI; // radians -> degrees
880 
881  dataItem->setPose(Pose {
882  pos.x(), pos.y(), pos.z(),
883  angles.x(), angles.y(), angles.z()
884  });
885 
886  updateView();
887  }
888 
889  // Refine pose via ICP
890  if(m_correspondanceDialog->doICP() && modelBuffer && dataBuffer)
891  {
892  Pose modelPose = modelItem->getPose();
893  pos = Eigen::Vector3f(modelPose.x, modelPose.y, modelPose.z);
894  angles = Eigen::Vector3f(modelPose.r, modelPose.t, modelPose.p);
895  angles /= 180.0 / M_PI;
896  Transformf modelTransform = poseToMatrix<float>(pos, angles);
897 
898  /* TODO: convert to new ICPPointAlign
899 
900  ICPPointAlign icp(modelBuffer, dataBuffer, modelTransform, mat);
901  icp.setEpsilon(m_correspondanceDialog->getEpsilon());
902  icp.setMaxIterations(m_correspondanceDialog->getMaxIterations());
903  icp.setMaxMatchDistance(m_correspondanceDialog->getMaxDistance());
904  Matrix4d refinedTransform = icp.match();
905 
906  matrixToPose(refinedTransform, pos, angles);
907  angles *= M_PI / 180.0; // radians -> degrees
908 
909  dataItem->setPose(Pose {
910  pos.x(), pos.y(), pos.z(),
911  angles.x(), angles.y(), angles.z()
912  });
913  */
914  }
916  updateView();
917 }
918 
920 {
921  QList<QTreeWidgetItem*> items = labelTreeWidget->selectedItems();
922  QPoint globalPos = labelTreeWidget->mapToGlobal(p);
923  if(items.size() > 0)
924  {
925 
926  QTreeWidgetItem* item = items.first();
927  if (item->type() == LVRLabelClassType)
928  {
929  auto selected = m_labelTreeParentItemContextMenu->exec(globalPos);
930  if(selected == m_actionAddNewInstance)
931  {
932  addNewInstance(item);
933  }
934  return;
935  }
936  if(item->type() == LVRLabelInstanceType)
937  {
938  auto selected = m_labelTreeChildItemContextMenu->exec(globalPos);
939  if(selected == m_actionRemoveInstance)
940  {
941  m_pickingInteractor->removeLabel(item->data(LABEL_ID_COLUMN, 0).toInt());
942  auto topLevelItem = item->parent();
943  //update the Count avoidign the standart "signal" case to avoid race conditions
944  topLevelItem->setText(LABELED_POINT_COLUMN, QString::number(topLevelItem->text(LABELED_POINT_COLUMN).toInt() - item->text(LABELED_POINT_COLUMN).toInt()));
945  topLevelItem->removeChild(item);
946  }
947  return;
948 
949  }
950  }
951 
952  m_actionAddNewInstance->setEnabled(false);
953  m_labelTreeParentItemContextMenu->exec(globalPos);
954  m_actionAddNewInstance->setEnabled(true);
955 }
956 
958 {
959  //Ask For the Label name
960  bool accepted;
961  QString className = QInputDialog::getText(this, tr("Choose name for new Label class"),
962  tr("Class name:"), QLineEdit::Normal,
963  tr("Labelname") , &accepted);
964  if (!accepted || className.isEmpty())
965  {
966  //No valid Input
967  return;
968  }
969 
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())
972  {
973  //Non Valid Color Return
974  return;
975  }
976 
977  if (labelTreeWidget->topLevelItemCount() == 0)
978  {
979 
980  //Setting up Top Label
981  QTreeWidgetItem * item = new QTreeWidgetItem(LVRLabelClassType);
982  item->setText(0, QString::fromStdString(UNKNOWNNAME));
983  item->setText(LABELED_POINT_COLUMN, QString::number(0));
984  item->setCheckState(LABEL_VISIBLE_COLUMN, Qt::Checked);
985  item->setData(LABEL_ID_COLUMN, 1, QColor(Qt::red));
986  //item->setFlags(item->flags() & ~ Qt::ItemIsSelectable);
987 
988  //Setting up new child item
989  QTreeWidgetItem * childItem = new QTreeWidgetItem(LVRLabelInstanceType);
990  childItem->setText(LABEL_NAME_COLUMN, QString::fromStdString(UNKNOWNNAME) + QString::number(1));
991  childItem->setText(LABELED_POINT_COLUMN, QString::number(0));
992  childItem->setCheckState(LABEL_VISIBLE_COLUMN, Qt::Checked);
993  childItem->setData(LABEL_ID_COLUMN, 1, QColor(Qt::red));
994  childItem->setData(LABEL_ID_COLUMN, 0, 0);
995  item->addChild(childItem);
996  labelTreeWidget->addTopLevelItem(item);
997  //Added first Top Level item enable instance button
998  Q_EMIT(labelAdded(childItem));
999  selectedInstanceComboBox->addItem(childItem->text(LABEL_NAME_COLUMN), 0);
1000  }
1001 
1002  int id = m_id++;
1003  //Setting up new Toplevel item
1004  QTreeWidgetItem * item = new QTreeWidgetItem(LVRLabelClassType);
1005  item->setText(0, className);
1006  item->setText(LABELED_POINT_COLUMN, QString::number(0));
1007  item->setCheckState(LABEL_VISIBLE_COLUMN, Qt::Checked);
1008  item->setData(LABEL_ID_COLUMN, 1, label_color);
1009  //item->setFlags(item->flags() & ~ Qt::ItemIsSelectable);
1010 
1011  //Setting up new child item
1012  QTreeWidgetItem * childItem = new QTreeWidgetItem(LVRLabelInstanceType);
1013  childItem->setText(LABEL_NAME_COLUMN, className + QString::number(1));
1014  childItem->setText(LABELED_POINT_COLUMN, QString::number(0));
1015  childItem->setCheckState(LABEL_VISIBLE_COLUMN, Qt::Checked);
1016  childItem->setData(LABEL_ID_COLUMN, 1, label_color);
1017  childItem->setData(LABEL_ID_COLUMN, 0, id);
1018  item->addChild(childItem);
1019  m_selectedLabelItem = childItem;
1020  labelTreeWidget->addTopLevelItem(item);
1021 
1022  //Add label to combo box
1023  selectedInstanceComboBox->addItem(childItem->text(LABEL_NAME_COLUMN), id);
1024  Q_EMIT(labelAdded(childItem));
1025 }
1027 {
1028  // Only display context menu for point clounds and meshes
1029  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1030  if(items.size() > 0)
1031  {
1032  QTreeWidgetItem* item = items.first();
1033  if(item->type() == LVRModelItemType)
1034  {
1035  QPoint globalPos = treeWidget->mapToGlobal(p);
1036  m_treeParentItemContextMenu->exec(globalPos);
1037  }
1038  if(item->type() == LVRPointCloudItemType || item->type() == LVRMeshItemType)
1039  {
1040  QPoint globalPos = treeWidget->mapToGlobal(p);
1041  m_treeChildItemContextMenu->exec(globalPos);
1042  }
1043  if (item->type() == LVRScanDataItemType)
1044  {
1045  QPoint globalPos = treeWidget->mapToGlobal(p);
1046 
1047  LVRScanDataItem *sdi = static_cast<LVRScanDataItem *>(item);
1048  QMenu *con_menu = new QMenu;
1049 
1050  if (sdi->isPointCloudLoaded())
1051  {
1052  con_menu->addAction(m_actionUnloadPointCloudData);
1053  }
1054  else
1055  {
1056  con_menu->addAction(m_actionLoadPointCloudData);
1057  }
1058 
1059  con_menu->addAction(m_actionDeleteModelItem);
1060  con_menu->addAction(m_actionCopyModelItem);
1061  if(m_items_copied.size() > 0)
1062  {
1063  con_menu->addAction(m_actionPasteModelItem);
1064  }
1065  con_menu->exec(globalPos);
1066 
1067  delete con_menu;
1068  }
1069  if(item->type() == LVRCvImageItemType)
1070  {
1071  QPoint globalPos = treeWidget->mapToGlobal(p);
1072  QMenu *con_menu = new QMenu;
1073 
1074  LVRCvImageItem *cvi = static_cast<LVRCvImageItem *>(item);
1075 
1076  con_menu->addAction(m_actionShowImage);
1077  con_menu->exec(globalPos);
1078 
1079  delete con_menu;
1080  }
1081  if(item->type() == LVRCamDataItemType)
1082  {
1083  QPoint globalPos = treeWidget->mapToGlobal(p);
1084  QMenu *con_menu = new QMenu;
1085 
1086  LVRCamDataItem* cam = static_cast<LVRCamDataItem *>(item);
1087 
1088  con_menu->addAction(m_actionSetViewToCamera);
1089  con_menu->exec(globalPos);
1090 
1091  delete con_menu;
1092  }
1093  }
1094 }
1095 
1097 {
1098  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1099  if(items.size() > 0)
1100  {
1101  QTreeWidgetItem* item = items.first();
1102  LVRModelItem* model_item = getModelItem(item);
1103  if(model_item != NULL) new LVRRenameDialog(model_item, treeWidget);
1104  }
1105 }
1106 
1108 {
1109  std::cout << "model loaded" << std::endl;
1110  // Load model and generate vtk representation
1111  ModelPtr model = ModelFactory::readModel(name.toStdString());
1112  ModelBridgePtr bridge(new LVRModelBridge(model));
1113  bridge->addActors(m_renderer);
1114 
1115  // Add item for this model to tree widget
1116  QFileInfo info(name);
1117  QString base = info.fileName();
1118  LVRModelItem* item = new LVRModelItem(bridge, base);
1119  this->treeWidget->addTopLevelItem(item);
1120  item->setExpanded(true);
1121 
1122  // Read Pose file
1123  boost::filesystem::path poseFile = name.toStdString();
1124 
1125  for (auto& extension : { "pose", "dat", "frames" })
1126  {
1127  poseFile.replace_extension(extension);
1128  if (boost::filesystem::exists(poseFile))
1129  {
1130  cout << "Found Pose file: " << poseFile << endl;
1131  Transformf mat = getTransformationFromFile<float>(poseFile);
1132  BaseVector<float> pos, angles;
1133  getPoseFromMatrix<float>(pos, angles, mat.transpose());
1134 
1135  angles *= 180.0 / M_PI; // radians -> degrees
1136 
1137  item->setPose(Pose {
1138  pos.x, pos.y, pos.z,
1139  angles.x, angles.y, angles.z
1140  });
1141 
1142  break;
1143  }
1144  }
1145  return item;
1146 }
1147 
1148 void LVRMainWindow::loadChunkedMesh(const QStringList& filenames, std::vector<std::string> layers, int cacheSize, float highResDistance)
1149 {
1150  if(filenames.size() > 0)
1151  {
1152  QTreeWidgetItem* lastItem = nullptr;
1153 
1154  QStringList::const_iterator it = filenames.begin();
1155  while(it != filenames.end())
1156  {
1157  QFileInfo info((*it));
1158  QString base = info.fileName();
1159 
1160  std::cout << base.toStdString() << std::endl;
1161 
1162  if (info.suffix() == "h5")
1163  {
1164 // std::vector<std::string> layers = {"mesh0", "mesh1"};
1165  std::cout << info.absoluteFilePath().toStdString() << std::endl;
1166  //m_chunkBridge = std::make_unique<LVRChunkedMeshBridge>(info.absoluteFilePath().toStdString(), m_renderer, layers, cacheSize);
1167  m_chunkBridge = ChunkedMeshBridgePtr(new LVRChunkedMeshBridge(info.absoluteFilePath().toStdString(), m_renderer, layers, cacheSize));
1168  m_chunkBridge->addInitialActors(m_renderer);
1169  m_chunkCuller = new ChunkedMeshCuller(m_chunkBridge.get(), highResDistance);
1170  m_renderer->AddCuller(m_chunkCuller);
1171  qRegisterMetaType<actorMap > ("actorMap");
1172  QObject::connect(m_chunkBridge.get(),
1173  SIGNAL(updateHighRes(actorMap, actorMap)),
1174  this,
1176  Qt::QueuedConnection);
1177  }
1178  ++it;
1179  }
1180  }
1181 }
1182 
1183 
1184 void LVRMainWindow::loadModels(const QStringList& filenames)
1185 {
1186  if(filenames.size() > 0)
1187  {
1188  QTreeWidgetItem* lastItem = nullptr;
1189 
1190  QStringList::const_iterator it = filenames.begin();
1191  while(it != filenames.end())
1192  {
1193  // check for h5
1194  QFileInfo info((*it));
1195  QString base = info.fileName();
1196 
1197  if (info.suffix() == "h5")
1198  {
1199  // h5 special loading case
1200  // special case h5:
1201  // scan data is stored as
1202  QTreeWidgetItem *root = new QTreeWidgetItem(treeWidget);
1203  root->setText(0, base);
1204 
1205  QIcon icon;
1206  icon.addFile(QString::fromUtf8(":/qv_scandata_tree_icon.png"), QSize(), QIcon::Normal, QIcon::Off);
1207  root->setIcon(0, icon);
1208 
1209  std::shared_ptr<ScanDataManager> sdm(new ScanDataManager(info.absoluteFilePath().toStdString()));
1210 
1211  lastItem = addScans(sdm, root);
1212 
1213  root->setExpanded(true);
1214 
1215  // load mesh only
1216  ModelPtr model_ptr(new Model());
1217  std::shared_ptr<HDF5IO> h5_io_ptr(new HDF5IO(info.absoluteFilePath().toStdString()));
1218  if(h5_io_ptr->readMesh(model_ptr))
1219  {
1220  ModelBridgePtr bridge(new LVRModelBridge(model_ptr));
1221  bridge->addActors(m_renderer);
1222 
1223  // Add item for this model to tree widget
1224  LVRModelItem* item = new LVRModelItem(bridge, "mesh");
1225  root->addChild(item);
1226  item->setExpanded(false);
1227  lastItem = item;
1228  }
1229 
1230  } else {
1231  lastItem = loadModelItem(*it);
1232  }
1233 
1234  ++it;
1235  }
1236 
1237  if (lastItem != nullptr)
1238  {
1239  for(QTreeWidgetItem* selected : treeWidget->selectedItems())
1240  {
1241  selected->setSelected(false);
1242  }
1243  lastItem->setSelected(true);
1244  }
1245 
1247  restoreSliders();
1248  assertToggles();
1249  updateView();
1250 
1251 
1252  vtkSmartPointer<vtkPoints> points =
1253  vtkSmartPointer<vtkPoints>::New();
1254  QTreeWidgetItemIterator itu(treeWidget);
1255  LVRPointCloudItem* citem;
1256 
1257  while (*itu)
1258  {
1259  QTreeWidgetItem* item = *itu;
1260 
1261  if ( item->type() == LVRPointCloudItemType)
1262  {
1263  citem = static_cast<LVRPointCloudItem*>(*itu);
1264  points->SetData(citem->getPointBufferBridge()->getPointCloudActor()->GetMapper()->GetInput()->GetPointData()->GetScalars());
1265 
1266  m_pickingInteractor->setPoints(citem->getPointBufferBridge()->getPolyIDData());
1267  m_labelDialog->setPoints(item->parent()->text(0).toStdString(), citem->getPointBufferBridge()->getPolyData());
1268  }
1269  itu++;
1270  }
1271 
1272  }
1273 }
1274 
1276 {
1277  QStringList filenames = QFileDialog::getOpenFileNames(this, tr("Open Model"), "", tr("Model Files (*.ply *.obj *.pts *.3d *.txt *.h5)"));
1278  loadModels(filenames);
1279 
1280 }
1281 
1283 {
1284  QStringList filenames = QFileDialog::getOpenFileNames(this, tr("Open chunked mesh"), "", tr("Chunked meshes (*.h5)"));
1285  bool ok;
1286  QString text = QInputDialog::getText(0, "Enter layers",
1287  "Layers whitspace seperated:", QLineEdit::Normal,
1288  "", &ok);
1289  std::vector<std::string> layers;
1290  std::string unseperated = text.toStdString();
1291  if(text.isEmpty())
1292  {
1293  layers = {"mesh0"};
1294  }
1295  else
1296  {
1297 
1298  boost::tokenizer<boost::char_separator<char>> tokens(unseperated, boost::char_separator<char>());
1299  layers = std::vector<std::string>(tokens.begin(), tokens.end());
1300  }
1301 
1302 
1303  std::cout << "LAYERS " ;
1304  for(auto &layer : layers)
1305  {
1306  std::cout << layer << " ";
1307  }
1308 
1309  std::cout << std::endl;
1310  double highResDistance = QInputDialog::getDouble(0, "highResDistance", "highResDistance");
1311 
1312  if(highResDistance < 0)
1313  {
1314  highResDistance = 0.0;
1315  }
1316 
1317 
1318  int cacheSize = QInputDialog::getInt(0, "cacheSize", "cache size");
1319 
1320  if(cacheSize < 0)
1321  {
1322  cacheSize = 0;
1323  }
1324  loadChunkedMesh(filenames, layers, cacheSize, highResDistance);
1325 
1326 }
1327 
1329 {
1330  std::cout << "loaded points" << std::endl;
1331  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1332  if(items.size() > 0)
1333  {
1334  QTreeWidgetItem* item = items.first();
1335 
1336  if(item->type() == LVRScanDataItemType)
1337  {
1338  LVRScanDataItem *sd = static_cast<LVRScanDataItem *>(item);
1339 
1340 
1341  if (!sd->isPointCloudLoaded())
1342  {
1344  sd->setVisibility(true, m_actionShow_Points->isChecked());
1345 
1347  assertToggles();
1348  restoreSliders();
1349  refreshView();
1350  }
1351  }
1352  }
1353 
1354 }
1355 
1357 {
1358  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1359  if(items.size() > 0)
1360  {
1361  QTreeWidgetItem* item = items.first();
1362 
1363  if(item->type() == LVRScanDataItemType)
1364  {
1365  LVRScanDataItem *sd = static_cast<LVRScanDataItem *>(item);
1366 
1367  if (sd->isPointCloudLoaded())
1368  {
1370 
1372  refreshView();
1373  restoreSliders();
1374  assertToggles();
1375  }
1376  }
1377  }
1378 
1379 }
1380 
1382 {
1383  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1384 
1385  if(items.size() > 0)
1386  {
1387  QTreeWidgetItem* item = items.first();
1388 
1389  if(item->type() == LVRCvImageItemType)
1390  {
1391  LVRCvImageItem *cvi = static_cast<LVRCvImageItem *>(item);
1392 
1393  cvi->openWindow();
1394  }
1395  }
1396 }
1397 
1399 {
1400  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1401 
1402  if(items.size() > 0)
1403  {
1404  QTreeWidgetItem* item = items.first();
1405 
1406  if(item->type() == LVRCamDataItemType)
1407  {
1408  LVRCamDataItem *cam = static_cast<LVRCamDataItem *>(item);
1409 
1410  cam->setCameraView();
1411 
1412  refreshView();
1413  }
1414  }
1415 }
1416 
1418 {
1419  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1420  if(items.size() > 0)
1421  {
1422  QTreeWidgetItem* item = items.first();
1423 
1424  if(item->type() == LVRModelItemType)
1425  {
1426  QTreeWidgetItemIterator it(item);
1427 
1428  while(*it)
1429  {
1430  QTreeWidgetItem* child_item = *it;
1431  if(child_item->type() == LVRPointCloudItemType && child_item->parent() == item)
1432  {
1433  LVRPointCloudItem* pc_item = getPointCloudItem(item);
1434  if(pc_item != NULL)
1435  {
1436  m_renderer->RemoveActor(pc_item->getActor());
1437  if (m_histograms.count(pc_item))
1438  {
1439  m_histograms.erase(pc_item);
1440  }
1441  }
1442  }
1443  else if(child_item->type() == LVRMeshItemType && child_item->parent() == item)
1444  {
1445  LVRMeshItem* mesh_item = getMeshItem(item);
1446  if(mesh_item != NULL)
1447  {
1448  m_renderer->RemoveActor(mesh_item->getWireframeActor());
1449  m_renderer->RemoveActor(mesh_item->getActor());
1450  }
1451  }
1452 
1453  ++it;
1454  }
1455  }
1456  else
1457  {
1458  // Remove model from view
1459  LVRPointCloudItem* pc_item = getPointCloudItem(item);
1460  if(pc_item != NULL)
1461  {
1462  m_renderer->RemoveActor(pc_item->getActor());
1463  if (m_histograms.count(pc_item))
1464  {
1465  m_histograms.erase(pc_item);
1466  }
1467  }
1468 
1469  LVRMeshItem* mesh_item = getMeshItem(item);
1470  if(mesh_item != NULL) m_renderer->RemoveActor(mesh_item->getActor());
1471  }
1472 
1473  // Remove list item (safe according to http://stackoverflow.com/a/9399167)
1474  delete item;
1475 
1476  refreshView();
1477  restoreSliders();
1478  }
1479 }
1480 
1481 
1483 {
1484  // std::cout << "COPY!" << std::endl;
1485 
1486  if(m_items_copied.size() == 0)
1487  {
1490  }
1491 
1492  m_items_copied = treeWidget->selectedItems();
1493 }
1494 
1496 {
1497 
1498  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
1499 
1500  if(items.size() > 0)
1501  {
1502  QTreeWidgetItem* to_item = items.first();
1503 
1504  for(QTreeWidgetItem* from_item : m_items_copied)
1505  {
1506  std::cout << "copy " << from_item->text(0).toStdString() << std::endl;
1507  QString name = from_item->text(0);
1508 
1509  // check if name already exist
1510  bool child_name_exists = false;
1511  bool recheck = true;
1512 
1513  while(childNameExists(to_item, name))
1514  {
1515 
1516  // TODO better
1517  name = increaseFilename(name);
1518  std::cout << "Change name to " << name.toStdString() << std::endl;
1519 
1520  }
1521 
1522  QTreeWidgetItem* insert_item = from_item->clone();
1523  insert_item->setText(0, name);
1524  insert_item->setToolTip(0, name);
1525 
1526  // addChild removes all other childs?
1527 
1528  to_item->addChild(insert_item);
1529 
1530  }
1531 
1532  m_items_copied.clear();
1533 
1536 
1537  }
1538 
1539 }
1540 
1541 bool LVRMainWindow::childNameExists(QTreeWidgetItem* item, const QString& name)
1542 {
1543  bool child_name_exists = false;
1544 
1545  const int num_children = item->childCount();
1546 
1547  for(int i=0; i<num_children; i++)
1548  {
1549  const QTreeWidgetItem* child = item->child(i);
1550  const QString child_name = child->text(0);
1551  if(name == child_name)
1552  {
1553  child_name_exists = true;
1554  break;
1555  }
1556  }
1557 
1558  return child_name_exists;
1559 }
1560 
1562 {
1563  QRegExp rx("(\\d+)$");
1564 
1565  if(rx.indexIn(filename, 0) != -1)
1566  {
1567  int number = 0;
1568  number = rx.cap(1).toInt();
1569  number += 1;
1570  filename.replace(rx, QString::number(number));
1571  } else {
1572  filename += "_1";
1573  }
1574 
1575  return filename;
1576 }
1577 
1578 
1580 {
1581  if(item->type() == LVRModelItemType)
1582  return static_cast<LVRModelItem*>(item);
1583 
1584  if(item->parent() && item->parent()->type() == LVRModelItemType)
1585  return static_cast<LVRModelItem*>(item->parent());
1586 
1587  return NULL;
1588 }
1589 
1590 QList<LVRPointCloudItem*> LVRMainWindow::getPointCloudItems(QList<QTreeWidgetItem*> items)
1591 {
1592  QList<LVRPointCloudItem*> pcs;
1593 
1594  for(QTreeWidgetItem* item : items)
1595  {
1596  if(item->type() == LVRPointCloudItemType)
1597  {
1598  pcs.append(static_cast<LVRPointCloudItem*>(item));
1599  } else if(item->type() == LVRModelItemType) {
1600  // get pc of model
1601  QTreeWidgetItemIterator it(item);
1602  while(*it)
1603  {
1604  QTreeWidgetItem* child_item = *it;
1605  if(child_item->type() == LVRPointCloudItemType
1606  && child_item->parent() == item)
1607  {
1608  pcs.append(static_cast<LVRPointCloudItem*>(child_item));
1609  }
1610  ++it;
1611  }
1612 
1613  } else if(item->type() == LVRScanDataItemType) {
1614  // Scan data selected: fetch pointcloud (transformed?)
1615  QTreeWidgetItemIterator it(item);
1616  while(*it)
1617  {
1618  QTreeWidgetItem* child_item = *it;
1619  if(child_item->type() == LVRPointCloudItemType
1620  && child_item->parent() == item)
1621  {
1622  // pointcloud found!
1623  pcs.append(static_cast<LVRPointCloudItem*>(child_item));
1624  }
1625 
1626  ++it;
1627  }
1628 
1629  }
1630 
1631  }
1632 
1633  return pcs;
1634 }
1635 
1637 {
1638  if(item->type() == LVRPointCloudItemType) return static_cast<LVRPointCloudItem*>(item);
1639  if(item->type() == LVRModelItemType)
1640  {
1641  QTreeWidgetItemIterator it(item);
1642 
1643  while(*it)
1644  {
1645  QTreeWidgetItem* child_item = *it;
1646  if(child_item->type() == LVRPointCloudItemType && child_item->parent() == item)
1647  {
1648  return static_cast<LVRPointCloudItem*>(child_item);
1649  }
1650  ++it;
1651  }
1652  }
1653  return NULL;
1654 }
1655 
1657 {
1658  if(item->type() == LVRMeshItemType) return static_cast<LVRMeshItem*>(item);
1659  if(item->type() == LVRModelItemType)
1660  {
1661  QTreeWidgetItemIterator it(item);
1662 
1663  while(*it)
1664  {
1665  QTreeWidgetItem* child_item = *it;
1666  if(child_item->type() == LVRMeshItemType && child_item->parent() == item)
1667  {
1668  return static_cast<LVRMeshItem*>(child_item);
1669  }
1670  ++it;
1671  }
1672  }
1673  return NULL;
1674 }
1675 
1676 std::set<LVRModelItem*> LVRMainWindow::getSelectedModelItems()
1677 {
1678  std::set<LVRModelItem*> items;
1679  for (QTreeWidgetItem* item : treeWidget->selectedItems())
1680  {
1681  LVRModelItem* modelItem = getModelItem(item);
1682  if (modelItem)
1683  {
1684  items.insert(modelItem);
1685  }
1686  }
1687  return items;
1688 }
1689 std::set<LVRPointCloudItem*> LVRMainWindow::getSelectedPointCloudItems()
1690 {
1691  std::set<LVRPointCloudItem*> items;
1692  for (QTreeWidgetItem* item : treeWidget->selectedItems())
1693  {
1694  LVRPointCloudItem* pointCloudItem = getPointCloudItem(item);
1695  if (pointCloudItem)
1696  {
1697  items.insert(pointCloudItem);
1698  }
1699  }
1700  return items;
1701 }
1702 std::set<LVRMeshItem*> LVRMainWindow::getSelectedMeshItems()
1703 {
1704  std::set<LVRMeshItem*> items;
1705  for (QTreeWidgetItem* item : treeWidget->selectedItems())
1706  {
1707  LVRMeshItem* modelItem = getMeshItem(item);
1708  if (modelItem)
1709  {
1710  items.insert(modelItem);
1711  }
1712  }
1713  return items;
1714 }
1715 
1717 {
1718  togglePoints(m_actionShow_Points->isChecked());
1719  toggleNormals(m_actionShow_Normals->isChecked());
1720  toggleMeshes(m_actionShow_Mesh->isChecked());
1722 }
1723 
1724 void LVRMainWindow::setModelVisibility(QTreeWidgetItem* treeWidgetItem, int column)
1725 {
1726  if(treeWidgetItem->type() == LVRModelItemType)
1727  {
1728  QTreeWidgetItemIterator it(treeWidgetItem);
1729 
1730  while(*it)
1731  {
1732  QTreeWidgetItem* child_item = *it;
1733  if(child_item->type() == LVRPointCloudItemType)
1734  {
1735  LVRModelItem* model_item = static_cast<LVRModelItem*>(treeWidgetItem);
1736  model_item->setModelVisibility(column, m_actionShow_Points->isChecked());
1737  }
1738  if(child_item->type() == LVRMeshItemType)
1739  {
1740  LVRModelItem* model_item = static_cast<LVRModelItem*>(treeWidgetItem);
1741  model_item->setModelVisibility(column, m_actionShow_Mesh->isChecked());
1742  }
1743  ++it;
1744  }
1745 
1746  refreshView();
1747  }
1748  else if (treeWidgetItem->type() == LVRScanDataItemType)
1749  {
1750  LVRScanDataItem *item = static_cast<LVRScanDataItem *>(treeWidgetItem);
1751  item->setVisibility(true, m_actionShow_Points->isChecked());
1752 
1753  refreshView();
1754  }
1755  else if (treeWidgetItem->type() == LVRCamDataItemType)
1756  {
1757  LVRCamDataItem *item = static_cast<LVRCamDataItem *>(treeWidgetItem);
1758  item->setVisibility(true);
1759 
1760  refreshView();
1761  }
1762  else if (treeWidgetItem->type() == LVRBoundingBoxItemType)
1763  {
1764  LVRBoundingBoxItem *item = static_cast<LVRBoundingBoxItem *>(treeWidgetItem);
1765  item->setVisibility(true);
1766 
1767  refreshView();
1768  }
1769  else if (treeWidgetItem->parent() && treeWidgetItem->parent()->type() == LVRScanDataItemType)
1770  {
1771  setModelVisibility(treeWidgetItem->parent(), column);
1772  }
1773 }
1774 
1775 
1776 
1778 {
1779  for (QTreeWidgetItem* item : treeWidget->selectedItems())
1780  {
1781  if(item->type() == LVRModelItemType)
1782  {
1783  QTreeWidgetItemIterator it(item);
1784 
1785  while(*it)
1786  {
1787  QTreeWidgetItem* child_item = *it;
1788  if(child_item->type() == LVRPointCloudItemType && child_item->parent()->isSelected())
1789  {
1790  LVRPointCloudItem* model_item = static_cast<LVRPointCloudItem*>(child_item);
1791  model_item->setPointSize(pointSize);
1792  }
1793  ++it;
1794  }
1795  }
1796  else if(item->type() == LVRPointCloudItemType)
1797  {
1798  LVRPointCloudItem* model_item = static_cast<LVRPointCloudItem*>(item);
1799  model_item->setPointSize(pointSize);
1800  }
1801 
1802  refreshView();
1803  }
1804 }
1805 
1806 void LVRMainWindow::changeTransparency(int transparencyValue)
1807 {
1808  for (QTreeWidgetItem* item : treeWidget->selectedItems())
1809  {
1810  float opacityValue = 1 - ((float)transparencyValue / (float)100);
1811 
1812  if(item->type() == LVRModelItemType)
1813  {
1814  QTreeWidgetItemIterator it(item);
1815 
1816  while(*it)
1817  {
1818  QTreeWidgetItem* child_item = *it;
1819  if(child_item->type() == LVRPointCloudItemType && child_item->parent()->isSelected())
1820  {
1821  LVRPointCloudItem* model_item = static_cast<LVRPointCloudItem*>(child_item);
1822  model_item->setOpacity(opacityValue);
1823  }
1824  else if(child_item->type() == LVRMeshItemType && child_item->parent()->isSelected())
1825  {
1826  LVRMeshItem* model_item = static_cast<LVRMeshItem*>(child_item);
1827  model_item->setOpacity(opacityValue);
1828  }
1829  ++it;
1830  }
1831  }
1832  else if(item->type() == LVRPointCloudItemType)
1833  {
1834  LVRPointCloudItem* model_item = static_cast<LVRPointCloudItem*>(item);
1835  model_item->setOpacity(opacityValue);
1836  }
1837  else if(item->type() == LVRMeshItemType)
1838  {
1839  LVRMeshItem* model_item = static_cast<LVRMeshItem*>(item);
1840  model_item->setOpacity(opacityValue);
1841  }
1842 
1843  refreshView();
1844  }
1845 }
1846 
1848 {
1849  for (QTreeWidgetItem* item : treeWidget->selectedItems())
1850  {
1851  if(item->type() == LVRMeshItemType)
1852  {
1853  LVRMeshItem* model_item = static_cast<LVRMeshItem*>(item);
1854  model_item->setShading(shader);
1855  refreshView();
1856  }
1857  }
1858 }
1859 
1860 void LVRMainWindow::togglePoints(bool checkboxState)
1861 {
1862  QTreeWidgetItemIterator it(treeWidget);
1863 
1864  while(*it)
1865  {
1866  QTreeWidgetItem* item = *it;
1867  if(item->type() == LVRPointCloudItemType)
1868  {
1869  if (item->parent()->type() == LVRModelItemType)
1870  {
1871  LVRModelItem* model_item = static_cast<LVRModelItem*>(item->parent());
1872  if(model_item->isEnabled()) model_item->setVisibility(checkboxState);
1873  }
1874  if (item->parent()->type() == LVRScanDataItemType)
1875  {
1876  LVRScanDataItem* sd_item = static_cast<LVRScanDataItem*>(item->parent());
1877  sd_item->setVisibility(true, checkboxState);
1878  }
1879  }
1880  ++it;
1881  }
1882 
1883  refreshView();
1884 }
1885 
1886 void LVRMainWindow::toggleNormals(bool checkboxState)
1887 {
1888  QTreeWidgetItemIterator it(treeWidget);
1889 
1890  while(*it)
1891  {
1892  QTreeWidgetItem* item = *it;
1893  if(item->type() == LVRPointCloudItemType)
1894  {
1895  if (item->parent()->type() == LVRModelItemType)
1896  {
1897  LVRModelItem* model_item = static_cast<LVRModelItem*>(item->parent());
1898  if(model_item->isEnabled()){
1899  model_item->getModelBridge()->setNormalsVisibility(checkboxState);
1900  }
1901  }
1902  }
1903  ++it;
1904  }
1905 
1906  refreshView();
1907 }
1908 
1909 void LVRMainWindow::toggleMeshes(bool checkboxState)
1910 {
1911  QTreeWidgetItemIterator it(treeWidget);
1912 
1913  while(*it)
1914  {
1915  QTreeWidgetItem* item = *it;
1916  if(item->type() == LVRMeshItemType)
1917  {
1918  LVRModelItem* model_item = static_cast<LVRModelItem*>(item->parent());
1919  if(model_item->isEnabled()) model_item->setVisibility(checkboxState);
1920  }
1921  ++it;
1922  }
1923 
1924  refreshView();
1925 }
1926 
1927 void LVRMainWindow::toggleWireframe(bool checkboxState)
1928 {
1929  if(m_actionShow_Mesh)
1930  {
1931  QTreeWidgetItemIterator it(treeWidget);
1932 
1933  while(*it)
1934  {
1935  QTreeWidgetItem* item = *it;
1936  if(item->type() == LVRMeshItemType)
1937  {
1938  LVRMeshItem* mesh_item = static_cast<LVRMeshItem*>(item);
1939  if(checkboxState)
1940  {
1941  m_renderer->AddActor(mesh_item->getWireframeActor());
1942  }
1943  else
1944  {
1945  m_renderer->RemoveActor(mesh_item->getWireframeActor());
1946  }
1947  refreshView();
1948  }
1949  ++it;
1950  }
1951 
1952  refreshView();
1953  }
1954 }
1955 
1956 QTreeWidgetItem* LVRMainWindow::addScans(std::shared_ptr<ScanDataManager> sdm, QTreeWidgetItem *parent)
1957 {
1958  QTreeWidgetItem *lastItem = nullptr;
1959  std::vector<ScanPtr> scans = sdm->getScans();
1960  std::vector<std::vector<ScanImage> > camData = sdm->getCameraData();
1961 
1962  bool cam_data_available = camData.size() > 0;
1963 
1964  for (size_t i = 0; i < scans.size(); i++)
1965  {
1966  char buf[128];
1967  std::sprintf(buf, "%05d", scans[i]->positionNumber);
1968  LVRScanDataItem *item = new LVRScanDataItem(scans[i], sdm, i, m_renderer, QString("pos_") + buf, parent);
1969 
1970  if(cam_data_available && camData[i].size() > 0)
1971  {
1972  QTreeWidgetItem* cameras_item = new QTreeWidgetItem(item, LVRCamerasItemType);
1973  cameras_item->setText(0, QString("Photos"));
1974  // insert cam poses
1975  // QTreeWidgetItem *images = new QTreeWidgetItem(item, QString("cams"));
1976  for(int j=0; j < camData[i].size(); j++)
1977  {
1978  char buf2[128];
1979  std::sprintf(buf2, "%05d", j);
1980  // implement this
1981  LVRCamDataItem *cam_item = new LVRCamDataItem(camData[i][j], sdm, j, m_renderer, QString("photo_") + buf2, cameras_item);
1982 
1983  lastItem = cam_item;
1984  }
1985  }
1986 
1987  lastItem = item;
1988  }
1989 
1990  return lastItem;
1991 }
1992 
1994 {
1995 
1996  QStringList filenames;
1997  viewer::Options options(argc, argv);
1998  if(options.printUsage())
1999  {
2000  return;
2001  }
2002 
2003  std::vector<std::string> files;
2004  files.push_back(options.getInputFileName());
2005  for(int i = 0; i < files.size(); i++)
2006  {
2007  std::cout << "filename " << files[i] << std::endl;
2008  filenames << files[i].c_str();
2009  }
2010 
2011  if(options.isChunkedMesh())
2012  {
2013  loadChunkedMesh(filenames, options.getLayers(), options.getCacheSize(),
2014  options.getHighResDistance());
2015  }
2016  else{
2017  loadModels(filenames);
2018  }
2019 }
2020 
2021 void LVRMainWindow::changePicker(bool labeling)
2022 {
2023 
2024  if(labeling)
2025  {
2026  vtkSmartPointer<vtkAreaPicker> AreaPicker = vtkSmartPointer<vtkAreaPicker>::New();
2027  qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(AreaPicker);
2028  } else
2029  {
2030  vtkSmartPointer<vtkPointPicker> pointPicker = vtkSmartPointer<vtkPointPicker>::New();
2031  qvtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(pointPicker);
2032  }
2033 }
2034 
2036 {
2037  if(!m_labeling)
2038  {
2040 
2041  }else
2042  {
2044  }
2046 }
2048 {
2051  m_correspondanceDialog->m_dialog->raise();
2052  m_correspondanceDialog->m_dialog->activateWindow();
2053  Q_EMIT(correspondenceDialogOpened());
2054 }
2055 
2057 {
2058  QColor c = QColorDialog::getColor();
2059  if (c.isValid())
2060  {
2061  for (QTreeWidgetItem* item : treeWidget->selectedItems())
2062  {
2063  if(item->type() == LVRPointCloudItemType)
2064  {
2065  LVRPointCloudItem* pc_item = static_cast<LVRPointCloudItem*>(item);
2066  pc_item->setColor(c);
2067  }
2068  else if(item->type() == LVRMeshItemType)
2069  {
2070  LVRMeshItem* mesh_item = static_cast<LVRMeshItem*>(item);
2071  mesh_item->setColor(c);
2072  }
2073  else {
2074  return;
2075  }
2076 
2078  refreshView();
2079  }
2080  }
2081 }
2082 
2084 {
2086  // Get selected item from tree and check type
2087  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2088  if(items.size() > 0)
2089  {
2090  QTreeWidgetItem* item = items.first();
2091  if(item->type() == LVRModelItemType)
2092  {
2093  LVRModelItem* item = static_cast<LVRModelItem*>(items.first());
2094  LVRTransformationDialog* dialog = new LVRTransformationDialog(item, qvtkWidget->GetRenderWindow());
2095  }
2096  else if(item->type() == LVRPointCloudItemType || item->type() == LVRMeshItemType)
2097  {
2098  if(item->parent()->type() == LVRModelItemType)
2099  {
2100  LVRModelItem* l_item = static_cast<LVRModelItem*>(item->parent());
2101  LVRTransformationDialog* dialog = new LVRTransformationDialog(l_item, qvtkWidget->GetRenderWindow());
2102  }
2103  else
2104  {
2105  m_incompatibilityBox->exec();
2106  }
2107  }
2108  else
2109  {
2110  m_incompatibilityBox->exec();
2111  }
2112  }
2113 }
2114 
2116 {
2117  buildIncompatibilityBox(string("normal estimation"), POINTCLOUDS_AND_PARENT_ONLY);
2118  // Get selected item from tree and check type
2119  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2120 
2121  if(items.size() > 0)
2122  {
2123 
2124  QList<LVRPointCloudItem*> pc_items = getPointCloudItems(items);
2125  QList<QTreeWidgetItem*> parent_items;
2126  for(LVRPointCloudItem* pc_item : pc_items)
2127  {
2128  parent_items.append(pc_item->parent());
2129  }
2130 
2131  if(pc_items.size() > 0)
2132  {
2133  LVREstimateNormalsDialog* dialog = new LVREstimateNormalsDialog(pc_items, parent_items, treeWidget, qvtkWidget->GetRenderWindow());
2134  return;
2135  }
2136  }
2137  m_incompatibilityBox->exec();
2138  qvtkWidget->GetRenderWindow()->Render();
2139 }
2140 
2142 {
2143  buildIncompatibilityBox(string("reconstruction"), POINTCLOUDS_AND_PARENT_ONLY);
2144  // Get selected item from tree and check type
2145  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2146  if(items.size() > 0)
2147  {
2148  LVRPointCloudItem* pc_item = getPointCloudItem(items.first());
2149  QTreeWidgetItem* parent_item = pc_item->parent();
2150  if(pc_item != NULL)
2151  {
2152  LVRReconstructViaMarchingCubesDialog* dialog = new LVRReconstructViaMarchingCubesDialog("MC", pc_item, parent_item, treeWidget, qvtkWidget->GetRenderWindow());
2153  return;
2154  }
2155  }
2156  m_incompatibilityBox->exec();
2157 }
2158 
2160 {
2161  buildIncompatibilityBox(string("reconstruction"), POINTCLOUDS_AND_PARENT_ONLY);
2162  // Get selected item from tree and check type
2163  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2164  if(items.size() > 0)
2165  {
2166  LVRPointCloudItem* pc_item = getPointCloudItem(items.first());
2167  LVRModelItem* parent_item = getModelItem(items.first());
2168  if(pc_item != NULL)
2169  {
2170  LVRReconstructViaMarchingCubesDialog* dialog = new LVRReconstructViaMarchingCubesDialog("PMC", pc_item, parent_item, treeWidget, qvtkWidget->GetRenderWindow());
2171  return;
2172  }
2173  }
2174  m_incompatibilityBox->exec();
2175 }
2176 
2178 {
2179  buildIncompatibilityBox(string("reconstruction"), POINTCLOUDS_AND_PARENT_ONLY);
2180  // Get selected item from tree and check type
2181  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2182  if(items.size() > 0)
2183  {
2184  LVRPointCloudItem* pc_item = getPointCloudItem(items.first());
2185  LVRModelItem* parent_item = getModelItem(items.first());
2186  if(pc_item != NULL)
2187  {
2188  LVRReconstructViaExtendedMarchingCubesDialog* dialog = new LVRReconstructViaExtendedMarchingCubesDialog("SF", pc_item, parent_item, treeWidget, qvtkWidget->GetRenderWindow());
2189  return;
2190  }
2191  }
2192  m_incompatibilityBox->exec();
2193 }
2194 
2196 {
2197  buildIncompatibilityBox(string("planar optimization"), MESHES_AND_PARENT_ONLY);
2198  // Get selected item from tree and check type
2199  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2200  if(items.size() > 0)
2201  {
2202  LVRMeshItem* mesh_item = getMeshItem(items.first());
2203  LVRModelItem* parent_item = getModelItem(items.first());
2204  if(mesh_item != NULL)
2205  {
2206  LVRPlanarOptimizationDialog* dialog = new LVRPlanarOptimizationDialog(mesh_item, parent_item, treeWidget, qvtkWidget->GetRenderWindow());
2207  return;
2208  }
2209  }
2210  m_incompatibilityBox->exec();
2211 }
2212 
2214 {
2215  buildIncompatibilityBox(string("artifact removal"), MESHES_AND_PARENT_ONLY);
2216  // Get selected item from tree and check type
2217  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2218  if(items.size() > 0)
2219  {
2220  LVRMeshItem* mesh_item = getMeshItem(items.first());
2221  LVRModelItem* parent_item = getModelItem(items.first());
2222  if(mesh_item != NULL)
2223  {
2224  LVRRemoveArtifactsDialog* dialog = new LVRRemoveArtifactsDialog(mesh_item, parent_item, treeWidget, qvtkWidget->GetRenderWindow());
2225  return;
2226  }
2227  }
2228  m_incompatibilityBox->exec();
2229 }
2230 
2232 {
2233  buildIncompatibilityBox(string("MLS projection"), POINTCLOUDS_AND_PARENT_ONLY);
2234  // Get selected item from tree and check type
2235  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2236  if(items.size() > 0)
2237  {
2238  LVRPointCloudItem* pc_item = getPointCloudItem(items.first());
2239  LVRModelItem* parent_item = getModelItem(items.first());
2240  if(pc_item != NULL)
2241  {
2242  LVRMLSProjectionDialog* dialog = new LVRMLSProjectionDialog(pc_item, parent_item, treeWidget, qvtkWidget->GetRenderWindow());
2243  return;
2244  }
2245  }
2246  m_incompatibilityBox->exec();
2247 }
2248 
2250 {
2251  buildIncompatibilityBox(string("outlier removal"), POINTCLOUDS_AND_PARENT_ONLY);
2252  // Get selected item from tree and check type
2253  QList<QTreeWidgetItem*> items = treeWidget->selectedItems();
2254  if(items.size() > 0)
2255  {
2256  LVRPointCloudItem* pc_item = getPointCloudItem(items.first());
2257  LVRModelItem* parent_item = getModelItem(items.first());
2258  if(pc_item != NULL)
2259  {
2260  LVRRemoveOutliersDialog* dialog = new LVRRemoveOutliersDialog(pc_item, parent_item, treeWidget, qvtkWidget->GetRenderWindow());
2261  return;
2262  }
2263  }
2264  m_incompatibilityBox->exec();
2265 }
2266 
2267 void LVRMainWindow::buildIncompatibilityBox(string actionName, unsigned char allowedTypes)
2268 {
2269  // Setup a message box for unsupported items
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%.";
2273  QString body;
2274 
2275  if(allowedTypes == MODELITEMS_ONLY)
2276  bodyString = str(boost::format(bodyString) % actionName % "whole models");
2277  else if(allowedTypes == POINTCLOUDS_ONLY)
2278  bodyString = str(boost::format(bodyString) % actionName % "point clouds");
2279  else if(allowedTypes == MESHES_ONLY)
2280  bodyString = str(boost::format(bodyString) % actionName % "meshes");
2281  else if(allowedTypes == POINTCLOUDS_AND_PARENT_ONLY)
2282  bodyString = str(boost::format(bodyString) % actionName % "point clouds and model items containing point clouds");
2283  else if(allowedTypes == MESHES_AND_PARENT_ONLY)
2284  bodyString = str(boost::format(bodyString) % actionName % "meshes and model items containing meshes");
2285  else if(allowedTypes == POINTCLOUDS_AND_MESHES_AND_PARENT_ONLY)
2286  bodyString = str(boost::format(bodyString) % actionName % "point clouds, meshes and whole models");
2287 
2288  body = QString::fromStdString(bodyString);
2289 
2290  m_incompatibilityBox->setText(title);
2291  m_incompatibilityBox->setInformativeText(body);
2292  m_incompatibilityBox->setStandardButtons(QMessageBox::Ok);
2293 }
2294 
2296 {
2297  m_errorDialog->show();
2298  m_errorDialog->raise();
2299 }
2300 
2302 {
2303  std::set<LVRPointCloudItem*> pointCloudItems = getSelectedPointCloudItems();
2304  if(pointCloudItems.empty())
2305  {
2306  showErrorDialog();
2307  return;
2308  }
2309 
2310  for (LVRPointCloudItem* item : pointCloudItems)
2311  {
2312  PointBufferPtr points = item->getPointBuffer();
2313  if (!points->getUCharChannel("spectral_channels"))
2314  {
2315  showErrorDialog();
2316  return;
2317  }
2318 
2319  if (!m_histograms.count(item))
2320  {
2321  m_histograms[item] = new LVRHistogram(this, points);
2322  }
2323  m_histograms[item]->show();
2324  }
2325 }
2326 
2327 void LVRMainWindow::showPointPreview(vtkActor* actor, int point)
2328 {
2329  if (actor == nullptr || point < 0)
2330  {
2331  return;
2332  }
2333  LVRPointBufferBridge* pointBridge = nullptr;
2334 
2335  QTreeWidgetItemIterator it(treeWidget);
2336 
2337  while(*it)
2338  {
2339  if ((*it)->type() == LVRPointCloudItemType)
2340  {
2341  PointBufferBridgePtr pbuf = static_cast<LVRPointCloudItem *>(*it)->getPointBufferBridge();
2342  if (pbuf->getPointCloudActor() == actor)
2343  {
2344  pointBridge = pbuf.get();
2345  break;
2346  }
2347  }
2348  it++;
2349  }
2350 
2351  if (pointBridge == nullptr)
2352  {
2353  return;
2354  }
2355  m_previewPoint = point;
2356  m_previewPointBuffer = pointBridge->getPointBuffer();
2357  updatePointPreview(point, pointBridge->getPointBuffer());
2358 }
2359 
2361 {
2362  if (!m_previewPointBuffer)
2363  {
2364  return;
2365  }
2367 }
2368 
2370 {
2371  switch(action)
2372  {
2373  case QAbstractSlider::SliderSingleStepAdd:
2374  case QAbstractSlider::SliderSingleStepSub:
2375  case QAbstractSlider::SliderPageStepAdd:
2376  case QAbstractSlider::SliderPageStepSub:
2377  {
2379  break;
2380  }
2381  case -1: //valueChanged(int)
2382  {
2383  for (int i = 0; i < 3; i++)
2384  {
2385  int wavelength = m_spectralSliders[i]->value();
2386  if (!m_spectralLineEdits[i]->hasFocus())
2387  {
2388  m_spectralLineEdits[i]->setText(QString("%1").arg(wavelength));
2389  }
2390  }
2391  }
2392  }
2393 }
2394 
2396 {
2399 }
2400 
2402 {
2405 }
2406 
2408 {
2409  std::set<LVRPointCloudItem*> items = getSelectedPointCloudItems();
2410  if(!items.empty())
2411  {
2412  PointBufferPtr points = (*items.begin())->getPointBuffer();
2413  int min = *points->getIntAtomic("spectral_wavelength_min");
2414  int max = *points->getIntAtomic("spectral_wavelength_max");
2415 
2416 
2417  QString test = m_gradientLineEdit-> text();
2418  bool ok;
2419  int wavelength = test.toUInt(&ok);
2420 
2421  if (!ok)
2422  {
2423  return;
2424  }
2425 
2426  if (wavelength < min)
2427  m_gradientSlider->setValue(min);
2428  else if (wavelength >= max)
2429  m_gradientSlider->setValue(max-1);
2430  else
2431  m_gradientSlider->setValue(wavelength);
2432 
2433  }
2434 }
2435 
2437 {
2438  if (!this->dockWidgetSpectralSliderSettingsContents->isEnabled())
2439  {
2440  return;
2441  }
2442 
2443  std::set<LVRPointCloudItem*> items = getSelectedPointCloudItems();
2444 
2445  if (items.empty())
2446  {
2447  return;
2448  }
2449 
2450  color<size_t> channels;
2451  color<bool> use_channel;
2452 
2453  PointBufferPtr p = (*items.begin())->getPointBuffer();
2454 
2455  for (int i = 0; i < 3; i++)
2456  {
2457  int wavelength = m_spectralSliders[i]->value();
2458  m_spectralLineEdits[i]->setText(QString("%1").arg(wavelength));
2459 
2460  channels[i] = Util::getSpectralChannel(wavelength, p);
2461 
2462  use_channel[i] = m_spectralCheckboxes[i]->isChecked();
2463  m_spectralSliders[i]->setEnabled(use_channel[i]);
2464  m_spectralLineEdits[i]->setEnabled(use_channel[i]);
2465  }
2466 
2467  for(LVRPointCloudItem* item : items)
2468  {
2469  item->getPointBufferBridge()->setSpectralChannels(channels, use_channel);
2470  }
2471  m_renderer->GetRenderWindow()->Render();
2472 }
2473 
2475 {
2476  std::set<LVRPointCloudItem*> items = getSelectedPointCloudItems();
2477  if(!items.empty())
2478  {
2479  PointBufferPtr points = (*items.begin())->getPointBuffer();
2480  int min = *points->getIntAtomic("spectral_wavelength_min");
2481  int max = *points->getIntAtomic("spectral_wavelength_max");
2482 
2483  for (int i = 0; i < 3; i++)
2484  {
2485  QString test = m_spectralLineEdits[i]-> text();
2486  bool ok;
2487  int wavelength = test.toUInt(&ok);
2488 
2489  if (!ok)
2490  {
2491  return;
2492  }
2493  if (wavelength < min)
2494  m_spectralSliders[i]->setValue(min);
2495  else if (wavelength >= max)
2496  m_spectralSliders[i]->setValue(max);
2497  else
2498  m_spectralSliders[i]->setValue(wavelength);
2499  }
2500  }
2501 }
2502 
2504 {
2505  switch(action)
2506  {
2507  case QAbstractSlider::SliderSingleStepAdd:
2508  case QAbstractSlider::SliderSingleStepSub:
2509  case QAbstractSlider::SliderPageStepAdd:
2510  case QAbstractSlider::SliderPageStepSub:
2511  {
2513  break;
2514  }
2515  case -1: //valueChanged(int)
2516  {
2517  int wavelength = m_gradientSlider->value();
2518  if (!m_gradientLineEdit->hasFocus())
2519  {
2520  m_gradientLineEdit->setText(QString("%1").arg(wavelength));
2521  }
2522  }
2523  }
2524 }
2525 
2527 {
2528  if (!this->dockWidgetSpectralColorGradientSettingsContents->isEnabled())
2529  {
2530  return;
2531  }
2532 
2533  std::set<LVRPointCloudItem*> items = getSelectedPointCloudItems();
2534 
2535  if (items.empty())
2536  {
2537  return;
2538  }
2539 
2540  size_t wavelength = m_gradientSlider->value();
2541 
2542  PointBufferPtr p = (*items.begin())->getPointBuffer();
2543 
2544  // @TODO returnvalue could be negative
2545  size_t channel = Util::getSpectralChannel(wavelength, p);
2546 
2547  bool useNDVI = this->checkBox_NDVI->isChecked();
2548  bool normalized = this->checkBox_normcolors->isChecked();
2549  int type = this->comboBox_colorgradient->currentIndex();
2550 
2551  for(LVRPointCloudItem* item : items)
2552  {
2553  item->getPointBufferBridge()->setSpectralColorGradient((GradientType)type, channel, normalized, useNDVI);
2554  }
2555  m_gradientLineEdit->setText(QString("%1").arg(wavelength));
2556  m_gradientSlider->setEnabled(!useNDVI);
2557  m_gradientLineEdit->setEnabled(!useNDVI);
2558  m_renderer->GetRenderWindow()->Render();
2559 }
2560 
2562 {
2563  size_t n = points->numPoints();
2564  points->getPointArray();
2565  if (pointId < 0 || pointId >= n)
2566  {
2567  return;
2568  }
2569 
2570  size_t n_spec, n_channels;
2571  UCharChannelOptional spectral_channels = points->getUCharChannel("spectral_channels");
2572 
2573  if (spectral_channels)
2574  {
2575  size_t n_spec = spectral_channels->numElements();
2576  unsigned n_channels = spectral_channels->width();
2577 
2578  if (pointId >= n_spec)
2579  {
2581  }
2582  else
2583  {
2584  floatArr data(new float[n_channels]);
2585  for (int i = 0; i < n_channels; i++)
2586  {
2587  data[i] = (*spectral_channels)[pointId][i] / 255.0;
2588  }
2589  m_PointPreviewPlotter->setPoints(data, n_channels, 0, 1);
2590  m_PointPreviewPlotter->setXRange(*points->getIntAtomic("spectral_wavelength_min"), *points->getIntAtomic("spectral_wavelength_max"));
2591  }
2592  }
2593 }
2594 
2596 {
2597  if (checked == this->frameSpectralSlidersArea->isEnabled())
2598  {
2599  return;
2600  }
2601 
2603  {
2604  item->getPointBufferBridge()->useGradient(!checked);
2605  }
2606  m_renderer->GetRenderWindow()->Render();
2607 
2608  this->frameSpectralSlidersArea->setEnabled(checked);
2609  this->frameSpectralGradientArea->setEnabled(!checked);
2610  this->radioButtonUseSpectralGradient->setChecked(!checked);
2611 }
2612 
2614 {
2615  if (checked == this->frameSpectralGradientArea->isEnabled())
2616  {
2617  return;
2618  }
2619 
2621  {
2622  item->getPointBufferBridge()->useGradient(checked);
2623  }
2624  m_renderer->GetRenderWindow()->Render();
2625 
2626  this->frameSpectralGradientArea->setEnabled(checked);
2627  this->frameSpectralSlidersArea->setEnabled(!checked);
2628  this->radioButtonUseSpectralSlider->setChecked(!checked);
2629 }
2630 
2632 {
2633 // std::unique_lock<std::mutex> lock(m_chunkBridge->mw_mutex);
2634 // std::cout << "Adding to renderer" << std::endl;
2635 // m_chunkBridge->release = true;
2636 // m_chunkBridge->mw_cond.notify_all();
2637 // lock.unlock();
2638 
2639  for(auto& it: lowRes)
2640  {
2641  m_renderer->RemoveActor(it.second);
2642  it.second->ReleaseGraphicsResources(m_renderer->GetRenderWindow());
2643  }
2644 
2645  for(auto& it: highRes)
2646  {
2647  if(it.second)
2648  {
2649  m_renderer->AddActor(it.second);
2650  }
2651  }
2652  m_renderer->GetRenderWindow()->Render();
2653 }
2654 void LVRMainWindow::updatePointCount(uint16_t id, int selectedPointCount)
2655 {
2656 
2657  int topItemCount = labelTreeWidget->topLevelItemCount();
2658  for (int i = 0; i < topItemCount; i++)
2659  {
2660  QTreeWidgetItem* topLevelItem = labelTreeWidget->topLevelItem(i);
2661  int childCount = topLevelItem->childCount();
2662  for (int j = 0; j < childCount; j++)
2663  {
2664  if(id == topLevelItem->child(j)->data(LABEL_ID_COLUMN, 0).toInt())
2665  {
2666  int pointCountDifference = selectedPointCount - topLevelItem->child(j)->text(LABELED_POINT_COLUMN).toInt();
2667  topLevelItem->child(j)->setText(LABELED_POINT_COLUMN, QString::number(selectedPointCount));
2668  //Add points to toplevel points
2669  topLevelItem->setText(LABELED_POINT_COLUMN, QString::number(pointCountDifference + topLevelItem->text(LABELED_POINT_COLUMN).toInt()));
2670  return;
2671  }
2672  }
2673  }
2674 }
2675 void LVRMainWindow::cellSelected(QTreeWidgetItem* item, int column)
2676 {
2677  if(column == LABEL_NAME_COLUMN)
2678  {
2679  //Edit Label name
2680  bool accepted;
2681  QString label_name = QInputDialog::getText(this, tr("Select Label Name"),
2682  tr("Label name:"), QLineEdit::Normal,
2683  item->text(LABEL_NAME_COLUMN), &accepted);
2684  if (accepted && !label_name.isEmpty())
2685  {
2686  item->setText(LABEL_NAME_COLUMN, label_name);
2687  if (!item->parent())
2688  {
2689  //Toplevel item nothing else to do
2690  return;
2691  }
2692  /*
2693  int comboBoxPos = m_ui->selectedLabelComboBox->findData(item->data(LABEL_ID_COLUMN, 0).toInt());
2694  if (comboBoxPos >= 0)
2695  {
2696  m_ui->selectedLabelComboBox->setItemText(comboBoxPos, label_name);
2697 
2698  }*/
2699  return;
2700  }
2701  }else if(column == LABEL_ID_COLUMN)
2702  {
2703  //Change
2704  QColor label_color = QColorDialog::getColor(Qt::red, this, tr("Choose Label Color"));
2705  if (label_color.isValid())
2706  {
2707  item->setData(LABEL_ID_COLUMN, 1, label_color);
2708  if(item->parent())
2709  {
2710  //Update Color In picker
2711  Q_EMIT(labelAdded(item));
2712  return;
2713  }
2714  else
2715  {
2716  //ask if all childs Should be updated
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)
2723  {
2724  //update All Childs
2725  for (int i = 0; i < item->childCount(); i++)
2726  {
2727  item->child(i)->setData(LABEL_ID_COLUMN, 1, label_color);
2728  Q_EMIT(labelAdded(item->child(i)));
2729  }
2730  }
2731 
2732  }
2733  }
2734  }
2735  else
2736  {
2737  if(item->parent())
2738  {
2739  m_selectedLabelItem = item;
2740 
2741  Q_EMIT(labelChanged(item->data(LABEL_ID_COLUMN, 0).toInt()));
2742 
2743  }
2744  }
2745 }
2746 
2747 void LVRMainWindow::visibilityChanged(QTreeWidgetItem* changedItem, int column)
2748 {
2749  if(column != LABEL_VISIBLE_COLUMN)
2750  {
2751  return;
2752  }
2753 
2754  //check if Instance or whole label changed
2755  if (changedItem->parent())
2756  {
2757  //parent exists item is an instance
2758  Q_EMIT(hidePoints(changedItem->data(LABEL_ID_COLUMN,0).toInt(), changedItem->checkState(LABEL_VISIBLE_COLUMN)));
2759  } else
2760  {
2761  //Check if unlabeled item
2762  for (int i = 0; i < changedItem->childCount(); i++)
2763  {
2764  QTreeWidgetItem* childItem = changedItem->child(i);
2765 
2766  //sets child elements checkbox on toplevel box value if valuechanged a singal will be emitted and handeled
2767  childItem->setCheckState(LABEL_VISIBLE_COLUMN, changedItem->checkState(LABEL_VISIBLE_COLUMN));
2768  }
2769  }
2770 
2771 
2772 }
2773 
2774 void LVRMainWindow::addNewInstance(QTreeWidgetItem * selectedTopLevelItem)
2775 {
2776 
2777  QString choosenLabel = selectedTopLevelItem->text(LABEL_NAME_COLUMN);
2778 
2779  bool accepted;
2780  QString instance_name = QInputDialog::getText(this, tr("Choose Name for new Instance"),
2781  tr("Instance name:"), QLineEdit::Normal,
2782  QString(choosenLabel + QString::number(selectedTopLevelItem->childCount() + 1)) , &accepted);
2783  if (!accepted || instance_name.isEmpty())
2784  {
2785  //No valid Input
2786  return;
2787  }
2788 
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())
2791  {
2792  //Non Valid Color Return
2793  return;
2794  }
2795 
2796  int id = m_id++;
2797  QTreeWidgetItem * childItem = new QTreeWidgetItem(LVRLabelInstanceType);
2798  childItem->setText(LABEL_NAME_COLUMN, instance_name);
2799  childItem->setText(LABELED_POINT_COLUMN, QString::number(0));
2800  childItem->setCheckState(LABEL_VISIBLE_COLUMN, Qt::Checked);
2801  childItem->setData(LABEL_ID_COLUMN, 1, label_color);
2802  childItem->setData(LABEL_ID_COLUMN, 0, id);
2803  selectedTopLevelItem->addChild(childItem);
2804 
2805 
2806  //Add label to combo box
2807  selectedInstanceComboBox->addItem(childItem->text(LABEL_NAME_COLUMN), id);
2808  Q_EMIT(labelAdded(childItem));
2809 
2810 }
2811 
2813 {
2814 
2815  //TODO: What should be done if elements exists?
2816  QString fileName = QFileDialog::getOpenFileName(this,
2817  tr("Open HDF5 File"), QDir::homePath(), tr("HDF5 files (*.h5)"));
2818  if(!QFile::exists(fileName))
2819  {
2820  return;
2821  }
2822 
2823  HDF5Kernel kernel(fileName.toStdString());
2824  std::vector<std::string> pointCloudNames;
2825  kernel.subGroupNames("pointclouds", pointCloudNames);
2826  for (auto pointcloudName : pointCloudNames)
2827  {
2828  //pointclouds
2829  boost::filesystem::path classGroup = (boost::filesystem::path("pointclouds") / boost::filesystem::path(pointcloudName) / boost::filesystem::path("labels"));
2830  std::vector<std::string> labelClasses;
2831  kernel.subGroupNames(classGroup.string(), labelClasses);
2832  for (auto labelClass : labelClasses)
2833  {
2834  //Get TopLevel Item for tree view
2835  QTreeWidgetItem * item = new QTreeWidgetItem();
2836  item->setText(0, QString::fromStdString(labelClass));
2837  item->setText(LABELED_POINT_COLUMN, QString::number(0));
2838  item->setCheckState(LABEL_VISIBLE_COLUMN, Qt::Checked);
2839 
2840  labelTreeWidget->addTopLevelItem(item);
2841 
2842 
2843  //pointclouds/$name/labels/$labelname
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)
2848  {
2849 
2850  int id = 0;
2851  boost::filesystem::path finalGroup = instanceGroup;
2852  //pointclouds/$name/labels/$labelname/instance
2853  finalGroup = (instanceGroup / boost::filesystem::path(instance));
2854  if (labelClass != UNKNOWNNAME)
2855  {
2856  id = m_id++;
2857 
2858  }
2859 
2860  //Get Color and IDs
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);
2867 
2868  //Add Child to top Level
2869  QTreeWidgetItem * childItem = new QTreeWidgetItem();
2870  childItem->setText(LABELED_POINT_COLUMN, QString::number(0));
2871  childItem->setText(0, QString::fromStdString(instance));
2872  QColor label_color(rgbData[0], rgbData[1], rgbData[2]);
2873  childItem->setData(LABEL_ID_COLUMN, 1, label_color);
2874  childItem->setData(LABEL_ID_COLUMN, 0, id);
2875  item->addChild(childItem);
2876  Q_EMIT(labelAdded(childItem));
2877  std::vector<int> out(idData.get(), idData.get() + idDim[0]);
2878  Q_EMIT(labelLoaded(id, out));
2879  selectedInstanceComboBox->addItem(childItem->text(LABEL_NAME_COLUMN), id);
2880 
2881  }
2882  }
2883  }
2884 }
2886 {
2887  std::vector<uint16_t> labeledPoints = m_pickingInteractor->getLabeles();
2888  vtkSmartPointer<vtkPolyData> points;
2889  std::map<uint16_t,std::vector<int>> idMap;
2890 
2891  for (int i = 0; i < labeledPoints.size(); i++)
2892  {
2893 
2894  if(idMap.find(labeledPoints[i]) == idMap.end())
2895  {
2896  //first occurence of id add new entry
2897  idMap[labeledPoints[i]] = {};
2898  }
2899  idMap[labeledPoints[i]].push_back(i);
2900  }
2901 
2902  QFileDialog dialog;
2903  dialog.setDirectory(QDir::homePath());
2904  dialog.setFileMode(QFileDialog::AnyFile);
2905  QString strFile = dialog.getSaveFileName(this, "Creat New HDF5 File","","");
2906 
2907  HDF5Kernel label_hdf5kernel((strFile + QString(".h5")).toStdString());
2908  int topItemCount = labelTreeWidget->topLevelItemCount();
2909 
2910 
2911  //TODO This should be for all Pointclouds
2912  boost::filesystem::path pointcloudName;
2913  QTreeWidgetItemIterator itu(treeWidget);
2914  LVRPointCloudItem* citem;
2915  while (*itu)
2916  {
2917  QTreeWidgetItem* item = *itu;
2918 
2919  if ( item->type() == LVRPointCloudItemType)
2920  {
2921  citem = static_cast<LVRPointCloudItem*>(*itu);
2922  pointcloudName = item->parent()->text(0).toStdString();
2923  points = citem->getPointBufferBridge()->getPolyData();
2924  }
2925  itu++;
2926  }
2927 
2928  double* pointsData = new double[points->GetNumberOfPoints() * 3];
2929 
2930  for (int i = 0; i < points->GetNumberOfPoints(); i++)
2931  {
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];
2936 
2937  }
2938 
2939  std::vector<size_t> pointsDimension = {3, points->GetNumberOfPoints()};
2940  boost::shared_array<double> sharedPoints(pointsData);
2941 
2942  //Unlabeled top item
2943  QTreeWidgetItem* unlabeledItem;
2944 
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++)
2948  {
2949  QTreeWidgetItem* topLevelItem = labelTreeWidget->topLevelItem(i);
2950  if(topLevelItem->text(LABEL_NAME_COLUMN) == QString::fromStdString(UNKNOWNNAME))
2951  {
2952  unlabeledItem = topLevelItem;
2953  }
2954  boost::filesystem::path topLabel = topLevelItem->text(LABEL_NAME_COLUMN).toStdString();
2955  int childCount = topLevelItem->childCount();
2956  for (int j = 0; j < childCount; j++)
2957  {
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())
2964  {
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);
2967 
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);
2974  }
2975  }
2976  }
2977 }
2978 
2980 {
2981  Q_EMIT(labelChanged(selectedInstanceComboBox->itemData(index).toInt()));
2982 }
2983 } /* namespace lvr2 */
QAction * m_actionOpenChunkedMesh
A class to handle point information with an arbitrarily large number of attribute channels...
Definition: PointBuffer.hpp:51
QAction * m_actionRenameModelItem
void updatePointPreview(int pointId, PointBufferPtr points)
Changes the Point displayed by the PointPreview.
void buildIncompatibilityBox(string actionName, unsigned char allowedTypes)
QAction * m_actionShowSpectralPointPreview
QPushButton * m_buttonCameraPathTool
QAction * m_actionSetViewToCamera
QAction * m_actionShow_Wireframe
void matrixToPose(const Transform< T > &mat, Vector3< T > &position, Vector3< T > &rotation)
Extracts the Pose from a Matrix.
PointBufferPtr getPointBuffer(QString name)
Datastructures for holding loaded data.
QLineEdit * m_gradientLineEdit
boost::shared_ptr< LVRPointBufferBridge > PointBufferBridgePtr
vtkSmartPointer< vtkCamera > m_camera
void showLabelTreeContextMenu(const QPoint &)
std::set< LVRModelItem * > getSelectedModelItems()
void onSpectralSliderChanged(int action=-1)
Determines if changeSpectralColor() should be called. Updates the m_spectralLineEdit to the value fro...
void setColor(QColor &c)
Definition: LVRMeshItem.cpp:80
const kaboom::Options * options
#define LABEL_VISIBLE_COLUMN
QPushButton * m_buttonTransformModel
A 4x4 matrix class implementation for use with the provided vertex types.
Definition: Matrix4.hpp:64
QList< QTreeWidgetItem * > m_items_copied
QAction * m_actionRemove_Outliers
#define LABEL_NAME_COLUMN
void loadModels(const QStringList &filenames)
QAction * m_actionPlanar_Optimization
std::vector< uint16_t > & getLabeles()
static int getSpectralChannel(int wavelength, PointBufferPtr p, int fallback=-1)
Returns the spectral channel index for a given wavelength.
Definition: Util.cpp:35
LVRPointCloudItem * getPointCloudItem(QTreeWidgetItem *item)
QAction * m_actionMatch_Textures_from_Package
QMessageBox * m_incompatibilityBox
std::string getInputFileName() const
Returns the input file.
LVRPlotter * m_PointPreviewPlotter
void cellSelected(QTreeWidgetItem *item, int column)
void changePicker(bool labeling)
ChunkedMeshBridgePtr m_chunkBridge
vtkSmartPointer< vtkActor > getActor()
void addNewInstance(QTreeWidgetItem *)
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > actorMap
void setPoints(vtkSmartPointer< vtkPolyData > points)
PointBufferPtr getPointBuffer()
QAction * m_actionExtract_labeling
QAction * m_actionStop_labeling
QAction * m_actionRemoveInstance
void correspondenceDialogOpened()
QAction * m_actionExtract_and_Rematch_Patterns
ChunkedMeshCuller * m_chunkCuller
void setShading(int &shader)
QAction * m_actionShowSpectralColorGradient
void onSpectralLineEditSubmit()
Same as onSpectralLineEditChanged(), but triggers changeSpectralView()
BoundingBoxBridgePtr getBoundingBoxBridge()
virtual void saveDoubleArray(const std::string &groupName, const std::string &datasetName, const std::vector< size_t > &dimensions, const boost::shared_array< double > &data) const
Definition: HDF5Kernel.cpp:447
static ModelPtr readModel(std::string filename)
LVRMeshItem * getMeshItem(QTreeWidgetItem *item)
QAction * m_actionUnloadPointCloudData
std::map< LVRPointCloudItem *, LVRHistogram * > m_histograms
vtkSmartPointer< vtkActor > getArrowActor()
std::set< LVRPointCloudItem * > getSelectedPointCloudItems()
QAction * m_actionMLS_Projection
QAction * m_actionReset_Camera
QAction * m_actionAddNewInstance
vtkSmartPointer< vtkActor > getStartActor()
void setXRange(int min, int max)
Definition: LVRPlotter.cpp:86
LVRLabelDialog * m_labelDialog
static const string UNKNOWNNAME
void getColor1(float &r, float &g, float &b)
void setVisibility(bool visible)
vtkSmartPointer< vtkRenderWindowInteractor > m_renderWindowInteractor
#define M_PI
Definition: Matrix4.hpp:52
virtual void subGroupNames(const std::string &group, std::vector< string > &subGroupNames) const
Definition: HDF5Kernel.cpp:474
void setVisibility(bool visible)
UCharChannel::Optional UCharChannelOptional
Definition: Channel.hpp:96
static LVRPickingInteractor * New()
std::shared_ptr< PointBuffer > PointBufferPtr
QAction * m_actionExportModelTransformed
void labelLoaded(int, std::vector< int >)
Main class for conversion of LVR model instances to vtk actors. This class parses the internal model ...
ModelBridgePtr getModelBridge()
QAction * m_actionShow_Normals
QAction * m_actionGlobal_Relaxation
LVRTreeWidgetHelper * m_treeWidgetHelper
void reconstructUsingMarchingCubes()
void showTreeContextMenu(const QPoint &)
void onGradientSliderChanged(int action=-1)
Determines if changeGradientColor() should be called. Updates the m_gradientLineEdit to the value fro...
void reconstructUsingPlanarMarchingCubes()
QAction * m_actionLoadPointCloudData
void updateSpectralGradientEnabled(bool checked)
Switches between Sliders and Gradients. checked == true => Gradient DockWidget enabled.
QPushButton * m_buttonExportData
vtkSmartPointer< vtkOrientationMarkerWidget > m_axesWidget
void changeTransparency(int transparencyValue)
QList< LVRPointCloudItem * > getPointCloudItems(QList< QTreeWidgetItem *> items)
Eigen::Vector3f Vector3f
Eigen 3D vector, single precision.
QAction * m_actionStart_labeling
void updateSpectralSlidersEnabled(bool checked)
Switches between Sliders and Gradients. checked == true => Slider DockWidget enabled.
LVRModelItem * loadModelItem(QString name)
BaseVector< float > Vec
vtkSmartPointer< vtkActor > getEndActor()
QAction * m_actionPasteModelItem
void showErrorDialog()
Shows a Popup Dialog saying that no PointClouds with spectral data are selected.
bool isSelfOrChildSelected(QTreeWidgetItem *item)
void setPoints(const std::string, const vtkSmartPointer< vtkPolyData > points)
BaseHDF5IO::AddFeatures< lvr2::hdf5features::ScanProjectIO, lvr2::hdf5features::ArrayIO > HDF5IO
boost::shared_ptr< LVRModelBridge > ModelBridgePtr
QAction * m_actionRemove_Artifacts
void changeShading(int shader)
QLabel * m_spectralLabels[3]
QMenu * m_treeChildItemContextMenu
__kf_device__ float3 normalized(const float3 &v)
Definition: temp_utils.hpp:97
__kf_device__ Vec3f tr(const float4 &v)
Definition: device.hpp:79
QMenu * m_labelTreeParentItemContextMenu
void onSpectralLineEditChanged()
Updates the m_spectralSlider to the value from m_spectralLineEdit.
LVRMainWindow()
MainWindow.
QAction * m_actionStore_Current_View
QTreeWidgetItem * m_selectedLabelItem
Transform< float > Transformf
4x4 single precision transformation matrix
Definition: MatrixTypes.hpp:68
void changeGradientColor()
Updates all selected LVRPointCloudItems to the desired Gradient. can take seconds ...
QCheckBox * m_spectralCheckboxes[3]
void toogleEDL(bool checkboxstate)
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
void setRenderer(vtkSmartPointer< vtkRenderer > renderer)
void setOpacity(float &opacity)
vtkSmartPointer< vtkActor > getActor()
QAction * m_actionShowSpectralSlider
QAction * m_actionICP_Using_Manual_Correspondance
std::set< LVRMeshItem * > getSelectedMeshItems()
QAction * m_actionICP_Using_Pose_Estimations
SharedPointer p
QMenu * m_treeParentItemContextMenu
void setVisibility(bool visible)
void onGradientLineEditSubmit()
Same as onGradientLineEditChanged(), but triggers changeGradientView()
void loadPointCloudData(vtkSmartPointer< vtkRenderer > renderer)
GradientType
Identifies a color gradient.
Definition: ColorMap.hpp:50
void changePointSize(int pointSize)
void setPoints(floatArr points, size_t numPoints)
Definition: LVRPlotter.cpp:57
QAction * m_actionCopyModelItem
void visibilityChanged(QTreeWidgetItem *, int)
QSlider * m_spectralSliders[3]
void removeArrow(LVRVtkArrow *)
QTreeWidgetItem * addScans(std::shared_ptr< ScanDataManager > sdm, QTreeWidgetItem *parent)
void onGradientLineEditChanged()
Updates the m_gradientSlider to the value from m_gradientLineEdit.
QAction * m_actionExtended_Marching_Cubes
static int getSpectralWavelength(int channel, PointBufferPtr p, int fallback=-1)
For a given spectral channel it return the corresponding wavelength.
Definition: Util.cpp:55
void comboBoxIndexChanged(int index)
void setSelectionColor(QColor &c)
QAction * m_actionPlanar_Marching_Cubes
bool childNameExists(QTreeWidgetItem *item, const QString &name)
LVRPickingInteractor * m_pickingInteractor
QAction * m_actionShowColorDialog
void setVisibility(bool visible, bool pc_visible)
void setPointSize(int &pointSize)
QAction * m_actionShowBackgroundSettings
QAction * m_actionCameraPathTool
static float wavelengthPerChannel(PointBufferPtr p)
Calculates the wavelength distance between two spectral channels.
Definition: Util.cpp:73
QAction * m_actionMarching_Cubes
QAction * m_actionEstimate_Normals
#define LABELED_POINT_COLUMN
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
QLineEdit * m_spectralLineEdits[3]
PointBufferBridgePtr getPointBufferBridge()
QPushButton * m_buttonCreateMesh
QAction * m_actionFurniture_Recognition
vtkSmartPointer< vtkAxesActor > m_axes
A wrapper class to generate arrow actors for vtk based on VTK&#39;s oriented arrow example.
Definition: LVRVtkArrow.hpp:49
void reconstructUsingExtendedMarchingCubes()
void toggleWireframe(bool checkboxState)
void setPose(const Pose &pose)
BaseVector< float > Vec
LVRModelItem * getModelItem(QString name)
vtkSmartPointer< vtkActor > getWireframeActor()
void setModelVisibility(QTreeWidgetItem *treeWidgetItem, int column)
void parseCommandLine(int argc, char **argv)
void changeSpectralColor()
Updates all selected LVRPointCloudItems to the desired Spectral. can take seconds ...
QAction * m_actionRecall_Stored_View
void saveArray(const std::string &groupName, const std::string &datasetName, const size_t &size, const boost::shared_array< T > data) const
QAction * m_actionShow_Points
std::vector< std::string > getLayers() const
Returns the layers used for LOD.
bool printUsage() const
Prints a usage message to stdout.
void togglePoints(bool checkboxState)
void updateDisplayLists(actorMap lowRes, actorMap highRes)
void toggleNormals(bool checkboxState)
void labelChanged(uint16_t)
LVRModelItem * getModelItem(QTreeWidgetItem *item)
void showHistogramDialog()
Shows a Popup Dialog with the average Intensity per Spectral Channel.
QAction * m_actionAddLabelClass
void setOpacity(float &opacity)
void restoreSliders()
Adjusts all the Sliders, LineEdits and CheckBoxes to the currently selected Items.
Ui_LabelDialog * m_ui
QAction * m_actionSimple_Plane_Classification
#define LABEL_ID_COLUMN
QAction * m_actionDeleteModelItem
void hidePoints(int, bool)
vtkSmartPointer< vtkRenderer > m_renderer
void unloadPointCloudData(vtkSmartPointer< vtkRenderer > renderer)
void addArrow(LVRVtkArrow *)
boost::optional< Transformf > getTransformation()
QString increaseFilename(QString filename)
QAction * m_actionShowSpectralHistogram
QAction * m_actionCompute_Textures
void setModelVisibility(int column, bool globalValue)
boost::shared_ptr< LVRChunkedMeshBridge > ChunkedMeshBridgePtr
QMenu * m_labelTreeChildItemContextMenu
#define NULL
Definition: mydefs.hpp:141
void updatePointCount(const uint16_t, const int)
void showPointInfoDialog()
Shows a Popup Dialog with Information about a Point.
PointBufferPtr m_previewPointBuffer
void labelAdded(QTreeWidgetItem *)
LVRCorrespondanceDialog * m_correspondanceDialog
PointBufferPtr getPointBuffer()
get the point buffer
void showPointPreview(vtkActor *actor, int point)
Shows the DockerWidget with the preview of the PointInfoDialog.
static void saveModel(ModelPtr m, std::string file)
vtkSmartPointer< vtkCameraRepresentation > m_pathCamera
char ** argv
void toggleMeshes(bool checkboxState)


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08