mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Code cleanup
This commit is contained in:
parent
c89f8dbb47
commit
0d1b416c4f
@ -1,5 +1,6 @@
|
|||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsScene>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <QPaintEngine>
|
#include <QPaintEngine>
|
||||||
#include <QPaintDevice>
|
#include <QPaintDevice>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -16,20 +17,10 @@
|
|||||||
|
|
||||||
#define MARGIN 10.0
|
#define MARGIN 10.0
|
||||||
|
|
||||||
|
|
||||||
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
|
||||||
{
|
|
||||||
if (e->button() == Qt::LeftButton)
|
|
||||||
emit mouseClicked(e->scenePos());
|
|
||||||
|
|
||||||
QGraphicsScene::mousePressEvent(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GraphView::GraphView(QWidget *parent)
|
GraphView::GraphView(QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
_scene = new Scene(this);
|
_scene = new QGraphicsScene();
|
||||||
setScene(_scene);
|
setScene(_scene);
|
||||||
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
@ -48,8 +39,6 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
|
|
||||||
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
||||||
SLOT(emitSliderPositionChanged(const QPointF&)));
|
SLOT(emitSliderPositionChanged(const QPointF&)));
|
||||||
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
|
||||||
SLOT(newSliderPosition(const QPointF&)));
|
|
||||||
|
|
||||||
_xScale = 1;
|
_xScale = 1;
|
||||||
_yScale = 1;
|
_yScale = 1;
|
||||||
@ -322,6 +311,14 @@ void GraphView::resizeEvent(QResizeEvent *)
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::mousePressEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
if (e->button() == Qt::LeftButton)
|
||||||
|
newSliderPosition(mapToScene(e->pos()));
|
||||||
|
|
||||||
|
QGraphicsView::mousePressEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
void GraphView::plot(QPainter *painter, const QRectF &target)
|
void GraphView::plot(QPainter *painter, const QRectF &target)
|
||||||
{
|
{
|
||||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
||||||
|
@ -2,11 +2,9 @@
|
|||||||
#define GRAPHVIEW_H
|
#define GRAPHVIEW_H
|
||||||
|
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QGraphicsScene>
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QPointF>
|
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
@ -20,17 +18,6 @@ class GraphItem;
|
|||||||
class PathItem;
|
class PathItem;
|
||||||
class GridItem;
|
class GridItem;
|
||||||
|
|
||||||
class Scene : public QGraphicsScene
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
Scene(QObject *parent = 0) : QGraphicsScene(parent) {}
|
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *e);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void mouseClicked(const QPointF &pos);
|
|
||||||
};
|
|
||||||
|
|
||||||
class GraphView : public QGraphicsView
|
class GraphView : public QGraphicsView
|
||||||
{
|
{
|
||||||
@ -76,7 +63,6 @@ protected:
|
|||||||
void addInfo(const QString &key, const QString &value);
|
void addInfo(const QString &key, const QString &value);
|
||||||
void clearInfo();
|
void clearInfo();
|
||||||
void skipColor() {_palette.color();}
|
void skipColor() {_palette.color();}
|
||||||
void resizeEvent(QResizeEvent *);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitSliderPositionChanged(const QPointF &pos);
|
void emitSliderPositionChanged(const QPointF &pos);
|
||||||
@ -91,6 +77,9 @@ private:
|
|||||||
void removeItem(QGraphicsItem *item);
|
void removeItem(QGraphicsItem *item);
|
||||||
void addItem(QGraphicsItem *item);
|
void addItem(QGraphicsItem *item);
|
||||||
|
|
||||||
|
void resizeEvent(QResizeEvent *);
|
||||||
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
|
||||||
qreal _xScale, _yScale;
|
qreal _xScale, _yScale;
|
||||||
qreal _yOffset;
|
qreal _yOffset;
|
||||||
QString _xUnits, _yUnits;
|
QString _xUnits, _yUnits;
|
||||||
@ -99,7 +88,7 @@ private:
|
|||||||
qreal _minYRange;
|
qreal _minYRange;
|
||||||
qreal _sliderPos;
|
qreal _sliderPos;
|
||||||
|
|
||||||
Scene *_scene;
|
QGraphicsScene *_scene;
|
||||||
|
|
||||||
AxisItem *_xAxis, *_yAxis;
|
AxisItem *_xAxis, *_yAxis;
|
||||||
SliderItem *_slider;
|
SliderItem *_slider;
|
||||||
|
Loading…
Reference in New Issue
Block a user