Subversion Repositories public

Rev

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

/***************************************************************************
 *   Copyright (C) 2007, 2008 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>

#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 struct INDEX
{
        QString path;
        QString activ;
        INDEX *next;
} INDEX;

typedef struct BMP_HEADER
{
//      uint16 bfType;
        unsigned int bfSize;
        unsigned int bfReserved;
        unsigned int bfOffBits;
} BMP_HEADER;

typedef struct BMP_INFO
{
        unsigned int biSize;
        int biWidth;
        int biHeight;
        unsigned short biPlanes;
        unsigned short biBitCount;
        unsigned int biCompression;
        unsigned int biSizeImage;
        int biXPelsPerMeter;
        int biYPelsPerMeter;
        unsigned int biClrUsed;
        unsigned int biClrImportant;
} BMP_INFO;

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          fileNew();
  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);
#if defined HAVE_GDAL && HAVE_LIBGDAL1_5_0
    bool writeWMSTag(double llat, double llon, double rlat, double rlon, int width, int height);
    void fillBMPHeader (BMP_HEADER *bmpH, BMP_INFO *bmpI, int nXSize, int nYSize, int nRasterCount);
#endif

private:
  QWidget *mama;
  QPixmap pmProfile, pmMap;
  QDateTime StartTime;
  QStringList files;
  QRect mapPan;
  manageFile spw;
  disassemble ds;
  garmin_data *gmn;
  int min_hr, max_hr, avg_hr;
  int zfactor;
  double min_height, max_height;
  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;
#endif

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

#endif