Subversion Repositories public

Rev

Rev 217 | Rev 221 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 217 Rev 218
Line 32... Line 32...
32
#include <ksimpleconfig.h>
32
#include <ksimpleconfig.h>
33
#include <klocale.h>
33
#include <klocale.h>
34
#include <klistview.h>
34
#include <klistview.h>
35
#include <kaboutdialog.h>
35
#include <kaboutdialog.h>
36
#include <kaboutdata.h>
36
#include <kaboutdata.h>
-
 
37
#include <kinputdialog.h>
37
#include <kglobalsettings.h>
38
#include <kglobalsettings.h>
-
 
39
#include <kcombobox.h>
38
#include <qapplication.h>
40
#include <qapplication.h>
39
#include <qstring.h>
41
#include <qstring.h>
40
#include <qdatetime.h>
42
#include <qdatetime.h>
41
#include <qtoolbutton.h>
43
#include <qtoolbutton.h>
42
#include <qcursor.h>
44
#include <qcursor.h>
Line 48... Line 50...
48
   #include <gdal/ogrsf_frmts.h>
50
   #include <gdal/ogrsf_frmts.h>
49
   #include <gdal/gdalwarper.h>
51
   #include <gdal/gdalwarper.h>
50
   #include <gdal/ogrsf_frmts.h>
52
   #include <gdal/ogrsf_frmts.h>
51
#endif
53
#endif
52
 
54
 
-
 
55
#include "garmin.h"
53
#include "copy.h"
56
#include "copy.h"
54
#include "transform.h"
57
#include "transform.h"
55
#include "import.h"
58
#include "import.h"
56
 
59
 
57
// #define DEBUG	1
60
// #define DEBUG	1
Line 201... Line 204...
201
 
204
 
202
	destroy();
205
	destroy();
203
	liActivities->clear();
206
	liActivities->clear();
204
	liActivities->setRootIsDecorated(true);
207
	liActivities->setRootIsDecorated(true);
205
	liActivities->setSortColumn(-1);
208
	liActivities->setSortColumn(-1);
-
 
209
	liActivities->addColumn(QString("Path"), 0);
-
 
210
	liActivities->hideColumn(1);
206
	other = new KListViewItem(liActivities, i18n("Others"));
211
	other = new KListViewItem(liActivities, i18n("Others"));
207
	biking = new KListViewItem(liActivities, i18n("Biking"));
212
	biking = new KListViewItem(liActivities, i18n("Biking"));
208
	running = new KListViewItem(liActivities, i18n("Running"));
213
	running = new KListViewItem(liActivities, i18n("Running"));
209
 
214
 
210
	other->setPixmap(0, QPixmap::fromMimeSource(QString("history.png")));
215
	other->setPixmap(0, QPixmap::fromMimeSource(QString("history.png")));
Line 337... Line 342...
337
 
342
 
338
	   switch (rn->run->sport_type)
343
	   switch (rn->run->sport_type)
339
	   {
344
	   {
340
	      case D1000_running:
345
	      case D1000_running:
341
		 el = new KListViewItem(running, idx);
346
		 el = new KListViewItem(running, idx);
-
 
347
		 el->setText(1, *strfl);
342
		 el->setPixmap(0, QPixmap::fromMimeSource(QString("run.png")));
348
		 el->setPixmap(0, QPixmap::fromMimeSource(QString("run.png")));
343
		 running->insertItem(el);
349
		 running->insertItem(el);
344
	      break;
350
	      break;
345
 
351
 
346
	      case D1000_biking:
352
	      case D1000_biking:
347
		 el = new KListViewItem(biking, idx);
353
		 el = new KListViewItem(biking, idx);
-
 
354
		 el->setText(1, *strfl);
348
		 el->setPixmap(0, QPixmap::fromMimeSource(QString("bike.png")));
355
		 el->setPixmap(0, QPixmap::fromMimeSource(QString("bike.png")));
349
		 biking->insertItem(el);
356
		 biking->insertItem(el);
350
	      break;
357
	      break;
351
 
358
 
352
	      case D1000_other:
359
	      case D1000_other:
353
		 el = new KListViewItem(other, idx);
360
		 el = new KListViewItem(other, idx);
-
 
361
		 el->setText(1, *strfl);
354
		 el->setPixmap(0, QPixmap::fromMimeSource(QString("other.png")));
362
		 el->setPixmap(0, QPixmap::fromMimeSource(QString("other.png")));
355
		 other->insertItem(el);
363
		 other->insertItem(el);
356
	      break;
364
	      break;
357
 
365
 
358
	      default:
366
	      default:
359
		 el = new KListViewItem(other, idx);
367
		 el = new KListViewItem(other, idx);
-
 
368
		 el->setText(1, *strfl);
360
		 el->setPixmap(0, QPixmap::fromMimeSource(QString("other.png")));
369
		 el->setPixmap(0, QPixmap::fromMimeSource(QString("other.png")));
361
		 other->insertItem(el);
370
		 other->insertItem(el);
362
	   }
371
	   }
