Skip to content

Commit

Permalink
improve stubs for DagPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Muream committed Jun 9, 2021
1 parent beb3eec commit 97b76d6
Showing 1 changed file with 107 additions and 36 deletions.
143 changes: 107 additions & 36 deletions src/MDagPath.inl
Original file line number Diff line number Diff line change
@@ -1,12 +1,78 @@
#define _doc_apiType R"pbdoc(Returns the type of the object at the end of the path.)pbdoc"

#define _doc_child R"pbdoc(Returns the specified child of the object at the end of the path.)pbdoc"

#define _doc_childCount R"pbdoc(Returns the number of objects parented directly beneath the object at the end of the path.)pbdoc"

#define _doc_exclusiveMatrix R"pbdoc(Returns the matrix for all transforms in the path, excluding the end object.)pbdoc"

#define _doc_exclusiveMatrixInverse R"pbdoc(Returns the inverse of exclusiveMatrix().)pbdoc"

#define _doc_extendToShape R"pbdoc(If the object at the end of this path is a transform and there is a shape node directly beneath it in the hierarchy, then the path is extended to that geometry node.\
\
NOTE: This method will fail if there multiple shapes below the transform.)pbdoc"

#define _doc_extendToShapeDirectlyBelow R"pbdoc(This method is used if the end of the path is a transform and there are shapes directly below the transform.\
The shape to extend to is set by passing in an appropriate index parameter.\
Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are below)pbdoc"

#define _doc_fullPathName R"pbdoc(Returns a string representation of the path from the DAG root to the path's last node.)pbdoc"

#define _doc_getAPathTo R"pbdoc(Returns the first path found to the given node.)pbdoc"

#define _doc_getAllPathsBelow R"pbdoc(Returns all paths to the given node.)pbdoc"

#define _doc_getAllPathsTo R"pbdoc(Returns all paths to the given node.)pbdoc"

#define _doc_getDrawOverrideInfo R"pbdoc(Returns the draw override information for this path.)pbdoc"

#define _doc_getPath R"pbdoc(Returns the specified sub-path of this path.)pbdoc"

#define _doc_hasFn R"pbdoc(Returns True if the object at the end of the path supports the given function set.)pbdoc"

#define _doc_inclusiveMatrix R"pbdoc(Returns the matrix for all transforms in the path, including the end object, if it is a transform.)pbdoc"

#define _doc_inclusiveMatrixInverse R"pbdoc(Returns the inverse of inclusiveMatrix().)pbdoc"

#define _doc_instanceNumber R"pbdoc(Returns the instance number of this path to the object at the end.)pbdoc"

#define _doc_isInstanced R"pbdoc(Returns True if the object at the end of the path can be reached by more than one path.)pbdoc"

#define _doc_isTemplated R"pbdoc(Returns true if the DAG Node at the end of the path is templated.)pbdoc"

#define _doc_isValid R"pbdoc(Returns True if this is a valid path.)pbdoc"

#define _doc_isVisible R"pbdoc(Returns true if the DAG Node at the end of the path is visible.)pbdoc"

#define _doc_length R"pbdoc(Returns the number of nodes on the path, not including the DAG's root node.)pbdoc"

#define _doc_matchTransform R"pbdoc(Extends the path to the specified shape node parented directly beneath the transform at the current end of the path.)pbdoc"

#define _doc_node R"pbdoc(Returns the DAG node at the end of the path.)pbdoc"

#define _doc_numberOfShapesDirectlyBelow R"pbdoc(Returns the number of shape nodes parented directly beneath the transform at the end of the path.)pbdoc"

#define _doc_partialPathName R"pbdoc(Returns the minimum string representation which will uniquely identify the path.)pbdoc"

#define _doc_pathCount R"pbdoc(Returns the number of sub-paths which make up this path.)pbdoc"

#define _doc_pop R"pbdoc(Removes objects from the end of the path.)pbdoc"

#define _doc_push R"pbdoc(Extends the path to the specified child object, which must be parented directly beneath the object currently at the end of the path.)pbdoc"

#define _doc_set R"pbdoc(Replaces the current path held by this object with another.)pbdoc"

#define _doc_transform R"pbdoc(Returns the last transform node on the path.)pbdoc"

DagPath
.def(py::init<>())

.def(py::self == MDagPath())
.def(py::self == MDagPath(), py::arg("other"))

.def("apiType", [](MDagPath & self) -> MFn::Type {
// Not throwing anything here since apiType returns kInvalid when it fails.
return self.apiType();
}, R"pbdoc(Returns the type of the object at the end of the path.)pbdoc")
}, _doc_apiType)

