[TD]Fix section snapping (fix #15961) (#15450)

* [TD]Add view snapping preferences

* [TD]fix section snapping algo

- snap sections to section normal line.
- snap views to other views in X&Y

* [TD]fix snapping to ProjectionGroups
This commit is contained in:
WandererFan
2024-09-02 12:41:25 -04:00
committed by GitHub
parent 57cf34828b
commit 140bcf605e
12 changed files with 404 additions and 119 deletions

View File

@@ -80,6 +80,7 @@
#include <Base/Console.h>
#include <Base/FileInfo.h>
#include <Base/Parameter.h>
#include <Base/Tools.h>
#include <Mod/Part/App/PartFeature.h>
@@ -1152,21 +1153,15 @@ gp_Ax2 DrawViewSection::getSectionCS() const
return sectionCS;
}
gp_Ax2 DrawViewSection::getProjectionCS(const Base::Vector3d pt) const
//! return the center of the shape resulting from the cut operation
Base::Vector3d DrawViewSection::getCutCentroid() const
{
Base::Vector3d vNormal = SectionNormal.getValue();
gp_Dir gNormal(vNormal.x, vNormal.y, vNormal.z);
Base::Vector3d vXDir = getXDirection();
gp_Dir gXDir(vXDir.x, vXDir.y, vXDir.z);
if (DrawUtil::fpCompare(fabs(gNormal.Dot(gXDir)), 1.0)) {
// can not build a gp_Ax2 from these values
throw Base::RuntimeError(
"DVS::getProjectionCS - SectionNormal and XDirection are parallel");
}
gp_Pnt gOrigin(pt.x, pt.y, pt.z);
return {gOrigin, gNormal, gXDir};
gp_Pnt inputCenter = ShapeUtils::findCentroid(m_cutPieces, getProjectionCS());
return Base::Vector3d(inputCenter.X(), inputCenter.Y(), inputCenter.Z());
}
std::vector<LineSet> DrawViewSection::getDrawableLines(int i)
{
// Base::Console().Message("DVS::getDrawableLines(%d) - lineSets: %d\n", i, m_lineSets.size());