363
 
372
 
364
	   delete qt;
373
	   delete qt;
Line 475... Line 484...
475
INDEX *akt;
484
INDEX *akt;
476
 
485
 
477
	if (!item)
486
	if (!item)
478
	   return;
487
	   return;
479
 
488
 
480
	akt = index;
489
//	akt = index;
481
 
490
 
482
	while (akt)
491
//	while (akt)
483
	{
492
//	{
484
	   if (akt->activ == item->text(0))
493
//	   if (akt->activ == item->text(0))
485
	   {
494
//	   {
486
	      spw.destroy();
495
	      spw.destroy();
487
 
496
 
488
              if (spw.setFileName(akt->path.ascii()) == -1)
497
//	      if (spw.setFileName(akt->path.ascii()) == -1)
-
 
498
	      if (spw.setFileName(item->text(1).ascii()) == -1)
489
		 return;
499
		 return;
490
 
500
 
491
	      if (gmn)
501
	      if (gmn)
492
		 garmin_free_data (gmn);
502
		 garmin_free_data (gmn);
493
 
503
 
494
	      gmn = spw.readFile();
504
	      gmn = spw.readFile();
495
	      zfactor = 0;
505
	      zfactor = 0;
496
	      showLaps();
506
	      showLaps();
497
	      showTrack();
507
	      showTrack();
498
	      showCurves();
508
	      showCurves();
499
	      return;
509
//	      return;
500
	   }
510
//	   }
501
 
511
 
502
	   akt = akt->next;
512
//	   akt = akt->next;
503
	}
513
//	}
504
}
514
}
505
 
515
 
506
void sportwatcherWidget::helpAbout()
516
void sportwatcherWidget::helpAbout()
507
{
517
{
508
KAboutData about("SportWatcher", "SportWatcher", VERSION);
518
KAboutData about("SportWatcher", "SportWatcher", VERSION);
Line 1139... Line 1149...
1139
	showLaps();
1149
	showLaps();
1140
	showTrack();
1150
	showTrack();
1141
	showCurves();
1151
	showCurves();
1142
}
1152
}
1143
 
1153
 
-
 
1154
/*
-
 
1155
 * Display a small dialog to rename the currently loaded session.
-
 
1156
 */
-
 
1157
void sportwatcherWidget::editRename()
-
 
1158
{
-
 
1159
bool ok;
-
 
1160
QString name, inhalt;
-
 
1161
QPtrList<QListViewItem> item;
-
 
1162
QListViewItem *lvItem;
-
 
1163
QFileInfo datei;
-
 
1164
RUN_NODE *rn;
-
 
1165
LAP *lap;
-
 
1166
garmin_list *list;
-
 
1167
D1009 *n;
-
 
1168
 
-
 
1169
	if (!gmn)
-
 
1170
	{
-
 
1171
	   KMessageBox::error(this, i18n("There is no session selected!"));
-
 
1172
	   return;
-
 
1173
	}
-
 
1174
	
-
 
1175
	rn = ds.getRunNode();
-
 
1176
	item = liActivities->selectedItems (false);
-
 
1177
	lvItem = item.first();
-
 
1178
 
-
 
1179
	if (!isdigit(rn->run->workout.name[0]))
-
 
1180
	   inhalt = lvItem->text(0);
-
 
1181
	else
-
 
1182
	   inhalt = QString::null;
-
 
1183
 
-
 
1184
	name = KInputDialog::getText(i18n("Rename session"), i18n("Session name"),
-
 
1185
		inhalt, &ok, this, "dialogRename", 0,
-
 
1186
		QString("Nxxxxxxxxxxxxxx"));
-
 
1187
 
-
 
1188
	if (!ok)
-
 
1189
	   return;
-
 
1190
 
-
 
1191
	if (name.length() <= 1)
-
 
1192
	{
-
 
1193
	   lap = ds.getLap(rn->run->first_lap_index);
-
 
1194
	   const QDateTime *qt = garmin_dtime (lap->start_time);
-
 
1195
	   QString idx = qt->toString("dd.MM.yyyy hh:mm.ss");
-
 
1196
	   lvItem->setText (0, idx);
-
 
1197
	   datei.setFile (lvItem->text(1));
-
 
1198
	   garmin_save_all (gmn, datei.fileName().ascii(), datei.dirPath(true).ascii(), 1);
-
 
1199
	   delete qt;
-
 
1200
	   return;
-
 
1201
	}
-
 
1202
 
-
 
1203
	strncpy (rn->run->workout.name, name.ascii(), 16);
-
 
1204
 
-
 
1205
	if (gmn->type != data_Dlist)
-
 
1206
	{
-
 
1207
	   KMessageBox::error(this, i18n("editRename: Unexpected structure type %1 found!").arg(gmn->type));
-
 
1208
	   return;
-
 
1209
	}
-
 
1210
 
-
 
1211
	list = (garmin_list *)gmn->data;
-
 
1212
 
-
 
1213
	if (list->head->data->type != data_D1009)	// This should be the run node
-
 
1214
	{
-
 
1215
	   KMessageBox::error(this, i18n("editRename: The run node was not found!"));
-
 
1216
	   return;
-
 
1217
	}
-
 
1218
 
-
 
1219
	n = (D1009 *)list->head->data->data;
-
 
1220
	strcpy (n->workout.name, rn->run->workout.name);
-
 
1221
	lvItem->setText (0, name);
-
 
1222
	datei.setFile (lvItem->text(1));
-
 
1223
	garmin_save_all (gmn, datei.fileName().ascii(), datei.dirPath(true).ascii(), 1);
-
 
1224
}
-
 
