From 6db2bfd256d2c409f0223bf2685a2829466add78 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Fri, 11 Jan 2019 08:50:02 +0100 Subject: keep inAngle and outAngle snapped to 15-degree increments --- src/data/edge.cpp | 6 ++++-- src/gui/nodeitem.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/data/edge.cpp b/src/data/edge.cpp index 41fc2bb..fcd9959 100644 --- a/src/data/edge.cpp +++ b/src/data/edge.cpp @@ -169,8 +169,10 @@ void Edge::updateControls() { qreal bnd = static_cast(_bend) * (M_PI / 180.0); outAngleR = angle - bnd; inAngleR = M_PI + angle + bnd; - _outAngle = static_cast(round(outAngleR * (180.0 / M_PI))); - _inAngle = static_cast(round(inAngleR * (180.0 / M_PI))); + + // keep _inAngle and _outAngle snapped to increments of 15 degrees + _outAngle = static_cast(roundToNearest(15.0, outAngleR * (180.0 / M_PI))); + _inAngle = static_cast(roundToNearest(15.0, inAngleR * (180.0 / M_PI))); } else { outAngleR = static_cast(_outAngle) * (M_PI / 180.0); inAngleR = static_cast(_inAngle) * (M_PI / 180.0); diff --git a/src/gui/nodeitem.cpp b/src/gui/nodeitem.cpp index 18ff43c..8907573 100644 --- a/src/gui/nodeitem.cpp +++ b/src/gui/nodeitem.cpp @@ -72,7 +72,7 @@ void NodeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge QVector p; p << 1.0 << 2.0; pen.setDashPattern(p); - pen.setWidthF(2.0f); + pen.setWidthF(2.0); painter->setPen(pen); painter->setBrush(Qt::NoBrush); painter->drawPath(shape()); @@ -135,10 +135,10 @@ void NodeItem::updateBounds() prepareGeometryChange(); QString label = _node->label(); if (label != "") { - QFontMetrics fm(Tikzit::LABEL_FONT); - QRectF labelRect = fm.boundingRect(label); - labelRect.moveCenter(QPointF(0, 0)); - _boundingRect = labelRect.united(shape().boundingRect()).adjusted(-4, -4, 4, 4); + //QFontMetrics fm(Tikzit::LABEL_FONT); + //QRectF labelRect = fm.boundingRect(label); + //labelRect.moveCenter(QPointF(0, 0)); + _boundingRect = labelRect().united(shape().boundingRect()).adjusted(-4, -4, 4, 4); } else { _boundingRect = shape().boundingRect().adjusted(-4, -4, 4, 4); } -- cgit v1.2.3