1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-20 05:44:23 +02:00

Added options dialogue

This commit is contained in:
2016-12-06 01:48:26 +01:00
parent 181f60ed40
commit a9668ca86e
34 changed files with 1044 additions and 195 deletions

View File

@ -6,13 +6,10 @@
#include "pathitem.h"
#define PATH_WIDTH 3
#define HOVER_WIDTH 4
void PathItem::updateShape()
{
QPainterPathStroker s;
s.setWidth(HOVER_WIDTH * 1.0/scale());
s.setWidth((_width + 1) * 1.0/scale());
_shape = s.createStroke(_path);
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
@ -23,8 +20,10 @@ void PathItem::updateShape()
PathItem::PathItem(QGraphicsItem *parent) : QGraphicsObject(parent)
{
_width = 3;
QBrush brush(Qt::SolidPattern);
_pen = QPen(brush, PATH_WIDTH);
_pen = QPen(brush, _width);
_units = Metric;
@ -54,7 +53,7 @@ void PathItem::setScale(qreal scale)
{
prepareGeometryChange();
_pen.setWidthF(PATH_WIDTH * 1.0/scale);
_pen.setWidthF(_width * 1.0/scale);
QGraphicsItem::setScale(scale);
_marker->setScale(1.0/scale);
@ -67,6 +66,22 @@ void PathItem::setColor(const QColor &color)
update();
}
void PathItem::setWidth(int width)
{
prepareGeometryChange();
_width = width;
_pen.setWidthF(_width * 1.0/scale());
updateShape();
}
void PathItem::setStyle(Qt::PenStyle style)
{
_pen.setStyle(style);
update();
}
void PathItem::setUnits(enum Units units)
{
_units = units;
@ -120,7 +135,7 @@ void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
_pen.setWidthF((_width + 1) * 1.0/scale());
setZValue(zValue() + 1.0);
update();
@ -131,7 +146,7 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
_pen.setWidthF(PATH_WIDTH * 1.0/scale());
_pen.setWidthF(_width * 1.0/scale());
setZValue(zValue() - 1.0);
update();