MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / checkReferences2D

Method checkReferences2D

src/Mod/TechDraw/App/DrawViewDimension.cpp:1660–1699  ·  view source on GitHub ↗

validate 2D references - only checks if the target exists

Source from the content-addressed store, hash-verified

1658
1659//! validate 2D references - only checks if the target exists
1660bool DrawViewDimension::checkReferences2D() const
1661{
1662 const std::vector<App::DocumentObject*>& objects = References2D.getValues();
1663 if (objects.empty()) {
1664 return false;
1665 }
1666
1667 const std::vector<std::string>& subElements = References2D.getSubValues();
1668 if (subElements.empty()) {
1669 // must have at least 1 null string entry to balance DVP
1670 return false;
1671 }
1672
1673 if (subElements.front().empty() && !References3D.getValues().empty()) {
1674 // this is (probably) a dim with 3d refs
1675 return true;
1676 }
1677
1678 for (auto& sub : subElements) {
1679 if (sub.empty()) {
1680 return false;
1681 }
1682
1683 int idx = DrawUtil::getIndexFromName(sub);
1684 if (DrawUtil::getGeomTypeFromName(sub) == "Edge") {
1685 TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx);
1686 if (!geom) {
1687 return false;
1688 }
1689 }
1690 else if (DrawUtil::getGeomTypeFromName(sub) == "Vertex") {
1691 TechDraw::VertexPtr vert = getViewPart()->getProjVertexByIndex(idx);
1692 if (!vert) {
1693 return false;
1694 }
1695 }
1696 }
1697
1698 return true;
1699}
1700
1701//! detect the state where 3d references have been nulled out due to
1702//! object deletion and the reference will need to be rebuilt.

Callers

nothing calls this directly

Calls 6

getSubValuesMethod · 0.80
getGeomByIndexMethod · 0.80
getProjVertexByIndexMethod · 0.80
getValuesMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected