Subversion Repositories public

Rev

Rev 280 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 280 Rev 314
Line 1... Line 1...
1
/***************************************************************************
1
/***************************************************************************
2
 *   Copyright (C) 2007 - 2009 by Andreas Theofilu                         *
2
 *   Copyright (C) 2007 - 2013 by Andreas Theofilu                         *
3
 *   andreas@theosys.at                                                    *
3
 *   andreas@theosys.at                                                    *
4
 *                                                                         *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation version 3 of the License.                *
7
 *   the Free Software Foundation version 3 of the License.                *
Line 31... Line 31...
31
#include <qstring.h>
31
#include <qstring.h>
32
#include <qtimer.h>
32
#include <qtimer.h>
33
#include <KLocale>
33
#include <KLocale>
34
 
34
 
35
#if defined HAVE_GDAL
35
#if defined HAVE_GDAL
36
   #include <gdal/gdal_priv.h>
36
#include <gdal/gdal_priv.h>
37
#endif
37
#endif
38
 
38
 
39
#include "garmin.h"
39
#include "garmin.h"
40
#include "managefile.h"
40
#include "managefile.h"
41
#include "disassemble.h"
41
#include "disassemble.h"
-
 
42
#include "import.h"
42
 
43
 
43
#include <QtGui/QWidget>
44
#include <QtGui/QWidget>
44
#include <QTreeWidget>
45
#include <QTreeWidget>
45
#include "ui_sportwatcherwidgetbase.h"
46
#include "ui_sportwatcherwidgetbase.h"
46
 
47
 
47
typedef enum {
48
typedef enum
-
 
49
{
48
	MPT_BMP = 0,
50
    MPT_BMP = 0,
49
	MPT_SHP = 1,
51
    MPT_SHP = 1,
50
	MPT_VRT = 2,
52
    MPT_VRT = 2,
51
	MPT_GIF = 3,
53
    MPT_GIF = 3,
52
	MPT_PNG = 4,
54
    MPT_PNG = 4,
53
	MPT_SGI = 5,
55
    MPT_SGI = 5,
54
	MPT_TIF = 6,
56
    MPT_TIF = 6,
55
	MPT_WMS = 7,
57
    MPT_WMS = 7,
56
	MPT_OSM = 8
58
    MPT_OSM = 8
57
} MPT;
59
} MPT;
58
 
60
 
59
typedef struct GEORECT
61
typedef struct GEORECT
60
{
62
{
61
	double llat;
63
    double llat;
62
	double llon;
64
    double llon;
63
	double rlat;
65
    double rlat;
64
	double rlon;
66
    double rlon;
65
	int width;
67
    int width;
66
	int height;
68
    int height;
67
} GEORECT;
69
} GEORECT;
68
 
70
 
69
typedef struct AVGHEIGHT
71
typedef struct AVGHEIGHT
70
{
72
{
71
	double alt;		// Altitude
73
    double alt;		// Altitude
72
	int    pos;		// Position in the chain, starting with 0
74
    int    pos;		// Position in the chain, starting with 0
73
	struct AVGHEIGHT *prev;
75
    struct AVGHEIGHT *prev;
74
	struct AVGHEIGHT *next;
76
    struct AVGHEIGHT *next;
75
} AVGHEIGHT;
77
} AVGHEIGHT;
76
 
78
 
77
//class sportwatcherWidget : public QWidget, public Ui::sportwatcherWidgetBase
79
//class sportwatcherWidget : public QWidget, public Ui::sportwatcherWidgetBase
78
class sportwatcherWidget : public QWidget, public Ui::sportwatcherWidgetBase
80
class sportwatcherWidget : public QWidget, public Ui::sportwatcherWidgetBase, public CallbackInterface
79
{
81
{
80
	Q_OBJECT
82
    Q_OBJECT
81
 
83
 
82
	public:
84
	public:
83
	   sportwatcherWidget(QWidget *parent = 0);
85
	    sportwatcherWidget (QWidget *parent = 0);
84
	   ~sportwatcherWidget();
86
	    ~sportwatcherWidget();
85
	   /* $PUBLIC_FUNCTIONS$ */
87
	    /* $PUBLIC_FUNCTIONS$ */
86
	   void Initialize();
88
	    void Initialize();
-
 
89
		virtual int cbiCallbackFunction(void *g) { saveImported(g); return 0; }
-
 
90
	    void saveImported (void *g);		// Callback function
87
 
91
 
88
	private:
92
	private:
89
	   Ui::sportwatcherWidgetBase ui_sportwatcherWidgetBase;
