DART  6.6.2
InteractiveFrame.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_GUI_OSG_INTERACTIVEFRAME_HPP_
34 #define DART_GUI_OSG_INTERACTIVEFRAME_HPP_
35 
37 
38 namespace dart {
39 
40 namespace dynamics {
41 class MeshShape;
42 } // namespace dynamics
43 
44 namespace gui {
45 namespace osg {
46 
47 class InteractiveFrame;
48 
50 {
51 public:
52 
53  enum Type {
54 
55  LINEAR = 0,
58 
59  NUM_TYPES
60  };
61 
62  InteractiveTool(InteractiveFrame* frame, double defaultAlpha,
63  const std::string& name);
64 
66  void setEnabled(bool enabled);
67 
69  bool getEnabled() const;
70 
72  void setAlpha(double alpha);
73 
75  void resetAlpha();
76 
79  void setDefaultAlpha(double alpha, bool reset=true);
80 
82  double getDefaultAlpha() const;
83 
86 
89 
91  const dart::dynamics::ShapePtr& shape);
92 
93  const std::vector<dart::dynamics::SimpleFrame*> getShapeFrames();
94 
95  const std::vector<const dart::dynamics::SimpleFrame*> getShapeFrames() const;
96 
97  void removeAllShapeFrames();
98 
99 protected:
100 
101  std::vector<std::unique_ptr<dart::dynamics::SimpleFrame>> mSimpleFrames;
102 
104 
105  bool mEnabled;
106 
108 
109 };
110 
112 {
113 public:
115 
116 
118  dart::dynamics::Frame* referenceFrame,
119  const std::string& name = "interactive_frame",
120  const Eigen::Isometry3d& relativeTransform = Eigen::Isometry3d::Identity(),
121  double size_scale=0.2, double thickness_scale=2.0);
122 
124  virtual ~InteractiveFrame();
125 
128  virtual void resizeStandardVisuals(double size_scale=0.2,
129  double thickness_scale=2.0);
130 
132  InteractiveTool* getTool(InteractiveTool::Type tool, std::size_t coordinate);
133 
136  std::size_t coordinate) const;
137 
139  const dart::dynamics::ShapePtr& shape);
140 
141  const std::vector<dart::dynamics::SimpleFrame*> getShapeFrames();
142 
143  const std::vector<const dart::dynamics::SimpleFrame*> getShapeFrames() const;
144 
145  void removeAllShapeFrames();
146 
147 protected:
150  void createStandardVisualizationShapes(double size, double thickness);
151 
154 
156  void deleteAllTools();
157 
160 
161  std::vector<std::unique_ptr<dart::dynamics::SimpleFrame>> mSimpleFrames;
162 
163 };
164 
165 typedef std::shared_ptr<InteractiveFrame> InteractiveFramePtr;
166 
167 } // namespace osg
168 } // namespace gui
169 } // namespace dart
170 
171 #endif // DART_GUI_OSG_INTERACTIVEFRAME_HPP_
#define DART_DEFINE_ALIGNED_SHARED_OBJECT_CREATOR(class_name)
Definition: Memory.hpp:148
std::string * name
Definition: SkelParser.cpp:1642
The Frame class serves as the backbone of DART's kinematic tree structure.
Definition: Frame.hpp:57
The SimpleFrame class offers a user-friendly way of creating arbitrary Frames within the kinematic tr...
Definition: SimpleFrame.hpp:52
Definition: InteractiveFrame.hpp:112
virtual void resizeStandardVisuals(double size_scale=0.2, double thickness_scale=2.0)
Recreate the visuals for this InteractiveFrame according to the specified scales.
Definition: InteractiveFrame.cpp:188
void deleteAllVisualizationShapes()
Deletes all the visualization shapes held by the InteractiveFrame.
Definition: InteractiveFrame.cpp:590
dart::dynamics::SimpleFrame * addShapeFrame(const dart::dynamics::ShapePtr &shape)
Definition: InteractiveFrame.cpp:226
std::vector< std::unique_ptr< dart::dynamics::SimpleFrame > > mSimpleFrames
Definition: InteractiveFrame.hpp:161
const std::vector< dart::dynamics::SimpleFrame * > getShapeFrames()
Definition: InteractiveFrame.cpp:243
void deleteAllTools()
Delete all the tool entities belonging to this InteractiveFrame.
Definition: InteractiveFrame.cpp:605
InteractiveFrame(dart::dynamics::Frame *referenceFrame, const std::string &name="interactive_frame", const Eigen::Isometry3d &relativeTransform=Eigen::Isometry3d::Identity(), double size_scale=0.2, double thickness_scale=2.0)
Constructor.
Definition: InteractiveFrame.cpp:156
void removeAllShapeFrames()
Definition: InteractiveFrame.cpp:266
virtual ~InteractiveFrame()
Destructor.
Definition: InteractiveFrame.cpp:181
void createStandardVisualizationShapes(double size, double thickness)
Creates the standard visualization shapes for InteractiveFrames.
Definition: InteractiveFrame.cpp:272
InteractiveTool * getTool(InteractiveTool::Type tool, std::size_t coordinate)
Get the specified tool.
Definition: InteractiveFrame.cpp:196
InteractiveTool * mTools[InteractiveTool::NUM_TYPES][3]
Array of tools belonging to this InteractiveFrame.
Definition: InteractiveFrame.hpp:159
Definition: InteractiveFrame.hpp:50
bool mEnabled
Definition: InteractiveFrame.hpp:105
InteractiveFrame * getInteractiveFrame()
Get the InteractiveFrame that this tool belongs to.
Definition: InteractiveFrame.cpp:98
bool getEnabled() const
Returns true if this tool is enabled.
Definition: InteractiveFrame.cpp:65
const std::vector< dart::dynamics::SimpleFrame * > getShapeFrames()
Definition: InteractiveFrame.cpp:127
double mDefaultAlpha
Definition: InteractiveFrame.hpp:103
void resetAlpha()
Reset the alpha of this tool back to its default value.
Definition: InteractiveFrame.cpp:78
dart::dynamics::SimpleFrame * addShapeFrame(const dart::dynamics::ShapePtr &shape)
Definition: InteractiveFrame.cpp:110
void setDefaultAlpha(double alpha, bool reset=true)
Set the default alpha for this tool.
Definition: InteractiveFrame.cpp:84
std::vector< std::unique_ptr< dart::dynamics::SimpleFrame > > mSimpleFrames
Definition: InteractiveFrame.hpp:101
void removeAllShapeFrames()
Definition: InteractiveFrame.cpp:150
Type
Definition: InteractiveFrame.hpp:53
@ PLANAR
Tool for rotations.
Definition: InteractiveFrame.hpp:57
@ NUM_TYPES
Tool for planar translations.
Definition: InteractiveFrame.hpp:59
@ ANGULAR
Tool for linearly constrained translations.
Definition: InteractiveFrame.hpp:56
@ LINEAR
Definition: InteractiveFrame.hpp:55
InteractiveFrame * mInteractiveFrame
Definition: InteractiveFrame.hpp:107
void setAlpha(double alpha)
Set the alpha of this tool.
Definition: InteractiveFrame.cpp:71
InteractiveTool(InteractiveFrame *frame, double defaultAlpha, const std::string &name)
Definition: InteractiveFrame.cpp:44
double getDefaultAlpha() const
Get the default alpha setting for this tool.
Definition: InteractiveFrame.cpp:92
void setEnabled(bool enabled)
Set this tool to be enabled or disabled.
Definition: InteractiveFrame.cpp:57
std::shared_ptr< Shape > ShapePtr
Definition: SmartPointer.hpp:81
std::shared_ptr< InteractiveFrame > InteractiveFramePtr
Definition: InteractiveFrame.hpp:165
Definition: BulletCollisionDetector.cpp:63