PresenterViewWidgetController.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::PresenterViewWidgetController
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 <atomic>
28 #include <thread>
29 
30 #include <QElapsedTimer>
31 #include <QLabel>
32 #include <QLayout>
33 #include <QMap>
34 #include <QPushButton>
35 #include <QString>
36 #include <QTimer>
37 #include <QVBoxLayout>
38 #include <QWidget>
39 
44 
45 #include <ArmarXGui/gui-plugins/MessageDisplayPlugin/ui_PresenterViewWidget.h>
46 #include <ArmarXGui/interface/DemoStateManagerInterface.h>
50 
51 #include "StatusIndication.h"
52 
53 namespace armarx
54 {
55 
57  public armarx::ArmarXComponentWidgetControllerTemplate<PresenterViewWidgetController>
58 
59  {
60  Q_OBJECT
61 
62  public:
64 
66  {
67  }
68 
69  // inherited from armarx::Component
70  // implement you custom startup, connect and exit code here
71  virtual void onInitComponent();
72  virtual void onConnectComponent();
73  virtual void onDisconnectComponent();
74  virtual void onExitComponent();
75 
76  static QString
78  {
79  return "DemoState.PresenterView";
80  }
81 
82  // You may want to offer GUI save/load functionality.
83  // If not, you can leave these methods empty.
84  virtual void loadSettings(QSettings* settings);
85  virtual void saveSettings(QSettings* settings);
86 
87  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
88 
89  void configured() override;
90 
91 
92  signals:
93 
94 
95  // you may want to specify custom Qt signal methods here
96  // void updateData();
97  void stateAndSeverityUpdated(QString state, int severity);
98 
99 
100  public slots:
101 
102  // you may want to specify custom Qt slots methods here
103  // don't forget to connect them in onConnectComponent()
104  // e.g. connect(ui.myButton, SIGNAL(clicked()), this, SLOT(myButtonPressed()));
105  // void myButtonPressed();
106  void checkState();
107 
108  void updateStateAndSeverity(QString state, int severity);
109 
110  void updateStopwatch();
111 
112  private:
113  // the ui object comes from your Qt-UI widget "ui_MyGuiPluginWidget.h"
114  // PLEASE NOTE: the toplevel widget in this file needs to be named MyGuiPluginWidget
115  // otherwise this line will fail to compile
116  Ui::PresenterViewWidget widget;
117 
118  const std::string DEFAULT_SETTINGS_PLUGIN_NAME;
119  const std::string DEFAULT_SETTINGS_CUSTOM_TEXT;
120  QPointer<armarx::SimpleConfigDialog> m_config_dialog;
121 
122  std::string demoStateManagerName;
123 
124  DemoStateManagerInterfacePrx demoStateManagerPrx;
125 
126  std::thread checkStateTask;
127  std::atomic_bool stopCheckStateTask{false};
128 
129  std::string mapColor(severity::SeverityEnum);
130 
131  QTimer* updateTimer;
132  QElapsedTimer stopwatch;
133  StatusIndicationLabel* statusIndicationLabel;
134  };
135 
136 } // namespace armarx
armarx::PresenterViewWidgetController::onExitComponent
virtual void onExitComponent()
Hook for subclass.
Definition: PresenterViewWidgetController.cpp:203
armarx::PresenterViewWidgetController::checkState
void checkState()
Definition: PresenterViewWidgetController.cpp:120
armarx::PresenterViewWidgetController::saveSettings
virtual void saveSettings(QSettings *settings)
Implement to save the settings as part of the GUI configuration.
Definition: PresenterViewWidgetController.cpp:79
armarx::PresenterViewWidgetController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: PresenterViewWidgetController.cpp:210
armarx::PresenterViewWidgetController::updateStopwatch
void updateStopwatch()
Definition: PresenterViewWidgetController.cpp:164
armarx::PresenterViewWidgetController
Definition: PresenterViewWidgetController.h:56
StatusIndication.h
armarx::PresenterViewWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: PresenterViewWidgetController.cpp:224
armarx::PresenterViewWidgetController::updateStateAndSeverity
void updateStateAndSeverity(QString state, int severity)
Definition: PresenterViewWidgetController.cpp:146
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
armarx::PresenterViewWidgetController::onDisconnectComponent
virtual void onDisconnectComponent()
Hook for subclass.
Definition: PresenterViewWidgetController.cpp:196
ArmarXGuiPlugin.h
armarx::PresenterViewWidgetController::loadSettings
virtual void loadSettings(QSettings *settings)
Implement to load the settings that are part of the GUI configuration.
Definition: PresenterViewWidgetController.cpp:67
armarx::PresenterViewWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: PresenterViewWidgetController.h:77
LocalTimeServer.h
ArmarXComponentWidgetController.h
armarx::PresenterViewWidgetController::onConnectComponent
virtual void onConnectComponent()
Pure virtual hook for the subclass.
Definition: PresenterViewWidgetController.cpp:102
stopwatch
Definition: Stopwatch.cpp:3
armarx::PresenterViewWidgetController::PresenterViewWidgetController
PresenterViewWidgetController()
Definition: PresenterViewWidgetController.cpp:42
Metronome.h
armarx::PresenterViewWidgetController::stateAndSeverityUpdated
void stateAndSeverityUpdated(QString state, int severity)
TimeUtil.h
armarx::PresenterViewWidgetController::~PresenterViewWidgetController
virtual ~PresenterViewWidgetController()
Definition: PresenterViewWidgetController.h:65
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
ImportExportComponent.h
armarx::PresenterViewWidgetController::onInitComponent
virtual void onInitComponent()
Pure virtual hook for the subclass.
Definition: PresenterViewWidgetController.cpp:88