Subversion Repositories public

Rev

Rev 248 | Rev 276 | 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,
55
	MPT_WMS = 7
56
} MPT;
57
 
58
typedef struct GEORECT
59
{
60
	double llat;
61
	double llon;
62
	double rlat;
63
	double rlon;
64
	int width;
65
	int height;
66
} GEORECT;
67
 
169 andreas 68
typedef struct AVGHEIGHT
69
{
70
	double alt;		// Altitude
71
	int    pos;		// Position in the chain, starting with 0
72
	struct AVGHEIGHT *prev;
73
	struct AVGHEIGHT *next;
74
} AVGHEIGHT;
75
 
232 andreas 76
//class sportwatcherWidget : public QWidget, public Ui::sportwatcherWidgetBase
245 andreas 77
class sportwatcherWidget : public QWidget, public Ui::sportwatcherWidgetBase
88 andreas 78
{
245 andreas 79
	Q_OBJECT
88 andreas 80
 
245 andreas 81
	public:
82
	   sportwatcherWidget(QWidget *parent = 0);
83
	   ~sportwatcherWidget();
84
	   /* $PUBLIC_FUNCTIONS$ */
85
	   void Initialize();
88 andreas 86
 
245 andreas 87
	private:
88
	   Ui::sportwatcherWidgetBase ui_sportwatcherWidgetBase;
232 andreas 89
 
245 andreas 90
	public slots:
91
	   /* $PUBLIC_SLOTS$ */
92
	   void btFullscreenSlot();
93
	   void btGlasMinusSlot();
94
	   void btGlasPlusSlot();
95
	   void btHandSlot();
96
	   void btGlasSlot();
97
	   void btFlagSlot();
98
	   void liLapsSlot(Q3ListViewItem *item);
246 andreas 99
	   void liActivitiesSlot(QTreeWidgetItem *item, int col);
248 andreas 100
	   void tabViewSlot(int tab);
245 andreas 101
	   void filePrint();
102
	   void fileSaveAs();
103
	   void fileSave();
104
	   void fileOpen();
105
	   void fileImport();
106
	   void fileNew();
107
	   void editRename();
108
	   void extrasSaveHR();
109
	   void extrasSettings();
110
	   void extrasWMSSettings();
111
	   void kcbCurveSlot(int idx);
88 andreas 112
 
245 andreas 113
	protected:
114
	   /* $PROTECTED_FUNCTIONS$ */
115
	   void destroy();
116
	   void showLaps();
117
	   void showTrack();
118
	   void showTrack(int zoom);
119
	   void showTrack(int zoom, const QRect &pan, LAP *lap);
120
	   void showCurves();
121
	   void showCurves(LAP *lap);
250 andreas 122
	   void showThreeCurve();
245 andreas 123
	   void resizeEvent(QResizeEvent *e);
124
	   void mouseMoveEvent(QMouseEvent *e);
125
	   void mousePressEvent(QMouseEvent *e);
126
	   void mouseReleaseEvent(QMouseEvent *e);
88 andreas 127
 
245 andreas 128
	protected:
129
	   QTimer timer;
132 andreas 130
 
245 andreas 131
	private:
132
	   void getActivities();
133
	   QDateTime *garmin_dtime (uint32 t);
134
	   bool writeTag(const QFile &fn, const QString &str, int indent);
135
	   double getAvgAlt (AVGHEIGHT *avgHeight, int pos);
136
	   AVGHEIGHT *getAvgPtr (AVGHEIGHT *avgHeight, int pos);
137
	   void saveGPX(const QString &fn);
138
	   void saveOSM(const QString &fn);
247 andreas 139
	   QTreeWidgetItem *findElement(QTreeWidget *wdg, const QString &val);
250 andreas 140
	   void drawGrHR (int x, int y);
141
	   void drawGrElev (int x, int y);
142
	   void drawGrSpeed (int x, int y);
232 andreas 143
#if defined HAVE_GDAL
245 andreas 144
	   bool writeWMSTag(double llat, double llon, double rlat, double rlon, int width, int height);
145
	   bool transCoords (double *x1, double *y1, double *x2, double *y2, int code, int width, int height, bool square);
146
	   QString *getProjection (int isrs, QString *srs);
147
	   bool warpImage(QString fn, QString *fName);
151 andreas 148
#endif
88 andreas 149
 
245 andreas 150
	private:
151
	   QWidget *mama;
250 andreas 152
	   QPixmap pmProfile, pmMap, pmHR, pmElevation, pmSpeed;
245 andreas 153
	   QDateTime StartTime;
154
	   QStringList files;
155
	   QRect mapPan;
156
	   KLocale *kl;		// This is for translating date and time
157
	   manageFile spw;
158
	   disassemble ds;
159
	   garmin_data *gmn;
160
	   int min_hr, max_hr, avg_hr;
161
	   int zfactor;
162
	   double min_height, max_height;
163
	   double min_speed, max_speed;
164
	   double total_distance;
165
	   double oldTransX, oldTransY;
166
	   unsigned long max_time;
167
	   bool stateHand, stateFlag, stateGlas;
168
	   int lmbPressed;
169
	   LAP *mapLap;
248 andreas 170
	   int curTab;
171
	   bool tabDirt0, tabDirt1, tabDirt2, tabDirt3;
232 andreas 172
#if defined HAVE_GDAL
245 andreas 173
	   GDALDataset *poDataset;
174
	   int mFactor;
175
	   GEORECT geoRect;
151 andreas 176
#endif
88 andreas 177
 
245 andreas 178
	private:
179
	   /* Config Parameters */
180
	   int lower1, lower2, lower3;
181
	   int upper1, upper2, upper3;
182
	   int MaxHr, restHr;
183
	   int vo2max, weight, sampleTime;
184
	   int Units, MapType;
185
	   bool Serial, Contour, Forerunner;
246 andreas 186
	   bool DIRTY;
245 andreas 187
	   QString Device, Data, HRM, MAP;
88 andreas 188
};
189
 
190
#endif