Skip to content

Commit

Permalink
Add tab panel & control
Browse files Browse the repository at this point in the history
  • Loading branch information
Juancams committed Jan 25, 2024
1 parent 16b9123 commit 7bafa6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <QThread>
#include <QApplication>
#include <QMessageBox>
#include <QTabWidget>

#undef NO_ERROR

Expand Down Expand Up @@ -65,9 +66,10 @@ class CoresensePanel : public rviz_common::Panel
void onInitialize() override;

protected:
QVBoxLayout * layout;
QVBoxLayout * layout_;
QTreeWidget * tree_widget_;
QLabel * label_info_;
QTabWidget * tab_widget_;

private slots:
void show_info(QTreeWidgetItem * item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,39 @@ CoresensePanel::CoresensePanel(QWidget * parent)
{
node_ = rclcpp::Node::make_shared("coresense_instrumentation_rviz_panel");

layout = new QVBoxLayout;
tab_widget_ = new QTabWidget();

QWidget* panel_tab = new QWidget();

QVBoxLayout* panel_layout = new QVBoxLayout(panel_tab);

// Crear un tree widget
tree_widget_ = new QTreeWidget();
tree_widget_->setColumnCount(3);
tree_widget_->setHeaderLabels({"Node", "State", "Type"});
tree_widget_->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
tree_widget_->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
tree_widget_->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
tree_widget_->clear();
layout->addWidget(tree_widget_);
panel_layout->addWidget(tree_widget_);

// Crear un label
label_info_ = new QLabel();
layout->addWidget(label_info_);
panel_layout->addWidget(label_info_);

connect(
tree_widget_, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this,
SLOT(show_info(QTreeWidgetItem*)));

// Establecer el diseño del panel
setLayout(layout);
panel_tab->setLayout(panel_layout);
tab_widget_->addTab(panel_tab, "Panel");

QWidget* control_tab = new QWidget();
QVBoxLayout* control_layout = new QVBoxLayout(control_tab);
control_tab->setLayout(control_layout);
tab_widget_->addTab(control_tab, "Control");

layout_ = new QVBoxLayout();
layout_->addWidget(tab_widget_);
setLayout(layout_);

status_sub_ = node_->create_subscription<coresense_instrumentation_interfaces::msg::NodeInfo>(
"/status", 10, std::bind(&CoresensePanel::statusCallback, this, std::placeholders::_1));
Expand Down

0 comments on commit 7bafa6f

Please sign in to comment.