diff --git a/src/Mod/TechDraw/App/DrawUtil.cpp b/src/Mod/TechDraw/App/DrawUtil.cpp index 1d109361bb..a1c55d12ad 100644 --- a/src/Mod/TechDraw/App/DrawUtil.cpp +++ b/src/Mod/TechDraw/App/DrawUtil.cpp @@ -296,36 +296,41 @@ std::pair DrawUtil::boxIntersect2d(Base::Vector3 dir.Normalize(); // y = mx + b // m = (y1 - y0) / (x1 - x0) - if (DrawUtil::fpCompare(dir.x, 0.0) ) { + if (DrawUtil::fpCompare(dir.x, 0.0) ) { //vertical case p1 = Base::Vector3d(point.x, - yRange / 2.0, 0.0); p2 = Base::Vector3d(point.x, yRange / 2.0, 0.0); } else { double slope = dir.y / dir.x; double left = -xRange / 2.0; double right = xRange / 2.0; - double top = yRange / 2.0; - double bottom = -yRange / 2.0; - double yLeft = point.y - slope * (point.x - left) ; - double yRight = point.y - slope * (point.x - right); - double xTop = point.x - ( (point.y - top) / slope ); - double xBottom = point.x - ( (point.y - bottom) / slope ); + if (DrawUtil::fpCompare(slope, 0.0)) { //horizontal case + p1 = Base::Vector3d(left, point.y); + p2 = Base::Vector3d(right, point.y); + } else { //normal case + double top = yRange / 2.0; + double bottom = -yRange / 2.0; + double yLeft = point.y - slope * (point.x - left) ; + double yRight = point.y - slope * (point.x - right); + double xTop = point.x - ( (point.y - top) / slope ); + double xBottom = point.x - ( (point.y - bottom) / slope ); - if ( (bottom < yLeft) && - (top > yLeft) ) { - p1 = Base::Vector3d(left, yLeft); - } else if (yLeft <= bottom) { - p1 = Base::Vector3d(xBottom, bottom); - } else if (yLeft >= top) { - p1 = Base::Vector3d(xTop, top); - } + if ( (bottom < yLeft) && + (top > yLeft) ) { + p1 = Base::Vector3d(left, yLeft); + } else if (yLeft <= bottom) { + p1 = Base::Vector3d(xBottom, bottom); + } else if (yLeft >= top) { + p1 = Base::Vector3d(xTop, top); + } - if ( (bottom < yRight) && - (top > yRight) ) { - p2 = Base::Vector3d(right, yRight); - } else if (yRight <= bottom) { - p2 = Base::Vector3d(xBottom, bottom); - } else if (yRight >= top) { - p2 = Base::Vector3d(xTop, top); + if ( (bottom < yRight) && + (top > yRight) ) { + p2 = Base::Vector3d(right, yRight); + } else if (yRight <= bottom) { + p2 = Base::Vector3d(xBottom, bottom); + } else if (yRight >= top) { + p2 = Base::Vector3d(xTop, top); + } } } result.first = p1; diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index ea0f7844f6..510f14909b 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -585,6 +585,11 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap std::pair DrawViewSection::sectionLineEnds(void) { std::pair result; + Base::Vector3d stdZ(0.0, 0.0, 1.0); + double baseRotation = getBaseDVP()->Rotation.getValue(); //Qt degrees + Base::Rotation rotator(stdZ, baseRotation * M_PI / 180.0); + Base::Rotation unrotator(stdZ, - baseRotation * M_PI / 180.0); + auto sNorm = SectionNormal.getValue(); double angle = M_PI / 2.0; auto axis = getBaseDVP()->Direction.getValue(); @@ -605,7 +610,12 @@ std::pair DrawViewSection::sectionLineEnds(void) xRange /= getBaseDVP()->getScale(); double yRange = bbx.MaxY - bbx.MinY; yRange /= getBaseDVP()->getScale(); + sOrgOnBase = rotator.multVec(sOrgOnBase); + sLineOnBase = rotator.multVec(sLineOnBase); + result = DrawUtil::boxIntersect2d(sOrgOnBase, sLineOnBase, xRange, yRange); //unscaled + result.first = unrotator.multVec(result.first); + result.second = unrotator.multVec(result.second); return result; } diff --git a/src/Mod/TechDraw/Gui/QGIDecoration.cpp b/src/Mod/TechDraw/Gui/QGIDecoration.cpp index 1fe22d59f6..dcea41af80 100644 --- a/src/Mod/TechDraw/Gui/QGIDecoration.cpp +++ b/src/Mod/TechDraw/Gui/QGIDecoration.cpp @@ -106,6 +106,12 @@ QColor QGIDecoration::prefSelectColor() return PreferencesGui::selectQColor(); } +QRectF QGIDecoration::boundingRect() const +{ + return childrenBoundingRect(); +} + + void QGIDecoration::makeMark(double x, double y) { QGICMark* cmItem = new QGICMark(-1); diff --git a/src/Mod/TechDraw/Gui/QGIDecoration.h b/src/Mod/TechDraw/Gui/QGIDecoration.h index b7697b6466..754c4a04af 100644 --- a/src/Mod/TechDraw/Gui/QGIDecoration.h +++ b/src/Mod/TechDraw/Gui/QGIDecoration.h @@ -47,6 +47,7 @@ public: enum {Type = QGraphicsItem::UserType + 173}; int type() const { return Type;} + virtual QRectF boundingRect() const; virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ); virtual void draw(); void setWidth(double w); diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 002c2748bd..fb69a0f10f 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -872,7 +872,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b double fontSize = Preferences::dimFontSizeMM(); sectionLine->setFont(m_font, fontSize); sectionLine->setZValue(ZVALUE::SECTIONLINE); - sectionLine->setRotation(viewPart->Rotation.getValue()); + sectionLine->setRotation(- viewPart->Rotation.getValue()); sectionLine->draw(); } }