| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | # include <gp_Ax3.hxx> |
| | # include <gp_Trsf.hxx> |
| | # include <gp_Vec.hxx> |
| |
|
| |
|
| | #include <Base/Console.h> |
| | #include <Base/Converter.h> |
| | #include <Base/Tools.h> |
| |
|
| | #include "DimensionGeometry.h" |
| | #include "DrawUtil.h" |
| | #include "DrawViewPart.h" |
| | #include "DrawViewDetail.h" |
| |
|
| |
|
| | using namespace TechDraw; |
| | using DU = DrawUtil; |
| |
|
| | pointPair::pointPair(const pointPair& pp) |
| | { |
| | first(pp.first()); |
| | second(pp.second()); |
| | overrideFirst(pp.extensionLineFirst()); |
| | overrideSecond(pp.extensionLineSecond()); |
| | } |
| |
|
| | |
| | void pointPair::setExtensionLine(const pointPair& pp){ |
| | overrideFirst(pp.first()); |
| | overrideSecond(pp.second()); |
| | } |
| |
|
| | |
| | void pointPair::move(const Base::Vector3d& offset) |
| | { |
| | m_first = m_first - offset; |
| | m_second = m_second - offset; |
| | m_overrideFirst = m_overrideFirst - offset; |
| | m_overrideSecond = m_overrideSecond - offset; |
| | } |
| |
|
| | |
| | void pointPair::scale(double factor) |
| | { |
| | m_first = m_first * factor; |
| | m_second = m_second * factor; |
| | m_overrideFirst = m_overrideFirst * factor; |
| | m_overrideSecond = m_overrideSecond * factor; |
| | } |
| |
|
| | |
| | void pointPair::project(const DrawViewPart* dvp) |
| | { |
| | auto detailView = dynamic_cast<const DrawViewDetail*>(dvp); |
| | if (detailView) { |
| | m_first = detailView->mapPoint3dToDetail(m_first) * detailView->getScale(); |
| | m_second = detailView->mapPoint3dToDetail(m_second) * detailView->getScale(); |
| | m_overrideFirst = detailView->mapPoint3dToDetail(m_overrideFirst) * detailView->getScale(); |
| | m_overrideSecond = detailView->mapPoint3dToDetail(m_overrideSecond) * detailView->getScale(); |
| | return; |
| | } |
| | m_first = dvp->projectPoint(m_first) * dvp->getScale(); |
| | m_second = dvp->projectPoint(m_second) * dvp->getScale(); |
| | m_overrideFirst = dvp->projectPoint(m_overrideFirst) * dvp->getScale(); |
| | m_overrideSecond = dvp->projectPoint(m_overrideSecond) * dvp->getScale(); |
| | } |
| |
|
| | |
| | |
| | |
| | void pointPair::mapToPage(const DrawViewPart* dvp) |
| | { |
| | gp_Trsf xOXYZ; |
| | gp_Ax3 OXYZ; |
| | xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getRotatedCS())); |
| |
|
| | gp_Vec gvFirst = Base::convertTo<gp_Vec>(m_first).Transformed(xOXYZ); |
| | m_first = Base::convertTo<Base::Vector3d>(gvFirst); |
| | gp_Vec gvSecond = Base::convertTo<gp_Vec>(m_second).Transformed(xOXYZ); |
| | m_second = Base::convertTo<Base::Vector3d>(gvSecond); |
| | } |
| |
|
| | |
| | |
| | void pointPair::invertY() |
| | { |
| | m_first = DU::invertY(m_first); |
| | m_second = DU::invertY(m_second); |
| | } |
| |
|
| | void pointPair::dump(const std::string& text) const |
| | { |
| | Base::Console().message("pointPair - %s\n", text.c_str()); |
| | Base::Console().message("pointPair - first: %s second: %s\n", |
| | DU::formatVector(first()).c_str(), DU::formatVector(second()).c_str()); |
| | } |
| |
|
| | |
| | |
| | pointPair pointPair::toCanonicalForm(DrawViewPart* dvp) const |
| | { |
| | pointPair result; |
| | |
| | result.m_first = CosmeticVertex::makeCanonicalPoint(dvp, m_first); |
| | result.m_second = CosmeticVertex::makeCanonicalPoint(dvp, m_second); |
| | result.m_overrideFirst = CosmeticVertex::makeCanonicalPoint(dvp, m_overrideFirst); |
| | result.m_overrideSecond = CosmeticVertex::makeCanonicalPoint(dvp, m_overrideSecond); |
| | return result; |
| | } |
| |
|
| | |
| | |
| | pointPair pointPair::toDisplayForm(DrawViewPart* dvp) const |
| | { |
| | pointPair result; |
| |
|
| | |
| | result.m_first = m_first * dvp->getScale(); |
| | result.m_second = m_second * dvp->getScale(); |
| | result.m_overrideFirst = m_overrideFirst * dvp->getScale(); |
| | result.m_overrideSecond = m_overrideSecond * dvp->getScale(); |
| | auto rotationDeg = dvp->Rotation.getValue(); |
| | if (rotationDeg != 0.0) { |
| | auto rotationRad = Base::toRadians(rotationDeg); |
| | result.m_first.RotateZ(rotationRad); |
| | result.m_second.RotateZ(rotationRad); |
| | result.m_overrideFirst.RotateZ(rotationRad); |
| | result.m_overrideSecond.RotateZ(rotationRad); |
| | } |
| | return result; |
| | } |
| |
|
| |
|
| |
|
| | anglePoints::anglePoints() |
| | { |
| | m_ends.first(Base::Vector3d(0.0, 0.0, 0.0)); |
| | m_ends.second(Base::Vector3d(0.0, 0.0, 0.0)); |
| | m_vertex = Base::Vector3d(0.0, 0.0, 0.0); |
| | } |
| |
|
| | anglePoints::anglePoints(const anglePoints& ap) : m_ends(ap.ends()), m_vertex(ap.vertex()) {} |
| |
|
| | anglePoints& anglePoints::operator=(const anglePoints& ap) |
| | { |
| | m_ends = ap.ends(); |
| | m_vertex = ap.vertex(); |
| | return *this; |
| | } |
| |
|
| | |
| | void anglePoints::move(const Base::Vector3d& offset) |
| | { |
| | m_ends.move(offset); |
| | m_vertex = m_vertex - offset; |
| | } |
| |
|
| | |
| | void anglePoints::project(const DrawViewPart* dvp) |
| | { |
| | m_ends.project(dvp); |
| | m_vertex = dvp->projectPoint(m_vertex) * dvp->getScale(); |
| | } |
| |
|
| | |
| | |
| | void anglePoints::mapToPage(const DrawViewPart* dvp) |
| | { |
| | m_ends.mapToPage(dvp); |
| |
|
| | gp_Trsf xOXYZ; |
| | gp_Ax3 OXYZ; |
| | xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getRotatedCS())); |
| | gp_Vec gvVertex = Base::convertTo<gp_Vec>(m_vertex).Transformed(xOXYZ); |
| | m_vertex = Base::convertTo<Base::Vector3d>(gvVertex); |
| | } |
| |
|
| | |
| | |
| | void anglePoints::invertY() |
| | { |
| | m_ends.invertY(); |
| | m_vertex = DU::invertY(m_vertex); |
| | } |
| |
|
| | |
| | |
| | anglePoints anglePoints::toCanonicalForm(DrawViewPart* dvp) const |
| | { |
| | anglePoints result; |
| | result.m_ends = m_ends.toCanonicalForm(dvp); |
| | result.m_vertex = CosmeticVertex::makeCanonicalPoint(dvp, m_vertex); |
| | return result; |
| | } |
| |
|
| | |
| | |
| | anglePoints anglePoints::toDisplayForm(DrawViewPart* dvp) const |
| | { |
| | anglePoints result; |
| | result.m_ends = m_ends.toDisplayForm(dvp); |
| | result.m_vertex = m_vertex * dvp->getScale(); |
| | auto rotationDeg = dvp->Rotation.getValue(); |
| | if (rotationDeg != 0.0) { |
| | auto rotationRad = Base::toRadians(rotationDeg); |
| | result.m_vertex.RotateZ(rotationRad); |
| | } |
| | return result; |
| | } |
| | void anglePoints::dump(const std::string& text) const |
| | { |
| | Base::Console().message("anglePoints - %s\n", text.c_str()); |
| | Base::Console().message("anglePoints - ends - first: %s second: %s\n", |
| | DU::formatVector(first()).c_str(), DU::formatVector(second()).c_str()); |
| | Base::Console().message("anglePoints - vertex: %s\n", DU::formatVector(vertex()).c_str()); |
| | } |
| |
|
| | arcPoints::arcPoints() : |
| | isArc(false), |
| | radius(0.0), |
| | arcCW(false) |
| | { |
| | center = Base::Vector3d(0.0, 0.0, 0.0); |
| | onCurve.first(Base::Vector3d(0.0, 0.0, 0.0)); |
| | onCurve.second(Base::Vector3d(0.0, 0.0, 0.0)); |
| | arcEnds.first(Base::Vector3d(0.0, 0.0, 0.0)); |
| | arcEnds.second(Base::Vector3d(0.0, 0.0, 0.0)); |
| | midArc = Base::Vector3d(0.0, 0.0, 0.0); |
| | } |
| |
|
| | arcPoints& arcPoints::operator=(const arcPoints& ap) |
| | { |
| | isArc = ap.isArc; |
| | radius = ap.radius; |
| | center = ap.center; |
| | onCurve = ap.onCurve; |
| | arcEnds = ap.arcEnds; |
| | midArc = ap.midArc; |
| | arcCW = ap.arcCW; |
| | return *this; |
| | } |
| |
|
| | void arcPoints::move(const Base::Vector3d& offset) |
| | { |
| | center = center - offset; |
| | onCurve.first(onCurve.first() - offset); |
| | onCurve.second(onCurve.second() - offset); |
| | arcEnds.first(arcEnds.first() - offset); |
| | arcEnds.second(arcEnds.second() - offset); |
| | midArc = midArc - offset; |
| | } |
| |
|
| | void arcPoints::project(const DrawViewPart* dvp) |
| | { |
| | radius = radius * dvp->getScale(); |
| | center = dvp->projectPoint(center) * dvp->getScale(); |
| | onCurve.first(dvp->projectPoint(onCurve.first()) * dvp->getScale()); |
| | onCurve.second(dvp->projectPoint(onCurve.second()) * dvp->getScale()); |
| | arcEnds.first(dvp->projectPoint(arcEnds.first()) * dvp->getScale()); |
| | arcEnds.second(dvp->projectPoint(arcEnds.second()) * dvp->getScale()); |
| | midArc = dvp->projectPoint(midArc) * dvp->getScale(); |
| | } |
| |
|
| | |
| | void arcPoints::mapToPage(const DrawViewPart* dvp) |
| | { |
| | gp_Trsf xOXYZ; |
| | gp_Ax3 OXYZ; |
| | xOXYZ.SetTransformation(OXYZ, gp_Ax3(dvp->getRotatedCS())); |
| |
|
| | gp_Vec gvCenter = Base::convertTo<gp_Vec>(center).Transformed(xOXYZ); |
| | center = Base::convertTo<Base::Vector3d>(gvCenter); |
| | gp_Vec gvOnCurve1 = Base::convertTo<gp_Vec>(onCurve.first()).Transformed(xOXYZ); |
| | onCurve.first(Base::convertTo<Base::Vector3d>(gvOnCurve1)); |
| | gp_Vec gvOnCurve2 = Base::convertTo<gp_Vec>(onCurve.second()).Transformed(xOXYZ); |
| | onCurve.second(Base::convertTo<Base::Vector3d>(gvOnCurve2)); |
| | gp_Vec gvArcEnds1 = Base::convertTo<gp_Vec>(arcEnds.first()).Transformed(xOXYZ); |
| | arcEnds.first(Base::convertTo<Base::Vector3d>(gvArcEnds1)); |
| | gp_Vec gvArcEnds2 = Base::convertTo<gp_Vec>(arcEnds.second()).Transformed(xOXYZ); |
| | arcEnds.second(Base::convertTo<Base::Vector3d>(gvArcEnds2)); |
| | gp_Vec gvMidArc = Base::convertTo<gp_Vec>(midArc).Transformed(xOXYZ); |
| | midArc = Base::convertTo<Base::Vector3d>(gvMidArc); |
| | } |
| |
|
| | |
| | void arcPoints::invertY() |
| | { |
| | center = DU::invertY(center); |
| | onCurve.invertY(); |
| | arcEnds.invertY(); |
| | midArc = DU::invertY(midArc); |
| | } |
| |
|
| | |
| | |
| | arcPoints arcPoints::toDisplayForm(DrawViewPart* dvp) const |
| | { |
| | arcPoints result; |
| | result.onCurve = onCurve.toDisplayForm(dvp); |
| | result.arcEnds = arcEnds.toDisplayForm(dvp); |
| | result.center = center * dvp->getScale(); |
| | result.midArc = midArc * dvp->getScale(); |
| | result.radius = radius * dvp->getScale(); |
| | auto rotationDeg = dvp->Rotation.getValue(); |
| | if (rotationDeg != 0.0) { |
| | auto rotationRad = Base::toRadians(rotationDeg); |
| | result.center.RotateZ(rotationRad); |
| | result.midArc.RotateZ(rotationRad); |
| | } |
| | return result; |
| | } |
| |
|
| | |
| | |
| | arcPoints arcPoints::toCanonicalForm(DrawViewPart* dvp) const |
| | { |
| | arcPoints result; |
| | result.onCurve = onCurve.toCanonicalForm(dvp); |
| | result.arcEnds = arcEnds.toCanonicalForm(dvp); |
| | result.center = CosmeticVertex::makeCanonicalPoint(dvp, center); |
| | result.midArc = CosmeticVertex::makeCanonicalPoint(dvp, midArc); |
| | result.radius = radius / dvp->getScale(); |
| | return result; |
| | } |
| |
|
| |
|
| | void arcPoints::dump(const std::string& text) const |
| | { |
| | Base::Console().message("arcPoints - %s\n", text.c_str()); |
| | Base::Console().message("arcPoints - radius: %.3f center: %s\n", radius, |
| | DrawUtil::formatVector(center).c_str()); |
| | Base::Console().message("arcPoints - isArc: %d arcCW: %d\n", isArc, arcCW); |
| | Base::Console().message("arcPoints - onCurve: %s %s\n", |
| | DrawUtil::formatVector(onCurve.first()).c_str(), |
| | DrawUtil::formatVector(onCurve.second()).c_str()); |
| | Base::Console().message("arcPoints - arcEnds: %s %s\n", |
| | DrawUtil::formatVector(arcEnds.first()).c_str(), |
| | DrawUtil::formatVector(arcEnds.second()).c_str()); |
| | Base::Console().message("arcPoints - midArc: %s\n", DrawUtil::formatVector(midArc).c_str()); |
| | } |
| |
|
| |
|
| | areaPoint::areaPoint() : |
| | area(0.0), |
| | actualArea(0.0), |
| | center(Base::Vector3d()) |
| | { |
| | } |
| |
|
| | areaPoint& areaPoint::operator=(const areaPoint& ap) |
| | { |
| | area = ap.area; |
| | center = ap.center; |
| | actualArea = ap.actualArea; |
| | return *this; |
| | } |
| |
|
| | void areaPoint::move(const Base::Vector3d& offset) |
| | { |
| | center = center - offset; |
| | } |
| |
|
| | void areaPoint::project(const DrawViewPart* dvp) |
| | { |
| | center = dvp->projectPoint(center) * dvp->getScale(); |
| | } |
| |
|
| | void areaPoint::invertY() |
| | { |
| | center = DU::invertY(center); |
| | } |
| |
|
| | void areaPoint::dump(const std::string& text) const |
| | { |
| | Base::Console().message("areaPoint - %s\n", text.c_str()); |
| | Base::Console().message("areaPoint - area: %.3f center: %s\n", area, |
| | DrawUtil::formatVector(center).c_str()); |
| | } |
| |
|