Merge pull request #4069 from aapo-aapo/TD-Balloon-improvements

[TD] TechDraw Balloon improvements with two new App::PropertyType properties
This commit is contained in:
Yorik van Havre
2020-12-14 11:56:08 +01:00
committed by GitHub
3 changed files with 24 additions and 11 deletions

View File

@@ -105,11 +105,16 @@ DrawViewBalloon::DrawViewBalloon(void)
ADD_PROPERTY_TYPE(ShapeScale,(1.0),"",(App::PropertyType)(App::Prop_None),"Balloon shape scale");
ShapeScale.setConstraints(&SymbolScaleRange);
ADD_PROPERTY_TYPE(EndTypeScale,(1.0),"",(App::PropertyType)(App::Prop_None),"EndType shape scale");
ShapeScale.setConstraints(&SymbolScaleRange);
ADD_PROPERTY_TYPE(TextWrapLen,(-1),"",(App::PropertyType)(App::Prop_None),"Text wrap length; -1 means no wrap");
ADD_PROPERTY_TYPE(KinkLength,(prefKinkLength()),"",(App::PropertyType)(App::Prop_None),
"Distance from symbol to leader kink");
ADD_PROPERTY_TYPE(LineVisible,(true),"",(App::PropertyType)(App::Prop_None),"Balloon line visible or hidden");
SourceView.setScope(App::LinkScope::Global);
Rotation.setStatus(App::Property::Hidden,true);
Caption.setStatus(App::Property::Hidden,true);

View File

@@ -49,15 +49,17 @@ public:
DrawViewBalloon();
virtual ~DrawViewBalloon();
App::PropertyLink SourceView;
App::PropertyString Text;
App::PropertyEnumeration EndType;
App::PropertyEnumeration BubbleShape;
App::PropertyLink SourceView;
App::PropertyString Text;
App::PropertyEnumeration EndType;
App::PropertyEnumeration BubbleShape;
App::PropertyFloatConstraint ShapeScale;
App::PropertyDistance OriginX;
App::PropertyDistance OriginY;
App::PropertyFloat TextWrapLen;
App::PropertyDistance KinkLength;
App::PropertyFloatConstraint EndTypeScale;
App::PropertyDistance OriginX;
App::PropertyDistance OriginY;
App::PropertyFloat TextWrapLen;
App::PropertyDistance KinkLength;
App::PropertyBool LineVisible;
short mustExecute() const override;

View File

@@ -717,14 +717,14 @@ void QGIViewBalloon::draw()
double yAdj = 0.0;
int endType = balloon->EndType.getValue();
double arrowAdj = QGIArrow::getOverlapAdjust(endType,
QGIArrow::getPrefArrowSize());
balloon->EndTypeScale.getValue()*QGIArrow::getPrefArrowSize());
if (endType == ArrowType::NONE) {
arrow->hide();
} else {
arrow->setStyle(endType);
arrow->setSize(QGIArrow::getPrefArrowSize());
arrow->setSize(balloon->EndTypeScale.getValue()*QGIArrow::getPrefArrowSize());
arrow->draw();
Base::Vector3d arrowTipPos(arrowTipX, arrowTipY, 0.0);
@@ -738,7 +738,7 @@ void QGIViewBalloon::draw()
float arAngle = atan2(dirballoonLinesLine.y, dirballoonLinesLine.x) * 180 / M_PI;
arrow->setPos(arrowTipX, arrowTipY);
if ( (endType == ArrowType::FILLED_TRIANGLE) &&
if ( (endType == ArrowType::FILLED_TRIANGLE) &&
(prefOrthoPyramid()) ) {
if (arAngle < 0.0) {
arAngle += 360.0;
@@ -765,6 +765,12 @@ void QGIViewBalloon::draw()
dLinePath.lineTo(arrowTipX - xAdj, arrowTipY - yAdj);
balloonLines->setPath(dLinePath);
// This overwrites the previously created QPainterPath with empty one, in case it should be hidden. Should be refactored.
if (!balloon->LineVisible.getValue()) {
arrow->hide();
balloonLines->setPath(QPainterPath());
}
// redraw the Balloon and the parent View
if (hasHover && !isSelected()) {
setPrettyPre();