[TD]Cosmetic function overhaul (#14216)

* [TD]Cosmetic geometry and tools update

- all cosmetics to store geometry in same form
- all cosmetics to survive scaling and rotation
- extension functions to survive scaling and rotation

* [TD]overhaul leader point storage and editing

- add py routine makeLeader(points)

* [TD]add leader conversion utility

* [TD]Set Leader RotateWithView default to true

* [TD]fix intersection vertex position

* [TD]add CosmeticEdge::makeLineFromCanonicalPoints

* [TD]fix 2 Extension tools

- positioning in DrawCosmeticCircle
- mishandling of points in execLineParallelPerpendicular

* [TD]Remove duplicate constexpr

* [TD]fix 2x Cosmetic arc tools

* [TD]refactor LineFormat out of Cosmetic

* [TD]move cosmetic appearance settings to LineFormat

* [TD]remove 2 unused methods

* [TD]apply format to blue line & circle tools

* [TD]fix ballon arrowhead does not rotate with view

* [TD]fix CosmeticCircle3Points

* [TD]allow multiple cosmetic object deletions

* [TD]fix extend/shorten centerline
This commit is contained in:
WandererFan
2024-05-23 09:41:42 -04:00
committed by GitHub
parent a8d093280e
commit 50f970efd7
56 changed files with 1812 additions and 1076 deletions

View File

@@ -621,7 +621,7 @@ std::vector<Base::Vector3d> BaseGeom::intersection(TechDraw::BaseGeomPtr geom2)
TopExp_Explorer explorer(sectionShape, TopAbs_VERTEX);
while (explorer.More()) {
Base::Vector3d pt(DrawUtil::toVector3d(BRep_Tool::Pnt(TopoDS::Vertex(explorer.Current()))));
interPoints.push_back(DrawUtil::invertY(pt));
interPoints.push_back(pt);
explorer.Next();
}
}
@@ -802,16 +802,20 @@ AOC::AOC(const TopoDS_Edge &e) : Circle(e)
gp_Vec v1(m, s); //vector mid to start
gp_Vec v2(m, ePt); //vector mid to end
gp_Vec v3(0, 0, 1); //stdZ
// this is the wrong determination of cw/ccw. needs to be determined by edge.
double a = v3.DotCross(v1, v2); //error if v1 = v2?
startAngle = fmod(f, 2.0*M_PI);
endAngle = fmod(l, 2.0*M_PI);
cw = (a < 0) ? true: false;
largeArc = (fabs(l-f) > M_PI) ? true : false;
startPnt = Base::Vector3d(s.X(), s.Y(), s.Z());
endPnt = Base::Vector3d(ePt.X(), ePt.Y(), s.Z());
midPnt = Base::Vector3d(m.X(), m.Y(), s.Z());
startPnt = DU::toVector3d(s);
endPnt = DU::toVector3d(ePt);
midPnt = DU::toVector3d(m);
if (e.Orientation() == TopAbs_REVERSED) {
reversed = true;
}
@@ -845,6 +849,11 @@ AOC::AOC(Base::Vector3d c, double r, double sAng, double eAng) : Circle()
gp_Vec v1(m, s); //vector mid to start
gp_Vec v2(m, ePt); //vector mid to end
gp_Vec v3(0, 0, 1); //stdZ
// this is a bit of an arcane method of determining if v2 is clockwise from v1 or counter clockwise from v1.
// The v1 x v2 points up if v2 is ccw from v1 and points down if v2 is cw from v1. Taking (v1 x v2) * stdZ
// gives 1 for parallel with stdZ (v2 is ccw from v1) or -1 for antiparallel with stdZ (v2 is clockwise from v1).
// this cw flag is a problem. we should just declare that arcs are always ccw and flip the start and end angles.
double a = v3.DotCross(v1, v2); //error if v1 = v2?
startAngle = fmod(f, 2.0*M_PI);
@@ -852,9 +861,9 @@ AOC::AOC(Base::Vector3d c, double r, double sAng, double eAng) : Circle()
cw = (a < 0) ? true: false;
largeArc = (fabs(l-f) > M_PI) ? true : false;
startPnt = Base::Vector3d(s.X(), s.Y(), s.Z());
endPnt = Base::Vector3d(ePt.X(), ePt.Y(), s.Z());
midPnt = Base::Vector3d(m.X(), m.Y(), s.Z());
startPnt = DU::toVector3d(s);
endPnt = DU::toVector3d(ePt);
midPnt = DU::toVector3d(m);
if (edge.Orientation() == TopAbs_REVERSED) {
reversed = true;
}
@@ -890,6 +899,22 @@ bool AOC::isOnArc(Base::Vector3d p)
return false;
}
BaseGeomPtr AOC::copy()
{
auto base = BaseGeom::copy();
TechDraw::CirclePtr circle = std::static_pointer_cast<TechDraw::Circle>(base);
TechDraw::AOCPtr aoc = std::static_pointer_cast<TechDraw::AOC>(circle);
if (aoc) {
aoc->clockwiseAngle(clockwiseAngle());
aoc->startPnt = startPnt;
aoc->startAngle = startAngle;
aoc->endPnt = endPnt;
aoc->endAngle = endAngle;
aoc->largeArc = largeArc;
}
return base;
}
double AOC::distToArc(Base::Vector3d p)
{
return minDist(p);