Subversion Repositories public

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
88 andreas 1
/***************************************************************************
119 andreas 2
 *   Copyright (C) 2007, 2008 by Andreas Theofilu                          *
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>
29
#include <qpoint.h>
30
#include <qpointarray.h>
31
#include <qrect.h>
104 andreas 32
#include <qstring.h>
132 andreas 33
#include <qtimer.h>
88 andreas 34
 
155 andreas 35
#if defined HAVE_GDAL && HAVE_LIBGDAL1_5_0
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
 
43
#include "sportwatcherwidgetbase.h"
44
 
158 andreas 45
typedef enum {
46
	MPT_BMP = 0,
47
	MPT_SHP = 1,
48
	MPT_VRT = 2,
49
	MPT_GIF = 3,
50
	MPT_PNG = 4,
51
	MPT_SGI = 5,
52
	MPT_TIF = 6,
53
	MPT_WMS = 7
54
} MPT;
55
 
88 andreas 56
typedef struct INDEX
57
{
58
	QString path;
59
	QString activ;
60
	INDEX *next;
61
} INDEX;
62
 
158 andreas 63
typedef struct GEORECT
64
{
65
	double llat;
66
	double llon;
67
	double rlat;
68
	double rlon;
69
	int width;
70
	int height;
71
} GEORECT;
72
 
169 andreas 73
typedef struct AVGHEIGHT
74
{
75
	double alt;		// Altitude
76
	int    pos;		// Position in the chain, starting with 0
77
	struct AVGHEIGHT *prev;
78
	struct AVGHEIGHT *next;
79
} AVGHEIGHT;
80
 
88 andreas 81
class sportwatcherWidget : public sportwatcherWidgetBase
82
{
83
  Q_OBJECT
84
 
85
public:
86
  sportwatcherWidget(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
87
  ~sportwatcherWidget();
88
  /*$PUBLIC_FUNCTIONS$*/
89
 
90
public slots:
91
  /*$PUBLIC_SLOTS$*/
92
  virtual void          btFullscreenSlot();
93
  virtual void          btGlasMinusSlot();
94
  virtual void          btGlasPlusSlot();
95
  virtual void          btHandSlot();
96
  virtual void          btGlasSlot();
97
  virtual void          btFlagSlot();
98
  virtual void          liLapsSlot(QListViewItem *item);
99
  virtual void          liActivitiesSlot(QListViewItem *item);
100
  virtual void          helpAbout();
101
  virtual void          helpContents();
102
  virtual void          helpIndex();
103
  virtual void          fileExit();
104
  virtual void          filePrint();
105
  virtual void          fileSaveAs();
106
  virtual void          fileSave();
107
  virtual void          fileOpen();
217 andreas 108
  virtual void		fileImport();
88 andreas 109
  virtual void          fileNew();
110
  virtual void		extrasSaveHR();
111
  virtual void		extrasSettings();
152 andreas 112
  virtual void		extrasWMSSettings();
88 andreas 113
 
114
protected:
115
  /*$PROTECTED_FUNCTIONS$*/
100 andreas 116
  void destroy();
88 andreas 117
  void showLaps();
100 andreas 118
  void showTrack();
104 andreas 119
  void showTrack(int zoom);
132 andreas 120
  void showTrack(int zoom, const QRect &pan, LAP *lap);
88 andreas 121
  void showCurves();
148 andreas 122
  void showCurves(LAP *lap);
88 andreas 123
  void resizeEvent(QResizeEvent *e);
124
  void paintEvent(QPaintEvent *e);
132 andreas 125
  void mouseMoveEvent(QMouseEvent *e);
126
  void mousePressEvent(QMouseEvent *e);
127
  void mouseReleaseEvent(QMouseEvent *e);
88 andreas 128
 
132 andreas 129
protected:
130
  QTimer timer;
131
 
88 andreas 132
protected slots:
133
  /*$PROTECTED_SLOTS$*/
134
 
135
private:
136
    QDateTime *garmin_dtime (uint32 t);
137
    void getActivities();
104 andreas 138
    bool writeTag(const QFile &fn, const QString &str, int indent);
132 andreas 139
    bool findIndex(const QString &key);
169 andreas 140
    double getAvgAlt (AVGHEIGHT *avgHeight, int pos);
141
    AVGHEIGHT *getAvgPtr (AVGHEIGHT *avgHeight, int pos);
172 andreas 142
    void saveGPX(const QString &fn);
143
    void saveOSM(const QString &fn);
155 andreas 144
#if defined HAVE_GDAL && HAVE_LIBGDAL1_5_0
151 andreas 145
    bool writeWMSTag(double llat, double llon, double rlat, double rlon, int width, int height);
157 andreas 146
    bool transCoords (double *x1, double *y1, double *x2, double *y2, int code, int width, int height, bool square);
158 andreas 147
    QString *getProjection (int isrs, QString *srs);
148
    bool warpImage(QString fn, QString *fName);
151 andreas 149
#endif
88 andreas 150
 
151
private:
152
  QWidget *mama;
100 andreas 153
  QPixmap pmProfile, pmMap;
88 andreas 154
  QDateTime StartTime;
155
  QStringList files;
132 andreas 156
  QRect mapPan;
88 andreas 157
  manageFile spw;
158
  disassemble ds;
159
  garmin_data *gmn;
160
  int min_hr, max_hr, avg_hr;
104 andreas 161
  int zfactor;
88 andreas 162
  double min_height, max_height;
104 andreas 163
  double total_distance;
132 andreas 164
  double oldTransX, oldTransY;
88 andreas 165
  unsigned long max_time;
132 andreas 166
  bool stateHand, stateFlag, stateGlas;
167
  int lmbPressed;
168
  LAP *mapLap;
88 andreas 169
  INDEX *index;
155 andreas 170
#if defined HAVE_GDAL && HAVE_LIBGDAL1_5_0
151 andreas 171
  GDALDataset *poDataset;
157 andreas 172
  int mFactor;
158 andreas 173
  GEORECT geoRect;
151 andreas 174
#endif
88 andreas 175
 
176
private:
177
  /* Config Parameters */
178
  int lower1, lower2, lower3;
179
  int upper1, upper2, upper3;
180
  int MaxHr, restHr;
181
  int vo2max, weight, sampleTime;
158 andreas 182
  int Units, MapType;
168 andreas 183
  bool Serial, Contour;
143 andreas 184
  QString Device, Data, HRM, MAP;
88 andreas 185
};
186
 
187
#endif
188