1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2016-02-19 21:34:55 +01:00
parent 2f80e612b5
commit 59d8b3cc77
8 changed files with 29 additions and 29 deletions

View File

@ -4,7 +4,7 @@ GPX viewer and analyzer.
* User-definable map sources.
* Track and elevation/speed graphs.
* Support for multiple tracks in one view.
* Support for POI files (Garmin CSV format).
* Support for POI files.
* Export to PDF.
* Native GUI for Windows, Mac OS X and Linux.

View File

@ -13,7 +13,6 @@ HEADERS += src/config.h \
src/rtree.h \
src/ll.h \
src/axisitem.h \
src/poiitem.h \
src/colorshop.h \
src/keys.h \
src/slideritem.h \
@ -33,7 +32,8 @@ HEADERS += src/config.h \
src/trackview.h \
src/track.h \
src/graphview.h \
src/trackpoint.h
src/trackpoint.h \
src/waypointitem.h
SOURCES += src/main.cpp \
src/gui.cpp \
src/gpx.cpp \
@ -41,7 +41,6 @@ SOURCES += src/main.cpp \
src/poi.cpp \
src/ll.cpp \
src/axisitem.cpp \
src/poiitem.cpp \
src/colorshop.cpp \
src/slideritem.cpp \
src/markeritem.cpp \
@ -57,7 +56,8 @@ SOURCES += src/main.cpp \
src/nicenum.cpp \
src/trackview.cpp \
src/track.cpp \
src/graphview.cpp
src/graphview.cpp \
src/waypointitem.cpp
RESOURCES += gpxsee.qrc
TRANSLATIONS = lang/gpxsee_cs.ts
macx:ICON = icons/gpxsee.icns

View File

@ -6,8 +6,6 @@
#include "poi.h"
#define BOUNDING_RECT_SIZE 0.01
bool POI::loadFile(const QString &fileName)
{
QString error;
@ -122,17 +120,17 @@ static bool cb(size_t data, void* context)
return true;
}
QVector<WayPoint> POI::points(const QVector<QPointF> &path) const
QVector<WayPoint> POI::points(const QVector<QPointF> &path, qreal radius) const
{
QVector<WayPoint> ret;
QSet<int> set;
qreal min[2], max[2];
for (int i = 0; i < path.count(); i++) {
min[0] = path.at(i).x() - BOUNDING_RECT_SIZE;
min[1] = path.at(i).y() - BOUNDING_RECT_SIZE;
max[0] = path.at(i).x() + BOUNDING_RECT_SIZE;
max[1] = path.at(i).y() + BOUNDING_RECT_SIZE;
min[0] = path.at(i).x() - radius;
min[1] = path.at(i).y() - radius;
max[0] = path.at(i).x() + radius;
max[1] = path.at(i).y() + radius;
_tree.Search(min, max, cb, &set);
}

View File

@ -15,7 +15,8 @@ public:
QString errorString() const {return _error;}
int errorLine() const {return _errorLine;}
QVector<WayPoint> points(const QVector<QPointF> &path) const;
QVector<WayPoint> points(const QVector<QPointF> &path,
qreal radius = 0.01) const;
void clear();
@ -27,6 +28,7 @@ private:
POITree _tree;
QVector<WayPoint> _data;
QString _error;
int _errorLine;
};

View File

@ -6,7 +6,7 @@
#include "poi.h"
#include "gpx.h"
#include "map.h"
#include "poiitem.h"
#include "waypointitem.h"
#include "markeritem.h"
#include "scaleitem.h"
#include "ll.h"
@ -156,7 +156,7 @@ void TrackView::rescale(qreal scale)
_trackPaths.at(i)->setPen(pen);
}
QHash<WayPoint, POIItem*>::const_iterator it, jt;
QHash<WayPoint, WayPointItem*>::const_iterator it, jt;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
it.value()->setPos(QPointF(it.value()->entry().coordinates().x()
* 1.0/scale, -it.value()->entry().coordinates().y() * 1.0/scale));
@ -176,7 +176,7 @@ void TrackView::rescale(qreal scale)
void TrackView::loadPOI(const POI &poi)
{
QHash<WayPoint, POIItem*>::const_iterator it,jt;
QHash<WayPoint, WayPointItem*>::const_iterator it,jt;
if (!_tracks.size())
return;
@ -188,7 +188,7 @@ void TrackView::loadPOI(const POI &poi)
if (_pois.contains(p.at(i)))
continue;
POIItem *pi = new POIItem(p.at(i));
WayPointItem *pi = new WayPointItem(p.at(i));
pi->setPos(p.at(i).coordinates().x() * 1.0/_scale,
-p.at(i).coordinates().y() * 1.0/_scale);
pi->setZValue(1);
@ -298,7 +298,7 @@ enum QPrinter::Orientation TrackView::orientation() const
void TrackView::clearPOI()
{
QHash<WayPoint, POIItem*>::const_iterator it;
QHash<WayPoint, WayPointItem*>::const_iterator it;
for (it = _pois.constBegin(); it != _pois.constEnd(); it++) {
_scene->removeItem(it.value());

View File

@ -13,7 +13,7 @@
class GPX;
class POI;
class Map;
class POIItem;
class WayPointItem;
class MarkerItem;
class ScaleItem;
@ -61,7 +61,7 @@ private:
QList<QVector<QPointF> > _tracks;
QList<QGraphicsPathItem*> _trackPaths;
QList<MarkerItem*> _markers;
QHash<WayPoint, POIItem*> _pois;
QHash<WayPoint, WayPointItem*> _pois;
Map *_map;
ScaleItem *_mapScale;

View File

@ -1,18 +1,18 @@
#include <QPainter>
#include "config.h"
#include "poiitem.h"
#include "waypointitem.h"
#define POINT_SIZE 8
POIItem::POIItem(const WayPoint &entry, QGraphicsItem *parent)
WayPointItem::WayPointItem(const WayPoint &entry, QGraphicsItem *parent)
: QGraphicsItem(parent)
{
_entry = entry;
updateBoundingRect();
}
void POIItem::updateBoundingRect()
void WayPointItem::updateBoundingRect()
{
QFont font;
font.setPixelSize(FONT_SIZE);
@ -24,7 +24,7 @@ void POIItem::updateBoundingRect()
ts.height() + fm.descent() + POINT_SIZE);
}
void POIItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(option);

View File

@ -1,13 +1,13 @@
#ifndef POIITEM_H
#define POIITEM_H
#ifndef WAYPOINTITEM_H
#define WAYPOINTITEM_H
#include <QGraphicsItem>
#include "waypoint.h"
class POIItem : public QGraphicsItem
class WayPointItem : public QGraphicsItem
{
public:
POIItem(const WayPoint &entry, QGraphicsItem *parent = 0);
WayPointItem(const WayPoint &entry, QGraphicsItem *parent = 0);
const WayPoint &entry() const {return _entry;}
QRectF boundingRect() const {return _boundingRect;}
@ -21,4 +21,4 @@ private:
QRectF _boundingRect;
};
#endif // POIITEM_H
#endif // WAYPOINTITEM_H