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_OperatorViewWidget.h>
43 #include <ArmarXGui/interface/DemoStateManagerInterface.h>
47 
48 namespace armarx
49 {
50 
52  public armarx::ArmarXComponentWidgetControllerTemplate<OperatorViewWidgetController>
53 
54  {
55  Q_OBJECT
56 
57  public:
59 
61  {
62  }
63 
64  // inherited from armarx::Component
65  // implement you custom startup, connect and exit code here
66  virtual void onInitComponent();
67  virtual void onConnectComponent();
68  virtual void onDisconnectComponent();
69  virtual void onExitComponent();
70 
71  static QString
73  {
74  return "DemoState.OperatorView";
75  }
76 
77  // You may want to offer GUI save/load functionality.
78  // If not, you can leave these methods empty.
79  virtual void loadSettings(QSettings* settings);
80  virtual void saveSettings(QSettings* settings);
81 
82  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
83 
84  void configured() override;
85 
86 
87  signals:
88  void defaultValuesLoaded();
89  void disconnectComponent();
90 
91 
92  public slots:
93 
94  // you may want to specify custom Qt slots methods here
95  // don't forget to connect them in onConnectComponent()
96  // e.g. connect(ui.myButton, SIGNAL(clicked()), this, SLOT(myButtonPressed()));
97  // void myButtonPressed();
98  void clearButtonPressed();
100  void insertButtonPressed(QString text = "", int severity = -1);
101  void sendOnlyButtonPressed(QString text = "", int severity = -1);
102  void createButtonLayout();
103  void defaultButtonPressed(std::string state, armarx::severity::SeverityEnum severity);
105  void cleanUI();
106 
107  private:
108  // the ui object comes from your Qt-UI widget "ui_MyGuiPluginWidget.h"
109  // PLEASE NOTE: the toplevel widget in this file needs to be named MyGuiPluginWidget
110  // otherwise this line will fail to compile
111  Ui::OperatorViewWidget widget;
112 
113 
114  const std::string DEFAULT_SETTINGS_PLUGIN_NAME;
115  const std::string DEFAULT_SETTINGS_CUSTOM_TEXT;
116  QPointer<armarx::SimpleConfigDialog> m_config_dialog;
117  std::string demoStateManagerName;
118  DemoStateManagerInterfacePrx demoStateManagerPrx;
119  std::thread wThread;
120  std::string defaultStateValues;
121  QHBoxLayout* layoutNormal;
122  QHBoxLayout* layoutWarning;
123  QHBoxLayout* layoutError;
124  QHBoxLayout* layoutFatal;
125  std::unordered_set<std::string> buttonText;
126  std::map<QPushButton*, severity::SeverityEnum> buttons;
127  void createButtons(const QString& input);
128  std::string mapColor(severity::SeverityEnum severity);
129  QList<QPushButton*> getButtonsFromLayout(QLayout* layout);
130  void clearLayout(QLayout* layout);
131  };
132 
133 } // namespace armarx
armarx::OperatorViewWidgetController::~OperatorViewWidgetController
virtual ~OperatorViewWidgetController()
Definition: OperatorViewWidgetController.h:60
armarx::OperatorViewWidgetController::insertButtonPressed
void insertButtonPressed(QString text="", int severity=-1)
Definition: OperatorViewWidgetController.cpp:177
armarx::OperatorViewWidgetController::createButtonLayout
void createButtonLayout()
Definition: OperatorViewWidgetController.cpp:124
armarx::OperatorViewWidgetController::onInitComponent
virtual void onInitComponent()
Pure virtual hook for the subclass.
Definition: OperatorViewWidgetController.cpp:77
armarx::OperatorViewWidgetController::saveSettings
virtual void saveSettings(QSettings *settings)
Implement to save the settings as part of the GUI configuration.
Definition: OperatorViewWidgetController.cpp:68
armarx::OperatorViewWidgetController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: OperatorViewWidgetController.cpp:451
armarx::OperatorViewWidgetController::loadSettings
virtual void loadSettings(QSettings *settings)
Implement to load the settings that are part of the GUI configuration.
Definition: OperatorViewWidgetController.cpp:56
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
armarx::OperatorViewWidgetController::cleanUI
void cleanUI()
Definition: OperatorViewWidgetController.cpp:384
armarx::OperatorViewWidgetController::defaultValuesLoaded
void defaultValuesLoaded()
armarx::OperatorViewWidgetController::insertAndSendButtonPressed
void insertAndSendButtonPressed()
Definition: OperatorViewWidgetController.cpp:168
ArmarXGuiPlugin.h
armarx::OperatorViewWidgetController::onConnectComponent
virtual void onConnectComponent()
Pure virtual hook for the subclass.
Definition: OperatorViewWidgetController.cpp:88
ArmarXComponentWidgetController.h
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:12
armarx::OperatorViewWidgetController::exportButtonsToPropertyFormat
void exportButtonsToPropertyFormat()
Definition: OperatorViewWidgetController.cpp:312
armarx::OperatorViewWidgetController::disconnectComponent
void disconnectComponent()
armarx::OperatorViewWidgetController::onExitComponent
virtual void onExitComponent()
Hook for subclass.
Definition: OperatorViewWidgetController.cpp:445
armarx::OperatorViewWidgetController::clearButtonPressed
void clearButtonPressed()
Definition: OperatorViewWidgetController.cpp:154
armarx::OperatorViewWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: OperatorViewWidgetController.cpp:465
armarx::OperatorViewWidgetController
Definition: OperatorViewWidgetController.h:51
armarx::OperatorViewWidgetController::OperatorViewWidgetController
OperatorViewWidgetController()
Definition: OperatorViewWidgetController.cpp:44
armarx::OperatorViewWidgetController::sendOnlyButtonPressed
void sendOnlyButtonPressed(QString text="", int severity=-1)
Definition: OperatorViewWidgetController.cpp:228
armarx::OperatorViewWidgetController::onDisconnectComponent
virtual void onDisconnectComponent()
Hook for subclass.
Definition: OperatorViewWidgetController.cpp:437
armarx::OperatorViewWidgetController::defaultButtonPressed
void defaultButtonPressed(std::string state, armarx::severity::SeverityEnum severity)
Definition: OperatorViewWidgetController.cpp:298
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::OperatorViewWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: OperatorViewWidgetController.h:72
ImportExportComponent.h