mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 03:42:09 +01:00
Various route-releated fixes & improvements
This commit is contained in:
parent
c00ebdeefd
commit
8624b42e0b
@ -607,6 +607,14 @@
|
|||||||
<translation>km</translation>
|
<translation>km</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>RouteItem</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/routeitem.cpp" line="17"/>
|
||||||
|
<source>Distance</source>
|
||||||
|
<translation>Vzdálenost</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>ScaleItem</name>
|
<name>ScaleItem</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -55,6 +55,22 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GraphView::~GraphView()
|
||||||
|
{
|
||||||
|
if (_xAxis->scene() != _scene)
|
||||||
|
delete _xAxis;
|
||||||
|
if (_yAxis->scene() != _scene)
|
||||||
|
delete _yAxis;
|
||||||
|
if (_slider->scene() != _scene)
|
||||||
|
delete _slider;
|
||||||
|
if (_info->scene() != _scene)
|
||||||
|
delete _info;
|
||||||
|
|
||||||
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
|
if (_graphs.at(i)->scene() != _scene)
|
||||||
|
delete _graphs[i];
|
||||||
|
}
|
||||||
|
|
||||||
void GraphView::createXLabel()
|
void GraphView::createXLabel()
|
||||||
{
|
{
|
||||||
_xAxis->setLabel(QString("%1 [%2]").arg(_xLabel).arg(_xUnits));
|
_xAxis->setLabel(QString("%1 [%2]").arg(_xLabel).arg(_xUnits));
|
||||||
|
@ -33,6 +33,7 @@ class GraphView : public QGraphicsView
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
GraphView(QWidget *parent = 0);
|
GraphView(QWidget *parent = 0);
|
||||||
|
~GraphView();
|
||||||
|
|
||||||
void loadData(const QVector<QPointF> &data, int id = 0);
|
void loadData(const QVector<QPointF> &data, int id = 0);
|
||||||
int count() const {return _graphs.count();}
|
int count() const {return _graphs.count();}
|
||||||
|
@ -146,10 +146,14 @@ void Parser::routepointData()
|
|||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "name")
|
if (_reader.name() == "name")
|
||||||
handleRoutepointData(Name, _reader.readElementText());
|
handleRoutepointData(Name, _reader.readElementText());
|
||||||
|
else if (_reader.name() == "desc")
|
||||||
|
handleRoutepointData(Description, _reader.readElementText());
|
||||||
else if (_reader.name() == "ele")
|
else if (_reader.name() == "ele")
|
||||||
handleRoutepointData(Elevation, _reader.readElementText());
|
handleRoutepointData(Elevation, _reader.readElementText());
|
||||||
else if (_reader.name() == "geoidheight")
|
else if (_reader.name() == "geoidheight")
|
||||||
handleRoutepointData(Geoidheight, _reader.readElementText());
|
handleRoutepointData(Geoidheight, _reader.readElementText());
|
||||||
|
else if (_reader.name() == "time")
|
||||||
|
handleRoutepointData(Time, _reader.readElementText());
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,32 @@
|
|||||||
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "ll.h"
|
#include "ll.h"
|
||||||
|
#include "misc.h"
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
|
#include "tooltip.h"
|
||||||
#include "routeitem.h"
|
#include "routeitem.h"
|
||||||
|
|
||||||
|
|
||||||
#define ROUTE_WIDTH 3
|
#define ROUTE_WIDTH 3
|
||||||
|
|
||||||
|
QString RouteItem::toolTip()
|
||||||
|
{
|
||||||
|
ToolTip tt;
|
||||||
|
|
||||||
|
tt.insert(qApp->translate("RouteItem", "Distance"),
|
||||||
|
::distance(_distance, _units));
|
||||||
|
|
||||||
|
return tt.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RouteItem::updateShape()
|
||||||
|
{
|
||||||
|
QPainterPathStroker s;
|
||||||
|
s.setWidth(ROUTE_WIDTH * 1.0/scale());
|
||||||
|
_shape = s.createStroke(_path);
|
||||||
|
}
|
||||||
|
|
||||||
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent)
|
: QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
@ -26,8 +46,14 @@ RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
|||||||
wi->setParentItem(this);
|
wi->setParentItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_units = Metric;
|
||||||
_distance = route.distance();
|
_distance = route.distance();
|
||||||
|
|
||||||
|
setToolTip(toolTip());
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
|
||||||
|
updateShape();
|
||||||
|
|
||||||
QBrush brush(Qt::SolidPattern);
|
QBrush brush(Qt::SolidPattern);
|
||||||
_pen = QPen(brush, ROUTE_WIDTH, Qt::DotLine);
|
_pen = QPen(brush, ROUTE_WIDTH, Qt::DotLine);
|
||||||
|
|
||||||
@ -60,6 +86,8 @@ void RouteItem::setScale(qreal scale)
|
|||||||
QList<QGraphicsItem *> childs = childItems();
|
QList<QGraphicsItem *> childs = childItems();
|
||||||
for (int i = 0; i < childs.count(); i++)
|
for (int i = 0; i < childs.count(); i++)
|
||||||
childs.at(i)->setScale(1.0/scale);
|
childs.at(i)->setScale(1.0/scale);
|
||||||
|
|
||||||
|
updateShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::setColor(const QColor &color)
|
void RouteItem::setColor(const QColor &color)
|
||||||
@ -68,6 +96,12 @@ void RouteItem::setColor(const QColor &color)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouteItem::setUnits(enum Units units)
|
||||||
|
{
|
||||||
|
_units = units;
|
||||||
|
setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
void RouteItem::moveMarker(qreal distance)
|
void RouteItem::moveMarker(qreal distance)
|
||||||
{
|
{
|
||||||
if (distance > _distance)
|
if (distance > _distance)
|
||||||
|
@ -4,13 +4,16 @@
|
|||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include "markeritem.h"
|
#include "markeritem.h"
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
|
|
||||||
class RouteItem : public QGraphicsItem
|
class RouteItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RouteItem(const Route &route, QGraphicsItem *parent = 0);
|
RouteItem(const Route &route, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QRectF boundingRect() const {return _path.boundingRect();}
|
QPainterPath shape() const {return _shape;}
|
||||||
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
@ -18,6 +21,7 @@ public:
|
|||||||
|
|
||||||
void setScale(qreal scale);
|
void setScale(qreal scale);
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
|
void setUnits(enum Units units);
|
||||||
|
|
||||||
void showMarker(bool show) {_marker->setVisible(show);}
|
void showMarker(bool show) {_marker->setVisible(show);}
|
||||||
void moveMarker(qreal distance);
|
void moveMarker(qreal distance);
|
||||||
@ -26,11 +30,16 @@ public:
|
|||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateShape();
|
||||||
|
QString toolTip();
|
||||||
|
|
||||||
QPainterPath _path;
|
QPainterPath _path;
|
||||||
|
QPainterPath _shape;
|
||||||
QPen _pen;
|
QPen _pen;
|
||||||
|
|
||||||
MarkerItem *_marker;
|
MarkerItem *_marker;
|
||||||
|
|
||||||
|
Units _units;
|
||||||
qreal _distance;
|
qreal _distance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -341,7 +341,8 @@ void TrackView::setUnits(enum Units units)
|
|||||||
|
|
||||||
for (int i = 0; i < _tracks.count(); i++)
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
_tracks[i]->setUnits(units);
|
_tracks[i]->setUnits(units);
|
||||||
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
|
_routes[i]->setUnits(units);
|
||||||
for (int i = 0; i < _waypoints.size(); i++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setUnits(units);
|
_waypoints.at(i)->setUnits(units);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user