diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index 01f3aea3f9..f71fb3cb33 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -802,17 +802,24 @@ TechDraw::BaseGeom* CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFeat) TechDraw::BaseGeom* newGeom = nullptr; Base::Vector3d p1 = ends.first; Base::Vector3d p2 = ends.second; - gp_Pnt gp1(p1.x,p1.y,p1.z); - gp_Pnt gp2(p2.x,p2.y,p2.z); - TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2); - TopoDS_Shape s = TechDraw::scaleShape(e, scale); - TopoDS_Edge newEdge = TopoDS::Edge(s); - newGeom = TechDraw::BaseGeom::baseFactory(newEdge); - newGeom->classOfEdge = ecHARD; - newGeom->hlrVisible = true; - newGeom->cosmetic = true; - newGeom->source(CENTERLINE); - newGeom->setCosmeticTag(getTagAsString()); + if (!p1.IsEqual(p2, 0.00001)) { + gp_Pnt gp1(p1.x,p1.y,p1.z); + gp_Pnt gp2(p2.x,p2.y,p2.z); + TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2); + TopoDS_Shape s = TechDraw::scaleShape(e, scale); + TopoDS_Edge newEdge = TopoDS::Edge(s); + newGeom = TechDraw::BaseGeom::baseFactory(newEdge); + newGeom->classOfEdge = ecHARD; + newGeom->hlrVisible = true; + newGeom->cosmetic = true; + newGeom->source(CENTERLINE); + newGeom->setCosmeticTag(getTagAsString()); + } else { + Base::Console().Warning("Centerline endpoints are equal. Could not draw.\n"); + //what to do here? //return current geom? + return m_geometry; + } + return newGeom; } diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index d75fd99173..903c6952ff 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -185,6 +185,7 @@ void TaskCenterLine::setUiPrimary() ui->rbAligned->setEnabled(false); else ui->rbAligned->setEnabled(true); + if (m_type == 1) // only if line, feature is enabled ui->cbFlip->setEnabled(true); else @@ -238,6 +239,7 @@ void TaskCenterLine::setUiEdit() ui->cbFlip->setChecked(true); else ui->cbFlip->setChecked(false); + if (m_cl->m_type == 1) // only if line, feature is enabled ui->cbFlip->setEnabled(true); else @@ -264,14 +266,16 @@ void TaskCenterLine::createCenterLine(void) m_mode = CenterLine::CLMODE::ALIGNED; } + bool flip = ui->cbFlip->isChecked(); TechDraw::CenterLine* cl = CenterLine::CenterLineBuilder(m_partFeat, m_subNames, - m_mode); + m_mode, + flip); if (cl != nullptr) { cl->setShifts(hShift, vShift); cl->setExtend(extendBy); cl->setRotate(rotate); - cl->m_flip2Line = ui->cbFlip->checkState(); + cl->m_flip2Line = ui->cbFlip->isChecked(); App::Color ac; ac.setValue(ui->cpLineColor->color()); cl->m_format.m_color = ac; @@ -310,7 +314,7 @@ void TaskCenterLine::updateCenterLine(void) m_cl->m_hShift = ui->qsbHorizShift->rawValue(); m_cl->m_extendBy = ui->qsbExtend->rawValue(); m_cl->m_type = m_type; - m_cl->m_flip2Line = ui->cbFlip->checkState(); + m_cl->m_flip2Line = ui->cbFlip->isChecked(); m_partFeat->replaceCenterLine(m_cl); m_partFeat->refreshCLGeoms(); m_partFeat->requestPaint();