1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-31 09:05:14 +01:00

Improved graph zooming

(however, still not perfect...)
This commit is contained in:
Martin Tůma 2020-11-21 20:37:22 +01:00
parent 75bd542feb
commit 781bc8c38f
3 changed files with 6 additions and 1 deletions

View File

@ -41,6 +41,7 @@ AxisItem::AxisItem(Type type, QGraphicsItem *parent)
{
_type = type;
_size = 0;
_zoom = 1.0;
_font.setPixelSize(FONT_SIZE);
_font.setFamily(FONT_FAMILY);
@ -52,7 +53,8 @@ void AxisItem::setRange(const RangeF &range)
_range = range;
QFontMetrics fm(_font);
Ticks ticks(_range.min(), _range.max(), (_type == X) ? XTICKS : YTICKS);
Ticks ticks(_range.min(), _range.max(),
(_type == X) ? XTICKS * _zoom : YTICKS * _zoom);
_ticks = QVector<Tick>(ticks.count());
for (int i = 0; i < ticks.count(); i++) {
Tick &t = _ticks[i];

View File

@ -20,6 +20,7 @@ public:
void setRange(const RangeF &range);
void setSize(qreal size);
void setLabel(const QString& label);
void setZoom(qreal zoom) {_zoom = zoom;}
QSizeF margin() const;
QList<qreal> ticks() const;
@ -41,6 +42,7 @@ private:
QRectF _boundingRect;
QFont _font;
QLocale _locale;
qreal _zoom;
};
#endif // AXISITEM_H

View File

@ -279,6 +279,7 @@ void GraphView::redraw(const QSizeF &size)
ry.resize(_minYRange * _yScale);
_xAxis->setRange(rx);
_xAxis->setZoom(_zoom);
_yAxis->setRange(ry);
mx = _xAxis->margin();
my = _yAxis->margin();