ImageRecorderWidgetController.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package VisionX::gui-plugins::ImageRecorder
17  * @author Christian R. G. Dreher <c.dreher@kit.edu>
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 
24 #pragma once
25 
26 
27 // STD/STL
28 
29 
30 // Qt
31 #include <QDialog>
32 #include <QPointer>
33 #include <QString>
34 #include <QTimer>
35 
36 // ArmarX
40 #include <VisionX/components/ImageRecordingManager/ImageRecordingManagerInterface.h>
41 #include <VisionX/gui-plugins/ImageRecorder/ui_ImageRecorderWidget.h>
43 
44 
45 namespace visionx
46 {
47 
48  class ImageProviderConfigWidget;
49 
51  public armarx::ArmarXComponentWidgetControllerTemplate<ImageRecorderWidgetController>
52  {
53 
54  Q_OBJECT
55 
56  private:
57 
58  QPointer<QTimer> m_poll_timer;
59 
60  QPointer<armarx::SimpleConfigDialog> m_config_dialog;
61 
62  Ui::image_recorder_widget m_widget;
63 
64  std::string m_imrecman_name;
65 
66  ImageRecordingManagerInterfacePrx m_imrecman;
67 
68  std::map<std::string, ImageProviderConfigWidget*> m_config_widgets;
69 
70  unsigned int m_image_provider_ctr = 0;
71 
72  public:
73 
75 
76  void onInitComponent() override;
77 
78  void onConnectComponent() override;
79 
80  void onDisconnectComponent() override;
81 
82  void onExitComponent() override;
83 
84  static QString GetWidgetName()
85  {
86  return "VisionX.ImageRecorder";
87  }
88 
89  static QIcon GetWidgetIcon()
90  {
91  return QIcon {"://icons/image_recorder.svg"};
92  }
93 
94  static QIcon GetWidgetCategoryIcon()
95  {
96  return QIcon {"://icons/eye.svg"};
97  }
98 
99  void loadSettings(QSettings* settings) override;
100 
101  void saveSettings(QSettings* settings) override;
102 
103  QPointer<QDialog> getConfigDialog(QWidget* parent) override;
104 
105  void configured() override;
106 
107  //QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent) override;
108 
109  void build_ui_from_config(const std::map<std::string, imrec::Config>& configs);
110 
111  void update_statuses(const std::map<std::string, visionx::imrec::Status>& statuses);
112 
113  void add_image_provider_conf_widget(const std::string& image_provider_name, const imrec::Config& config);
114 
115  std::map<std::string, imrec::Config> to_config_map();
116 
117  signals:
118 
119  void component_connected();
120 
121  void component_disconnected();
122 
123  private slots:
124 
125  void init_gui();
126 
127  void uninit_gui();
128 
129  void poll_statuses();
130 
131  void get_config_from_imrecman();
132 
133  void set_config_at_imrecman();
134 
135  void add_image_provider();
136 
137  void remove_image_provider(const std::string& name);
138 
139  void copy_config_json_to_clipboard();
140 
141  void update_start_rec_label();
142 
143  void start_recordings();
144 
145  void stop_recordings();
146 
147  void edit_mode_changed(int state);
148 
149  void rename_image_provider(const std::string& old_name, const std::string& new_name);
150 
151  };
152 }
visionx::ImageRecorderWidgetController::add_image_provider_conf_widget
void add_image_provider_conf_widget(const std::string &image_provider_name, const imrec::Config &config)
Definition: ImageRecorderWidgetController.cpp:218
visionx::ImageRecorderWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: ImageRecorderWidgetController.cpp:77
visionx::ImageRecorderWidgetController::to_config_map
std::map< std::string, imrec::Config > to_config_map()
Definition: ImageRecorderWidgetController.cpp:238
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ImageRecorderWidgetController::component_connected
void component_connected()
visionx::ImageRecorderWidgetController
Definition: ImageRecorderWidgetController.h:50
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
SimpleConfigDialog.h
visionx::ImageRecorderWidgetController::update_statuses
void update_statuses(const std::map< std::string, visionx::imrec::Status > &statuses)
Definition: ImageRecorderWidgetController.cpp:191
ArmarXGuiPlugin.h
visionx::ImageRecorderWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: ImageRecorderWidgetController.cpp:89
ArmarXComponentWidgetController.h
visionx::ImageRecorderWidgetController::build_ui_from_config
void build_ui_from_config(const std::map< std::string, imrec::Config > &configs)
Definition: ImageRecorderWidgetController.cpp:164
visionx::ImageRecorderWidgetController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: ImageRecorderWidgetController.cpp:138
visionx::ImageRecorderWidgetController::ImageRecorderWidgetController
ImageRecorderWidgetController()
Definition: ImageRecorderWidgetController.cpp:46
visionx::ImageRecorderWidgetController::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: ImageRecorderWidgetController.h:89
visionx::ImageRecorderWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: ImageRecorderWidgetController.cpp:118
visionx::ImageRecorderWidgetController::component_disconnected
void component_disconnected()
visionx::ImageRecorderWidgetController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: ImageRecorderWidgetController.cpp:152
visionx::ImageRecorderWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: ImageRecorderWidgetController.cpp:128
ImageProviderConfigWidget.h
visionx::ImageRecorderWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: ImageRecorderWidgetController.h:84
visionx::ImageRecorderWidgetController::GetWidgetCategoryIcon
static QIcon GetWidgetCategoryIcon()
Definition: ImageRecorderWidgetController.h:94
visionx::ImageRecorderWidgetController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: ImageRecorderWidgetController.cpp:109
visionx::ImageRecorderWidgetController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: ImageRecorderWidgetController.cpp:100