DART  6.10.1
InteractiveFrame.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, 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  enum Type
53  {
54 
55  LINEAR = 0,
58 
59  NUM_TYPES
60  };
61 
63  InteractiveFrame* frame, double defaultAlpha, 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  std::vector<std::unique_ptr<dart::dynamics::SimpleFrame>> mSimpleFrames;
101 
103 
104  bool mEnabled;
105 
107 };
108 
110 {
111 public:
113 
114 
116  dart::dynamics::Frame* referenceFrame,
117  const std::string& name = "interactive_frame",
118  const Eigen::Isometry3d& relativeTransform
119  = Eigen::Isometry3d::Identity(),
120  double size_scale = 0.2,
121  double thickness_scale = 2.0);
122 
124  virtual ~InteractiveFrame();
125 
128  virtual void resizeStandardVisuals(
129  double size_scale = 0.2, double thickness_scale = 2.0);
130 
132  InteractiveTool* getTool(InteractiveTool::Type tool, std::size_t coordinate);
133 
135  const InteractiveTool* getTool(
136  InteractiveTool::Type tool, 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 typedef std::shared_ptr<InteractiveFrame> InteractiveFramePtr;
165 
166 } // namespace osg
167 } // namespace gui
168 } // namespace dart
169 
170 #endif // DART_GUI_OSG_INTERACTIVEFRAME_HPP_
#define DART_DEFINE_ALIGNED_SHARED_OBJECT_CREATOR(class_name)
Definition: Memory.hpp:155
std::string * name
Definition: SkelParser.cpp:1697
The Frame class serves as the backbone of DART's kinematic tree structure.
Definition: Frame.hpp:58
The SimpleFrame class offers a user-friendly way of creating arbitrary Frames within the kinematic tr...
Definition: SimpleFrame.hpp:52
Definition: InteractiveFrame.hpp:110
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:586
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:242
void deleteAllTools()
Delete all the tool entities belonging to this InteractiveFrame.
Definition: InteractiveFrame.cpp:601
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:155
void removeAllShapeFrames()
Definition: InteractiveFrame.cpp:265
virtual ~InteractiveFrame()
Destructor.
Definition: InteractiveFrame.cpp:181
void createStandardVisualizationShapes(double size, double thickness)
Creates the standard visualization shapes for InteractiveFrames.
Definition: InteractiveFrame.cpp:271
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:104
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:126
double mDefaultAlpha
Definition: InteractiveFrame.hpp:102
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:100
void removeAllShapeFrames()
Definition: InteractiveFrame.cpp:149
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:106
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:164
Definition: BulletCollisionDetector.cpp:65