Debian Codegraph @

python/dartpy/gui/osg/RealTimeWorldNode.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 <pybind11/pybind11.h>
36
37 PYBIND11_DECLARE_HOLDER_TYPE(T, ::osg::ref_ptr<T>, true);
38
39 namespace py = pybind11;
40
41 namespace dart {
42 namespace python {
43
44 class PyRealTimeWorldNodeNode : public dart::gui::osg::RealTimeWorldNode
45 {
46 public:
47 // Inherit the constructors
48 using RealTimeWorldNode::RealTimeWorldNode;
49
50 // Trampoline for virtual function
51 void refresh() override
52 {
53 PYBIND11_OVERLOAD(
54 void, // Return type
55 RealTimeWorldNode, // Parent class
56 refresh, // Name of function in C++ (must match Python name)
57 );
58 }
59
60 // Trampoline for virtual function
61 void customPreRefresh() override
62 {
63 PYBIND11_OVERLOAD(
64 void, // Return type
65 RealTimeWorldNode, // Parent class
66 customPreRefresh, // Name of function in C++ (must match Python name)
67 );
68 }
69
70 // Trampoline for virtual function
71 void customPostRefresh() override
72 {
73 PYBIND11_OVERLOAD(
74 void, // Return type
75 RealTimeWorldNode, // Parent class
76 customPostRefresh, // Name of function in C++ (must match Python name)
77 );
78 }
79
80 // Trampoline for virtual function
81 void customPreStep() override
82 {
83 PYBIND11_OVERLOAD(
84 void, // Return type
85 RealTimeWorldNode, // Parent class
86 customPreStep, // Name of function in C++ (must match Python name)
87 );
88 }
89
90 // Trampoline for virtual function
91 void customPostStep() override
92 {
93 PYBIND11_OVERLOAD(
94 void, // Return type
95 RealTimeWorldNode, // Parent class
96 customPostStep, // Name of function in C++ (must match Python name)
97 );
98 }
99 };
100
101 void RealTimeWorldNode(py::module& m)
102 {
103 ::py::class_<
104 dart::gui::osg::RealTimeWorldNode,
105 dart::gui::osg::WorldNode,
106 PyRealTimeWorldNodeNode,
107 ::osg::ref_ptr<dart::gui::osg::RealTimeWorldNode>>(m, "RealTimeWorldNode")
108 .def(::py::init<>())
109 .def(
110 ::py::init<const std::shared_ptr<dart::simulation::World>&>(),
111 ::py::arg("world"))
112 .def(
113 ::py::init<
114 const std::shared_ptr<dart::simulation::World>&,
115 const osg::ref_ptr<osgShadow::ShadowTechnique>&>(),
116 ::py::arg("world"),
117 ::py::arg("shadower"))
118 .def(
119 ::py::init<
120 const std::shared_ptr<dart::simulation::World>&,
121 const osg::ref_ptr<osgShadow::ShadowTechnique>&,
122 double>(),
123 ::py::arg("world"),
124 ::py::arg("shadower"),
125 ::py::arg("targetFrequency"))
126 .def(
127 ::py::init<
128 const std::shared_ptr<dart::simulation::World>&,
129 const osg::ref_ptr<osgShadow::ShadowTechnique>&,
130 double,
131 double>(),
132 ::py::arg("world"),
133 ::py::arg("shadower"),
134 ::py::arg("targetFrequency"),
135 ::py::arg("targetRealTimeFactor"))
136 .def(
137 "setTargetFrequency",
138 +[](dart::gui::osg::RealTimeWorldNode* self, double targetFrequency) {
139 self->setTargetFrequency(targetFrequency);
140 },
141 ::py::arg("targetFrequency"))
142 .def(
143 "getTargetFrequency",
144 +[](const dart::gui::osg::RealTimeWorldNode* self) -> double {
145 return self->getTargetFrequency();
146 })
147 .def(
148 "setTargetRealTimeFactor",
149 +[](dart::gui::osg::RealTimeWorldNode* self, double targetRTF) {
150 self->setTargetRealTimeFactor(targetRTF);
151 },
152 ::py::arg("targetRTF"))
153 .def(
154 "getTargetRealTimeFactor",
155 +[](const dart::gui::osg::RealTimeWorldNode* self) -> double {
156 return self->getTargetRealTimeFactor();
157 })
158 .def(
159 "getLastRealTimeFactor",
160 +[](const dart::gui::osg::RealTimeWorldNode* self) -> double {
161 return self->getLastRealTimeFactor();
162 })
163 .def(
164 "getLowestRealTimeFactor",
165 +[](const dart::gui::osg::RealTimeWorldNode* self) -> double {
166 return self->getLowestRealTimeFactor();
167 })
168 .def(
169 "getHighestRealTimeFactor",
170 +[](const dart::gui::osg::RealTimeWorldNode* self) -> double {
171 return self->getHighestRealTimeFactor();
172 })
173 .def(
174 "refresh",
175 +[](dart::gui::osg::RealTimeWorldNode* self) { self->refresh(); });
176 }
177
178 } // namespace python
179 } // namespace dart