LVRScanDataItem.cpp
Go to the documentation of this file.
1 #include "LVRScanDataItem.hpp"
2 #include "LVRModelItem.hpp"
3 #include "LVRItemTypes.hpp"
4 
6 
7 namespace lvr2
8 {
9 
11  ScanPtr data, std::shared_ptr<ScanDataManager> sdm, size_t idx,
12  vtkSmartPointer<vtkRenderer> renderer,
13  QString name, QTreeWidgetItem *parent)
14  : QTreeWidgetItem(parent, LVRScanDataItemType) ,m_renderer(renderer)
15 {
16  m_showSpectralsItem = nullptr;
17  m_pcItem = nullptr;
18  m_pItem = nullptr;
19  m_bbItem = nullptr;
20  m_data = data;
21  m_name = name;
22  m_sdm = sdm;
23  m_idx = idx;
24 
25 
26  // init pose
27  double pose[6];
28  eigenToEuler<double>(m_data->registration, pose);
29 
30  m_matrix = m_data->registration;
31 
32  m_pose.x = pose[0];
33  m_pose.y = pose[1];
34  m_pose.z = pose[2];
35  m_pose.r = pose[3] * 57.295779513;
36  m_pose.t = pose[4] * 57.295779513;
37  m_pose.p = pose[5] * 57.295779513;
38 
40 
42 
43  // init bb
45  m_bbItem = new LVRBoundingBoxItem(m_bb, "Bounding Box", this);
46  renderer->AddActor(m_bb->getActor());
47  m_bb->setPose(m_pose);
48 
50 
51  // load data
52  reload();
53 
54  setText(0, m_name);
55  setCheckState(0, Qt::Checked);
56 }
57 
59 {
61 }
62 
63 void LVRScanDataItem::reload(vtkSmartPointer<vtkRenderer> renderer)
64 {
65  if (m_model)
66  {
67  m_model->removeActors(renderer);
68  }
69 
70  if (m_pcItem)
71  {
72  delete m_pcItem;
73  }
74 
76  {
77  delete m_showSpectralsItem;
78  m_showSpectralsItem = nullptr;
79  }
80 
81  if (m_data->points)
82  {
83  m_model = ModelBridgePtr(new LVRModelBridge( ModelPtr( new Model(m_data->points))));
84  m_pcItem = new LVRPointCloudItem(m_model->getPointBridge(), this);
85 
86  m_model->addActors(renderer);
87  m_model->setTransform(m_matrix);
88 
89  if (!isPointCloudLoaded())
90  {
91  setText(1, "(Preview)");
92  }
93 
94  if (m_data->points->getUCharChannel("spectral_channels"))
95  {
96  m_showSpectralsItem = new QTreeWidgetItem(this);
97  m_showSpectralsItem->setText(0, "Spectrals");
98  m_showSpectralsItem->setCheckState(0, Qt::Checked);
99  }
100  }
101 }
102 
104 {
105  return m_data->pointsLoaded;
106 }
107 
108 void LVRScanDataItem::loadPointCloudData(vtkSmartPointer<vtkRenderer> renderer)
109 {
110  m_sdm->loadPointCloudData(m_data);
111 
112  if (isPointCloudLoaded())
113  {
114  reload(renderer);
115 
116  setText(1, "");
117  }
118 }
119 
120 void LVRScanDataItem::unloadPointCloudData(vtkSmartPointer<vtkRenderer> renderer)
121 {
122  m_sdm->loadPointCloudData(m_data, true);
123 
124  reload(renderer);
125 }
126 
128 {
129  return m_model;
130 }
131 
132 void LVRScanDataItem::setVisibility(bool visible, bool pc_visible)
133 {
134  if (!this->checkState(0))
135  {
136  visible = false;
137  }
138 
139  for (int i = 0; i < childCount(); i++)
140  {
141  QTreeWidgetItem* item = child(i);
142 
143  if(item->type() == LVRCamerasItemType)
144  {
145  for(int j=0; j < item->childCount(); j++)
146  {
147  QTreeWidgetItem* cam_item = item->child(j);
148 
149  if(cam_item->type() == LVRCamDataItemType)
150  {
151  LVRCamDataItem* cam_item_c = static_cast<LVRCamDataItem*>(cam_item);
152  cam_item_c->setVisibility(visible);
153  }
154 
155  }
156  }
157 
158  item->setHidden(!visible);
159  }
160 
161  if (m_model)
162  {
163  m_model->setVisibility(pc_visible && visible);
164  }
165 
167  {
168  m_model->getPointBridge()->setColorsVisibility(m_showSpectralsItem->checkState(0));
169  }
170 
171  if (m_bbItem)
172  {
173  m_bbItem->setVisibility(visible);
174  }
175 
176 }
177 
179 {
180  // we don't want to do delete m_bbItem, m_pItem and m_pcItem here
181  // because QTreeWidgetItem deletes its childs automatically in its destructor.
182 }
183 
184 } // namespace lvr2
lvr2::LVRScanDataItem::m_name
QString m_name
Definition: LVRScanDataItem.hpp:62
lvr2::LVRBoundingBoxBridge
Definition: LVRBoundingBoxBridge.hpp:17
lvr2::Pose::t
float t
Definition: LVRModelBridge.hpp:53
lvr2::LVRScanDataItem::getModelBridgePtr
ModelBridgePtr getModelBridgePtr()
Definition: LVRScanDataItem.cpp:127
lvr2::LVRScanDataItem::m_idx
size_t m_idx
Definition: LVRScanDataItem.hpp:64
lvr2::LVRScanDataItem::m_renderer
vtkSmartPointer< vtkRenderer > m_renderer
Definition: LVRScanDataItem.hpp:74
lvr2::LVRBoundingBoxItem::setVisibility
void setVisibility(bool visible)
Definition: LVRBoundingBoxItem.cpp:45
LVRItemTypes.hpp
lvr2::LVRScanDataItem::~LVRScanDataItem
~LVRScanDataItem()
Definition: LVRScanDataItem.cpp:178
lvr2::LVRPointCloudItem
Definition: LVRPointCloudItem.hpp:45
LVRModelItem.hpp
lvr2::LVRScanDataItem::loadPointCloudData
void loadPointCloudData(vtkSmartPointer< vtkRenderer > renderer)
Definition: LVRScanDataItem.cpp:108
lvr2::Model
Definition: Model.hpp:51
lvr2::LVRCamDataItemType
@ LVRCamDataItemType
Definition: LVRItemTypes.hpp:47
lvr2::LVRScanDataItem::m_pItem
LVRPoseItem * m_pItem
Definition: LVRScanDataItem.hpp:71
lvr2::LVRScanDataItem::m_bbItem
LVRBoundingBoxItem * m_bbItem
Definition: LVRScanDataItem.hpp:69
lvr2::LVRScanDataItem::m_sdm
std::shared_ptr< ScanDataManager > m_sdm
Definition: LVRScanDataItem.hpp:63
lvr2::TransformableBase::setTransform
void setTransform(Eigen::Matrix< T, 4, 4 > transform)
Definition: Transformable.hpp:22
lvr2::ModelBridgePtr
boost::shared_ptr< LVRModelBridge > ModelBridgePtr
Definition: LVRModelBridge.hpp:120
lvr2::Pose::r
float r
Definition: LVRModelBridge.hpp:53
lvr2::LVRScanDataItem::setVisibility
void setVisibility(bool visible, bool pc_visible)
Definition: LVRScanDataItem.cpp:132
lvr2::LVRBoundingBoxItem
Definition: LVRBoundingBoxItem.hpp:12
lvr2::LVRScanDataItem::m_data
ScanPtr m_data
Definition: LVRScanDataItem.hpp:65
lvr2::LVRScanDataItem::m_pose
Pose m_pose
Definition: LVRScanDataItem.hpp:68
LVRScanDataItem.hpp
lvr2::LVRScanDataItemType
@ LVRScanDataItemType
Definition: LVRItemTypes.hpp:46
lvr2::LVRScanDataItem::m_pcItem
LVRPointCloudItem * m_pcItem
Definition: LVRScanDataItem.hpp:70
lvr2::Pose::p
float p
Definition: LVRModelBridge.hpp:53
lvr2::LVRModelBridge
Main class for conversion of LVR model instances to vtk actors. This class parses the internal model ...
Definition: LVRModelBridge.hpp:61
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::ModelPtr
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
lvr2::Pose::x
float x
Definition: LVRModelBridge.hpp:53
lvr2::LVRPoseItem::setPose
void setPose(const Pose &pose)
Definition: LVRPoseItem.cpp:69
lvr2::Pose::y
float y
Definition: LVRModelBridge.hpp:53
lvr2::BoundingBoxBridgePtr
boost::shared_ptr< LVRBoundingBoxBridge > BoundingBoxBridgePtr
Definition: LVRBoundingBoxBridge.hpp:35
lvr2::Pose::z
float z
Definition: LVRModelBridge.hpp:53
lvr2::LVRScanDataItem::m_matrix
Transformd m_matrix
Definition: LVRScanDataItem.hpp:73
lvr2::LVRScanDataItem::reload
void reload()
Definition: LVRScanDataItem.cpp:58
lvr2::LVRPoseItem
Definition: LVRPoseItem.hpp:44
lvr2::LVRScanDataItem::m_model
ModelBridgePtr m_model
Definition: LVRScanDataItem.hpp:66
lvr2::LVRCamDataItem::setVisibility
void setVisibility(bool visible)
Definition: LVRCamDataItem.cpp:92
lvr2::LVRScanDataItem::m_bb
BoundingBoxBridgePtr m_bb
Definition: LVRScanDataItem.hpp:67
lvr2::LVRScanDataItem::m_showSpectralsItem
QTreeWidgetItem * m_showSpectralsItem
Definition: LVRScanDataItem.hpp:72
lvr2::LVRScanDataItem::unloadPointCloudData
void unloadPointCloudData(vtkSmartPointer< vtkRenderer > renderer)
Definition: LVRScanDataItem.cpp:120
lvr2::LVRScanDataItem::LVRScanDataItem
LVRScanDataItem(ScanPtr data, std::shared_ptr< ScanDataManager > sdm, size_t idx, vtkSmartPointer< vtkRenderer > renderer, QString name="", QTreeWidgetItem *parent=NULL)
Definition: LVRScanDataItem.cpp:10
lvr2::LVRCamerasItemType
@ LVRCamerasItemType
Definition: LVRItemTypes.hpp:48
lvr2::LVRScanDataItem::isPointCloudLoaded
bool isPointCloudLoaded()
Definition: LVRScanDataItem.cpp:103
lvr2::LVRCamDataItem
Definition: LVRCamDataItem.hpp:36
TransformUtils.hpp
lvr2::ScanPtr
std::shared_ptr< Scan > ScanPtr
Shared pointer to scans.
Definition: ScanTypes.hpp:98


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 Wed Mar 2 2022 00:37:24