1225
 
1144
void sportwatcherWidget::fileNew()
1226
void sportwatcherWidget::fileNew()
1145
{
1227
{
1146
progressWidget *dlg = new progressWidget(this, "progressWidgetBase");
1228
progressWidget *dlg = new progressWidget(this, "progressWidgetBase");
1147
 
1229
 
1148
	dlg->show();
1230
	dlg->show();
Line 1544... Line 1626...
1544
	}
1626
	}
1545
 
1627
 
1546
	ds.destroy();
1628
	ds.destroy();
1547
	min_hr = max_hr = 0;
1629
	min_hr = max_hr = 0;
1548
	min_height = max_height = 0.0;
1630
	min_height = max_height = 0.0;
-
 
1631
	min_speed = max_speed = 0.0;
1549
	liLaps->clear();
1632
	liLaps->clear();
1550
	liLaps->setAllColumnsShowFocus(true);
1633
	liLaps->setAllColumnsShowFocus(true);
1551
	ds.garmin_print_data(gmn);
1634
	ds.garmin_print_data(gmn);
1552
	rn = ds.getRunNode();
1635
	rn = ds.getRunNode();
1553
	rakt = rn;
1636
	rakt = rn;
Line 1869... Line 1952...
1869
			  old_dsc = alt_dsc;
1952
			  old_dsc = alt_dsc;
1870
		    }
1953
		    }
1871
		    else
1954
		    else
1872
		       alt_dsc = alt_asc = 0;
1955
		       alt_dsc = alt_asc = 0;
1873
 
1956
 
-
 
1957
		    POINT *oldPoint = 0;
-
 
1958
		    double sc, dist, speed;
-
 
1959
 
1874
		    while (point)
1960
		    while (point)
