| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| |
|
| | #include <App/Document.h>
|
| | #include <App/DocumentObject.h>
|
| | #include <Base/GeometryPyCXX.h>
|
| |
|
| | #include "Selection.h"
|
| | #include "SelectionObject.h"
|
| |
|
| |
|
| |
|
| | #include "Selection/SelectionObjectPy.h"
|
| | #include "Selection/SelectionObjectPy.cpp"
|
| |
|
| |
|
| | using namespace Gui;
|
| |
|
| |
|
| | std::string SelectionObjectPy::representation() const
|
| | {
|
| | return "<SelectionObject>";
|
| | }
|
| |
|
| | PyObject* SelectionObjectPy::remove(PyObject* args)
|
| | {
|
| | if (!PyArg_ParseTuple(args, "")) {
|
| | return nullptr;
|
| | }
|
| | Selection().rmvSelection(
|
| | getSelectionObjectPtr()->getDocName(),
|
| | getSelectionObjectPtr()->getFeatName()
|
| | );
|
| | Py_Return;
|
| | }
|
| |
|
| | PyObject* SelectionObjectPy::isObjectTypeOf(PyObject* args)
|
| | {
|
| | char* type;
|
| | if (!PyArg_ParseTuple(args, "s", &type)) {
|
| | return nullptr;
|
| | }
|
| | Base::Type id = Base::Type::fromName(type);
|
| | if (id.isBad()) {
|
| | PyErr_SetString(PyExc_TypeError, "Not a valid type");
|
| | return nullptr;
|
| | }
|
| |
|
| | bool ok = getSelectionObjectPtr()->isObjectTypeOf(id);
|
| |
|
| | return Py_BuildValue("O", (ok ? Py_True : Py_False));
|
| | }
|
| |
|
| | Py::String SelectionObjectPy::getObjectName() const
|
| | {
|
| | return {getSelectionObjectPtr()->getFeatName()};
|
| | }
|
| |
|
| | Py::Tuple SelectionObjectPy::getSubElementNames() const
|
| | {
|
| | std::vector<std::string> objs = getSelectionObjectPtr()->getSubNames();
|
| |
|
| | Py::Tuple temp(objs.size());
|
| | Py::sequence_index_type index = 0;
|
| | for (const auto& obj : objs) {
|
| | temp.setItem(index++, Py::String(obj));
|
| | }
|
| |
|
| | return temp;
|
| | }
|
| |
|
| | Py::String SelectionObjectPy::getFullName() const
|
| | {
|
| | return {getSelectionObjectPtr()->getAsPropertyLinkSubString()};
|
| | }
|
| |
|
| | Py::String SelectionObjectPy::getTypeName() const
|
| | {
|
| | return {getSelectionObjectPtr()->getTypeName()};
|
| | }
|
| |
|
| | Py::String SelectionObjectPy::getDocumentName() const
|
| | {
|
| | return {getSelectionObjectPtr()->getDocName()};
|
| | }
|
| |
|
| | Py::Object SelectionObjectPy::getDocument() const
|
| | {
|
| | App::DocumentObject* obj = getSelectionObjectPtr()->getObject();
|
| | if (!obj) {
|
| | throw Py::RuntimeError("Cannot get document of deleted object");
|
| | }
|
| | return Py::Object(obj->getDocument()->getPyObject(), true);
|
| | }
|
| |
|
| | Py::Object SelectionObjectPy::getObject() const
|
| | {
|
| | App::DocumentObject* obj = getSelectionObjectPtr()->getObject();
|
| | if (!obj) {
|
| | throw Py::RuntimeError("Object already deleted");
|
| | }
|
| | return Py::Object(obj->getPyObject(), true);
|
| | }
|
| |
|
| | Py::Tuple SelectionObjectPy::getSubObjects() const
|
| | {
|
| | App::DocumentObject* obj = getSelectionObjectPtr()->getObject();
|
| | if (!obj) {
|
| | throw Py::RuntimeError("Cannot get sub-objects of deleted object");
|
| | }
|
| |
|
| | std::vector<PyObject*> subObjs;
|
| |
|
| | for (const auto& subname : getSelectionObjectPtr()->getSubNames()) {
|
| | PyObject* pyObj = nullptr;
|
| | Base::Matrix4D mat;
|
| | obj->getSubObject(subname.c_str(), &pyObj, &mat);
|
| | if (pyObj) {
|
| | subObjs.push_back(pyObj);
|
| | }
|
| | }
|
| |
|
| | Py::Tuple temp(subObjs.size());
|
| | Py::sequence_index_type index = 0;
|
| | for (const auto& subObj : subObjs) {
|
| | temp.setItem(index++, Py::asObject(subObj));
|
| | }
|
| |
|
| | return temp;
|
| | }
|
| |
|
| | Py::Boolean SelectionObjectPy::getHasSubObjects() const
|
| | {
|
| | return {getSelectionObjectPtr()->hasSubNames()};
|
| | }
|
| |
|
| | Py::Tuple SelectionObjectPy::getPickedPoints() const
|
| | {
|
| | const std::vector<Base::Vector3d>& points = getSelectionObjectPtr()->getPickedPoints();
|
| |
|
| | Py::Tuple temp(points.size());
|
| | Py::sequence_index_type index = 0;
|
| | for (const auto& point : points) {
|
| | temp.setItem(index++, Py::Vector(point));
|
| | }
|
| |
|
| | return temp;
|
| | }
|
| |
|
| | PyObject* SelectionObjectPy::getCustomAttributes(const char* ) const
|
| | {
|
| | return nullptr;
|
| | }
|
| |
|
| | int SelectionObjectPy::setCustomAttributes(const char* , PyObject* )
|
| | {
|
| | return 0;
|
| | }
|
| |
|