QT5 -- Part 3 of 3

Fixup crashes and major issues created by porting
to QT5. These have included;

* Fix CP plot log scale
* AllPlot axes and tooltip
* DBAccess prepare/bind bug
* LTMSettings crash
* LTMWindow zoomer/picker crash
* LTMPlot axes hack

There are still issues remaining but we can start
working through them at leisure -- the product now
builds and runs.
This commit is contained in:
Mark Liversedge
2013-12-09 14:07:35 +00:00
parent f7854ffc24
commit a876c8da62
23 changed files with 288 additions and 78 deletions

7
.gitignore vendored
View File

@@ -6,3 +6,10 @@ Makefile
# osx noise
.DS_Store
profile
moc/
obj/
lib/
bin/
plugins/
resources/

3
src/.gitignore vendored
View File

@@ -39,3 +39,6 @@ GoldenCheetah.app
#ignore ctags for vim
tags
#ignore patches
*.patch

View File

@@ -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;i<ymax;i+=step)
xytick[QwtScaleDiv::MajorTick]<<i;
setAxisTitle(QwtAxisId(QwtAxis::yLeft, 2).id, labels.join(" / "));
setAxisScaleDiv(QwtAxisId(QwtAxis::yLeft, 2),QwtScaleDiv(ymin, ymax, xytick));
setAxisTitle(QwtAxisId(QwtAxis::yLeft, 1).id, labels.join(" / "));
setAxisScaleDiv(QwtAxisId(QwtAxis::yLeft, 1),QwtScaleDiv(ymin, ymax, xytick));
//setAxisLabelAlignment(yLeft2,Qt::AlignVCenter);
}
if (speedCurve->isVisible() || (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]<<i;
//setAxisScale(QwtAxisId(QwtAxis::yRight, 2), ymin, ymax);
setAxisScaleDiv(QwtAxisId(QwtAxis::yRight, 2),QwtScaleDiv(ymin,ymax,xytick));
setAxisScaleDiv(QwtAxisId(QwtAxis::yRight, 1),QwtScaleDiv(ymin,ymax,xytick));
//setAxisLabelAlignment(QwtAxisId(QwtAxis::yRight, 2),Qt::AlignVCenter);
altCurve->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));
}

View File

@@ -32,7 +32,6 @@
#include <qwt_scale_widget.h>
#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"));

View File

@@ -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<SummaryMetrics> 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())
{

View File

@@ -34,6 +34,7 @@
#include <QSettings>
#include <qwt_series_data.h>
#include <qwt_scale_widget.h>
#include <qwt_legend.h>
#include <qwt_plot_curve.h>
#include <qwt_curve_fitter.h>
@@ -42,17 +43,43 @@
#include <math.h> // 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!

View File

@@ -26,6 +26,7 @@
#include <qwt_plot_curve.h>
#include <qwt_plot_grid.h>
#include <qwt_scale_draw.h>
#include <qwt_axis_id.h>
#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

View File

@@ -128,6 +128,9 @@ LTMSettings::readChartXML(QDir home, QList<LTMSettings> &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<<settings.name;
out<<settings.title;
@@ -176,6 +179,9 @@ QDataStream &operator<<(QDataStream &out, const LTMSettings &settings)
QDataStream &operator>>(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;

View File

@@ -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>("LTMSettings");
data = measures = bests = NULL;
ltmTool = NULL;
}
void writeChartXML(QDir, QList<LTMSettings>);
@@ -150,6 +151,7 @@ class LTMSettings {
LTMTool *ltmTool;
QString field1, field2;
};
Q_DECLARE_METATYPE(LTMSettings);
class EditChartDialog : public QDialog
{

View File

@@ -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)));

View File

@@ -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

View File

@@ -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 \

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.