[TD]initial implementation of cosmetic cicle command
This commit is contained in:
@@ -388,9 +388,9 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
}
|
||||
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
Base::Vector3d pnt1 = DrawUtil::invertY(static_cast<Base::VectorPy*>(pPnt1)->value());
|
||||
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
|
||||
TechDraw::BaseGeomPtr bg = std::make_shared<TechDraw::Circle> (pnt1, radius);
|
||||
std::string newTag = dvp->addCosmeticEdge(bg);
|
||||
std::string newTag = dvp->addCosmeticEdge(bg->inverted());
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
|
||||
if (ce) {
|
||||
ce->permaRadius = radius;
|
||||
@@ -428,9 +428,97 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
|
||||
//from here on is almost duplicate of makeCosmeticCircle
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
Base::Vector3d pnt1 = DrawUtil::invertY(static_cast<Base::VectorPy*>(pPnt1)->value());
|
||||
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
|
||||
TechDraw::BaseGeomPtr bg = std::make_shared<TechDraw::AOC> (pnt1, radius, angle1, angle2);
|
||||
std::string newTag = dvp->addCosmeticEdge(bg);
|
||||
std::string newTag = dvp->addCosmeticEdge(bg->inverted());
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
|
||||
if (ce) {
|
||||
ce->permaRadius = radius;
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
if (!pColor)
|
||||
ce->m_format.m_color = defCol;
|
||||
else
|
||||
ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor);
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_RuntimeError, "DVPPI:makeCosmeticCircleArc - arc creation failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//int link =
|
||||
dvp->add1CEToGE(newTag);
|
||||
dvp->requestPaint();
|
||||
|
||||
return PyUnicode_FromString(newTag.c_str()); //return tag for new CE
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticCircle3d(PyObject *args)
|
||||
{
|
||||
PyObject* pPnt1 = nullptr;
|
||||
double radius = 5.0;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!d|idO!", &(Base::VectorPy::Type), &pPnt1,
|
||||
&radius,
|
||||
&style, &weight,
|
||||
&PyTuple_Type, &pColor)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
|
||||
// center, project and invert the 3d point
|
||||
Base::Vector3d centroid = dvp->getOriginalCentroid();
|
||||
pnt1 = DrawUtil::invertY(dvp->projectPoint(pnt1 - centroid));
|
||||
TechDraw::BaseGeomPtr bg = std::make_shared<TechDraw::Circle> (pnt1, radius);
|
||||
std::string newTag = dvp->addCosmeticEdge(bg->inverted());
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
|
||||
if (ce) {
|
||||
ce->permaRadius = radius;
|
||||
ce->m_format.m_style = style;
|
||||
ce->m_format.m_weight = weight;
|
||||
ce->m_format.m_color = pColor ? DrawUtil::pyTupleToColor(pColor) : defCol;
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_RuntimeError, "DVPPI:makeCosmeticCircle - circle creation failed");
|
||||
return nullptr;
|
||||
}
|
||||
//int link =
|
||||
dvp->add1CEToGE(newTag);
|
||||
dvp->requestPaint();
|
||||
|
||||
return PyUnicode_FromString(newTag.c_str()); //return tag for new CE
|
||||
}
|
||||
|
||||
PyObject* DrawViewPartPy::makeCosmeticCircleArc3d(PyObject *args)
|
||||
{
|
||||
PyObject* pPnt1 = nullptr;
|
||||
double radius = 5.0;
|
||||
double angle1 = 0.0;
|
||||
double angle2 = 360.0;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!ddd|idO!", &(Base::VectorPy::Type), &pPnt1,
|
||||
&radius, &angle1, &angle2,
|
||||
&style, &weight, &PyTuple_Type, &pColor)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//from here on is almost duplicate of makeCosmeticCircle
|
||||
DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
|
||||
// center, project and invert the 3d point
|
||||
Base::Vector3d centroid = dvp->getOriginalCentroid();
|
||||
pnt1 = DrawUtil::invertY(dvp->projectPoint(pnt1 - centroid));
|
||||
TechDraw::BaseGeomPtr bg = std::make_shared<TechDraw::AOC> (pnt1, radius, angle1, angle2);
|
||||
std::string newTag = dvp->addCosmeticEdge(bg->inverted());
|
||||
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
|
||||
if (ce) {
|
||||
ce->permaRadius = radius;
|
||||
|
||||
Reference in New Issue
Block a user