diff --git a/src/Mod/TechDraw/App/AppTechDraw.cpp b/src/Mod/TechDraw/App/AppTechDraw.cpp index 0d1ec2284e..370211d953 100644 --- a/src/Mod/TechDraw/App/AppTechDraw.cpp +++ b/src/Mod/TechDraw/App/AppTechDraw.cpp @@ -149,5 +149,7 @@ PyMOD_INIT_FUNC(TechDraw) TechDraw::DrawWeldSymbolPython::init(); TechDraw::DrawBrokenViewPython::init(); + TechDraw::LineFormat::initCurrentLineFormat(); + PyMOD_Return(mod); } diff --git a/src/Mod/TechDraw/App/AppTechDrawPy.cpp b/src/Mod/TechDraw/App/AppTechDrawPy.cpp index 517761dfdc..4bb3fc7254 100644 --- a/src/Mod/TechDraw/App/AppTechDrawPy.cpp +++ b/src/Mod/TechDraw/App/AppTechDrawPy.cpp @@ -72,7 +72,7 @@ #include "ProjectionAlgos.h" #include "TechDrawExport.h" #include "CosmeticVertexPy.h" - +#include "DrawLeaderLinePy.h" namespace TechDraw { //module level static C++ functions go here @@ -191,6 +191,9 @@ public: add_varargs_method("makeCanonicalPoint", &Module::makeCanonicalPoint, "makeCanonicalPoint(DrawViewPart, Vector3d) - Returns the unscaled, unrotated version of the input point)" ); + add_varargs_method("makeLeader", &Module::makeLeader, + "makeLeader(parent - DrawViewPart, points - [Vector], startSymbol - int, endSymbol - int) - Creates a leader line attached to parent. Points are in page coordinates with (0, 0) at lowerleft.s" + ); initialize("This is a module for making drawings"); // register with Python } ~Module() override {} @@ -1286,6 +1289,42 @@ private: cPoint = CosmeticVertex::makeCanonicalPoint(dvp, cPoint, unscale); return Py::asObject(new Base::VectorPy(cPoint)); } + + Py::Object makeLeader(const Py::Tuple& args) + { + PyObject* pDvp(nullptr); + PyObject* pPointList(nullptr); + int iStartSymbol = 0; + int iEndSymbol = 0; + TechDraw::DrawViewPart* dvp = nullptr; + + if (!PyArg_ParseTuple(args.ptr(), "OO!|ii", &pDvp, &(PyList_Type), &pPointList, &iStartSymbol, &iEndSymbol)) { + throw Py::TypeError("expected (DrawViewPart, listofpoints, startsymbolindex, endsymbolindex"); + } + if (PyObject_TypeCheck(pDvp, &(TechDraw::DrawViewPartPy::Type))) { + App::DocumentObject* obj = static_cast(pDvp)->getDocumentObjectPtr(); + dvp = static_cast(obj); + } + + std::vector pointList; + try { + Py::Sequence list(pPointList); + for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { + if (PyObject_TypeCheck((*it).ptr(), &(Base::VectorPy::Type))) { + Base::Vector3d temp = static_cast((*it).ptr())->value(); + pointList.push_back(temp); + } + } + } + catch (Standard_Failure& e) { + throw Py::Exception(Part::PartExceptionOCCError, e.GetMessageString()); + } + auto newLeader = DrawLeaderLine::makeLeader(dvp, pointList, iStartSymbol, iEndSymbol); + + // return the new leader as DrawLeaderPy + return Py::asObject(new DrawLeaderLinePy(newLeader)); + } + }; PyObject* initModule() diff --git a/src/Mod/TechDraw/App/CMakeLists.txt b/src/Mod/TechDraw/App/CMakeLists.txt index 0f33bcb55d..d141eac135 100644 --- a/src/Mod/TechDraw/App/CMakeLists.txt +++ b/src/Mod/TechDraw/App/CMakeLists.txt @@ -174,6 +174,8 @@ SET(TechDraw_SRCS XMLQuery.h LineGenerator.cpp LineGenerator.h + LineFormat.cpp + LineFormat.h ) SET(Geometry_SRCS diff --git a/src/Mod/TechDraw/App/CenterLine.cpp b/src/Mod/TechDraw/App/CenterLine.cpp index 1f24e57d43..7c32a01389 100644 --- a/src/Mod/TechDraw/App/CenterLine.cpp +++ b/src/Mod/TechDraw/App/CenterLine.cpp @@ -885,10 +885,10 @@ void CenterLine::Save(Base::Writer &writer) const // style is deprecated in favour of line number, but we still save and restore it // to avoid problems with old documents. - writer.Stream() << writer.ind() << "