From 05577c267c85fcc1211c3b7f1d902293418d39e2 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Sun, 12 Jan 2020 18:33:59 -0500 Subject: [PATCH] [TD]Balloon ends and kink --- src/Mod/TechDraw/App/DrawViewBalloon.cpp | 29 +++-- src/Mod/TechDraw/App/DrawViewBalloon.h | 16 ++- src/Mod/TechDraw/Gui/QGIArrow.cpp | 94 ++++++++------- src/Mod/TechDraw/Gui/QGIArrow.h | 3 +- src/Mod/TechDraw/Gui/QGIPrimPath.cpp | 13 ++- src/Mod/TechDraw/Gui/QGIPrimPath.h | 2 + src/Mod/TechDraw/Gui/QGIViewBalloon.cpp | 139 +++++++++++++++-------- src/Mod/TechDraw/Gui/QGIViewBalloon.h | 2 + src/Mod/TechDraw/Gui/TaskBalloon.ui | 5 + 9 files changed, 192 insertions(+), 111 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewBalloon.cpp b/src/Mod/TechDraw/App/DrawViewBalloon.cpp index 91293acdc7..06df033232 100644 --- a/src/Mod/TechDraw/App/DrawViewBalloon.cpp +++ b/src/Mod/TechDraw/App/DrawViewBalloon.cpp @@ -89,6 +89,7 @@ const char* DrawViewBalloon::endTypeEnums[]= { "FILLED_TRIANGLE", "OPEN_CIRCLE", "FORK", "PYRAMID", + "NONE", NULL}; //const char* DrawViewBalloon::endTypeEnums[]= {"Arrow", @@ -123,19 +124,15 @@ DrawViewBalloon::DrawViewBalloon(void) ADD_PROPERTY_TYPE(TextWrapLen,(-1),"",(App::PropertyType)(App::Prop_None),"Balloon symbol scale"); -// OriginX.setStatus(App::Property::Hidden,false); -// OriginY.setStatus(App::Property::Hidden,false); + ADD_PROPERTY_TYPE(KinkLength,(prefKinkLength()),"",(App::PropertyType)(App::Prop_None), + "Distance from symbol to leader kink"); + OriginIsSet.setStatus(App::Property::Hidden,false); OriginIsSet.setStatus(App::Property::ReadOnly,true); SourceView.setScope(App::LinkScope::Global); -// SourceView.setStatus(App::Property::Hidden,true); Rotation.setStatus(App::Property::Hidden,true); -// ScaleType.setStatus(App::Property::Hidden,true); -// Scale.setStatus(App::Property::Hidden,true); Caption.setStatus(App::Property::Hidden,true); -// X.setStatus(App::Property::Hidden,true); -// Y.setStatus(App::Property::Hidden,true); } DrawViewBalloon::~DrawViewBalloon() @@ -145,6 +142,14 @@ DrawViewBalloon::~DrawViewBalloon() void DrawViewBalloon::onChanged(const App::Property* prop) { + if (!isRestoring()) { + if ( (prop == &EndType) || + (prop == &Symbol) || + (prop == &Text) || + (prop == &KinkLength) ) { + requestPaint(); + } + } DrawView::onChanged(prop); } @@ -255,6 +260,16 @@ App::DocumentObjectExecReturn *DrawViewBalloon::execute(void) requestPaint(); return App::DocumentObject::execute(); } + +double DrawViewBalloon::prefKinkLength(void) const +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter(). + GetGroup("BaseApp")->GetGroup("Preferences")-> + GetGroup("Mod/TechDraw/Dimensions"); + double length = hGrp->GetFloat("BalloonKink", 5.0); + return length; +} + /* PyObject *DrawViewBalloon::getPyObject(void) { diff --git a/src/Mod/TechDraw/App/DrawViewBalloon.h b/src/Mod/TechDraw/App/DrawViewBalloon.h index b9c89d5898..82a1a8af74 100644 --- a/src/Mod/TechDraw/App/DrawViewBalloon.h +++ b/src/Mod/TechDraw/App/DrawViewBalloon.h @@ -60,6 +60,8 @@ public: App::PropertyBool OriginIsSet; App::PropertyFloat TextWrapLen; + App::PropertyDistance KinkLength; + short mustExecute() const override; DrawViewPart* getViewPart() const; @@ -68,9 +70,7 @@ public: //virtual PyObject *getPyObject(void); virtual App::DocumentObjectExecReturn *execute(void) override; - //@} - /// returns the type name of the ViewProvider virtual const char* getViewProviderName(void) const override { return "TechDrawGui::ViewProviderBalloon"; } @@ -80,11 +80,17 @@ public: void handleXYLock(void) override; + double prefKinkLength(void) const; + + protected: void onChanged(const App::Property* prop) override; -/* virtual void onDocumentRestored();*/ - virtual void handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property * prop) override; - virtual void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) override; + virtual void handleChangedPropertyType(Base::XMLReader &reader, + const char *TypeName, + App::Property * prop) override; + virtual void handleChangedPropertyName(Base::XMLReader &reader, + const char * TypeName, + const char *PropName) override; private: }; diff --git a/src/Mod/TechDraw/Gui/QGIArrow.cpp b/src/Mod/TechDraw/Gui/QGIArrow.cpp index 810068910d..72d70781ab 100644 --- a/src/Mod/TechDraw/Gui/QGIArrow.cpp +++ b/src/Mod/TechDraw/Gui/QGIArrow.cpp @@ -43,7 +43,7 @@ using namespace TechDrawGui; QGIArrow::QGIArrow() : m_fill(Qt::SolidPattern), - m_size(5.0), + m_size(getPrefArrowSize()), m_style(0), m_dirMode(false), m_dir(Base::Vector3d(1.0,0.0,0.0)) @@ -63,45 +63,39 @@ QGIArrow::QGIArrow() : void QGIArrow::draw() { QPainterPath path; if (m_style == FILLED_TRIANGLE) { - setFillStyle(Qt::SolidPattern); if (m_dirMode) { path = makeFilledTriangle(getDirection(), m_size,m_size/6.0); } else { path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //"arrow l/w sb 3/1" ?? } } else if (m_style == OPEN_ARROW) { - setFillStyle(Qt::NoBrush); if (m_dirMode) { path = makeOpenArrow(getDirection(), m_size,m_size/3.0); //broad arrow? } else { path = makeOpenArrow(m_size,m_size/3.0,isFlipped()); } } else if (m_style == HASH_MARK) { - setFillStyle(Qt::NoBrush); if (m_dirMode) { path = makeHashMark(getDirection(), m_size/2.0,m_size/2.0); //big enough? } else { path = makeHashMark(m_size/2.0,m_size/2.0,isFlipped()); //big enough? } } else if (m_style == DOT) { - setFillStyle(Qt::SolidPattern); path = makeDot(m_size/2.0,m_size/2.0,isFlipped()); } else if (m_style == OPEN_CIRCLE) { path = makeOpenDot(m_size/2.0,m_size/2.0,isFlipped()); } else if (m_style == FORK) { - setFillStyle(Qt::NoBrush); if (m_dirMode) { path = makeForkArrow(getDirection(), m_size/2.0,m_size/2.0); //big enough? } else { path = makeForkArrow(m_size/2.0,m_size/2.0,isFlipped()); //big enough? } } else if (m_style == PYRAMID){ - setFillStyle(Qt::SolidPattern); - if (m_dirMode) { - path = makePyramid(getDirection(), m_size); - } else { - path = makePyramid(m_size,isFlipped()); - } + if (m_dirMode) { + path = makePyramid(getDirection(), m_size); + } else { + path = makePyramid(m_size,isFlipped()); + } }else { path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //sb a question mark or ??? } @@ -271,50 +265,51 @@ QPainterPath QGIArrow::makeForkArrow(Base::Vector3d dir, double length, double w QPainterPath QGIArrow::makePyramid(double length, bool flipped) { - double half_width = length/2.; - double top = -length; - double base = 0.; - // [(0,-width), (0, width)] is base of arrow - if (flipped) { - top = 0.; - base = -length; - } - top = Rez::guiX(top); - base = Rez::guiX(base); - QPainterPath path; - path.moveTo(QPointF(top, 0.)); - path.lineTo(QPointF(base,Rez::guiX(-half_width))); - path.lineTo(QPointF(base,Rez::guiX(half_width))); - path.closeSubpath(); - setFillStyle(Qt::SolidPattern); - return path; + double half_width = length/2.; + double top = -length; + double base = 0.; + // [(0,-width), (0, width)] is base of arrow + if (flipped) { + top = 0.; + base = -length; + } + top = Rez::guiX(top); + base = Rez::guiX(base); + QPainterPath path; + path.moveTo(QPointF(top, 0.)); + path.lineTo(QPointF(base,Rez::guiX(-half_width))); + path.lineTo(QPointF(base,Rez::guiX(half_width))); + path.closeSubpath(); + setFillStyle(Qt::SolidPattern); + return path; } QPainterPath QGIArrow::makePyramid(Base::Vector3d dir, double length) { - //(0,0) is tip of arrow - // dir is direction arrow points - Base::Vector3d negDir = -dir; - negDir.Normalize(); - double width = length / 2.; - Base::Vector3d perp(-negDir.y,negDir.x, 0.0); - Base::Vector3d barb1 = perp * width; - Base::Vector3d barb2 = perp * -width; - Base::Vector3d top = negDir * length; + //(0,0) is tip of arrow + // dir is direction arrow points + Base::Vector3d negDir = -dir; + negDir.Normalize(); + double width = length / 2.; + Base::Vector3d perp(-negDir.y,negDir.x, 0.0); + Base::Vector3d barb1 = perp * width; + Base::Vector3d barb2 = perp * -width; + Base::Vector3d top = negDir * length; - QPainterPath path; - path.moveTo(QPointF(Rez::guiX(top.x),Rez::guiX(top.y))); - path.lineTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y))); - path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y))); - path.closeSubpath(); - setFillStyle(Qt::SolidPattern); - return path; + QPainterPath path; + path.moveTo(QPointF(Rez::guiX(top.x),Rez::guiX(top.y))); + path.lineTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y))); + path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y))); + path.closeSubpath(); + setFillStyle(Qt::SolidPattern); + return path; } int QGIArrow::getPrefArrowStyle() { Base::Reference hGrp = App::GetApplication().GetUserParameter(). - GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); + GetGroup("BaseApp")->GetGroup("Preferences")-> + GetGroup("Mod/TechDraw/Dimensions"); int style = hGrp->GetInt("ArrowStyle", 0); return style; } @@ -356,8 +351,11 @@ double QGIArrow::getOverlapAdjust(int style, double size) result = 0.0; break; case PYRAMID: - result = 0.0; - break; + result = size; + break; + case NONE: + result = 0.0; + break; default: //unknown result = 1.0; } diff --git a/src/Mod/TechDraw/Gui/QGIArrow.h b/src/Mod/TechDraw/Gui/QGIArrow.h index 05b6228304..26a704ef73 100644 --- a/src/Mod/TechDraw/Gui/QGIArrow.h +++ b/src/Mod/TechDraw/Gui/QGIArrow.h @@ -42,7 +42,8 @@ enum ArrowType { DOT, OPEN_CIRCLE, FORK, - PYRAMID + PYRAMID, + NONE }; class TechDrawGuiExport QGIArrow : public QGIPrimPath diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp index 3fea640c21..4af6fbfe2b 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp @@ -43,8 +43,9 @@ using namespace TechDrawGui; QGIPrimPath::QGIPrimPath(): m_width(0), m_capStyle(Qt::RoundCap), - m_fillStyleCurrent (Qt::NoBrush) -// m_fillStyleCurrent (Qt::SolidPattern) + m_fillStyleCurrent (Qt::NoBrush), +// m_fillStyleCurrent (Qt::SolidPattern), + m_fillOverride(false) { setCacheMode(QGraphicsItem::NoCache); setFlag(QGraphicsItem::ItemIsSelectable, true); @@ -128,13 +129,17 @@ void QGIPrimPath::setPrettyNormal() { void QGIPrimPath::setPrettyPre() { // Base::Console().Message("QGIPP::setPrettyPre()\n"); m_colCurrent = getPreColor(); - m_fillColorCurrent = getPreColor(); + if (!m_fillOverride) { + m_fillColorCurrent = getPreColor(); + } } void QGIPrimPath::setPrettySel() { // Base::Console().Message("QGIPP::setPrettySel()\n"); m_colCurrent = getSelectColor(); - m_fillColorCurrent = getSelectColor(); + if (!m_fillOverride) { + m_fillColorCurrent = getSelectColor(); + } } //wf: why would a face use it's parent's normal colour? diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.h b/src/Mod/TechDraw/Gui/QGIPrimPath.h index 08ae7a0220..b7b0316176 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.h +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.h @@ -68,6 +68,7 @@ public: void resetFill(); void setFillColor(QColor c); QColor getFillColor(void) { return m_colDefFill; } + void setFillOverride(bool b) { m_fillOverride = b; } protected: virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; @@ -101,6 +102,7 @@ protected: Qt::BrushStyle m_styleNormal; //current Normal fill style Qt::BrushStyle m_styleSelect; //Select/preSelect fill style + bool m_fillOverride; private: diff --git a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp index 615aa22920..c0587194f3 100644 --- a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp @@ -265,6 +265,8 @@ QGIViewBalloon::QGIViewBalloon() : balloonShape = new QGIDimLines(); addToGroup(balloonShape); balloonShape->setNormalColor(getNormalColor()); + balloonShape->setFill(Qt::white, Qt::SolidPattern); + balloonShape->setFillOverride(true); balloonShape->setPrettyNormal(); arrow = new QGIArrow(); @@ -272,6 +274,7 @@ QGIViewBalloon::QGIViewBalloon() : arrow->setNormalColor(getNormalColor()); arrow->setFillColor(getNormalColor()); arrow->setPrettyNormal(); + arrow->setStyle(prefDefaultArrow()); balloonLabel->setZValue(ZVALUE::LABEL); arrow->setZValue(ZVALUE::DIMENSION); @@ -279,7 +282,7 @@ QGIViewBalloon::QGIViewBalloon() : balloonLines->setZValue(ZVALUE::DIMENSION); balloonLines->setStyle(Qt::SolidLine); - balloonShape->setZValue(ZVALUE::DIMENSION); + balloonShape->setZValue(ZVALUE::DIMENSION + 1); //above balloonLines! balloonShape->setStyle(Qt::SolidLine); oldLabelCenter = new QPointF; @@ -305,7 +308,6 @@ QGIViewBalloon::QGIViewBalloon() : balloonLabel, SIGNAL(hover(bool)), this , SLOT (hover(bool))); -// toggleBorder(false); setZValue(ZVALUE::DIMENSION); } @@ -441,7 +443,6 @@ void QGIViewBalloon::balloonLabelDragFinished() return; } - //this needs to be scaled? double x = Rez::appX(balloonLabel->X()), y = Rez::appX(balloonLabel->Y()); Gui::Command::openCommand("Drag Balloon"); @@ -509,7 +510,7 @@ void QGIViewBalloon::draw() void QGIViewBalloon::draw_modifier(bool modifier) { - if (!isVisible()) { //should this be controlled by parent ViewPart? + if (!isVisible()) { return; } @@ -539,9 +540,6 @@ void QGIViewBalloon::draw_modifier(bool modifier) return; } - m_colNormal = getNormalColor(); -// balloonLabel->setColor(m_colNormal); - m_lineWidth = Rez::guiX(vp->LineWidth.getValue()); double textWidth = balloonLabel->getDimText()->boundingRect().width(); @@ -556,7 +554,7 @@ void QGIViewBalloon::draw_modifier(bool modifier) Base::Vector3d dLineStart; Base::Vector3d kinkPoint; - double kinkLength = Rez::guiX(5.0); + double kinkLength = Rez::guiX(balloon->KinkLength.getValue()); float orginX = Rez::guiX(balloon->OriginX.getValue()); float orginY = Rez::guiX(balloon->OriginY.getValue()); @@ -564,7 +562,7 @@ void QGIViewBalloon::draw_modifier(bool modifier) const char *balloonType = balloon->Symbol.getValueAsString(); float scale = balloon->SymbolScale.getValue(); - double offset = 0; + double offsetLR = 0; QPainterPath balloonPath; if (strcmp(balloonType, "Circular") == 0) { @@ -572,10 +570,10 @@ void QGIViewBalloon::draw_modifier(bool modifier) balloonRadius = balloonRadius * scale; balloonPath.moveTo(lblCenter.x, lblCenter.y); balloonPath.addEllipse(lblCenter.x - balloonRadius,lblCenter.y - balloonRadius, balloonRadius * 2, balloonRadius * 2); - offset = balloonRadius; + offsetLR = balloonRadius; } else if (strcmp(balloonType, "None") == 0) { balloonPath = QPainterPath(); - offset = (textWidth / 2.0) + Rez::guiX(2.0); + offsetLR = (textWidth / 2.0) + Rez::guiX(2.0); } else if (strcmp(balloonType, "Rectangle") == 0) { //Add some room textHeight = (textHeight * scale) + Rez::guiX(1.0); @@ -586,13 +584,14 @@ void QGIViewBalloon::draw_modifier(bool modifier) } } textWidth = (textWidth * scale) + Rez::guiX(2.0); + textHeight = (textHeight * scale) + Rez::guiX(2.0); balloonPath.addRect(lblCenter.x -(textWidth / 2.0), lblCenter.y - (textHeight / 2.0), textWidth, textHeight); - offset = (textWidth / 2.0); + offsetLR = (textWidth / 2.0); } else if (strcmp(balloonType, "Triangle") == 0) { double radius = sqrt(pow((textHeight / 2.0), 2) + pow((textWidth / 2.0), 2)); radius = radius * scale; radius += Rez::guiX(3.0); - offset = (tan(30 * M_PI / 180) * radius); + offsetLR = (tan(30 * M_PI / 180) * radius); QPolygonF triangle; double startAngle = -M_PI / 2; double angle = startAngle; @@ -612,19 +611,19 @@ void QGIViewBalloon::draw_modifier(bool modifier) balloonPath.arcTo(textBoxCorner.x() + textWidth - (textHeight / 2.0), textBoxCorner.y(), textHeight, textHeight, 90, -180); balloonPath.lineTo(textBoxCorner.x(), textBoxCorner.y() + textHeight); balloonPath.arcTo(textBoxCorner.x() - (textHeight / 2), textBoxCorner.y(), textHeight, textHeight, -90, -180); - offset = (textWidth / 2.0) + (textHeight / 2.0); + offsetLR = (textWidth / 2.0) + (textHeight / 2.0); } else if (strcmp(balloonType, "Square") == 0) { //Add some room textWidth = (textWidth * scale) + Rez::guiX(2.0); textHeight = (textHeight * scale) + Rez::guiX(1.0); double max = std::max(textWidth, textHeight); balloonPath.addRect(lblCenter.x -(max / 2.0), lblCenter.y - (max / 2.0), max, max); - offset = (max / 2.0); + offsetLR = (max / 2.0); } else if (strcmp(balloonType, "Hexagon") == 0) { double radius = sqrt(pow((textHeight / 2.0), 2) + pow((textWidth / 2.0), 2)); radius = radius * scale; radius += Rez::guiX(1.0); - offset = radius; + offsetLR = radius; QPolygonF triangle; double startAngle = -2 * M_PI / 3; double angle = startAngle; @@ -636,12 +635,20 @@ void QGIViewBalloon::draw_modifier(bool modifier) balloonPath.addPolygon(triangle); } - offset = (lblCenter.x < orginX) ? offset : -offset; - dLineStart.y = lblCenter.y; - dLineStart.x = lblCenter.x + offset; - kinkLength = (lblCenter.x < orginX) ? kinkLength : -kinkLength; - kinkPoint.y = dLineStart.y; - kinkPoint.x = dLineStart.x + kinkLength; + balloonShape->setPath(balloonPath); + + offsetLR = (lblCenter.x < orginX) ? offsetLR : -offsetLR ; + + if (DrawUtil::fpCompare(kinkLength, 0.0)) { //if no kink, then dLine start sb on line from center to arrow + dLineStart = lblCenter; + kinkPoint = dLineStart; + } else { + dLineStart.y = lblCenter.y; + dLineStart.x = lblCenter.x + offsetLR ; + kinkLength = (lblCenter.x < orginX) ? kinkLength : -kinkLength; + kinkPoint.y = dLineStart.y; + kinkPoint.x = dLineStart.x + kinkLength; + } QPainterPath dLinePath; dLinePath.moveTo(dLineStart.x, dLineStart.y); @@ -655,35 +662,61 @@ void QGIViewBalloon::draw_modifier(bool modifier) orginX = Rez::guiX(balloon->OriginX.getValue()); orginY = Rez::guiX(balloon->OriginY.getValue()); - dLinePath.lineTo(orginX, orginY); - oldLabelCenter->setX(lblCenter.x); oldLabelCenter->setY(lblCenter.y); - balloonLines->setPath(dLinePath); - balloonShape->setPath(balloonPath); - -// const char *endType = balloon->EndType.getValueAsString(); - -// if (strcmp(endType, "FILLED_TRIANGLE") == 0) { -// arrow->setStyle(QGIArrow::getPrefArrowStyle()); -// } else if (strcmp(endType, "DOT") == 0) { -// arrow->setStyle(3); -// } - + double xAdj = 0.0; + double yAdj = 0.0; int endType = balloon->EndType.getValue(); - arrow->setStyle(endType); + std::string endTypeString = balloon->EndType.getValueAsString(); + double arrowAdj = QGIArrow::getOverlapAdjust(endType, + QGIArrow::getPrefArrowSize()); - arrow->setSize(QGIArrow::getPrefArrowSize()); - arrow->draw(); + if (endTypeString == "NONE") { + arrow->hide(); + } else { + arrow->setStyle(endType); - Base::Vector3d orign(orginX, orginY, 0.0); - Base::Vector3d dirballoonLinesLine = (orign - kinkPoint).Normalize(); - float arAngle = atan2(dirballoonLinesLine.y, dirballoonLinesLine.x) * 180 / M_PI; + arrow->setSize(QGIArrow::getPrefArrowSize()); + arrow->draw(); - arrow->setPos(orginX, orginY); - arrow->setRotation(arAngle); - arrow->show(); + Base::Vector3d orign(orginX, orginY, 0.0); + Base::Vector3d dirballoonLinesLine; + if (!DrawUtil::fpCompare(kinkLength, 0.0)) { + dirballoonLinesLine = (orign - kinkPoint).Normalize(); + } else { + dirballoonLinesLine = (orign - dLineStart).Normalize(); + } + + float arAngle = atan2(dirballoonLinesLine.y, dirballoonLinesLine.x) * 180 / M_PI; + + arrow->setPos(orginX, orginY); + if ( (endTypeString == "PYRAMID") && + (prefOrthoPyramid()) ) { + if (arAngle < 0.0) { + arAngle += 360.0; + } + //set the angle to closest cardinal direction + if ( (45.0 < arAngle) && (arAngle < 135.0) ) { + arAngle = 90.0; + } else if ( (135.0 < arAngle) && (arAngle < 225.0) ) { + arAngle = 180.0; + } else if ( (225.0 < arAngle) && (arAngle < 315.0) ) { + arAngle = 270.0; + } else { + arAngle = 0; + } + double radAngle = arAngle * M_PI / 180.0; + double sinAngle = sin(radAngle); + double cosAngle = cos(radAngle); + xAdj = Rez::guiX(arrowAdj * cosAngle); + yAdj = Rez::guiX(arrowAdj * sinAngle); + } + arrow->setRotation(arAngle); + arrow->show(); + } + dLinePath.lineTo(orginX - xAdj, orginY - yAdj); + balloonLines->setPath(dLinePath); // redraw the Balloon and the parent View if (hasHover && !isSelected()) { @@ -694,9 +727,7 @@ void QGIViewBalloon::draw_modifier(bool modifier) setPrettyNormal(); } - update(); if (parentItem()) { - //TODO: parent redraw still required with new frame/label?? parentItem()->update(); } else { Base::Console().Log("INFO - QGIVB::draw - no parent to update\n"); @@ -707,6 +738,9 @@ void QGIViewBalloon::draw_modifier(bool modifier) void QGIViewBalloon::setPrettyPre(void) { arrow->setPrettyPre(); + //TODO: primPath needs override for fill + //balloonShape->setFillOverride(true); //don't fill with pre or select colours. +// balloonShape->setFill(Qt::white, Qt::NoBrush); balloonShape->setPrettyPre(); balloonLines->setPrettyPre(); } @@ -715,6 +749,7 @@ void QGIViewBalloon::setPrettySel(void) { // Base::Console().Message("QGIVBal::setPrettySel()\n"); arrow->setPrettySel(); +// balloonShape->setFill(Qt::white, Qt::NoBrush); balloonShape->setPrettySel(); balloonLines->setPrettySel(); } @@ -722,6 +757,7 @@ void QGIViewBalloon::setPrettySel(void) void QGIViewBalloon::setPrettyNormal(void) { arrow->setPrettyNormal(); +// balloonShape->setFill(Qt::white, Qt::SolidPattern); balloonShape->setPrettyNormal(); balloonLines->setPrettyNormal(); } @@ -794,4 +830,15 @@ int QGIViewBalloon::prefDefaultArrow() const return arrow; } + +//should this be an object property or global preference? +//when would you want a crooked pyramid? +bool QGIViewBalloon::prefOrthoPyramid() const +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); + bool ortho = hGrp->GetBool("OrthoPyramid", true); + return ortho; +} + #include diff --git a/src/Mod/TechDraw/Gui/QGIViewBalloon.h b/src/Mod/TechDraw/Gui/QGIViewBalloon.h index 2351f5f016..06de3cce51 100644 --- a/src/Mod/TechDraw/Gui/QGIViewBalloon.h +++ b/src/Mod/TechDraw/Gui/QGIViewBalloon.h @@ -151,6 +151,8 @@ public: virtual QColor getNormalColor(void) override; int prefDefaultArrow() const; + bool prefOrthoPyramid() const; + public Q_SLOTS: void balloonLabelDragged(bool ctrl); diff --git a/src/Mod/TechDraw/Gui/TaskBalloon.ui b/src/Mod/TechDraw/Gui/TaskBalloon.ui index d568ffef22..66cdec699e 100644 --- a/src/Mod/TechDraw/Gui/TaskBalloon.ui +++ b/src/Mod/TechDraw/Gui/TaskBalloon.ui @@ -92,6 +92,11 @@ :/icons/arrowpyramid.svg:/icons/arrowpyramid.svg + + + NONE + +