.def("child", [](MDagPath & self, unsigned int i) -> MObject {
if (!self.isValid()) {
Expand All @@ -23,7 +89,8 @@ DagPath
}

return result;
}, R"pbdoc(Returns the specified child of the object at the end of the path.)pbdoc")
}, py::arg("i"),
_doc_child)

.def("childCount", [](MDagPath & self) -> int {
if (!self.isValid()) {
Expand All @@ -38,7 +105,7 @@ DagPath
}

return result;
}, R"pbdoc(Returns the number of objects parented directly beneath the object at the end of the path.)pbdoc")
}, _doc_childCount)

.def("exclusiveMatrix", [](MDagPath & self) -> MMatrix {
if (!self.isValid()) {
Expand All @@ -53,7 +120,7 @@ DagPath
}

return result;
}, R"pbdoc(Returns the matrix for all transforms in the path, excluding the end object.)pbdoc")
}, _doc_exclusiveMatrix)

.def("exclusiveMatrixInverse", [](MDagPath & self) -> MMatrix {
if (!self.isValid()) {
Expand All @@ -67,7 +134,7 @@ DagPath
}

return result;
}, R"pbdoc(Returns the inverse of exclusiveMatrix().)pbdoc")
}, _doc_exclusiveMatrixInverse)

.def("extendToShape", [](MDagPath & self) {
if (!self.isValid()) {
Expand All @@ -79,9 +146,7 @@ DagPath
if (!status) {
throw std::logic_error(status.errorString().asChar());
}
}, R"pbdoc(If the object at the end of this path is a transform and there is a shape node directly beneath it in the hierarchy, then the path is extended to that geometry node.
NOTE: This method will fail if there multiple shapes below the transform.)pbdoc")
}, _doc_extendToShape)

.def("extendToShapeDirectlyBelow", [](MDagPath & self, unsigned int index) {
if (!self.isValid()) {
Expand All @@ -99,9 +164,8 @@ NOTE: This method will fail if there multiple shapes below the transform.)pbdoc"
if (!status) {
throw std::logic_error(status.errorString().asChar());
}
}, R"pbdoc(This method is used if the end of the path is a transform and there are shapes directly below the transform.
The shape to extend to is set by passing in an appropriate index parameter.
Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are below)pbdoc")
}, py::arg("index"),
_doc_extendToShapeDirectlyBelow)

.def("fullPathName", [](MDagPath & self) -> std::string {
if (!self.isValid()) {
Expand All @@ -116,7 +180,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns a string representation of the path from the DAG root to the path's last node.)pbdoc")
}, _doc_fullPathName)

.def_static("getAPathTo", [](MObject node) -> MDagPath {
if (node.isNull()) {
Expand All @@ -136,23 +200,27 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return path;
}, R"pbdoc(Returns the first path found to the given node.)pbdoc")
}, py::arg("node"),
_doc_getAPathTo)

.def_static("getAllPathsBelow", [](MObject node) -> std::vector<MDagPath> {
throw std::logic_error{"Function not yet implemented."};
}, R"pbdoc(Returns all paths to the given node.)pbdoc")
}, py::arg("node"),
_doc_getAllPathsBelow)

.def_static("getAllPathsTo", [](MObject node) -> std::vector<MDagPath> {
throw std::logic_error{"Function not yet implemented."};
}, R"pbdoc(Returns all paths to the given node.)pbdoc")
}, py::arg("node"),
_doc_getAllPathsTo)

.def("getDrawOverrideInfo", [](MDagPath & self) -> MDAGDrawOverrideInfo {
throw std::logic_error{"Function not yet implemented."};
}, R"pbdoc(Returns the draw override information for this path.)pbdoc")
}, _doc_getDrawOverrideInfo)

.def("getPath", [](MDagPath & self, unsigned int i = 0) -> MDagPath {
throw std::logic_error{"Function not yet implemented."};
}, R"pbdoc(Returns the specified sub-path of this path.)pbdoc")
}, py::arg("i"),
_doc_getPath)

.def("hasFn", [](MDagPath & self, MFn::Type type) -> bool {
if (!self.isValid()) {
Expand All @@ -167,14 +235,15 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns True if the object at the end of the path supports the given function set.)pbdoc")
}, py::arg("type"),
_doc_hasFn)

