Subversion Repositories public

Rev

Rev 280 | Details | Compare with Previous | Last modification | View Log | RSS feed

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