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 <QVBoxLayout>
40 #include <QWidget>
41 
44 
48 
49 #include <RobotAPI/gui-plugins/ui_SkillDashboardWidget.h>
50 #include <RobotAPI/interface/components/SkillDashboardInterface.h>
51 #include <RobotAPI/interface/skills/SkillManagerInterface.h>
52 #include <RobotAPI/interface/skills/SkillMemoryInterface.h>
55 
57 
58 namespace armarx
59 {
60 
62  {
63  Q_OBJECT
64  Q_INTERFACES(ArmarXGuiInterface)
65  Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
66  public:
68 
69  QString
70  getPluginName() override
71  {
72  return "SkillDashboardWidget";
73  }
74  };
75 
76  /*!
77  * \page RobotAPI-GuiPlugins-HandUnitWidget HandUnitGuiPlugin
78  * \brief With this widget the HandUnit can be controlled.
79  * \image html HandUnitGUI.png
80  * You can either select a preshape from the drop-down-menu on top or set each
81  * joint individually.
82  * When you add the widget to the Gui, you need to specify the following parameters:
83  *
84  * Parameter Name | Example Value | Required? | Description
85  * :---------------- | :-------------: | :-------------- |:--------------------
86  * Proxy | LeftHandUnit | Yes | The hand unit you want to control.
87  */
89  public ArmarXComponentWidgetControllerTemplate<SkillDashboardWidget>
90  {
91  Q_OBJECT
92  public:
93  explicit SkillDashboardWidget();
94 
96  {
97  }
98 
99  // inherited from Component
100  void onInitComponent() override;
101  void onConnectComponent() override;
102  void onDisconnectComponent() override;
103  void onExitComponent() override;
104 
105  // inherited of ArmarXWidget
106  static QString
108  {
109  return "Skills.Dashboard";
110  }
111 
112  void loadSettings(QSettings* settings) override;
113  void saveSettings(QSettings* settings) override;
114  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
115  QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent) override;
116 
117 
118  void configured() override;
119 
120  protected:
121  Ui::SkillDashboardWidget ui;
122 
123 
124  signals:
125  void loadButtonInit();
126  void skillFinished(const std::string& name);
127 
128  private slots:
129  void openConfigWindow(const std::string& name = "",
130  const std::string& id = "",
131  const std::string& args = "");
132  void loadButtons();
133  void editShortcut(const std::string& name);
134  void deleteShortcut(const std::string& name);
135  void executeSkill(const std::string& name);
136  void exportButtons();
137  void activateButton(const std::string& name);
138  void onShortcutNameChanged();
139  void editMode(bool edit);
140 
141  private:
142  SkillDashboardConfigWindow* configWindow;
143  QVBoxLayout* shortcutLayout;
144  const std::string DEFAULT_SETTINGS_PLUGIN_NAME;
145  const std::string DEFAULT_SETTINGS_CUSTOM_TEXT;
146  QPointer<armarx::SimpleConfigDialog> m_config_dialog;
147  std::string dashboardManagerName;
148  std::string skillManagerOberserverName = "SkillManager";
149  SkillDashboardInterfacePrx dashboardPrx;
150  void clearLayout(QLayout* layout);
151  armarx::skills::manager::dti::SkillManagerInterfacePrx managerPrx;
152  std::thread exampleTask;
153  void exampleThreadMethod();
154  std::atomic_bool connected = false;
155  std::map<std::string, QPushButton*> shortcutButtons;
156  std::map<std::string, QToolButton*> deleteButtons;
157  std::map<std::string, QToolButton*> configButtons;
158  std::map<std::string, skills::manager::dto::SkillExecutionID> runningSkills;
160  std::string currentShortcutName;
161  QAction* editModeAction;
162  QPointer<QToolBar> customToolbar;
163  };
164 } // namespace armarx
armarx::ArmarXGuiPlugin
Definition: ArmarXGuiPlugin.h:46
armarx::SkillDashboardConfigWindow
Definition: SkillDashboardConfigWindow.h:39
armarx::SkillDashboardWidget::skillFinished
void skillFinished(const std::string &name)
RunningTask.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
Dict.h
armarx::SkillDashboardGuiPlugin::getPluginName
QString getPluginName() override
Definition: SkillDashboardWidgetController.h:70
NLohmannJSONConverter.h
ArmarXGuiInterface
The main gui interface.
Definition: ArmarXGuiInterface.h:80
ArmarXGuiPlugin.h
armarx::SkillDashboardWidget::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: SkillDashboardWidgetController.cpp:595
armarx::SkillDashboardWidget::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: SkillDashboardWidgetController.cpp:111
ArmarXComponentWidgetController.h
armarx::SkillDashboardWidget::~SkillDashboardWidget
virtual ~SkillDashboardWidget()
Definition: SkillDashboardWidgetController.h:95
armarx::SkillDashboardWidget::loadButtonInit
void loadButtonInit()
armarx::SkillDashboardWidget::getCustomTitlebarWidget
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
Definition: SkillDashboardWidgetController.cpp:492
armarx::SkillDashboardGuiPlugin
Definition: SkillDashboardWidgetController.h:61
SkillDashboardConfigWindow.h
armarx::SkillDashboardWidget::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: SkillDashboardWidgetController.cpp:586
armarx::SkillDashboardWidget::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: SkillDashboardWidgetController.cpp:133
armarx::SkillDashboardWidget::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: SkillDashboardWidgetController.cpp:557
armarx::SkillDashboardWidget::SkillDashboardWidget
SkillDashboardWidget()
Definition: SkillDashboardWidgetController.cpp:71
armarx::SkillDashboardWidget::ui
Ui::SkillDashboardWidget ui
Definition: SkillDashboardWidgetController.h:121
armarx::SkillDashboardWidget::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: SkillDashboardWidgetController.cpp:573
armarx::SkillDashboardWidget::GetWidgetName
static QString GetWidgetName()
Definition: SkillDashboardWidgetController.h:107
armarx::SkillDashboardGuiPlugin::SkillDashboardGuiPlugin
SkillDashboardGuiPlugin()
Definition: SkillDashboardWidgetController.cpp:66
armarx::SkillDashboardWidget::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: SkillDashboardWidgetController.cpp:545
armarx::SkillDashboardWidget
Definition: SkillDashboardWidgetController.h:88
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::SkillDashboardWidget::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: SkillDashboardWidgetController.cpp:552
ImportExportComponent.h