Skip to content

Commit

Permalink
[TD]makeCosmeticLine Y inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jul 12, 2020
1 parent 83f34a1 commit 0ab224b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 33 deletions.
28 changes: 18 additions & 10 deletions src/Mod/TechDraw/App/Cosmetic.cpp
Expand Up @@ -346,13 +346,14 @@ CosmeticEdge::CosmeticEdge()
initialize();
}

//TODO: set permaStart/permaEnd in ctors. Need scale.
CosmeticEdge::CosmeticEdge(CosmeticEdge* ce)
{
// Base::Console().Message("CE::CE(ce)\n");
TechDraw::BaseGeom* newGeom = ce->m_geometry->copy();
//these endpoints are already YInverted
permaStart = ce->permaStart;
permaEnd = ce->permaEnd;
permaEnd = ce->permaEnd;
permaRadius = ce->permaRadius;
m_geometry = newGeom;
m_format = ce->m_format;
initialize();
Expand All @@ -376,8 +377,16 @@ CosmeticEdge::CosmeticEdge(TopoDS_Edge e)
{
// Base::Console().Message("CE::CE(TopoDS_Edge)\n");
m_geometry = TechDraw::BaseGeom::baseFactory(e);
//we assume input edge is already in Yinverted coordinates
permaStart = m_geometry->getStartPoint();
permaEnd = m_geometry->getEndPoint();
if ((m_geometry->geomType == TechDraw::GeomType::CIRCLE) ||
(m_geometry->geomType == TechDraw::GeomType::ARCOFCIRCLE) ) {
TechDraw::Circle* circ = static_cast<TechDraw::Circle*>(m_geometry);
permaStart = circ->center;
permaEnd = circ->center;
permaRadius = circ->radius;
}
initialize();
}

Expand All @@ -387,6 +396,13 @@ CosmeticEdge::CosmeticEdge(TechDraw::BaseGeom* g)
m_geometry = g;
permaStart = m_geometry->getStartPoint();
permaEnd = m_geometry->getEndPoint();
if ((g->geomType == TechDraw::GeomType::CIRCLE) ||
(g->geomType == TechDraw::GeomType::ARCOFCIRCLE)) {
TechDraw::Circle* circ = static_cast<TechDraw::Circle*>(g);
permaStart = circ->center;
permaEnd = circ->center;
permaRadius = circ->radius;
}
initialize();
}

Expand All @@ -408,14 +424,6 @@ void CosmeticEdge::initialize(void)
m_geometry->setCosmeticTag(getTagAsString());
}

//why is this needed? isn't permaxxxx always unscaled??
//void CosmeticEdge::unscaleEnds(double scale)
//{
// permaStart = permaStart / scale;
// permaEnd = permaEnd / scale;
// permaRadius = permaRadius / scale;
//}

TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
{
TechDraw::BaseGeom* newGeom = nullptr;
Expand Down
23 changes: 0 additions & 23 deletions src/Mod/TechDraw/App/DrawViewPartPyImp.cpp
Expand Up @@ -193,7 +193,6 @@ PyObject* DrawViewPartPy::makeCosmeticVertex3d(PyObject *args)
//get by unique tag
PyObject* DrawViewPartPy::getCosmeticVertex(PyObject *args)
{
// Base::Console().Message("DVPP::getCosmeticVertex()\n");
PyObject* result = nullptr;
char* id; //unique tag
if (!PyArg_ParseTuple(args, "s", &id)) {
Expand All @@ -212,7 +211,6 @@ PyObject* DrawViewPartPy::getCosmeticVertex(PyObject *args)
//get by selection name
PyObject* DrawViewPartPy::getCosmeticVertexBySelection(PyObject *args)
{
// Base::Console().Message("DVPP::getCosmeticVertexBySelection()\n");
PyObject* result = nullptr;
char* selName; //Selection routine name - "Vertex0"
if (!PyArg_ParseTuple(args, "s", &selName)) {
Expand All @@ -231,7 +229,6 @@ PyObject* DrawViewPartPy::getCosmeticVertexBySelection(PyObject *args)

PyObject* DrawViewPartPy::removeCosmeticVertex(PyObject *args)
{
// Base::Console().Message("DVPP::removeCosmeticVertex()\n");
DrawViewPart* dvp = getDrawViewPartPtr();
if (dvp == nullptr) {
return Py_None;
Expand Down Expand Up @@ -285,17 +282,6 @@ PyObject* DrawViewPartPy::replaceCosmeticVertex(PyObject *args)
Base::Console().Message("DVPP::replaceCosmeticVertex() - deprecated. do not use.\n");
return PyBool_FromLong(0l);

// PyObject* pNewCV = nullptr;
// if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CosmeticVertexPy::Type), &pNewCV)) {
// throw Py::TypeError("expected (CosmeticVertex)");
// }
// DrawViewPart* dvp = getDrawViewPartPtr();
// TechDraw::CosmeticVertexPy* cvPy = static_cast<TechDraw::CosmeticVertexPy*>(pNewCV);
// TechDraw::CosmeticVertex* cv = cvPy->getCosmeticVertexPtr();
// bool result = dvp->replaceCosmeticVertex(cv);
// dvp->refreshCVGeoms();
// dvp->requestPaint();
// return PyBool_FromLong((long) result);
}


Expand All @@ -318,14 +304,11 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
}

DrawViewPart* dvp = getDrawViewPartPtr();
//points inverted in addCosmeticEdge(p1, p2)
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
Base::Vector3d pnt2 = static_cast<Base::VectorPy*>(pPnt2)->value();
std::string newTag = dvp->addCosmeticEdge(pnt1, pnt2);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
if (ce != nullptr) {
ce->permaStart = pnt1;
ce->permaEnd = pnt2;
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
Expand All @@ -348,8 +331,6 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(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();
Expand All @@ -368,8 +349,6 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
std::string newTag = dvp->addCosmeticEdge(bg);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
if (ce != nullptr) {
ce->permaStart = pnt1;
ce->permaEnd = pnt1;
ce->permaRadius = radius;
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
Expand Down Expand Up @@ -413,8 +392,6 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
std::string newTag = dvp->addCosmeticEdge(bg);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdge(newTag);
if (ce != nullptr) {
ce->permaStart = pnt1;
ce->permaEnd = pnt1;
ce->permaRadius = radius;
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
Expand Down

0 comments on commit 0ab224b

Please sign in to comment.