[TD]initial implementation of cosmetic cicle command
This commit is contained in:
@@ -73,6 +73,16 @@
|
||||
<UserDocu>tag = makeCosmeticCircleArc(center, radius, start, end) - add a CosmeticEdge at center with radius radius(View coordinates) from start angle to end angle. Returns tag of new CosmeticEdge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeCosmeticCircle3d">
|
||||
<Documentation>
|
||||
<UserDocu>tag = makeCosmeticCircle3d(center, radius) - add a CosmeticEdge at center (3d point) with radius. Returns tag of new CosmeticEdge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="makeCosmeticCircleArc3d">
|
||||
<Documentation>
|
||||
<UserDocu>tag = makeCosmeticCircleArc3d(center, radius, start, end) - add a CosmeticEdge at center (3d point) with radius from start angle to end angle. Returns tag of new CosmeticEdge.</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="getCosmeticEdge">
|
||||
<Documentation>
|
||||
<UserDocu>ce = getCosmeticEdge(id) - returns CosmeticEdge with unique id.</UserDocu>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -423,7 +423,7 @@ bool BaseGeom::closed()
|
||||
// return a BaseGeom similar to this, but inverted with respect to Y axis
|
||||
BaseGeomPtr BaseGeom::inverted()
|
||||
{
|
||||
Base::Console().Message("BG::inverted()\n");
|
||||
// Base::Console().Message("BG::inverted()\n");
|
||||
TopoDS_Shape invertedShape = ShapeUtils::invertGeometry(occEdge);
|
||||
TopoDS_Edge invertedEdge = TopoDS::Edge(invertedShape);
|
||||
return baseFactory(invertedEdge);
|
||||
|
||||
@@ -147,6 +147,11 @@ class TechDrawExport BaseGeom : public std::enable_shared_from_this<BaseGeom>
|
||||
void setCosmeticTag(std::string t) { cosmeticTag = t; }
|
||||
Part::TopoShape asTopoShape(double scale);
|
||||
|
||||
virtual double getStartAngle() { return 0.0; }
|
||||
virtual double getEndAngle() { return 0.0; }
|
||||
virtual bool clockwiseAngle() { return false; }
|
||||
virtual void clockwiseAngle(bool direction) { (void) direction; }
|
||||
|
||||
protected:
|
||||
void createNewTag();
|
||||
|
||||
@@ -217,6 +222,10 @@ class TechDrawExport AOE: public Ellipse
|
||||
~AOE() override = default;
|
||||
|
||||
public:
|
||||
double getStartAngle() override { return startAngle; }
|
||||
double getEndAngle() override { return endAngle; }
|
||||
bool clockwiseAngle() override { return cw; }
|
||||
void clockwiseAngle(bool direction) override { cw = direction; }
|
||||
Base::Vector3d startPnt; //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
|
||||
Base::Vector3d endPnt;
|
||||
Base::Vector3d midPnt;
|
||||
@@ -241,6 +250,11 @@ class TechDrawExport AOC: public Circle
|
||||
~AOC() override = default;
|
||||
|
||||
public:
|
||||
double getStartAngle() override { return startAngle; }
|
||||
double getEndAngle() override { return endAngle; }
|
||||
bool clockwiseAngle() override { return cw; }
|
||||
void clockwiseAngle(bool direction) override { cw = direction; }
|
||||
|
||||
std::string toString() const override;
|
||||
void Save(Base::Writer& w) const override;
|
||||
void Restore(Base::XMLReader& r) override;
|
||||
@@ -284,6 +298,9 @@ class TechDrawExport BSpline: public BaseGeom
|
||||
~BSpline() override = default;
|
||||
|
||||
public:
|
||||
double getStartAngle() override { return startAngle; }
|
||||
double getEndAngle() override { return endAngle; }
|
||||
|
||||
Base::Vector3d startPnt;
|
||||
Base::Vector3d endPnt;
|
||||
Base::Vector3d midPnt;
|
||||
|
||||
Reference in New Issue
Block a user