8 #include <pybind11/native_enum.h>
9 #include <pybind11/pybind11.h>
10 #include <pybind11/stl.h>
11 #include <pybind11/stl_bind.h>
19 #include "../casters.h"
22 using namespace pybind11::literals;
28 py::detail::internals &internals = py::detail::get_internals();
29 const auto instance =
reinterpret_cast<py::detail::instance *
>(nurse.ptr());
30 if (!instance->has_patients)
34 auto &nursePatients = internals.patients[nurse.ptr()];
36 auto it = std::find(nursePatients.begin(), nursePatients.end(), patient.ptr());
37 if (it == std::end(nursePatients))
42 nursePatients.erase(it);
43 instance->has_patients = !nursePatients.empty();
44 if (!instance->has_patients)
46 internals.patients.erase(nurse.ptr());
53 auto instance =
reinterpret_cast<py::detail::instance *
>(
object.ptr());
54 instance->owned = state;
55 for (
auto &v_h : py::detail::values_and_holders(instance))
59 v_h.set_holder_constructed(state);
72 py::object pyObj = py::cast(obj, py::return_value_policy::take_ownership);
79 py::class_<ccObject>(m,
"ccObject", R
"pbdoc(
80 The base class of all ACloudViewer's data types
82 - ccOjbects have a name that can be changed
83 - an 'enabled' state to control if the object should be displayed
89 >>> pc = pycc.ccPointCloud()
90 >>> pc.setName("Green Yoshi")
91 >>> pc.getName() == "Green Yoshi"
93 >>> pc.hasMetaData("Favorite Food")
95 >>> pc.getMetaData("Favorite Food") is None
97 >>> pc.setMetaData("Favorite Food", "Apples")
98 >>> pc.hasMetaData("Favorite Food")
100 >>> pc.getMetaData("Favorite Food") == "Apples"
106 Returns the name of the object
109 Sets the name of the object
119 Returns whether the object is enabled
122 Sets the "enabled" state
127 The new "enabled" state
131 Returns whether the object is locked
138 Returns the metadata associated to a key.
140 Returns None if no metadata for the key is found
145 The key / name of the metadata to retrieve
148 Removes the metadata associated to a key.
153 The key / name of the metadata to remove
157 [](
ccObject &obj,
const QString &key,
const QVariant &data)
162 Sets the metadata associated to a key.
167 The key / name of the metadata to remove
172 Returns True if the object has some metadata associated to the key
177 The key / name of the metadata to remove
180 py::native_enum<ccHObject::DEPENDENCY_FLAGS>(
181 m, "DEPENDENCY_FLAGS",
"enum.Enum",
"ccHObject::DEPENDENCY_FLAGS.")
182 .value(
"DP_NONE", ccHObject::DEPENDENCY_FLAGS::DP_NONE)
183 .value(
"DP_NOTIFY_OTHER_ON_DELETE", ccHObject::DEPENDENCY_FLAGS::DP_NOTIFY_OTHER_ON_DELETE)
184 .value(
"DP_NOTIFY_OTHER_ON_UPDATE", ccHObject::DEPENDENCY_FLAGS::DP_NOTIFY_OTHER_ON_UPDATE)
185 .value(
"DP_DELETE_OTHER", ccHObject::DEPENDENCY_FLAGS::DP_DELETE_OTHER)
186 .value(
"DP_PARENT_OF_OTHER", ccHObject::DEPENDENCY_FLAGS::DP_PARENT_OF_OTHER)
190 py::class_<ccHObject, ccObject, ccDrawableObject>(m,
"ccHObject", R
"pbdoc(
191 ACloudViewer's hierarchical object
193 Hierarchical objects can have children forming a hierarchy tree
198 >>> h = pycc.ccHObject("My Project Hierarchy")
200 This new hierarchy has no parents, nor children:
202 >>> h.getParent() is None
204 >>> h.getChildrenNumber(), h.getChildCountRecursive()
207 .def(py::init<QString>(), "name"_a = QString())
211 py::return_value_policy::reference_internal,
213 Returns the parent of this object
215 Returns None if the object has no parent
219 Returns the number of 'direct' children this object has
222 Returns the recursive number of children
226 [](py::object &
self,
const unsigned int index)
228 auto *child =
self.cast<
ccHObject *>()->getChild(index);
231 py::keep_alive<0, 1>(),
233 .def(
"find", &
ccHObject::find,
"uniqueID"_a, py::return_value_policy::reference_internal)
236 [](py::object &
self, py::object &child)
253 int insertIndex) {
return self.addChild(child, dependencyFlags, insertIndex); },
254 py::keep_alive<2, 1>(),
256 "dependencyFlags"_a = ccHObject::DEPENDENCY_FLAGS::DP_PARENT_OF_OTHER,
257 "insertIndex"_a = -1)
265 py::keep_alive<0, 1>())
273 py::keep_alive<0, 1>())
279 .def(
"applyGLTransformation_recursive",
286 Notifies all dependent entities that the geometry of this entity has changed
289 py::class_<ccShiftedObject, ccHObject>(m, "ccShiftedObject")
290 .def(
"setGlobalShift",
295 .def(
"setGlobalShift",
void setDeletable(py::object &object, bool state)
void removePatient(py::object &nurse, py::object &patient)
void define_ccObject(py::module &m)
py::object castToFakeOwnedObject(T &&obj)
Hierarchical CLOUDVIEWER Object.
virtual void notifyGeometryUpdate()
virtual const ccGLMatrix & getGLTransformationHistory() const
Returns the transformation 'history' matrix.
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
ccHObject * getLastChild() const
Shortcut: returns last child.
int getChildIndex(const ccHObject *aChild) const
Returns child index.
int getIndex() const
Returns index relatively to its parent or -1 if no parent.
virtual ccBBox getDisplayBB_recursive(bool relative)
Returns the bounding-box of this entity and it's children WHEN DISPLAYED.
ccHObject * getFirstChild() const
Shortcut: returns first child.
void detachChild(ccHObject *child)
Detaches a specific child.
bool isAncestorOf(const ccHObject *anObject) const
Returns true if the current object is an ancestor of the specified one.
void applyGLTransformation_recursive(const ccGLMatrix *trans=nullptr)
Applies the active OpenGL transformation to the entity (recursive)
unsigned getChildrenNumber() const
Returns the number of children.
unsigned int getChildCountRecursive() const
Returns the total number of children under this object recursively.
virtual void setGLTransformationHistory(const ccGLMatrix &mat)
Sets the transformation 'history' matrix (handle with care!)
DEPENDENCY_FLAGS
Dependency flags.
ccHObject * getParent() const
Returns parent object.
void detachAllChildren()
Removes a specific child.
void swapChildren(unsigned firstChildIndex, unsigned secondChildIndex)
Swaps two children.
virtual void resetGLTransformationHistory()
Resets the transformation 'history' matrix.
bool isGroup() const
Returns whether the instance is a group.
Generic "CLOUDVIEWER Object" template.
virtual void setLocked(bool state)
Sets the "enabled" property.
virtual bool isLocked() const
Returns whether the object is locked or not.
virtual QString getName() const
Returns object name.
virtual unsigned getUniqueID() const
Returns object unique ID.
void setMetaData(const QString &key, const QVariant &data)
Sets a meta-data element.
QVariant getMetaData(const QString &key) const
Returns a given associated meta data.
bool hasMetaData(const QString &key) const
Returns whether a meta-data element with the given key exists or not.
virtual void setName(const QString &name)
Sets object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
bool removeMetaData(const QString &key)
Removes a given associated meta-data.
virtual bool isEnabled() const
Returns whether the object is enabled or not.
virtual void toggleActivation()
Toggles the "enabled" property.
Shifted entity interface.
virtual void setGlobalScale(double scale)
bool isShifted() const
Returns whether the cloud is shifted or not.
virtual void setGlobalShift(double x, double y, double z)
Sets shift applied to original coordinates (information storage only)
virtual const CCVector3d & getGlobalShift() const
Returns the shift applied to original coordinates.
virtual double getGlobalScale() const
Returns the scale applied to original coordinates.
void copyGlobalShiftAndScale(const ccShiftedObject &s)
Copies the Global Shift and Scale from another entity.