All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
JointMaker.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2013 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 _JOINTMAKER_HH_
19 #define _JOINTMAKER_HH_
20 
21 #include <string>
22 #include <vector>
23 #include <boost/unordered/unordered_map.hpp>
24 
25 #include <sdf/sdf.hh>
26 
29 #include "gazebo/math/Vector3.hh"
31 #include "gazebo/gui/qt.h"
32 #include "gazebo/util/system.hh"
33 
34 namespace gazebo
35 {
36  namespace gui
37  {
38  class JointData;
39  class JointInspector;
40 
43 
46  class GAZEBO_VISIBLE JointMaker : public QObject
47  {
48  Q_OBJECT
49 
52  public: enum JointType
53  {
69  JOINT_BALL
70  };
71 
73  public: JointMaker();
74 
76  public: virtual ~JointMaker();
77 
79  public: void Reset();
80 
83  public: void CreateJoint(JointType _type);
84 
86  public: void Update();
87 
90  public: void RemoveJoint(const std::string &_jointName);
91 
94  public: void RemoveJointsByPart(const std::string &_partName);
95 
97  public: void GenerateSDF();
98 
100  public: sdf::ElementPtr GetSDF() const;
101 
104  public: static int GetJointAxisCount(JointMaker::JointType _type);
105 
109  public: static std::string GetTypeAsString(JointMaker::JointType _type);
110 
114  public: JointMaker::JointType GetState() const;
115 
117  public: void Stop();
118 
122  private: bool OnMousePress(const common::MouseEvent &_event);
123 
127  private: bool OnMouseRelease(const common::MouseEvent &_event);
128 
132  private: bool OnMouseMove(const common::MouseEvent &_event);
133 
137  private: bool OnMouseDoubleClick(const common::MouseEvent &_event);
138 
140  private: void CreateHotSpot();
141 
144  private: void OpenInspector(const std::string &_name);
145 
147  Q_SIGNALS: void JointAdded();
148 
150  private slots: void OnOpenInspector();
151 
153  private: JointMaker::JointType jointType;
154 
156  private: rendering::VisualPtr hoverVis;
157 
159  private: rendering::VisualPtr prevHoverVis;
160 
162  private: rendering::VisualPtr selectedVis;
163 
165  private: rendering::VisualPtr inspectVis;
166 
168  private: boost::unordered_map<std::string, JointData *> joints;
169 
171  private: JointData *mouseJoint;
172 
174  private: std::vector<event::ConnectionPtr> connections;
175 
177  private: bool newJointCreated;
178 
180  private: boost::unordered_map<JointMaker::JointType, std::string>
181  jointMaterials;
182 
184  private: sdf::ElementPtr modelSDF;
185 
187  private: int jointCounter;
188 
190  private: QAction *inspectAct;
191  };
193 
194 
197  class GAZEBO_VISIBLE JointData : public QObject
198  {
199  Q_OBJECT
200 
203 
206 
209 
212 
215 
218 
220  public: math::Vector3 axis[2];
221 
223  public: double lowerLimit[2];
224 
226  public: double upperLimit[2];
227 
230 
232  public: bool dirty;
233 
236 
239  private slots: void OnApply();
240  };
242  }
243 }
244 #endif
Class for drawing lines that can change.
Definition: DynamicLines.hh:43
math::Vector3 anchor
Joint anchor point.
Definition: JointMaker.hh:229
Generic description of a mouse event.
Definition: MouseEvent.hh:32
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
rendering::VisualPtr child
Child visual the joint is connected to.
Definition: JointMaker.hh:211
bool dirty
True if the joint visual needs update.
Definition: JointMaker.hh:232
Fixed joint.
Definition: JointMaker.hh:57
JointMaker::JointType type
Type of joint.
Definition: JointMaker.hh:217
JointInspector * inspector
Inspector for configuring joint properties.
Definition: JointMaker.hh:235
rendering::VisualPtr parent
Parent visual the joint is connected to.
Definition: JointMaker.hh:208
Joint visualization.
Definition: JointMaker.hh:46
JointType
Definition: JointMaker.hh:52
Hinge2 joint.
Definition: JointMaker.hh:63
Screw joint.
Definition: JointMaker.hh:65
A class to inspect and modify joints.
Definition: JointInspector.hh:37
rendering::DynamicLines * line
Visual line used to represent joint connecting parent and child.
Definition: JointMaker.hh:214
Slider joint.
Definition: JointMaker.hh:59
boost::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:100
rendering::VisualPtr visual
Visual of the dynamic line.
Definition: JointMaker.hh:202
Universal joint.
Definition: JointMaker.hh:67
Hinge joint.
Definition: JointMaker.hh:61
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
rendering::VisualPtr hotspot
Visual of the hotspot
Definition: JointMaker.hh:205
Helper class to store joint data.
Definition: JointMaker.hh:197
none
Definition: JointMaker.hh:55