[TD]Long and link dim refs (fix #13375) (#18641)

* [Meas]Changes for TD dimension refs for links

* [TD]App changes for dim refs to links

* [TD]Gui changes for dim refs to links

* [TD]fix 2 lint messages

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
WandererFan
2024-12-23 17:36:22 -05:00
committed by GitHub
parent a13ecd87db
commit f144a87539
16 changed files with 1092 additions and 198 deletions

View File

@@ -44,7 +44,7 @@
// // reference
// replace(ref, newRef)
// else:
// // auto correct phase 2
// // auto correct phase 2 - to be implemented
// // we don't have any geometry that is identical to our saved geometry.
// // finding a match now becomes guess work. we have to find the most
// // similar geometry (with at least some level of same-ness) and use
@@ -68,6 +68,7 @@
#include <Base/Tools.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Measure/App/ShapeFinder.h>
#include "GeometryMatcher.h"
#include "DimensionReferences.h"
@@ -77,6 +78,7 @@
#include "Preferences.h"
using namespace TechDraw;
using namespace Measure;
using DU = DrawUtil;
//! true if references point to valid geometry and the valid geometry matches the
@@ -173,17 +175,17 @@ bool DimensionAutoCorrect::autocorrectReferences(std::vector<bool>& referenceSta
continue;
}
// we did not find an exact match, so check for an similar match
// we did not find an exact match, so check for a similar match
success = fix1GeomSimilar(fixedRef, savedGeometry.at(iRef).getShape());
if (success) {
// we did find an similar match
// we did find a similar match
referenceState.at(iRef) = true;
repairedRefs.push_back(fixedRef);
iRef++;
continue;
}
// we did not find an similar match the geometry
// we did not find a similar match the geometry
result = false;
referenceState.at(iRef) = false;
repairedRefs.push_back(fixedRef);
@@ -289,7 +291,8 @@ bool DimensionAutoCorrect::findExactEdge2d(ReferenceEntry& refToFix, const Part:
return true;
}
}
// no match
// no match, return the input reference
return false;
}
@@ -413,8 +416,16 @@ bool DimensionAutoCorrect::findSimilarEdge3d(ReferenceEntry& refToFix,
bool DimensionAutoCorrect::isMatchingGeometry(const ReferenceEntry& ref,
const Part::TopoShape& savedGeometry) const
{
// Base::Console().Message("DAC::isMatchingGeometry()\n");
Part::TopoShape temp = ref.asCanonicalTopoShape();
Part::TopoShape temp;
if (ref.is3d()) {
auto shape3d = ShapeFinder::getLocatedShape(*ref.getObject(), ref.getSubName(true));
temp = Part::TopoShape(shape3d);
} else {
auto shape2d = ref.getGeometry();
temp = Part::TopoShape(shape2d);
}
if (temp.isNull()) {
// this shouldn't happen as we already know that this ref points to valid geometry
return false;
@@ -435,7 +446,7 @@ ReferenceEntry DimensionAutoCorrect::searchObjForVert(App::DocumentObject* obj,
bool exact) const
{
(void)exact;
auto shape3d = Part::Feature::getShape(obj);
auto shape3d = ShapeFinder::getLocatedShape(*obj, "");
if (shape3d.IsNull()) {
// how to handle this?
return {};
@@ -443,7 +454,7 @@ ReferenceEntry DimensionAutoCorrect::searchObjForVert(App::DocumentObject* obj,
auto vertsAll = getDimension()->getVertexes(shape3d);
size_t iVert {1};
for (auto& vert : vertsAll) {
bool isSame = getMatcher()->compareGeometry(vert, refVertex);
bool isSame = getMatcher()->compareGeometry(refVertex, vert);
if (isSame) {
auto newSubname = std::string("Vertex") + std::to_string(iVert);
return {obj, newSubname, getDimension()->getDocument()};