[TD]draw line through 2 points

This commit is contained in:
wandererfan
2020-08-17 19:34:40 -04:00
committed by WandererFan
parent 1a6bbf8127
commit 1cad17c5f5
12 changed files with 1169 additions and 5 deletions

View File

@@ -327,6 +327,53 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
return PyUnicode_FromString(newTag.c_str()); //return tag for new CE
}
PyObject* DrawViewPartPy::makeCosmeticLine3D(PyObject *args)
{
PyObject* pPnt1 = nullptr;
PyObject* pPnt2 = nullptr;
int style = LineFormat::getDefEdgeStyle();
double weight = LineFormat::getDefEdgeWidth();
App::Color defCol = LineFormat::getDefEdgeColor();
PyObject* pColor = nullptr;
if (!PyArg_ParseTuple(args, "O!O!|idO", &(Base::VectorPy::Type), &pPnt1,
&(Base::VectorPy::Type), &pPnt2,
&style, &weight,
&pColor)) {
throw Py::TypeError("expected (vector, vector,[style,weight,color])");
}
DrawViewPart* dvp = getDrawViewPartPtr();
Base::Vector3d centroid = dvp->getOriginalCentroid();
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
pnt1 = pnt1 - centroid;
pnt1 = DrawUtil::invertY(dvp->projectPoint(pnt1));
Base::Vector3d pnt2 = static_cast<Base::VectorPy*>(pPnt2)->value();
pnt2 = pnt2 - centroid;
pnt2 = DrawUtil::invertY(dvp->projectPoint(pnt2));
std::string newTag = dvp->addCosmeticEdge(pnt1, pnt2);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
if (ce != nullptr) {
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
ce->m_format.m_color = defCol;
} else {
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
}
} else {
std::string msg = "DVPPI:makeCosmeticLine - line creation failed";
Base::Console().Message("%s\n",msg.c_str());
throw Py::RuntimeError(msg);
}
//int link =
dvp->add1CEToGE(newTag);
dvp->requestPaint();
return PyUnicode_FromString(newTag.c_str()); //return tag for new CE
}
PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
{
PyObject* pPnt1 = nullptr;