1 /***************************************************************************
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011, 2012, 2013 Emanuel Eichhammer **
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 2 of the License, or **
9 ** (at your option) any later version. **
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. **
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/. **
19 ****************************************************************************
20 ** Author: Emanuel Eichhammer **
21 ** Website/Contact: http://www.qcustomplot.com/ **
24 ****************************************************************************
25 ** Emanuel Eichhammer has granted Wireshark permission to use QCustomPlot **
26 ** under the terms of the GNU General Public License version 2. **
27 ****************************************************************************/
32 #ifdef QT_DISABLE_DEPRECATED_BEFORE
33 # undef QT_DISABLE_DEPRECATED_BEFORE
35 #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(0, 0, 0)
38 #include <QWeakPointer>
41 #include <QPaintEvent>
42 #include <QMouseEvent>
56 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
57 # include <qnumeric.h>
67 class QCPLayoutElement
;
71 class QCPAbstractPlottable
;
73 class QCPAbstractItem
;
74 class QCPItemPosition
;
78 class QCPAbstractLegendItem
;
79 class QCPAbstractItem
;
84 #ifdef QT_DISABLE_DEPRECATED_BEFORE
85 # undef QT_DISABLE_DEPRECATED_BEFORE
87 #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(0, 0, 0)
90 // decl definitions for shared library compilation/usage:
91 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
92 # define QCP_LIB_DECL Q_DECL_EXPORT
93 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
94 # define QCP_LIB_DECL Q_DECL_IMPORT
100 The QCP Namespace contains general enums and QFlags used throughout the QCustomPlot library
105 Defines the sides of a rectangular entity to which margins can be applied.
107 \see QCPLayoutElement::setAutoMargins, QCPAxisRect::setAutoMargins
109 enum MarginSide
{ msLeft
= 0x01 ///< <tt>0x01</tt> left margin
110 ,msRight
= 0x02 ///< <tt>0x02</tt> right margin
111 ,msTop
= 0x04 ///< <tt>0x04</tt> top margin
112 ,msBottom
= 0x08 ///< <tt>0x08</tt> bottom margin
113 ,msAll
= 0xFF ///< <tt>0xFF</tt> all margins
114 ,msNone
= 0x00 ///< <tt>0x00</tt> no margin
116 Q_DECLARE_FLAGS(MarginSides
, MarginSide
)
119 Defines what objects of a plot can be forcibly drawn antialiased/not antialiased. If an object is
120 neither forcibly drawn antialiased nor forcibly drawn not antialiased, it is up to the respective
121 element how it is drawn. Typically it provides a \a setAntialiased function for this.
123 \c AntialiasedElements is a flag of or-combined elements of this enum type.
125 \see QCustomPlot::setAntialiasedElements, QCustomPlot::setNotAntialiasedElements
127 enum AntialiasedElement
{ aeAxes
= 0x0001 ///< <tt>0x0001</tt> Axis base line and tick marks
128 ,aeGrid
= 0x0002 ///< <tt>0x0002</tt> Grid lines
129 ,aeSubGrid
= 0x0004 ///< <tt>0x0004</tt> Sub grid lines
130 ,aeLegend
= 0x0008 ///< <tt>0x0008</tt> Legend box
131 ,aeLegendItems
= 0x0010 ///< <tt>0x0010</tt> Legend items
132 ,aePlottables
= 0x0020 ///< <tt>0x0020</tt> Main lines of plottables (excluding error bars, see element \ref aeErrorBars)
133 ,aeItems
= 0x0040 ///< <tt>0x0040</tt> Main lines of items
134 ,aeScatters
= 0x0080 ///< <tt>0x0080</tt> Scatter symbols of plottables (excluding scatter symbols of type ssPixmap)
135 ,aeErrorBars
= 0x0100 ///< <tt>0x0100</tt> Error bars
136 ,aeFills
= 0x0200 ///< <tt>0x0200</tt> Borders of fills (e.g. under or between graphs)
137 ,aeZeroLine
= 0x0400 ///< <tt>0x0400</tt> Zero-lines, see \ref QCPGrid::setZeroLinePen
138 ,aeAll
= 0xFFFF ///< <tt>0xFFFF</tt> All elements
139 ,aeNone
= 0x0000 ///< <tt>0x0000</tt> No elements
141 Q_DECLARE_FLAGS(AntialiasedElements
, AntialiasedElement
)
144 Defines plotting hints that control various aspects of the quality and speed of plotting.
146 \see QCustomPlot::setPlottingHints
148 enum PlottingHint
{ phNone
= 0x000 ///< <tt>0x000</tt> No hints are set
149 ,phFastPolylines
= 0x001 ///< <tt>0x001</tt> Graph/Curve lines are drawn with a faster method. This reduces the quality
150 ///< especially of the line segment joins. (Only relevant for solid line pens.)
151 ,phForceRepaint
= 0x002 ///< <tt>0x002</tt> causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called. This is set by default
152 ///< on Windows-Systems to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse).
153 ,phCacheLabels
= 0x004 ///< <tt>0x004</tt> axis (tick) labels will be cached as pixmaps, increasing replot performance.
155 Q_DECLARE_FLAGS(PlottingHints
, PlottingHint
)
158 Defines the mouse interactions possible with QCustomPlot.
160 \c Interactions is a flag of or-combined elements of this enum type.
162 \see QCustomPlot::setInteractions
164 enum Interaction
{ iRangeDrag
= 0x001 ///< <tt>0x001</tt> Axis ranges are draggable (see \ref QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeDragAxes)
165 ,iRangeZoom
= 0x002 ///< <tt>0x002</tt> Axis ranges are zoomable with the mouse wheel (see \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeZoomAxes)
166 ,iMultiSelect
= 0x004 ///< <tt>0x004</tt> The user can select multiple objects by holding the modifier set by \ref QCustomPlot::setMultiSelectModifier while clicking
167 ,iSelectPlottables
= 0x008 ///< <tt>0x008</tt> Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable)
168 ,iSelectAxes
= 0x010 ///< <tt>0x010</tt> Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
169 ,iSelectLegend
= 0x020 ///< <tt>0x020</tt> Legends are selectable (or their child items, see QCPLegend::setSelectableParts)
170 ,iSelectItems
= 0x040 ///< <tt>0x040</tt> Items are selectable (Rectangles, Arrows, Textitems, etc. see \ref QCPAbstractItem)
171 ,iSelectOther
= 0x080 ///< <tt>0x080</tt> All other objects are selectable (e.g. your own derived layerables, the plot title,...)
173 Q_DECLARE_FLAGS(Interactions
, Interaction
)
177 Returns whether the specified \a value is considered an invalid data value for plottables (i.e.
178 is \e nan or \e +/-inf). This function is used to check data validity upon replots, when the
179 compiler flag \c QCUSTOMPLOT_CHECK_DATA is set.
181 inline bool isInvalidData(double value
)
183 return (!qIsNaN(value
) && !qIsInf(value
));
189 Checks two arguments instead of one.
191 inline bool isInvalidData(double value1
, double value2
)
193 return isInvalidData(value1
) || isInvalidData(value2
);
198 Sets the specified \a side of \a margins to \a value
202 inline void setMarginValue(QMargins
&margins
, QCP::MarginSide side
, int value
)
206 case QCP::msLeft
: margins
.setLeft(value
); break;
207 case QCP::msRight
: margins
.setRight(value
); break;
208 case QCP::msTop
: margins
.setTop(value
); break;
209 case QCP::msBottom
: margins
.setBottom(value
); break;
210 case QCP::msAll
: margins
= QMargins(value
, value
, value
, value
); break;
217 Returns the value of the specified \a side of \a margins. If \a side is \ref QCP::msNone or
218 \ref QCP::msAll, returns 0.
222 inline int getMarginValue(const QMargins
&margins
, QCP::MarginSide side
)
226 case QCP::msLeft
: return margins
.left();
227 case QCP::msRight
: return margins
.right();
228 case QCP::msTop
: return margins
.top();
229 case QCP::msBottom
: return margins
.bottom();
235 } // end of namespace QCP
237 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements
)
238 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints
)
239 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides
)
240 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions
)
243 class QCP_LIB_DECL QCPScatterStyle
248 Defines the shape used for scatter points.
250 On plottables/items that draw scatters, the sizes of these visualizations (with exception of
251 \ref ssDot and \ref ssPixmap) can be controlled with the \ref setSize function. Scatters are
252 drawn with the pen and brush specified with \ref setPen and \ref setBrush.
254 Q_ENUMS(ScatterShape
)
255 enum ScatterShape
{ ssNone
///< no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines)
256 ,ssDot
///< \enumimage{ssDot.png} a single pixel (use \ref ssDisc or \ref ssCircle if you want a round shape with a certain radius)
257 ,ssCross
///< \enumimage{ssCross.png} a cross
258 ,ssPlus
///< \enumimage{ssPlus.png} a plus
259 ,ssCircle
///< \enumimage{ssCircle.png} a circle
260 ,ssDisc
///< \enumimage{ssDisc.png} a circle which is filled with the pen (not the brush as with ssCircle)
261 ,ssSquare
///< \enumimage{ssSquare.png} a square
262 ,ssDiamond
///< \enumimage{ssDiamond.png} a diamond
263 ,ssStar
///< \enumimage{ssStar.png} a star with eight arms, i.e. a combination of cross and plus
264 ,ssTriangle
///< \enumimage{ssTriangle.png} an equilateral triangle, standing on baseline
265 ,ssTriangleInverted
///< \enumimage{ssTriangleInverted.png} an equilateral triangle, standing on corner
266 ,ssCrossSquare
///< \enumimage{ssCrossSquare.png} a square with a cross inside
267 ,ssPlusSquare
///< \enumimage{ssPlusSquare.png} a square with a plus inside
268 ,ssCrossCircle
///< \enumimage{ssCrossCircle.png} a circle with a cross inside
269 ,ssPlusCircle
///< \enumimage{ssPlusCircle.png} a circle with a plus inside
270 ,ssPeace
///< \enumimage{ssPeace.png} a circle, with one vertical and two downward diagonal lines
271 ,ssPixmap
///< a custom pixmap specified by setScatterPixmap, centered on the data point coordinates
272 ,ssCustom
///< custom painter operations are performed per scatter (As QPainterPath, see \ref setCustomPath)
276 QCPScatterStyle(ScatterShape shape
, double size
=6);
277 QCPScatterStyle(ScatterShape shape
, const QColor
&color
, double size
);
278 QCPScatterStyle(ScatterShape shape
, const QColor
&color
, const QColor
&fill
, double size
);
279 QCPScatterStyle(ScatterShape shape
, const QPen
&pen
, const QBrush
&brush
, double size
);
280 QCPScatterStyle(const QPixmap
&pixmap
);
281 QCPScatterStyle(const QPainterPath
&customPath
, const QPen
&pen
, const QBrush
&brush
=Qt::NoBrush
, double size
=6);
284 double size() const { return mSize
; }
285 ScatterShape
shape() const { return mShape
; }
286 QPen
pen() const { return mPen
; }
287 QBrush
brush() const { return mBrush
; }
288 QPixmap
pixmap() const { return mPixmap
; }
289 QPainterPath
customPath() const { return mCustomPath
; }
292 void setSize(double size
);
293 void setShape(ScatterShape shape
);
294 void setPen(const QPen
&pen
);
295 void setBrush(const QBrush
&brush
);
296 void setPixmap(const QPixmap
&pixmap
);
297 void setCustomPath(const QPainterPath
&customPath
);
299 // non-property methods:
300 bool isNone() const { return mShape
== ssNone
; }
301 bool isPenDefined() const { return mPenDefined
; }
302 void applyTo(QCPPainter
*painter
, const QPen
&defaultPen
) const;
303 void drawShape(QCPPainter
*painter
, QPointF pos
) const;
304 void drawShape(QCPPainter
*painter
, double x
, double y
) const;
313 QPainterPath mCustomPath
;
315 // non-property members:
318 Q_DECLARE_TYPEINFO(QCPScatterStyle
, Q_MOVABLE_TYPE
);
321 class QCP_LIB_DECL QCPPainter
: public QPainter
326 Defines special modes the painter can operate in. They disable or enable certain subsets of features/fixes/workarounds,
327 depending on whether they are wanted on the respective output device.
329 enum PainterMode
{pmDefault
= 0x00 ///< <tt>0x00</tt> Default mode for painting on screen devices
330 ,pmVectorized
= 0x01 ///< <tt>0x01</tt> Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fixes.
331 ,pmNoCaching
= 0x02 ///< <tt>0x02</tt> Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixmap labels
332 ,pmNonCosmetic
= 0x04 ///< <tt>0x04</tt> Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.)
334 Q_FLAGS(PainterMode PainterModes
)
335 Q_DECLARE_FLAGS(PainterModes
, PainterMode
)
338 QCPPainter(QPaintDevice
*device
);
342 bool antialiasing() const { return testRenderHint(QPainter::Antialiasing
); }
343 PainterModes
modes() const { return mModes
; }
346 void setAntialiasing(bool enabled
);
347 void setMode(PainterMode mode
, bool enabled
=true);
348 void setModes(PainterModes modes
);
350 // methods hiding non-virtual base class functions (QPainter bug workarounds):
351 bool begin(QPaintDevice
*device
);
352 void setPen(const QPen
&pen
);
353 void setPen(const QColor
&color
);
354 void setPen(Qt::PenStyle penStyle
);
355 void drawLine(const QLineF
&line
);
356 void drawLine(const QPointF
&p1
, const QPointF
&p2
) {drawLine(QLineF(p1
, p2
));}
360 // non-virtual methods:
361 void makeNonCosmetic();
366 bool mIsAntialiasing
;
368 // non-property members:
369 QStack
<bool> mAntialiasingStack
;
371 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes
)
374 class QCP_LIB_DECL QCPLayer
: public QObject
377 /// \cond INCLUDE_QPROPERTIES
378 Q_PROPERTY(QCustomPlot
* parentPlot READ parentPlot
)
379 Q_PROPERTY(QString name READ name
)
380 Q_PROPERTY(int index READ index
)
381 Q_PROPERTY(QList
<QCPLayerable
*> children READ children
)
384 QCPLayer(QCustomPlot
* parentPlot
, const QString
&layerName
);
388 QCustomPlot
*parentPlot() const { return mParentPlot
; }
389 QString
name() const { return mName
; }
390 int index() const { return mIndex
; }
391 QList
<QCPLayerable
*> children() const { return mChildren
; }
395 QCustomPlot
*mParentPlot
;
398 QList
<QCPLayerable
*> mChildren
;
400 // non-virtual methods:
401 void addChild(QCPLayerable
*layerable
, bool prepend
);
402 void removeChild(QCPLayerable
*layerable
);
405 Q_DISABLE_COPY(QCPLayer
)
407 friend class QCustomPlot
;
408 friend class QCPLayerable
;
411 class QCP_LIB_DECL QCPLayerable
: public QObject
414 /// \cond INCLUDE_QPROPERTIES
415 Q_PROPERTY(bool visible READ visible WRITE setVisible
)
416 Q_PROPERTY(QCustomPlot
* parentPlot READ parentPlot
)
417 Q_PROPERTY(QCPLayerable
* parentLayerable READ parentLayerable
)
418 Q_PROPERTY(QCPLayer
* layer READ layer WRITE setLayer
)
419 Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased
)
422 QCPLayerable(QCustomPlot
*plot
, QString targetLayer
="", QCPLayerable
*parentLayerable
=0);
426 bool visible() const { return mVisible
; }
427 QCustomPlot
*parentPlot() const { return mParentPlot
; }
428 QCPLayerable
*parentLayerable() const { return mParentLayerable
.data(); }
429 QCPLayer
*layer() const { return mLayer
; }
430 bool antialiased() const { return mAntialiased
; }
433 void setVisible(bool on
);
434 bool setLayer(QCPLayer
*layer
);
435 bool setLayer(const QString
&layerName
);
436 void setAntialiased(bool enabled
);
438 // introduced virtual methods:
439 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
441 // non-property methods:
442 bool realVisibility() const;
447 QCustomPlot
*mParentPlot
;
448 QWeakPointer
<QCPLayerable
> mParentLayerable
;
452 // introduced virtual methods:
453 virtual void parentPlotInitialized(QCustomPlot
*parentPlot
);
454 virtual QCP::Interaction
selectionCategory() const;
455 virtual QRect
clipRect() const;
456 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const = 0;
457 virtual void draw(QCPPainter
*painter
) = 0;
459 virtual void selectEvent(QMouseEvent
*event
, bool additive
, const QVariant
&details
, bool *selectionStateChanged
);
460 virtual void deselectEvent(bool *selectionStateChanged
);
462 // non-property methods:
463 void initializeParentPlot(QCustomPlot
*parentPlot
);
464 void setParentLayerable(QCPLayerable
* parentLayerable
);
465 bool moveToLayer(QCPLayer
*layer
, bool prepend
);
466 void applyAntialiasingHint(QCPPainter
*painter
, bool localAntialiased
, QCP::AntialiasedElement overrideElement
) const;
469 Q_DISABLE_COPY(QCPLayerable
)
471 friend class QCustomPlot
;
472 friend class QCPAxisRect
;
476 class QCP_LIB_DECL QCPRange
482 QCPRange(double lower
, double upper
);
485 double center() const;
487 QCPRange
sanitizedForLogScale() const;
488 QCPRange
sanitizedForLinScale() const;
489 bool contains(double value
) const;
491 static bool validRange(double lower
, double upper
);
492 static bool validRange(const QCPRange
&range
);
493 static const double minRange
; //1e-280;
494 static const double maxRange
; //1e280;
496 Q_DECLARE_TYPEINFO(QCPRange
, Q_MOVABLE_TYPE
);
499 class QCP_LIB_DECL QCPMarginGroup
: public QObject
503 QCPMarginGroup(QCustomPlot
*parentPlot
);
506 // non-virtual methods:
507 QList
<QCPLayoutElement
*> elements(QCP::MarginSide side
) const { return mChildren
.value(side
); }
508 bool isEmpty() const;
512 // non-property members:
513 QCustomPlot
*mParentPlot
;
514 QHash
<QCP::MarginSide
, QList
<QCPLayoutElement
*> > mChildren
;
516 // non-virtual methods:
517 int commonMargin(QCP::MarginSide side
) const;
518 void addChild(QCP::MarginSide side
, QCPLayoutElement
*element
);
519 void removeChild(QCP::MarginSide side
, QCPLayoutElement
*element
);
522 Q_DISABLE_COPY(QCPMarginGroup
)
524 friend class QCPLayoutElement
;
528 class QCP_LIB_DECL QCPLayoutElement
: public QCPLayerable
531 /// \cond INCLUDE_QPROPERTIES
532 Q_PROPERTY(QCPLayout
* layout READ layout
)
533 Q_PROPERTY(QRect rect READ rect
)
534 Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect
)
535 Q_PROPERTY(QMargins margins READ margins WRITE setMargins
)
536 Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins
)
537 Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize
)
538 Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize
)
541 explicit QCPLayoutElement(QCustomPlot
*parentPlot
=0);
542 virtual ~QCPLayoutElement();
545 QCPLayout
*layout() const { return mParentLayout
; }
546 QRect
rect() const { return mRect
; }
547 QRect
outerRect() const { return mOuterRect
; }
548 QMargins
margins() const { return mMargins
; }
549 QMargins
minimumMargins() const { return mMinimumMargins
; }
550 QCP::MarginSides
autoMargins() const { return mAutoMargins
; }
551 QSize
minimumSize() const { return mMinimumSize
; }
552 QSize
maximumSize() const { return mMaximumSize
; }
553 QCPMarginGroup
*marginGroup(QCP::MarginSide side
) const { return mMarginGroups
.value(side
, (QCPMarginGroup
*)0); }
554 QHash
<QCP::MarginSide
, QCPMarginGroup
*> marginGroups() const { return mMarginGroups
; }
557 void setOuterRect(const QRect
&rect
);
558 void setMargins(const QMargins
&margins
);
559 void setMinimumMargins(const QMargins
&margins
);
560 void setAutoMargins(QCP::MarginSides sides
);
561 void setMinimumSize(const QSize
&size
);
562 void setMinimumSize(int width
, int height
);
563 void setMaximumSize(const QSize
&size
);
564 void setMaximumSize(int width
, int height
);
565 void setMarginGroup(QCP::MarginSides sides
, QCPMarginGroup
*group
);
567 // introduced virtual methods:
568 virtual void update();
569 virtual QSize
minimumSizeHint() const;
570 virtual QSize
maximumSizeHint() const;
571 virtual QList
<QCPLayoutElement
*> elements(bool recursive
) const;
573 // reimplemented virtual methods:
574 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
578 QCPLayout
*mParentLayout
;
579 QSize mMinimumSize
, mMaximumSize
;
580 QRect mRect
, mOuterRect
;
581 QMargins mMargins
, mMinimumMargins
;
582 QCP::MarginSides mAutoMargins
;
583 QHash
<QCP::MarginSide
, QCPMarginGroup
*> mMarginGroups
;
585 // introduced virtual methods:
586 virtual int calculateAutoMargin(QCP::MarginSide side
);
588 virtual void mousePressEvent(QMouseEvent
*event
) {Q_UNUSED(event
)}
589 virtual void mouseMoveEvent(QMouseEvent
*event
) {Q_UNUSED(event
)}
590 virtual void mouseReleaseEvent(QMouseEvent
*event
) {Q_UNUSED(event
)}
591 virtual void mouseDoubleClickEvent(QMouseEvent
*event
) {Q_UNUSED(event
)}
592 virtual void wheelEvent(QWheelEvent
*event
) {Q_UNUSED(event
)}
594 // reimplemented virtual methods:
595 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const { Q_UNUSED(painter
) }
596 virtual void draw(QCPPainter
*painter
) { Q_UNUSED(painter
) }
597 virtual void parentPlotInitialized(QCustomPlot
*parentPlot
);
600 Q_DISABLE_COPY(QCPLayoutElement
)
602 friend class QCustomPlot
;
603 friend class QCPLayout
;
604 friend class QCPMarginGroup
;
608 class QCP_LIB_DECL QCPLayout
: public QCPLayoutElement
612 explicit QCPLayout();
614 // reimplemented virtual methods:
615 virtual void update();
616 virtual QList
<QCPLayoutElement
*> elements(bool recursive
) const;
618 // introduced virtual methods:
619 virtual int elementCount() const = 0;
620 virtual QCPLayoutElement
* elementAt(int index
) const = 0;
621 virtual QCPLayoutElement
* takeAt(int index
) = 0;
622 virtual bool take(QCPLayoutElement
* element
) = 0;
623 virtual void simplify();
625 // non-virtual methods:
626 bool removeAt(int index
);
627 bool remove(QCPLayoutElement
* element
);
631 // introduced virtual methods:
632 virtual void updateLayout();
634 // non-virtual methods:
635 void sizeConstraintsChanged() const;
636 void adoptElement(QCPLayoutElement
*el
);
637 void releaseElement(QCPLayoutElement
*el
);
638 QVector
<int> getSectionSizes(QVector
<int> maxSizes
, QVector
<int> minSizes
, QVector
<double> stretchFactors
, int totalSize
) const;
641 Q_DISABLE_COPY(QCPLayout
)
642 friend class QCPLayoutElement
;
646 class QCP_LIB_DECL QCPLayoutGrid
: public QCPLayout
649 /// \cond INCLUDE_QPROPERTIES
650 Q_PROPERTY(int rowCount READ rowCount
)
651 Q_PROPERTY(int columnCount READ columnCount
)
652 Q_PROPERTY(QList
<double> columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors
)
653 Q_PROPERTY(QList
<double> rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors
)
654 Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing
)
655 Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing
)
658 explicit QCPLayoutGrid();
659 virtual ~QCPLayoutGrid();
662 int rowCount() const;
663 int columnCount() const;
664 QList
<double> columnStretchFactors() const { return mColumnStretchFactors
; }
665 QList
<double> rowStretchFactors() const { return mRowStretchFactors
; }
666 int columnSpacing() const { return mColumnSpacing
; }
667 int rowSpacing() const { return mRowSpacing
; }
670 void setColumnStretchFactor(int column
, double factor
);
671 void setColumnStretchFactors(const QList
<double> &factors
);
672 void setRowStretchFactor(int row
, double factor
);
673 void setRowStretchFactors(const QList
<double> &factors
);
674 void setColumnSpacing(int pixels
);
675 void setRowSpacing(int pixels
);
677 // reimplemented virtual methods:
678 virtual void updateLayout();
679 virtual int elementCount() const;
680 virtual QCPLayoutElement
* elementAt(int index
) const;
681 virtual QCPLayoutElement
* takeAt(int index
);
682 virtual bool take(QCPLayoutElement
* element
);
683 virtual QList
<QCPLayoutElement
*> elements(bool recursive
) const;
684 virtual void simplify();
685 virtual QSize
minimumSizeHint() const;
686 virtual QSize
maximumSizeHint() const;
688 // non-virtual methods:
689 QCPLayoutElement
*element(int row
, int column
) const;
690 bool addElement(int row
, int column
, QCPLayoutElement
*element
);
691 bool hasElement(int row
, int column
);
692 void expandTo(int newRowCount
, int newColumnCount
);
693 void insertRow(int newIndex
);
694 void insertColumn(int newIndex
);
698 QList
<QList
<QCPLayoutElement
*> > mElements
;
699 QList
<double> mColumnStretchFactors
;
700 QList
<double> mRowStretchFactors
;
701 int mColumnSpacing
, mRowSpacing
;
703 // non-virtual methods:
704 void getMinimumRowColSizes(QVector
<int> *minColWidths
, QVector
<int> *minRowHeights
) const;
705 void getMaximumRowColSizes(QVector
<int> *maxColWidths
, QVector
<int> *maxRowHeights
) const;
708 Q_DISABLE_COPY(QCPLayoutGrid
)
712 class QCP_LIB_DECL QCPLayoutInset
: public QCPLayout
717 Defines how the placement and sizing is handled for a certain element in a QCPLayoutInset.
719 enum InsetPlacement
{ipFree
///< The element may be positioned/sized arbitrarily, see \ref setInsetRect
720 ,ipBorderAligned
///< The element is aligned to one of the layout sides, see \ref setInsetAlignment
723 explicit QCPLayoutInset();
724 virtual ~QCPLayoutInset();
727 InsetPlacement
insetPlacement(int index
) const;
728 Qt::Alignment
insetAlignment(int index
) const;
729 QRectF
insetRect(int index
) const;
732 void setInsetPlacement(int index
, InsetPlacement placement
);
733 void setInsetAlignment(int index
, Qt::Alignment alignment
);
734 void setInsetRect(int index
, const QRectF
&rect
);
736 // reimplemented virtual methods:
737 virtual void updateLayout();
738 virtual int elementCount() const;
739 virtual QCPLayoutElement
* elementAt(int index
) const;
740 virtual QCPLayoutElement
* takeAt(int index
);
741 virtual bool take(QCPLayoutElement
* element
);
742 virtual void simplify() {}
743 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
745 // non-virtual methods:
746 void addElement(QCPLayoutElement
*element
, Qt::Alignment alignment
);
747 void addElement(QCPLayoutElement
*element
, const QRectF
&rect
);
751 QList
<QCPLayoutElement
*> mElements
;
752 QList
<InsetPlacement
> mInsetPlacement
;
753 QList
<Qt::Alignment
> mInsetAlignment
;
754 QList
<QRectF
> mInsetRect
;
757 Q_DISABLE_COPY(QCPLayoutInset
)
761 class QCP_LIB_DECL QCPLineEnding
766 Defines the type of ending decoration for line-like items, e.g. an arrow.
768 \image html QCPLineEnding.png
770 The width and length of these decorations can be controlled with the functions \ref setWidth
771 and \ref setLength. Some decorations like \ref esDisc, \ref esSquare, \ref esDiamond and \ref esBar only
772 support a width, the length property is ignored.
774 \see QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail
777 enum EndingStyle
{ esNone
///< No ending decoration
778 ,esFlatArrow
///< A filled arrow head with a straight/flat back (a triangle)
779 ,esSpikeArrow
///< A filled arrow head with an indented back
780 ,esLineArrow
///< A non-filled arrow head with open back
781 ,esDisc
///< A filled circle
782 ,esSquare
///< A filled square
783 ,esDiamond
///< A filled diamond (45° rotated square)
784 ,esBar
///< A bar perpendicular to the line
785 ,esHalfBar
///< A bar perpendicular to the line sticking out to one side
786 ,esSkewedBar
///< A bar that is skewed (skew controllable via \ref setLength)
790 QCPLineEnding(EndingStyle style
, double width
=8, double length
=10, bool inverted
=false);
793 EndingStyle
style() const { return mStyle
; }
794 double width() const { return mWidth
; }
795 double length() const { return mLength
; }
796 bool inverted() const { return mInverted
; }
799 void setStyle(EndingStyle style
);
800 void setWidth(double width
);
801 void setLength(double length
);
802 void setInverted(bool inverted
);
804 // non-property methods:
805 double boundingDistance() const;
806 double realLength() const;
807 void draw(QCPPainter
*painter
, const QVector2D
&pos
, const QVector2D
&dir
) const;
808 void draw(QCPPainter
*painter
, const QVector2D
&pos
, double angle
) const;
813 double mWidth
, mLength
;
816 Q_DECLARE_TYPEINFO(QCPLineEnding
, Q_MOVABLE_TYPE
);
819 class QCP_LIB_DECL QCPGrid
:public QCPLayerable
822 /// \cond INCLUDE_QPROPERTIES
823 Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible
)
824 Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid
)
825 Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine
)
826 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
827 Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen
)
828 Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen
)
831 QCPGrid(QCPAxis
*parentAxis
);
834 bool subGridVisible() const { return mSubGridVisible
; }
835 bool antialiasedSubGrid() const { return mAntialiasedSubGrid
; }
836 bool antialiasedZeroLine() const { return mAntialiasedZeroLine
; }
837 QPen
pen() const { return mPen
; }
838 QPen
subGridPen() const { return mSubGridPen
; }
839 QPen
zeroLinePen() const { return mZeroLinePen
; }
842 void setSubGridVisible(bool visible
);
843 void setAntialiasedSubGrid(bool enabled
);
844 void setAntialiasedZeroLine(bool enabled
);
845 void setPen(const QPen
&pen
);
846 void setSubGridPen(const QPen
&pen
);
847 void setZeroLinePen(const QPen
&pen
);
851 bool mSubGridVisible
;
852 bool mAntialiasedSubGrid
, mAntialiasedZeroLine
;
853 QPen mPen
, mSubGridPen
, mZeroLinePen
;
854 // non-property members:
855 QCPAxis
*mParentAxis
;
857 // reimplemented virtual methods:
858 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const;
859 virtual void draw(QCPPainter
*painter
);
861 // non-virtual methods:
862 void drawGridLines(QCPPainter
*painter
) const;
863 void drawSubGridLines(QCPPainter
*painter
) const;
865 friend class QCPAxis
;
869 class QCP_LIB_DECL QCPAxis
: public QCPLayerable
872 /// \cond INCLUDE_QPROPERTIES
873 Q_PROPERTY(AxisType axisType READ axisType
)
874 Q_PROPERTY(QCPAxisRect
* axisRect READ axisRect
)
875 Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType
)
876 Q_PROPERTY(double scaleLogBase READ scaleLogBase WRITE setScaleLogBase
)
877 Q_PROPERTY(QCPRange range READ range WRITE setRange
)
878 Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed
)
879 Q_PROPERTY(bool autoTicks READ autoTicks WRITE setAutoTicks
)
880 Q_PROPERTY(int autoTickCount READ autoTickCount WRITE setAutoTickCount
)
881 Q_PROPERTY(bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels
)
882 Q_PROPERTY(bool autoTickStep READ autoTickStep WRITE setAutoTickStep
)
883 Q_PROPERTY(bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks
)
884 Q_PROPERTY(bool ticks READ ticks WRITE setTicks
)
885 Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels
)
886 Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding
)
887 Q_PROPERTY(LabelType tickLabelType READ tickLabelType WRITE setTickLabelType
)
888 Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont
)
889 Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor
)
890 Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation
)
891 Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat
)
892 Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat
)
893 Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision
)
894 Q_PROPERTY(double tickStep READ tickStep WRITE setTickStep
)
895 Q_PROPERTY(QVector
<double> tickVector READ tickVector WRITE setTickVector
)
896 Q_PROPERTY(QVector
<QString
> tickVectorLabels READ tickVectorLabels WRITE setTickVectorLabels
)
897 Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn
)
898 Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut
)
899 Q_PROPERTY(int subTickCount READ subTickCount WRITE setSubTickCount
)
900 Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn
)
901 Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut
)
902 Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen
)
903 Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen
)
904 Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen
)
905 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont
)
906 Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor
)
907 Q_PROPERTY(QString label READ label WRITE setLabel
)
908 Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding
)
909 Q_PROPERTY(int padding READ padding WRITE setPadding
)
910 Q_PROPERTY(int offset READ offset WRITE setOffset
)
911 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts
)
912 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts
)
913 Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont
)
914 Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont
)
915 Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor
)
916 Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor
)
917 Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen
)
918 Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen
)
919 Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen
)
920 Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding
)
921 Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding
)
922 Q_PROPERTY(QCPGrid
* grid READ grid
)
926 Defines at which side of the axis rect the axis will appear. This also affects how the tick
927 marks are drawn, on which side the labels are placed etc.
929 enum AxisType
{ atLeft
= 0x01 ///< <tt>0x01</tt> Axis is vertical and on the left side of the axis rect
930 ,atRight
= 0x02 ///< <tt>0x02</tt> Axis is vertical and on the right side of the axis rect
931 ,atTop
= 0x04 ///< <tt>0x04</tt> Axis is horizontal and on the top side of the axis rect
932 ,atBottom
= 0x08 ///< <tt>0x08</tt> Axis is horizontal and on the bottom side of the axis rect
934 Q_FLAGS(AxisType AxisTypes
)
935 Q_DECLARE_FLAGS(AxisTypes
, AxisType
)
937 When automatic tick label generation is enabled (\ref setAutoTickLabels), defines how the
938 coordinate of the tick is interpreted, i.e. translated into a string.
940 \see setTickLabelType
942 enum LabelType
{ ltNumber
///< Tick coordinate is regarded as normal number and will be displayed as such. (see \ref setNumberFormat)
943 ,ltDateTime
///< Tick coordinate is regarded as a date/time (seconds since 1970-01-01T00:00:00 UTC) and will be displayed and formatted as such. (for details, see \ref setDateTimeFormat)
947 Defines the scale of an axis.
950 enum ScaleType
{ stLinear
///< Linear scaling
951 ,stLogarithmic
///< Logarithmic scaling with correspondingly transformed plots and (major) tick marks at every base power (see \ref setScaleLogBase).
955 Defines the selectable parts of an axis.
956 \see setSelectableParts, setSelectedParts
958 enum SelectablePart
{ spNone
= 0 ///< None of the selectable parts
959 ,spAxis
= 0x001 ///< The axis backbone and tick marks
960 ,spTickLabels
= 0x002 ///< Tick labels (numbers) of this axis (as a whole, not individually)
961 ,spAxisLabel
= 0x004 ///< The axis label
963 Q_FLAGS(SelectablePart SelectableParts
)
964 Q_DECLARE_FLAGS(SelectableParts
, SelectablePart
)
966 explicit QCPAxis(QCPAxisRect
*parent
, AxisType type
);
969 AxisType
axisType() const { return mAxisType
; }
970 QCPAxisRect
*axisRect() const { return mAxisRect
; }
971 ScaleType
scaleType() const { return mScaleType
; }
972 double scaleLogBase() const { return mScaleLogBase
; }
973 const QCPRange
range() const { return mRange
; }
974 bool rangeReversed() const { return mRangeReversed
; }
975 bool autoTicks() const { return mAutoTicks
; }
976 int autoTickCount() const { return mAutoTickCount
; }
977 bool autoTickLabels() const { return mAutoTickLabels
; }
978 bool autoTickStep() const { return mAutoTickStep
; }
979 bool autoSubTicks() const { return mAutoSubTicks
; }
980 bool ticks() const { return mTicks
; }
981 bool tickLabels() const { return mTickLabels
; }
982 int tickLabelPadding() const { return mTickLabelPadding
; }
983 LabelType
tickLabelType() const { return mTickLabelType
; }
984 QFont
tickLabelFont() const { return mTickLabelFont
; }
985 QColor
tickLabelColor() const { return mTickLabelColor
; }
986 double tickLabelRotation() const { return mTickLabelRotation
; }
987 QString
dateTimeFormat() const { return mDateTimeFormat
; }
988 QString
numberFormat() const;
989 int numberPrecision() const { return mNumberPrecision
; }
990 double tickStep() const { return mTickStep
; }
991 QVector
<double> tickVector() const { return mTickVector
; }
992 QVector
<QString
> tickVectorLabels() const { return mTickVectorLabels
; }
993 int tickLengthIn() const { return mTickLengthIn
; }
994 int tickLengthOut() const { return mTickLengthOut
; }
995 int subTickCount() const { return mSubTickCount
; }
996 int subTickLengthIn() const { return mSubTickLengthIn
; }
997 int subTickLengthOut() const { return mSubTickLengthOut
; }
998 QPen
basePen() const { return mBasePen
; }
999 QPen
tickPen() const { return mTickPen
; }
1000 QPen
subTickPen() const { return mSubTickPen
; }
1001 QFont
labelFont() const { return mLabelFont
; }
1002 QColor
labelColor() const { return mLabelColor
; }
1003 QString
label() const { return mLabel
; }
1004 int labelPadding() const { return mLabelPadding
; }
1005 int padding() const { return mPadding
; }
1006 int offset() const { return mOffset
; }
1007 SelectableParts
selectedParts() const { return mSelectedParts
; }
1008 SelectableParts
selectableParts() const { return mSelectableParts
; }
1009 QFont
selectedTickLabelFont() const { return mSelectedTickLabelFont
; }
1010 QFont
selectedLabelFont() const { return mSelectedLabelFont
; }
1011 QColor
selectedTickLabelColor() const { return mSelectedTickLabelColor
; }
1012 QColor
selectedLabelColor() const { return mSelectedLabelColor
; }
1013 QPen
selectedBasePen() const { return mSelectedBasePen
; }
1014 QPen
selectedTickPen() const { return mSelectedTickPen
; }
1015 QPen
selectedSubTickPen() const { return mSelectedSubTickPen
; }
1016 QCPLineEnding
lowerEnding() const { return mLowerEnding
; }
1017 QCPLineEnding
upperEnding() const { return mUpperEnding
; }
1018 QCPGrid
*grid() const { return mGrid
; }
1021 void setScaleType(ScaleType type
);
1022 void setScaleLogBase(double base
);
1023 Q_SLOT
void setRange(const QCPRange
&range
);
1024 void setRange(double lower
, double upper
);
1025 void setRange(double position
, double size
, Qt::AlignmentFlag alignment
);
1026 void setRangeLower(double lower
);
1027 void setRangeUpper(double upper
);
1028 void setRangeReversed(bool reversed
);
1029 void setAutoTicks(bool on
);
1030 void setAutoTickCount(int approximateCount
);
1031 void setAutoTickLabels(bool on
);
1032 void setAutoTickStep(bool on
);
1033 void setAutoSubTicks(bool on
);
1034 void setTicks(bool show
);
1035 void setTickLabels(bool show
);
1036 void setTickLabelPadding(int padding
);
1037 void setTickLabelType(LabelType type
);
1038 void setTickLabelFont(const QFont
&font
);
1039 void setTickLabelColor(const QColor
&color
);
1040 void setTickLabelRotation(double degrees
);
1041 void setDateTimeFormat(const QString
&format
);
1042 void setNumberFormat(const QString
&formatCode
);
1043 void setNumberPrecision(int precision
);
1044 void setTickStep(double step
);
1045 void setTickVector(const QVector
<double> &vec
);
1046 void setTickVectorLabels(const QVector
<QString
> &vec
);
1047 void setTickLength(int inside
, int outside
=0);
1048 void setTickLengthIn(int inside
);
1049 void setTickLengthOut(int outside
);
1050 void setSubTickCount(int count
);
1051 void setSubTickLength(int inside
, int outside
=0);
1052 void setSubTickLengthIn(int inside
);
1053 void setSubTickLengthOut(int outside
);
1054 void setBasePen(const QPen
&pen
);
1055 void setTickPen(const QPen
&pen
);
1056 void setSubTickPen(const QPen
&pen
);
1057 void setLabelFont(const QFont
&font
);
1058 void setLabelColor(const QColor
&color
);
1059 void setLabel(const QString
&str
);
1060 void setLabelPadding(int padding
);
1061 void setPadding(int padding
);
1062 void setOffset(int offset
);
1063 void setSelectedTickLabelFont(const QFont
&font
);
1064 void setSelectedLabelFont(const QFont
&font
);
1065 void setSelectedTickLabelColor(const QColor
&color
);
1066 void setSelectedLabelColor(const QColor
&color
);
1067 void setSelectedBasePen(const QPen
&pen
);
1068 void setSelectedTickPen(const QPen
&pen
);
1069 void setSelectedSubTickPen(const QPen
&pen
);
1070 Q_SLOT
void setSelectableParts(const QCPAxis::SelectableParts
&selectableParts
);
1071 Q_SLOT
void setSelectedParts(const QCPAxis::SelectableParts
&selectedParts
);
1072 void setLowerEnding(const QCPLineEnding
&ending
);
1073 void setUpperEnding(const QCPLineEnding
&ending
);
1075 // reimplemented virtual methods:
1076 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
1078 // non-virtual methods:
1079 Qt::Orientation
orientation() const { return mOrientation
; }
1080 void moveRange(double diff
);
1081 void scaleRange(double factor
, double center
);
1082 void setScaleRatio(const QCPAxis
*otherAxis
, double ratio
=1.0);
1083 double pixelToCoord(double value
) const;
1084 double coordToPixel(double value
) const;
1085 SelectablePart
getPartAt(const QPointF
&pos
) const;
1086 QList
<QCPAbstractPlottable
*> plottables() const;
1087 QList
<QCPGraph
*> graphs() const;
1088 QList
<QCPAbstractItem
*> items() const;
1090 static AxisType
marginSideToAxisType(QCP::MarginSide side
);
1093 void ticksRequest();
1094 void rangeChanged(const QCPRange
&newRange
);
1095 void selectionChanged(const QCPAxis::SelectableParts
&parts
);
1103 struct TickLabelData
1105 QString basePart
, expPart
;
1106 QRect baseBounds
, expBounds
, totalBounds
, rotatedTotalBounds
;
1107 QFont baseFont
, expFont
;
1110 // property members:
1113 QCPAxisRect
*mAxisRect
;
1114 int mOffset
, mPadding
;
1115 Qt::Orientation mOrientation
;
1116 SelectableParts mSelectableParts
, mSelectedParts
;
1117 QPen mBasePen
, mSelectedBasePen
;
1118 QCPLineEnding mLowerEnding
, mUpperEnding
;
1122 QFont mLabelFont
, mSelectedLabelFont
;
1123 QColor mLabelColor
, mSelectedLabelColor
;
1125 int mTickLabelPadding
;
1126 bool mTickLabels
, mAutoTickLabels
;
1127 double mTickLabelRotation
;
1128 LabelType mTickLabelType
;
1129 QFont mTickLabelFont
, mSelectedTickLabelFont
;
1130 QColor mTickLabelColor
, mSelectedTickLabelColor
;
1131 QString mDateTimeFormat
;
1132 int mNumberPrecision
;
1133 char mNumberFormatChar
;
1134 bool mNumberBeautifulPowers
;
1135 bool mNumberMultiplyCross
;
1136 // ticks and subticks:
1139 int mSubTickCount
, mAutoTickCount
;
1140 bool mAutoTicks
, mAutoTickStep
, mAutoSubTicks
;
1141 int mTickLengthIn
, mTickLengthOut
, mSubTickLengthIn
, mSubTickLengthOut
;
1142 QPen mTickPen
, mSelectedTickPen
;
1143 QPen mSubTickPen
, mSelectedSubTickPen
;
1146 bool mRangeReversed
;
1147 ScaleType mScaleType
;
1148 double mScaleLogBase
, mScaleLogBaseLogInv
;
1150 // non-property members:
1152 QCache
<QString
, CachedLabel
> mLabelCache
;
1153 int mLowestVisibleTick
, mHighestVisibleTick
;
1154 QChar mExponentialChar
, mPositiveSignChar
;
1155 QVector
<double> mTickVector
;
1156 QVector
<QString
> mTickVectorLabels
;
1157 QVector
<double> mSubTickVector
;
1158 QRect mAxisSelectionBox
, mTickLabelsSelectionBox
, mLabelSelectionBox
;
1159 bool mCachedMarginValid
;
1162 // introduced virtual methods:
1163 virtual void setupTickVectors();
1164 virtual void generateAutoTicks();
1165 virtual int calculateAutoSubTickCount(double tickStep
) const;
1166 virtual int calculateMargin();
1167 // tick label drawing/caching:
1168 virtual void placeTickLabel(QCPPainter
*painter
, double position
, int distanceToAxis
, const QString
&text
, QSize
*tickLabelsSize
);
1169 virtual void drawTickLabel(QCPPainter
*painter
, double x
, double y
, const TickLabelData
&labelData
) const;
1170 virtual TickLabelData
getTickLabelData(const QFont
&font
, const QString
&text
) const;
1171 virtual QPointF
getTickLabelDrawOffset(const TickLabelData
&labelData
) const;
1172 virtual void getMaxTickLabelSize(const QFont
&font
, const QString
&text
, QSize
*tickLabelsSize
) const;
1174 // reimplemented virtual methods:
1175 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const;
1176 virtual void draw(QCPPainter
*painter
);
1177 virtual QCP::Interaction
selectionCategory() const;
1179 virtual void selectEvent(QMouseEvent
*event
, bool additive
, const QVariant
&details
, bool *selectionStateChanged
);
1180 virtual void deselectEvent(bool *selectionStateChanged
);
1182 // non-virtual methods:
1183 void visibleTickBounds(int &lowIndex
, int &highIndex
) const;
1184 double baseLog(double value
) const;
1185 double basePow(double value
) const;
1186 QPen
getBasePen() const;
1187 QPen
getTickPen() const;
1188 QPen
getSubTickPen() const;
1189 QFont
getTickLabelFont() const;
1190 QFont
getLabelFont() const;
1191 QColor
getTickLabelColor() const;
1192 QColor
getLabelColor() const;
1195 Q_DISABLE_COPY(QCPAxis
)
1197 friend class QCustomPlot
;
1198 friend class QCPGrid
;
1199 friend class QCPAxisRect
;
1201 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts
)
1202 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes
)
1203 Q_DECLARE_METATYPE(QCPAxis::SelectablePart
)
1206 class QCP_LIB_DECL QCPAbstractPlottable
: public QCPLayerable
1209 /// \cond INCLUDE_QPROPERTIES
1210 Q_PROPERTY(QString name READ name WRITE setName
)
1211 Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill
)
1212 Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE setAntialiasedScatters
)
1213 Q_PROPERTY(bool antialiasedErrorBars READ antialiasedErrorBars WRITE setAntialiasedErrorBars
)
1214 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
1215 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
1216 Q_PROPERTY(QBrush brush READ brush WRITE setBrush
)
1217 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush
)
1218 Q_PROPERTY(QCPAxis
* keyAxis READ keyAxis WRITE setKeyAxis
)
1219 Q_PROPERTY(QCPAxis
* valueAxis READ valueAxis WRITE setValueAxis
)
1220 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable
)
1221 Q_PROPERTY(bool selected READ selected WRITE setSelected
)
1224 QCPAbstractPlottable(QCPAxis
*keyAxis
, QCPAxis
*valueAxis
);
1227 QString
name() const { return mName
; }
1228 bool antialiasedFill() const { return mAntialiasedFill
; }
1229 bool antialiasedScatters() const { return mAntialiasedScatters
; }
1230 bool antialiasedErrorBars() const { return mAntialiasedErrorBars
; }
1231 QPen
pen() const { return mPen
; }
1232 QPen
selectedPen() const { return mSelectedPen
; }
1233 QBrush
brush() const { return mBrush
; }
1234 QBrush
selectedBrush() const { return mSelectedBrush
; }
1235 QCPAxis
*keyAxis() const { return mKeyAxis
.data(); }
1236 QCPAxis
*valueAxis() const { return mValueAxis
.data(); }
1237 bool selectable() const { return mSelectable
; }
1238 bool selected() const { return mSelected
; }
1241 void setName(const QString
&name
);
1242 void setAntialiasedFill(bool enabled
);
1243 void setAntialiasedScatters(bool enabled
);
1244 void setAntialiasedErrorBars(bool enabled
);
1245 void setPen(const QPen
&pen
);
1246 void setSelectedPen(const QPen
&pen
);
1247 void setBrush(const QBrush
&brush
);
1248 void setSelectedBrush(const QBrush
&brush
);
1249 void setKeyAxis(QCPAxis
*axis
);
1250 void setValueAxis(QCPAxis
*axis
);
1251 Q_SLOT
void setSelectable(bool selectable
);
1252 Q_SLOT
void setSelected(bool selected
);
1254 // introduced virtual methods:
1255 virtual void clearData() = 0;
1256 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const = 0;
1257 virtual bool addToLegend();
1258 virtual bool removeFromLegend() const;
1260 // non-property methods:
1261 void rescaleAxes(bool onlyEnlarge
=false) const;
1262 void rescaleKeyAxis(bool onlyEnlarge
=false) const;
1263 void rescaleValueAxis(bool onlyEnlarge
=false) const;
1266 void selectionChanged(bool selected
);
1270 Represents negative and positive sign domain for passing to \ref getKeyRange and \ref getValueRange.
1272 enum SignDomain
{ sdNegative
///< The negative sign domain, i.e. numbers smaller than zero
1273 ,sdBoth
///< Both sign domains, including zero, i.e. all (rational) numbers
1274 ,sdPositive
///< The positive sign domain, i.e. numbers greater than zero
1277 // property members:
1279 bool mAntialiasedFill
, mAntialiasedScatters
, mAntialiasedErrorBars
;
1280 QPen mPen
, mSelectedPen
;
1281 QBrush mBrush
, mSelectedBrush
;
1282 QWeakPointer
<QCPAxis
> mKeyAxis
, mValueAxis
;
1283 bool mSelectable
, mSelected
;
1285 // reimplemented virtual methods:
1286 virtual QRect
clipRect() const;
1287 virtual void draw(QCPPainter
*painter
) = 0;
1288 virtual QCP::Interaction
selectionCategory() const;
1289 void applyDefaultAntialiasingHint(QCPPainter
*painter
) const;
1291 virtual void selectEvent(QMouseEvent
*event
, bool additive
, const QVariant
&details
, bool *selectionStateChanged
);
1292 virtual void deselectEvent(bool *selectionStateChanged
);
1294 // introduced virtual methods:
1295 virtual void drawLegendIcon(QCPPainter
*painter
, const QRectF
&rect
) const = 0;
1296 virtual QCPRange
getKeyRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const = 0;
1297 virtual QCPRange
getValueRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const = 0;
1299 // non-virtual methods:
1300 void coordsToPixels(double key
, double value
, double &x
, double &y
) const;
1301 const QPointF
coordsToPixels(double key
, double value
) const;
1302 void pixelsToCoords(double x
, double y
, double &key
, double &value
) const;
1303 void pixelsToCoords(const QPointF
&pixelPos
, double &key
, double &value
) const;
1304 QPen
mainPen() const;
1305 QBrush
mainBrush() const;
1306 void applyFillAntialiasingHint(QCPPainter
*painter
) const;
1307 void applyScattersAntialiasingHint(QCPPainter
*painter
) const;
1308 void applyErrorBarsAntialiasingHint(QCPPainter
*painter
) const;
1309 double distSqrToLine(const QPointF
&start
, const QPointF
&end
, const QPointF
&point
) const;
1312 Q_DISABLE_COPY(QCPAbstractPlottable
)
1314 friend class QCustomPlot
;
1315 friend class QCPPlottableLegendItem
;
1319 class QCP_LIB_DECL QCPItemAnchor
1322 QCPItemAnchor(QCustomPlot
*parentPlot
, QCPAbstractItem
*parentItem
, const QString name
, int anchorId
=-1);
1323 virtual ~QCPItemAnchor();
1326 QString
name() const { return mName
; }
1327 virtual QPointF
pixelPoint() const;
1330 // property members:
1333 // non-property members:
1334 QCustomPlot
*mParentPlot
;
1335 QCPAbstractItem
*mParentItem
;
1337 QSet
<QCPItemPosition
*> mChildren
;
1339 // introduced virtual methods:
1340 virtual QCPItemPosition
*toQCPItemPosition() { return 0; }
1342 // non-virtual methods:
1343 void addChild(QCPItemPosition
* pos
); // called from pos when this anchor is set as parent
1344 void removeChild(QCPItemPosition
*pos
); // called from pos when its parent anchor is reset or pos deleted
1347 Q_DISABLE_COPY(QCPItemAnchor
)
1349 friend class QCPItemPosition
;
1354 class QCP_LIB_DECL QCPItemPosition
: public QCPItemAnchor
1358 Defines the ways an item position can be specified. Thus it defines what the numbers passed to
1359 \ref setCoords actually mean.
1363 enum PositionType
{ ptAbsolute
///< Static positioning in pixels, starting from the top left corner of the viewport/widget.
1364 ,ptViewportRatio
///< Static positioning given by a fraction of the viewport size.
1365 ,ptAxisRectRatio
///< Static positioning given by a fraction of the axis rect size (see \ref setAxisRect).
1366 ,ptPlotCoords
///< Dynamic positioning at a plot coordinate defined by two axes (see \ref setAxes).
1369 QCPItemPosition(QCustomPlot
*parentPlot
, QCPAbstractItem
*parentItem
, const QString name
);
1370 virtual ~QCPItemPosition();
1373 PositionType
type() const { return mPositionType
; }
1374 QCPItemAnchor
*parentAnchor() const { return mParentAnchor
; }
1375 double key() const { return mKey
; }
1376 double value() const { return mValue
; }
1377 QPointF
coords() const { return QPointF(mKey
, mValue
); }
1378 QCPAxis
*keyAxis() const { return mKeyAxis
.data(); }
1379 QCPAxis
*valueAxis() const { return mValueAxis
.data(); }
1380 QCPAxisRect
*axisRect() const { return mAxisRect
.data(); }
1381 virtual QPointF
pixelPoint() const;
1384 void setType(PositionType type
);
1385 bool setParentAnchor(QCPItemAnchor
*parentAnchor
, bool keepPixelPosition
=false);
1386 void setCoords(double key
, double value
);
1387 void setCoords(const QPointF
&coords
);
1388 void setAxes(QCPAxis
* keyAxis
, QCPAxis
* valueAxis
);
1389 void setAxisRect(QCPAxisRect
*axisRect
);
1390 void setPixelPoint(const QPointF
&pixelPoint
);
1393 // property members:
1394 PositionType mPositionType
;
1395 QWeakPointer
<QCPAxis
> mKeyAxis
, mValueAxis
;
1396 QWeakPointer
<QCPAxisRect
> mAxisRect
;
1397 double mKey
, mValue
;
1398 QCPItemAnchor
*mParentAnchor
;
1400 // reimplemented virtual methods:
1401 virtual QCPItemPosition
*toQCPItemPosition() { return this; }
1404 Q_DISABLE_COPY(QCPItemPosition
)
1409 class QCP_LIB_DECL QCPAbstractItem
: public QCPLayerable
1412 /// \cond INCLUDE_QPROPERTIES
1413 Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect
)
1414 Q_PROPERTY(QCPAxisRect
* clipAxisRect READ clipAxisRect WRITE setClipAxisRect
)
1415 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable
)
1416 Q_PROPERTY(bool selected READ selected WRITE setSelected
)
1419 QCPAbstractItem(QCustomPlot
*parentPlot
);
1420 virtual ~QCPAbstractItem();
1423 bool clipToAxisRect() const { return mClipToAxisRect
; }
1424 QCPAxisRect
*clipAxisRect() const { return mClipAxisRect
.data(); }
1425 bool selectable() const { return mSelectable
; }
1426 bool selected() const { return mSelected
; }
1429 void setClipToAxisRect(bool clip
);
1430 void setClipAxisRect(QCPAxisRect
*rect
);
1431 void setSelectable(bool selectable
);
1432 void setSelected(bool selected
);
1434 // reimplemented virtual methods:
1435 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const = 0;
1437 // non-virtual methods:
1438 QList
<QCPItemPosition
*> positions() const { return mPositions
; }
1439 QList
<QCPItemAnchor
*> anchors() const { return mAnchors
; }
1440 QCPItemPosition
*position(const QString
&name
) const;
1441 QCPItemAnchor
*anchor(const QString
&name
) const;
1442 bool hasAnchor(const QString
&name
) const;
1445 void selectionChanged(bool selected
);
1448 // property members:
1449 bool mClipToAxisRect
;
1450 QWeakPointer
<QCPAxisRect
> mClipAxisRect
;
1451 QList
<QCPItemPosition
*> mPositions
;
1452 QList
<QCPItemAnchor
*> mAnchors
;
1453 bool mSelectable
, mSelected
;
1455 // reimplemented virtual methods:
1456 virtual QCP::Interaction
selectionCategory() const;
1457 virtual QRect
clipRect() const;
1458 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const;
1459 virtual void draw(QCPPainter
*painter
) = 0;
1461 virtual void selectEvent(QMouseEvent
*event
, bool additive
, const QVariant
&details
, bool *selectionStateChanged
);
1462 virtual void deselectEvent(bool *selectionStateChanged
);
1464 // introduced virtual methods:
1465 virtual QPointF
anchorPixelPoint(int anchorId
) const;
1467 // non-virtual methods:
1468 double distSqrToLine(const QPointF
&start
, const QPointF
&end
, const QPointF
&point
) const;
1469 double rectSelectTest(const QRectF
&rect
, const QPointF
&pos
, bool filledRect
) const;
1470 QCPItemPosition
*createPosition(const QString
&name
);
1471 QCPItemAnchor
*createAnchor(const QString
&name
, int anchorId
);
1474 Q_DISABLE_COPY(QCPAbstractItem
)
1476 friend class QCustomPlot
;
1477 friend class QCPItemAnchor
;
1481 class QCP_LIB_DECL QCustomPlot
: public QWidget
1484 /// \cond INCLUDE_QPROPERTIES
1485 Q_PROPERTY(QRect viewport READ viewport WRITE setViewport
)
1486 Q_PROPERTY(QPixmap background READ background WRITE setBackground
)
1487 Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled
)
1488 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode
)
1489 Q_PROPERTY(QCPLayoutGrid
* plotLayout READ plotLayout
)
1490 Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE setAutoAddPlottableToLegend
)
1491 Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE setSelectionTolerance
)
1492 Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag
)
1493 Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier
)
1497 Defines how a layer should be inserted relative to an other layer.
1499 \see addLayer, moveLayer
1501 enum LayerInsertMode
{ limBelow
///< Layer is inserted below other layer
1502 ,limAbove
///< Layer is inserted above other layer
1504 Q_ENUMS(LayerInsertMode
)
1506 explicit QCustomPlot(QWidget
*parent
= 0);
1507 virtual ~QCustomPlot();
1510 QRect
viewport() const { return mViewport
; }
1511 QPixmap
background() const { return mBackgroundPixmap
; }
1512 bool backgroundScaled() const { return mBackgroundScaled
; }
1513 Qt::AspectRatioMode
backgroundScaledMode() const { return mBackgroundScaledMode
; }
1514 QCPLayoutGrid
*plotLayout() const { return mPlotLayout
; }
1515 QCP::AntialiasedElements
antialiasedElements() const { return mAntialiasedElements
; }
1516 QCP::AntialiasedElements
notAntialiasedElements() const { return mNotAntialiasedElements
; }
1517 bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend
; }
1518 const QCP::Interactions
interactions() const { return mInteractions
; }
1519 int selectionTolerance() const { return mSelectionTolerance
; }
1520 bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag
; }
1521 QCP::PlottingHints
plottingHints() const { return mPlottingHints
; }
1522 Qt::KeyboardModifier
multiSelectModifier() const { return mMultiSelectModifier
; }
1525 void setViewport(const QRect
&rect
);
1526 void setBackground(const QPixmap
&pm
);
1527 void setBackground(const QPixmap
&pm
, bool scaled
, Qt::AspectRatioMode mode
=Qt::KeepAspectRatioByExpanding
);
1528 void setBackground(const QBrush
&brush
);
1529 void setBackgroundScaled(bool scaled
);
1530 void setBackgroundScaledMode(Qt::AspectRatioMode mode
);
1531 void setAntialiasedElements(const QCP::AntialiasedElements
&antialiasedElements
);
1532 void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement
, bool enabled
=true);
1533 void setNotAntialiasedElements(const QCP::AntialiasedElements
¬AntialiasedElements
);
1534 void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement
, bool enabled
=true);
1535 void setAutoAddPlottableToLegend(bool on
);
1536 void setInteractions(const QCP::Interactions
&interactions
);
1537 void setInteraction(const QCP::Interaction
&interaction
, bool enabled
=true);
1538 void setSelectionTolerance(int pixels
);
1539 void setNoAntialiasingOnDrag(bool enabled
);
1540 void setPlottingHints(const QCP::PlottingHints
&hints
);
1541 void setPlottingHint(QCP::PlottingHint hint
, bool enabled
=true);
1542 void setMultiSelectModifier(Qt::KeyboardModifier modifier
);
1544 // non-property methods:
1545 // plottable interface:
1546 QCPAbstractPlottable
*plottable(int index
);
1547 QCPAbstractPlottable
*plottable();
1548 bool addPlottable(QCPAbstractPlottable
*plottable
);
1549 bool removePlottable(QCPAbstractPlottable
*plottable
);
1550 bool removePlottable(int index
);
1551 int clearPlottables();
1552 int plottableCount() const;
1553 QList
<QCPAbstractPlottable
*> selectedPlottables() const;
1554 QCPAbstractPlottable
*plottableAt(const QPointF
&pos
, bool onlySelectable
=false) const;
1555 bool hasPlottable(QCPAbstractPlottable
*plottable
) const;
1557 // specialized interface for QCPGraph:
1558 QCPGraph
*graph(int index
) const;
1559 QCPGraph
*graph() const;
1560 QCPGraph
*addGraph(QCPAxis
*keyAxis
=0, QCPAxis
*valueAxis
=0);
1561 bool removeGraph(QCPGraph
*graph
);
1562 bool removeGraph(int index
);
1564 int graphCount() const;
1565 QList
<QCPGraph
*> selectedGraphs() const;
1568 QCPAbstractItem
*item(int index
) const;
1569 QCPAbstractItem
*item() const;
1570 bool addItem(QCPAbstractItem
* item
);
1571 bool removeItem(QCPAbstractItem
*item
);
1572 bool removeItem(int index
);
1574 int itemCount() const;
1575 QList
<QCPAbstractItem
*> selectedItems() const;
1576 QCPAbstractItem
*itemAt(const QPointF
&pos
, bool onlySelectable
=false) const;
1577 bool hasItem(QCPAbstractItem
*item
) const;
1580 QCPLayer
*layer(const QString
&name
) const;
1581 QCPLayer
*layer(int index
) const;
1582 QCPLayer
*currentLayer() const;
1583 bool setCurrentLayer(const QString
&name
);
1584 bool setCurrentLayer(QCPLayer
*layer
);
1585 int layerCount() const;
1586 bool addLayer(const QString
&name
, QCPLayer
*otherLayer
=0, LayerInsertMode insertMode
=limAbove
);
1587 bool removeLayer(QCPLayer
*layer
);
1588 bool moveLayer(QCPLayer
*layer
, QCPLayer
*otherLayer
, LayerInsertMode insertMode
=limAbove
);
1590 // axis rect/layout interface:
1591 int axisRectCount() const;
1592 QCPAxisRect
* axisRect(int index
=0) const;
1593 QList
<QCPAxisRect
*> axisRects() const;
1594 QCPLayoutElement
* layoutElementAt(const QPointF
&pos
) const;
1595 Q_SLOT
void rescaleAxes(bool onlyVisible
=false);
1597 QList
<QCPAxis
*> selectedAxes() const;
1598 QList
<QCPLegend
*> selectedLegends() const;
1599 Q_SLOT
void deselectAll();
1601 bool savePdf(const QString
&fileName
, bool noCosmeticPen
=false, int width
=0, int height
=0);
1602 bool savePng(const QString
&fileName
, int width
=0, int height
=0, double scale
=1.0, int quality
=-1);
1603 bool saveJpg(const QString
&fileName
, int width
=0, int height
=0, double scale
=1.0, int quality
=-1);
1604 bool saveBmp(const QString
&fileName
, int width
=0, int height
=0, double scale
=1.0);
1605 bool saveRastered(const QString
&fileName
, int width
, int height
, double scale
, const char *format
, int quality
=-1);
1606 QPixmap
toPixmap(int width
=0, int height
=0, double scale
=1.0);
1607 void toPainter(QCPPainter
*painter
, int width
=0, int height
=0);
1608 Q_SLOT
void replot();
1610 QCPAxis
*xAxis
, *yAxis
, *xAxis2
, *yAxis2
;
1614 void mouseDoubleClick(QMouseEvent
*event
);
1615 void mousePress(QMouseEvent
*event
);
1616 void mouseMove(QMouseEvent
*event
);
1617 void mouseRelease(QMouseEvent
*event
);
1618 void mouseWheel(QWheelEvent
*event
);
1620 void plottableClick(QCPAbstractPlottable
*plottable
, QMouseEvent
*event
);
1621 void plottableDoubleClick(QCPAbstractPlottable
*plottable
, QMouseEvent
*event
);
1622 void itemClick(QCPAbstractItem
*item
, QMouseEvent
*event
);
1623 void itemDoubleClick(QCPAbstractItem
*item
, QMouseEvent
*event
);
1624 void axisClick(QCPAxis
*axis
, QCPAxis::SelectablePart part
, QMouseEvent
*event
);
1625 void axisDoubleClick(QCPAxis
*axis
, QCPAxis::SelectablePart part
, QMouseEvent
*event
);
1626 void legendClick(QCPLegend
*legend
, QCPAbstractLegendItem
*item
, QMouseEvent
*event
);
1627 void legendDoubleClick(QCPLegend
*legend
, QCPAbstractLegendItem
*item
, QMouseEvent
*event
);
1628 void titleClick(QMouseEvent
*event
, QCPPlotTitle
*title
);
1629 void titleDoubleClick(QMouseEvent
*event
, QCPPlotTitle
*title
);
1631 void selectionChangedByUser();
1632 void beforeReplot();
1636 // property members:
1638 QCPLayoutGrid
*mPlotLayout
;
1639 bool mAutoAddPlottableToLegend
;
1640 QList
<QCPAbstractPlottable
*> mPlottables
;
1641 QList
<QCPGraph
*> mGraphs
; // extra list of plottables also in mPlottables that are of type QCPGraph
1642 QList
<QCPAbstractItem
*> mItems
;
1643 QList
<QCPLayer
*> mLayers
;
1644 QCP::AntialiasedElements mAntialiasedElements
, mNotAntialiasedElements
;
1645 QCP::Interactions mInteractions
;
1646 int mSelectionTolerance
;
1647 bool mNoAntialiasingOnDrag
;
1648 QBrush mBackgroundBrush
;
1649 QPixmap mBackgroundPixmap
;
1650 QPixmap mScaledBackgroundPixmap
;
1651 bool mBackgroundScaled
;
1652 Qt::AspectRatioMode mBackgroundScaledMode
;
1653 QCPLayer
*mCurrentLayer
;
1654 QCP::PlottingHints mPlottingHints
;
1655 Qt::KeyboardModifier mMultiSelectModifier
;
1657 // non-property members:
1658 QPixmap mPaintBuffer
;
1659 QPoint mMousePressPos
;
1660 QCPLayoutElement
*mMouseEventElement
;
1663 // reimplemented virtual methods:
1664 virtual QSize
minimumSizeHint() const;
1665 virtual QSize
sizeHint() const;
1666 virtual void paintEvent(QPaintEvent
*event
);
1667 virtual void resizeEvent(QResizeEvent
*event
);
1668 virtual void mouseDoubleClickEvent(QMouseEvent
*event
);
1669 virtual void mousePressEvent(QMouseEvent
*event
);
1670 virtual void mouseMoveEvent(QMouseEvent
*event
);
1671 virtual void mouseReleaseEvent(QMouseEvent
*event
);
1672 virtual void wheelEvent(QWheelEvent
*event
);
1674 // introduced virtual methods:
1675 virtual void draw(QCPPainter
*painter
);
1676 virtual void axisRemoved(QCPAxis
*axis
);
1677 virtual void legendRemoved(QCPLegend
*legend
);
1679 // non-virtual methods:
1680 void updateLayerIndices() const;
1681 QCPLayerable
*layerableAt(const QPointF
&pos
, bool onlySelectable
, QVariant
*selectionDetails
=0) const;
1682 void drawBackground(QCPPainter
*painter
);
1684 friend class QCPLegend
;
1685 friend class QCPAxis
;
1686 friend class QCPLayer
;
1687 friend class QCPAxisRect
;
1695 class QCP_LIB_DECL QCPData
1699 QCPData(double key
, double value
);
1701 double keyErrorPlus
, keyErrorMinus
;
1702 double valueErrorPlus
, valueErrorMinus
;
1704 Q_DECLARE_TYPEINFO(QCPData
, Q_MOVABLE_TYPE
);
1706 /*! \typedef QCPDataMap
1707 Container for storing QCPData items in a sorted fashion. The key of the map
1708 is the key member of the QCPData instance.
1710 This is the container in which QCPGraph holds its data.
1711 \see QCPData, QCPGraph::setData
1713 typedef QMap
<double, QCPData
> QCPDataMap
;
1714 typedef QMapIterator
<double, QCPData
> QCPDataMapIterator
;
1715 typedef QMutableMapIterator
<double, QCPData
> QCPDataMutableMapIterator
;
1718 class QCP_LIB_DECL QCPGraph
: public QCPAbstractPlottable
1721 /// \cond INCLUDE_QPROPERTIES
1722 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle
)
1723 Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle
)
1724 Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType
)
1725 Q_PROPERTY(QPen errorPen READ errorPen WRITE setErrorPen
)
1726 Q_PROPERTY(double errorBarSize READ errorBarSize WRITE setErrorBarSize
)
1727 Q_PROPERTY(bool errorBarSkipSymbol READ errorBarSkipSymbol WRITE setErrorBarSkipSymbol
)
1728 Q_PROPERTY(QCPGraph
* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph
)
1732 Defines how the graph's line is represented visually in the plot. The line is drawn with the
1733 current pen of the graph (\ref setPen).
1736 enum LineStyle
{ lsNone
///< data points are not connected with any lines (e.g. data only represented
1737 ///< with symbols according to the scatter style, see \ref setScatterStyle)
1738 ,lsLine
///< data points are connected by a straight line
1739 ,lsStepLeft
///< line is drawn as steps where the step height is the value of the left data point
1740 ,lsStepRight
///< line is drawn as steps where the step height is the value of the right data point
1741 ,lsStepCenter
///< line is drawn as steps where the step is in between two data points
1742 ,lsImpulse
///< each data point is represented by a line parallel to the value axis, which reaches from the data point to the zero-value-line
1746 Defines what kind of error bars are drawn for each data point
1748 enum ErrorType
{ etNone
///< No error bars are shown
1749 ,etKey
///< Error bars for the key dimension of the data point are shown
1750 ,etValue
///< Error bars for the value dimension of the data point are shown
1751 ,etBoth
///< Error bars for both key and value dimensions of the data point are shown
1755 explicit QCPGraph(QCPAxis
*keyAxis
, QCPAxis
*valueAxis
);
1756 virtual ~QCPGraph();
1759 const QCPDataMap
*data() const { return mData
; }
1760 LineStyle
lineStyle() const { return mLineStyle
; }
1761 QCPScatterStyle
scatterStyle() const { return mScatterStyle
; }
1762 ErrorType
errorType() const { return mErrorType
; }
1763 QPen
errorPen() const { return mErrorPen
; }
1764 double errorBarSize() const { return mErrorBarSize
; }
1765 bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol
; }
1766 QCPGraph
*channelFillGraph() const { return mChannelFillGraph
.data(); }
1769 void setData(QCPDataMap
*data
, bool copy
=false);
1770 void setData(const QVector
<double> &key
, const QVector
<double> &value
);
1771 void setDataKeyError(const QVector
<double> &key
, const QVector
<double> &value
, const QVector
<double> &keyError
);
1772 void setDataKeyError(const QVector
<double> &key
, const QVector
<double> &value
, const QVector
<double> &keyErrorMinus
, const QVector
<double> &keyErrorPlus
);
1773 void setDataValueError(const QVector
<double> &key
, const QVector
<double> &value
, const QVector
<double> &valueError
);
1774 void setDataValueError(const QVector
<double> &key
, const QVector
<double> &value
, const QVector
<double> &valueErrorMinus
, const QVector
<double> &valueErrorPlus
);
1775 void setDataBothError(const QVector
<double> &key
, const QVector
<double> &value
, const QVector
<double> &keyError
, const QVector
<double> &valueError
);
1776 void setDataBothError(const QVector
<double> &key
, const QVector
<double> &value
, const QVector
<double> &keyErrorMinus
, const QVector
<double> &keyErrorPlus
, const QVector
<double> &valueErrorMinus
, const QVector
<double> &valueErrorPlus
);
1777 void setLineStyle(LineStyle ls
);
1778 void setScatterStyle(const QCPScatterStyle
&style
);
1779 void setErrorType(ErrorType errorType
);
1780 void setErrorPen(const QPen
&pen
);
1781 void setErrorBarSize(double size
);
1782 void setErrorBarSkipSymbol(bool enabled
);
1783 void setChannelFillGraph(QCPGraph
*targetGraph
);
1785 // non-property methods:
1786 void addData(const QCPDataMap
&dataMap
);
1787 void addData(const QCPData
&data
);
1788 void addData(double key
, double value
);
1789 void addData(const QVector
<double> &keys
, const QVector
<double> &values
);
1790 void removeDataBefore(double key
);
1791 void removeDataAfter(double key
);
1792 void removeData(double fromKey
, double toKey
);
1793 void removeData(double key
);
1795 // reimplemented virtual methods:
1796 virtual void clearData();
1797 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
1798 using QCPAbstractPlottable::rescaleAxes
;
1799 using QCPAbstractPlottable::rescaleKeyAxis
;
1800 using QCPAbstractPlottable::rescaleValueAxis
;
1801 virtual void rescaleAxes(bool onlyEnlarge
, bool includeErrorBars
) const; // overloads base class interface
1802 virtual void rescaleKeyAxis(bool onlyEnlarge
, bool includeErrorBars
) const; // overloads base class interface
1803 virtual void rescaleValueAxis(bool onlyEnlarge
, bool includeErrorBars
) const; // overloads base class interface
1806 // property members:
1809 LineStyle mLineStyle
;
1810 QCPScatterStyle mScatterStyle
;
1811 ErrorType mErrorType
;
1812 double mErrorBarSize
;
1813 bool mErrorBarSkipSymbol
;
1814 QWeakPointer
<QCPGraph
> mChannelFillGraph
;
1816 // reimplemented virtual methods:
1817 virtual void draw(QCPPainter
*painter
);
1818 virtual void drawLegendIcon(QCPPainter
*painter
, const QRectF
&rect
) const;
1819 virtual QCPRange
getKeyRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const;
1820 virtual QCPRange
getValueRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const;
1821 virtual QCPRange
getKeyRange(bool &validRange
, SignDomain inSignDomain
, bool includeErrors
) const; // overloads base class interface
1822 virtual QCPRange
getValueRange(bool &validRange
, SignDomain inSignDomain
, bool includeErrors
) const; // overloads base class interface
1824 // introduced virtual methods:
1825 virtual void drawFill(QCPPainter
*painter
, QVector
<QPointF
> *lineData
) const;
1826 virtual void drawScatterPlot(QCPPainter
*painter
, QVector
<QCPData
> *pointData
) const;
1827 virtual void drawLinePlot(QCPPainter
*painter
, QVector
<QPointF
> *lineData
) const;
1828 virtual void drawImpulsePlot(QCPPainter
*painter
, QVector
<QPointF
> *lineData
) const;
1830 // non-virtual methods:
1831 void getPlotData(QVector
<QPointF
> *lineData
, QVector
<QCPData
> *pointData
) const;
1832 void getScatterPlotData(QVector
<QCPData
> *pointData
) const;
1833 void getLinePlotData(QVector
<QPointF
> *lineData
, QVector
<QCPData
> *pointData
) const;
1834 void getStepLeftPlotData(QVector
<QPointF
> *lineData
, QVector
<QCPData
> *pointData
) const;
1835 void getStepRightPlotData(QVector
<QPointF
> *lineData
, QVector
<QCPData
> *pointData
) const;
1836 void getStepCenterPlotData(QVector
<QPointF
> *lineData
, QVector
<QCPData
> *pointData
) const;
1837 void getImpulsePlotData(QVector
<QPointF
> *lineData
, QVector
<QCPData
> *pointData
) const;
1838 void drawError(QCPPainter
*painter
, double x
, double y
, const QCPData
&data
) const;
1839 void getVisibleDataBounds(QCPDataMap::const_iterator
&lower
, QCPDataMap::const_iterator
&upper
, int &count
) const;
1840 void addFillBasePoints(QVector
<QPointF
> *lineData
) const;
1841 void removeFillBasePoints(QVector
<QPointF
> *lineData
) const;
1842 QPointF
lowerFillBasePoint(double lowerKey
) const;
1843 QPointF
upperFillBasePoint(double upperKey
) const;
1844 const QPolygonF
getChannelFillPolygon(const QVector
<QPointF
> *lineData
) const;
1845 int findIndexBelowX(const QVector
<QPointF
> *data
, double x
) const;
1846 int findIndexAboveX(const QVector
<QPointF
> *data
, double x
) const;
1847 int findIndexBelowY(const QVector
<QPointF
> *data
, double y
) const;
1848 int findIndexAboveY(const QVector
<QPointF
> *data
, double y
) const;
1849 double pointDistance(const QPointF
&pixelPoint
) const;
1851 friend class QCustomPlot
;
1852 friend class QCPLegend
;
1860 class QCP_LIB_DECL QCPCurveData
1864 QCPCurveData(double t
, double key
, double value
);
1865 double t
, key
, value
;
1867 Q_DECLARE_TYPEINFO(QCPCurveData
, Q_MOVABLE_TYPE
);
1869 /*! \typedef QCPCurveDataMap
1870 Container for storing QCPCurveData items in a sorted fashion. The key of the map
1871 is the t member of the QCPCurveData instance.
1873 This is the container in which QCPCurve holds its data.
1874 \see QCPCurveData, QCPCurve::setData
1877 typedef QMap
<double, QCPCurveData
> QCPCurveDataMap
;
1878 typedef QMapIterator
<double, QCPCurveData
> QCPCurveDataMapIterator
;
1879 typedef QMutableMapIterator
<double, QCPCurveData
> QCPCurveDataMutableMapIterator
;
1882 class QCP_LIB_DECL QCPCurve
: public QCPAbstractPlottable
1885 /// \cond INCLUDE_QPROPERTIES
1886 Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle
)
1887 Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle
)
1891 Defines how the curve's line is represented visually in the plot. The line is drawn with the
1892 current pen of the curve (\ref setPen).
1895 enum LineStyle
{ lsNone
, ///< No line is drawn between data points (e.g. only scatters)
1896 lsLine
///< Data points are connected with a straight line
1898 explicit QCPCurve(QCPAxis
*keyAxis
, QCPAxis
*valueAxis
);
1899 virtual ~QCPCurve();
1902 QCPCurveDataMap
*data() const { return mData
; }
1903 QCPScatterStyle
scatterStyle() const { return mScatterStyle
; }
1904 LineStyle
lineStyle() const { return mLineStyle
; }
1907 void setData(QCPCurveDataMap
*data
, bool copy
=false);
1908 void setData(const QVector
<double> &t
, const QVector
<double> &key
, const QVector
<double> &value
);
1909 void setData(const QVector
<double> &key
, const QVector
<double> &value
);
1910 void setScatterStyle(const QCPScatterStyle
&style
);
1911 void setLineStyle(LineStyle style
);
1913 // non-property methods:
1914 void addData(const QCPCurveDataMap
&dataMap
);
1915 void addData(const QCPCurveData
&data
);
1916 void addData(double t
, double key
, double value
);
1917 void addData(double key
, double value
);
1918 void addData(const QVector
<double> &ts
, const QVector
<double> &keys
, const QVector
<double> &values
);
1919 void removeDataBefore(double t
);
1920 void removeDataAfter(double t
);
1921 void removeData(double fromt
, double tot
);
1922 void removeData(double t
);
1924 // reimplemented virtual methods:
1925 virtual void clearData();
1926 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
1929 // property members:
1930 QCPCurveDataMap
*mData
;
1931 QCPScatterStyle mScatterStyle
;
1932 LineStyle mLineStyle
;
1934 // reimplemented virtual methods:
1935 virtual void draw(QCPPainter
*painter
);
1936 virtual void drawLegendIcon(QCPPainter
*painter
, const QRectF
&rect
) const;
1937 virtual QCPRange
getKeyRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const;
1938 virtual QCPRange
getValueRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const;
1940 // introduced virtual methods:
1941 virtual void drawScatterPlot(QCPPainter
*painter
, const QVector
<QPointF
> *pointData
) const;
1943 // non-virtual methods:
1944 void getCurveData(QVector
<QPointF
> *lineData
) const;
1945 double pointDistance(const QPointF
&pixelPoint
) const;
1946 QPointF
outsideCoordsToPixels(double key
, double value
, int region
, QRect axisRect
) const;
1948 friend class QCustomPlot
;
1949 friend class QCPLegend
;
1957 class QCP_LIB_DECL QCPBarData
1961 QCPBarData(double key
, double value
);
1964 Q_DECLARE_TYPEINFO(QCPBarData
, Q_MOVABLE_TYPE
);
1966 /*! \typedef QCPBarDataMap
1967 Container for storing QCPBarData items in a sorted fashion. The key of the map
1968 is the key member of the QCPBarData instance.
1970 This is the container in which QCPBars holds its data.
1971 \see QCPBarData, QCPBars::setData
1973 typedef QMap
<double, QCPBarData
> QCPBarDataMap
;
1974 typedef QMapIterator
<double, QCPBarData
> QCPBarDataMapIterator
;
1975 typedef QMutableMapIterator
<double, QCPBarData
> QCPBarDataMutableMapIterator
;
1978 class QCP_LIB_DECL QCPBars
: public QCPAbstractPlottable
1981 /// \cond INCLUDE_QPROPERTIES
1982 Q_PROPERTY(double width READ width WRITE setWidth
)
1983 Q_PROPERTY(QCPBars
* barBelow READ barBelow
)
1984 Q_PROPERTY(QCPBars
* barAbove READ barAbove
)
1987 explicit QCPBars(QCPAxis
*keyAxis
, QCPAxis
*valueAxis
);
1991 double width() const { return mWidth
; }
1992 QCPBars
*barBelow() const { return mBarBelow
.data(); }
1993 QCPBars
*barAbove() const { return mBarAbove
.data(); }
1994 QCPBarDataMap
*data() const { return mData
; }
1997 void setWidth(double width
);
1998 void setData(QCPBarDataMap
*data
, bool copy
=false);
1999 void setData(const QVector
<double> &key
, const QVector
<double> &value
);
2001 // non-property methods:
2002 void moveBelow(QCPBars
*bars
);
2003 void moveAbove(QCPBars
*bars
);
2004 void addData(const QCPBarDataMap
&dataMap
);
2005 void addData(const QCPBarData
&data
);
2006 void addData(double key
, double value
);
2007 void addData(const QVector
<double> &keys
, const QVector
<double> &values
);
2008 void removeDataBefore(double key
);
2009 void removeDataAfter(double key
);
2010 void removeData(double fromKey
, double toKey
);
2011 void removeData(double key
);
2013 // reimplemented virtual methods:
2014 virtual void clearData();
2015 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2018 // property members:
2019 QCPBarDataMap
*mData
;
2021 QWeakPointer
<QCPBars
> mBarBelow
, mBarAbove
;
2023 // reimplemented virtual methods:
2024 virtual void draw(QCPPainter
*painter
);
2025 virtual void drawLegendIcon(QCPPainter
*painter
, const QRectF
&rect
) const;
2026 virtual QCPRange
getKeyRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const;
2027 virtual QCPRange
getValueRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const;
2029 // non-virtual methods:
2030 QPolygonF
getBarPolygon(double key
, double value
) const;
2031 double getBaseValue(double key
, bool positive
) const;
2032 static void connectBars(QCPBars
* lower
, QCPBars
* upper
);
2034 friend class QCustomPlot
;
2035 friend class QCPLegend
;
2043 class QCP_LIB_DECL QCPStatisticalBox
: public QCPAbstractPlottable
2046 /// \cond INCLUDE_QPROPERTIES
2047 Q_PROPERTY(double key READ key WRITE setKey
)
2048 Q_PROPERTY(double minimum READ minimum WRITE setMinimum
)
2049 Q_PROPERTY(double lowerQuartile READ lowerQuartile WRITE setLowerQuartile
)
2050 Q_PROPERTY(double median READ median WRITE setMedian
)
2051 Q_PROPERTY(double upperQuartile READ upperQuartile WRITE setUpperQuartile
)
2052 Q_PROPERTY(double maximum READ maximum WRITE setMaximum
)
2053 Q_PROPERTY(QVector
<double> outliers READ outliers WRITE setOutliers
)
2054 Q_PROPERTY(double width READ width WRITE setWidth
)
2055 Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth
)
2056 Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen
)
2057 Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen
)
2058 Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen
)
2059 Q_PROPERTY(QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle
)
2062 explicit QCPStatisticalBox(QCPAxis
*keyAxis
, QCPAxis
*valueAxis
);
2065 double key() const { return mKey
; }
2066 double minimum() const { return mMinimum
; }
2067 double lowerQuartile() const { return mLowerQuartile
; }
2068 double median() const { return mMedian
; }
2069 double upperQuartile() const { return mUpperQuartile
; }
2070 double maximum() const { return mMaximum
; }
2071 QVector
<double> outliers() const { return mOutliers
; }
2072 double width() const { return mWidth
; }
2073 double whiskerWidth() const { return mWhiskerWidth
; }
2074 QPen
whiskerPen() const { return mWhiskerPen
; }
2075 QPen
whiskerBarPen() const { return mWhiskerBarPen
; }
2076 QPen
medianPen() const { return mMedianPen
; }
2077 QCPScatterStyle
outlierStyle() const { return mOutlierStyle
; }
2080 void setKey(double key
);
2081 void setMinimum(double value
);
2082 void setLowerQuartile(double value
);
2083 void setMedian(double value
);
2084 void setUpperQuartile(double value
);
2085 void setMaximum(double value
);
2086 void setOutliers(const QVector
<double> &values
);
2087 void setData(double key
, double minimum
, double lowerQuartile
, double median
, double upperQuartile
, double maximum
);
2088 void setWidth(double width
);
2089 void setWhiskerWidth(double width
);
2090 void setWhiskerPen(const QPen
&pen
);
2091 void setWhiskerBarPen(const QPen
&pen
);
2092 void setMedianPen(const QPen
&pen
);
2093 void setOutlierStyle(const QCPScatterStyle
&style
);
2095 // non-property methods:
2096 virtual void clearData();
2097 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2100 // property members:
2101 QVector
<double> mOutliers
;
2102 double mKey
, mMinimum
, mLowerQuartile
, mMedian
, mUpperQuartile
, mMaximum
;
2104 double mWhiskerWidth
;
2105 QPen mWhiskerPen
, mWhiskerBarPen
, mMedianPen
;
2106 QCPScatterStyle mOutlierStyle
;
2108 // reimplemented virtual methods:
2109 virtual void draw(QCPPainter
*painter
);
2110 virtual void drawLegendIcon(QCPPainter
*painter
, const QRectF
&rect
) const;
2111 virtual QCPRange
getKeyRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const;
2112 virtual QCPRange
getValueRange(bool &validRange
, SignDomain inSignDomain
=sdBoth
) const;
2114 // introduced virtual methods:
2115 virtual void drawQuartileBox(QCPPainter
*painter
, QRectF
*quartileBox
=0) const;
2116 virtual void drawMedian(QCPPainter
*painter
) const;
2117 virtual void drawWhiskers(QCPPainter
*painter
) const;
2118 virtual void drawOutliers(QCPPainter
*painter
) const;
2120 friend class QCustomPlot
;
2121 friend class QCPLegend
;
2125 class QCP_LIB_DECL QCPItemStraightLine
: public QCPAbstractItem
2128 /// \cond INCLUDE_QPROPERTIES
2129 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2130 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2133 QCPItemStraightLine(QCustomPlot
*parentPlot
);
2134 virtual ~QCPItemStraightLine();
2137 QPen
pen() const { return mPen
; }
2138 QPen
selectedPen() const { return mSelectedPen
; }
2141 void setPen(const QPen
&pen
);
2142 void setSelectedPen(const QPen
&pen
);
2144 // reimplemented virtual methods:
2145 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2147 QCPItemPosition
* const point1
;
2148 QCPItemPosition
* const point2
;
2151 // property members:
2152 QPen mPen
, mSelectedPen
;
2154 // reimplemented virtual methods:
2155 virtual void draw(QCPPainter
*painter
);
2157 // non-virtual methods:
2158 double distToStraightLine(const QVector2D
&point1
, const QVector2D
&vec
, const QVector2D
&point
) const;
2159 QLineF
getRectClippedStraightLine(const QVector2D
&point1
, const QVector2D
&vec
, const QRect
&rect
) const;
2160 QPen
mainPen() const;
2164 class QCP_LIB_DECL QCPItemLine
: public QCPAbstractItem
2167 /// \cond INCLUDE_QPROPERTIES
2168 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2169 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2170 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead
)
2171 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail
)
2174 QCPItemLine(QCustomPlot
*parentPlot
);
2175 virtual ~QCPItemLine();
2178 QPen
pen() const { return mPen
; }
2179 QPen
selectedPen() const { return mSelectedPen
; }
2180 QCPLineEnding
head() const { return mHead
; }
2181 QCPLineEnding
tail() const { return mTail
; }
2184 void setPen(const QPen
&pen
);
2185 void setSelectedPen(const QPen
&pen
);
2186 void setHead(const QCPLineEnding
&head
);
2187 void setTail(const QCPLineEnding
&tail
);
2189 // reimplemented virtual methods:
2190 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2192 QCPItemPosition
* const start
;
2193 QCPItemPosition
* const end
;
2196 // property members:
2197 QPen mPen
, mSelectedPen
;
2198 QCPLineEnding mHead
, mTail
;
2200 // reimplemented virtual methods:
2201 virtual void draw(QCPPainter
*painter
);
2203 // non-virtual methods:
2204 QLineF
getRectClippedLine(const QVector2D
&start
, const QVector2D
&end
, const QRect
&rect
) const;
2205 QPen
mainPen() const;
2209 class QCP_LIB_DECL QCPItemCurve
: public QCPAbstractItem
2212 /// \cond INCLUDE_QPROPERTIES
2213 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2214 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2215 Q_PROPERTY(QCPLineEnding head READ head WRITE setHead
)
2216 Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail
)
2219 QCPItemCurve(QCustomPlot
*parentPlot
);
2220 virtual ~QCPItemCurve();
2223 QPen
pen() const { return mPen
; }
2224 QPen
selectedPen() const { return mSelectedPen
; }
2225 QCPLineEnding
head() const { return mHead
; }
2226 QCPLineEnding
tail() const { return mTail
; }
2229 void setPen(const QPen
&pen
);
2230 void setSelectedPen(const QPen
&pen
);
2231 void setHead(const QCPLineEnding
&head
);
2232 void setTail(const QCPLineEnding
&tail
);
2234 // reimplemented virtual methods:
2235 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2237 QCPItemPosition
* const start
;
2238 QCPItemPosition
* const startDir
;
2239 QCPItemPosition
* const endDir
;
2240 QCPItemPosition
* const end
;
2243 // property members:
2244 QPen mPen
, mSelectedPen
;
2245 QCPLineEnding mHead
, mTail
;
2247 // reimplemented virtual methods:
2248 virtual void draw(QCPPainter
*painter
);
2250 // non-virtual methods:
2251 QPen
mainPen() const;
2255 class QCP_LIB_DECL QCPItemRect
: public QCPAbstractItem
2258 /// \cond INCLUDE_QPROPERTIES
2259 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2260 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2261 Q_PROPERTY(QBrush brush READ brush WRITE setBrush
)
2262 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush
)
2265 QCPItemRect(QCustomPlot
*parentPlot
);
2266 virtual ~QCPItemRect();
2269 QPen
pen() const { return mPen
; }
2270 QPen
selectedPen() const { return mSelectedPen
; }
2271 QBrush
brush() const { return mBrush
; }
2272 QBrush
selectedBrush() const { return mSelectedBrush
; }
2275 void setPen(const QPen
&pen
);
2276 void setSelectedPen(const QPen
&pen
);
2277 void setBrush(const QBrush
&brush
);
2278 void setSelectedBrush(const QBrush
&brush
);
2280 // reimplemented virtual methods:
2281 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2283 QCPItemPosition
* const topLeft
;
2284 QCPItemPosition
* const bottomRight
;
2285 QCPItemAnchor
* const top
;
2286 QCPItemAnchor
* const topRight
;
2287 QCPItemAnchor
* const right
;
2288 QCPItemAnchor
* const bottom
;
2289 QCPItemAnchor
* const bottomLeft
;
2290 QCPItemAnchor
* const left
;
2293 enum AnchorIndex
{aiTop
, aiTopRight
, aiRight
, aiBottom
, aiBottomLeft
, aiLeft
};
2295 // property members:
2296 QPen mPen
, mSelectedPen
;
2297 QBrush mBrush
, mSelectedBrush
;
2299 // reimplemented virtual methods:
2300 virtual void draw(QCPPainter
*painter
);
2301 virtual QPointF
anchorPixelPoint(int anchorId
) const;
2303 // non-virtual methods:
2304 QPen
mainPen() const;
2305 QBrush
mainBrush() const;
2309 class QCP_LIB_DECL QCPItemText
: public QCPAbstractItem
2312 /// \cond INCLUDE_QPROPERTIES
2313 Q_PROPERTY(QColor color READ color WRITE setColor
)
2314 Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor
)
2315 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2316 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2317 Q_PROPERTY(QBrush brush READ brush WRITE setBrush
)
2318 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush
)
2319 Q_PROPERTY(QFont font READ font WRITE setFont
)
2320 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont
)
2321 Q_PROPERTY(QString text READ text WRITE setText
)
2322 Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment
)
2323 Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment
)
2324 Q_PROPERTY(double rotation READ rotation WRITE setRotation
)
2325 Q_PROPERTY(QMargins padding READ padding WRITE setPadding
)
2328 QCPItemText(QCustomPlot
*parentPlot
);
2329 virtual ~QCPItemText();
2332 QColor
color() const { return mColor
; }
2333 QColor
selectedColor() const { return mSelectedColor
; }
2334 QPen
pen() const { return mPen
; }
2335 QPen
selectedPen() const { return mSelectedPen
; }
2336 QBrush
brush() const { return mBrush
; }
2337 QBrush
selectedBrush() const { return mSelectedBrush
; }
2338 QFont
font() const { return mFont
; }
2339 QFont
selectedFont() const { return mSelectedFont
; }
2340 QString
text() const { return mText
; }
2341 Qt::Alignment
positionAlignment() const { return mPositionAlignment
; }
2342 Qt::Alignment
textAlignment() const { return mTextAlignment
; }
2343 double rotation() const { return mRotation
; }
2344 QMargins
padding() const { return mPadding
; }
2347 void setColor(const QColor
&color
);
2348 void setSelectedColor(const QColor
&color
);
2349 void setPen(const QPen
&pen
);
2350 void setSelectedPen(const QPen
&pen
);
2351 void setBrush(const QBrush
&brush
);
2352 void setSelectedBrush(const QBrush
&brush
);
2353 void setFont(const QFont
&font
);
2354 void setSelectedFont(const QFont
&font
);
2355 void setText(const QString
&text
);
2356 void setPositionAlignment(Qt::Alignment alignment
);
2357 void setTextAlignment(Qt::Alignment alignment
);
2358 void setRotation(double degrees
);
2359 void setPadding(const QMargins
&padding
);
2361 // reimplemented virtual methods:
2362 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2364 QCPItemPosition
* const position
;
2365 QCPItemAnchor
* const topLeft
;
2366 QCPItemAnchor
* const top
;
2367 QCPItemAnchor
* const topRight
;
2368 QCPItemAnchor
* const right
;
2369 QCPItemAnchor
* const bottomRight
;
2370 QCPItemAnchor
* const bottom
;
2371 QCPItemAnchor
* const bottomLeft
;
2372 QCPItemAnchor
* const left
;
2375 enum AnchorIndex
{aiTopLeft
, aiTop
, aiTopRight
, aiRight
, aiBottomRight
, aiBottom
, aiBottomLeft
, aiLeft
};
2377 // property members:
2378 QColor mColor
, mSelectedColor
;
2379 QPen mPen
, mSelectedPen
;
2380 QBrush mBrush
, mSelectedBrush
;
2381 QFont mFont
, mSelectedFont
;
2383 Qt::Alignment mPositionAlignment
;
2384 Qt::Alignment mTextAlignment
;
2388 // reimplemented virtual methods:
2389 virtual void draw(QCPPainter
*painter
);
2390 virtual QPointF
anchorPixelPoint(int anchorId
) const;
2392 // non-virtual methods:
2393 QPointF
getTextDrawPoint(const QPointF
&pos
, const QRectF
&rect
, Qt::Alignment positionAlignment
) const;
2394 QFont
mainFont() const;
2395 QColor
mainColor() const;
2396 QPen
mainPen() const;
2397 QBrush
mainBrush() const;
2401 class QCP_LIB_DECL QCPItemEllipse
: public QCPAbstractItem
2404 /// \cond INCLUDE_QPROPERTIES
2405 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2406 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2407 Q_PROPERTY(QBrush brush READ brush WRITE setBrush
)
2408 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush
)
2411 QCPItemEllipse(QCustomPlot
*parentPlot
);
2412 virtual ~QCPItemEllipse();
2415 QPen
pen() const { return mPen
; }
2416 QPen
selectedPen() const { return mSelectedPen
; }
2417 QBrush
brush() const { return mBrush
; }
2418 QBrush
selectedBrush() const { return mSelectedBrush
; }
2421 void setPen(const QPen
&pen
);
2422 void setSelectedPen(const QPen
&pen
);
2423 void setBrush(const QBrush
&brush
);
2424 void setSelectedBrush(const QBrush
&brush
);
2426 // reimplemented virtual methods:
2427 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2429 QCPItemPosition
* const topLeft
;
2430 QCPItemPosition
* const bottomRight
;
2431 QCPItemAnchor
* const topLeftRim
;
2432 QCPItemAnchor
* const top
;
2433 QCPItemAnchor
* const topRightRim
;
2434 QCPItemAnchor
* const right
;
2435 QCPItemAnchor
* const bottomRightRim
;
2436 QCPItemAnchor
* const bottom
;
2437 QCPItemAnchor
* const bottomLeftRim
;
2438 QCPItemAnchor
* const left
;
2439 QCPItemAnchor
* const center
;
2442 enum AnchorIndex
{aiTopLeftRim
, aiTop
, aiTopRightRim
, aiRight
, aiBottomRightRim
, aiBottom
, aiBottomLeftRim
, aiLeft
, aiCenter
};
2444 // property members:
2445 QPen mPen
, mSelectedPen
;
2446 QBrush mBrush
, mSelectedBrush
;
2448 // reimplemented virtual methods:
2449 virtual void draw(QCPPainter
*painter
);
2450 virtual QPointF
anchorPixelPoint(int anchorId
) const;
2452 // non-virtual methods:
2453 QPen
mainPen() const;
2454 QBrush
mainBrush() const;
2458 class QCP_LIB_DECL QCPItemPixmap
: public QCPAbstractItem
2461 /// \cond INCLUDE_QPROPERTIES
2462 Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap
)
2463 Q_PROPERTY(bool scaled READ scaled WRITE setScaled
)
2464 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode
)
2465 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2466 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2469 QCPItemPixmap(QCustomPlot
*parentPlot
);
2470 virtual ~QCPItemPixmap();
2473 QPixmap
pixmap() const { return mPixmap
; }
2474 bool scaled() const { return mScaled
; }
2475 Qt::AspectRatioMode
aspectRatioMode() const { return mAspectRatioMode
; }
2476 QPen
pen() const { return mPen
; }
2477 QPen
selectedPen() const { return mSelectedPen
; }
2480 void setPixmap(const QPixmap
&pixmap
);
2481 void setScaled(bool scaled
, Qt::AspectRatioMode aspectRatioMode
=Qt::KeepAspectRatio
);
2482 void setPen(const QPen
&pen
);
2483 void setSelectedPen(const QPen
&pen
);
2485 // reimplemented virtual methods:
2486 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2488 QCPItemPosition
* const topLeft
;
2489 QCPItemPosition
* const bottomRight
;
2490 QCPItemAnchor
* const top
;
2491 QCPItemAnchor
* const topRight
;
2492 QCPItemAnchor
* const right
;
2493 QCPItemAnchor
* const bottom
;
2494 QCPItemAnchor
* const bottomLeft
;
2495 QCPItemAnchor
* const left
;
2498 enum AnchorIndex
{aiTop
, aiTopRight
, aiRight
, aiBottom
, aiBottomLeft
, aiLeft
};
2500 // property members:
2502 QPixmap mScaledPixmap
;
2504 Qt::AspectRatioMode mAspectRatioMode
;
2505 QPen mPen
, mSelectedPen
;
2507 // reimplemented virtual methods:
2508 virtual void draw(QCPPainter
*painter
);
2509 virtual QPointF
anchorPixelPoint(int anchorId
) const;
2511 // non-virtual methods:
2512 void updateScaledPixmap(QRect finalRect
=QRect(), bool flipHorz
=false, bool flipVert
=false);
2513 QRect
getFinalRect(bool *flippedHorz
=0, bool *flippedVert
=0) const;
2514 QPen
mainPen() const;
2518 class QCP_LIB_DECL QCPItemTracer
: public QCPAbstractItem
2521 /// \cond INCLUDE_QPROPERTIES
2522 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2523 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2524 Q_PROPERTY(QBrush brush READ brush WRITE setBrush
)
2525 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush
)
2526 Q_PROPERTY(double size READ size WRITE setSize
)
2527 Q_PROPERTY(TracerStyle style READ style WRITE setStyle
)
2528 Q_PROPERTY(QCPGraph
* graph READ graph WRITE setGraph
)
2529 Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey
)
2530 Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating
)
2534 The different visual appearances a tracer item can have. Some styles size may be controlled with \ref setSize.
2538 enum TracerStyle
{ tsNone
///< The tracer is not visible
2539 ,tsPlus
///< A plus shaped crosshair with limited size
2540 ,tsCrosshair
///< A plus shaped crosshair which spans the complete axis rect
2541 ,tsCircle
///< A circle
2542 ,tsSquare
///< A square
2544 Q_ENUMS(TracerStyle
)
2546 QCPItemTracer(QCustomPlot
*parentPlot
);
2547 virtual ~QCPItemTracer();
2550 QPen
pen() const { return mPen
; }
2551 QPen
selectedPen() const { return mSelectedPen
; }
2552 QBrush
brush() const { return mBrush
; }
2553 QBrush
selectedBrush() const { return mSelectedBrush
; }
2554 double size() const { return mSize
; }
2555 TracerStyle
style() const { return mStyle
; }
2556 QCPGraph
*graph() const { return mGraph
; }
2557 double graphKey() const { return mGraphKey
; }
2558 bool interpolating() const { return mInterpolating
; }
2561 void setPen(const QPen
&pen
);
2562 void setSelectedPen(const QPen
&pen
);
2563 void setBrush(const QBrush
&brush
);
2564 void setSelectedBrush(const QBrush
&brush
);
2565 void setSize(double size
);
2566 void setStyle(TracerStyle style
);
2567 void setGraph(QCPGraph
*graph
);
2568 void setGraphKey(double key
);
2569 void setInterpolating(bool enabled
);
2571 // reimplemented virtual methods:
2572 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2574 // non-virtual methods:
2575 void updatePosition();
2577 QCPItemPosition
* const position
;
2580 // property members:
2581 QPen mPen
, mSelectedPen
;
2582 QBrush mBrush
, mSelectedBrush
;
2587 bool mInterpolating
;
2589 // reimplemented virtual methods:
2590 virtual void draw(QCPPainter
*painter
);
2592 // non-virtual methods:
2593 QPen
mainPen() const;
2594 QBrush
mainBrush() const;
2598 class QCP_LIB_DECL QCPItemBracket
: public QCPAbstractItem
2601 /// \cond INCLUDE_QPROPERTIES
2602 Q_PROPERTY(QPen pen READ pen WRITE setPen
)
2603 Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen
)
2604 Q_PROPERTY(double length READ length WRITE setLength
)
2605 Q_PROPERTY(BracketStyle style READ style WRITE setStyle
)
2608 enum BracketStyle
{ bsSquare
///< A brace with angled edges
2609 ,bsRound
///< A brace with round edges
2610 ,bsCurly
///< A curly brace
2611 ,bsCalligraphic
///< A curly brace with varying stroke width giving a calligraphic impression
2614 QCPItemBracket(QCustomPlot
*parentPlot
);
2615 virtual ~QCPItemBracket();
2618 QPen
pen() const { return mPen
; }
2619 QPen
selectedPen() const { return mSelectedPen
; }
2620 double length() const { return mLength
; }
2621 BracketStyle
style() const { return mStyle
; }
2624 void setPen(const QPen
&pen
);
2625 void setSelectedPen(const QPen
&pen
);
2626 void setLength(double length
);
2627 void setStyle(BracketStyle style
);
2629 // reimplemented virtual methods:
2630 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2632 QCPItemPosition
* const left
;
2633 QCPItemPosition
* const right
;
2634 QCPItemAnchor
* const center
;
2637 // property members:
2638 enum AnchorIndex
{aiCenter
};
2639 QPen mPen
, mSelectedPen
;
2641 BracketStyle mStyle
;
2643 // reimplemented virtual methods:
2644 virtual void draw(QCPPainter
*painter
);
2645 virtual QPointF
anchorPixelPoint(int anchorId
) const;
2647 // non-virtual methods:
2648 QPen
mainPen() const;
2652 class QCP_LIB_DECL QCPAxisRect
: public QCPLayoutElement
2655 /// \cond INCLUDE_QPROPERTIES
2656 Q_PROPERTY(QPixmap background READ background WRITE setBackground
)
2657 Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled
)
2658 Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode
)
2659 Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag
)
2660 Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom
)
2663 explicit QCPAxisRect(QCustomPlot
*parentPlot
, bool setupDefaultAxes
=true);
2664 virtual ~QCPAxisRect();
2667 QPixmap
background() const { return mBackgroundPixmap
; }
2668 bool backgroundScaled() const { return mBackgroundScaled
; }
2669 Qt::AspectRatioMode
backgroundScaledMode() const { return mBackgroundScaledMode
; }
2670 Qt::Orientations
rangeDrag() const { return mRangeDrag
; }
2671 Qt::Orientations
rangeZoom() const { return mRangeZoom
; }
2672 QCPAxis
*rangeDragAxis(Qt::Orientation orientation
);
2673 QCPAxis
*rangeZoomAxis(Qt::Orientation orientation
);
2674 double rangeZoomFactor(Qt::Orientation orientation
);
2677 void setBackground(const QPixmap
&pm
);
2678 void setBackground(const QPixmap
&pm
, bool scaled
, Qt::AspectRatioMode mode
=Qt::KeepAspectRatioByExpanding
);
2679 void setBackground(const QBrush
&brush
);
2680 void setBackgroundScaled(bool scaled
);
2681 void setBackgroundScaledMode(Qt::AspectRatioMode mode
);
2682 void setRangeDrag(Qt::Orientations orientations
);
2683 void setRangeZoom(Qt::Orientations orientations
);
2684 void setRangeDragAxes(QCPAxis
*horizontal
, QCPAxis
*vertical
);
2685 void setRangeZoomAxes(QCPAxis
*horizontal
, QCPAxis
*vertical
);
2686 void setRangeZoomFactor(double horizontalFactor
, double verticalFactor
);
2687 void setRangeZoomFactor(double factor
);
2689 // non-property methods:
2690 int axisCount(QCPAxis::AxisType type
) const;
2691 QCPAxis
*axis(QCPAxis::AxisType type
, int index
=0) const;
2692 QList
<QCPAxis
*> axes(QCPAxis::AxisTypes types
) const;
2693 QList
<QCPAxis
*> axes() const;
2694 QCPAxis
*addAxis(QCPAxis::AxisType type
);
2695 QList
<QCPAxis
*> addAxes(QCPAxis::AxisTypes types
);
2696 bool removeAxis(QCPAxis
*axis
);
2697 QCPLayoutInset
*insetLayout() const { return mInsetLayout
; }
2699 void setupFullAxesBox(bool connectRanges
=false);
2700 QList
<QCPAbstractPlottable
*> plottables() const;
2701 QList
<QCPGraph
*> graphs() const;
2702 QList
<QCPAbstractItem
*> items() const;
2704 // read-only interface imitating a QRect:
2705 int left() const { return mRect
.left(); }
2706 int right() const { return mRect
.right(); }
2707 int top() const { return mRect
.top(); }
2708 int bottom() const { return mRect
.bottom(); }
2709 int width() const { return mRect
.width(); }
2710 int height() const { return mRect
.height(); }
2711 QSize
size() const { return mRect
.size(); }
2712 QPoint
topLeft() const { return mRect
.topLeft(); }
2713 QPoint
topRight() const { return mRect
.topRight(); }
2714 QPoint
bottomLeft() const { return mRect
.bottomLeft(); }
2715 QPoint
bottomRight() const { return mRect
.bottomRight(); }
2716 QPoint
center() const { return mRect
.center(); }
2718 // reimplemented virtual methods:
2719 virtual void update();
2720 virtual QList
<QCPLayoutElement
*> elements(bool recursive
) const;
2723 // property members:
2724 QBrush mBackgroundBrush
;
2725 QPixmap mBackgroundPixmap
;
2726 QPixmap mScaledBackgroundPixmap
;
2727 bool mBackgroundScaled
;
2728 Qt::AspectRatioMode mBackgroundScaledMode
;
2729 QCPLayoutInset
*mInsetLayout
;
2730 Qt::Orientations mRangeDrag
, mRangeZoom
;
2731 QWeakPointer
<QCPAxis
> mRangeDragHorzAxis
, mRangeDragVertAxis
, mRangeZoomHorzAxis
, mRangeZoomVertAxis
;
2732 double mRangeZoomFactorHorz
, mRangeZoomFactorVert
;
2733 // non-property members:
2734 QCPRange mDragStartHorzRange
, mDragStartVertRange
;
2735 QCP::AntialiasedElements mAADragBackup
, mNotAADragBackup
;
2738 QHash
<QCPAxis::AxisType
, QList
<QCPAxis
*> > mAxes
;
2740 // reimplemented virtual methods:
2741 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const;
2742 virtual void draw(QCPPainter
*painter
);
2743 virtual int calculateAutoMargin(QCP::MarginSide side
);
2745 virtual void mousePressEvent(QMouseEvent
*event
);
2746 virtual void mouseMoveEvent(QMouseEvent
*event
);
2747 virtual void mouseReleaseEvent(QMouseEvent
*event
);
2748 virtual void wheelEvent(QWheelEvent
*event
);
2750 // non-property methods:
2751 void drawBackground(QCPPainter
*painter
);
2752 void updateAxesOffset(QCPAxis::AxisType type
);
2755 Q_DISABLE_COPY(QCPAxisRect
)
2757 friend class QCustomPlot
;
2761 class QCP_LIB_DECL QCPAbstractLegendItem
: public QCPLayoutElement
2764 /// \cond INCLUDE_QPROPERTIES
2765 Q_PROPERTY(QCPLegend
* parentLegend READ parentLegend
)
2766 Q_PROPERTY(QFont font READ font WRITE setFont
)
2767 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor
)
2768 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont
)
2769 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor
)
2770 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable
)
2771 Q_PROPERTY(bool selected READ selected WRITE setSelected
)
2774 explicit QCPAbstractLegendItem(QCPLegend
*parent
);
2777 QCPLegend
*parentLegend() const { return mParentLegend
; }
2778 QFont
font() const { return mFont
; }
2779 QColor
textColor() const { return mTextColor
; }
2780 QFont
selectedFont() const { return mSelectedFont
; }
2781 QColor
selectedTextColor() const { return mSelectedTextColor
; }
2782 bool selectable() const { return mSelectable
; }
2783 bool selected() const { return mSelected
; }
2786 void setFont(const QFont
&font
);
2787 void setTextColor(const QColor
&color
);
2788 void setSelectedFont(const QFont
&font
);
2789 void setSelectedTextColor(const QColor
&color
);
2790 void setSelectable(bool selectable
);
2791 void setSelected(bool selected
);
2793 // reimplemented virtual methods:
2794 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2797 void selectionChanged(bool selected
);
2800 // property members:
2801 QCPLegend
*mParentLegend
;
2804 QFont mSelectedFont
;
2805 QColor mSelectedTextColor
;
2806 bool mSelectable
, mSelected
;
2808 // reimplemented virtual methods:
2809 virtual QCP::Interaction
selectionCategory() const;
2810 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const;
2811 virtual QRect
clipRect() const;
2812 virtual void draw(QCPPainter
*painter
) = 0;
2814 virtual void selectEvent(QMouseEvent
*event
, bool additive
, const QVariant
&details
, bool *selectionStateChanged
);
2815 virtual void deselectEvent(bool *selectionStateChanged
);
2818 Q_DISABLE_COPY(QCPAbstractLegendItem
)
2820 friend class QCPLegend
;
2824 class QCP_LIB_DECL QCPPlottableLegendItem
: public QCPAbstractLegendItem
2828 QCPPlottableLegendItem(QCPLegend
*parent
, QCPAbstractPlottable
*plottable
);
2831 QCPAbstractPlottable
*plottable() { return mPlottable
; }
2834 // property members:
2835 QCPAbstractPlottable
*mPlottable
;
2837 // reimplemented virtual methods:
2838 virtual void draw(QCPPainter
*painter
);
2839 virtual QSize
minimumSizeHint() const;
2841 // non-virtual methods:
2842 QPen
getIconBorderPen() const;
2843 QColor
getTextColor() const;
2844 QFont
getFont() const;
2848 class QCP_LIB_DECL QCPLegend
: public QCPLayoutGrid
2851 /// \cond INCLUDE_QPROPERTIES
2852 Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen
)
2853 Q_PROPERTY(QBrush brush READ brush WRITE setBrush
)
2854 Q_PROPERTY(QFont font READ font WRITE setFont
)
2855 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor
)
2856 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize
)
2857 Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding
)
2858 Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen
)
2859 Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts
)
2860 Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts
)
2861 Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen
)
2862 Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen
)
2863 Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush
)
2864 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont
)
2865 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor
)
2869 Defines the selectable parts of a legend
2871 \see setSelectedParts, setSelectableParts
2873 enum SelectablePart
{ spNone
= 0x000 ///< <tt>0x000</tt> None
2874 ,spLegendBox
= 0x001 ///< <tt>0x001</tt> The legend box (frame)
2875 ,spItems
= 0x002 ///< <tt>0x002</tt> Legend items individually (see \ref selectedItems)
2877 Q_FLAGS(SelectablePart SelectableParts
)
2878 Q_DECLARE_FLAGS(SelectableParts
, SelectablePart
)
2880 explicit QCPLegend();
2881 virtual ~QCPLegend();
2884 QPen
borderPen() const { return mBorderPen
; }
2885 QBrush
brush() const { return mBrush
; }
2886 QFont
font() const { return mFont
; }
2887 QColor
textColor() const { return mTextColor
; }
2888 QSize
iconSize() const { return mIconSize
; }
2889 int iconTextPadding() const { return mIconTextPadding
; }
2890 QPen
iconBorderPen() const { return mIconBorderPen
; }
2891 SelectableParts
selectableParts() const { return mSelectableParts
; }
2892 SelectableParts
selectedParts() const;
2893 QPen
selectedBorderPen() const { return mSelectedBorderPen
; }
2894 QPen
selectedIconBorderPen() const { return mSelectedIconBorderPen
; }
2895 QBrush
selectedBrush() const { return mSelectedBrush
; }
2896 QFont
selectedFont() const { return mSelectedFont
; }
2897 QColor
selectedTextColor() const { return mSelectedTextColor
; }
2900 void setBorderPen(const QPen
&pen
);
2901 void setBrush(const QBrush
&brush
);
2902 void setFont(const QFont
&font
);
2903 void setTextColor(const QColor
&color
);
2904 void setIconSize(const QSize
&size
);
2905 void setIconSize(int width
, int height
);
2906 void setIconTextPadding(int padding
);
2907 void setIconBorderPen(const QPen
&pen
);
2908 void setSelectableParts(const SelectableParts
&selectableParts
);
2909 void setSelectedParts(const SelectableParts
&selectedParts
);
2910 void setSelectedBorderPen(const QPen
&pen
);
2911 void setSelectedIconBorderPen(const QPen
&pen
);
2912 void setSelectedBrush(const QBrush
&brush
);
2913 void setSelectedFont(const QFont
&font
);
2914 void setSelectedTextColor(const QColor
&color
);
2916 // reimplemented virtual methods:
2917 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
2919 // non-virtual methods:
2920 QCPAbstractLegendItem
*item(int index
) const;
2921 QCPPlottableLegendItem
*itemWithPlottable(const QCPAbstractPlottable
*plottable
) const;
2922 int itemCount() const;
2923 bool hasItem(QCPAbstractLegendItem
*item
) const;
2924 bool hasItemWithPlottable(const QCPAbstractPlottable
*plottable
) const;
2925 bool addItem(QCPAbstractLegendItem
*item
);
2926 bool removeItem(int index
);
2927 bool removeItem(QCPAbstractLegendItem
*item
);
2929 QList
<QCPAbstractLegendItem
*> selectedItems() const;
2932 void selectionChanged(QCPLegend::SelectableParts selection
);
2935 // property members:
2936 QPen mBorderPen
, mIconBorderPen
;
2941 int mIconTextPadding
;
2942 SelectableParts mSelectedParts
, mSelectableParts
;
2943 QPen mSelectedBorderPen
, mSelectedIconBorderPen
;
2944 QBrush mSelectedBrush
;
2945 QFont mSelectedFont
;
2946 QColor mSelectedTextColor
;
2948 // reimplemented virtual methods:
2949 virtual void parentPlotInitialized(QCustomPlot
*parentPlot
);
2950 virtual QCP::Interaction
selectionCategory() const;
2951 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const;
2952 virtual void draw(QCPPainter
*painter
);
2954 virtual void selectEvent(QMouseEvent
*event
, bool additive
, const QVariant
&details
, bool *selectionStateChanged
);
2955 virtual void deselectEvent(bool *selectionStateChanged
);
2957 // non-virtual methods:
2958 QPen
getBorderPen() const;
2959 QBrush
getBrush() const;
2962 Q_DISABLE_COPY(QCPLegend
)
2964 friend class QCustomPlot
;
2965 friend class QCPAbstractLegendItem
;
2967 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts
)
2968 Q_DECLARE_METATYPE(QCPLegend::SelectablePart
)
2971 class QCP_LIB_DECL QCPPlotTitle
: public QCPLayoutElement
2974 /// \cond INCLUDE_QPROPERTIES
2975 Q_PROPERTY(QString text READ text WRITE setText
)
2976 Q_PROPERTY(QFont font READ font WRITE setFont
)
2977 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor
)
2978 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont
)
2979 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor
)
2980 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable
)
2981 Q_PROPERTY(bool selected READ selected WRITE setSelected
)
2984 explicit QCPPlotTitle(QCustomPlot
*parentPlot
);
2985 explicit QCPPlotTitle(QCustomPlot
*parentPlot
, const QString
&text
);
2988 QString
text() const { return mText
; }
2989 QFont
font() const { return mFont
; }
2990 QColor
textColor() const { return mTextColor
; }
2991 QFont
selectedFont() const { return mSelectedFont
; }
2992 QColor
selectedTextColor() const { return mSelectedTextColor
; }
2993 bool selectable() const { return mSelectable
; }
2994 bool selected() const { return mSelected
; }
2997 void setText(const QString
&text
);
2998 void setFont(const QFont
&font
);
2999 void setTextColor(const QColor
&color
);
3000 void setSelectedFont(const QFont
&font
);
3001 void setSelectedTextColor(const QColor
&color
);
3002 void setSelectable(bool selectable
);
3003 void setSelected(bool selected
);
3005 // reimplemented virtual methods:
3006 virtual double selectTest(const QPointF
&pos
, bool onlySelectable
, QVariant
*details
=0) const;
3009 void selectionChanged(bool selected
);
3012 // property members:
3016 QFont mSelectedFont
;
3017 QColor mSelectedTextColor
;
3018 QRect mTextBoundingRect
;
3019 bool mSelectable
, mSelected
;
3021 // reimplemented virtual methods:
3022 virtual void applyDefaultAntialiasingHint(QCPPainter
*painter
) const;
3023 virtual void draw(QCPPainter
*painter
);
3024 virtual QSize
minimumSizeHint() const;
3025 virtual QSize
maximumSizeHint() const;
3027 virtual void selectEvent(QMouseEvent
*event
, bool additive
, const QVariant
&details
, bool *selectionStateChanged
);
3028 virtual void deselectEvent(bool *selectionStateChanged
);
3030 // non-virtual methods:
3031 QFont
mainFont() const;
3032 QColor
mainTextColor() const;
3035 Q_DISABLE_COPY(QCPPlotTitle
)
3038 #endif // QCUSTOMPLOT_H