OperatorViewWidgetController.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 <QMap>
34#include <QPushButton>
35#include <QString>
36#include <QTimer>
37#include <QVBoxLayout>
38#include <QWidget>
39
41
42#include <ArmarXGui/gui-plugins/MessageDisplayPlugin/ui_form.h>
43#include <ArmarXGui/interface/DemoStateManagerInterface.h>
47
48#include "flowlayout.h"
49
50namespace armarx
51{
52
54 public armarx::ArmarXComponentWidgetControllerTemplate<OperatorViewWidgetController>
55
56 {
57 Q_OBJECT
58
59 public:
61
63 {
64 }
65
66 // inherited from armarx::Component
67 // implement you custom startup, connect and exit code here
68 virtual void onInitComponent();
69 virtual void onConnectComponent();
70 virtual void onDisconnectComponent();
71 virtual void onExitComponent();
72
73 static QString
75 {
76 return "DemoState.OperatorView";
77 }
78
79 // You may want to offer GUI save/load functionality.
80 // If not, you can leave these methods empty.
81 virtual void loadSettings(QSettings* settings);
82 virtual void saveSettings(QSettings* settings);
83
84 QPointer<QDialog> getConfigDialog(QWidget* parent) override;
85
86 void configured() override;
87
88
89 signals:
92 void stateAndSeverityUpdated(QString state, int severity);
93
94
95 public slots:
96
97 // you may want to specify custom Qt slots methods here
98 // don't forget to connect them in onConnectComponent()
99 // e.g. connect(ui.myButton, SIGNAL(clicked()), this, SLOT(myButtonPressed()));
100 // void myButtonPressed();
101 void insertButtonPressed(QString text = "", int severity = -1);
102 void sendOnlyButtonPressed(QString text = "", int severity = -1);
103 void createButtonLayout();
104 void defaultButtonPressed(std::string state, armarx::severity::SeverityEnum severity);
106 void cleanUI();
107 void checkState();
108 void updateStateAndSeverity(QString state, int severity);
109
110 private:
111 // the ui object comes from your Qt-UI widget "ui_MyGuiPluginWidget.h"
112 // PLEASE NOTE: the toplevel widget in this file needs to be named MyGuiPluginWidget
113 // otherwise this line will fail to compile
114 Ui::Form widget;
115
116
117 const std::string DEFAULT_SETTINGS_PLUGIN_NAME;
118 const std::string DEFAULT_SETTINGS_CUSTOM_TEXT;
119 QPointer<armarx::SimpleConfigDialog> m_config_dialog;
120 std::string demoStateProxyName;
121 DemoStateManagerInterfacePrx demoStateManagerPrx;
122 std::thread wThread;
123 FlowLayout* layoutNormal;
124 FlowLayout* layoutWarning;
125 FlowLayout* layoutError;
126 FlowLayout* layoutFatal;
127 //std::unordered_set<std::string> buttonText;
128 std::map<QPushButton*, severity::SeverityEnum> buttons;
129 void createButtons();
130 std::string mapColor(severity::SeverityEnum severity);
131 QList<QPushButton*> getButtonsFromLayout(QLayout* layout);
132 void clearLayout(QLayout* layout);
133 void deleteButton(std::string state, armarx::severity::SeverityEnum severity);
134 std::thread checkStateTask;
135 std::atomic_bool stopCheckStateTask{false};
136 QTimer* updateTimer;
137 };
138
139} // namespace armarx
void sendOnlyButtonPressed(QString text="", int severity=-1)
virtual void saveSettings(QSettings *settings)
Implement to save the settings as part of the GUI configuration.
virtual void loadSettings(QSettings *settings)
Implement to load the settings that are part of the GUI configuration.
virtual void onInitComponent()
Pure virtual hook for the subclass.
void stateAndSeverityUpdated(QString state, int severity)
void defaultButtonPressed(std::string state, armarx::severity::SeverityEnum severity)
void insertButtonPressed(QString text="", int severity=-1)
virtual void onDisconnectComponent()
Hook for subclass.
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
virtual void onConnectComponent()
Pure virtual hook for the subclass.
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
void updateStateAndSeverity(QString state, int severity)
This file offers overloads of toIce() and fromIce() functions for STL container types.