VisualConfig.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 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_VISUAL_CONFIG_HH_
19 #define _GAZEBO_VISUAL_CONFIG_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: msgs::Visual *GetData(const std::string &_name) const;
108 
113  public: void SetGeometry(const std::string &_name,
114  const math::Vector3 &_size, const std::string &_uri = "");
115 
120  public: void Geometry(const std::string &_name,
121  ignition::math::Vector3d &_size, std::string &_uri);
122 
130  public: void SetMaterial(const std::string &_name,
131  const std::string &_materialName,
132  const common::Color &_ambient, const common::Color &_diffuse,
133  const common::Color &_specular, const common::Color &_emissive);
134 
137  public: const std::map<int, VisualConfigData *> &ConfigData() const;
138 
141  Q_SIGNALS: void VisualRemoved(const std::string &_name);
142 
145  Q_SIGNALS: void VisualAdded(const std::string &_name);
146 
148  Q_SIGNALS: void Applied();
149 
151  private slots: void OnAddVisual();
152 
155  private slots: void OnRemoveVisual(int _id);
156 
161  private slots: void OnPoseChanged(const QString &_name,
162  const ignition::math::Pose3d &_value);
163 
170  private slots: void OnGeometryChanged(const std::string &_name,
171  const std::string &_value,
172  const ignition::math::Vector3d &_dimensions,
173  const std::string &_uri);
174 
179  private slots: void OnColorChanged(const QString &_name,
180  const gazebo::common::Color &_value);
181 
186  private slots: void OnDoubleChanged(const QString &_name,
187  const double _value);
188 
193  private slots: void OnStringChanged(const QString &_name,
194  const std::string &_value);
195 
197  private: std::map<int, VisualConfigData *> configs;
198 
200  private: int counter;
201 
203  private: QSignalMapper *signalMapper;
204 
206  private: QVBoxLayout *listLayout;
207  };
209  }
210 }
211 #endif
std::string name
Name of the visual.
Definition: VisualConfig.hh:53
int id
Unique ID of this visual config.
Definition: VisualConfig.hh:50
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: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: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.