SkillDashboardWidgetController.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXGui::gui-plugins::OperatorViewWidgetController
19 * @author Leonie Leven
20 * @date 2024
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <thread>
28#include <unordered_set>
29
30#include <QApplication>
31#include <QClipboard>
32#include <QLabel>
33#include <QMainWindow>
34#include <QMap>
35#include <QPushButton>
36#include <QString>
37#include <QTimer>
38#include <QToolBar>
39#include <QToolButton>
40#include <QVBoxLayout>
41#include <QWidget>
42
45
46//#include <ArmarXGui/gui-plugins/DemoStateOperatorView/flowlayout.h>
47#include <stack>
48
52
53#include <RobotAPI/interface/components/SkillDashboardInterface.h>
54#include <RobotAPI/interface/skills/SkillManagerInterface.h>
55#include <RobotAPI/interface/skills/SkillMemoryInterface.h>
58
59#include "EllipsisPushButton.h"
61
62// C++ includes
63#include <memory>
64
65// ui_SkillDashboardWidget.h is included by the .cpp, not here: moc textually inlines every
66// #include it can resolve, and parsing the uic-generated header alongside this one
67// makes moc mis-qualify this class as Ui::armarx::*.
68namespace Ui
69{
70 class SkillDashboardWidget;
71}
72
73namespace armarx
74{
75
77 {
78 Q_OBJECT
79 Q_INTERFACES(ArmarXGuiInterface)
80 Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
81 public:
83
84 QString
85 getPluginName() override
86 {
87 return "SkillDashboardWidget";
88 }
89 };
90
92 public ArmarXComponentWidgetControllerTemplate<SkillDashboardWidget>
93 {
94 Q_OBJECT
95 public:
96 explicit SkillDashboardWidget();
97
98 // Defined in the .cpp, where Ui::SkillDashboardWidget is complete.
100 // inherited from Component
101 void onInitComponent() override;
102 void onConnectComponent() override;
103 void onDisconnectComponent() override;
104 void onExitComponent() override;
105
106 // inherited of ArmarXWidget
107 static QString
109 {
110 return "Skills.Dashboard";
111 }
112
113 void loadSettings(QSettings* settings) override;
114 void saveSettings(QSettings* settings) override;
115 QPointer<QDialog> getConfigDialog(QWidget* parent) override;
116 QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent) override;
117
118 void configured() override;
119
120 protected:
121 std::unique_ptr<Ui::SkillDashboardWidget> ui;
122
123
124 signals:
127 void skillFinished(const std::string& name, skills::core::dto::Execution::Status status);
128
129 private slots:
130 void openConfigWindow(const std::string& name = "",
131 const std::string& id = "",
132 const std::string& args = "",
133 const std::string& iconName = "",
134 const std::string& shortcutId = "");
135 void loadButtons();
136 void editShortcut(const std::string& name);
137 void deleteShortcut(const std::string& name);
138 void executeSkill(const std::string& name);
139 void exportButtons();
140 void activateButton(const std::string& name, skills::core::dto::Execution::Status status);
141 void onShortcutNameChanged();
142 void editMode(bool edit);
143 void enableBlockedButtons();
144 void importButtons();
145 void addFromClipboard();
146 void stopAll();
147 void saveShortcutOrder();
148 void loadPath();
149
150 private:
151 SkillDashboardConfigWindow* configWindow;
152 QVBoxLayout* shortcutLayout;
153 const std::string DEFAULT_SETTINGS_PLUGIN_NAME;
154 const std::string DEFAULT_SETTINGS_CUSTOM_TEXT;
155 QPointer<armarx::SimpleConfigDialog> m_config_dialog;
156 std::string skillDashboardProxyName;
157 std::string skillManagerOberserverName = "SkillManager";
158 SkillDashboardInterfacePrx dashboardPrx;
159 void clearLayout(QLayout* layout);
160 armarx::skills::manager::dti::SkillManagerInterfacePrx managerPrx;
161 std::thread exampleTask;
162 void exampleThreadMethod();
163 void updateShortcutListHeight();
164 std::atomic_bool connected = false;
165 std::map<std::string, EllipsisPushButton*> shortcutButtons;
166 std::map<std::string, QToolButton*> deleteButtons;
167 std::map<std::string, QToolButton*> configButtons;
168 std::map<std::string, skills::manager::dto::SkillExecutionID> runningSkills;
170 std::string currentShortcutName;
171 QAction* editModeAction;
172 QToolButton* recoverButtons;
173 QPointer<QToolBar> customToolbar;
174 bool initGUI = true;
175 bool editModeSetting;
176 MessageWidget* errorMessageArea;
177 };
178} // namespace armarx
The main gui interface.
void onInitComponent() override
Pure virtual hook for the subclass.
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
void onDisconnectComponent() override
Hook for subclass.
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
void onConnectComponent() override
Pure virtual hook for the subclass.
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
void skillFinished(const std::string &name, skills::core::dto::Execution::Status status)
void onExitComponent() override
Hook for subclass.
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
std::unique_ptr< Ui::SkillDashboardWidget > ui
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.