ImageProviderConfigWidget.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 VisionX::gui-plugins::ImageRecorder
19  * @author Christian R. G. Dreher <c.dreher@kit.edu>
20  * @date 2020
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #pragma once
27 
28 
29 // STD/STL
30 #include <optional>
31 #include <string>
32 
33 // Qt
34 #include <QPointer>
35 #include <QTimer>
36 #include <QWidget>
37 
38 // ArmarX
41 #include <VisionX/gui-plugins/ImageRecorder/ui_ImageProviderConfigWidget.h>
42 #include <VisionX/interface/core/ImageProviderInterface.h>
44 
45 
46 namespace visionx
47 {
48 
49  class ChannelConfigWidget;
50  class ImageRecorderWidgetController;
51 
52  enum class ViewMode
53  {
54  Full,
56  };
57 
58  class ImageProviderConfigWidget : public QWidget
59  {
60 
61  Q_OBJECT
62 
63  private:
64 
65  Ui::image_provider_config_widget m_widget;
66  QPointer<armarx::IceProxyFinder<RecordingImageProviderInterfacePrx>> m_ice_proxy_finder;
67  QPointer<QTimer> m_blink_timer;
68  armarx::IceManagerPtr m_iceman;
69  std::string m_image_provider_name;
70  std::vector<ChannelConfigWidget*> m_channel_config_widgets;
71  bool m_icon_blink = false;
72  std::string m_current_icon_name;
73  std::optional<imrec::State> m_current_state;
74  imrec::Status m_current_status;
75 
76  public:
77 
78  ImageProviderConfigWidget(QWidget* parent, armarx::IceManagerPtr iceman, const std::string& image_provider_name, const visionx::imrec::ChannelConfigs& channel_configs);
79 
81 
82  void confirmImageProviderName(const std::string& new_name);
83 
84  void rejectImageProviderName(const std::string& new_name);
85 
86  std::vector<visionx::imrec::ChannelConfig> toChannelConfigs() const;
87 
88  void setImageProviderStatus(std::optional<visionx::imrec::Status> status);
89 
90  void setViewMode(ViewMode viewMode);
91 
92  private:
93 
94  void build_ui_from_configs(const std::vector<imrec::ChannelConfig>& configs, const std::vector<imrec::ChannelPreferences>& prefs_list);
95 
96  void add_channel_conf_widget(const imrec::ChannelConfig& channel_config, const imrec::ChannelPreferences& channel_prefs);
97 
98  void update_channel_list();
99 
100  std::vector<imrec::ChannelPreferences> get_channel_prefs();
101 
102  bool is_channel_name_unique(const std::string& name);
103 
104  signals:
105 
106  void imageProviderRenamed(const std::string& old_name, const std::string& new_name);
107 
108  void imageProviderRemoved(const std::string& name);
109 
110  void imageProviderStateChanged(std::optional<imrec::State> old_state, std::optional<imrec::State> new_state);
111 
112  private slots:
113 
114  void state_changed(std::optional<imrec::State> old_state, std::optional<imrec::State> new_state);
115 
116  void blink();
117 
118  void channel_renamed(const std::string& old_name, const std::string& new_name);
119 
120  void image_provider_renamed(const QString& name);
121 
122  void image_provider_removed();
123 
124  };
125 
126 }
visionx::ImageProviderConfigWidget::imageProviderStateChanged
void imageProviderStateChanged(std::optional< imrec::State > old_state, std::optional< imrec::State > new_state)
visionx::ImageProviderConfigWidget::toChannelConfigs
std::vector< visionx::imrec::ChannelConfig > toChannelConfigs() const
Definition: ImageProviderConfigWidget.cpp:141
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ImageProviderConfigWidget::rejectImageProviderName
void rejectImageProviderName(const std::string &new_name)
Definition: ImageProviderConfigWidget.cpp:133
visionx::ImageProviderConfigWidget::setViewMode
void setViewMode(ViewMode viewMode)
Definition: ImageProviderConfigWidget.cpp:201
visionx::ImageProviderConfigWidget::setImageProviderStatus
void setImageProviderStatus(std::optional< visionx::imrec::Status > status)
Definition: ImageProviderConfigWidget.cpp:155
armarx::status
status
Definition: FiniteStateMachine.h:259
imrec.h
visionx::ViewMode::StatusOnly
@ StatusOnly
IceProxyFinder.h
visionx::ImageProviderConfigWidget::imageProviderRemoved
void imageProviderRemoved(const std::string &name)
IceManager.h
visionx::ViewMode::Full
@ Full
visionx::ImageProviderConfigWidget::imageProviderRenamed
void imageProviderRenamed(const std::string &old_name, const std::string &new_name)
visionx::ImageProviderConfigWidget
Definition: ImageProviderConfigWidget.h:58
IceUtil::Handle< IceManager >
visionx::ImageProviderConfigWidget::confirmImageProviderName
void confirmImageProviderName(const std::string &new_name)
Definition: ImageProviderConfigWidget.cpp:123
visionx::ImageProviderConfigWidget::ImageProviderConfigWidget
ImageProviderConfigWidget(QWidget *parent, armarx::IceManagerPtr iceman, const std::string &image_provider_name, const visionx::imrec::ChannelConfigs &channel_configs)
Definition: ImageProviderConfigWidget.cpp:63
visionx::ImageProviderConfigWidget::~ImageProviderConfigWidget
virtual ~ImageProviderConfigWidget()
Definition: ImageProviderConfigWidget.cpp:116
visionx::ViewMode
ViewMode
Definition: ImageProviderConfigWidget.h:52