.def("inclusiveMatrix", [](MDagPath & self) -> MMatrix {
if (!self.isValid()) {
throw std::logic_error("Call on invalid DagPath.");
}
return self.inclusiveMatrix();
}, R"pbdoc(Returns the matrix for all transforms in the path, including the end object, if it is a transform.)pbdoc")
}, _doc_inclusiveMatrix)

.def("inclusiveMatrixInverse", [](MDagPath & self) -> MMatrix {
if (!self.isValid()) {
Expand All @@ -189,7 +258,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns the inverse of inclusiveMatrix().)pbdoc")
}, _doc_inclusiveMatrixInverse)

.def("instanceNumber", [](MDagPath & self) -> int {
if (!self.isValid()) {
Expand All @@ -206,7 +275,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns the instance number of this path to the object at the end.)pbdoc")
}, _doc_instanceNumber)

.def("isInstanced", [](MDagPath & self) -> bool {
if (!self.isValid()) {
Expand All @@ -221,7 +290,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns True if the object at the end of the path can be reached by more than one path.)pbdoc")
}, _doc_isInstanced)

.def("isTemplated", [](MDagPath & self) -> bool {
if (!self.isValid()) {
Expand All @@ -236,7 +305,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns true if the DAG Node at the end of the path is templated.)pbdoc")
}, _doc_isTemplated)

.def("isValid", [](MDagPath & self) -> bool {
MStatus status;
Expand All @@ -247,7 +316,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns True if this is a valid path.)pbdoc")
}, _doc_isValid)

.def("isVisible", [](MDagPath & self) -> bool {
if (!self.isValid()) {
Expand All @@ -262,7 +331,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns true if the DAG Node at the end of the path is visible.)pbdoc")
}, _doc_isVisible)

.def("length", [](MDagPath & self) -> int {
if (!self.isValid()) {
Expand All @@ -277,11 +346,11 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns the number of nodes on the path, not including the DAG's root node.)pbdoc")
}, _doc_length)

.def("matchTransform", [](MDagPath & self) {
throw std::logic_error{"Function not yet implemented."};
}, R"pbdoc(Extends the path to the specified shape node parented directly beneath the transform at the current end of the path.)pbdoc")
}, _doc_matchTransform)

.def("node", [](MDagPath & self) -> MObject {
if (!self.isValid()) {
Expand All @@ -296,7 +365,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns the DAG node at the end of the path.)pbdoc")
}, _doc_node)

.def("numberOfShapesDirectlyBelow", [](MDagPath & self) -> unsigned int {
if (!self.isValid()) {
Expand All @@ -312,7 +381,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns the number of shape nodes parented directly beneath the transform at the end of the path.)pbdoc")
}, _doc_numberOfShapesDirectlyBelow)

.def("partialPathName", [](MDagPath & self) -> std::string {
if (!self.isValid()) {
Expand All @@ -327,11 +396,11 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return std::string(result.asChar());
}, R"pbdoc(Returns the minimum string representation which will uniquely identify the path.)pbdoc")
}, _doc_partialPathName)

.def("pathCount", [](MDagPath & self) -> int {
throw std::logic_error{"Function not yet implemented."};
}, R"pbdoc(Returns the number of sub-paths which make up this path.)pbdoc")
}, _doc_pathCount)

.def("pop", [](MDagPath & self, unsigned int num = 1) {
if (!self.isValid()) {
Expand All @@ -346,7 +415,7 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
throw std::logic_error(status.errorString().asChar());
}

}, R"pbdoc(Removes objects from the end of the path.)pbdoc", py::arg("num") = 1)
}, _doc_pop, py::arg("num") = 1)

.def("push", [](MDagPath & self, MObject child) {
if (!self.isValid()) {
Expand All @@ -359,15 +428,17 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
throw std::logic_error(status.errorString().asChar());
}

}, R"pbdoc(Extends the path to the specified child object, which must be parented directly beneath the object currently at the end of the path.)pbdoc")
}, py::arg("child"),
_doc_push)

.def("set", [](MDagPath & self, MDagPath src) {
MStatus status = self.set(src);

if (!status) {
throw std::logic_error(status.errorString().asChar());
}
}, R"pbdoc(Replaces the current path held by this object with another.)pbdoc")
}, py::arg("src"),
_doc_set)

.def("transform", [](MDagPath & self) -> MObject {
if (!self.isValid()) {
Expand All @@ -382,4 +453,4 @@ Use the `numberOfShapesDirectlyBelow()` method to determine how many shapes are
}

return result;
}, R"pbdoc(Returns the last transform node on the path.)pbdoc");
}, _doc_transform);

0 comments on commit 97b76d6

Please sign in to comment.