src/items/item-tracer.h Source File

· · ·
item-tracer.h
1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
5 ** **
6 ** This program is free software: you can redistribute it and/or modify **
7 ** it under the terms of the GNU General Public License as published by **
8 ** the Free Software Foundation, either version 3 of the License, or **
9 ** (at your option) any later version. **
10 ** **
11 ** This program is distributed in the hope that it will be useful, **
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
14 ** GNU General Public License for more details. **
15 ** **
16 ** You should have received a copy of the GNU General Public License **
17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
18 ** **
19 ****************************************************************************
20 ** Author: Emanuel Eichhammer **
21 ** Website/Contact: http://www.qcustomplot.com/ **
22 ** Date: 04.11.13 **
23 ** Version: 1.1.0 **
24 ****************************************************************************/
25
26 #ifndef QCP_ITEM_TRACER_H
27 #define QCP_ITEM_TRACER_H
28
29 #include "../global.h"
30 #include "../item.h"
31
32 class QCPPainter;
33 class QCustomPlot;
34 class QCPGraph;
35
36 class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem
37 {
38 Q_OBJECT
40 Q_PROPERTY(QPen pen READ pen WRITE setPen)
41 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
42 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
43 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
44 Q_PROPERTY(double size READ size WRITE setSize)
45 Q_PROPERTY(TracerStyle style READ style WRITE setStyle)
46 Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph)
47 Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey)
48 Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating)
50 public:
56 enum TracerStyle { tsNone
57 ,tsPlus
58 ,tsCrosshair
59 ,tsCircle
60 ,tsSquare
61 };
62 Q_ENUMS(TracerStyle)
63
64 QCPItemTracer(QCustomPlot *parentPlot);
65 virtual ~QCPItemTracer();
66
67 // getters:
68 QPen pen() const { return mPen; }
69 QPen selectedPen() const { return mSelectedPen; }
70 QBrush brush() const { return mBrush; }
71 QBrush selectedBrush() const { return mSelectedBrush; }
72 double size() const { return mSize; }
73 TracerStyle style() const { return mStyle; }
74 QCPGraph *graph() const { return mGraph; }
75 double graphKey() const { return mGraphKey; }
76 bool interpolating() const { return mInterpolating; }
77
78 // setters;
79 void setPen(const QPen &pen);
80 void setSelectedPen(const QPen &pen);
81 void setBrush(const QBrush &brush);
82 void setSelectedBrush(const QBrush &brush);
83 void setSize(double size);
84 void setStyle(TracerStyle style);
85 void setGraph(QCPGraph *graph);
86 void setGraphKey(double key);
87 void setInterpolating(bool enabled);
88
89 // reimplemented virtual methods:
90 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
91
92 // non-virtual methods:
93 void updatePosition();
94
95 QCPItemPosition * const position;
96
97 protected:
98 // property members:
99 QPen mPen, mSelectedPen;
100 QBrush mBrush, mSelectedBrush;
101 double mSize;
102 TracerStyle mStyle;
103 QCPGraph *mGraph;
104 double mGraphKey;
105 bool mInterpolating;
106
107 // reimplemented virtual methods:
108 virtual void draw(QCPPainter *painter);
109
110 // non-virtual methods:
111 QPen mainPen() const;
112 QBrush mainBrush() const;
113 };
114
115 #endif // QCP_ITEM_TRACER_H
Generated with Doxygen 1.8.1.2