TechDraw: Enable snapping section views to their base views.

This commit is contained in:
PaddleStroke
2024-04-29 12:19:04 +02:00
committed by WandererFan
parent f0ebd62637
commit 127ee90cec
5 changed files with 77 additions and 23 deletions

View File

@@ -932,27 +932,29 @@ std::vector<TechDraw::FacePtr> DrawViewSection::makeTDSectionFaces(TopoDS_Compou
std::pair<Base::Vector3d, Base::Vector3d> DrawViewSection::sectionLineEnds()
{
std::pair<Base::Vector3d, Base::Vector3d> result;
Base::Vector3d stdZ(0.0, 0.0, 1.0);
double baseRotation = getBaseDVP()->Rotation.getValue();// Qt degrees are clockwise
Base::Rotation rotator(stdZ, baseRotation * M_PI / 180.0);
Base::Rotation unrotator(stdZ, -baseRotation * M_PI / 180.0);
Base::Vector3d dir = getSectionDirectionOnBaseView();
Base::Vector3d sectionOrg = SectionOrigin.getValue() - getBaseDVP()->getOriginalCentroid();
sectionOrg = getBaseDVP()->projectPoint(sectionOrg);// convert to base view CS
double halfSize = (getBaseDVP()->getSizeAlongVector(dir) / 2.0) * SectionLineStretch.getValue();
result.first = sectionOrg + dir * halfSize;
result.second = sectionOrg - dir * halfSize;
return result;
}
// calculate the direction of the section in 2d on the base view.
Base::Vector3d DrawViewSection::getSectionDirectionOnBaseView()
{
auto sNorm = SectionNormal.getValue();
auto axis = getBaseDVP()->Direction.getValue();
Base::Vector3d stdOrg(0.0, 0.0, 0.0);
Base::Vector3d sectionLineDir = -axis.Cross(sNorm);
sectionLineDir.Normalize();
sectionLineDir = getBaseDVP()->projectPoint(sectionLineDir);// convert to base view CS
sectionLineDir.Normalize();
Base::Vector3d sectionOrg = SectionOrigin.getValue() - getBaseDVP()->getOriginalCentroid();
sectionOrg = getBaseDVP()->projectPoint(sectionOrg);// convert to base view
// CS
double halfSize = (getBaseDVP()->getSizeAlongVector(sectionLineDir) / 2.0) * SectionLineStretch.getValue();
result.first = sectionOrg + sectionLineDir * halfSize;
result.second = sectionOrg - sectionLineDir * halfSize;
return result;
return sectionLineDir;
}
// find the points and directions to make the change point marks.