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 ignition::math::Color &_ambient,
141  const ignition::math::Color &_diffuse,
142  const ignition::math::Color &_specular,
143  const ignition::math::Color &_emissive);
144 
147  public: const std::map<int, VisualConfigData *> &ConfigData() const;
148 
151  Q_SIGNALS: void VisualRemoved(const std::string &_name);
152 
155  Q_SIGNALS: void VisualAdded(const std::string &_name);
156 
160  Q_SIGNALS: void ShowVisual(const bool _show, const std::string &_name);
161 
163  Q_SIGNALS: void Applied();
164 
166  private slots: void OnAddVisual();
167 
170  private slots: void OnRemoveVisual(int _id);
171 
174  private slots: void OnShowVisual(const int _id);
175 
180  private slots: void OnPoseChanged(const QString &_name,
181  const ignition::math::Pose3d &_value);
182 
189  private slots: void OnGeometryChanged(const std::string &_name,
190  const std::string &_value,
191  const ignition::math::Vector3d &_dimensions,
192  const std::string &_uri);
193 
198  private slots: void OnColorChanged(const QString &_name,
199  const ignition::math::Color &_value);
200 
205  private slots: void OnDoubleChanged(const QString &_name,
206  const double _value);
207 
212  private slots: void OnStringChanged(const QString &_name,
213  const std::string &_value);
214 
216  private: std::map<int, VisualConfigData *> configs;
217 
219  private: std::map<int, VisualConfigData *> deletedConfigs;
220 
222  private: std::map<int, VisualConfigData *> addedConfigs;
223 
225  private: int counter;
226 
228  private: QSignalMapper *mapperRemove;
229 
231  private: QSignalMapper *mapperShow;
232 
234  private: QVBoxLayout *listLayout;
235  };
237  }
238 }
239 #endif
std::string name
Name of the visual.
Definition: VisualConfig.hh:56
int id
Unique ID of this visual config.
Definition: VisualConfig.hh:53
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:193
void RestoreOriginalData()
Restore the widget'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
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.