fixed strokes with pressure on rules and triangle

preferencesAboutTextFull
Claudio Valerio 11 years ago
parent 1c251fae8b
commit 1df0122f25
  1. 13
      src/tools/UBGraphicsRuler.cpp
  2. 4
      src/tools/UBGraphicsRuler.h
  3. 14
      src/tools/UBGraphicsTriangle.cpp
  4. 1
      src/tools/UBGraphicsTriangle.h

@ -449,12 +449,14 @@ void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width)
{ {
QPointF itemPos = mapFromScene(scenePos); QPointF itemPos = mapFromScene(scenePos);
mStrokeWidth = width;
qreal y; qreal y;
if (itemPos.y() > rect().y() + rect().height() / 2) if (itemPos.y() > rect().y() + rect().height() / 2)
{ {
drawLineDirection = 0; drawLineDirection = 0;
y = rect().y() + rect().height() + width / 2; y = rect().y() + rect().height() + mStrokeWidth / 2;
} }
else else
{ {
@ -471,21 +473,22 @@ void UBGraphicsRuler::StartLine(const QPointF& scenePos, qreal width)
itemPos = mapToScene(itemPos); itemPos = mapToScene(itemPos);
scene()->moveTo(itemPos); scene()->moveTo(itemPos);
scene()->drawLineTo(itemPos, width, true); scene()->drawLineTo(itemPos, mStrokeWidth, true);
} }
void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width) void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width)
{ {
Q_UNUSED(width);
QPointF itemPos = mapFromScene(scenePos); QPointF itemPos = mapFromScene(scenePos);
qreal y; qreal y;
if (drawLineDirection == 0) if (drawLineDirection == 0)
{ {
y = rect().y() + rect().height() + width / 2; y = rect().y() + rect().height() + mStrokeWidth / 2;
} }
else else
{ {
y = rect().y() - width /2; y = rect().y() - mStrokeWidth /2;
} }
if (itemPos.x() < rect().x() + sLeftEdgeMargin) if (itemPos.x() < rect().x() + sLeftEdgeMargin)
itemPos.setX(rect().x() + sLeftEdgeMargin); itemPos.setX(rect().x() + sLeftEdgeMargin);
@ -496,7 +499,7 @@ void UBGraphicsRuler::DrawLine(const QPointF& scenePos, qreal width)
itemPos = mapToScene(itemPos); itemPos = mapToScene(itemPos);
// We have to use "pointed" line for marker tool // We have to use "pointed" line for marker tool
scene()->drawLineTo(itemPos, width, UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker); scene()->drawLineTo(itemPos, mStrokeWidth, UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker);
} }
void UBGraphicsRuler::EndLine() void UBGraphicsRuler::EndLine()

@ -60,7 +60,7 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
virtual void EndLine(); virtual void EndLine();
protected: protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
@ -105,6 +105,8 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
static const int sMinLength = 150; // 3sm static const int sMinLength = 150; // 3sm
static const int sMaxLength = 35000; // 700sm static const int sMaxLength = 35000; // 700sm
qreal mStrokeWidth;
}; };
#endif /* UBGRAPHICSRULER_H_ */ #endif /* UBGRAPHICSRULER_H_ */

@ -855,13 +855,14 @@ void UBGraphicsTriangle::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
void UBGraphicsTriangle::StartLine(const QPointF &scenePos, qreal width) void UBGraphicsTriangle::StartLine(const QPointF &scenePos, qreal width)
{ {
QPointF itemPos = mapFromScene(scenePos); QPointF itemPos = mapFromScene(scenePos);
mStrokeWidth = width;
qreal y; qreal y;
if (mOrientation == 0 || mOrientation == 1) { if (mOrientation == 0 || mOrientation == 1) {
y = rect().y() + rect().height() + width / 2; y = rect().y() + rect().height() + mStrokeWidth / 2;
} else if (mOrientation == 2 || mOrientation == 3) { } else if (mOrientation == 2 || mOrientation == 3) {
y = rect().y() - width / 2; y = rect().y() - mStrokeWidth / 2;
} }
if (itemPos.x() < rect().x() + sLeftEdgeMargin) if (itemPos.x() < rect().x() + sLeftEdgeMargin)
@ -873,19 +874,20 @@ void UBGraphicsTriangle::StartLine(const QPointF &scenePos, qreal width)
itemPos = mapToScene(itemPos); itemPos = mapToScene(itemPos);
scene()->moveTo(itemPos); scene()->moveTo(itemPos);
scene()->drawLineTo(itemPos, width, true); scene()->drawLineTo(itemPos, mStrokeWidth, true);
} }
void UBGraphicsTriangle::DrawLine(const QPointF &scenePos, qreal width) void UBGraphicsTriangle::DrawLine(const QPointF &scenePos, qreal width)
{ {
Q_UNUSED(width);
QPointF itemPos = mapFromScene(scenePos); QPointF itemPos = mapFromScene(scenePos);
qreal y; qreal y;
if (mOrientation == 0 || mOrientation == 1) { if (mOrientation == 0 || mOrientation == 1) {
y = rect().y() + rect().height() + width / 2; y = rect().y() + rect().height() + mStrokeWidth / 2;
} else if (mOrientation == 2 || mOrientation == 3) { } else if (mOrientation == 2 || mOrientation == 3) {
y = rect().y() - width / 2; y = rect().y() - mStrokeWidth / 2;
} }
if (itemPos.x() < rect().x() + sLeftEdgeMargin) if (itemPos.x() < rect().x() + sLeftEdgeMargin)
@ -897,7 +899,7 @@ void UBGraphicsTriangle::DrawLine(const QPointF &scenePos, qreal width)
itemPos = mapToScene(itemPos); itemPos = mapToScene(itemPos);
// We have to use "pointed" line for marker tool // We have to use "pointed" line for marker tool
scene()->drawLineTo(itemPos, width, scene()->drawLineTo(itemPos, mStrokeWidth,
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker); UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker);
} }

@ -168,6 +168,7 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
static const int sArrowLength = 30; static const int sArrowLength = 30;
static const int sMinWidth = 380; static const int sMinWidth = 380;
static const int sMinHeight = 200; static const int sMinHeight = 200;
qreal mStrokeWidth;
}; };
#endif /* UBGRAPHICSTRIANGLE_H_ */ #endif /* UBGRAPHICSTRIANGLE_H_ */

Loading…
Cancel
Save