1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-17 16:20:48 +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. * User-definable map sources.
* Track and elevation/speed graphs. * Track and elevation/speed graphs.
* Support for multiple tracks in one view. * Support for multiple tracks in one view.
* Support for POI files (Garmin CSV format). * Support for POI files.
* Export to PDF. * Export to PDF.
* Native GUI for Windows, Mac OS X and Linux. * Native GUI for Windows, Mac OS X and Linux.

View File

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

View File

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

View File

@ -15,7 +15,8 @@ public:
QString errorString() const {return _error;} QString errorString() const {return _error;}
int errorLine() const {return _errorLine;} 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(); void clear();
@ -27,6 +28,7 @@ private:
POITree _tree; POITree _tree;
QVector<WayPoint> _data; QVector<WayPoint> _data;
QString _error; QString _error;
int _errorLine; int _errorLine;
}; };

View File

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

View File

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

View File

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

View File

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