PointCloudSegmentsTable.cpp
Go to the documentation of this file.
2 
4 
6 
8 #include <VisionX/gui-plugins/UserAssistedSegmenterGui/widgets/ui_PointCloudSegmentsTable.h>
9 
10 int
11 toByte(float f)
12 {
13  return static_cast<int>(f * 255.f);
14 }
15 
16 static QColor
17 qcolor(std::size_t id)
18 {
19  const armarx::DrawColor c = armarx::GlasbeyLUT::at(id);
20  return QColor(toByte(c.r), toByte(c.g), toByte(c.b), toByte(c.a));
21 }
22 
23 namespace visionx
24 {
25 
27  QTableWidget(parent), ui(new Ui::PointCloudSegmentsTable)
28  {
29  ui->setupUi(this);
30 
31  setColumnCount(3);
32  setRowCount(1);
33 
34  QStringList header;
35  header << "ID"
36  << "#Points"
37  << "C";
38  setHorizontalHeaderLabels(header);
39  setEditTriggers(QAbstractItemView::NoEditTriggers);
40  setColumnWidth(0, 45);
41  setColumnWidth(1, 75);
42  setColumnWidth(2, 30);
43  }
44 
46  {
47  delete ui;
48  }
49 
50  void
51  PointCloudSegmentsTable::setData(const pcl::PointCloud<pcl::PointXYZRGBL>& pointCloud,
52  bool excludeZero)
53  {
54  setData(visionx::tools::getLabelMap(pointCloud, excludeZero));
55  }
56 
57  void
59  const std::map<PointCloudSegmentsTable::Label, pcl::PointIndices>& segmentMap)
60  {
61  // Fill table
62  setRowCount(static_cast<int>(segmentMap.size()));
63 
64  // Allow sorting by numeric columns: https://stackoverflow.com/a/7852076
65 
66  int row = 0;
67  for (const auto& [segmentID, indices] : segmentMap)
68  {
69  std::size_t size = indices.indices.size();
70 
71  QTableWidgetItem* itemID = new QTableWidgetItem();
72  itemID->setData(Qt::EditRole, segmentID);
73  itemID->setTextAlignment(Qt::AlignCenter);
74  setItem(row, 0, itemID);
75 
76  QTableWidgetItem* itemSize = new QTableWidgetItem();
77  itemSize->setData(Qt::EditRole, static_cast<int>(size));
78  itemSize->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
79  setItem(row, 1, itemSize);
80 
81  QTableWidgetItem* itemColor = new QTableWidgetItem(QString(""));
82  itemColor->setBackgroundColor(qcolor(segmentID));
83  setItem(row, 2, itemColor);
84 
85  row++;
86  }
87  sortItems(1);
88  }
89 
90 } // namespace visionx
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
armarx::GlasbeyLUT::at
static DrawColor at(std::size_t id, float alpha=1.f)
Definition: GlasbeyLUT.cpp:27
PointCloudSegmentsTable.h
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
toByte
int toByte(float f)
Definition: PointCloudSegmentsTable.cpp:11
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:54
pcl::graph::indices
pcl::PointIndices::Ptr indices(const PCG &g)
Retrieve the indices of the points of the point cloud stored in a point cloud graph that actually bel...
Definition: point_cloud_graph.h:717
PCLUtilities.h
visionx::PointCloudSegmentsTable::PointCloudSegmentsTable
PointCloudSegmentsTable(QWidget *parent=nullptr)
Definition: PointCloudSegmentsTable.cpp:26
visionx::PointCloudSegmentsTable
Definition: PointCloudSegmentsTable.h:21
GlasbeyLUT.h
visionx::tools::getLabelMap
std::map< uint32_t, pcl::PointIndices > getLabelMap(const PointCloudT &labeledCloud, bool excludeZero=true)
Definition: PCLUtilities.h:161
visionx::PointCloudSegmentsTable::setData
void setData(const pcl::PointCloud< pcl::PointXYZRGBL > &pointCloud, bool excludeZero=false)
Definition: PointCloudSegmentsTable.cpp:51
visionx::PointCloudSegmentsTable::~PointCloudSegmentsTable
~PointCloudSegmentsTable()
Definition: PointCloudSegmentsTable.cpp:45
Logging.h