1875
		    {
1961
		    {
1876
		       if (point->time > (lap->start_time + (lap->total_time / 100)))
1962
		       if (point->time > (lap->start_time + (lap->total_time / 100)))
1877
			 break;
1963
			 break;
1878
 
1964
 
-
 
1965
		       if (!oldPoint)
-
 
1966
			  oldPoint = point;
-
 
1967
 
1879
		       if (point->alt > alt_asc && point->alt < 20000)
1968
		       if (point->alt > alt_asc && point->alt < 20000)
1880
		       {
1969
		       {
1881
			  alt_asc = point->alt;
1970
			  alt_asc = point->alt;
1882
 
1971
 
1883
			  if (alt_dsc == 0)
1972
			  if (alt_dsc == 0)
Line 1899... Line 1988...
1899
			  max_height = point->alt;
1988
			  max_height = point->alt;
1900
 
1989
 
1901
		       if (point->alt < 20000 && (min_height == 0.0 || min_height > point->alt))
1990
		       if (point->alt < 20000 && (min_height == 0.0 || min_height > point->alt))
1902
			  min_height = point->alt;
1991
			  min_height = point->alt;
1903
 
1992
 
-
 
1993
		       // Calculate speed of current track
-
 
1994
		       sc = point->time - oldPoint->time;
-
 
1995
		       dist = point->distance - oldPoint->distance;
-
 
1996
 
-
 
1997
		       if (sc > 0.0)
-
 
1998
			  speed = (dist / sc) * 3.6;
-
 
1999
		       else
-
 
2000
			  speed = 0.0;
-
 
2001
 
-
 
2002
		       if (Units == 1)
-
 
2003
			  speed /= 1.609344;
-
 
2004
 
-
 
2005
		       if (speed > 0.0 && speed < 400.0 && max_speed < speed)
-
 
2006
			  max_speed = speed;
-
 
2007
 
-
 
2008
		       if (speed > 0.0 && (min_speed == 0.0 || min_speed > speed))
-
 
2009
			  min_speed = speed;
-
 
2010
 
1904
		       if (point->heart_rate > 0)
2011
		       if (point->heart_rate > 0)
1905
		       {
2012
		       {
1906
			  avg_hr += point->heart_rate;
2013
			  avg_hr += point->heart_rate;
1907
			  men++;
2014
			  men++;
1908
		       }
2015
		       }
1909
 
2016
 
-
 
2017
		       oldPoint = point;
1910
		       point = ds.getPoint(point->time + 1);
2018
		       point = ds.getPoint(point->time + 1);
1911
		    }
2019
		    }
1912
 
2020
 
1913
		    if (old_asc < alt_asc)
2021
		    if (old_asc < alt_asc)
1914
		       sum_asc += (alt_asc - old_asc);
2022
		       sum_asc += (alt_asc - old_asc);
Line 2603... Line 2711...
2603
 
2711
 
2604
void sportwatcherWidget::showCurves(LAP *lap)
2712
void sportwatcherWidget::showCurves(LAP *lap)
2605
{
2713
{
2606
QPainter paint;
2714
QPainter paint;
2607
int width, height;
2715
int width, height;
2608
int i, secs;
2716
int i, secs, cuType;
2609
int lineHeight, margin_left, margin_right, margin_bottom;
2717
int lineHeight, margin_left, margin_right, margin_bottom;
2610
int x1, y1, x2, y2;		// Coordinates
2718
int x1, y1, x2, y2;		// Coordinates
2611
bool meter;
2719
bool meter;
2612
double maxHeight, minHeight;
2720
double maxHeight, minHeight, maxSpeed, minSpeed;
2613
int maxHr, minHr, rh;
2721
int maxHr, minHr, rh;
2614
POINT *point;
2722
POINT *point;
2615
RUN_NODE *rn;
2723
RUN_NODE *rn;
2616
LAP *lp;
2724
LAP *lp;
2617
double w_tick, h_tick;		// Number of pixels one "tick" has;
2725
double w_tick, h_tick;		// Number of pixels one "tick" has;
Line 2621... Line 2729...
2621
	// values detected in the function showLap(). In case
2729
	// values detected in the function showLap(). In case
2622
	// all values are 0, we exit here.
2730
	// all values are 0, we exit here.
2623
	if (min_hr == 0 && max_hr == 0 && min_height == 0.0 && max_height == 0.0)
2731
	if (min_hr == 0 && max_hr == 0 && min_height == 0.0 && max_height == 0.0)
2624
	   return;
2732
	   return;
2625
 
2733
 
-
 
2734
	// Look up, what curves we should draw
-
 
2735
	cuType = kcbCurveTypes->currentItem();
-
 
2736
	// Get the dimensions of the available draw area
2626
	width = imgProfile->width() - 2;
2737
	width = imgProfile->width() - 2;
2627
	height = imgProfile->height();
2738
	height = imgProfile->height();
2628
	pmProfile.resize(width, height);
2739
	pmProfile.resize(width, height);
2629
	paint.begin(&pmProfile);
2740
	paint.begin(&pmProfile);
2630
 
2741
 
Line 2639... Line 2750...
2639
 
2750
 
2640
	   if (minHeight < 0.0)		// make sure, we are not too deep
2751
	   if (minHeight < 0.0)		// make sure, we are not too deep
2641
	      minHeight = 0.0;
2752
	      minHeight = 0.0;
2642
	}
2753
	}
2643
 
2754
 
-
 
2755
	if (max_speed > 0.0)
-
 
2756
	{
-
 
2757
	double add = (max_speed - min_speed) / 100.0 * 5.0;	// Percent
-
 
2758
 
-
 
2759
	   maxSpeed = max_speed + add;
-
 
2760
	   minSpeed = min_speed - add;
-
 
2761
 
-
 
2762
	   if (minSpeed < 0.0)		// make sure, we are not too deep
-
 
2763
	      minSpeed = 0.0;
-
 
2764
	}
-
 
2765
 
2644
	if (max_hr > 0)
2766
	if (max_hr > 0)
2645
	{
2767
	{
2646
	   maxHr = max_hr + 10;
2768
	   maxHr = max_hr + 10;
2647
	   minHr = min_hr - 10;
2769
	   minHr = min_hr - 10;
2648
 
2770
 
Line 2673... Line 2795...
2673
	lineHeight = 10;
2795
	lineHeight = 10;
2674
	rh = height - margin_bottom - 1;
2796
	rh = height - margin_bottom - 1;
2675
 
2797
 
2676
	w_tick = (double)(width - (margin_left + margin_right)) / max_time;	// 1 tick = 1 second
2798
	w_tick = (double)(width - (margin_left + margin_right)) / max_time;	// 1 tick = 1 second
2677
 
2799
 
2678
	if ((maxHeight - minHeight) > (double)(maxHr - minHr))
2800
	if (cuType == 1)	// Speed?
2679
	{
2801
	{
-
 
2802
	   if ((maxSpeed - minSpeed) > (double)(maxHr - minHr))
-
 
2803
	   {
2680
	   h_tick = (double)rh / (maxHeight - minHeight);		// 1 tick = 1 meter
2804
	      h_tick = (double)rh / (maxSpeed - minSpeed);		// 1 tick = 1 meter
2681
	   meter = true;
2805
	      meter = true;
-
 
2806
	   }
-
 
2807
	   else
-
 
2808
	   {
-
 
2809
	      h_tick = (double)rh / ((double)maxHr - (double)minHr);	// 1 tick = 1 bpm
-
 
2810
	      meter = false;
-
 
2811
	   }
2682
	}
2812
	}
2683
	else
2813
	else	// Altitude
2684
	{
2814
	{
-
 
2815
	   if ((maxHeight - minHeight) > (double)(maxHr - minHr))
-
 
2816
	   {
-
 
2817
	      h_tick = (double)rh / (maxHeight - minHeight);		// 1 tick = 1 meter
-
 
2818
	      meter = true;
-
 
2819
	   }
-
 
2820
	   else
-
 
2821
	   {
2685
	   h_tick = (double)rh / ((double)maxHr - (double)minHr);	// 1 tick = 1 bpm
2822
	      h_tick = (double)rh / ((double)maxHr - (double)minHr);	// 1 tick = 1 bpm
2686
	   meter = false;
2823
	      meter = false;
-
 
2824
	   }
2687
	}
2825
	}
2688
	
2826
 
2689
	// Fill background with background colors
2827
	// Fill background with background colors
2690
	paint.fillRect(0, 0, width + 4, height + 4, background);
2828
	paint.fillRect(0, 0, width + 4, height + 4, background);
2691
	// Draw a grid with markers at every 10 minutes
2829
	// Draw a grid with markers at every 10 minutes
2692
	paint.setPen(QPen(frame, 1, QPen::SolidLine));
2830
	paint.setPen(QPen(frame, 1, QPen::SolidLine));
2693
	// Bottom border line
2831
	// Bottom border line
Line 2733... Line 2871...
2733
	paint.setFont(fntNormal);
2871
	paint.setFont(fntNormal);
2734
	paint.drawText(margin_left - 20, height - lineHeight, 40, lineHeight, Qt::AlignCenter, QString("00:00"));
2872
	paint.drawText(margin_left - 20, height - lineHeight, 40, lineHeight, Qt::AlignCenter, QString("00:00"));
2735
	paint.save();
2873
	paint.save();
2736
	paint.rotate(270);
2874
	paint.rotate(270);
2737
	paint.setPen(QPen(barcol, 1, QPen::SolidLine));
2875
	paint.setPen(QPen(barcol, 1, QPen::SolidLine));
-
 
2876
 
-
 
2877
	if (cuType == 0)
2738
	paint.drawText((height + 4) * -1, 3, height - 2, lineHeight, Qt::AlignCenter, i18n((Units == 1) ? "Elevation (ft)" : "Elevation (m)"));
2878
	   paint.drawText((height + 4) * -1, 3, height - 2, lineHeight, Qt::AlignCenter, i18n((Units == 1) ? "Elevation (ft)" : "Elevation (m)"));
-
 
2879
	else if (cuType == 1)
-
 
2880
	   paint.drawText((height + 4) * -1, 3, height - 2, lineHeight, Qt::AlignCenter, i18n((Units == 1) ? "Speed (mph)" : "Speed (km/h)"));
-
 
2881
	else
-
 
2882
	   paint.drawText((height + 4) * -1, 3, height - 2, lineHeight, Qt::AlignCenter, i18n((Units == 1) ? "Elevation (ft)" : "Elevation (m)"));
-
 
2883
 
2739
	paint.setPen(QPen(blue, 1, QPen::SolidLine));
2884
	paint.setPen(QPen(blue, 1, QPen::SolidLine));
-
 
2885
 
-
 
2886
	if (cuType < 2)
2740
	paint.drawText((height + 4) * -1, width - 1 - lineHeight, height - 2, lineHeight, Qt::AlignCenter, i18n("Heart Rate (bpm)"));
2887
	   paint.drawText((height + 4) * -1, width - 1 - lineHeight, height - 2, lineHeight, Qt::AlignCenter, i18n("Heart Rate (bpm)"));
-
 
2888
	else
-
 
2889
	   paint.drawText((height + 4) * -1, width - 1 - lineHeight, height - 2, lineHeight, Qt::AlignCenter, i18n((Units == 1) ? "Speed (mph)" : "Speed (km/h)"));
-
 
2890
 
2741
	paint.restore();
2891
	paint.restore();
2742
	paint.setPen(QPen(mark, 1, QPen::SolidLine));
2892
	paint.setPen(QPen(mark, 1, QPen::SolidLine));
2743
	// Draw the time scale
2893
	// Draw the time scale
2744
	for (i = 0; (unsigned int)i < max_time; i++)
2894
	for (i = 0; (unsigned int)i < max_time; i++)
2745
	{
2895
	{
Line 2765... Line 2915...
2765
	QString qs;
2915
	QString qs;
2766
	tm = tm.addSecs(max_time);
2916
	tm = tm.addSecs(max_time);
2767
	paint.setPen(QPen(frame, 1, QPen::SolidLine));
2917
	paint.setPen(QPen(frame, 1, QPen::SolidLine));
2768
	paint.drawText(width - margin_right - 25, height - lineHeight, 50, lineHeight, Qt::AlignCenter, tm.toString((max_time >= 3600) ? "hh:mm:ss" : "mm:ss"));
2918
	paint.drawText(width - margin_right - 25, height - lineHeight, 50, lineHeight, Qt::AlignCenter, tm.toString((max_time >= 3600) ? "hh:mm:ss" : "mm:ss"));
2769
 
2919
 
2770
	if (max_height > 0.0)
2920
	if (max_height > 0.0 || max_speed > 0.0)
2771
	{
2921
	{
2772
	   paint.setPen(QPen(barcol, 1, QPen::SolidLine));
2922
	   paint.setPen(QPen(barcol, 1, QPen::SolidLine));
-
 
2923
 
-
 
2924
	   if (cuType == 1)
-
 
2925
	      paint.drawText(12, height - margin_bottom - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", minSpeed));
-
 
2926
	   else
2773
	   paint.drawText(12, height - margin_bottom - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", (Units == 1) ? minHeight / 0.304 : minHeight));
2927
	      paint.drawText(12, height - margin_bottom - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", (Units == 1) ? minHeight / 0.304 : minHeight));
2774
	}
2928
	}
2775
	
2929
	
2776
	if (max_hr > 0)
2930
	if (max_hr > 0)
2777
	{
2931
	{
2778
	   paint.setPen(QPen(blue, 1, QPen::SolidLine));
2932
	   paint.setPen(QPen(blue, 1, QPen::SolidLine));
Line 2780... Line 2934...
2780
	}
2934
	}
2781
 
2935
 
2782
	paint.setPen(QPen(mark, 1, QPen::SolidLine));
2936
	paint.setPen(QPen(mark, 1, QPen::SolidLine));
2783
 
2937
 
2784
	// Grid horizontal
2938
	// Grid horizontal
-
 
2939
	int factor = 0;
-
 
2940
	int target = 0;
-
 
2941
 
-
 
2942
	if (cuType == 1)
-
 
2943
	{
-
 
2944
	   factor = (meter) ? (maxSpeed - minSpeed) / (rh / 12) : (maxHr - minHr) / (rh / 12);
-
 
2945
	   target = (meter) ? (int)(maxSpeed - minSpeed) : (maxHr - minHr);
-
 
2946
	}
-
 
2947
	else
-
 
2948
	{
2785
	int factor = (meter) ? (maxHeight - minHeight) / (rh / 12) : (maxHr - minHr) / (rh / 12);
2949
	   factor = (meter) ? (maxHeight - minHeight) / (rh / 12) : (maxHr - minHr) / (rh / 12);
2786
	int target = (meter) ? (int)(maxHeight - minHeight) : (maxHr - minHr);
2950
	   target = (meter) ? (int)(maxHeight - minHeight) : (maxHr - minHr);
-
 
2951
	}
-
 
2952
 
2787
	int oldy = height;
2953
	int oldy = height;
2788
 
2954
 
2789
	for (i = 0; i < target; i++)
2955
	for (i = 0; i < target; i++)
2790
	{
2956
	{
2791
	   if (i > 0 && !(i % factor))
2957
	   if (i > 0 && !(i % factor))
Line 2802... Line 2968...
2802
	      if (y1 < (oldy - lineHeight))
2968
	      if (y1 < (oldy - lineHeight))
2803
	      {
2969
	      {
2804
		 if (meter)
2970
		 if (meter)
2805
		 {
2971
		 {
2806
		    paint.setPen(QPen(barcol, 1, QPen::SolidLine));
2972
		    paint.setPen(QPen(barcol, 1, QPen::SolidLine));
-
 
2973
 
-
 
2974
		    if (cuType == 1)
-
 
2975
		       paint.drawText(12, y1 - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", minSpeed + i));
-
 
2976
		    else
2807
		    paint.drawText(12, y1 - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", (Units == 1) ? (minHeight + i) / 0.304 : minHeight + i));
2977
		       paint.drawText(12, y1 - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", (Units == 1) ? (minHeight + i) / 0.304 : minHeight + i));
2808
 
2978
 
2809
		    if (maxHr > 0)
2979
		    if (maxHr > 0)
2810
		    {
2980
		    {
2811
		       double hrscale = (double)(maxHr - minHr) / (double)target;
2981
		       double hrscale = (double)(maxHr - minHr) / (double)target;
2812
		       paint.setPen(QPen(blue, 1, QPen::SolidLine));
2982
		       paint.setPen(QPen(blue, 1, QPen::SolidLine));
Line 2816... Line 2986...
2816
		 else
2986
		 else
2817
		 {
2987
		 {
2818
		    paint.setPen(QPen(blue, 1, QPen::SolidLine));
2988
		    paint.setPen(QPen(blue, 1, QPen::SolidLine));
2819
		    paint.drawText(width - margin_right + 2, y1 - lineHeight / 2, margin_right - 14, lineHeight, Qt::AlignLeft, qs.sprintf("%d", minHr + i));
2989
		    paint.drawText(width - margin_right + 2, y1 - lineHeight / 2, margin_right - 14, lineHeight, Qt::AlignLeft, qs.sprintf("%d", minHr + i));
2820
 
2990
 
2821
		    if (max_height > 0)
2991
		    if (cuType == 0 && max_height > 0)
2822
		    {
2992
		    {
2823
		       double hrscale = (maxHeight - minHeight) / (double)target;
2993
		       double hrscale = (maxHeight - minHeight) / (double)target;
2824
		       paint.setPen(QPen(barcol, 1, QPen::SolidLine));
2994
		       paint.setPen(QPen(barcol, 1, QPen::SolidLine));
2825
		       paint.drawText(12, y1 - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", minHeight + hrscale * (double)i));
2995
		       paint.drawText(12, y1 - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", minHeight + hrscale * (double)i));
2826
		    }
2996
		    }
-
 
2997
		    else if (max_speed > 0)
-
 
2998
		    {
-
 
2999
		       double hrscale = (maxSpeed - minSpeed) / (double)target;
-
 
3000
		       paint.setPen(QPen(barcol, 1, QPen::SolidLine));
-
 
3001
		       paint.drawText(12, y1 - lineHeight / 2, margin_left - 14, lineHeight, Qt::AlignRight, qs.sprintf("%.0f", minSpeed + hrscale * (double)i));
-
 
3002
		    }
2827
		}
3003
		}
2828
 
3004
 
2829
		 paint.setPen(QPen(mark, 1, QPen::SolidLine));
3005
		 paint.setPen(QPen(mark, 1, QPen::SolidLine));
2830
		 oldy = y1;
3006
		 oldy = y1;
2831
	      }
3007
	      }
Line 2887... Line 3063...
2887
	hy1 = hy2 = hx1 = hx2 = 0;
3063
	hy1 = hy2 = hx1 = hx2 = 0;
2888
	int hEc = 0;
3064
	int hEc = 0;
2889
	i = 0;
3065
	i = 0;
2890
	AVGHEIGHT *avgHakt, *avgHfirst, *avgHlast, *avgHeight = 0;
3066
	AVGHEIGHT *avgHakt, *avgHfirst, *avgHlast, *avgHeight = 0;
2891
	avgHfirst = avgHlast = 0;
3067
	avgHfirst = avgHlast = 0;
2892
 
-
 
2893
	// To even the surface lines, we store every altitude in the
3068
	// To even the surface lines, we store every altitude in the
2894
	// memory, by building a chain. Then, if the user has set in the
3069
	// memory, by building a chain. Then, if the user has set in the
2895
	// settings (Contour == true), we will even the line by calculating
3070
	// settings (Contour == true), we will even the line by calculating
2896
	// the average of 10 messure points and setting every value to the
3071
	// the average of 10 messure points and setting every value to the
2897
	// average, who is up or down more than 2 meters from the average.
3072
	// average, who is up or down more than 2 meters from the average.
Line 2933... Line 3108...
2933
	   i++;
3108
	   i++;
2934
	}
3109
	}
2935
 
3110
 
2936
	avgHlast = avgHeight;
3111
	avgHlast = avgHeight;
2937
	// If wanted, even the lines
3112
	// If wanted, even the lines
2938
	if (Contour && hEc > 0)
3113
	if (Contour && hEc > 0 && cuType != 0)
2939
	{
3114
	{
2940
	double alt[100], avg, avg1, avg2, avg3, avg4;
3115
	double alt[100], avg, avg1, avg2, avg3, avg4;
2941
	int a, pos;
3116
	int a, pos;
2942
 
3117
 
2943
	   for (i = 0; i < (hEc + 100); i += 100)
3118
	   for (i = 0; i < (hEc + 100); i += 100)
Line 2974... Line 3149...
2974
		 }
3149
		 }
2975
	      }
3150
	      }
2976
	   }
3151
	   }
2977
	}
3152
	}
2978
 
3153
 
2979
	// plot the altitude
3154
	// plot the altitude or speed. Depends on <cuType>)
2980
	i = 0;
3155
	i = 0;
2981
	int j = 0;
3156
	int j = 0;
-
 
3157
	POINT *oldPoint = 0;
-
 
3158
	double speed = 0.0;
2982
 
3159
	
2983
	while ((point = ds.getPoint(i)) != 0)
3160
	while ((point = ds.getPoint(i)) != 0)
2984
	{
3161
	{
-
 
3162
	   if (!oldPoint)
-
 
3163
	      oldPoint = point;
-
 
3164
 
2985
	   // calculate the y position based on the time
3165
	   // calculate the y position based on the time
2986
	   qt = garmin_dtime(point->time);
3166
	   qt = garmin_dtime(point->time);
2987
	   secs = zeit.secsTo(qt->time());
3167
	   secs = zeit.secsTo(qt->time());
2988
	   delete qt;
3168
	   delete qt;
2989
	   x2 = secs * w_tick + margin_left + 1;
3169
	   x2 = secs * w_tick + margin_left + 1;
Line 2993... Line 3173...
2993
	      x1 = x2;
3173
	      x1 = x2;
2994
 
3174
 
2995
	   if (hx1 == 0)
3175
	   if (hx1 == 0)
2996
	      hx1 = hx2;
3176
	      hx1 = hx2;
2997
 
3177
 
2998
	   if (point->alt < 20000.0 && point->alt > -1000.0)
3178
	   if (cuType == 1)
2999
	   {
3179
	   {
3000
	   double alt = getAvgAlt(avgHfirst, j);
3180
	      double dist;
-
 
3181
	      double sc;
3001
 
3182
 
3002
	      j++;
-
 
3003
 
-
 
3004
	      if (meter)
-
 
3005
		 y2 = (double)rh - (alt - minHeight) * h_tick;
3183
	      if (point->distance >= 1 && point->distance < 1.0e24)
3006
	      else
-
 
3007
	      {
3184
	      {
3008
		 double hrscale = rh / (maxHeight - minHeight);
3185
		 dist = point->distance - oldPoint->distance;
3009
		 y2 = (double)rh - (alt - minHeight) * hrscale;
3186
		 sc = point->time - oldPoint->time;
-
 
3187
		 speed = (dist / sc) * 3.6;
-
 
3188
 
-
 
3189
		 if (Units == 1)
-
 
3190
		    speed /= 1.609344;
-
 
3191
 
-
 
3192
		 if (speed < 0.0 || speed > 400.0)
3010
	      }
3193
		    speed = 0.0;
3011
 
3194
 
-
 
3195
		 if (meter)
-
 
3196
		    y2 = (double)rh - (speed - minSpeed) * h_tick;
-
 
3197
		 else
-
 
3198
		 {
-
 
3199
		    double hrscale = rh / (maxSpeed - minSpeed);
-
 
3200
		    y2 = (double)rh - (speed - minSpeed) * hrscale;
-
 
3201
		 }
-
 
3202
 
3012
	      if (y1 == 0)
3203
		 if (y1 == 0)
-
 
3204
		    y1 = y2;
-
 
3205
 
-
 
3206
		 paint.setPen(QPen(barcol, 1, QPen::SolidLine));
-
 
3207
		 paint.drawLine(x1, y1, x2, y2);
3013
		 y1 = y2;
3208
		 y1 = y2;
-
 
3209
		 x1 = x2;
-
 
3210
	      }
-
 
3211
	   }
-
 
3212
	   else
-
 
3213
	   {
-
 
3214
	      if (point->alt < 20000.0 && point->alt > -1000.0)
-
 
3215
	      {
-
 
3216
	      double alt = getAvgAlt(avgHfirst, j);
3014
 
3217
 
-
 
3218
		 j++;
-
 
3219
 
-
 
3220
		 if (meter)
-
 
3221
		    y2 = (double)rh - (alt - minHeight) * h_tick;
-
 
3222
		 else
-
 
3223
		 {
-
 
3224
		    double hrscale = rh / (maxHeight - minHeight);
-
 
3225
		    y2 = (double)rh - (alt - minHeight) * hrscale;
-
 
3226
		 }
-
 
3227
 
-
 
3228
		 if (y1 == 0)
-
 
3229
		    y1 = y2;
-
 
3230
 
3015
	      paint.setPen(QPen(barcol, 1, QPen::SolidLine));
3231
		 paint.setPen(QPen(barcol, 1, QPen::SolidLine));
3016
	      paint.drawLine(x1, y1, x2, y2);
3232
		 paint.drawLine(x1, y1, x2, y2);
3017
	      y1 = y2;
3233
		 y1 = y2;
3018
	      x1 = x2;
3234
		 x1 = x2;
-
 
3235
	      }
3019
	   }
3236
	   }
3020
 
3237
 
3021
	   if (point->heart_rate > 0)
3238
	   if (point->heart_rate > 0)
3022
	   {
3239
	   {
3023
	      if (meter)
3240
	      if (meter)
Line 3036... Line 3253...
3036
	      hy1 = hy2;
3253
	      hy1 = hy2;
3037
	      hx1 = hx2;
3254
	      hx1 = hx2;
3038
	   }
3255
	   }
3039
 
3256
 
3040
	   i++;
3257
	   i++;
-
 
3258
	   oldPoint = point;
3041
	}
3259
	}
3042
 
3260
 
3043
	paint.end();
3261
	paint.end();
3044
	imgProfile->setPixmap(pmProfile);
3262
	imgProfile->setPixmap(pmProfile);
3045
 
3263