SkillMemoryGui.cpp
Go to the documentation of this file.
1 #include "SkillMemoryGui.h"
2 
3 #include "gui_utils.h"
4 
5 namespace armarx::skills::gui
6 {
7  SkillMemoryGUI::SkillMemoryGUI(QTreeWidget* _skillExecutionTreeWidget,
8  QLayout* _skillExecutionTreeWidgetParentLayout,
9  QGroupBox* _skillGroupBox,
10  QSplitter* _skillGroupBoxParentLayout,
11  QGroupBox* _skillDetailGroupBox,
12  QSplitter* _skillDetailGroupBoxParentLayout,
13  QHBoxLayout* _updateWidgetLayout,
14 
15  QLayout* stopAllLayout,
16 
17  QWidget* _connectionStatusLabel,
18 
19  std::shared_ptr<SkillManagerWrapper> _memory)
20  {
21  Logging::setTag("SkillMemoryGui");
22 
23  // parameter check
24  ARMARX_CHECK(_skillExecutionTreeWidgetParentLayout);
25  ARMARX_CHECK(_skillGroupBoxParentLayout);
26  ARMARX_CHECK(_skillDetailGroupBoxParentLayout);
27  ARMARX_CHECK(_memory);
28 
29  ARMARX_CHECK(_skillExecutionTreeWidget);
30  ARMARX_CHECK(_skillGroupBox);
31  ARMARX_CHECK(_skillDetailGroupBox);
32  ARMARX_CHECK(_updateWidgetLayout);
33  ARMARX_CHECK(_connectionStatusLabel);
34  ARMARX_CHECK(_memory);
35 
36  // setup memory
37  this->memory = _memory;
38 
39  // Update widget
40  this->updateWidgetLayout = _updateWidgetLayout;
41  this->updateWidget = new PeriodicUpdateWidget();
42  this->updateWidgetLayout->insertWidget(0, updateWidget);
43 
44 
45  // replace skillExecutionTreeWidget
46  this->skillExecutionTreeWidget = new SkillExecutionTreeWidget(memory);
47  armarx::gui::replaceWidget(_skillExecutionTreeWidget,
48  this->skillExecutionTreeWidget,
49  _skillExecutionTreeWidgetParentLayout);
50 
51  // replace skillGroupBox
52  this->skillGroupBox = new SkillGroupBox(memory);
53 
54  // replace skillDetailGroupBox
55  this->skillDetailGroupBox = new SkillDetailGroupBox(memory);
56 
57  armarx::gui::clearSplitter(_skillGroupBoxParentLayout);
58  _skillGroupBoxParentLayout->insertWidget(0, this->skillDetailGroupBox);
59  _skillGroupBoxParentLayout->insertWidget(0, this->skillGroupBox);
60 
61  // setup stop all button
62  stopAllButton = new QPushButton(QString::fromStdString(STOP_ALL_BUTTON_TEXT));
63  stopAllLayout->addWidget(stopAllButton);
64 
65  this->connectionStatusLabel = new StatusLabel();
66  armarx::gui::replaceWidget(_connectionStatusLabel,
67  this->connectionStatusLabel,
68  _connectionStatusLabel->parentWidget()->layout());
69 
70  setupUi();
71  }
72 
73  void
74  SkillMemoryGUI::setupUi()
75  {
76  stopAllButton->setStyleSheet("background-color: red");
77  connectSignals();
78  }
79 
80  void
81  SkillMemoryGUI::connectSignals()
82  {
83  connect(skillGroupBox,
85  skillDetailGroupBox,
87 
88  // disconnect gui
89  connect(this, &SkillMemoryGUI::disconnectGui, skillGroupBox, &SkillGroupBox::disconnectGui);
90  connect(this,
92  skillDetailGroupBox,
94  connect(this,
96  skillExecutionTreeWidget,
98  connect(
100 
101  // connect gui
102  connect(this,
104  updateWidget,
106  connect(this, &SkillMemoryGUI::connectGui, skillGroupBox, &SkillGroupBox::connectGui);
107 
108  // timer
109  connect(this->updateWidget,
111  this->memory.get(),
113 
114  // updates
115  connect(this->memory.get(),
117  this,
119 
120  connect(this, &SkillMemoryGUI::updateGui, this->skillGroupBox, &SkillGroupBox::updateGui);
121 
122  connect(this,
124  this->skillExecutionTreeWidget,
126 
127 
128  // stop all
129  connect(stopAllButton,
130  &QPushButton::clicked,
131  memory.get(),
133 
134  // status label
135  connect(memory.get(),
137  connectionStatusLabel,
139  }
140 } // namespace armarx::skills::gui
armarx::skills::gui::SkillGroupBox::connectGui
void connectGui(std::string observerName)
Definition: SkillGroupBox.cpp:23
armarx::skills::gui::SkillMemoryGUI::SkillMemoryGUI
SkillMemoryGUI(QTreeWidget *_skillExecutionTreeWidget, QLayout *_skillExecutionTreeWidgetParentLayout, QGroupBox *_skillGroupBox, QSplitter *_skillGroupBoxParentLayout, QGroupBox *_skillDetailGroupBox, QSplitter *_skillDetailGroupBoxParentLayout, QHBoxLayout *_updateWidgetLayout, QLayout *stopAllLayout, QWidget *connectionStatusLabel, std::shared_ptr< SkillManagerWrapper > _memory)
Definition: SkillMemoryGui.cpp:7
armarx::skills::gui::SkillManagerWrapper::updateAvailable
void updateAvailable(Snapshot update)
armarx::skills::gui::StatusLabel::handleMessage
void handleMessage(std::string const &message, std::string const &error)
Display a message to indicate an update.
Definition: StatusLabel.cpp:16
armarx::skills::gui::SkillGroupBox::updateSkillDetails
void updateSkillDetails(skills::SkillID &skillId)
Notify the skill description widget of an updated selection.
armarx::skills::gui::SkillManagerWrapper::updateFromMemory
void updateFromMemory()
Requests this wrapper to overwrite its own state from memory.
Definition: SkillManagerWrapper.cpp:227
armarx::skills::gui::SkillGroupBox::disconnectGui
void disconnectGui()
armarx::skills::gui::SkillMemoryGUI::STOP_ALL_BUTTON_TEXT
static const constexpr char * STOP_ALL_BUTTON_TEXT
Definition: SkillMemoryGui.h:28
armarx::skills::gui::SkillMemoryGUI::disconnectGui
void disconnectGui()
Notify affected widgets to clear all saved state.
armarx::skills::gui::SkillManagerWrapper::connectionUpdate
void connectionUpdate(std::string const &message, std::string const &error)
armarx::skills::gui::PeriodicUpdateWidget::stopTimer
void stopTimer()
Definition: PeriodicUpdateWidget.cpp:96
armarx::skills::gui::SkillMemoryGUI::connectGui
void connectGui(std::string observerName)
Notify widgets of new connection.
armarx::skills::gui::SkillDetailGroupBox
Definition: SkillDetailsGroupBox.h:19
armarx::gui::replaceWidget
void replaceWidget(WidgetT *&old, QWidget *neu, QLayout *parentLayout)
Definition: gui_utils.h:36
armarx::memory
Brief description of class memory.
Definition: memory.h:39
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::skills::gui::SkillDetailGroupBox::disconnectGui
void disconnectGui()
armarx::skills::gui::PeriodicUpdateWidget
Definition: PeriodicUpdateWidget.h:14
armarx::skills::gui::PeriodicUpdateWidget::update
void update()
armarx::skills::gui::SkillExecutionTreeWidget::disconnectGui
void disconnectGui()
Definition: SkillExecutionTreeWidget.cpp:84
armarx::skills::gui::SkillGroupBox
Definition: SkillGroupBox.h:13
armarx::skills::gui
Definition: PeriodicUpdateWidget.cpp:11
armarx::skills::gui::StatusLabel
Definition: StatusLabel.h:8
armarx::skills::gui::SkillMemoryGUI::updateGui
void updateGui(SkillManagerWrapper::Snapshot update)
armarx::skills::gui::SkillDetailGroupBox::updateSkillDetails
void updateSkillDetails(skills::SkillID &skillId)
Notify subwidgets of an updated skill selection.
Definition: SkillDetailsGroupBox.cpp:6
armarx::skills::gui::SkillExecutionTreeWidget::updateGui
void updateGui(SkillManagerWrapper::Snapshot update)
Definition: SkillExecutionTreeWidget.cpp:143
SkillMemoryGui.h
armarx::gui::clearSplitter
void clearSplitter(QSplitter *splitter)
Definition: gui_utils.cpp:103
armarx::Logging::setTag
void setTag(const LogTag &tag)
Definition: Logging.cpp:55
armarx::skills::gui::SkillManagerWrapper::stopAllExecutions
void stopAllExecutions()
Stops all available (and running) executions.
Definition: SkillManagerWrapper.cpp:196
armarx::skills::gui::SkillExecutionTreeWidget
Definition: SkillExecutionTreeWidget.h:14
gui_utils.h
armarx::skills::gui::SkillGroupBox::updateGui
void updateGui(SkillManagerWrapper::Snapshot update)
Definition: SkillGroupBox.cpp:29
armarx::skills::gui::PeriodicUpdateWidget::startTimerIfEnabled
void startTimerIfEnabled()
Definition: PeriodicUpdateWidget.cpp:78