diff --git a/.gitignore b/.gitignore index f31147ff5..ddf7614ab 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,10 @@ Makefile # osx noise .DS_Store profile + +moc/ +obj/ +lib/ +bin/ +plugins/ +resources/ diff --git a/src/.gitignore b/src/.gitignore index 100fa8c45..c39920c38 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -39,3 +39,6 @@ GoldenCheetah.app #ignore ctags for vim tags + +#ignore patches +*.patch diff --git a/src/AllPlot.cpp b/src/AllPlot.cpp index 65d3dcfe2..743cf4b2f 100644 --- a/src/AllPlot.cpp +++ b/src/AllPlot.cpp @@ -262,6 +262,10 @@ AllPlot::AllPlot(AllPlotWindow *parent, Context *context): setCanvasBackground(GColor(CRIDEPLOTBACKGROUND)); canvas()->setFrameStyle(QFrame::NoFrame); + // set the axes that we use.. + setAxesCount(QwtAxis::yLeft, 2); + setAxesCount(QwtAxis::yRight, 3); + setXTitle(); wattsCurve = new QwtPlotCurve(tr("Power")); @@ -277,23 +281,23 @@ AllPlot::AllPlot(AllPlotWindow *parent, Context *context): apCurve->setYAxis(yLeft); hrCurve = new QwtPlotCurve(tr("Heart Rate")); - hrCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + hrCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); speedCurve = new QwtPlotCurve(tr("Speed")); speedCurve->setYAxis(yRight); cadCurve = new QwtPlotCurve(tr("Cadence")); - cadCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + cadCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); altCurve = new QwtPlotCurve(tr("Altitude")); // altCurve->setRenderHint(QwtPlotItem::RenderAntialiased); - altCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 2)); + altCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 1)); tempCurve = new QwtPlotCurve(tr("Temperature")); if (context->athlete->useMetricUnits) tempCurve->setYAxis(yRight); // with speed else - tempCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); // with cadence + tempCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); // with cadence windCurve = new QwtPlotIntervalCurve(tr("Wind")); windCurve->setYAxis(yRight); @@ -302,17 +306,17 @@ AllPlot::AllPlot(AllPlotWindow *parent, Context *context): torqueCurve->setYAxis(yRight); balanceLCurve = new QwtPlotCurve(tr("Left Balance")); - balanceLCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + balanceLCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); balanceRCurve = new QwtPlotCurve(tr("Right Balance")); - balanceRCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + balanceRCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); wCurve = new QwtPlotCurve(tr("W' Balance (j)")); - wCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 3)); + wCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 2)); mCurve = new QwtPlotCurve(tr("Matches")); mCurve->setStyle(QwtPlotCurve::Dots); - mCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 3)); + mCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 2)); curveTitle.attach(this); curveTitle.setLabelAlignment(Qt::AlignRight); @@ -333,9 +337,9 @@ AllPlot::AllPlot(AllPlotWindow *parent, Context *context): plotLayout()->setAlignCanvasToScales(true); setAxisMaxMinor(xBottom, 0); setAxisMaxMinor(yLeft, 0); - setAxisMaxMinor(QwtAxisId(QwtAxis::yLeft, 2), 0); + setAxisMaxMinor(QwtAxisId(QwtAxis::yLeft, 1), 0); setAxisMaxMinor(yRight, 0); - setAxisMaxMinor(QwtAxisId(QwtAxis::yRight, 2), 0); + setAxisMaxMinor(QwtAxisId(QwtAxis::yRight, 1), 0); axisWidget(QwtPlot::yLeft)->installEventFilter(this); @@ -524,10 +528,10 @@ AllPlot::configChanged() sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); - setAxisScaleDraw(QwtAxisId(QwtAxis::yLeft, 2), sd); + setAxisScaleDraw(QwtAxisId(QwtAxis::yLeft, 1), sd); pal.setColor(QPalette::WindowText, GColor(CHEARTRATE)); pal.setColor(QPalette::Text, GColor(CHEARTRATE)); - axisWidget(QwtAxisId(QwtAxis::yLeft, 2))->setPalette(pal); + axisWidget(QwtAxisId(QwtAxis::yLeft, 1))->setPalette(pal); sd = new QwtScaleDraw; sd->setTickLength(QwtScaleDiv::MajorTick, 3); @@ -542,20 +546,20 @@ AllPlot::configChanged() sd->setTickLength(QwtScaleDiv::MajorTick, 3); sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); - setAxisScaleDraw(QwtAxisId(QwtAxis::yRight, 2), sd); + setAxisScaleDraw(QwtAxisId(QwtAxis::yRight, 1), sd); pal.setColor(QPalette::WindowText, GColor(CALTITUDE)); pal.setColor(QPalette::Text, GColor(CALTITUDE)); - axisWidget(QwtAxisId(QwtAxis::yRight, 2))->setPalette(pal); + axisWidget(QwtAxisId(QwtAxis::yRight, 1))->setPalette(pal); sd = new QwtScaleDraw; sd->enableComponent(QwtScaleDraw::Ticks, false); sd->enableComponent(QwtScaleDraw::Backbone, false); sd->setLabelRotation(90);// in the 000s sd->setTickLength(QwtScaleDiv::MajorTick, 3); - setAxisScaleDraw(QwtAxisId(QwtAxis::yRight, 3), sd); + setAxisScaleDraw(QwtAxisId(QwtAxis::yRight, 2), sd); pal.setColor(QPalette::WindowText, GColor(CWBAL)); pal.setColor(QPalette::Text, GColor(CWBAL)); - axisWidget(QwtAxisId(QwtAxis::yRight, 3))->setPalette(pal); + axisWidget(QwtAxisId(QwtAxis::yRight, 2))->setPalette(pal); } struct DataPoint { @@ -914,7 +918,7 @@ AllPlot::recalc() if (!hrArray.empty()) { hrCurve->setSamples(xaxis.data() + startingIndex, smoothHr.data() + startingIndex, totalPoints); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); } if (!speedArray.empty()) { @@ -924,12 +928,12 @@ AllPlot::recalc() if (!cadArray.empty()) { cadCurve->setSamples(xaxis.data() + startingIndex, smoothCad.data() + startingIndex, totalPoints); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); } if (!altArray.empty()) { altCurve->setSamples(xaxis.data() + startingIndex, smoothAltitude.data() + startingIndex, totalPoints); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 1)); } if (!tempArray.empty()) { @@ -937,7 +941,7 @@ AllPlot::recalc() if (context->athlete->useMetricUnits) intervalHighlighterCurve->setYAxis(yRight); else - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); } @@ -953,9 +957,9 @@ AllPlot::recalc() if (!balanceArray.empty()) { balanceLCurve->setSamples(xaxis.data() + startingIndex, smoothBalanceL.data() + startingIndex, totalPoints); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); balanceRCurve->setSamples(xaxis.data() + startingIndex, smoothBalanceR.data() + startingIndex, totalPoints); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); } setYMax(); @@ -964,7 +968,7 @@ AllPlot::recalc() refreshCalibrationMarkers(); refreshZoneLabels(); - //replot(); + replot(); } void @@ -1118,9 +1122,9 @@ AllPlot::setYMax() // set axis scales if (wCurve->isVisible()) { - setAxisTitle(QwtAxisId(QwtAxis::yRight, 3).id, tr("W' Balance (j)")); - setAxisScale(QwtAxisId(QwtAxis::yRight, 3),parent->wpData->minY-1000,parent->wpData->maxY+1000); - setAxisLabelAlignment(QwtAxisId(QwtAxis::yRight, 3),Qt::AlignVCenter); + setAxisTitle(QwtAxisId(QwtAxis::yRight, 2).id, tr("W' Balance (j)")); + setAxisScale(QwtAxisId(QwtAxis::yRight, 2),parent->wpData->minY-1000,parent->wpData->maxY+1000); + setAxisLabelAlignment(QwtAxisId(QwtAxis::yRight, 2),Qt::AlignVCenter); } if (wattsCurve->isVisible()) { @@ -1203,8 +1207,8 @@ AllPlot::setYMax() for (int i=0;iisVisible() || (context->athlete->useMetricUnits && tempCurve->isVisible()) || torqueCurve->isVisible()) { @@ -1247,7 +1251,7 @@ AllPlot::setYMax() //setAxisLabelAlignment(yRight,Qt::AlignVCenter); } if (altCurve->isVisible()) { - setAxisTitle(QwtAxisId(QwtAxis::yRight, 2).id, context->athlete->useMetricUnits ? tr("Meters") : tr("Feet")); + setAxisTitle(QwtAxisId(QwtAxis::yRight, 1).id, context->athlete->useMetricUnits ? tr("Meters") : tr("Feet")); double ymin,ymax; if (referencePlot == NULL) { @@ -1274,16 +1278,22 @@ AllPlot::setYMax() xytick[QwtScaleDiv::MajorTick]<setBaseline(ymin); } enableAxis(yLeft, wattsCurve->isVisible() || npCurve->isVisible() || xpCurve->isVisible() || apCurve->isVisible()); - enableAxis(QwtAxisId(QwtAxis::yLeft, 2).id, hrCurve->isVisible() || cadCurve->isVisible()); + enableAxis(QwtAxisId(QwtAxis::yLeft, 1).id, hrCurve->isVisible() || cadCurve->isVisible()); enableAxis(yRight, speedCurve->isVisible()); - enableAxis(QwtAxisId(QwtAxis::yRight, 2).id, altCurve->isVisible()); - enableAxis(QwtAxisId(QwtAxis::yRight, 3).id, wCurve->isVisible()); + enableAxis(QwtAxisId(QwtAxis::yRight, 1).id, altCurve->isVisible()); + enableAxis(QwtAxisId(QwtAxis::yRight, 2).id, wCurve->isVisible()); + + setAxisVisible(yLeft, wattsCurve->isVisible() || npCurve->isVisible() || xpCurve->isVisible() || apCurve->isVisible()); + setAxisVisible(QwtAxisId(QwtAxis::yLeft, 1).id, hrCurve->isVisible() || cadCurve->isVisible()); + setAxisVisible(yRight, speedCurve->isVisible()); + setAxisVisible(QwtAxisId(QwtAxis::yRight, 1).id, altCurve->isVisible()); + setAxisVisible(QwtAxisId(QwtAxis::yRight, 2).id, wCurve->isVisible()); } void @@ -1444,19 +1454,138 @@ AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) sym->setStyle(QwtSymbol::NoSymbol); sym->setSize(0); } - wCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } wattsCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } npCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } xpCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } apCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } hrCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } speedCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } cadCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } altCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } tempCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } torqueCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } balanceLCurve->setSymbol(sym); + + sym = new QwtSymbol; + sym->setPen(QPen(GColor(CPLOTMARKER))); + if (stopidx-startidx < 150) { + sym->setStyle(QwtSymbol::Ellipse); + sym->setSize(3); + } else { + sym->setStyle(QwtSymbol::NoSymbol); + sym->setSize(0); + } balanceRCurve->setSymbol(sym); setYMax(); @@ -1465,7 +1594,7 @@ AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) if (!plot->smoothAltitude.empty()) { altCurve->attach(this); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yRight, 1)); } if (parent->wpData->xdata().count()) { wCurve->attach(this); @@ -1489,7 +1618,7 @@ AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) } if (!plot->smoothHr.empty()) { hrCurve->attach(this); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); } if (!plot->smoothSpeed.empty()) { speedCurve->attach(this); @@ -1497,7 +1626,7 @@ AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) } if (!plot->smoothCad.empty()) { cadCurve->attach(this); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); } if (!plot->smoothTemp.empty()) { tempCurve->attach(this); @@ -1514,7 +1643,7 @@ AllPlot::setDataFromPlot(AllPlot *plot, int startidx, int stopidx) if (!plot->smoothBalanceL.empty()) { balanceLCurve->attach(this); balanceRCurve->attach(this); - intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 2)); + intervalHighlighterCurve->setYAxis(QwtAxisId(QwtAxis::yLeft, 1)); } diff --git a/src/CpintPlot.cpp b/src/CpintPlot.cpp index 58e9c79f4..4cc3bb481 100644 --- a/src/CpintPlot.cpp +++ b/src/CpintPlot.cpp @@ -32,7 +32,6 @@ #include #include "RideItem.h" #include "LogTimeScaleDraw.h" -#include "LogTimeScaleEngine.h" #include "RideFile.h" #include "Season.h" #include "Settings.h" @@ -61,7 +60,7 @@ CpintPlot::CpintPlot(Context *context, QString p, const Zones *zones, bool range LogTimeScaleDraw *ld = new LogTimeScaleDraw; ld->setTickLength(QwtScaleDiv::MajorTick, 3); setAxisScaleDraw(xBottom, ld); - setAxisScaleEngine(xBottom, new LogTimeScaleEngine); + setAxisScaleEngine(xBottom, new QwtLogScaleEngine); setAxisScale(xBottom, (double)0.017, (double)60); QwtScaleDraw *sd = new QwtScaleDraw; @@ -150,7 +149,7 @@ CpintPlot::setSeries(RideFile::SeriesType x) series = x; // Log scale for all bar Energy - setAxisScaleEngine(xBottom, new LogTimeScaleEngine); + setAxisScaleEngine(xBottom, new QwtLogScaleEngine); setAxisScaleDraw(xBottom, new LogTimeScaleDraw); setAxisTitle(xBottom, tr("Interval Length")); diff --git a/src/DBAccess.cpp b/src/DBAccess.cpp index 75efeaa75..aa4b0af51 100644 --- a/src/DBAccess.cpp +++ b/src/DBAccess.cpp @@ -105,6 +105,7 @@ DBAccess::initDatabase(QDir home) db->setDatabaseName(home.absolutePath() + "/metricDBv3"); if (!db->database(sessionid).isOpen()) { + QMessageBox::critical(0, qApp->translate("DBAccess","Cannot open database"), qApp->translate("DBAccess","Unable to establish a database connection.\n" "This feature requires SQLite support. Please read " @@ -156,6 +157,7 @@ bool DBAccess::createMetricsTable() } } } + // we need to create it! if (rc && createTables) { QString createMetricTable = "create table metrics (filename varchar primary key," @@ -293,6 +295,7 @@ bool DBAccess::createDatabase() void DBAccess::checkDBVersion() { + // get a CRC for metadata.xml QString metadataXML = QString(context->athlete->home.absolutePath()) + "/metadata.xml"; int metadatacrcnow = computeFileCRC(metadataXML); @@ -334,21 +337,25 @@ void DBAccess::checkDBVersion() bool dropMeasures = false; while (query.next()) { + QString table_name = query.value(0).toString(); int currentversion = query.value(1).toInt(); //int creationdate = query.value(2).toInt(); // not relevant anymore, we use version/crc int crc = query.value(3).toInt(); if (table_name == "metrics" && (currentversion != DBSchemaVersion || crc != metadatacrcnow)) { + dropMetric = true; } if (table_name == "measures" && crc != measurescrcnow) { + dropMeasures = true; } } query.finish(); + // "metrics" table, is it up-to-date? if (dropMetric) { dropMetricTable(); @@ -540,6 +547,7 @@ DBAccess::getRide(QString filename, SummaryMetrics &summaryMetrics, QColor&color } } } + query.finish(); return found; } @@ -566,10 +574,12 @@ QList DBAccess::getAllMetricsFor(QDateTime start, QDateTime end) " ORDER BY ride_date;"; // execute the select statement - QSqlQuery query(selectStatement, db->database(sessionid)); + QSqlQuery query(db->database(sessionid)); + query.prepare(selectStatement); query.bindValue(":start", start.date()); query.bindValue(":end", end.date()); query.exec(); + while(query.next()) { SummaryMetrics summaryMetrics; @@ -612,11 +622,13 @@ SummaryMetrics DBAccess::getRideMetrics(QString filename) selectStatement += QString(", Z%1 ").arg(context->specialFields.makeTechName(field.name)); } } - selectStatement += " FROM metrics where filename == :filename ;"; + selectStatement += " FROM metrics WHERE filename = :filename ;"; // execute the select statement - QSqlQuery query(selectStatement, db->database(sessionid)); - query.bindValue(":filename", filename); + QSqlQuery query(db->database(sessionid)); + query.prepare(selectStatement); + query.bindValue(":filename", QVariant(filename)); + query.exec(); while(query.next()) { diff --git a/src/LTMPlot.cpp b/src/LTMPlot.cpp index eadfc8d6b..82b5a6132 100644 --- a/src/LTMPlot.cpp +++ b/src/LTMPlot.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -42,17 +43,43 @@ #include // for isinf() isnan() -static int supported_axes[] = { QwtPlot::yLeft, - QwtPlot::yRight, - QwtAxisId(QwtAxis::yLeft,2).id, - QwtAxisId(QwtAxis::yRight,2).id, - QwtAxisId(QwtAxis::yLeft,3).id, - QwtAxisId(QwtAxis::yRight,3).id - }; - LTMPlot::LTMPlot(LTMWindow *parent, Context *context) : bg(NULL), parent(parent), context(context), highlighter(NULL) { + // don't do this .. + setAutoReplot(false); + + // setup my axes + // for now we limit to 4 on left and 4 on right + setAxesCount(QwtAxis::yLeft, 2); + setAxesCount(QwtAxis::yRight, 2); + + int n=0; + for (int i=0; i<2; i++) { + + // lefts + supported_axes[n++] = QwtAxisId(QwtAxis::yLeft, i).id; + + QwtScaleDraw *sd = new QwtScaleDraw; + sd->setTickLength(QwtScaleDiv::MajorTick, 3); + sd->enableComponent(QwtScaleDraw::Ticks, false); + sd->enableComponent(QwtScaleDraw::Backbone, false); + setAxisScaleDraw(supported_axes[n], sd); + setAxisMaxMinor(supported_axes[n], 0); + setAxisVisible(supported_axes[n], false); + + // lefts + supported_axes[n++] = QwtAxisId(QwtAxis::yLeft, i).id; + + sd = new QwtScaleDraw; + sd->setTickLength(QwtScaleDiv::MajorTick, 3); + sd->enableComponent(QwtScaleDraw::Ticks, false); + sd->enableComponent(QwtScaleDraw::Backbone, false); + setAxisScaleDraw(supported_axes[n], sd); + setAxisMaxMinor(supported_axes[n], 0); + setAxisVisible(supported_axes[n], false); + } + // get application settings insertLegend(new QwtLegend(), QwtPlot::BottomLegend); setAxisTitle(yLeft, tr("")); @@ -163,7 +190,11 @@ LTMPlot::setData(LTMSettings *set) } // disable all y axes until we have populated - for (int i=0; i<8; i++) enableAxis(supported_axes[i], false); + for (int i=0; i<4; i++) { + setAxisVisible(supported_axes[i], false); + enableAxis(supported_axes[i], false); + axisWidget(supported_axes[i])->hide(); + } axes.clear(); // reset all min/max Y values @@ -296,9 +327,6 @@ LTMPlot::setData(LTMSettings *set) current->setPen(cpen); current->setStyle(metricDetail.curveStyle); - QwtSymbol *sym = new QwtSymbol; - sym->setStyle(metricDetail.symbolStyle); - // choose the axis int axisid = chooseYAxis(metricDetail.uunits); current->setYAxis(axisid); @@ -345,6 +373,7 @@ LTMPlot::setData(LTMSettings *set) current->setPen(QPen(Qt::NoPen)); current->setCurveAttribute(QwtPlotCurve::Inverted, true); + QwtSymbol *sym = new QwtSymbol; sym->setStyle(QwtSymbol::NoSymbol); current->setSymbol(sym); @@ -443,9 +472,6 @@ LTMPlot::setData(LTMSettings *set) current->setPen(cpen); current->setStyle(metricDetail.curveStyle); - QwtSymbol *sym = new QwtSymbol; - sym->setStyle(metricDetail.symbolStyle); - // choose the axis int axisid = chooseYAxis(metricDetail.uunits); current->setYAxis(axisid); @@ -547,8 +573,11 @@ LTMPlot::setData(LTMSettings *set) // we might have hidden the symbols for this curve // if its set to none then default to a rectangle + QwtSymbol *sym = new QwtSymbol; if (metricDetail.symbolStyle == QwtSymbol::NoSymbol) sym->setStyle(QwtSymbol::Rect); + else + sym->setStyle(metricDetail.symbolStyle); sym->setSize(20); QColor lighter = metricDetail.penColor; lighter.setAlpha(50); @@ -610,8 +639,11 @@ LTMPlot::setData(LTMSettings *set) // we might have hidden the symbols for this curve // if its set to none then default to a rectangle + QwtSymbol *sym = new QwtSymbol; if (metricDetail.symbolStyle == QwtSymbol::NoSymbol) sym->setStyle(QwtSymbol::Rect); + else + sym->setStyle(metricDetail.symbolStyle); sym->setSize(12); QColor lighter = metricDetail.penColor; lighter.setAlpha(200); @@ -638,6 +670,7 @@ LTMPlot::setData(LTMSettings *set) current->setPen(QPen(Qt::NoPen)); current->setCurveAttribute(QwtPlotCurve::Inverted, true); + QwtSymbol *sym = new QwtSymbol; sym->setStyle(QwtSymbol::NoSymbol); current->setSymbol(sym); @@ -689,6 +722,7 @@ LTMPlot::setData(LTMSettings *set) QPen cpen = QPen(metricDetail.penColor); cpen.setWidth(width); + QwtSymbol *sym = new QwtSymbol; sym->setSize(6); sym->setStyle(metricDetail.symbolStyle); sym->setPen(QPen(metricDetail.penColor)); @@ -705,6 +739,8 @@ LTMPlot::setData(LTMSettings *set) } else if (metricDetail.curveStyle == QwtPlotCurve::Dots) { + + QwtSymbol *sym = new QwtSymbol; sym->setSize(6); sym->setStyle(metricDetail.symbolStyle); sym->setPen(QPen(metricDetail.penColor)); @@ -713,6 +749,7 @@ LTMPlot::setData(LTMSettings *set) } else if (metricDetail.curveStyle == QwtPlotCurve::Sticks) { + QwtSymbol *sym = new QwtSymbol; sym->setSize(4); sym->setStyle(metricDetail.symbolStyle); sym->setPen(QPen(metricDetail.penColor)); @@ -780,8 +817,8 @@ LTMPlot::setData(LTMSettings *set) } QString format = axisTitle(yLeft).text(); - parent->toolTip()->setAxes(xBottom, yLeft); - parent->toolTip()->setFormat(format); + //XXX parent->toolTip()->setAxes(xBottom, yLeft); + //XXX parent->toolTip()->setFormat(format); // draw zone labels axisid of -1 means delete whats there // cause no watts are being displayed @@ -901,7 +938,7 @@ LTMPlot::createCurveData(LTMSettings *settings, MetricDetail metricDetail, QVect int lastDay=0; unsigned long secondsPerGroupBy=0; bool wantZero = (metricDetail.curveStyle == QwtPlotCurve::Steps); - foreach (SummaryMetrics rideMetrics, *data) { + foreach (SummaryMetrics rideMetrics, *data) { // filter out unwanted rides but not for PMC type metrics // because that needs to be done in the stress calculator @@ -1094,18 +1131,14 @@ LTMPlot::chooseYAxis(QString units) // return the YAxis to use if ((chosen = axes.value(units, -1)) != -1) return chosen; - else if (axes.count() < 8) { + else if (axes.count() < 4) { chosen = supported_axes[axes.count()]; if (units == "seconds" || units == tr("seconds")) setAxisTitle(chosen, tr("hours")); // we convert seconds to hours else setAxisTitle(chosen, units); enableAxis(chosen, true); + setAxisVisible(chosen, true); + axisWidget(chosen)->show(); axes.insert(units, chosen); - QwtScaleDraw *sd = new QwtScaleDraw; - sd->setTickLength(QwtScaleDiv::MajorTick, 3); - sd->enableComponent(QwtScaleDraw::Ticks, false); - sd->enableComponent(QwtScaleDraw::Backbone, false); - setAxisScaleDraw(chosen, sd); - setAxisMaxMinor(chosen, 0); return chosen; } else { // eek! diff --git a/src/LTMPlot.h b/src/LTMPlot.h index 2d7bca62b..e75007077 100644 --- a/src/LTMPlot.h +++ b/src/LTMPlot.h @@ -26,6 +26,7 @@ #include #include #include +#include #include "LTMTool.h" #include "LTMSettings.h" @@ -102,6 +103,8 @@ class LTMPlot : public QwtPlot // remember the coggan or skiba stress calculators // so it isn't recalculated for each data series! StressCalculator *cogganPMC, *skibaPMC; + + int supported_axes[8]; }; // Produce Labels for X-Axis diff --git a/src/LTMSettings.cpp b/src/LTMSettings.cpp index f8301924c..fe47c6fbc 100644 --- a/src/LTMSettings.cpp +++ b/src/LTMSettings.cpp @@ -128,6 +128,9 @@ LTMSettings::readChartXML(QDir home, QList &charts) *----------------------------------------------------------------------*/ QDataStream &operator<<(QDataStream &out, const LTMSettings &settings) { + // 4.6 - 4.9 all the same + out.setVersion(QDataStream::Qt_4_9); + // all the baisc fields first out<>(QDataStream &in, LTMSettings &settings) { + // 4.6 - 4.9 all the same + in.setVersion(QDataStream::Qt_4_9); + RideMetricFactory &factory = RideMetricFactory::instance(); int counter=0; int version=0; @@ -198,8 +204,7 @@ QDataStream &operator>>(QDataStream &in, LTMSettings &settings) in>>version; in>>counter; } - - while(counter--) { +while(counter-- && !in.atEnd()) { MetricDetail m; in>>m.type; in>>m.stack; diff --git a/src/LTMSettings.h b/src/LTMSettings.h index a5f73c759..f3024e4ef 100644 --- a/src/LTMSettings.h +++ b/src/LTMSettings.h @@ -118,7 +118,6 @@ class MetricDetail { // do this QDataStream &operator<<(QDataStream &out, const LTMSettings &settings); QDataStream &operator>>(QDataStream &in, LTMSettings &settings); -Q_DECLARE_METATYPE(LTMSettings); // used to maintain details about the metrics being plotted class LTMSettings { @@ -128,6 +127,8 @@ class LTMSettings { LTMSettings() { // we need to register the stream operators qRegisterMetaTypeStreamOperators("LTMSettings"); + data = measures = bests = NULL; + ltmTool = NULL; } void writeChartXML(QDir, QList); @@ -150,6 +151,7 @@ class LTMSettings { LTMTool *ltmTool; QString field1, field2; }; +Q_DECLARE_METATYPE(LTMSettings); class EditChartDialog : public QDialog { diff --git a/src/LTMWindow.cpp b/src/LTMWindow.cpp index 68b9994a5..6f26f2151 100644 --- a/src/LTMWindow.cpp +++ b/src/LTMWindow.cpp @@ -93,6 +93,7 @@ LTMWindow::LTMWindow(Context *context) : popupLayout->addWidget(ltmPopup); popup->setLayout(popupLayout); +#if 0 // zoomer on the plot ltmZoomer = new QwtPlotZoomer(ltmPlot->canvas()); ltmZoomer->setRubberBand(QwtPicker::RectRubberBand); @@ -120,6 +121,7 @@ LTMWindow::LTMWindow(Context *context) : picker->setEnabled(true); _canvasPicker = new LTMCanvasPicker(ltmPlot); +#endif ltmTool = new LTMTool(context, &settings); @@ -153,8 +155,8 @@ LTMWindow::LTMWindow(Context *context) : connect(context, SIGNAL(filterChanged()), this, SLOT(refresh())); // connect pickers to ltmPlot - connect(_canvasPicker, SIGNAL(pointHover(QwtPlotCurve*, int)), ltmPlot, SLOT(pointHover(QwtPlotCurve*, int))); - connect(_canvasPicker, SIGNAL(pointClicked(QwtPlotCurve*, int)), ltmPlot, SLOT(pointClicked(QwtPlotCurve*, int))); + //XXX connect(_canvasPicker, SIGNAL(pointHover(QwtPlotCurve*, int)), ltmPlot, SLOT(pointHover(QwtPlotCurve*, int))); + //XXX connect(_canvasPicker, SIGNAL(pointClicked(QwtPlotCurve*, int)), ltmPlot, SLOT(pointClicked(QwtPlotCurve*, int))); connect(context, SIGNAL(rideAdded(RideItem*)), this, SLOT(refresh(void))); connect(context, SIGNAL(rideDeleted(RideItem*)), this, SLOT(refresh(void))); diff --git a/src/LogTimeScaleDraw.cpp b/src/LogTimeScaleDraw.cpp index 2dd479dac..6a2db73aa 100644 --- a/src/LogTimeScaleDraw.cpp +++ b/src/LogTimeScaleDraw.cpp @@ -48,7 +48,24 @@ struct tick_info_t { char *label; }; -extern tick_info_t tick_info[]; +static tick_info_t tick_info[] = { + { 1.0/60.0, "1s" }, + { 5.0/60.0, "5s" }, + { 15.0/60.0, "15s" }, + { 0.5, "30s" }, + { 1.0, "1m" }, + { 2.0, "2m" }, + { 3.0, "3m" }, + { 5.0, "5m" }, + { 10.0, "10m" }, + { 20.0, "20m" }, + { 30.0, "30m" }, + { 60.0, "1h" }, + { 120.0, "2h" }, + { 180.0, "3h" }, + { 300.0, "5h" }, + { -1.0, NULL } +}; void LogTimeScaleDraw::drawLabel(QPainter *painter, double value) const diff --git a/src/LogTimeScaleEngine.cpp b/src/deprecated/LogTimeScaleEngine.cpp similarity index 100% rename from src/LogTimeScaleEngine.cpp rename to src/deprecated/LogTimeScaleEngine.cpp diff --git a/src/LogTimeScaleEngine.h b/src/deprecated/LogTimeScaleEngine.h similarity index 100% rename from src/LogTimeScaleEngine.h rename to src/deprecated/LogTimeScaleEngine.h diff --git a/src/src.pro b/src/src.pro index 5d81500e2..d6b1be022 100644 --- a/src/src.pro +++ b/src/src.pro @@ -309,7 +309,6 @@ HEADERS += \ Library.h \ LibraryParser.h \ LogTimeScaleDraw.h \ - LogTimeScaleEngine.h \ LTMCanvasPicker.h \ LTMChartParser.h \ LTMOutliers.h \ @@ -502,7 +501,6 @@ SOURCES += \ Library.cpp \ LibraryParser.cpp \ LogTimeScaleDraw.cpp \ - LogTimeScaleEngine.cpp \ LTMCanvasPicker.cpp \ LTMChartParser.cpp \ LTMOutliers.cpp \ diff --git a/src/translations/gc_cs.qm b/src/translations/gc_cs.qm deleted file mode 100644 index f6bb1fa99..000000000 Binary files a/src/translations/gc_cs.qm and /dev/null differ diff --git a/src/translations/gc_de.qm b/src/translations/gc_de.qm deleted file mode 100644 index 3886c18aa..000000000 Binary files a/src/translations/gc_de.qm and /dev/null differ diff --git a/src/translations/gc_es.qm b/src/translations/gc_es.qm deleted file mode 100644 index abb146fb5..000000000 Binary files a/src/translations/gc_es.qm and /dev/null differ diff --git a/src/translations/gc_fr.qm b/src/translations/gc_fr.qm deleted file mode 100644 index b5a757786..000000000 Binary files a/src/translations/gc_fr.qm and /dev/null differ diff --git a/src/translations/gc_it.qm b/src/translations/gc_it.qm deleted file mode 100644 index 34482cb29..000000000 Binary files a/src/translations/gc_it.qm and /dev/null differ diff --git a/src/translations/gc_ja.qm b/src/translations/gc_ja.qm deleted file mode 100644 index 734fa55f7..000000000 Binary files a/src/translations/gc_ja.qm and /dev/null differ diff --git a/src/translations/gc_pt-br.qm b/src/translations/gc_pt-br.qm deleted file mode 100644 index 01bf6c2a4..000000000 Binary files a/src/translations/gc_pt-br.qm and /dev/null differ diff --git a/src/translations/gc_pt.qm b/src/translations/gc_pt.qm deleted file mode 100644 index 3ce31f09b..000000000 Binary files a/src/translations/gc_pt.qm and /dev/null differ diff --git a/src/translations/gc_ru.qm b/src/translations/gc_ru.qm deleted file mode 100644 index 8cd42d4e5..000000000 Binary files a/src/translations/gc_ru.qm and /dev/null differ