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