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 _VISUAL_CONFIG_HH_
19 #define _VISUAL_CONFIG_HH_
20 
21 #include <map>
22 #include <string>
23 
24 #include "gazebo/math/Pose.hh"
25 
26 #include "gazebo/gui/qt.h"
28 
29 namespace gazebo
30 {
31  namespace gui
32  {
33  class ConfigWidget;
34 
37 
40  class VisualConfigData : public QWidget
41  {
42  Q_OBJECT
43 
46  private slots: void OnToggleItem(bool _checked);
47 
49  public: int id;
50 
52  public: std::string name;
53 
56 
58  public: QWidget *widget;
59  };
60 
63  class VisualConfig : public QWidget
64  {
65  Q_OBJECT
66 
68  public: VisualConfig();
69 
71  public: ~VisualConfig();
72 
77  public: void AddVisual(const std::string &_name,
78  const msgs::Visual *_visualMsg = NULL);
79 
83  public: void UpdateVisual(const std::string &_name,
84  ConstVisualPtr _visualMsg);
85 
87  public: void Reset();
88 
91  public: unsigned int GetVisualCount() const;
92 
96  public: msgs::Visual *GetData(const std::string &_name) const;
97 
102  public: void SetGeometry(const std::string &_name,
103  const math::Vector3 &_size, const std::string &_uri = "");
104 
112  public: void SetMaterial(const std::string &_name,
113  const std::string &_materialName,
114  const common::Color &_ambient, const common::Color &_diffuse,
115  const common::Color &_specular, const common::Color &_emissive);
116 
119  Q_SIGNALS: void VisualRemoved(const std::string &_name);
120 
123  Q_SIGNALS: void VisualAdded(const std::string &_name);
124 
126  private slots: void OnAddVisual();
127 
130  private slots: void OnRemoveVisual(int _id);
131 
133  private: std::map<int, VisualConfigData *> configs;
134 
136  private: int counter;
137 
139  private: QSignalMapper *signalMapper;
140 
142  private: QVBoxLayout *listLayout;
143  };
145  }
146 }
147 #endif
msgs::Visual * GetData(const std::string &_name) const
Get the msg containing all visual data.
void VisualAdded(const std::string &_name)
Qt signal emitted when a visual is added.
int id
Unique ID of this visual config.
Definition: VisualConfig.hh:49
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:40
A widget generated from a google protobuf message.
Definition: ConfigWidget.hh:139
VisualConfig()
Constructor.
unsigned int GetVisualCount() const
Get the number of visuals.
A tab for configuring visual properties of a link.
Definition: VisualConfig.hh:63
std::string name
Name of the visual.
Definition: VisualConfig.hh:52
void SetMaterial(const std::string &_name, const std::string &_materialName, const common::Color &_ambient, const common::Color &_diffuse, const common::Color &_specular, const common::Color &_emissive)
Set the material of a visual.
ConfigWidget * configWidget
Config widget for configuring visual properties.
Definition: VisualConfig.hh:55
void VisualRemoved(const std::string &_name)
Qt signal emitted when a visual is removed.
void Reset()
Reset the visual tab.
QWidget * widget
Widget associated with this data.
Definition: VisualConfig.hh:58
~VisualConfig()
Destructor.
void AddVisual(const std::string &_name, const msgs::Visual *_visualMsg=NULL)
Add a visual widget to the tab.
#define NULL
Definition: CommonTypes.hh:30
Defines a color.
Definition: Color.hh:36
void UpdateVisual(const std::string &_name, ConstVisualPtr _visualMsg)
Update a visual widget from a visual msg.
void SetGeometry(const std::string &_name, const math::Vector3 &_size, const std::string &_uri="")
Set the geometry data of a visual.