diff --git a/src/AllPlotWindow.cpp b/src/AllPlotWindow.cpp index 1956ba769..dbd1715a7 100644 --- a/src/AllPlotWindow.cpp +++ b/src/AllPlotWindow.cpp @@ -36,7 +36,7 @@ #include AllPlotWindow::AllPlotWindow(MainWindow *mainWindow) : - QWidget(mainWindow), mainWindow(mainWindow) + QWidget(mainWindow), mainWindow(mainWindow), current(NULL) { QVBoxLayout *vlayout = new QVBoxLayout; @@ -239,15 +239,22 @@ AllPlotWindow::rideSelected() if (mainWindow->activeTab() != this) return; RideItem *ride = mainWindow->rideItem(); - if (!ride) + if (!ride || ride == current) return; + current = ride; + + int showit = showStack->isChecked(); + if (showit) allPlot->hide(); + else allPlot->show(); + + // set it up anyway since the stack plots + // reuse the arrays clearSelection(); // clear any ride interval selection data setAllPlotWidgets(ride); allPlot->setDataI(ride); allZoomer->setZoomBase(); // update stacked view if that is set - int showit = showStack->isChecked(); setShowStack(0); // zap whats there setShowStack(showit); } diff --git a/src/AllPlotWindow.h b/src/AllPlotWindow.h index db7013143..54d990be2 100644 --- a/src/AllPlotWindow.h +++ b/src/AllPlotWindow.h @@ -99,6 +99,8 @@ class AllPlotWindow : public QWidget QSlider *smoothSlider; QLineEdit *smoothLineEdit; + RideItem *current; + private: void showInfo(QString); void resetStackedDatas(); diff --git a/src/DanielsPoints.cpp b/src/DanielsPoints.cpp index 6dd1e3761..c2d4a272a 100644 --- a/src/DanielsPoints.cpp +++ b/src/DanielsPoints.cpp @@ -112,10 +112,11 @@ class DanielsEquivalentPower : public RideMetric { } void compute(const RideFile *, const Zones *zones, int zoneRange, - const QHash &deps) { - if (!zones || zoneRange < 0) { + const QHash &deps) + { + if (!zones || zoneRange < 0) { setValue(0); - return; + return; } double cp = zones->getCP(zoneRange); @@ -127,7 +128,7 @@ class DanielsEquivalentPower : public RideMetric { assert(timeRiding); double score = danielsPoints->value(true); double secs = timeRiding->value(true); - watts = cp * pow(score / DanielsPoints::K / secs, 0.25); + watts = secs == 0.0 ? 0.0 : cp * pow(score / DanielsPoints::K / secs, 0.25); setValue(watts); } diff --git a/src/GoogleMapControl.cpp b/src/GoogleMapControl.cpp index 733380a4f..a5a95afc7 100644 --- a/src/GoogleMapControl.cpp +++ b/src/GoogleMapControl.cpp @@ -139,7 +139,7 @@ using namespace gm; #define GOOGLE_KEY "ABQIAAAAS9Z2oFR8vUfLGYSzz40VwRQ69UCJw2HkJgivzGoninIyL8-QPBTtnR-6pM84ljHLEk3PDql0e2nJmg" -GoogleMapControl::GoogleMapControl(MainWindow *mw) +GoogleMapControl::GoogleMapControl(MainWindow *mw) : current(NULL) { parent = mw; view = new QWebView(); @@ -156,12 +156,13 @@ GoogleMapControl::GoogleMapControl(MainWindow *mw) void GoogleMapControl::rideSelected() { - if (parent->activeTab() != this) - return; - RideItem * ride = parent->rideItem(); + if (parent->activeTab() != this) return; - if (!ride) + RideItem * ride = parent->rideItem(); + if (ride == current || !ride || !ride->ride()) return; + else + current = ride; int zone =ride->zoneRange(); if(zone < 0) @@ -177,8 +178,6 @@ GoogleMapControl::rideSelected() double prevLon = 0; double prevLat = 0; - if (ride == NULL || ride->ride() == NULL) return; - foreach(RideFilePoint *rfp,ride->ride()->dataPoints()) { RideFilePoint curRfp = *rfp; @@ -204,8 +203,15 @@ GoogleMapControl::rideSelected() void GoogleMapControl::resizeEvent(QResizeEvent * ) { - newRideToLoad = true; - loadRide(); + static bool first = true; + if (parent->activeTab() != this) return; + + if (first == true) { + first = false; + } else { + newRideToLoad = true; + loadRide(); + } } void GoogleMapControl::loadStarted() @@ -284,6 +290,7 @@ void GoogleMapControl::createHtml() << "GoldenCheetah" << endl << "" << endl + << CreateMapToolTipJavaScript() << endl << "" << endl << "" << endl << "" << endl - << "
" << endl << "
" << endl << "
" << endl << "" << endl << "" << endl; - currentPage << oss.str(); + currentPage << oss.str(); } @@ -355,11 +362,12 @@ string GoogleMapControl::CreatePolyLine() intervalPoints.end(), AvgPower()); // find the color - QColor color = GetColor(rideCP,avgPower); + // create the polyline - CreateSubPolyLine(intervalPoints,oss,color); + CreateSubPolyLine(intervalPoints,oss,avgPower); intervalPoints.clear(); intervalPoints.push_back(rfp); + } } @@ -369,12 +377,13 @@ string GoogleMapControl::CreatePolyLine() void GoogleMapControl::CreateSubPolyLine(const std::vector &points, std::ostringstream &oss, - QColor color) + int avgPower) { oss.precision(6); + QColor color = GetColor(rideCP,avgPower); QString colorstr = color.name(); oss.setf(ios::fixed,ios::floatfield); - oss << "map.addOverlay (new GPolyline(["; + oss << "var polyline = new GPolyline(["; BOOST_FOREACH(RideFilePoint rfp, points) { @@ -383,8 +392,21 @@ void GoogleMapControl::CreateSubPolyLine(const std::vector &point oss << "new GLatLng(" << rfp.lat << "," << rfp.lon << ")," << endl; } } + oss << "],\"" << colorstr.toStdString() << "\",4);" << endl; - oss << "],\"" << colorstr.toStdString() << "\",5));"; + oss << "GEvent.addListener(polyline, 'mouseover', function() {" << endl + << "var tooltip_text = '30s Power: " << avgPower << "';" << endl + << "var ss={'weight':8};" << endl + << "this.setStrokeStyle(ss);" << endl + << "this.overlay = new MapTooltip(this,tooltip_text);" << endl + << "map.addOverlay(this.overlay);" << endl + << "});" << endl + << "GEvent.addListener(polyline, 'mouseout', function() {" << endl + << "map.removeOverlay(this.overlay);" << endl + << "var ss={'weight':5};" << endl + << "this.setStrokeStyle(ss);" << endl + << "});" << endl; + oss << "map.addOverlay (polyline);" << endl; } @@ -460,3 +482,67 @@ string GoogleMapControl::CreateIntervalMarkers() } return oss.str(); } + +string GoogleMapControl::CreateMapToolTipJavaScript() +{ + ostringstream oss; + oss << " "<< endl; + return oss.str(); +} diff --git a/src/GoogleMapControl.h b/src/GoogleMapControl.h index dfa2a6841..7cdc858b3 100644 --- a/src/GoogleMapControl.h +++ b/src/GoogleMapControl.h @@ -46,7 +46,8 @@ Q_OBJECT std::string CreatePolyLine(); void CreateSubPolyLine(const std::vector &points, std::ostringstream &oss, - QColor color); + int avgPower); + std::string CreateMapToolTipJavaScript(); std::string CreateIntervalMarkers(); void loadRide(); // the web browser is loading a page, do NOT start another load @@ -64,6 +65,7 @@ Q_OBJECT int rideCP; // current HTML for the ride std::ostringstream currentPage; + RideItem *current; public slots: void rideSelected(); diff --git a/src/ModelWindow.cpp b/src/ModelWindow.cpp index eed006f4a..eecf53341 100644 --- a/src/ModelWindow.cpp +++ b/src/ModelWindow.cpp @@ -46,7 +46,7 @@ ModelWindow::addStandardChannels(QComboBox *box) } ModelWindow::ModelWindow(MainWindow *parent, const QDir &home) : - QWidget(parent), home(home), main(parent), ride(NULL) + QWidget(parent), home(home), main(parent), ride(NULL), current(NULL) { // Layouts QVBoxLayout *mainLayout = new QVBoxLayout; @@ -92,6 +92,7 @@ ModelWindow::ModelWindow(MainWindow *parent, const QDir &home) : styleSelector->addItem(tr("Bar")); styleSelector->addItem(tr("Grid")); styleSelector->addItem(tr("Surface")); + styleSelector->addItem(tr("Dots")); styleSelector->setCurrentIndex(0); ignore = new QCheckBox(tr("Ignore Zero")); @@ -188,6 +189,10 @@ ModelWindow::rideSelected() if (main->activeTab() != this) return; ride = main->rideItem(); + + if (!ride || !ride->ride() || ride == current) + + current = ride; setData(true); } diff --git a/src/ModelWindow.h b/src/ModelWindow.h index b9ea60794..3a9a822c8 100644 --- a/src/ModelWindow.h +++ b/src/ModelWindow.h @@ -115,6 +115,8 @@ class ModelWindow : public QWidget // z pane slider QSlider *zpane; + RideItem *current; + private: void addStandardChannels(QComboBox *); diff --git a/src/PfPvWindow.cpp b/src/PfPvWindow.cpp index 87a77dc8b..a880d0dab 100644 --- a/src/PfPvWindow.cpp +++ b/src/PfPvWindow.cpp @@ -23,7 +23,7 @@ #include PfPvWindow::PfPvWindow(MainWindow *mainWindow) : - QWidget(mainWindow), mainWindow(mainWindow) + QWidget(mainWindow), mainWindow(mainWindow), current(NULL) { QVBoxLayout *vlayout = new QVBoxLayout; QHBoxLayout *qaLayout = new QHBoxLayout; @@ -91,11 +91,16 @@ PfPvWindow::rideSelected() { if (mainWindow->activeTab() != this) return; + + RideItem *ride = mainWindow->rideItem(); - if (!ride || !ride->ride()) + if (ride == current || !ride || !ride->ride()) return; pfPvPlot->setData(ride); + + current = ride; + // update the QLabel widget with the CP value set in PfPvPlot::setData() qaCPValue->setText(QString("%1").arg(pfPvPlot->getCP())); } diff --git a/src/PfPvWindow.h b/src/PfPvWindow.h index fd91c53bd..4d78f70cc 100644 --- a/src/PfPvWindow.h +++ b/src/PfPvWindow.h @@ -60,6 +60,7 @@ class PfPvWindow : public QWidget QLineEdit *qaCPValue; QLineEdit *qaCadValue; QLineEdit *qaClValue; + RideItem *current; }; #endif // _GC_PfPvWindow_h diff --git a/src/src.pro b/src/src.pro index a35ea7240..9b6b107f8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -24,13 +24,21 @@ LIBS += -lm SOURCES += SrmDevice.cpp } -!isEmpty( QWT3D_INSTALL) { - INCLUDEPATH += $${QWT3D_INSTALL}/include - LIBS += $${QWT3D_INSTALL}/lib/libqwtplot3d.a - QT += opengl - HEADERS += ModelPlot.h ModelWindow.h - SOURCES += ModelPlot.cpp ModelWindow.cpp - DEFINES += GC_HAVE_QWTPLOT3D +!isEmpty( QWT3D_INSTALL ) { + INCLUDEPATH += $${QWT3D_INSTALL}/include + LIBS += $${QWT3D_INSTALL}/lib/libqwtplot3d.a + CONFIG += qwt3d +} +isEmpty( QWT3D_INSTALL ):linux-g++:exists( /usr/include/qwtplot3d-qt4 ):exists( /usr/lib/libqwtplot3d-qt4.so ) { + INCLUDEPATH += /usr/include/qwtplot3d-qt4 + LIBS += /usr/lib/libqwtplot3d-qt4.so + CONFIG += qwt3d +} +qwt3d { + QT += opengl + HEADERS += ModelPlot.h ModelWindow.h + SOURCES += ModelPlot.cpp ModelWindow.cpp + DEFINES += GC_HAVE_QWTPLOT3D } macx { diff --git a/src/win32/GoldenCheetahInstall.nsi b/src/win32/GoldenCheetahInstall.nsi index 6750d7efc..3546fd137 100644 --- a/src/win32/GoldenCheetahInstall.nsi +++ b/src/win32/GoldenCheetahInstall.nsi @@ -62,11 +62,20 @@ Section "Golden Cheetah (required)" File "..\release\QtGui4.dll" File "..\release\QtSql4.dll" File "..\release\QtXml4.dll" + File "..\release\QtWebKit4.dll" + File "..\release\QtXmlPatterns4.dll" + File "..\release\phonon4.dll" File "..\release\QtNetwork4.dll" File "..\release\QtOpenGL4.dll" File "..\release\libgcc_s_dw2-1.dll" File "..\release\qwtplot3d.dll" + SetOutPath $INSTDIR\sqldrivers + File "..\release\qsqlite4.dll" + + SetOutPath $INSTDIR\imageformats + File "..\release\qjpeg4.dll" + ; Write the installation path into the registry WriteRegStr HKLM SOFTWARE\GoldenCheetah "Install_Dir" "$INSTDIR" @@ -109,11 +118,16 @@ Section "Uninstall" Delete $INSTDIR\QtGui4.dll Delete $INSTDIR\QtSql4.dll Delete $INSTDIR\QtXml4.dll + Delete $INSTDIR\QtWebKit4.dll + Delete $INSTDIR\QtXmlPatterns4.dll + Delete $INSTDIR\phonon4.dll Delete $INSTDIR\QtNetwork4.dll Delete $INSTDIR\QtOpenGL4.dll Delete $INSTDIR\libgcc_s_dw2-1.dll Delete $INSTDIR\qwtplot3d.dll Delete $INSTDIR\uninstall.exe + Delete $INSTDIR\sqldrivers\qsqlite4.dll + Delete $INSTDIR\imageformats\qjpeg4.dll ; Remove shortcuts, if any Delete "$SMPROGRAMS\GoldenCheetah\*.*"