Subversion Repositories public

Rev

Rev 221 | Rev 232 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/***************************************************************************
 *   Copyright (C) 2007 - 2009 by Andreas Theofilu                         *
 *   andreas@theosys.at                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation version 3 of the License.                *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef SPORTWATCHERWIDGET_H
#define SPORTWATCHERWIDGET_H

#include <qlabel.h>
#include <qdatetime.h>
#include <qpixmap.h>
#include <qimage.h>
#include <qpainter.h>
#include <qpen.h>
#include <qpoint.h>
#include <qpointarray.h>
#include <qrect.h>
#include <qstring.h>
#include <qtimer.h>
#include <klocale.h>

#if defined HAVE_GDAL && HAVE_LIBGDAL1_5_0
   #include <gdal/gdal_priv.h>
#endif

#include "garmin.h"
#include "managefile.h"
#include "disassemble.h"

#include "sportwatcherwidgetbase.h"

typedef enum {
        MPT_BMP = 0,
        MPT_SHP = 1,
        MPT_VRT = 2,
        MPT_GIF = 3,
        MPT_PNG = 4,
        MPT_SGI = 5,
        MPT_TIF = 6,
        MPT_WMS = 7
} MPT;

typedef struct INDEX
{
        QString path;
        QString activ;
        INDEX *next;
} INDEX;

typedef struct GEORECT
{
        double llat;
        double llon;
        double rlat;
        double rlon;
        int width;
        int height;
} GEORECT;

typedef struct AVGHEIGHT
{
        double alt;             // Altitude
        int    pos;             // Position in the chain, starting with 0
        struct AVGHEIGHT *prev;
        struct AVGHEIGHT *next;
} AVGHEIGHT;

class sportwatcherWidget : public sportwatcherWidgetBase
{
  Q_OBJECT

public:
  sportwatcherWidget(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
  ~sportwatcherWidget();
  /*$PUBLIC_FUNCTIONS$*/

public slots:
  /*$PUBLIC_SLOTS$*/
  virtual void          btFullscreenSlot();
  virtual void          btGlasMinusSlot();
  virtual void          btGlasPlusSlot();
  virtual void          btHandSlot();
  virtual void          btGlasSlot();
  virtual void          btFlagSlot();
  virtual void          liLapsSlot(QListViewItem *item);
  virtual void          liActivitiesSlot(QListViewItem *item);
  virtual void          helpAbout();
  virtual void          helpContents();
  virtual void          helpIndex();
  virtual void          fileExit();
  virtual void          filePrint();
  virtual void          fileSaveAs();
  virtual void          fileSave();
  virtual void          fileOpen();
  virtual void          fileImport();
  virtual void          fileNew();
  virtual void          editRename();
  virtual void          extrasSaveHR();
  virtual void          extrasSettings();
  virtual void          extrasWMSSettings();

protected:
  /*$PROTECTED_FUNCTIONS$*/
  void destroy();
  void showLaps();
  void showTrack();
  void showTrack(int zoom);
  void showTrack(int zoom, const QRect &pan, LAP *lap);
  void showCurves();
  void showCurves(LAP *lap);
  void resizeEvent(QResizeEvent *e);
  void paintEvent(QPaintEvent *e);
  void mouseMoveEvent(QMouseEvent *e);
  void mousePressEvent(QMouseEvent *e);
  void mouseReleaseEvent(QMouseEvent *e);

protected:
  QTimer timer;

protected slots:
  /*$PROTECTED_SLOTS$*/

private:
    QDateTime *garmin_dtime (uint32 t);
    void getActivities();
    bool writeTag(const QFile &fn, const QString &str, int indent);
    bool findIndex(const QString &key);
    double getAvgAlt (AVGHEIGHT *avgHeight, int pos);
    AVGHEIGHT *getAvgPtr (AVGHEIGHT *avgHeight, int pos);
    void saveGPX(const QString &fn);
    void saveOSM(const QString &fn);
#if defined HAVE_GDAL && HAVE_LIBGDAL1_5_0
    bool writeWMSTag(double llat, double llon, double rlat, double rlon, int width, int height);
    bool transCoords (double *x1, double *y1, double *x2, double *y2, int code, int width, int height, bool square);
    QString *getProjection (int isrs, QString *srs);
    bool warpImage(QString fn, QString *fName);
#endif

private:
  QWidget *mama;
  QPixmap pmProfile, pmMap;
  QDateTime StartTime;
  QStringList files;
  QRect mapPan;
  KLocale *kl;          // This is for translating date and time
  manageFile spw;
  disassemble ds;
  garmin_data *gmn;
  int min_hr, max_hr, avg_hr;
  int zfactor;
  double min_height, max_height;
  double min_speed, max_speed;
  double total_distance;
  double oldTransX, oldTransY;
  unsigned long max_time;
  bool stateHand, stateFlag, stateGlas;
  int lmbPressed;
  LAP *mapLap;
  INDEX *index;
#if defined HAVE_GDAL && HAVE_LIBGDAL1_5_0
  GDALDataset *poDataset;
  int mFactor;
  GEORECT geoRect;
#endif

private:
  /* Config Parameters */
  int lower1, lower2, lower3;
  int upper1, upper2, upper3;
  int MaxHr, restHr;
  int vo2max, weight, sampleTime;
  int Units, MapType;
  bool Serial, Contour, Forerunner;
  QString Device, Data, HRM, MAP;
};

#endif