| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| |
|
| | # include <BRepBuilderAPI_MakeEdge.hxx>
|
| |
|
| | #include <Base/PyWrapParseTupleAndKeywords.h>
|
| |
|
| | #include "CosmeticEdgePy.h"
|
| | #include "CosmeticEdgePy.cpp"
|
| | #include "Cosmetic.h"
|
| | #include "DrawUtil.h"
|
| | #include "Geometry.h"
|
| |
|
| |
|
| | using namespace TechDraw;
|
| |
|
| |
|
| | std::string CosmeticEdgePy::representation() const
|
| | {
|
| | std::stringstream ss;
|
| | ss << "<CosmeticEdge object> at " << std::hex << this;
|
| | return ss.str();
|
| |
|
| | }
|
| |
|
| | PyObject *CosmeticEdgePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
|
| | {
|
| |
|
| | PyErr_SetString(PyExc_RuntimeError,
|
| | "You cannot create an instance of the abstract class 'CosmeticEdge'.");
|
| | return nullptr;
|
| | }
|
| |
|
| |
|
| | int CosmeticEdgePy::PyInit(PyObject* , PyObject* )
|
| | {
|
| | return 0;
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | void CosmeticEdgePy::setFormat(Py::Dict arg)
|
| | {
|
| | Py::Tuple dummy;
|
| | Py::TupleN color(Py::Float(0.0), Py::Float(0.0), Py::Float(0.0), Py::Float(0.0));
|
| | int style = 1;
|
| | double weight = 0.5;
|
| | PyObject* pColor = color.ptr();
|
| | PyObject* visible = Py_True;
|
| | static const std::array<const char *, 5> kw{"style", "weight", "color", "visible", nullptr};
|
| | if (!Base::Wrapped_ParseTupleAndKeywords(dummy.ptr(), arg.ptr(), "|idO!O!", kw,
|
| | &style, &weight, &PyTuple_Type, &pColor, &PyBool_Type, &visible)) {
|
| | throw Py::ValueError("Expected {'style':int, 'weight':float, 'color':tuple, 'visible':bool} dict");
|
| | }
|
| |
|
| | TechDraw::LineFormat* format = &(this->getCosmeticEdgePtr()->m_format);
|
| | format->setStyle(style);
|
| | format->setWidth(weight);
|
| | format->setColor(DrawUtil::pyTupleToColor(pColor));
|
| | format->setVisible(Base::asBoolean(visible));
|
| | }
|
| |
|
| | Py::Dict CosmeticEdgePy::getFormat() const
|
| | {
|
| | TechDraw::LineFormat* format= &(this->getCosmeticEdgePtr()->m_format);
|
| | Py::Dict dict;
|
| |
|
| | dict.setItem("style", Py::Long(format->getStyle()));
|
| | dict.setItem("weight", Py::Float(format->getWidth()));
|
| | dict.setItem("color", Py::Tuple(DrawUtil::colorToPyTuple(format->getColor()), true));
|
| | dict.setItem("visible", Py::Boolean(format->getVisible()));
|
| |
|
| | return dict;
|
| | }
|
| |
|
| | Py::String CosmeticEdgePy::getTag() const
|
| | {
|
| | std::string tmp = getCosmeticEdgePtr()->getTagAsString();
|
| | return Py::String(tmp);
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | Py::Vector CosmeticEdgePy::getStart() const
|
| | {
|
| | Base::Vector3d point = getCosmeticEdgePtr()->permaStart;
|
| | point = DrawUtil::invertY(point);
|
| | return Py::Vector(point);
|
| | }
|
| |
|
| | void CosmeticEdgePy::setStart(Py::Vector arg)
|
| | {
|
| | Base::Vector3d pNew = static_cast<Base::Vector3d>(arg);
|
| |
|
| | pNew = DrawUtil::invertY(pNew);
|
| | Base::Vector3d pEnd = getCosmeticEdgePtr()->permaEnd;
|
| | gp_Pnt gp1(pNew.x, pNew.y, pNew.z);
|
| | gp_Pnt gp2(pEnd.x, pEnd.y, pEnd.z);
|
| | TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
|
| |
|
| | getCosmeticEdgePtr()->m_geometry = TechDraw::BaseGeom::baseFactory(e);
|
| | getCosmeticEdgePtr()->permaStart = pNew;
|
| |
|
| | }
|
| |
|
| | Py::Vector CosmeticEdgePy::getEnd() const
|
| | {
|
| | Base::Vector3d point = getCosmeticEdgePtr()->permaEnd;
|
| | point = DrawUtil::invertY(point);
|
| | return Py::Vector(point);
|
| | }
|
| |
|
| | void CosmeticEdgePy::setEnd(Py::Vector arg)
|
| | {
|
| | Base::Vector3d pNew = static_cast<Base::Vector3d>(arg);
|
| |
|
| | pNew = DrawUtil::invertY(pNew);
|
| | Base::Vector3d pStart = getCosmeticEdgePtr()->permaStart;
|
| | gp_Pnt gp1(pNew.x, pNew.y, pNew.z);
|
| | gp_Pnt gp2(pStart.x, pStart.y, pStart.z);
|
| | TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp2, gp1);
|
| |
|
| | getCosmeticEdgePtr()->m_geometry = TechDraw::BaseGeom::baseFactory(e);
|
| | getCosmeticEdgePtr()->permaEnd = pNew;
|
| |
|
| | }
|
| |
|
| | Py::Float CosmeticEdgePy::getRadius() const
|
| | {
|
| | GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
|
| | if ( (gt != GeomType::CIRCLE) &&
|
| | (gt != GeomType::ARCOFCIRCLE) ) {
|
| | throw Py::TypeError("Not a circle. Can not get radius");
|
| | }
|
| | double r = getCosmeticEdgePtr()->permaRadius;
|
| | return Py::Float(r);
|
| | }
|
| |
|
| | void CosmeticEdgePy::setRadius(Py::Float arg)
|
| | {
|
| | GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
|
| | if ( (gt != GeomType::CIRCLE) &&
|
| | (gt != GeomType::ARCOFCIRCLE) ) {
|
| | throw Py::TypeError("Not a circle. Can not set radius");
|
| | }
|
| |
|
| | double r = static_cast<double>(arg);
|
| | getCosmeticEdgePtr()->permaRadius = r;
|
| |
|
| | getCosmeticEdgePtr()->m_geometry =
|
| | std::make_shared<TechDraw::Circle> (getCosmeticEdgePtr()->permaStart, r);
|
| |
|
| | }
|
| |
|
| | Py::Vector CosmeticEdgePy::getCenter() const
|
| | {
|
| | GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
|
| | if ( (gt != GeomType::CIRCLE) &&
|
| | (gt != GeomType::ARCOFCIRCLE) ) {
|
| | throw Py::TypeError("Not a circle. Can not get center");
|
| | }
|
| | Base::Vector3d point = getCosmeticEdgePtr()->permaStart;
|
| | point = DrawUtil::invertY(point);
|
| | return Py::Vector(point);
|
| | }
|
| |
|
| | void CosmeticEdgePy::setCenter(Py::Vector arg)
|
| | {
|
| | GeomType gt = getCosmeticEdgePtr()->m_geometry->getGeomType();
|
| |
|
| | if ( (gt != GeomType::CIRCLE) &&
|
| | (gt != GeomType::ARCOFCIRCLE) ) {
|
| | throw Py::TypeError("Not a circle. Can not set center");
|
| | }
|
| |
|
| | Base::Vector3d pNew = static_cast<Base::Vector3d>(arg);
|
| | pNew = DrawUtil::invertY(pNew);
|
| | auto oldGeom = getCosmeticEdgePtr()->m_geometry;
|
| | TechDraw::CirclePtr oldCircle = std::dynamic_pointer_cast<TechDraw::Circle> (oldGeom);
|
| | if (!oldCircle) {
|
| | throw Py::TypeError("Edge geometry is not a circle");
|
| | }
|
| |
|
| | getCosmeticEdgePtr()->permaStart = pNew;
|
| | getCosmeticEdgePtr()->permaEnd = pNew;
|
| | getCosmeticEdgePtr()->permaRadius = oldCircle->radius;
|
| | getCosmeticEdgePtr()->m_geometry =
|
| | std::make_shared<TechDraw::Circle> (getCosmeticEdgePtr()->permaStart, oldCircle->radius);
|
| |
|
| | }
|
| |
|
| | PyObject *CosmeticEdgePy::getCustomAttributes(const char* ) const
|
| | {
|
| | return nullptr;
|
| | }
|
| |
|
| | int CosmeticEdgePy::setCustomAttributes(const char* , PyObject* )
|
| | {
|
| | return 0;
|
| | }
|
| |
|
| |
|