WidgetController.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::WidgetController
19  * @author Philipp Schmidt ( ufedv at student dot kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 #include <mutex>
28 
29 // QT
30 #include <QListWidgetItem>
31 #include <QColorDialog>
32 
33 // Point Cloud Library
34 #include <pcl/point_types.h>
35 #include <pcl/visualization/pcl_visualizer.h>
36 
37 // ArmarX
38 #include <Ice/BuiltinSequences.h>
43 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
44 
45 // Point Cloud Processor
47 
48 // User interface
49 #include <VisionX/gui-plugins/PointCloudViewer/ui_Widget.h>
50 
51 #include "Manager.h"
52 #include "SaveDialog.h"
53 
54 
55 /* NOTES for developers:
56  *
57  * The code has two invariancies:
58  *
59  * 1.: The topic and proxies of a provider are used, exactly if it is listed in the list widget "providerList".
60  * 2.: If a provider is checked in the list widget "providerList" it has an entry in the manager
61  * and is shown in the viewer with the next render call renderClouds() with its ID.
62  */
63 
64 
65 namespace visionx
66 {
67  /**
68  \page VisionX-GuiPlugins-PointCloudViewer PointCloudViewer
69  \brief ...
70 
71  API Documentation \ref WidgetController
72 
73  \see GuiPlugin
74  */
75 
76  /**
77  * \class WidgetController
78  * \brief WidgetController brief one line description
79  *
80  * Detailed description
81  */
84  public armarx::ArmarXComponentWidgetControllerTemplate<WidgetController>,
85  public PointCloudProcessor
86  {
87  Q_OBJECT
88 
89  using PointT = pcl::PointXYZRGBL;
90 
91  public:
92 
93  /// Controller constructor.
94  explicit WidgetController();
95 
96  /// Controller destructor
97  ~WidgetController() override;
98 
99  /// @see ArmarXWidgetController::loadSettings()
100  void loadSettings(QSettings* settings) override;
101 
102  /// @see ArmarXWidgetController::saveSettings()
103  void saveSettings(QSettings* settings) override;
104 
105  /// Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
106  static QString GetWidgetName()
107  {
108  return "VisionX.PointCloudViewer";
109  }
110 
111  /// @see visionx::PointCloudProcessor::onInitPointCloudProcessor()
112  void onInitPointCloudProcessor() override;
113 
114  /// @see visionx::PointCloudProcessor::onConnectPointCloudProcessor()
115  ///
116  void onConnectPointCloudProcessor() override;
117  /// @see visionx::PointCloudProcessor::onDisconnectPointCloudProcessor()
118  void onDisconnectPointCloudProcessor() override;
119 
120  /// @see visionx::PointCloudProcessor::onExitPointCloudProcessor()
121  void onExitPointCloudProcessor() override;
122 
123 
124  /// @see visionx::PointCloudProcessor::process()
125  void process() override;
126 
127  void postDocking() override;
128 
129  void onLockWidget() override;
130  void onUnlockWidget() override;
131 
132  signals:
133 
134  void newPointCloudReceived(QString providerName, CoinPointCloud* cloud);
135 
136 
137  public slots:
138 
139  void refreshProviderList();
140  void showPointCloudInfo(QListWidgetItem* item);
141  void pointCloudChecked(QListWidgetItem* item);
142  void selectColor();
143  void savePointCloud();
144  void processPointCloud(QString providerName, CoinPointCloud* cloud);
145 
146 
147  void updateProviderList(IceGrid::ObjectInfoSeq objects);
148 
149 
150  private slots:
151 
152  void setPointSize(double value);
153  void disconnectQt();
154 
155 
156  private:
157 
158  template <class PointCloudT>
159  void getPointCloudAs(const std::string& providerName, PointCloudT& targetPointCloud);
160  template <class PointCloudT>
161  static void storePointCloudAs(const std::string& filename, const PointCloudT& pointCloud);
162 
163  private:
164 
165  QPointer<QWidget> m_widget;
166 
167  /// Widget Form
168  Ui::Widget widget;
169 
170  /// Cloud Manager
171  Manager* manager;
172 
173  /// Color dialog
174  QColorDialog colorDialog;
175 
176  /// Camera reset flag
177  bool recenterCamera;
178 
179  std::mutex mutex;
180 
181  std::atomic<float> pointSize {1};
182  };
183 }
184 
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
Manager.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
ArmarXGuiPlugin.h
visionx::Manager
Definition: Manager.h:37
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
visionx::PointCloudProcessor
The PointCloudProcessor class provides an interface for access to PointCloudProviders via Ice and sha...
Definition: PointCloudProcessor.h:186
filename
std::string filename
Definition: VisualizationRobot.cpp:84
armarx::PointCloudT
pcl::PointCloud< PointT > PointCloudT
Definition: Common.h:30
PointCloudProcessor.h
visionx::CoinPointCloud
Definition: CoinPointCloud.h:39
SaveDialog.h
visionx::WidgetController::GetWidgetName
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Definition: WidgetController.h:106
CoinViewer.h
visionx::WidgetController
WidgetController brief one line description.
Definition: WidgetController.h:82
ImportExportComponent.h