mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Fixed broken slider position setting
Refactoring
This commit is contained in:
parent
de71aa0d0c
commit
58bed99d14
@ -161,10 +161,10 @@ void GraphView::loadData(const QVector<QPointF> &data)
|
|||||||
void GraphView::redraw()
|
void GraphView::redraw()
|
||||||
{
|
{
|
||||||
if (!_graphs.isEmpty())
|
if (!_graphs.isEmpty())
|
||||||
resize(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::resize(const QSizeF &size)
|
void GraphView::redraw(const QSizeF &size)
|
||||||
{
|
{
|
||||||
QRectF r;
|
QRectF r;
|
||||||
QSizeF mx, my;
|
QSizeF mx, my;
|
||||||
@ -220,6 +220,7 @@ void GraphView::resize(const QSizeF &size)
|
|||||||
_scene->addItem(_xAxis);
|
_scene->addItem(_xAxis);
|
||||||
_scene->addItem(_yAxis);
|
_scene->addItem(_yAxis);
|
||||||
|
|
||||||
|
|
||||||
qreal sp = (_slider->pos().x() == _slider->area().left())
|
qreal sp = (_slider->pos().x() == _slider->area().left())
|
||||||
? 0 : (_slider->pos().x() - _slider->area().left())
|
? 0 : (_slider->pos().x() - _slider->area().left())
|
||||||
/ _slider->area().width();
|
/ _slider->area().width();
|
||||||
@ -251,13 +252,13 @@ void GraphView::plot(QPainter *painter, const QRectF &target)
|
|||||||
QSizeF orig = _scene->sceneRect().size();
|
QSizeF orig = _scene->sceneRect().size();
|
||||||
QSizeF canvas = QSizeF(orig.height() * ratio, orig.height());
|
QSizeF canvas = QSizeF(orig.height() * ratio, orig.height());
|
||||||
|
|
||||||
resize(canvas);
|
redraw(canvas);
|
||||||
_slider->hide();
|
_slider->hide();
|
||||||
_info->hide();
|
_info->hide();
|
||||||
_scene->render(painter, target, QRectF());
|
_scene->render(painter, target, QRectF());
|
||||||
_slider->show();
|
_slider->show();
|
||||||
_info->show();
|
_info->show();
|
||||||
resize(orig);
|
redraw(orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::clear()
|
void GraphView::clear()
|
||||||
@ -352,6 +353,9 @@ qreal GraphView::sliderPosition() const
|
|||||||
|
|
||||||
void GraphView::setSliderPosition(qreal pos)
|
void GraphView::setSliderPosition(qreal pos)
|
||||||
{
|
{
|
||||||
|
if (_graphs.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
if (pos > (_xMax - _xMin))
|
if (pos > (_xMax - _xMin))
|
||||||
_slider->setVisible(false);
|
_slider->setVisible(false);
|
||||||
else {
|
else {
|
||||||
|
@ -44,24 +44,23 @@ public:
|
|||||||
void setPrecision(int precision) {_precision = precision;}
|
void setPrecision(int precision) {_precision = precision;}
|
||||||
void setMinRange(qreal range) {_minRange = range;}
|
void setMinRange(qreal range) {_minRange = range;}
|
||||||
|
|
||||||
void redraw();
|
|
||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target);
|
void plot(QPainter *painter, const QRectF &target);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
qreal sliderPosition() const;
|
qreal sliderPosition() const;
|
||||||
void setSliderPosition(qreal pos);
|
void setSliderPosition(qreal pos);
|
||||||
|
|
||||||
void addInfo(const QString &key, const QString &value);
|
int count() const {return _graphs.count();}
|
||||||
void clearInfo();
|
|
||||||
|
|
||||||
void skipColor() {_palette.color();}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sliderPositionChanged(qreal);
|
void sliderPositionChanged(qreal);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
|
void redraw();
|
||||||
|
void addInfo(const QString &key, const QString &value);
|
||||||
|
void clearInfo();
|
||||||
|
void skipColor() {_palette.color();}
|
||||||
|
|
||||||
qreal _xScale, _yScale;
|
qreal _xScale, _yScale;
|
||||||
QString _xUnits, _yUnits;
|
QString _xUnits, _yUnits;
|
||||||
@ -77,7 +76,7 @@ private:
|
|||||||
void createXLabel();
|
void createXLabel();
|
||||||
void createYLabel();
|
void createYLabel();
|
||||||
void updateBounds(const QPointF &point);
|
void updateBounds(const QPointF &point);
|
||||||
void resize(const QSizeF &size);
|
void redraw(const QSizeF &size);
|
||||||
|
|
||||||
Scene *_scene;
|
Scene *_scene;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user