1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 14:53:21 +02:00

Fixed some more display issues

This commit is contained in:
Martin Tůma 2016-09-26 10:09:56 +02:00
parent 80bf57abfc
commit 014e260042
4 changed files with 14 additions and 23 deletions

View File

@ -152,7 +152,8 @@ void GraphView::setGraphType(GraphType type)
for (int i = 0; i < _graphs.count(); i++) {
_graphs.at(i)->setGraphType(type);
updateBounds(_graphs.at(i)->boundingRect());
if (_graphs.at(i)->scene() == _scene)
_bounds |= _graphs.at(i)->boundingRect();
}
if (type == Distance)
@ -185,7 +186,7 @@ void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
if (!_hide.contains(id)) {
_visible.append(gi);
_scene->addItem(gi);
updateBounds(gi->boundingRect());
_bounds |= gi->boundingRect();
setXUnits();
}
}
@ -218,7 +219,7 @@ void GraphView::showGraph(bool show, int id)
else {
addItem(gi);
_visible.append(gi);
updateBounds(gi->boundingRect());
_bounds |= gi->boundingRect();
}
}
}
@ -228,21 +229,11 @@ void GraphView::redraw()
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
}
void GraphView::updateBounds(const QRectF &boundingRect)
QRectF GraphView::bounds() const
{
QRectF br(boundingRect);
QRectF br(_bounds);
br.moveTopLeft(QPointF(br.left(), -br.top() - br.height()));
_bounds |= br;
}
QRectF GraphView::graphsBoundingRect() const
{
QRectF rect;
for (int i = 0; i < _visible.count(); i++)
rect |= _visible.at(i)->boundingRect();
return rect;
return br;
}
void GraphView::redraw(const QSizeF &size)
@ -279,7 +270,7 @@ void GraphView::redraw(const QSizeF &size)
mx = _xAxis->margin();
my = _yAxis->margin();
r = graphsBoundingRect();
r = _bounds;
if (r.height() < _minYRange)
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
_minYRange/2 - r.height()/2);

View File

@ -69,7 +69,7 @@ signals:
void sliderPositionChanged(qreal);
protected:
const QRectF &bounds() const {return _bounds;}
QRectF bounds() const;
void redraw(const QSizeF &size);
void addInfo(const QString &key, const QString &value);
void clearInfo();
@ -86,8 +86,6 @@ private:
void createYLabel();
void updateSliderPosition();
void updateSliderInfo();
void updateBounds(const QRectF &boundingRect);
QRectF graphsBoundingRect() const;
void removeItem(QGraphicsItem *item);
void addItem(QGraphicsItem *item);

View File

@ -108,7 +108,6 @@ void RouteItem::setUnits(enum Units units)
void RouteItem::moveMarker(qreal distance)
{
qDebug() << distance << _distance;
if (distance > _distance)
_marker->setVisible(false);
else {
@ -143,6 +142,8 @@ void RouteItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
_pen.setWidthF(HOVER_WIDTH * 1.0/scale());
setZValue(zValue() + 1.0);
update();
emit selected(true);
}
void RouteItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
@ -152,4 +153,6 @@ void RouteItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
_pen.setWidthF(ROUTE_WIDTH * 1.0/scale());
setZValue(zValue() - 1.0);
update();
emit selected(false);
}

View File

@ -132,8 +132,7 @@ QList<PathItem *> TrackView::loadGPX(const GPX &gpx)
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
return paths;
if ((_tracks.size() > 1 && _zoom < zoom)
|| (_routes.size() > 1 && _zoom < zoom)
if ((_tracks.size() + _routes.size() > 1 && _zoom < zoom)
|| (_waypoints.size() && _zoom < zoom))
rescale(_scale);