1 | /*
|
---|
2 | * QSeisPlot.hpp
|
---|
3 | *
|
---|
4 | * Created on: Jan 30, 2011
|
---|
5 | * Author: landvogt
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef QSEISPLOT_HPP
|
---|
9 | #define QSEISPLOT_HPP
|
---|
10 |
|
---|
11 | // include config.h
|
---|
12 | #ifdef HAVE_CONFIG_H
|
---|
13 | #include <config.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | //uncomment the define below to use the QwtPlotPanner instead
|
---|
17 | //of my manual implementation
|
---|
18 | //#define QWTPANNER
|
---|
19 |
|
---|
20 | #include <qwt_global.h>
|
---|
21 | #include <qwt_plot.h>
|
---|
22 | #ifdef QWTPANNER
|
---|
23 | #include <qwt_plot_panner.h>
|
---|
24 | #endif
|
---|
25 | #include "UIElements/Views/Qt4/Plotting/QScrollZoomer/ScrollZoomer.hpp"
|
---|
26 | #include <QtGui/QMouseEvent>
|
---|
27 | #include <QtCore/QList>
|
---|
28 | #include <map>
|
---|
29 | #include <string>
|
---|
30 |
|
---|
31 | class plottype;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * \class QSeisPlot
|
---|
35 | *
|
---|
36 | * This class is derived from QwtPlot.
|
---|
37 | * It implements the ScrollZoomer class
|
---|
38 | * from the Qwt Realtime example.
|
---|
39 | * The zoomer implementation has some flaws
|
---|
40 | * because the zoomer class needs to know
|
---|
41 | * what QRectF is the "unzoomed" view.
|
---|
42 | * Not all actions where this rect is changed
|
---|
43 | * are correctly handled at the moment!
|
---|
44 | *
|
---|
45 | * It is possible to pan around the plot canvas
|
---|
46 | * using the middle mouse button.
|
---|
47 | * The original QwtPanner implementation (available
|
---|
48 | * by defining "QWTPANNER") is less CPU intensive
|
---|
49 | * but does not pan while dragging around.
|
---|
50 | *
|
---|
51 | * This class also holds a QList of available
|
---|
52 | * curve colours. The list is initialised in the
|
---|
53 | * constructor. The QSeisPlotCurve class is
|
---|
54 | * implemented to fetch a colour from plot it is
|
---|
55 | * about to get attached to and "free the colour"
|
---|
56 | * if it gets detached.
|
---|
57 | **/
|
---|
58 |
|
---|
59 | class QSeisPlot : public QwtPlot
|
---|
60 | {
|
---|
61 | Q_OBJECT
|
---|
62 |
|
---|
63 | public:
|
---|
64 | QSeisPlot(QWidget *parent,QString type);
|
---|
65 | ~QSeisPlot();
|
---|
66 | void loadSettingsFromXML(QString fileName);
|
---|
67 | QColor getCurveColor(std::string);
|
---|
68 | void freeCurveColor(QColor color);
|
---|
69 |
|
---|
70 | private:
|
---|
71 | QList<QColor> availableColors;
|
---|
72 | ScrollZoomer *zoomer;
|
---|
73 | std::map<std::string,QColor> color_map;
|
---|
74 | #ifdef QWTPANNER
|
---|
75 | QwtPlotPanner *panner;
|
---|
76 | #else
|
---|
77 | QPointF startPan;
|
---|
78 | bool panning;
|
---|
79 | plottype *m_plottype;
|
---|
80 |
|
---|
81 | void mouseMoveEvent(QMouseEvent *event);
|
---|
82 | void mousePressEvent(QMouseEvent *event);
|
---|
83 | void mouseReleaseEvent(QMouseEvent *event);
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | signals:
|
---|
87 |
|
---|
88 | public slots:
|
---|
89 | void resetPlot();
|
---|
90 | void resetZoomer();
|
---|
91 | };
|
---|
92 |
|
---|
93 | #endif // QSEISPLOT_HPP
|
---|