93
	    Ui::sportwatcherWidgetBase ui_sportwatcherWidgetBase;
90
 
94
 
91
	public slots:
95
	public slots:
92
	   /* $PUBLIC_SLOTS$ */
96
	    /* $PUBLIC_SLOTS$ */
93
	   void btFullscreenSlot();
97
	    void btFullscreenSlot();
94
	   void btGlasMinusSlot();
98
	    void btGlasMinusSlot();
95
	   void btGlasPlusSlot();
99
	    void btGlasPlusSlot();
96
	   void btHandSlot();
100
	    void btHandSlot();
97
	   void btGlasSlot();
101
	    void btGlasSlot();
98
	   void btFlagSlot();
102
	    void btFlagSlot();
99
	   void liLapsSlot(Q3ListViewItem *item);
103
	    void liLapsSlot ( Q3ListViewItem *item );
100
	   void liActivitiesSlot(QTreeWidgetItem *item, int col);
104
	    void liActivitiesSlot ( QTreeWidgetItem *item, int col );
101
	   void tabViewSlot(int tab);
105
	    void tabViewSlot ( int tab );
102
	   void filePrint();
106
	    void filePrint();
103
	   void fileSaveAs();
107
	    void fileSaveAs();
104
	   void fileSave();
108
	    void fileSave();
105
	   void fileOpen();
109
	    void fileOpen();
106
	   void fileImport();
110
	    void fileImport();
107
	   void fileNew();
111
	    void fileNew();
108
	   void editRename();
112
	    void editRename();
109
	   void extrasSaveHR();
113
	    void extrasSaveHR();
110
	   void extrasSettings();
114
	    void extrasSettings();
111
	   void extrasWMSSettings();
115
	    void extrasWMSSettings();
112
	   void kcbCurveSlot(int idx);
116
	    void kcbCurveSlot ( int idx );
113
 
117
 
114
	protected:
118
	protected:
115
	   /* $PROTECTED_FUNCTIONS$ */
119
	    /* $PROTECTED_FUNCTIONS$ */
116
	   void destroy();
120
	    void destroy();
117
	   void showLaps();
121
	    void showLaps();
118
	   void showTrack();
122
	    void showTrack();
119
	   void showTrack(int zoom);
123
	    void showTrack ( int zoom );
120
	   void showTrack(int zoom, const QRect &pan, LAP *lap);
124
	    void showTrack ( int zoom, const QRect &pan, LAP *lap );
121
	   void showCurves();
125
	    void showCurves();
122
	   void showCurves(LAP *lap);
126
	    void showCurves ( LAP *lap );
123
	   void showThreeCurve(int pw=0, int ph=0);
127
	    void showThreeCurve ( int pw=0, int ph=0 );
124
	   void resizeEvent(QResizeEvent *e);
128
	    void resizeEvent ( QResizeEvent *e );
125
	   void mouseMoveEvent(QMouseEvent *e);
129
	    void mouseMoveEvent ( QMouseEvent *e );
126
	   void mousePressEvent(QMouseEvent *e);
130
	    void mousePressEvent ( QMouseEvent *e );
127
	   void mouseReleaseEvent(QMouseEvent *e);
131
	    void mouseReleaseEvent ( QMouseEvent *e );
128
 
132
 
129
	protected:
133
	protected:
130
	   QTimer timer;
134
	    QTimer timer;
131
 
135
 
132
	private:
136
	private:
133
	   void getActivities();
137
	    void getActivities();
134
	   QDateTime *garmin_dtime (uint32 t);
138
	    QDateTime *garmin_dtime ( uint32 t );
135
	   bool writeTag(const QFile &fn, const QString &str, int indent);
139
	    bool writeTag ( const QFile &fn, const QString &str, int indent );
136
	   double getAvgAlt (AVGHEIGHT *avgHeight, int pos);
140
	    double getAvgAlt ( AVGHEIGHT *avgHeight, int pos );
137
	   AVGHEIGHT *getAvgPtr (AVGHEIGHT *avgHeight, int pos);
141
	    AVGHEIGHT *getAvgPtr ( AVGHEIGHT *avgHeight, int pos );
138
	   void saveGPX(const QString &fn);
142
	    void saveGPX ( const QString &fn );
139
	   void saveOSM(const QString &fn);
143
	    void saveOSM ( const QString &fn );
140
	   QTreeWidgetItem *findElement(QTreeWidget *wdg, const QString &val);
144
	    QTreeWidgetItem *findElement ( QTreeWidget *wdg, const QString &val );
141
	   void drawGrHR (int x, int y);
145
	    void drawGrHR ( int x, int y );
