Subversion Repositories public

Rev

Rev 250 | Rev 280 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
88 andreas 1
/***************************************************************************
221 andreas 2
 *   Copyright (C) 2007 - 2009 by Andreas Theofilu                         *
119 andreas 3
 *   andreas@theosys.at                                                    *
88 andreas 4
 *                                                                         *
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  *
7
 *   the Free Software Foundation version 3 of the License.                *
8
 *                                                                         *
9
 *   This program is distributed in the hope that it will be useful,       *
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 *   GNU General Public License for more details.                          *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
19
 
20
#ifndef SPORTWATCHERWIDGET_H
21
#define SPORTWATCHERWIDGET_H
22
 
23
#include <qlabel.h>
24
#include <qdatetime.h>
25
#include <qpixmap.h>
26
#include <qimage.h>
27
#include <qpainter.h>
28
#include <qpen.h>
232 andreas 29
#include <QPoint>
88 andreas 30
#include <qrect.h>
104 andreas 31
#include <qstring.h>
132 andreas 32
#include <qtimer.h>
245 andreas 33
#include <KLocale>
88 andreas 34
 
232 andreas 35
#if defined HAVE_GDAL
151 andreas 36
   #include <gdal/gdal_priv.h>
37
#endif
38
 
88 andreas 39
#include "garmin.h"
40
#include "managefile.h"
41
#include "disassemble.h"
42
 
232 andreas 43
#include <QtGui/QWidget>
246 andreas 44
#include <QTreeWidget>
232 andreas 45
#include "ui_sportwatcherwidgetbase.h"
88 andreas 46
 
158 andreas 47
typedef enum {
48
	MPT_BMP = 0,
49
	MPT_SHP = 1,
50
	MPT_VRT = 2,
51
	MPT_GIF = 3,
52
	MPT_PNG = 4,
53
	MPT_SGI = 5,
54
	MPT_TIF = 6,
276 andreas 55
	MPT_WMS = 7,
56
	MPT_OSM = 8
158 andreas 57
} MPT;
58
 
59
typedef struct GEORECT
60
{
61
	double llat;
62
	double llon;
63
	double rlat;
64
	double rlon;
65
	int width;
66
	int height;
67
} GEORECT;
68
 
169 andreas 69
typedef struct AVGHEIGHT
70
{
71
	double alt;		// Altitude
72
	int    pos;		// Position in the chain, starting with 0
73
	struct AVGHEIGHT *prev;
74
	struct AVGHEIGHT *next;
75
} AVGHEIGHT;
76
 
232 andreas 77
//class sportwatcherWidget : public QWidget, public Ui::sportwatcherWidgetBase
245 andreas 78
class sportwatcherWidget : public QWidget, public Ui::sportwatcherWidgetBase
88 andreas 79
{
245 andreas 80
	Q_OBJECT
88 andreas 81
 
245 andreas 82
	public:
83
	   sportwatcherWidget(QWidget *parent = 0);
84
	   ~sportwatcherWidget();
85
	   /* $PUBLIC_FUNCTIONS$ */
86
	   void Initialize();
88 andreas 87
 
245 andreas 88
	private:
89
	   Ui::sportwatcherWidgetBase ui_sportwatcherWidgetBase;
232 andreas 90
 
245 andreas 91
	public slots:
92
	   /* $PUBLIC_SLOTS$ */
93
	   void btFullscreenSlot();
94
	   void btGlasMinusSlot();
95
	   void btGlasPlusSlot();
96
	   void btHandSlot();
97
	   void btGlasSlot();
98
	   void btFlagSlot();
99
	   void liLapsSlot(Q3ListViewItem *item);
246 andreas 100
	   void liActivitiesSlot(QTreeWidgetItem *item, int col);
248 andreas 101
	   void tabViewSlot(int tab);
245 andreas 102
	   void filePrint();
103
	   void fileSaveAs();
104
	   void fileSave();
105
	   void fileOpen();
106
	   void fileImport();
