mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Merge branch 'master' of git://github.com/srhea/GoldenCheetah
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
#include <qwt_arrow_button.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,8 @@ class AllPlotWindow : public QWidget
|
||||
QSlider *smoothSlider;
|
||||
QLineEdit *smoothLineEdit;
|
||||
|
||||
RideItem *current;
|
||||
|
||||
private:
|
||||
void showInfo(QString);
|
||||
void resetStackedDatas();
|
||||
|
||||
@@ -112,10 +112,11 @@ class DanielsEquivalentPower : public RideMetric {
|
||||
}
|
||||
|
||||
void compute(const RideFile *, const Zones *zones, int zoneRange,
|
||||
const QHash<QString,RideMetric*> &deps) {
|
||||
if (!zones || zoneRange < 0) {
|
||||
const QHash<QString,RideMetric*> &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);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
<< "<title>GoldenCheetah</title>" << endl
|
||||
<< "<script src=\"http://maps.google.com/maps?file=api&v=2&key=" << GOOGLE_KEY <<"\"" << endl
|
||||
<< "type=\"text/javascript\"></script>" << endl
|
||||
<< CreateMapToolTipJavaScript() << endl
|
||||
<< "<script type=\"text/javascript\">"<< endl
|
||||
<< "var map;" << endl
|
||||
<< "function initialize() {" << endl
|
||||
@@ -308,14 +315,14 @@ void GoogleMapControl::createHtml()
|
||||
<< "</script>" << endl
|
||||
<< "</head>" << endl
|
||||
<< "<body onload=\"initialize()\" onunload=\"GUnload()\">" << endl
|
||||
<< "<div id=\"map_canvas\" style=\"width: " << width <<"px; height: "
|
||||
<< "<div id=\"map_canvas\" style=\"width: " << width <<"px; height: "
|
||||
<< height <<"px\"></div>" << endl
|
||||
<< "<form action=\"#\" onsubmit=\"animate(); return false\">" << endl
|
||||
<< "</form>" << endl
|
||||
<< "</body>" << endl
|
||||
<< "</html>" << 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<RideFilePoint> &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<RideFilePoint> &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 << "<script type=\"text/javascript\">" << endl
|
||||
<< "var MapTooltip = function(obj, html, options) {"<< endl
|
||||
<< "this.obj = obj;"<< endl
|
||||
<< "this.html = html;"<< endl
|
||||
<< "this.options = options || {};"<< endl
|
||||
<< "}"<< endl
|
||||
<< "MapTooltip.prototype = new GOverlay();"<< endl
|
||||
<< "MapTooltip.prototype.initialize = function(map) {"<< endl
|
||||
<< "var div = document.getElementById('MapTooltipContainer');"<< endl
|
||||
<< "var that = this;"<< endl
|
||||
<< "if (!div) {"<< endl
|
||||
<< "var div = document.createElement('div');"<< endl
|
||||
<< "div.setAttribute('id', 'MapTooltipContainer');"<< endl
|
||||
<< "}"<< endl
|
||||
<< "if (this.options.maxWidth || this.options.minWidth) {"<< endl
|
||||
<< "div.style.maxWidth = this.options.maxWidth || '150px';"<< endl
|
||||
<< "div.style.minWidth = this.options.minWidth || '150px';"<< endl
|
||||
<< "} else {"<< endl
|
||||
<< "div.style.width = this.options.width || '150px';"<< endl
|
||||
<< "}"<< endl
|
||||
<< "div.style.padding = this.options.padding || '5px';"<< endl
|
||||
<< "div.style.backgroundColor = this.options.backgroundColor || '#ffffff';"<< endl
|
||||
<< "div.style.border = this.options.border || '1px solid #000000';"<< endl
|
||||
<< "div.style.fontSize = this.options.fontSize || '80%';"<< endl
|
||||
<< "div.style.color = this.options.color || '#000';"<< endl
|
||||
<< "div.innerHTML = this.html;"<< endl
|
||||
<< "div.style.position = 'absolute';"<< endl
|
||||
<< "div.style.zIndex = '1000';"<< endl
|
||||
<< "var offsetX = this.options.offsetX || 10;"<< endl
|
||||
<< "var offsetY = this.options.offsetY || 0;"<< endl
|
||||
<< "var bounds = map.getBounds();"<< endl
|
||||
<< "rightEdge = map.fromLatLngToDivPixel(bounds.getNorthEast()).x;"<< endl
|
||||
<< "bottomEdge = map.fromLatLngToDivPixel(bounds.getSouthWest()).y;"<< endl
|
||||
<< "var mapev = GEvent.addListener(map, 'mousemove', function(latlng) {"<< endl
|
||||
<< "GEvent.removeListener(mapev);"<< endl
|
||||
<< "var pixelPosX = (map.fromLatLngToDivPixel(latlng)).x + offsetX;"<< endl
|
||||
<< "var pixelPosY = (map.fromLatLngToDivPixel(latlng)).y - offsetY;"<< endl
|
||||
<< "div.style.left = pixelPosX + 'px';"<< endl
|
||||
<< "div.style.top = pixelPosY + 'px';"<< endl
|
||||
<< "map.getPane(G_MAP_FLOAT_PANE).appendChild(div);"<< endl
|
||||
<< "if ( (pixelPosX + div.offsetWidth) > rightEdge ) {"<< endl
|
||||
<< "div.style.left = (rightEdge - div.offsetWidth - 10) + 'px';"<< endl
|
||||
<< "}"<< endl
|
||||
<< "if ( (pixelPosY + div.offsetHeight) > bottomEdge ) {"<< endl
|
||||
<< "div.style.top = (bottomEdge - div.offsetHeight - 10) + 'px';"<< endl
|
||||
<< "}"<< endl
|
||||
<< "});"<< endl
|
||||
<< "this._map = map;"<< endl
|
||||
<< "this._div = div;"<< endl
|
||||
<< "}"<< endl
|
||||
<< "MapTooltip.prototype.remove = function() {"<< endl
|
||||
<< "if(this._div != null) {"<< endl
|
||||
<< "this._div.parentNode.removeChild(this._div);"<< endl
|
||||
<< "}"<< endl
|
||||
<< "}"<< endl
|
||||
<< "MapTooltip.prototype.redraw = function(force) {"<< endl
|
||||
<< "}"<< endl
|
||||
<< "</script> "<< endl;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ Q_OBJECT
|
||||
std::string CreatePolyLine();
|
||||
void CreateSubPolyLine(const std::vector<RideFilePoint> &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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,8 @@ class ModelWindow : public QWidget
|
||||
// z pane slider
|
||||
QSlider *zpane;
|
||||
|
||||
RideItem *current;
|
||||
|
||||
private:
|
||||
|
||||
void addStandardChannels(QComboBox *);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <QtGui>
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ class PfPvWindow : public QWidget
|
||||
QLineEdit *qaCPValue;
|
||||
QLineEdit *qaCadValue;
|
||||
QLineEdit *qaClValue;
|
||||
RideItem *current;
|
||||
};
|
||||
|
||||
#endif // _GC_PfPvWindow_h
|
||||
|
||||
22
src/src.pro
22
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 {
|
||||
|
||||
@@ -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\*.*"
|
||||
|
||||
Reference in New Issue
Block a user