src/items/item-rect.h Source File

· · ·
item-rect.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_RECT_H
27 #define QCP_ITEM_RECT_H
28
29 #include "../global.h"
30 #include "../item.h"
31
32 class QCPPainter;
33 class QCustomPlot;
34
35 class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem
36 {
37 Q_OBJECT
39 Q_PROPERTY(QPen pen READ pen WRITE setPen)
40 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
41 Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
42 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
44 public:
45 QCPItemRect(QCustomPlot *parentPlot);
46 virtual ~QCPItemRect();
47
48 // getters:
49 QPen pen() const { return mPen; }
50 QPen selectedPen() const { return mSelectedPen; }
51 QBrush brush() const { return mBrush; }
52 QBrush selectedBrush() const { return mSelectedBrush; }
53
54 // setters;
55 void setPen(const QPen &pen);
56 void setSelectedPen(const QPen &pen);
57 void setBrush(const QBrush &brush);
58 void setSelectedBrush(const QBrush &brush);
59
60 // reimplemented virtual methods:
61 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
62
63 QCPItemPosition * const topLeft;
64 QCPItemPosition * const bottomRight;
65 QCPItemAnchor * const top;
66 QCPItemAnchor * const topRight;
67 QCPItemAnchor * const right;
68 QCPItemAnchor * const bottom;
69 QCPItemAnchor * const bottomLeft;
70 QCPItemAnchor * const left;
71
72 protected:
73 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
74
75 // property members:
76 QPen mPen, mSelectedPen;
77 QBrush mBrush, mSelectedBrush;
78
79 // reimplemented virtual methods:
80 virtual void draw(QCPPainter *painter);
81 virtual QPointF anchorPixelPoint(int anchorId) const;
82
83 // non-virtual methods:
84 QPen mainPen() const;
85 QBrush mainBrush() const;
86 };
87
88 #endif // QCP_ITEM_RECT_H
Generated with Doxygen 1.8.1.2