142
	   void drawGrElev (int x, int y);
146
	    void drawGrElev ( int x, int y );
143
	   void drawGrSpeed (int x, int y);
147
	    void drawGrSpeed ( int x, int y );
144
	   qreal milToPixel(qreal, QPrinter &pr, bool dir=false);
148
	    qreal milToPixel ( qreal, QPrinter &pr, bool dir=false );
145
#if defined HAVE_GDAL
149
	#if defined HAVE_GDAL
146
	   bool writeWMSTag(double llat, double llon, double rlat, double rlon, int width, int height);
150
	    bool writeWMSTag ( double llat, double llon, double rlat, double rlon, int width, int height );
147
	   bool transCoords (double *x1, double *y1, double *x2, double *y2, int code, int width, int height, bool square);
151
	    bool transCoords ( double *x1, double *y1, double *x2, double *y2, int code, int width, int height, bool square );
148
	   QString *getProjection (int isrs, QString *srs);
152
	    QString *getProjection ( int isrs, QString *srs );
149
	   bool warpImage(QString fn, QString *fName);
153
	    bool warpImage ( QString fn, QString *fName );
150
#endif
154
	#endif
151
 
155
 
152
	private:
156
	private:
153
	   QWidget *mama;
157
	    QWidget *mama;
154
	   QPixmap pmProfile, pmMap, pmHR, pmElevation, pmSpeed;
158
	    QPixmap pmProfile, pmMap, pmHR, pmElevation, pmSpeed;
155
	   QPixmap pmPrMap, prHR, prElevation, prSpeed;	// These are used for printing
159
	    QPixmap pmPrMap, prHR, prElevation, prSpeed;	// These are used for printing
156
	   QDateTime StartTime;
160
	    QDateTime StartTime;
157
	   QStringList files;
161
	    QStringList files;
158
	   QRect mapPan;
162
	    QRect mapPan;
159
	   KLocale *kl;		// This is for translating date and time to the locale
163
	    KLocale *kl;		// This is for translating date and time to the locale
160
	   manageFile spw;
164
	    manageFile spw;
161
	   disassemble ds;
165
	    disassemble ds;
162
	   garmin_data *gmn;
166
	    garmin_data *gmn;
163
	   int min_hr, max_hr, avg_hr;
167
	    int min_hr, max_hr, avg_hr;
164
	   int zfactor;
168
	    int zfactor;
165
	   double min_height, max_height;
169
	    double min_height, max_height;
166
	   double min_speed, max_speed;
170
	    double min_speed, max_speed;
167
	   double total_distance;
171
	    double total_distance;
168
	   double oldTransX, oldTransY;
172
	    double oldTransX, oldTransY;
169
	   unsigned long max_time;
173
	    unsigned long max_time;
170
	   bool stateHand, stateFlag, stateGlas;
174
	    bool stateHand, stateFlag, stateGlas;
171
	   int lmbPressed;
175
	    int lmbPressed;
172
	   LAP *mapLap;
176
	    LAP *mapLap;
173
	   int curTab;
177
	    int curTab;
174
	   bool tabDirt0, tabDirt1, tabDirt2, tabDirt3;
178
	    bool tabDirt0, tabDirt1, tabDirt2, tabDirt3;
175
	   bool ActivePrint;
179
	    bool ActivePrint;
176
	   QPainter printArea;
180
	    QPainter printArea;
177
#if defined HAVE_GDAL
181
	#if defined HAVE_GDAL
178
	   GDALDataset *poDataset;
182
	    GDALDataset *poDataset;
179
	   int mFactor;
183
	    int mFactor;
180
	   GEORECT geoRect;
184
	    GEORECT geoRect;
181
#endif
185
	#endif
182
 
186
 
183
	private:
187
	private:
184
	   /* Config Parameters */
188
	    /* Config Parameters */
185
	   int lower1, lower2, lower3;
189
	    int lower1, lower2, lower3;
186
	   int upper1, upper2, upper3;
190
	    int upper1, upper2, upper3;
187
	   int MaxHr, restHr;
191
	    int MaxHr, restHr;
188
	   int vo2max, weight, sampleTime;
192
	    int vo2max, weight, sampleTime;
189
	   int Units, MapType;
193
	    int Units, MapType;
190
	   bool Serial, Contour, Forerunner;
194
	    bool Serial, Contour, Forerunner;
191
	   bool DIRTY;
195
	    bool DIRTY;
192
	   QString Device, Data, HRM, MAP;
196
	    QString Device, Data, HRM, MAP;
193
};
197
};
194
 
198
 
195
#endif
199
#endif