Debian Codegraph @

python/dartpy/gui/osg/InteractiveFrame.cpp

raw
1 /*
2 * Copyright (c) 2011-2022, 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 #include <dart/dart.hpp>
34 #include <dart/gui/osg/osg.hpp>
35 #include <osgShadow/ShadowMap>
36 #include <osgShadow/ShadowTechnique>
37 #include <pybind11/pybind11.h>
38
39 namespace py = pybind11;
40
41 namespace dart {
42 namespace python {
43
44 void InteractiveFrame(py::module& m)
45 {
46 auto it
47 = ::py::class_<
48 dart::gui::osg::InteractiveTool,
49 dart::dynamics::SimpleFrame,
50 std::shared_ptr<dart::gui::osg::InteractiveTool>>(
51 m, "InteractiveTool")
52 .def(
53 ::py::init<
54 dart::gui::osg::InteractiveFrame*,
55 double,
56 const std::string&>(),
57 ::py::arg("frame"),
58 ::py::arg("defaultAlpha"),
59 ::py::arg("name"))
60 .def(
61 "setEnabled",
62 +[](dart::gui::osg::InteractiveTool* self, bool enabled) {
63 self->setEnabled(enabled);
64 },
65 ::py::arg("enabled"))
66 .def(
67 "getEnabled",
68 +[](const dart::gui::osg::InteractiveTool* self) -> bool {
69 return self->getEnabled();
70 })
71 .def(
72 "setAlpha",
73 +[](dart::gui::osg::InteractiveTool* self, double alpha) {
74 self->setAlpha(alpha);
75 },
76 ::py::arg("alpha"))
77 .def(
78 "resetAlpha",
79 +[](dart::gui::osg::InteractiveTool* self) {
80 self->resetAlpha();
81 })
82 .def(
83 "setDefaultAlpha",
84 +[](dart::gui::osg::InteractiveTool* self, double alpha) {
85 self->setDefaultAlpha(alpha);
86 },
87 ::py::arg("alpha"))
88 .def(
89 "setDefaultAlpha",
90 +[](dart::gui::osg::InteractiveTool* self,
91 double alpha,
92 bool reset) { self->setDefaultAlpha(alpha, reset); },
93 ::py::arg("alpha"),
94 ::py::arg("reset"))
95 .def(
96 "getDefaultAlpha",
97 +[](const dart::gui::osg::InteractiveTool* self) -> double {
98 return self->getDefaultAlpha();
99 })
100 .def(
101 "getShapeFrames",
102 +[](dart::gui::osg::InteractiveTool* self)
103 -> const std::vector<dart::dynamics::SimpleFrame*> {
104 return self->getShapeFrames();
105 })
106 .def(
107 "getShapeFrames",
108 +[](const dart::gui::osg::InteractiveTool* self)
109 -> const std::vector<const dart::dynamics::SimpleFrame*> {
110 return self->getShapeFrames();
111 })
112 .def(
113 "removeAllShapeFrames",
114 +[](dart::gui::osg::InteractiveTool* self) {
115 self->removeAllShapeFrames();
116 });
117
118 ::py::enum_<dart::gui::osg::InteractiveTool::Type>(it, "Type")
119 .value("LINEAR", dart::gui::osg::InteractiveTool::Type::LINEAR)
120 .value("ANGULAR", dart::gui::osg::InteractiveTool::Type::ANGULAR)
121 .value("PLANAR", dart::gui::osg::InteractiveTool::Type::PLANAR)
122 .value("NUM_TYPES", dart::gui::osg::InteractiveTool::Type::NUM_TYPES)
123 .export_values();
124
125 ::py::class_<
126 dart::gui::osg::InteractiveFrame,
127 dart::dynamics::SimpleFrame,
128 std::shared_ptr<dart::gui::osg::InteractiveFrame>>(m, "InteractiveFrame")
129 .def(::py::init<dart::dynamics::Frame*>(), ::py::arg("referenceFrame"))
130 .def(
131 ::py::init<dart::dynamics::Frame*, const std::string&>(),
132 ::py::arg("referenceFrame"),
133 ::py::arg("name"))
134 .def(
135 ::py::init<
136 dart::dynamics::Frame*,
137 const std::string&,
138 const Eigen::Isometry3d&>(),
139 ::py::arg("referenceFrame"),
140 ::py::arg("name"),
141 ::py::arg("relativeTransform"))
142 .def(
143 ::py::init<
144 dart::dynamics::Frame*,
145 const std::string&,
146 const Eigen::Isometry3d&,
147 double>(),
148 ::py::arg("referenceFrame"),
149 ::py::arg("name"),
150 ::py::arg("relativeTransform"),
151 ::py::arg("sizeScale"))
152 .def(
153 ::py::init<
154 dart::dynamics::Frame*,
155 const std::string&,
156 const Eigen::Isometry3d&,
157 double,
158 double>(),
159 ::py::arg("referenceFrame"),
160 ::py::arg("name"),
161 ::py::arg("relativeTransform"),
162 ::py::arg("sizeScale"),
163 ::py::arg("thicknessScale"))
164 .def(
165 "resizeStandardVisuals",
166 +[](dart::gui::osg::InteractiveFrame* self) {
167 self->resizeStandardVisuals();
168 })
169 .def(
170 "resizeStandardVisuals",
171 +[](dart::gui::osg::InteractiveFrame* self, double size_scale) {
172 self->resizeStandardVisuals(size_scale);
173 },
174 ::py::arg("sizeScale"))
175 .def(
176 "resizeStandardVisuals",
177 +[](dart::gui::osg::InteractiveFrame* self,
178 double size_scale,
179 double thickness_scale) {
180 self->resizeStandardVisuals(size_scale, thickness_scale);
181 },
182 ::py::arg("sizeScale"),
183 ::py::arg("thicknessScale"))
184 .def(
185 "getShapeFrames",
186 +[](dart::gui::osg::InteractiveFrame* self)
187 -> const std::vector<dart::dynamics::SimpleFrame*> {
188 return self->getShapeFrames();
189 })
190 .def(
191 "getShapeFrames",
192 +[](const dart::gui::osg::InteractiveFrame* self)
193 -> const std::vector<const dart::dynamics::SimpleFrame*> {
194 return self->getShapeFrames();
195 })
196 .def(
197 "removeAllShapeFrames", +[](dart::gui::osg::InteractiveFrame* self) {
198 self->removeAllShapeFrames();
199 });
200 }
201
202 } // namespace python
203 } // namespace dart