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 "gazebo/gui/qt.h"
26 
27 namespace gazebo
28 {
29  namespace gui
30  {
31  class ConfigWidget;
32 
35 
38  class VisualConfigData : public QWidget
39  {
40  Q_OBJECT
41 
43  public slots: void RestoreOriginalData();
44 
47  private slots: void OnToggleItem(bool _checked);
48 
50  public: int id;
51 
53  public: std::string name;
54 
57 
59  public: QWidget *widget;
60 
63  public: msgs::Visual originalDataMsg;
64  };
65 
68  class GZ_GUI_VISIBLE VisualConfig : public QWidget
69  {
70  Q_OBJECT
71 
73  public: VisualConfig();
74 
76  public: ~VisualConfig();
77 
79  public: void Init();
80 
82  public slots: void RestoreOriginalData();
83 
88  public: void AddVisual(const std::string &_name,
89  const msgs::Visual *_visualMsg = NULL);
90 
94  public: void UpdateVisual(const std::string &_name,
95  ConstVisualPtr _visualMsg);
96 
98  public: void Reset();
99 
102  public: unsigned int GetVisualCount() const;
103 
107  public: void SetShowVisual(const bool _show, const std::string &_name);
108 
112  public: msgs::Visual *GetData(const std::string &_name) const;
113 
118  public: void SetGeometry(const std::string &_name,
119  const math::Vector3 &_size, const std::string &_uri = "");
120 
125  public: void Geometry(const std::string &_name,
126  ignition::math::Vector3d &_size, std::string &_uri);
127 
135  public: void SetMaterial(const std::string &_name,
136  const std::string &_materialName,
137  const common::Color &_ambient, const common::Color &_diffuse,
138  const common::Color &_specular, const common::Color &_emissive);
139 
142  public: const std::map<int, VisualConfigData *> &ConfigData() const;
143 
146  Q_SIGNALS: void VisualRemoved(const std::string &_name);
147 
150  Q_SIGNALS: void VisualAdded(const std::string &_name);
151 
155  Q_SIGNALS: void ShowVisual(const bool _show, const std::string &_name);
156 
158  Q_SIGNALS: void Applied();
159 
161  private slots: void OnAddVisual();
162 
165  private slots: void OnRemoveVisual(int _id);
166 
169  private slots: void OnShowVisual(const int _id);
170 
175  private slots: void OnPoseChanged(const QString &_name,
176  const ignition::math::Pose3d &_value);
177 
184  private slots: void OnGeometryChanged(const std::string &_name,
185  const std::string &_value,
186  const ignition::math::Vector3d &_dimensions,
187  const std::string &_uri);
188 
193  private slots: void OnColorChanged(const QString &_name,
194  const gazebo::common::Color &_value);
195 
200  private slots: void OnDoubleChanged(const QString &_name,
201  const double _value);
202 
207  private slots: void OnStringChanged(const QString &_name,
208  const std::string &_value);
209 
211  private: std::map<int, VisualConfigData *> configs;
212 
214  private: std::map<int, VisualConfigData *> deletedConfigs;
215 
217  private: std::map<int, VisualConfigData *> addedConfigs;
218 
220  private: int counter;
221 
223  private: QSignalMapper *mapperRemove;
224 
226  private: QSignalMapper *mapperShow;
227 
229  private: QVBoxLayout *listLayout;
230  };
232  }
233 }
234 #endif
std::string name
Name of the visual.
Definition: VisualConfig.hh:53
int id
Unique ID of this visual config.
Definition: VisualConfig.hh:50
Forward declarations for the common classes.
Definition: Animation.hh:33
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
A class of widgets used for configuring visual properties.
Definition: VisualConfig.hh:38
ConfigWidget * configWidget
Config widget for configuring visual properties.
Definition: VisualConfig.hh:56
A widget generated from a google protobuf message.
Definition: ConfigWidget.hh:147
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:68
msgs::Visual originalDataMsg
Message containing the data which was in the widget when first open.
Definition: VisualConfig.hh:63
QWidget * widget
Widget associated with this data.
Definition: VisualConfig.hh:59
#define NULL
Definition: CommonTypes.hh:31
Defines a color.
Definition: Color.hh:36
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.