107
	   void fileNew();
108
	   void editRename();
109
	   void extrasSaveHR();
110
	   void extrasSettings();
111
	   void extrasWMSSettings();
112
	   void kcbCurveSlot(int idx);
88 andreas 113
 
245 andreas 114
	protected:
115
	   /* $PROTECTED_FUNCTIONS$ */
116
	   void destroy();
117
	   void showLaps();
118
	   void showTrack();
119
	   void showTrack(int zoom);
120
	   void showTrack(int zoom, const QRect &pan, LAP *lap);
121
	   void showCurves();
122
	   void showCurves(LAP *lap);
250 andreas 123
	   void showThreeCurve();
245 andreas 124
	   void resizeEvent(QResizeEvent *e);
125
	   void mouseMoveEvent(QMouseEvent *e);
126
	   void mousePressEvent(QMouseEvent *e);
127
	   void mouseReleaseEvent(QMouseEvent *e);
88 andreas 128
 
245 andreas 129
	protected:
130
	   QTimer timer;
132 andreas 131
 
245 andreas 132
	private:
133
	   void getActivities();
134
	   QDateTime *garmin_dtime (uint32 t);
135
	   bool writeTag(const QFile &fn, const QString &str, int indent);
136
	   double getAvgAlt (AVGHEIGHT *avgHeight, int pos);
137
	   AVGHEIGHT *getAvgPtr (AVGHEIGHT *avgHeight, int pos);
138
	   void saveGPX(const QString &fn);
139
	   void saveOSM(const QString &fn);
247 andreas 140
	   QTreeWidgetItem *findElement(QTreeWidget *wdg, const QString &val);
250 andreas 141
	   void drawGrHR (int x, int y);
142
	   void drawGrElev (int x, int y);
143
	   void drawGrSpeed (int x, int y);
232 andreas 144
#if defined HAVE_GDAL
245 andreas 145
	   bool writeWMSTag(double llat, double llon, double rlat, double rlon, int width, int height);
146
	   bool transCoords (double *x1, double *y1, double *x2, double *y2, int code, int width, int height, bool square);
147
	   QString *getProjection (int isrs, QString *srs);
148
	   bool warpImage(QString fn, QString *fName);
151 andreas 149
#endif
88 andreas 150
 
245 andreas 151
	private:
152
	   QWidget *mama;
250 andreas 153
	   QPixmap pmProfile, pmMap, pmHR, pmElevation, pmSpeed;
245 andreas 154
	   QDateTime StartTime;
155
	   QStringList files;
156
	   QRect mapPan;
157
	   KLocale *kl;		// This is for translating date and time
158
	   manageFile spw;
159
	   disassemble ds;
160
	   garmin_data *gmn;
161
	   int min_hr, max_hr, avg_hr;
162
	   int zfactor;
163
	   double min_height, max_height;
164
	   double min_speed, max_speed;
165
	   double total_distance;
166
	   double oldTransX, oldTransY;
167
	   unsigned long max_time;
168
	   bool stateHand, stateFlag, stateGlas;
169
	   int lmbPressed;
170
	   LAP *mapLap;
248 andreas 171
	   int curTab;
172
	   bool tabDirt0, tabDirt1, tabDirt2, tabDirt3;
232 andreas 173
#if defined HAVE_GDAL
245 andreas 174
	   GDALDataset *poDataset;
175
	   int mFactor;
176
	   GEORECT geoRect;
151 andreas 177
#endif
88 andreas 178
 
245 andreas 179
	private:
180
	   /* Config Parameters */
181
	   int lower1, lower2, lower3;
182
	   int upper1, upper2, upper3;
183
	   int MaxHr, restHr;
184
	   int vo2max, weight, sampleTime;
185
	   int Units, MapType;
186
	   bool Serial, Contour, Forerunner;
246 andreas 187
	   bool DIRTY;
245 andreas 188
	   QString Device, Data, HRM, MAP;
88 andreas 189
};
190
 
191
#endif