diff options
author | jasplin <qt-info@nokia.com> | 2010-04-26 12:32:12 +0200 |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2010-04-26 12:32:12 +0200 |
commit | f7db12a4dedd98bce2ac19288cff73e3251a56b7 (patch) | |
tree | 2e1af7fc7e1ffe8c8cbf22512e93987b130de29f /src | |
parent | dd538e7b4e77af077f9857abe5845cb89a341aa1 (diff) |
Showed more time labels along the x-axis.
Diffstat (limited to 'src')
-rw-r--r-- | src/bm/plotter.cpp | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/bm/plotter.cpp b/src/bm/plotter.cpp index 129bc81..9797eaa 100644 --- a/src/bm/plotter.cpp +++ b/src/bm/plotter.cpp @@ -405,7 +405,7 @@ bool IndexPlotter::drawScenes( // Shift curve vertically according to base value if present ... QList<qreal> dispValues(values); const qreal dispBaseValue = 0.0; // by definition - const qreal linearDispBaseValue = 0.0; // by definition +// const qreal linearDispBaseValue = 0.0; // by definition qreal baseValue = 0.0; if (baseValuePos >= 0) { @@ -508,6 +508,18 @@ bool IndexPlotter::drawScenes( scene_far->addLine(btx, ymin, btx, ymax, QPen(color, 1)); } + const int nDispTimestamps = 8; + const int dispTimestampStep = (hiTimestamp - loTimestamp) / (nDispTimestamps - 1); + QList<qreal> dispTimestamps = QList<qreal>() << loTimestamp << hiTimestamp; + for (int i = 1; i < nDispTimestamps - 1; ++i) + dispTimestamps.insert(i, loTimestamp + i * dispTimestampStep); + + // Draw vertical lines indicating display timestamps ... + for (int i = 0; i < dispTimestamps.size(); ++i) { + const qreal xpos = xmin + (dispTimestamps.at(i) - loTimestamp) * xfact; + scene_far->addLine(xpos, ymin, xpos, ymax, QPen(QColor(200, 200, 200), 1)); + } + const qreal dpSize = 3; // Draw history curve between data points that are not missing ... @@ -587,7 +599,6 @@ bool IndexPlotter::drawScenes( QGraphicsSimpleTextItem *text = scene_near->addSimpleText(QString().setNum(dispBaseValue)); const qreal y_base = BMMisc::v2y(dispBaseValue, ymax, vmin, yfact, ydefault); - qDebug() << "y_base left:" << y_base; text->setPos( xmin - captionPad - captionHeight - labelPad - text->boundingRect().width(), y_base - text->boundingRect().height() / 2); @@ -600,6 +611,7 @@ bool IndexPlotter::drawScenes( } +#if 0 // ... right y axis ... { QFont font; @@ -640,6 +652,7 @@ bool IndexPlotter::drawScenes( delete text; } } +#endif // ... top x axis ... @@ -654,32 +667,29 @@ bool IndexPlotter::drawScenes( } // ... bottom x axis ... - QDateTime dateTime; - dateTime.setTime_t(loTimestamp); - const QString xLabel_lo = dateTime.toString(); - dateTime.setTime_t(hiTimestamp); - const QString xLabel_hi = dateTime.toString(); + { QFont font; font.setPointSize(14); - QGraphicsSimpleTextItem *text = scene_near->addSimpleText("time", font); - const qreal x_ = (xmin + xmax) / 2 - text->boundingRect().width() / 2; - const qreal y_ = ymax + labelPad; - text->translate(x_, y_); - } - { - QGraphicsSimpleTextItem *text = scene_near->addSimpleText(xLabel_lo); - text->setPos( - xmin - text->boundingRect().width() / 2, - ymax + labelPad); - } - { - QGraphicsSimpleTextItem *text = scene_near->addSimpleText(xLabel_hi); - text->setPos( - xmax - text->boundingRect().width() / 2, - ymax + labelPad); - } + for (int i = 0; i < dispTimestamps.size(); ++i) { + + const qreal timestamp = dispTimestamps.at(i); + + const QString xLabel = BMMisc::compactDateString(timestamp); + font.setPointSize(12); + + const qreal xpos = xmin + (timestamp - loTimestamp) * xfact; + + // ... bottom x axis label ... + { + QGraphicsSimpleTextItem *text = scene_near->addSimpleText(xLabel, font); + text->setPos( + xpos - text->boundingRect().width() / 2, + ymax + labelPad * 2); + } + } + } return true; } @@ -800,7 +810,7 @@ bool HistoriesPlotter::drawScenes( xfact = tfact * (xmax - xmin); } - const int nDispTimestamps = 5; + const int nDispTimestamps = 8; const int dispTimestampStep = (hiTimestamp - loTimestamp) / (nDispTimestamps - 1); QList<qreal> dispTimestamps = QList<qreal>() << loTimestamp << hiTimestamp; for (int i = 1; i < nDispTimestamps - 1; ++i) |