diff --git a/src/Mod/TechDraw/Gui/CommandHelpers.cpp b/src/Mod/TechDraw/Gui/CommandHelpers.cpp index 45ab2af998..44ee90a48d 100644 --- a/src/Mod/TechDraw/Gui/CommandHelpers.cpp +++ b/src/Mod/TechDraw/Gui/CommandHelpers.cpp @@ -70,26 +70,6 @@ TechDraw::DrawView* CommandHelpers::firstViewInSelection(Gui::Command* cmd) return baseView; } -//! find the first DrawView in the current selection for use as a base view (owner) -TechDraw::DrawView* CommandHelpers::firstNonSpreadsheetInSelection(Gui::Command* cmd) -{ - std::vector selection = cmd->getSelection().getSelectionEx(); - TechDraw::DrawView* baseView{nullptr}; - if (!selection.empty()) { - for (auto& selobj : selection) { - if (selobj.getObject()->isDerivedFrom()) { - continue; - } else { - auto docobj = selobj.getObject(); - baseView = static_cast(docobj); - break; - } - } - } - return baseView; -} - - std::vector CommandHelpers::getSelectedSubElements(Gui::Command* cmd, TechDraw::DrawViewPart* &dvp, std::string subType) @@ -129,83 +109,6 @@ std::vector CommandHelpers::getSelectedSubElements(Gui::Command* cm return selectedSubs; } -//! extract the selected shapes and xShapes and determine if a face has been -//! selected to define the projection direction -void CommandHelpers::getSelectedShapes(Gui::Command* cmd, - std::vector& shapes, - std::vector& xShapes, - App::DocumentObject* faceObj, - std::string& faceName) -{ - auto resolve = Gui::ResolveMode::OldStyleElement; - bool single = false; - auto selection = cmd->getSelection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId(), - resolve, single); - for (auto& sel : selection) { - bool is_linked = false; - auto obj = sel.getObject(); - if (obj->isDerivedFrom()) { - continue; - } - if (obj->isDerivedFrom() - || obj->isDerivedFrom() - || obj->isDerivedFrom()) { - is_linked = true; - } - // If parent of the obj is a link to another document, we possibly need to treat non-link obj as linked, too - // 1st, is obj in another document? - if (obj->getDocument() != cmd->getDocument()) { - std::set parents = obj->getInListEx(true); - for (auto& parent : parents) { - // Only consider parents in the current document, i.e. possible links in this View's document - if (parent->getDocument() != cmd->getDocument()) { - continue; - } - // 2nd, do we really have a link to obj? - if (parent->isDerivedFrom() - || parent->isDerivedFrom() - || parent->isDerivedFrom()) { - // We have a link chain from this document to obj, and obj is in another document -> it is an XLink target - is_linked = true; - } - } - } - if (is_linked) { - xShapes.push_back(obj); - continue; - } - //not a Link and not null. assume to be drawable. Undrawables will be - // skipped later. - shapes.push_back(obj); - if (faceObj) { - continue; - } - //don't know if this works for an XLink - for (auto& sub : sel.getSubNames()) { - if (TechDraw::DrawUtil::getGeomTypeFromName(sub) == "Face") { - faceName = sub; - // - faceObj = obj; - break; - } - } - } -} - - -std::pair CommandHelpers::viewDirection() -{ - if (!Preferences::useCameraDirection()) { - return { Base::Vector3d(0, -1, 0), Base::Vector3d(1, 0, 0) }; - } - - auto faceInfo = faceFromSelection(); - if (faceInfo.first) { - return DrawGuiUtil::getProjDirFromFace(faceInfo.first, faceInfo.second); - } - - return DrawGuiUtil::get3DDirAndRot(); -} std::pair CommandHelpers::faceFromSelection() { diff --git a/src/Mod/TechDraw/Gui/CommandHelpers.h b/src/Mod/TechDraw/Gui/CommandHelpers.h index ed86dbefae..ac854f45bc 100644 --- a/src/Mod/TechDraw/Gui/CommandHelpers.h +++ b/src/Mod/TechDraw/Gui/CommandHelpers.h @@ -47,7 +47,6 @@ class DrawView; class DrawViewPart; namespace CommandHelpers { - TechDraw::DrawView* firstViewInSelection(Gui::Command* cmd); TechDraw::DrawView* firstNonSpreadsheetInSelection(Gui::Command* cmd); @@ -55,14 +54,8 @@ std::vector getSelectedSubElements(Gui::Command* cmd, TechDraw::DrawViewPart* &dvp, std::string subType = "Edge"); -void getSelectedShapes(Gui::Command* cmd, - std::vector& shapes, - std::vector& xShapes, - App::DocumentObject* faceObj, - std::string& faceName); std::pair faceFromSelection(); -std::pair viewDirection(); } // end namespace CommandHelpers diff --git a/src/Mod/TechDraw/Gui/PATPathMaker.cpp b/src/Mod/TechDraw/Gui/PATPathMaker.cpp index 7bca467518..076d297492 100644 --- a/src/Mod/TechDraw/Gui/PATPathMaker.cpp +++ b/src/Mod/TechDraw/Gui/PATPathMaker.cpp @@ -115,37 +115,6 @@ QGraphicsPathItem* PATPathMaker::simpleLine(TechDraw::BaseGeomPtr base) } -//! make a fragment (length = remain) of a dashed line, with pattern starting at +offset -QGraphicsPathItem* PATPathMaker::geomToStubbyLine(TechDraw::BaseGeomPtr base, double remain, LineSet& ls) -{ - QGraphicsPathItem* fillItem = new QGraphicsPathItem(m_parent); - Base::Vector3d start(base->getStartPoint().x, - base->getStartPoint().y, - 0.0); - Base::Vector3d end(base->getEndPoint().x, - base->getEndPoint().y, - 0.0); - double origLen = (end - start).Length(); - - double appRemain = Rez::appX(remain); - Base::Vector3d newEnd = start + (ls.getUnitDir() * appRemain); - - double newLen = (newEnd - start).Length(); - - if (newLen > origLen) { - newEnd = end; - } - - double offset = Rez::guiX(m_fillScale * ls.getDashSpec().length()) - remain; - - fillItem->setPath(dashedPPath(offsetDash(decodeDashSpec(ls.getDashSpec()), offset), - Rez::guiX(start), - Rez::guiX(newEnd))); - m_fillItems.push_back(fillItem); - return fillItem; -} - - //! convert from mm to scene units std::vector PATPathMaker::decodeDashSpec(DashSpec patDash) { @@ -257,18 +226,3 @@ std::vector PATPathMaker::offsetDash(const std::vector dashPatte return result; } - -//! find remaining length of a dash pattern after offset -double PATPathMaker::dashRemain(const std::vector dashPattern, const double offset) -{ - double length = 0.0; - for (auto& d: dashPattern) { - length += fabs(d); - } - if (offset > length) { - return 0.0; - } - return length - offset; -} - - diff --git a/src/Mod/TechDraw/Gui/PATPathMaker.h b/src/Mod/TechDraw/Gui/PATPathMaker.h index d775f22449..ced1214845 100644 --- a/src/Mod/TechDraw/Gui/PATPathMaker.h +++ b/src/Mod/TechDraw/Gui/PATPathMaker.h @@ -45,17 +45,15 @@ public: void setPen(QPen pen) { m_pen = pen; } QPen getPen() { return m_pen; } void setParent(QGraphicsItem* parent) { m_parent = parent; } - + void lineSetToFillItems(TechDraw::LineSet& ls); protected: QGraphicsPathItem* geomToLine(TechDraw::BaseGeomPtr base, TechDraw::LineSet& ls); QGraphicsPathItem* simpleLine(TechDraw::BaseGeomPtr base); - QGraphicsPathItem* geomToStubbyLine(TechDraw::BaseGeomPtr base, double offset, TechDraw::LineSet& ls); QGraphicsPathItem* lineFromPoints(Base::Vector3d start, Base::Vector3d end, TechDraw::DashSpec ds); std::vector offsetDash(const std::vector dv, const double offset); QPainterPath dashedPPath(const std::vector dv, const Base::Vector3d start, const Base::Vector3d end); - double dashRemain(const std::vector dv, const double offset); double calcOffset(TechDraw::BaseGeomPtr g, TechDraw::LineSet ls); std::vector decodeDashSpec(TechDraw::DashSpec d);