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 <QColorDialog>
31 #include <QListWidgetItem>
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>
39 
41 
45 
46 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
47 
48 // Point Cloud Processor
50 
51 // User interface
52 #include <VisionX/gui-plugins/PointCloudViewer/ui_Widget.h>
53 
54 #include "Manager.h"
55 #include "SaveDialog.h"
56 
57 /* NOTES for developers:
58  *
59  * The code has two invariancies:
60  *
61  * 1.: The topic and proxies of a provider are used, exactly if it is listed in the list widget "providerList".
62  * 2.: If a provider is checked in the list widget "providerList" it has an entry in the manager
63  * and is shown in the viewer with the next render call renderClouds() with its ID.
64  */
65 
66 
67 namespace visionx
68 {
69  /**
70  \page VisionX-GuiPlugins-PointCloudViewer PointCloudViewer
71  \brief ...
72 
73  API Documentation \ref WidgetController
74 
75  \see GuiPlugin
76  */
77 
78  /**
79  * \class WidgetController
80  * \brief WidgetController brief one line description
81  *
82  * Detailed description
83  */
85  public armarx::ArmarXComponentWidgetControllerTemplate<WidgetController>,
86  public PointCloudProcessor
87  {
88  Q_OBJECT
89 
90  using PointT = pcl::PointXYZRGBL;
91 
92  public:
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
108  {
109  return "VisionX.PointCloudViewer";
110  }
111 
112  /// @see visionx::PointCloudProcessor::onInitPointCloudProcessor()
113  void onInitPointCloudProcessor() override;
114 
115  /// @see visionx::PointCloudProcessor::onConnectPointCloudProcessor()
116  ///
117  void onConnectPointCloudProcessor() override;
118  /// @see visionx::PointCloudProcessor::onDisconnectPointCloudProcessor()
119  void onDisconnectPointCloudProcessor() override;
120 
121  /// @see visionx::PointCloudProcessor::onExitPointCloudProcessor()
122  void onExitPointCloudProcessor() override;
123 
124 
125  /// @see visionx::PointCloudProcessor::process()
126  void process() override;
127 
128  void postDocking() override;
129 
130  void onLockWidget() override;
131  void onUnlockWidget() override;
132 
133  signals:
134 
135  void newPointCloudReceived(QString providerName, CoinPointCloud* cloud);
136 
137 
138  public slots:
139 
140  void refreshProviderList();
141  void showPointCloudInfo(QListWidgetItem* item);
142  void pointCloudChecked(QListWidgetItem* item);
143  void selectColor();
144  void savePointCloud();
145  void processPointCloud(QString providerName, CoinPointCloud* cloud);
146 
147 
148  void updateProviderList(IceGrid::ObjectInfoSeq objects);
149 
150 
151  private slots:
152 
153  void setPointSize(double value);
154  void disconnectQt();
155 
156 
157  private:
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  QPointer<QWidget> m_widget;
165 
166  /// Widget Form
167  Ui::Widget widget;
168 
169  /// Cloud Manager
170  Manager* manager;
171 
172  /// Color dialog
173  QColorDialog colorDialog;
174 
175  /// Camera reset flag
176  bool recenterCamera;
177 
178  std::mutex mutex;
179 
180  std::atomic<float> pointSize{1};
181  };
182 } // namespace visionx
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
Manager.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
ArmarXGuiPlugin.h
visionx::Manager
Definition: Manager.h:34
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
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:177
filename
std::string filename
Definition: VisualizationRobot.cpp:86
armarx::PointCloudT
pcl::PointCloud< PointT > PointCloudT
Definition: Common.h:32
PointCloudProcessor.h
visionx::CoinPointCloud
Definition: CoinPointCloud.h:38
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:107
CoinViewer.h
visionx::WidgetController
WidgetController brief one line description.
Definition: WidgetController.h:84
ImportExportComponent.h