· · ·
item-pixmap.h
1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011, 2012, 2013, 2014 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: 07.04.14 **
23 ** Version: 1.2.1 **
24 ****************************************************************************/
25
26 #ifndef QCP_ITEM_PIXMAP_H
27 #define QCP_ITEM_PIXMAP_H
28
29 #include "../global.h"
30 #include "../item.h"
31
32 class QCPPainter;
33 class QCustomPlot;
34
35 class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem
36 {
37 Q_OBJECT
39 Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
40 Q_PROPERTY(bool scaled READ scaled WRITE setScaled)
41 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode)
42 Q_PROPERTY(QPen pen READ pen WRITE setPen)
43 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
45 public:
46 QCPItemPixmap(QCustomPlot *parentPlot);
47 virtual ~QCPItemPixmap();
48
49 // getters:
50 QPixmap pixmap() const { return mPixmap; }
51 bool scaled() const { return mScaled; }
52 Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; }
53 QPen pen() const { return mPen; }
54 QPen selectedPen() const { return mSelectedPen; }
55
56 // setters;
57 void setPixmap(const QPixmap &pixmap);
58 void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio);
59 void setPen(const QPen &pen);
60 void setSelectedPen(const QPen &pen);
61
62 // reimplemented virtual methods:
63 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
64
65 QCPItemPosition * const topLeft;
66 QCPItemPosition * const bottomRight;
67 QCPItemAnchor * const top;
68 QCPItemAnchor * const topRight;
69 QCPItemAnchor * const right;
70 QCPItemAnchor * const bottom;
71 QCPItemAnchor * const bottomLeft;
72 QCPItemAnchor * const left;
73
74 protected:
75 enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
76
77 // property members:
78 QPixmap mPixmap;
79 QPixmap mScaledPixmap;
80 bool mScaled;
81 Qt::AspectRatioMode mAspectRatioMode;
82 QPen mPen, mSelectedPen;
83
84 // reimplemented virtual methods:
85 virtual void draw(QCPPainter *painter);
86 virtual QPointF anchorPixelPoint(int anchorId) const;
87
88 // non-virtual methods:
89 void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false);
90 QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const;
91 QPen mainPen() const;
92 };
93
94 #endif // QCP_ITEM_PIXMAP_H
Generated with Doxygen 1.8.1.2