VisualConfig.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GAZEBO_GUI_MODEL_VISUALCONFIG_HH_
19 #define GAZEBO_GUI_MODEL_VISUALCONFIG_HH_
20 
21 #include <map>
22 #include <string>
23 
24 #include <ignition/math/Pose3.hh>
25 #include <ignition/math/Vector3.hh>
26 
27 #include "gazebo/gui/qt.h"
29 
30 namespace gazebo
31 {
32  namespace gui
33  {
34  class ConfigWidget;
35 
38 
41  class VisualConfigData : public QWidget
42  {
43  Q_OBJECT
44 
46  public slots: void RestoreOriginalData();
47 
50  private slots: void OnToggleItem(bool _checked);
51 
53  public: int id;
54 
56  public: std::string name;
57 
60 
62  public: QWidget *widget;
63 
66  public: msgs::Visual originalDataMsg;
67  };
68 
71  class GZ_GUI_VISIBLE VisualConfig : public QWidget
72  {
73  Q_OBJECT
74 
76  public: VisualConfig();
77 
79  public: ~VisualConfig();
80 
82  public: void Init();
83 
85  public slots: void RestoreOriginalData();
86 
91  public: void AddVisual(const std::string &_name,
92  const msgs::Visual *_visualMsg = NULL);
93 
97  public: void UpdateVisual(const std::string &_name,
98  ConstVisualPtr _visualMsg);
99 
101  public: void Reset();
102 
105  public: unsigned int GetVisualCount() const;
106 
110  public: void SetShowVisual(const bool _show, const std::string &_name);
111 
115  public: msgs::Visual *GetData(const std::string &_name) const;
116 
121  public: void SetGeometry(const std::string &_name,
122  const ignition::math::Vector3d &_size, const std::string &_uri = "");
123 
128  public: void Geometry(const std::string &_name,
129  ignition::math::Vector3d &_size, std::string &_uri);
130 
138  public: void SetMaterial(const std::string &_name,
139  const std::string &_materialName,
140  const common::Color &_ambient, const common::Color &_diffuse,
141  const common::Color &_specular, const common::Color &_emissive);
142 
145  public: const std::map<int, VisualConfigData *> &ConfigData() const;
146 
149  Q_SIGNALS: void VisualRemoved(const std::string &_name);
150 
153  Q_SIGNALS: void VisualAdded(const std::string &_name);
154 
158  Q_SIGNALS: void ShowVisual(const bool _show, const std::string &_name);
159 
161  Q_SIGNALS: void Applied();
162 
164  private slots: void OnAddVisual();
165 
168  private slots: void OnRemoveVisual(int _id);
169 
172  private slots: void OnShowVisual(const int _id);
173 
178  private slots: void OnPoseChanged(const QString &_name,
179  const ignition::math::Pose3d &_value);
180 
187  private slots: void OnGeometryChanged(const std::string &_name,
188  const std::string &_value,
189  const ignition::math::Vector3d &_dimensions,
190  const std::string &_uri);
191 
196  private slots: void OnColorChanged(const QString &_name,
197  const gazebo::common::Color &_value);
198 
203  private slots: void OnDoubleChanged(const QString &_name,
204  const double _value);
205 
210  private slots: void OnStringChanged(const QString &_name,
211  const std::string &_value);
212 
214  private: std::map<int, VisualConfigData *> configs;
215 
217  private: std::map<int, VisualConfigData *> deletedConfigs;
218 
220  private: std::map<int, VisualConfigData *> addedConfigs;
221 
223  private: int counter;
224 
226  private: QSignalMapper *mapperRemove;
227 
229  private: QSignalMapper *mapperShow;
230 
232  private: QVBoxLayout *listLayout;
233  };
235  }
236 }
237 #endif
std::string name
Name of the visual.
Definition: VisualConfig.hh:56
int id
Unique ID of this visual config.
Definition: VisualConfig.hh:53
Forward declarations for the common classes.
Definition: Animation.hh:33
A class of widgets used for configuring visual properties.
Definition: VisualConfig.hh:41
ConfigWidget * configWidget
Config widget for configuring visual properties.
Definition: VisualConfig.hh:59
A widget generated from a google protobuf message.
Definition: ConfigWidget.hh:192
void RestoreOriginalData()
Restore the widget&#39;s data to how it was when first opened.
A tab for configuring visual properties of a link.
Definition: VisualConfig.hh:71
msgs::Visual originalDataMsg
Message containing the data which was in the widget when first open.
Definition: VisualConfig.hh:66
QWidget * widget
Widget associated with this data.
Definition: VisualConfig.hh:62
#define NULL
Definition: CommonTypes.hh:31
Defines a color.
Definition: Color.hh:35
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.