[TD]fix location of CV on rotated views

This commit is contained in:
wandererfan
2023-12-22 11:12:10 -05:00
committed by WandererFan
parent a146977198
commit 023dd8ed8a
12 changed files with 155 additions and 69 deletions

View File

@@ -71,6 +71,7 @@
#include "GeometryObject.h"
#include "ProjectionAlgos.h"
#include "TechDrawExport.h"
#include "CosmeticVertexPy.h"
namespace TechDraw {
@@ -185,7 +186,10 @@ public:
);
add_varargs_method("build3dCurves", &Module::build3dCurves,
"TopoShape = build3dCurves(TopoShape) -- convert the edges to a 3D curve\n"
"which is useful for shapes obtained Part.HLRBRep.Algo"
"which is useful for shapes obtained Part.HLRBRep.Algo"
);
add_varargs_method("makeCanonicalPoint", &Module::makeCanonicalPoint,
"makeCanonicalPoint(DrawViewPart, Vector3d) - Returns the unscaled, unrotated version of the input point)"
);
initialize("This is a module for making drawings"); // register with Python
}
@@ -1234,14 +1238,14 @@ private:
PyObject *pcObjShape(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "O!",
&(TopoShapePy::Type), &pcObjShape))
&(TopoShapePy::Type), &pcObjShape))
throw Py::Exception();
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
SVGOutput output;
Py::String result(output.exportEdges(pShape->getTopoShapePtr()->getShape()));
SVGOutput output;
Py::String result(output.exportEdges(pShape->getTopoShapePtr()->getShape()));
return result;
return result;
}
Py::Object build3dCurves(const Py::Tuple& args)
@@ -1249,15 +1253,34 @@ private:
PyObject *pcObjShape(nullptr);
if (!PyArg_ParseTuple(args.ptr(), "O!",
&(TopoShapePy::Type), &pcObjShape))
&(TopoShapePy::Type), &pcObjShape))
throw Py::Exception();
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObjShape);
const TopoShape& nShape =
TechDraw::build3dCurves(pShape->getTopoShapePtr()->getShape());
return Py::Object(new TopoShapePy(new TopoShape(nShape)));
const TopoShape& nShape =
TechDraw::build3dCurves(pShape->getTopoShapePtr()->getShape());
return Py::Object(new TopoShapePy(new TopoShape(nShape)));
}
Py::Object makeCanonicalPoint(const Py::Tuple& args)
{
PyObject* pyDocObj{nullptr};
PyObject* pyPointIn{nullptr};
PyObject *pyUnscale{Py_True};
if (!PyArg_ParseTuple(args.ptr(), "O!O!|O", &(TechDraw::DrawViewPartPy::Type), &pyDocObj,
&(Base::VectorPy::Type), &pyPointIn, &pyUnscale)) {
return Py::None();
}
bool unscale = pyUnscale == Py_True ? true : false;
DrawViewPartPy* pyDvp = static_cast<TechDraw::DrawViewPartPy*>(pyDocObj);
DrawViewPart* dvp = pyDvp->getDrawViewPartPtr();
Base::Vector3d cPoint = static_cast<Base::VectorPy*>(pyPointIn)->value();
cPoint = CosmeticVertex::makeCanonicalPoint(dvp, cPoint, unscale);
return Py::asObject(new Base::VectorPy(cPoint));
}
};
PyObject* initModule()