Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
qcustomplot.h
Go to the documentation of this file.
1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
5 ** **
6 ** This program is free software: you can redistribute it and/or modify **
7 ** it under the terms of the GNU General Public License as published by **
8 ** the Free Software Foundation, either version 2 of the License, or **
9 ** (at your option) any later version. **
10 ** **
11 ** This program is distributed in the hope that it will be useful, **
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
14 ** GNU General Public License for more details. **
15 ** **
16 ** You should have received a copy of the GNU General Public License **
17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
18 ** **
19 ****************************************************************************
20 ** Author: Emanuel Eichhammer **
21 ** Website/Contact: http://www.qcustomplot.com/ **
22 ** Emanuel Eichhammer has granted Wireshark permission to use QCustomPlot **
23 ** under the terms of the GNU General Public License version 2. **
24 ** Date: 27.12.14 **
25 ** Version: 1.3.0 **
26 ****************************************************************************/
27 
28 #ifndef QCUSTOMPLOT_H
29 #define QCUSTOMPLOT_H
30 
31 #include <QObject>
32 #include <QPointer>
33 #include <QWidget>
34 #include <QPainter>
35 #include <QPaintEvent>
36 #include <QMouseEvent>
37 #include <QPixmap>
38 #include <QVector>
39 #include <QString>
40 #include <QDateTime>
41 #include <QMultiMap>
42 #include <QFlags>
43 #include <QDebug>
44 #include <QVector2D>
45 #include <QStack>
46 #include <QCache>
47 #include <QMargins>
48 #include <qmath.h>
49 #include <limits>
50 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
51 # include <qnumeric.h>
52 # include <QPrinter>
53 # include <QPrintEngine>
54 #else
55 # include <QtNumeric>
56 # include <QtPrintSupport>
57 #endif
58 
59 class QCPPainter;
60 class QCustomPlot;
61 class QCPLayerable;
62 class QCPLayoutElement;
63 class QCPLayout;
64 class QCPAxis;
65 class QCPAxisRect;
68 class QCPGraph;
69 class QCPAbstractItem;
70 class QCPItemPosition;
71 class QCPLayer;
72 class QCPPlotTitle;
73 class QCPLegend;
75 class QCPColorMap;
76 class QCPColorScale;
77 class QCPBars;
78 
79 
83 // decl definitions for shared library compilation/usage:
84 #if defined(QCUSTOMPLOT_COMPILE_LIBRARY)
85 # define QCP_LIB_DECL Q_DECL_EXPORT
86 #elif defined(QCUSTOMPLOT_USE_LIBRARY)
87 # define QCP_LIB_DECL Q_DECL_IMPORT
88 #else
89 # define QCP_LIB_DECL
90 #endif
91 
95 namespace QCP
96 {
102 enum MarginSide { msLeft = 0x01
103  ,msRight = 0x02
104  ,msTop = 0x04
105  ,msBottom = 0x08
106  ,msAll = 0xFF
107  ,msNone = 0x00
108  };
109 Q_DECLARE_FLAGS(MarginSides, MarginSide)
110 
111 
120 enum AntialiasedElement { aeAxes = 0x0001
121  ,aeGrid = 0x0002
122  ,aeSubGrid = 0x0004
123  ,aeLegend = 0x0008
124  ,aeLegendItems = 0x0010
125  ,aePlottables = 0x0020
126  ,aeItems = 0x0040
127  ,aeScatters = 0x0080
128  ,aeErrorBars = 0x0100
129  ,aeFills = 0x0200
130  ,aeZeroLine = 0x0400
131  ,aeAll = 0xFFFF
132  ,aeNone = 0x0000
133  };
134 Q_DECLARE_FLAGS(AntialiasedElements, AntialiasedElement)
135 
136 
141 enum PlottingHint { phNone = 0x000
142  ,phFastPolylines = 0x001
143  ,phForceRepaint = 0x002
145  ,phCacheLabels = 0x004
147  };
148 Q_DECLARE_FLAGS(PlottingHints, PlottingHint)
149 
150 
157 enum Interaction { iRangeDrag = 0x001
158  ,iRangeZoom = 0x002
159  ,iMultiSelect = 0x004
161  ,iSelectAxes = 0x010
162  ,iSelectLegend = 0x020
163  ,iSelectItems = 0x040
164  ,iSelectOther = 0x080
165  };
166 Q_DECLARE_FLAGS(Interactions, Interaction)
167 
168 
174 inline bool isInvalidData(double value)
175 {
176  return qIsNaN(value) || qIsInf(value);
177 }
178 
184 inline bool isInvalidData(double value1, double value2)
185 {
186  return isInvalidData(value1) || isInvalidData(value2);
187 }
188 
195 inline void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
196 {
197  switch (side)
198  {
199  case QCP::msLeft: margins.setLeft(value); break;
200  case QCP::msRight: margins.setRight(value); break;
201  case QCP::msTop: margins.setTop(value); break;
202  case QCP::msBottom: margins.setBottom(value); break;
203  case QCP::msAll: margins = QMargins(value, value, value, value); break;
204  default: break;
205  }
206 }
207 
215 inline int getMarginValue(const QMargins &margins, QCP::MarginSide side)
216 {
217  switch (side)
218  {
219  case QCP::msLeft: return margins.left();
220  case QCP::msRight: return margins.right();
221  case QCP::msTop: return margins.top();
222  case QCP::msBottom: return margins.bottom();
223  default: break;
224  }
225  return 0;
226 }
227 
228 } // end of namespace QCP
229 
230 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::AntialiasedElements)
231 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::PlottingHints)
232 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::MarginSides)
233 Q_DECLARE_OPERATORS_FOR_FLAGS(QCP::Interactions)
234 
235 
236 class QCP_LIB_DECL QCPScatterStyle
237 {
238  Q_GADGET
239 public:
247  Q_ENUMS(ScatterShape)
248  enum ScatterShape { ssNone
249  ,ssDot
250  ,ssCross
251  ,ssPlus
252  ,ssCircle
253  ,ssDisc
254  ,ssSquare
255  ,ssDiamond
256  ,ssStar
257  ,ssTriangle
258  ,ssTriangleInverted
259  ,ssCrossSquare
260  ,ssPlusSquare
261  ,ssCrossCircle
262  ,ssPlusCircle
263  ,ssPeace
264  ,ssPixmap
265  ,ssCustom
266  };
267 
268  QCPScatterStyle();
269  QCPScatterStyle(ScatterShape shape, double size=6);
270  QCPScatterStyle(ScatterShape shape, const QColor &color, double size);
271  QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size);
272  QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size);
273  QCPScatterStyle(const QPixmap &pixmap);
274  QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush=Qt::NoBrush, double size=6);
275 
276  // getters:
277  double size() const { return mSize; }
278  ScatterShape shape() const { return mShape; }
279  QPen pen() const { return mPen; }
280  QBrush brush() const { return mBrush; }
281  QPixmap pixmap() const { return mPixmap; }
282  QPainterPath customPath() const { return mCustomPath; }
283 
284  // setters:
285  void setSize(double size);
286  void setShape(ScatterShape shape);
287  void setPen(const QPen &pen);
288  void setBrush(const QBrush &brush);
289  void setPixmap(const QPixmap &pixmap);
290  void setCustomPath(const QPainterPath &customPath);
291 
292  // non-property methods:
293  bool isNone() const { return mShape == ssNone; }
294  bool isPenDefined() const { return mPenDefined; }
295  void applyTo(QCPPainter *painter, const QPen &defaultPen) const;
296  void drawShape(QCPPainter *painter, QPointF pos) const;
297  void drawShape(QCPPainter *painter, double x, double y) const;
298 
299 protected:
300  // property members:
301  double mSize;
302  ScatterShape mShape;
303  QPen mPen;
304  QBrush mBrush;
305  QPixmap mPixmap;
306  QPainterPath mCustomPath;
307 
308  // non-property members:
309  bool mPenDefined;
310 };
311 Q_DECLARE_TYPEINFO(QCPScatterStyle, Q_MOVABLE_TYPE);
312 
313 
314 class QCP_LIB_DECL QCPPainter : public QPainter
315 {
316  Q_GADGET
317 public:
322  enum PainterMode { pmDefault = 0x00
323  ,pmVectorized = 0x01
324  ,pmNoCaching = 0x02
325  ,pmNonCosmetic = 0x04
326  };
327  Q_FLAGS(PainterMode PainterModes)
328  Q_DECLARE_FLAGS(PainterModes, PainterMode)
329 
330  QCPPainter();
331  QCPPainter(QPaintDevice *device);
332  ~QCPPainter();
333 
334  // getters:
335  bool antialiasing() const { return testRenderHint(QPainter::Antialiasing); }
336  PainterModes modes() const { return mModes; }
337 
338  // setters:
339  void setAntialiasing(bool enabled);
340  void setMode(PainterMode mode, bool enabled=true);
341  void setModes(PainterModes modes);
342 
343  // methods hiding non-virtual base class functions (QPainter bug workarounds):
344  bool begin(QPaintDevice *device);
345  void setPen(const QPen &pen);
346  void setPen(const QColor &color);
347  void setPen(Qt::PenStyle penStyle);
348  void drawLine(const QLineF &line);
349  void drawLine(const QPointF &p1, const QPointF &p2) {drawLine(QLineF(p1, p2));}
350  void save();
351  void restore();
352 
353  // non-virtual methods:
354  void makeNonCosmetic();
355 
356 protected:
357  // property members:
358  PainterModes mModes;
359  bool mIsAntialiasing;
360 
361  // non-property members:
362  QStack<bool> mAntialiasingStack;
363 };
364 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPPainter::PainterModes)
365 
366 
367 class QCP_LIB_DECL QCPLayer : public QObject
368 {
369  Q_OBJECT
371  Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
372  Q_PROPERTY(QString name READ name)
373  Q_PROPERTY(int index READ index)
374  Q_PROPERTY(QList<QCPLayerable*> children READ children)
375  Q_PROPERTY(bool visible READ visible WRITE setVisible)
377 public:
378  QCPLayer(QCustomPlot* parentPlot, const QString &layerName);
379  ~QCPLayer();
380 
381  // getters:
382  QCustomPlot *parentPlot() const { return mParentPlot; }
383  QString name() const { return mName; }
384  int index() const { return mIndex; }
385  QList<QCPLayerable*> children() const { return mChildren; }
386  bool visible() const { return mVisible; }
387 
388  // setters:
389  void setVisible(bool visible);
390 
391 protected:
392  // property members:
393  QCustomPlot *mParentPlot;
394  QString mName;
395  int mIndex;
396  QList<QCPLayerable*> mChildren;
397  bool mVisible;
398 
399  // non-virtual methods:
400  void addChild(QCPLayerable *layerable, bool prepend);
401  void removeChild(QCPLayerable *layerable);
402 
403 private:
404  Q_DISABLE_COPY(QCPLayer)
405 
406  friend class QCustomPlot;
407  friend class QCPLayerable;
408 };
409 
410 class QCP_LIB_DECL QCPLayerable : public QObject
411 {
412  Q_OBJECT
414  Q_PROPERTY(bool visible READ visible WRITE setVisible)
415  Q_PROPERTY(QCustomPlot* parentPlot READ parentPlot)
416  Q_PROPERTY(QCPLayerable* parentLayerable READ parentLayerable)
417  Q_PROPERTY(QCPLayer* layer READ layer WRITE setLayer NOTIFY layerChanged)
418  Q_PROPERTY(bool antialiased READ antialiased WRITE setAntialiased)
420 public:
421  QCPLayerable(QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0);
422  ~QCPLayerable();
423 
424  // getters:
425  bool visible() const { return mVisible; }
426  QCustomPlot *parentPlot() const { return mParentPlot; }
427  QCPLayerable *parentLayerable() const { return mParentLayerable.data(); }
428  QCPLayer *layer() const { return mLayer; }
429  bool antialiased() const { return mAntialiased; }
430 
431  // setters:
432  void setVisible(bool on);
433  Q_SLOT bool setLayer(QCPLayer *layer);
434  bool setLayer(const QString &layerName);
435  void setAntialiased(bool enabled);
436 
437  // introduced virtual methods:
438  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
439 
440  // non-property methods:
441  bool realVisibility() const;
442 
443 signals:
444  void layerChanged(QCPLayer *newLayer);
445 
446 protected:
447  // property members:
448  bool mVisible;
449  QCustomPlot *mParentPlot;
450  QPointer<QCPLayerable> mParentLayerable;
451  QCPLayer *mLayer;
452  bool mAntialiased;
453 
454  // introduced virtual methods:
455  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
456  virtual QCP::Interaction selectionCategory() const;
457  virtual QRect clipRect() const;
458  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0;
459  virtual void draw(QCPPainter *painter) = 0;
460  // events:
461  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
462  virtual void deselectEvent(bool *selectionStateChanged);
463 
464  // non-property methods:
465  void initializeParentPlot(QCustomPlot *parentPlot);
466  void setParentLayerable(QCPLayerable* parentLayerable);
467  bool moveToLayer(QCPLayer *layer, bool prepend);
468  void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const;
469 
470 private:
471  Q_DISABLE_COPY(QCPLayerable)
472 
473  friend class QCustomPlot;
474  friend class QCPAxisRect;
475 };
476 
477 
478 class QCP_LIB_DECL QCPRange
479 {
480 public:
481  double lower, upper;
482 
483  QCPRange();
484  QCPRange(double lower, double upper);
485 
486  bool operator==(const QCPRange& other) const { return lower == other.lower && upper == other.upper; }
487  bool operator!=(const QCPRange& other) const { return !(*this == other); }
488 
489  QCPRange &operator+=(const double& value) { lower+=value; upper+=value; return *this; }
490  QCPRange &operator-=(const double& value) { lower-=value; upper-=value; return *this; }
491  QCPRange &operator*=(const double& value) { lower*=value; upper*=value; return *this; }
492  QCPRange &operator/=(const double& value) { lower/=value; upper/=value; return *this; }
493  friend inline const QCPRange operator+(const QCPRange&, double);
494  friend inline const QCPRange operator+(double, const QCPRange&);
495  friend inline const QCPRange operator-(const QCPRange& range, double value);
496  friend inline const QCPRange operator*(const QCPRange& range, double value);
497  friend inline const QCPRange operator*(double value, const QCPRange& range);
498  friend inline const QCPRange operator/(const QCPRange& range, double value);
499 
500  double size() const;
501  double center() const;
502  void normalize();
503  void expand(const QCPRange &otherRange);
504  QCPRange expanded(const QCPRange &otherRange) const;
505  QCPRange sanitizedForLogScale() const;
506  QCPRange sanitizedForLinScale() const;
507  bool contains(double value) const;
508 
509  static bool validRange(double lower, double upper);
510  static bool validRange(const QCPRange &range);
511  static const double minRange; //1e-280;
512  static const double maxRange; //1e280;
513 
514 };
515 Q_DECLARE_TYPEINFO(QCPRange, Q_MOVABLE_TYPE);
516 
517 /* documentation of inline functions */
518 
539 /* end documentation of inline functions */
540 
544 inline const QCPRange operator+(const QCPRange& range, double value)
545 {
546  QCPRange result(range);
547  result += value;
548  return result;
549 }
550 
554 inline const QCPRange operator+(double value, const QCPRange& range)
555 {
556  QCPRange result(range);
557  result += value;
558  return result;
559 }
560 
564 inline const QCPRange operator-(const QCPRange& range, double value)
565 {
566  QCPRange result(range);
567  result -= value;
568  return result;
569 }
570 
574 inline const QCPRange operator*(const QCPRange& range, double value)
575 {
576  QCPRange result(range);
577  result *= value;
578  return result;
579 }
580 
584 inline const QCPRange operator*(double value, const QCPRange& range)
585 {
586  QCPRange result(range);
587  result *= value;
588  return result;
589 }
590 
594 inline const QCPRange operator/(const QCPRange& range, double value)
595 {
596  QCPRange result(range);
597  result /= value;
598  return result;
599 }
600 
601 
602 class QCP_LIB_DECL QCPMarginGroup : public QObject
603 {
604  Q_OBJECT
605 public:
606  QCPMarginGroup(QCustomPlot *parentPlot);
607  ~QCPMarginGroup();
608 
609  // non-virtual methods:
610  QList<QCPLayoutElement*> elements(QCP::MarginSide side) const { return mChildren.value(side); }
611  bool isEmpty() const;
612  void clear();
613 
614 protected:
615  // non-property members:
616  QCustomPlot *mParentPlot;
617  QHash<QCP::MarginSide, QList<QCPLayoutElement*> > mChildren;
618 
619  // non-virtual methods:
620  int commonMargin(QCP::MarginSide side) const;
621  void addChild(QCP::MarginSide side, QCPLayoutElement *element);
622  void removeChild(QCP::MarginSide side, QCPLayoutElement *element);
623 
624 private:
625  Q_DISABLE_COPY(QCPMarginGroup)
626 
627  friend class QCPLayoutElement;
628 };
629 
630 
631 class QCP_LIB_DECL QCPLayoutElement : public QCPLayerable
632 {
633  Q_OBJECT
635  Q_PROPERTY(QCPLayout* layout READ layout)
636  Q_PROPERTY(QRect rect READ rect)
637  Q_PROPERTY(QRect outerRect READ outerRect WRITE setOuterRect)
638  Q_PROPERTY(QMargins margins READ margins WRITE setMargins)
639  Q_PROPERTY(QMargins minimumMargins READ minimumMargins WRITE setMinimumMargins)
640  Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
641  Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
643 public:
648  enum UpdatePhase { upPreparation
649  ,upMargins
650  ,upLayout
651  };
652  Q_ENUMS(UpdatePhase)
653 
654  explicit QCPLayoutElement(QCustomPlot *parentPlot=0);
655  virtual ~QCPLayoutElement();
656 
657  // getters:
658  QCPLayout *layout() const { return mParentLayout; }
659  QRect rect() const { return mRect; }
660  QRect outerRect() const { return mOuterRect; }
661  QMargins margins() const { return mMargins; }
662  QMargins minimumMargins() const { return mMinimumMargins; }
663  QCP::MarginSides autoMargins() const { return mAutoMargins; }
664  QSize minimumSize() const { return mMinimumSize; }
665  QSize maximumSize() const { return mMaximumSize; }
666  QCPMarginGroup *marginGroup(QCP::MarginSide side) const { return mMarginGroups.value(side, (QCPMarginGroup*)0); }
667  QHash<QCP::MarginSide, QCPMarginGroup*> marginGroups() const { return mMarginGroups; }
668 
669  // setters:
670  void setOuterRect(const QRect &rect);
671  void setMargins(const QMargins &margins);
672  void setMinimumMargins(const QMargins &margins);
673  void setAutoMargins(QCP::MarginSides sides);
674  void setMinimumSize(const QSize &size);
675  void setMinimumSize(int width, int height);
676  void setMaximumSize(const QSize &size);
677  void setMaximumSize(int width, int height);
678  void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group);
679 
680  // introduced virtual methods:
681  virtual void update(UpdatePhase phase);
682  virtual QSize minimumSizeHint() const;
683  virtual QSize maximumSizeHint() const;
684  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
685 
686  // reimplemented virtual methods:
687  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
688 
689 protected:
690  // property members:
691  QCPLayout *mParentLayout;
692  QSize mMinimumSize, mMaximumSize;
693  QRect mRect, mOuterRect;
694  QMargins mMargins, mMinimumMargins;
695  QCP::MarginSides mAutoMargins;
696  QHash<QCP::MarginSide, QCPMarginGroup*> mMarginGroups;
697 
698  // introduced virtual methods:
699  virtual int calculateAutoMargin(QCP::MarginSide side);
700  // events:
701  virtual void mousePressEvent(QMouseEvent * ) { }
702  virtual void mouseMoveEvent(QMouseEvent * ) { }
703  virtual void mouseReleaseEvent(QMouseEvent * ) { }
704  virtual void mouseDoubleClickEvent(QMouseEvent * ) { }
705  virtual void wheelEvent(QWheelEvent * ) { }
706 
707  // reimplemented virtual methods:
708  virtual void applyDefaultAntialiasingHint(QCPPainter * ) const { }
709  virtual void draw(QCPPainter * ) { }
710  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
711 
712 private:
713  Q_DISABLE_COPY(QCPLayoutElement)
714 
715  friend class QCustomPlot;
716  friend class QCPLayout;
717  friend class QCPMarginGroup;
718 };
719 
720 
721 class QCP_LIB_DECL QCPLayout : public QCPLayoutElement
722 {
723  Q_OBJECT
724 public:
725  explicit QCPLayout();
726 
727  // reimplemented virtual methods:
728  virtual void update(UpdatePhase phase);
729  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
730 
731  // introduced virtual methods:
732  virtual int elementCount() const = 0;
733  virtual QCPLayoutElement* elementAt(int index) const = 0;
734  virtual QCPLayoutElement* takeAt(int index) = 0;
735  virtual bool take(QCPLayoutElement* element) = 0;
736  virtual void simplify();
737 
738  // non-virtual methods:
739  bool removeAt(int index);
740  bool remove(QCPLayoutElement* element);
741  void clear();
742 
743 protected:
744  // introduced virtual methods:
745  virtual void updateLayout();
746 
747  // non-virtual methods:
748  void sizeConstraintsChanged() const;
749  void adoptElement(QCPLayoutElement *el);
750  void releaseElement(QCPLayoutElement *el);
751  QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const;
752 
753 private:
754  Q_DISABLE_COPY(QCPLayout)
755  friend class QCPLayoutElement;
756 };
757 
758 
759 class QCP_LIB_DECL QCPLayoutGrid : public QCPLayout
760 {
761  Q_OBJECT
763  Q_PROPERTY(int rowCount READ rowCount)
764  Q_PROPERTY(int columnCount READ columnCount)
765  Q_PROPERTY(QList<double> columnStretchFactors READ columnStretchFactors WRITE setColumnStretchFactors)
766  Q_PROPERTY(QList<double> rowStretchFactors READ rowStretchFactors WRITE setRowStretchFactors)
767  Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing)
768  Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing)
770 public:
771  explicit QCPLayoutGrid();
772  virtual ~QCPLayoutGrid();
773 
774  // getters:
775  int rowCount() const;
776  int columnCount() const;
777  QList<double> columnStretchFactors() const { return mColumnStretchFactors; }
778  QList<double> rowStretchFactors() const { return mRowStretchFactors; }
779  int columnSpacing() const { return mColumnSpacing; }
780  int rowSpacing() const { return mRowSpacing; }
781 
782  // setters:
783  void setColumnStretchFactor(int column, double factor);
784  void setColumnStretchFactors(const QList<double> &factors);
785  void setRowStretchFactor(int row, double factor);
786  void setRowStretchFactors(const QList<double> &factors);
787  void setColumnSpacing(int pixels);
788  void setRowSpacing(int pixels);
789 
790  // reimplemented virtual methods:
791  virtual void updateLayout();
792  virtual int elementCount() const;
793  virtual QCPLayoutElement* elementAt(int index) const;
794  virtual QCPLayoutElement* takeAt(int index);
795  virtual bool take(QCPLayoutElement* element);
796  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
797  virtual void simplify();
798  virtual QSize minimumSizeHint() const;
799  virtual QSize maximumSizeHint() const;
800 
801  // non-virtual methods:
802  QCPLayoutElement *element(int row, int column) const;
803  bool addElement(int row, int column, QCPLayoutElement *element);
804  bool hasElement(int row, int column);
805  void expandTo(int newRowCount, int newColumnCount);
806  void insertRow(int newIndex);
807  void insertColumn(int newIndex);
808 
809 protected:
810  // property members:
811  QList<QList<QCPLayoutElement*> > mElements;
812  QList<double> mColumnStretchFactors;
813  QList<double> mRowStretchFactors;
814  int mColumnSpacing, mRowSpacing;
815 
816  // non-virtual methods:
817  void getMinimumRowColSizes(QVector<int> *minColWidths, QVector<int> *minRowHeights) const;
818  void getMaximumRowColSizes(QVector<int> *maxColWidths, QVector<int> *maxRowHeights) const;
819 
820 private:
821  Q_DISABLE_COPY(QCPLayoutGrid)
822 };
823 
824 
825 class QCP_LIB_DECL QCPLayoutInset : public QCPLayout
826 {
827  Q_OBJECT
828 public:
832  enum InsetPlacement { ipFree
833  ,ipBorderAligned
834  };
835 
836  explicit QCPLayoutInset();
837  virtual ~QCPLayoutInset();
838 
839  // getters:
840  InsetPlacement insetPlacement(int index) const;
841  Qt::Alignment insetAlignment(int index) const;
842  QRectF insetRect(int index) const;
843 
844  // setters:
845  void setInsetPlacement(int index, InsetPlacement placement);
846  void setInsetAlignment(int index, Qt::Alignment alignment);
847  void setInsetRect(int index, const QRectF &rect);
848 
849  // reimplemented virtual methods:
850  virtual void updateLayout();
851  virtual int elementCount() const;
852  virtual QCPLayoutElement* elementAt(int index) const;
853  virtual QCPLayoutElement* takeAt(int index);
854  virtual bool take(QCPLayoutElement* element);
855  virtual void simplify() {}
856  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
857 
858  // non-virtual methods:
859  void addElement(QCPLayoutElement *element, Qt::Alignment alignment);
860  void addElement(QCPLayoutElement *element, const QRectF &rect);
861 
862 protected:
863  // property members:
864  QList<QCPLayoutElement*> mElements;
865  QList<InsetPlacement> mInsetPlacement;
866  QList<Qt::Alignment> mInsetAlignment;
867  QList<QRectF> mInsetRect;
868 
869 private:
870  Q_DISABLE_COPY(QCPLayoutInset)
871 };
872 
873 
874 class QCP_LIB_DECL QCPLineEnding
875 {
876  Q_GADGET
877 public:
889  Q_ENUMS(EndingStyle)
890  enum EndingStyle { esNone
891  ,esFlatArrow
892  ,esSpikeArrow
893  ,esLineArrow
894  ,esDisc
895  ,esSquare
896  ,esDiamond
897  ,esBar
898  ,esHalfBar
899  ,esSkewedBar
900  };
901 
902  QCPLineEnding();
903  QCPLineEnding(EndingStyle style, double width=8, double length=10, bool inverted=false);
904 
905  // getters:
906  EndingStyle style() const { return mStyle; }
907  double width() const { return mWidth; }
908  double length() const { return mLength; }
909  bool inverted() const { return mInverted; }
910 
911  // setters:
912  void setStyle(EndingStyle style);
913  void setWidth(double width);
914  void setLength(double length);
915  void setInverted(bool inverted);
916 
917  // non-property methods:
918  double boundingDistance() const;
919  double realLength() const;
920  void draw(QCPPainter *painter, const QVector2D &pos, const QVector2D &dir) const;
921  void draw(QCPPainter *painter, const QVector2D &pos, double angle) const;
922 
923 protected:
924  // property members:
925  EndingStyle mStyle;
926  double mWidth, mLength;
927  bool mInverted;
928 };
929 Q_DECLARE_TYPEINFO(QCPLineEnding, Q_MOVABLE_TYPE);
930 
931 
932 class QCP_LIB_DECL QCPGrid :public QCPLayerable
933 {
934  Q_OBJECT
936  Q_PROPERTY(bool subGridVisible READ subGridVisible WRITE setSubGridVisible)
937  Q_PROPERTY(bool antialiasedSubGrid READ antialiasedSubGrid WRITE setAntialiasedSubGrid)
938  Q_PROPERTY(bool antialiasedZeroLine READ antialiasedZeroLine WRITE setAntialiasedZeroLine)
939  Q_PROPERTY(QPen pen READ pen WRITE setPen)
940  Q_PROPERTY(QPen subGridPen READ subGridPen WRITE setSubGridPen)
941  Q_PROPERTY(QPen zeroLinePen READ zeroLinePen WRITE setZeroLinePen)
943 public:
944  QCPGrid(QCPAxis *parentAxis);
945 
946  // getters:
947  bool subGridVisible() const { return mSubGridVisible; }
948  bool antialiasedSubGrid() const { return mAntialiasedSubGrid; }
949  bool antialiasedZeroLine() const { return mAntialiasedZeroLine; }
950  QPen pen() const { return mPen; }
951  QPen subGridPen() const { return mSubGridPen; }
952  QPen zeroLinePen() const { return mZeroLinePen; }
953 
954  // setters:
955  void setSubGridVisible(bool visible);
956  void setAntialiasedSubGrid(bool enabled);
957  void setAntialiasedZeroLine(bool enabled);
958  void setPen(const QPen &pen);
959  void setSubGridPen(const QPen &pen);
960  void setZeroLinePen(const QPen &pen);
961 
962 protected:
963  // property members:
964  bool mSubGridVisible;
965  bool mAntialiasedSubGrid, mAntialiasedZeroLine;
966  QPen mPen, mSubGridPen, mZeroLinePen;
967  // non-property members:
968  QCPAxis *mParentAxis;
969 
970  // reimplemented virtual methods:
971  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
972  virtual void draw(QCPPainter *painter);
973 
974  // non-virtual methods:
975  void drawGridLines(QCPPainter *painter) const;
976  void drawSubGridLines(QCPPainter *painter) const;
977 
978  friend class QCPAxis;
979 };
980 
981 
982 class QCP_LIB_DECL QCPAxis : public QCPLayerable
983 {
984  Q_OBJECT
986  Q_PROPERTY(AxisType axisType READ axisType)
987  Q_PROPERTY(QCPAxisRect* axisRect READ axisRect)
988  Q_PROPERTY(ScaleType scaleType READ scaleType WRITE setScaleType NOTIFY scaleTypeChanged)
989  Q_PROPERTY(double scaleLogBase READ scaleLogBase WRITE setScaleLogBase)
990  Q_PROPERTY(QCPRange range READ range WRITE setRange NOTIFY rangeChanged)
991  Q_PROPERTY(bool rangeReversed READ rangeReversed WRITE setRangeReversed)
992  Q_PROPERTY(bool autoTicks READ autoTicks WRITE setAutoTicks)
993  Q_PROPERTY(int autoTickCount READ autoTickCount WRITE setAutoTickCount)
994  Q_PROPERTY(bool autoTickLabels READ autoTickLabels WRITE setAutoTickLabels)
995  Q_PROPERTY(bool autoTickStep READ autoTickStep WRITE setAutoTickStep)
996  Q_PROPERTY(bool autoSubTicks READ autoSubTicks WRITE setAutoSubTicks)
997  Q_PROPERTY(bool ticks READ ticks WRITE setTicks)
998  Q_PROPERTY(bool tickLabels READ tickLabels WRITE setTickLabels)
999  Q_PROPERTY(int tickLabelPadding READ tickLabelPadding WRITE setTickLabelPadding)
1000  Q_PROPERTY(LabelType tickLabelType READ tickLabelType WRITE setTickLabelType)
1001  Q_PROPERTY(QFont tickLabelFont READ tickLabelFont WRITE setTickLabelFont)
1002  Q_PROPERTY(QColor tickLabelColor READ tickLabelColor WRITE setTickLabelColor)
1003  Q_PROPERTY(double tickLabelRotation READ tickLabelRotation WRITE setTickLabelRotation)
1004  Q_PROPERTY(LabelSide tickLabelSide READ tickLabelSide WRITE setTickLabelSide)
1005  Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
1006  Q_PROPERTY(Qt::TimeSpec dateTimeSpec READ dateTimeSpec WRITE setDateTimeSpec)
1007  Q_PROPERTY(QString numberFormat READ numberFormat WRITE setNumberFormat)
1008  Q_PROPERTY(int numberPrecision READ numberPrecision WRITE setNumberPrecision)
1009  Q_PROPERTY(double tickStep READ tickStep WRITE setTickStep)
1010  Q_PROPERTY(QVector<double> tickVector READ tickVector WRITE setTickVector)
1011  Q_PROPERTY(QVector<QString> tickVectorLabels READ tickVectorLabels WRITE setTickVectorLabels)
1012  Q_PROPERTY(int tickLengthIn READ tickLengthIn WRITE setTickLengthIn)
1013  Q_PROPERTY(int tickLengthOut READ tickLengthOut WRITE setTickLengthOut)
1014  Q_PROPERTY(int subTickCount READ subTickCount WRITE setSubTickCount)
1015  Q_PROPERTY(int subTickLengthIn READ subTickLengthIn WRITE setSubTickLengthIn)
1016  Q_PROPERTY(int subTickLengthOut READ subTickLengthOut WRITE setSubTickLengthOut)
1017  Q_PROPERTY(QPen basePen READ basePen WRITE setBasePen)
1018  Q_PROPERTY(QPen tickPen READ tickPen WRITE setTickPen)
1019  Q_PROPERTY(QPen subTickPen READ subTickPen WRITE setSubTickPen)
1020  Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont)
1021  Q_PROPERTY(QColor labelColor READ labelColor WRITE setLabelColor)
1022  Q_PROPERTY(QString label READ label WRITE setLabel)
1023  Q_PROPERTY(int labelPadding READ labelPadding WRITE setLabelPadding)
1024  Q_PROPERTY(int padding READ padding WRITE setPadding)
1025  Q_PROPERTY(int offset READ offset WRITE setOffset)
1026  Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectionChanged)
1027  Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectableChanged)
1028  Q_PROPERTY(QFont selectedTickLabelFont READ selectedTickLabelFont WRITE setSelectedTickLabelFont)
1029  Q_PROPERTY(QFont selectedLabelFont READ selectedLabelFont WRITE setSelectedLabelFont)
1030  Q_PROPERTY(QColor selectedTickLabelColor READ selectedTickLabelColor WRITE setSelectedTickLabelColor)
1031  Q_PROPERTY(QColor selectedLabelColor READ selectedLabelColor WRITE setSelectedLabelColor)
1032  Q_PROPERTY(QPen selectedBasePen READ selectedBasePen WRITE setSelectedBasePen)
1033  Q_PROPERTY(QPen selectedTickPen READ selectedTickPen WRITE setSelectedTickPen)
1034  Q_PROPERTY(QPen selectedSubTickPen READ selectedSubTickPen WRITE setSelectedSubTickPen)
1035  Q_PROPERTY(QCPLineEnding lowerEnding READ lowerEnding WRITE setLowerEnding)
1036  Q_PROPERTY(QCPLineEnding upperEnding READ upperEnding WRITE setUpperEnding)
1037  Q_PROPERTY(QCPGrid* grid READ grid)
1039 public:
1044  enum AxisType { atLeft = 0x01
1045  ,atRight = 0x02
1046  ,atTop = 0x04
1047  ,atBottom = 0x08
1048  };
1049  Q_FLAGS(AxisType AxisTypes)
1050  Q_DECLARE_FLAGS(AxisTypes, AxisType)
1057  enum LabelType { ltNumber
1058  ,ltDateTime
1059  };
1060  Q_ENUMS(LabelType)
1066  enum LabelSide { lsInside
1067  ,lsOutside
1068  };
1069  Q_ENUMS(LabelSide)
1074  enum ScaleType { stLinear
1075  ,stLogarithmic
1076  };
1077  Q_ENUMS(ScaleType)
1082  enum SelectablePart { spNone = 0
1083  ,spAxis = 0x001
1084  ,spTickLabels = 0x002
1085  ,spAxisLabel = 0x004
1086  };
1087  Q_FLAGS(SelectablePart SelectableParts)
1088  Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
1089 
1090  explicit QCPAxis(QCPAxisRect *parent, AxisType type);
1091  virtual ~QCPAxis();
1092 
1093  // getters:
1094  AxisType axisType() const { return mAxisType; }
1095  QCPAxisRect *axisRect() const { return mAxisRect; }
1096  ScaleType scaleType() const { return mScaleType; }
1097  double scaleLogBase() const { return mScaleLogBase; }
1098  const QCPRange range() const { return mRange; }
1099  bool rangeReversed() const { return mRangeReversed; }
1100  bool autoTicks() const { return mAutoTicks; }
1101  int autoTickCount() const { return mAutoTickCount; }
1102  bool autoTickLabels() const { return mAutoTickLabels; }
1103  bool autoTickStep() const { return mAutoTickStep; }
1104  bool autoSubTicks() const { return mAutoSubTicks; }
1105  bool ticks() const { return mTicks; }
1106  bool tickLabels() const { return mTickLabels; }
1107  int tickLabelPadding() const;
1108  LabelType tickLabelType() const { return mTickLabelType; }
1109  QFont tickLabelFont() const { return mTickLabelFont; }
1110  QColor tickLabelColor() const { return mTickLabelColor; }
1111  double tickLabelRotation() const;
1112  LabelSide tickLabelSide() const;
1113  QString dateTimeFormat() const { return mDateTimeFormat; }
1114  Qt::TimeSpec dateTimeSpec() const { return mDateTimeSpec; }
1115  QString numberFormat() const;
1116  int numberPrecision() const { return mNumberPrecision; }
1117  double tickStep() const { return mTickStep; }
1118  QVector<double> tickVector() const { return mTickVector; }
1119  QVector<QString> tickVectorLabels() const { return mTickVectorLabels; }
1120  int tickLengthIn() const;
1121  int tickLengthOut() const;
1122  int subTickCount() const { return mSubTickCount; }
1123  int subTickLengthIn() const;
1124  int subTickLengthOut() const;
1125  QPen basePen() const { return mBasePen; }
1126  QPen tickPen() const { return mTickPen; }
1127  QPen subTickPen() const { return mSubTickPen; }
1128  QFont labelFont() const { return mLabelFont; }
1129  QColor labelColor() const { return mLabelColor; }
1130  QString label() const { return mLabel; }
1131  int labelPadding() const;
1132  int padding() const { return mPadding; }
1133  int offset() const;
1134  SelectableParts selectedParts() const { return mSelectedParts; }
1135  SelectableParts selectableParts() const { return mSelectableParts; }
1136  QFont selectedTickLabelFont() const { return mSelectedTickLabelFont; }
1137  QFont selectedLabelFont() const { return mSelectedLabelFont; }
1138  QColor selectedTickLabelColor() const { return mSelectedTickLabelColor; }
1139  QColor selectedLabelColor() const { return mSelectedLabelColor; }
1140  QPen selectedBasePen() const { return mSelectedBasePen; }
1141  QPen selectedTickPen() const { return mSelectedTickPen; }
1142  QPen selectedSubTickPen() const { return mSelectedSubTickPen; }
1143  QCPLineEnding lowerEnding() const;
1144  QCPLineEnding upperEnding() const;
1145  QCPGrid *grid() const { return mGrid; }
1146 
1147  // setters:
1148  Q_SLOT void setScaleType(QCPAxis::ScaleType type);
1149  void setScaleLogBase(double base);
1150  Q_SLOT void setRange(const QCPRange &range);
1151  void setRange(double lower, double upper);
1152  void setRange(double position, double size, Qt::AlignmentFlag alignment);
1153  void setRangeLower(double lower);
1154  void setRangeUpper(double upper);
1155  void setRangeReversed(bool reversed);
1156  void setAutoTicks(bool on);
1157  void setAutoTickCount(int approximateCount);
1158  void setAutoTickLabels(bool on);
1159  void setAutoTickStep(bool on);
1160  void setAutoSubTicks(bool on);
1161  void setTicks(bool show);
1162  void setTickLabels(bool show);
1163  void setTickLabelPadding(int padding);
1164  void setTickLabelType(LabelType type);
1165  void setTickLabelFont(const QFont &font);
1166  void setTickLabelColor(const QColor &color);
1167  void setTickLabelRotation(double degrees);
1168  void setTickLabelSide(LabelSide side);
1169  void setDateTimeFormat(const QString &format);
1170  void setDateTimeSpec(const Qt::TimeSpec &timeSpec);
1171  void setNumberFormat(const QString &formatCode);
1172  void setNumberPrecision(int precision);
1173  void setTickStep(double step);
1174  void setTickVector(const QVector<double> &vec);
1175  void setTickVectorLabels(const QVector<QString> &vec);
1176  void setTickLength(int inside, int outside=0);
1177  void setTickLengthIn(int inside);
1178  void setTickLengthOut(int outside);
1179  void setSubTickCount(int count);
1180  void setSubTickLength(int inside, int outside=0);
1181  void setSubTickLengthIn(int inside);
1182  void setSubTickLengthOut(int outside);
1183  void setBasePen(const QPen &pen);
1184  void setTickPen(const QPen &pen);
1185  void setSubTickPen(const QPen &pen);
1186  void setLabelFont(const QFont &font);
1187  void setLabelColor(const QColor &color);
1188  void setLabel(const QString &str);
1189  void setLabelPadding(int padding);
1190  void setPadding(int padding);
1191  void setOffset(int offset);
1192  void setSelectedTickLabelFont(const QFont &font);
1193  void setSelectedLabelFont(const QFont &font);
1194  void setSelectedTickLabelColor(const QColor &color);
1195  void setSelectedLabelColor(const QColor &color);
1196  void setSelectedBasePen(const QPen &pen);
1197  void setSelectedTickPen(const QPen &pen);
1198  void setSelectedSubTickPen(const QPen &pen);
1199  Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts);
1200  Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts);
1201  void setLowerEnding(const QCPLineEnding &ending);
1202  void setUpperEnding(const QCPLineEnding &ending);
1203 
1204  // reimplemented virtual methods:
1205  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
1206 
1207  // non-property methods:
1208  Qt::Orientation orientation() const { return mOrientation; }
1209  void moveRange(double diff);
1210  void scaleRange(double factor, double center);
1211  void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0);
1212  void rescale(bool onlyVisiblePlottables=false);
1213  double pixelToCoord(double value) const;
1214  double coordToPixel(double value) const;
1215  SelectablePart getPartAt(const QPointF &pos) const;
1216  QList<QCPAbstractPlottable*> plottables() const;
1217  QList<QCPGraph*> graphs() const;
1218  QList<QCPAbstractItem*> items() const;
1219 
1220  static AxisType marginSideToAxisType(QCP::MarginSide side);
1221  static Qt::Orientation orientation(AxisType type) { return type==atBottom||type==atTop ? Qt::Horizontal : Qt::Vertical; }
1222  static AxisType opposite(AxisType type);
1223 
1224 signals:
1225  void ticksRequest();
1226  void rangeChanged(const QCPRange &newRange);
1227  void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
1228  void scaleTypeChanged(QCPAxis::ScaleType scaleType);
1229  void selectionChanged(const QCPAxis::SelectableParts &parts);
1230  void selectableChanged(const QCPAxis::SelectableParts &parts);
1231 
1232 protected:
1233  // property members:
1234  // axis base:
1235  AxisType mAxisType;
1236  QCPAxisRect *mAxisRect;
1237  //int mOffset; // in QCPAxisPainter
1238  int mPadding;
1239  Qt::Orientation mOrientation;
1240  SelectableParts mSelectableParts, mSelectedParts;
1241  QPen mBasePen, mSelectedBasePen;
1242  //QCPLineEnding mLowerEnding, mUpperEnding; // in QCPAxisPainter
1243  // axis label:
1244  //int mLabelPadding; // in QCPAxisPainter
1245  QString mLabel;
1246  QFont mLabelFont, mSelectedLabelFont;
1247  QColor mLabelColor, mSelectedLabelColor;
1248  // tick labels:
1249  //int mTickLabelPadding; // in QCPAxisPainter
1250  bool mTickLabels, mAutoTickLabels;
1251  //double mTickLabelRotation; // in QCPAxisPainter
1252  LabelType mTickLabelType;
1253  QFont mTickLabelFont, mSelectedTickLabelFont;
1254  QColor mTickLabelColor, mSelectedTickLabelColor;
1255  QString mDateTimeFormat;
1256  Qt::TimeSpec mDateTimeSpec;
1257  int mNumberPrecision;
1258  QLatin1Char mNumberFormatChar;
1259  bool mNumberBeautifulPowers;
1260  //bool mNumberMultiplyCross; // QCPAxisPainter
1261  // ticks and subticks:
1262  bool mTicks;
1263  double mTickStep;
1264  int mSubTickCount, mAutoTickCount;
1265  bool mAutoTicks, mAutoTickStep, mAutoSubTicks;
1266  //int mTickLengthIn, mTickLengthOut, mSubTickLengthIn, mSubTickLengthOut; // QCPAxisPainter
1267  QPen mTickPen, mSelectedTickPen;
1268  QPen mSubTickPen, mSelectedSubTickPen;
1269  // scale and range:
1270  QCPRange mRange;
1271  bool mRangeReversed;
1272  ScaleType mScaleType;
1273  double mScaleLogBase, mScaleLogBaseLogInv;
1274 
1275  // non-property members:
1276  QCPGrid *mGrid;
1277  QCPAxisPainterPrivate *mAxisPainter;
1278  int mLowestVisibleTick, mHighestVisibleTick;
1279  QVector<double> mTickVector;
1280  QVector<QString> mTickVectorLabels;
1281  QVector<double> mSubTickVector;
1282  bool mCachedMarginValid;
1283  int mCachedMargin;
1284 
1285  // introduced virtual methods:
1286  virtual void setupTickVectors();
1287  virtual void generateAutoTicks();
1288  virtual int calculateAutoSubTickCount(double tickStep) const;
1289  virtual int calculateMargin();
1290 
1291  // reimplemented virtual methods:
1292  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
1293  virtual void draw(QCPPainter *painter);
1294  virtual QCP::Interaction selectionCategory() const;
1295  // events:
1296  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
1297  virtual void deselectEvent(bool *selectionStateChanged);
1298 
1299  // non-virtual methods:
1300  void visibleTickBounds(int &lowIndex, int &highIndex) const;
1301  double baseLog(double value) const;
1302  double basePow(double value) const;
1303  QPen getBasePen() const;
1304  QPen getTickPen() const;
1305  QPen getSubTickPen() const;
1306  QFont getTickLabelFont() const;
1307  QFont getLabelFont() const;
1308  QColor getTickLabelColor() const;
1309  QColor getLabelColor() const;
1310 
1311 private:
1312  Q_DISABLE_COPY(QCPAxis)
1313 
1314  friend class QCustomPlot;
1315  friend class QCPGrid;
1316  friend class QCPAxisRect;
1317 };
1318 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::SelectableParts)
1319 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPAxis::AxisTypes)
1320 Q_DECLARE_METATYPE(QCPAxis::SelectablePart)
1321 
1322 
1324 {
1325 public:
1326  explicit QCPAxisPainterPrivate(QCustomPlot *parentPlot);
1327  virtual ~QCPAxisPainterPrivate();
1328 
1329  virtual void draw(QCPPainter *painter);
1330  virtual int size() const;
1331  void clearCache();
1332 
1333  QRect axisSelectionBox() const { return mAxisSelectionBox; }
1334  QRect tickLabelsSelectionBox() const { return mTickLabelsSelectionBox; }
1335  QRect labelSelectionBox() const { return mLabelSelectionBox; }
1336 
1337  // public property members:
1338  QCPAxis::AxisType type;
1339  QPen basePen;
1340  QCPLineEnding lowerEnding, upperEnding; // directly accessed by QCPAxis setters/getters
1341  int labelPadding; // directly accessed by QCPAxis setters/getters
1342  QFont labelFont;
1343  QColor labelColor;
1344  QString label;
1345  int tickLabelPadding; // directly accessed by QCPAxis setters/getters
1346  double tickLabelRotation; // directly accessed by QCPAxis setters/getters
1347  QCPAxis::LabelSide tickLabelSide; // directly accessed by QCPAxis setters/getters
1348  bool substituteExponent;
1349  bool numberMultiplyCross; // directly accessed by QCPAxis setters/getters
1350  int tickLengthIn, tickLengthOut, subTickLengthIn, subTickLengthOut; // directly accessed by QCPAxis setters/getters
1351  QPen tickPen, subTickPen;
1352  QFont tickLabelFont;
1353  QColor tickLabelColor;
1354  QRect axisRect, viewportRect;
1355  double offset; // directly accessed by QCPAxis setters/getters
1356  bool abbreviateDecimalPowers;
1357  bool reversedEndings;
1358 
1359  QVector<double> subTickPositions;
1360  QVector<double> tickPositions;
1361  QVector<QString> tickLabels;
1362 
1363 protected:
1365  {
1366  QPointF offset;
1367  QPixmap pixmap;
1368  };
1370  {
1371  QString basePart, expPart;
1372  QRect baseBounds, expBounds, totalBounds, rotatedTotalBounds;
1373  QFont baseFont, expFont;
1374  };
1375  QCustomPlot *mParentPlot;
1376  QByteArray mLabelParameterHash; // to determine whether mLabelCache needs to be cleared due to changed parameters
1377  QCache<QString, CachedLabel> mLabelCache;
1378  QRect mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox;
1379 
1380  virtual QByteArray generateLabelParameterHash() const;
1381 
1382  virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize);
1383  virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const;
1384  virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const;
1385  virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const;
1386  virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const;
1387 };
1388 
1389 
1390 class QCP_LIB_DECL QCPAbstractPlottable : public QCPLayerable
1391 {
1392  Q_OBJECT
1394  Q_PROPERTY(QString name READ name WRITE setName)
1395  Q_PROPERTY(bool antialiasedFill READ antialiasedFill WRITE setAntialiasedFill)
1396  Q_PROPERTY(bool antialiasedScatters READ antialiasedScatters WRITE setAntialiasedScatters)
1397  Q_PROPERTY(bool antialiasedErrorBars READ antialiasedErrorBars WRITE setAntialiasedErrorBars)
1398  Q_PROPERTY(QPen pen READ pen WRITE setPen)
1399  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
1400  Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
1401  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
1402  Q_PROPERTY(QCPAxis* keyAxis READ keyAxis WRITE setKeyAxis)
1403  Q_PROPERTY(QCPAxis* valueAxis READ valueAxis WRITE setValueAxis)
1404  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
1405  Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
1407 public:
1408  QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis);
1409 
1410  // getters:
1411  QString name() const { return mName; }
1412  bool antialiasedFill() const { return mAntialiasedFill; }
1413  bool antialiasedScatters() const { return mAntialiasedScatters; }
1414  bool antialiasedErrorBars() const { return mAntialiasedErrorBars; }
1415  QPen pen() const { return mPen; }
1416  QPen selectedPen() const { return mSelectedPen; }
1417  QBrush brush() const { return mBrush; }
1418  QBrush selectedBrush() const { return mSelectedBrush; }
1419  QCPAxis *keyAxis() const { return mKeyAxis.data(); }
1420  QCPAxis *valueAxis() const { return mValueAxis.data(); }
1421  bool selectable() const { return mSelectable; }
1422  bool selected() const { return mSelected; }
1423 
1424  // setters:
1425  void setName(const QString &name);
1426  void setAntialiasedFill(bool enabled);
1427  void setAntialiasedScatters(bool enabled);
1428  void setAntialiasedErrorBars(bool enabled);
1429  void setPen(const QPen &pen);
1430  void setSelectedPen(const QPen &pen);
1431  void setBrush(const QBrush &brush);
1432  void setSelectedBrush(const QBrush &brush);
1433  void setKeyAxis(QCPAxis *axis);
1434  void setValueAxis(QCPAxis *axis);
1435  Q_SLOT void setSelectable(bool selectable);
1436  Q_SLOT void setSelected(bool selected);
1437 
1438  // introduced virtual methods:
1439  virtual void clearData() = 0;
1440  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0;
1441  virtual bool addToLegend();
1442  virtual bool removeFromLegend() const;
1443 
1444  // non-property methods:
1445  void rescaleAxes(bool onlyEnlarge=false) const;
1446  void rescaleKeyAxis(bool onlyEnlarge=false) const;
1447  void rescaleValueAxis(bool onlyEnlarge=false) const;
1448 
1449 signals:
1450  void selectionChanged(bool selected);
1451  void selectableChanged(bool selectable);
1452 
1453 protected:
1457  enum SignDomain { sdNegative
1458  ,sdBoth
1459  ,sdPositive
1460  };
1461 
1462  // property members:
1463  QString mName;
1464  bool mAntialiasedFill, mAntialiasedScatters, mAntialiasedErrorBars;
1465  QPen mPen, mSelectedPen;
1466  QBrush mBrush, mSelectedBrush;
1467  QPointer<QCPAxis> mKeyAxis, mValueAxis;
1468  bool mSelectable, mSelected;
1469 
1470  // reimplemented virtual methods:
1471  virtual QRect clipRect() const;
1472  virtual void draw(QCPPainter *painter) = 0;
1473  virtual QCP::Interaction selectionCategory() const;
1474  void applyDefaultAntialiasingHint(QCPPainter *painter) const;
1475  // events:
1476  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
1477  virtual void deselectEvent(bool *selectionStateChanged);
1478 
1479  // introduced virtual methods:
1480  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0;
1481  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0;
1482  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0;
1483 
1484  // non-virtual methods:
1485  void coordsToPixels(double key, double value, double &x, double &y) const;
1486  const QPointF coordsToPixels(double key, double value) const;
1487  void pixelsToCoords(double x, double y, double &key, double &value) const;
1488  void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const;
1489  QPen mainPen() const;
1490  QBrush mainBrush() const;
1491  void applyFillAntialiasingHint(QCPPainter *painter) const;
1492  void applyScattersAntialiasingHint(QCPPainter *painter) const;
1493  void applyErrorBarsAntialiasingHint(QCPPainter *painter) const;
1494  double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
1495 
1496 private:
1497  Q_DISABLE_COPY(QCPAbstractPlottable)
1498 
1499  friend class QCustomPlot;
1500  friend class QCPAxis;
1501  friend class QCPPlottableLegendItem;
1502 };
1503 
1504 
1505 class QCP_LIB_DECL QCPItemAnchor
1506 {
1507 public:
1508  QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId=-1);
1509  virtual ~QCPItemAnchor();
1510 
1511  // getters:
1512  QString name() const { return mName; }
1513  virtual QPointF pixelPoint() const;
1514 
1515 protected:
1516  // property members:
1517  QString mName;
1518 
1519  // non-property members:
1520  QCustomPlot *mParentPlot;
1521  QCPAbstractItem *mParentItem;
1522  int mAnchorId;
1523  QSet<QCPItemPosition*> mChildrenX, mChildrenY;
1524 
1525  // introduced virtual methods:
1526  virtual QCPItemPosition *toQCPItemPosition() { return 0; }
1527 
1528  // non-virtual methods:
1529  void addChildX(QCPItemPosition* pos); // called from pos when this anchor is set as parent
1530  void removeChildX(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
1531  void addChildY(QCPItemPosition* pos); // called from pos when this anchor is set as parent
1532  void removeChildY(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
1533 
1534 private:
1535  Q_DISABLE_COPY(QCPItemAnchor)
1536 
1537  friend class QCPItemPosition;
1538 };
1539 
1540 
1541 
1542 class QCP_LIB_DECL QCPItemPosition : public QCPItemAnchor
1543 {
1544 public:
1551  enum PositionType { ptAbsolute
1552  ,ptViewportRatio
1553  ,ptAxisRectRatio
1556  ,ptPlotCoords
1559  };
1560 
1561  QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name);
1562  virtual ~QCPItemPosition();
1563 
1564  // getters:
1565  PositionType type() const { return typeX(); }
1566  PositionType typeX() const { return mPositionTypeX; }
1567  PositionType typeY() const { return mPositionTypeY; }
1568  QCPItemAnchor *parentAnchor() const { return parentAnchorX(); }
1569  QCPItemAnchor *parentAnchorX() const { return mParentAnchorX; }
1570  QCPItemAnchor *parentAnchorY() const { return mParentAnchorY; }
1571  double key() const { return mKey; }
1572  double value() const { return mValue; }
1573  QPointF coords() const { return QPointF(mKey, mValue); }
1574  QCPAxis *keyAxis() const { return mKeyAxis.data(); }
1575  QCPAxis *valueAxis() const { return mValueAxis.data(); }
1576  QCPAxisRect *axisRect() const;
1577  virtual QPointF pixelPoint() const;
1578 
1579  // setters:
1580  void setType(PositionType type);
1581  void setTypeX(PositionType type);
1582  void setTypeY(PositionType type);
1583  bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
1584  bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
1585  bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
1586  void setCoords(double key, double value);
1587  void setCoords(const QPointF &coords);
1588  void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
1589  void setAxisRect(QCPAxisRect *axisRect);
1590  void setPixelPoint(const QPointF &pixelPoint);
1591 
1592 protected:
1593  // property members:
1594  PositionType mPositionTypeX, mPositionTypeY;
1595  QPointer<QCPAxis> mKeyAxis, mValueAxis;
1596  QPointer<QCPAxisRect> mAxisRect;
1597  double mKey, mValue;
1598  QCPItemAnchor *mParentAnchorX, *mParentAnchorY;
1599 
1600  // reimplemented virtual methods:
1601  virtual QCPItemPosition *toQCPItemPosition() { return this; }
1602 
1603 private:
1604  Q_DISABLE_COPY(QCPItemPosition)
1605 
1606 };
1607 
1608 
1609 class QCP_LIB_DECL QCPAbstractItem : public QCPLayerable
1610 {
1611  Q_OBJECT
1613  Q_PROPERTY(bool clipToAxisRect READ clipToAxisRect WRITE setClipToAxisRect)
1614  Q_PROPERTY(QCPAxisRect* clipAxisRect READ clipAxisRect WRITE setClipAxisRect)
1615  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
1616  Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
1618 public:
1619  QCPAbstractItem(QCustomPlot *parentPlot);
1620  virtual ~QCPAbstractItem();
1621 
1622  // getters:
1623  bool clipToAxisRect() const { return mClipToAxisRect; }
1624  QCPAxisRect *clipAxisRect() const;
1625  bool selectable() const { return mSelectable; }
1626  bool selected() const { return mSelected; }
1627 
1628  // setters:
1629  void setClipToAxisRect(bool clip);
1630  void setClipAxisRect(QCPAxisRect *rect);
1631  Q_SLOT void setSelectable(bool selectable);
1632  Q_SLOT void setSelected(bool selected);
1633 
1634  // reimplemented virtual methods:
1635  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0;
1636 
1637  // non-virtual methods:
1638  QList<QCPItemPosition*> positions() const { return mPositions; }
1639  QList<QCPItemAnchor*> anchors() const { return mAnchors; }
1640  QCPItemPosition *position(const QString &name) const;
1641  QCPItemAnchor *anchor(const QString &name) const;
1642  bool hasAnchor(const QString &name) const;
1643 
1644 signals:
1645  void selectionChanged(bool selected);
1646  void selectableChanged(bool selectable);
1647 
1648 protected:
1649  // property members:
1650  bool mClipToAxisRect;
1651  QPointer<QCPAxisRect> mClipAxisRect;
1652  QList<QCPItemPosition*> mPositions;
1653  QList<QCPItemAnchor*> mAnchors;
1654  bool mSelectable, mSelected;
1655 
1656  // reimplemented virtual methods:
1657  virtual QCP::Interaction selectionCategory() const;
1658  virtual QRect clipRect() const;
1659  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
1660  virtual void draw(QCPPainter *painter) = 0;
1661  // events:
1662  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
1663  virtual void deselectEvent(bool *selectionStateChanged);
1664 
1665  // introduced virtual methods:
1666  virtual QPointF anchorPixelPoint(int anchorId) const;
1667 
1668  // non-virtual methods:
1669  double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
1670  double rectSelectTest(const QRectF &rect, const QPointF &pos, bool filledRect) const;
1671  QCPItemPosition *createPosition(const QString &name);
1672  QCPItemAnchor *createAnchor(const QString &name, int anchorId);
1673 
1674 private:
1675  Q_DISABLE_COPY(QCPAbstractItem)
1676 
1677  friend class QCustomPlot;
1678  friend class QCPItemAnchor;
1679 };
1680 
1681 
1682 class QCP_LIB_DECL QCustomPlot : public QWidget
1683 {
1684  Q_OBJECT
1686  Q_PROPERTY(QRect viewport READ viewport WRITE setViewport)
1687  Q_PROPERTY(QPixmap background READ background WRITE setBackground)
1688  Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
1689  Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode)
1690  Q_PROPERTY(QCPLayoutGrid* plotLayout READ plotLayout)
1691  Q_PROPERTY(bool autoAddPlottableToLegend READ autoAddPlottableToLegend WRITE setAutoAddPlottableToLegend)
1692  Q_PROPERTY(int selectionTolerance READ selectionTolerance WRITE setSelectionTolerance)
1693  Q_PROPERTY(bool noAntialiasingOnDrag READ noAntialiasingOnDrag WRITE setNoAntialiasingOnDrag)
1694  Q_PROPERTY(Qt::KeyboardModifier multiSelectModifier READ multiSelectModifier WRITE setMultiSelectModifier)
1696 public:
1702  enum LayerInsertMode { limBelow
1703  ,limAbove
1704  };
1705  Q_ENUMS(LayerInsertMode)
1706 
1707 
1712  enum RefreshPriority { rpImmediate
1713  ,rpQueued
1714  ,rpHint
1715  };
1716 
1717  explicit QCustomPlot(QWidget *parent = 0);
1718  virtual ~QCustomPlot();
1719 
1720  // getters:
1721  QRect viewport() const { return mViewport; }
1722  QPixmap background() const { return mBackgroundPixmap; }
1723  bool backgroundScaled() const { return mBackgroundScaled; }
1724  Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
1725  QCPLayoutGrid *plotLayout() const { return mPlotLayout; }
1726  QCP::AntialiasedElements antialiasedElements() const { return mAntialiasedElements; }
1727  QCP::AntialiasedElements notAntialiasedElements() const { return mNotAntialiasedElements; }
1728  bool autoAddPlottableToLegend() const { return mAutoAddPlottableToLegend; }
1729  const QCP::Interactions interactions() const { return mInteractions; }
1730  int selectionTolerance() const { return mSelectionTolerance; }
1731  bool noAntialiasingOnDrag() const { return mNoAntialiasingOnDrag; }
1732  QCP::PlottingHints plottingHints() const { return mPlottingHints; }
1733  Qt::KeyboardModifier multiSelectModifier() const { return mMultiSelectModifier; }
1734 
1735  // setters:
1736  void setViewport(const QRect &rect);
1737  void setBackground(const QPixmap &pm);
1738  void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
1739  void setBackground(const QBrush &brush);
1740  void setBackgroundScaled(bool scaled);
1741  void setBackgroundScaledMode(Qt::AspectRatioMode mode);
1742  void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements);
1743  void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true);
1744  void setNotAntialiasedElements(const QCP::AntialiasedElements &notAntialiasedElements);
1745  void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true);
1746  void setAutoAddPlottableToLegend(bool on);
1747  void setInteractions(const QCP::Interactions &interactions);
1748  void setInteraction(const QCP::Interaction &interaction, bool enabled=true);
1749  void setSelectionTolerance(int pixels);
1750  void setNoAntialiasingOnDrag(bool enabled);
1751  void setPlottingHints(const QCP::PlottingHints &hints);
1752  void setPlottingHint(QCP::PlottingHint hint, bool enabled=true);
1753  void setMultiSelectModifier(Qt::KeyboardModifier modifier);
1754 
1755  // non-property methods:
1756  // plottable interface:
1757  QCPAbstractPlottable *plottable(int index);
1758  QCPAbstractPlottable *plottable();
1759  bool addPlottable(QCPAbstractPlottable *plottable);
1760  bool removePlottable(QCPAbstractPlottable *plottable);
1761  bool removePlottable(int index);
1762  int clearPlottables();
1763  int plottableCount() const;
1764  QList<QCPAbstractPlottable*> selectedPlottables() const;
1765  QCPAbstractPlottable *plottableAt(const QPointF &pos, bool onlySelectable=false) const;
1766  bool hasPlottable(QCPAbstractPlottable *plottable) const;
1767 
1768  // specialized interface for QCPGraph:
1769  QCPGraph *graph(int index) const;
1770  QCPGraph *graph() const;
1771  QCPGraph *addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0);
1772  bool removeGraph(QCPGraph *graph);
1773  bool removeGraph(int index);
1774  int clearGraphs();
1775  int graphCount() const;
1776  QList<QCPGraph*> selectedGraphs() const;
1777 
1778  // item interface:
1779  QCPAbstractItem *item(int index) const;
1780  QCPAbstractItem *item() const;
1781  bool addItem(QCPAbstractItem* item);
1782  bool removeItem(QCPAbstractItem *item);
1783  bool removeItem(int index);
1784  int clearItems();
1785  int itemCount() const;
1786  QList<QCPAbstractItem*> selectedItems() const;
1787  QCPAbstractItem *itemAt(const QPointF &pos, bool onlySelectable=false) const;
1788  bool hasItem(QCPAbstractItem *item) const;
1789 
1790  // layer interface:
1791  QCPLayer *layer(const QString &name) const;
1792  QCPLayer *layer(int index) const;
1793  QCPLayer *currentLayer() const;
1794  bool setCurrentLayer(const QString &name);
1795  bool setCurrentLayer(QCPLayer *layer);
1796  int layerCount() const;
1797  bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove);
1798  bool removeLayer(QCPLayer *layer);
1799  bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove);
1800 
1801  // axis rect/layout interface:
1802  int axisRectCount() const;
1803  QCPAxisRect* axisRect(int index=0) const;
1804  QList<QCPAxisRect*> axisRects() const;
1805  QCPLayoutElement* layoutElementAt(const QPointF &pos) const;
1806  Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false);
1807 
1808  QList<QCPAxis*> selectedAxes() const;
1809  QList<QCPLegend*> selectedLegends() const;
1810  Q_SLOT void deselectAll();
1811 
1812  bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator=QString(), const QString &pdfTitle=QString());
1813  bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1);
1814  bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1);
1815  bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0);
1816  bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1);
1817  QPixmap toPixmap(int width=0, int height=0, double scale=1.0);
1818  void toPainter(QCPPainter *painter, int width=0, int height=0);
1819  Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint);
1820 
1821  QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
1823 
1824 signals:
1825  void mouseDoubleClick(QMouseEvent *event);
1826  void mousePress(QMouseEvent *event);
1827  void mouseMove(QMouseEvent *event);
1828  void mouseRelease(QMouseEvent *event);
1829  void mouseWheel(QWheelEvent *event);
1830 
1831  void plottableClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
1832  void plottableDoubleClick(QCPAbstractPlottable *plottable, QMouseEvent *event);
1833  void itemClick(QCPAbstractItem *item, QMouseEvent *event);
1834  void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event);
1835  void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
1836  void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event);
1837  void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
1838  void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event);
1839  void titleClick(QMouseEvent *event, QCPPlotTitle *title);
1840  void titleDoubleClick(QMouseEvent *event, QCPPlotTitle *title);
1841 
1842  void selectionChangedByUser();
1843  void beforeReplot();
1844  void afterReplot();
1845 
1846 protected:
1847  // property members:
1848  QRect mViewport;
1849  QCPLayoutGrid *mPlotLayout;
1850  bool mAutoAddPlottableToLegend;
1851  QList<QCPAbstractPlottable*> mPlottables;
1852  QList<QCPGraph*> mGraphs; // extra list of plottables also in mPlottables that are of type QCPGraph
1853  QList<QCPAbstractItem*> mItems;
1854  QList<QCPLayer*> mLayers;
1855  QCP::AntialiasedElements mAntialiasedElements, mNotAntialiasedElements;
1856  QCP::Interactions mInteractions;
1857  int mSelectionTolerance;
1858  bool mNoAntialiasingOnDrag;
1859  QBrush mBackgroundBrush;
1860  QPixmap mBackgroundPixmap;
1861  QPixmap mScaledBackgroundPixmap;
1862  bool mBackgroundScaled;
1863  Qt::AspectRatioMode mBackgroundScaledMode;
1864  QCPLayer *mCurrentLayer;
1865  QCP::PlottingHints mPlottingHints;
1866  Qt::KeyboardModifier mMultiSelectModifier;
1867 
1868  // non-property members:
1869  QPixmap mPaintBuffer;
1870  QPoint mMousePressPos;
1871  QPointer<QCPLayoutElement> mMouseEventElement;
1872  bool mReplotting;
1873 
1874  // reimplemented virtual methods:
1875  virtual QSize minimumSizeHint() const;
1876  virtual QSize sizeHint() const;
1877  virtual void paintEvent(QPaintEvent *event);
1878  virtual void resizeEvent(QResizeEvent *event);
1879  virtual void mouseDoubleClickEvent(QMouseEvent *event);
1880  virtual void mousePressEvent(QMouseEvent *event);
1881  virtual void mouseMoveEvent(QMouseEvent *event);
1882  virtual void mouseReleaseEvent(QMouseEvent *event);
1883  virtual void wheelEvent(QWheelEvent *event);
1884 
1885  // introduced virtual methods:
1886  virtual void draw(QCPPainter *painter);
1887  virtual void axisRemoved(QCPAxis *axis);
1888  virtual void legendRemoved(QCPLegend *legend);
1889 
1890  // non-virtual methods:
1891  void updateLayerIndices() const;
1892  QCPLayerable *layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const;
1893  void drawBackground(QCPPainter *painter);
1894 
1895  friend class QCPLegend;
1896  friend class QCPAxis;
1897  friend class QCPLayer;
1898  friend class QCPAxisRect;
1899 };
1900 
1901 
1902 class QCP_LIB_DECL QCPColorGradient
1903 {
1904  Q_GADGET
1905 public:
1911  enum ColorInterpolation { ciRGB
1912  ,ciHSV
1913  };
1914  Q_ENUMS(ColorInterpolation)
1915 
1916 
1920  enum GradientPreset { gpGrayscale
1921  ,gpHot
1922  ,gpCold
1923  ,gpNight
1924  ,gpCandy
1925  ,gpGeography
1926  ,gpIon
1927  ,gpThermal
1928  ,gpPolar
1929  ,gpSpectrum
1930  ,gpJet
1931  ,gpHues
1932  };
1933  Q_ENUMS(GradientPreset)
1934 
1935  QCPColorGradient(GradientPreset preset=gpCold);
1936  bool operator==(const QCPColorGradient &other) const;
1937  bool operator!=(const QCPColorGradient &other) const { return !(*this == other); }
1938 
1939  // getters:
1940  int levelCount() const { return mLevelCount; }
1941  QMap<double, QColor> colorStops() const { return mColorStops; }
1942  ColorInterpolation colorInterpolation() const { return mColorInterpolation; }
1943  bool periodic() const { return mPeriodic; }
1944 
1945  // setters:
1946  void setLevelCount(int n);
1947  void setColorStops(const QMap<double, QColor> &colorStops);
1948  void setColorStopAt(double position, const QColor &color);
1949  void setColorInterpolation(ColorInterpolation interpolation);
1950  void setPeriodic(bool enabled);
1951 
1952  // non-property methods:
1953  void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false);
1954  QRgb color(double position, const QCPRange &range, bool logarithmic=false);
1955  void loadPreset(GradientPreset preset);
1956  void clearColorStops();
1957  QCPColorGradient inverted() const;
1958 
1959 protected:
1960  void updateColorBuffer();
1961 
1962  // property members:
1963  int mLevelCount;
1964  QMap<double, QColor> mColorStops;
1965  ColorInterpolation mColorInterpolation;
1966  bool mPeriodic;
1967 
1968  // non-property members:
1969  QVector<QRgb> mColorBuffer;
1970  bool mColorBufferInvalidated;
1971 };
1972 
1973 
1974 class QCP_LIB_DECL QCPAxisRect : public QCPLayoutElement
1975 {
1976  Q_OBJECT
1978  Q_PROPERTY(QPixmap background READ background WRITE setBackground)
1979  Q_PROPERTY(bool backgroundScaled READ backgroundScaled WRITE setBackgroundScaled)
1980  Q_PROPERTY(Qt::AspectRatioMode backgroundScaledMode READ backgroundScaledMode WRITE setBackgroundScaledMode)
1981  Q_PROPERTY(Qt::Orientations rangeDrag READ rangeDrag WRITE setRangeDrag)
1982  Q_PROPERTY(Qt::Orientations rangeZoom READ rangeZoom WRITE setRangeZoom)
1984 public:
1985  explicit QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true);
1986  virtual ~QCPAxisRect();
1987 
1988  // getters:
1989  QPixmap background() const { return mBackgroundPixmap; }
1990  bool backgroundScaled() const { return mBackgroundScaled; }
1991  Qt::AspectRatioMode backgroundScaledMode() const { return mBackgroundScaledMode; }
1992  Qt::Orientations rangeDrag() const { return mRangeDrag; }
1993  Qt::Orientations rangeZoom() const { return mRangeZoom; }
1994  QCPAxis *rangeDragAxis(Qt::Orientation orientation);
1995  QCPAxis *rangeZoomAxis(Qt::Orientation orientation);
1996  double rangeZoomFactor(Qt::Orientation orientation);
1997 
1998  // setters:
1999  void setBackground(const QPixmap &pm);
2000  void setBackground(const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding);
2001  void setBackground(const QBrush &brush);
2002  void setBackgroundScaled(bool scaled);
2003  void setBackgroundScaledMode(Qt::AspectRatioMode mode);
2004  void setRangeDrag(Qt::Orientations orientations);
2005  void setRangeZoom(Qt::Orientations orientations);
2006  void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical);
2007  void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical);
2008  void setRangeZoomFactor(double horizontalFactor, double verticalFactor);
2009  void setRangeZoomFactor(double factor);
2010 
2011  // non-property methods:
2012  int axisCount(QCPAxis::AxisType type) const;
2013  QCPAxis *axis(QCPAxis::AxisType type, int index=0) const;
2014  QList<QCPAxis*> axes(QCPAxis::AxisTypes types) const;
2015  QList<QCPAxis*> axes() const;
2016  QCPAxis *addAxis(QCPAxis::AxisType type, QCPAxis *axis=0);
2017  QList<QCPAxis*> addAxes(QCPAxis::AxisTypes types);
2018  bool removeAxis(QCPAxis *axis);
2019  QCPLayoutInset *insetLayout() const { return mInsetLayout; }
2020 
2021  void setupFullAxesBox(bool connectRanges=false);
2022  QList<QCPAbstractPlottable*> plottables() const;
2023  QList<QCPGraph*> graphs() const;
2024  QList<QCPAbstractItem*> items() const;
2025 
2026  // read-only interface imitating a QRect:
2027  int left() const { return mRect.left(); }
2028  int right() const { return mRect.right(); }
2029  int top() const { return mRect.top(); }
2030  int bottom() const { return mRect.bottom(); }
2031  int width() const { return mRect.width(); }
2032  int height() const { return mRect.height(); }
2033  QSize size() const { return mRect.size(); }
2034  QPoint topLeft() const { return mRect.topLeft(); }
2035  QPoint topRight() const { return mRect.topRight(); }
2036  QPoint bottomLeft() const { return mRect.bottomLeft(); }
2037  QPoint bottomRight() const { return mRect.bottomRight(); }
2038  QPoint center() const { return mRect.center(); }
2039 
2040  // reimplemented virtual methods:
2041  virtual void update(UpdatePhase phase);
2042  virtual QList<QCPLayoutElement*> elements(bool recursive) const;
2043 
2044 protected:
2045  // property members:
2046  QBrush mBackgroundBrush;
2047  QPixmap mBackgroundPixmap;
2048  QPixmap mScaledBackgroundPixmap;
2049  bool mBackgroundScaled;
2050  Qt::AspectRatioMode mBackgroundScaledMode;
2051  QCPLayoutInset *mInsetLayout;
2052  Qt::Orientations mRangeDrag, mRangeZoom;
2053  QPointer<QCPAxis> mRangeDragHorzAxis, mRangeDragVertAxis, mRangeZoomHorzAxis, mRangeZoomVertAxis;
2054  double mRangeZoomFactorHorz, mRangeZoomFactorVert;
2055  // non-property members:
2056  QCPRange mDragStartHorzRange, mDragStartVertRange;
2057  QCP::AntialiasedElements mAADragBackup, mNotAADragBackup;
2058  QPoint mDragStart;
2059  bool mDragging;
2060  QHash<QCPAxis::AxisType, QList<QCPAxis*> > mAxes;
2061 
2062  // reimplemented virtual methods:
2063  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2064  virtual void draw(QCPPainter *painter);
2065  virtual int calculateAutoMargin(QCP::MarginSide side);
2066  // events:
2067  virtual void mousePressEvent(QMouseEvent *event);
2068  virtual void mouseMoveEvent(QMouseEvent *event);
2069  virtual void mouseReleaseEvent(QMouseEvent *event);
2070  virtual void wheelEvent(QWheelEvent *event);
2071 
2072  // non-property methods:
2073  void drawBackground(QCPPainter *painter);
2074  void updateAxesOffset(QCPAxis::AxisType type);
2075 
2076 private:
2077  Q_DISABLE_COPY(QCPAxisRect)
2078 
2079  friend class QCustomPlot;
2080 };
2081 
2082 
2083 class QCP_LIB_DECL QCPAbstractLegendItem : public QCPLayoutElement
2084 {
2085  Q_OBJECT
2087  Q_PROPERTY(QCPLegend* parentLegend READ parentLegend)
2088  Q_PROPERTY(QFont font READ font WRITE setFont)
2089  Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
2090  Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
2091  Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
2092  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectionChanged)
2093  Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectableChanged)
2095 public:
2096  explicit QCPAbstractLegendItem(QCPLegend *parent);
2097 
2098  // getters:
2099  QCPLegend *parentLegend() const { return mParentLegend; }
2100  QFont font() const { return mFont; }
2101  QColor textColor() const { return mTextColor; }
2102  QFont selectedFont() const { return mSelectedFont; }
2103  QColor selectedTextColor() const { return mSelectedTextColor; }
2104  bool selectable() const { return mSelectable; }
2105  bool selected() const { return mSelected; }
2106 
2107  // setters:
2108  void setFont(const QFont &font);
2109  void setTextColor(const QColor &color);
2110  void setSelectedFont(const QFont &font);
2111  void setSelectedTextColor(const QColor &color);
2112  Q_SLOT void setSelectable(bool selectable);
2113  Q_SLOT void setSelected(bool selected);
2114 
2115  // reimplemented virtual methods:
2116  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2117 
2118 signals:
2119  void selectionChanged(bool selected);
2120  void selectableChanged(bool selectable);
2121 
2122 protected:
2123  // property members:
2124  QCPLegend *mParentLegend;
2125  QFont mFont;
2126  QColor mTextColor;
2127  QFont mSelectedFont;
2128  QColor mSelectedTextColor;
2129  bool mSelectable, mSelected;
2130 
2131  // reimplemented virtual methods:
2132  virtual QCP::Interaction selectionCategory() const;
2133  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2134  virtual QRect clipRect() const;
2135  virtual void draw(QCPPainter *painter) = 0;
2136  // events:
2137  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
2138  virtual void deselectEvent(bool *selectionStateChanged);
2139 
2140 private:
2141  Q_DISABLE_COPY(QCPAbstractLegendItem)
2142 
2143  friend class QCPLegend;
2144 };
2145 
2146 
2148 {
2149  Q_OBJECT
2150 public:
2152 
2153  // getters:
2154  QCPAbstractPlottable *plottable() { return mPlottable; }
2155 
2156 protected:
2157  // property members:
2158  QCPAbstractPlottable *mPlottable;
2159 
2160  // reimplemented virtual methods:
2161  virtual void draw(QCPPainter *painter);
2162  virtual QSize minimumSizeHint() const;
2163 
2164  // non-virtual methods:
2165  QPen getIconBorderPen() const;
2166  QColor getTextColor() const;
2167  QFont getFont() const;
2168 };
2169 
2170 
2171 class QCP_LIB_DECL QCPLegend : public QCPLayoutGrid
2172 {
2173  Q_OBJECT
2175  Q_PROPERTY(QPen borderPen READ borderPen WRITE setBorderPen)
2176  Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
2177  Q_PROPERTY(QFont font READ font WRITE setFont)
2178  Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
2179  Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
2180  Q_PROPERTY(int iconTextPadding READ iconTextPadding WRITE setIconTextPadding)
2181  Q_PROPERTY(QPen iconBorderPen READ iconBorderPen WRITE setIconBorderPen)
2182  Q_PROPERTY(SelectableParts selectableParts READ selectableParts WRITE setSelectableParts NOTIFY selectionChanged)
2183  Q_PROPERTY(SelectableParts selectedParts READ selectedParts WRITE setSelectedParts NOTIFY selectableChanged)
2184  Q_PROPERTY(QPen selectedBorderPen READ selectedBorderPen WRITE setSelectedBorderPen)
2185  Q_PROPERTY(QPen selectedIconBorderPen READ selectedIconBorderPen WRITE setSelectedIconBorderPen)
2186  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
2187  Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
2188  Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
2190 public:
2196  enum SelectablePart { spNone = 0x000
2197  ,spLegendBox = 0x001
2198  ,spItems = 0x002
2199  };
2200  Q_FLAGS(SelectablePart SelectableParts)
2201  Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
2202 
2203  explicit QCPLegend();
2204  virtual ~QCPLegend();
2205 
2206  // getters:
2207  QPen borderPen() const { return mBorderPen; }
2208  QBrush brush() const { return mBrush; }
2209  QFont font() const { return mFont; }
2210  QColor textColor() const { return mTextColor; }
2211  QSize iconSize() const { return mIconSize; }
2212  int iconTextPadding() const { return mIconTextPadding; }
2213  QPen iconBorderPen() const { return mIconBorderPen; }
2214  SelectableParts selectableParts() const { return mSelectableParts; }
2215  SelectableParts selectedParts() const;
2216  QPen selectedBorderPen() const { return mSelectedBorderPen; }
2217  QPen selectedIconBorderPen() const { return mSelectedIconBorderPen; }
2218  QBrush selectedBrush() const { return mSelectedBrush; }
2219  QFont selectedFont() const { return mSelectedFont; }
2220  QColor selectedTextColor() const { return mSelectedTextColor; }
2221 
2222  // setters:
2223  void setBorderPen(const QPen &pen);
2224  void setBrush(const QBrush &brush);
2225  void setFont(const QFont &font);
2226  void setTextColor(const QColor &color);
2227  void setIconSize(const QSize &size);
2228  void setIconSize(int width, int height);
2229  void setIconTextPadding(int padding);
2230  void setIconBorderPen(const QPen &pen);
2231  Q_SLOT void setSelectableParts(const SelectableParts &selectableParts);
2232  Q_SLOT void setSelectedParts(const SelectableParts &selectedParts);
2233  void setSelectedBorderPen(const QPen &pen);
2234  void setSelectedIconBorderPen(const QPen &pen);
2235  void setSelectedBrush(const QBrush &brush);
2236  void setSelectedFont(const QFont &font);
2237  void setSelectedTextColor(const QColor &color);
2238 
2239  // reimplemented virtual methods:
2240  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2241 
2242  // non-virtual methods:
2243  QCPAbstractLegendItem *item(int index) const;
2244  QCPPlottableLegendItem *itemWithPlottable(const QCPAbstractPlottable *plottable) const;
2245  int itemCount() const;
2246  bool hasItem(QCPAbstractLegendItem *item) const;
2247  bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const;
2248  bool addItem(QCPAbstractLegendItem *item);
2249  bool removeItem(int index);
2250  bool removeItem(QCPAbstractLegendItem *item);
2251  void clearItems();
2252  QList<QCPAbstractLegendItem*> selectedItems() const;
2253 
2254 signals:
2255  void selectionChanged(QCPLegend::SelectableParts parts);
2256  void selectableChanged(QCPLegend::SelectableParts parts);
2257 
2258 protected:
2259  // property members:
2260  QPen mBorderPen, mIconBorderPen;
2261  QBrush mBrush;
2262  QFont mFont;
2263  QColor mTextColor;
2264  QSize mIconSize;
2265  int mIconTextPadding;
2266  SelectableParts mSelectedParts, mSelectableParts;
2267  QPen mSelectedBorderPen, mSelectedIconBorderPen;
2268  QBrush mSelectedBrush;
2269  QFont mSelectedFont;
2270  QColor mSelectedTextColor;
2271 
2272  // reimplemented virtual methods:
2273  virtual void parentPlotInitialized(QCustomPlot *parentPlot);
2274  virtual QCP::Interaction selectionCategory() const;
2275  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2276  virtual void draw(QCPPainter *painter);
2277  // events:
2278  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
2279  virtual void deselectEvent(bool *selectionStateChanged);
2280 
2281  // non-virtual methods:
2282  QPen getBorderPen() const;
2283  QBrush getBrush() const;
2284 
2285 private:
2286  Q_DISABLE_COPY(QCPLegend)
2287 
2288  friend class QCustomPlot;
2289  friend class QCPAbstractLegendItem;
2290 };
2291 Q_DECLARE_OPERATORS_FOR_FLAGS(QCPLegend::SelectableParts)
2292 Q_DECLARE_METATYPE(QCPLegend::SelectablePart)
2293 
2294 
2295 class QCP_LIB_DECL QCPPlotTitle : public QCPLayoutElement
2296 {
2297  Q_OBJECT
2299  Q_PROPERTY(QString text READ text WRITE setText)
2300  Q_PROPERTY(QFont font READ font WRITE setFont)
2301  Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
2302  Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
2303  Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
2304  Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
2305  Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
2307 public:
2308  explicit QCPPlotTitle(QCustomPlot *parentPlot);
2309  explicit QCPPlotTitle(QCustomPlot *parentPlot, const QString &text);
2310 
2311  // getters:
2312  QString text() const { return mText; }
2313  QFont font() const { return mFont; }
2314  QColor textColor() const { return mTextColor; }
2315  QFont selectedFont() const { return mSelectedFont; }
2316  QColor selectedTextColor() const { return mSelectedTextColor; }
2317  bool selectable() const { return mSelectable; }
2318  bool selected() const { return mSelected; }
2319 
2320  // setters:
2321  void setText(const QString &text);
2322  void setFont(const QFont &font);
2323  void setTextColor(const QColor &color);
2324  void setSelectedFont(const QFont &font);
2325  void setSelectedTextColor(const QColor &color);
2326  Q_SLOT void setSelectable(bool selectable);
2327  Q_SLOT void setSelected(bool selected);
2328 
2329  // reimplemented virtual methods:
2330  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2331 
2332 signals:
2333  void selectionChanged(bool selected);
2334  void selectableChanged(bool selectable);
2335 
2336 protected:
2337  // property members:
2338  QString mText;
2339  QFont mFont;
2340  QColor mTextColor;
2341  QFont mSelectedFont;
2342  QColor mSelectedTextColor;
2343  QRect mTextBoundingRect;
2344  bool mSelectable, mSelected;
2345 
2346  // reimplemented virtual methods:
2347  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2348  virtual void draw(QCPPainter *painter);
2349  virtual QSize minimumSizeHint() const;
2350  virtual QSize maximumSizeHint() const;
2351  // events:
2352  virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
2353  virtual void deselectEvent(bool *selectionStateChanged);
2354 
2355  // non-virtual methods:
2356  QFont mainFont() const;
2357  QColor mainTextColor() const;
2358 
2359 private:
2360  Q_DISABLE_COPY(QCPPlotTitle)
2361 };
2362 
2363 
2365 {
2366  Q_OBJECT
2367 public:
2368  explicit QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale);
2369 protected:
2370  QCPColorScale *mParentColorScale;
2371  QImage mGradientImage;
2372  bool mGradientImageInvalidated;
2373  // re-using some methods of QCPAxisRect to make them available to friend class QCPColorScale
2374  using QCPAxisRect::calculateAutoMargin;
2379  using QCPAxisRect::update;
2380  virtual void draw(QCPPainter *painter);
2381  void updateGradientImage();
2382  Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts);
2383  Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts);
2384  friend class QCPColorScale;
2385 };
2386 
2387 
2388 class QCP_LIB_DECL QCPColorScale : public QCPLayoutElement
2389 {
2390  Q_OBJECT
2392  Q_PROPERTY(QCPAxis::AxisType type READ type WRITE setType)
2393  Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
2394  Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
2395  Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
2396  Q_PROPERTY(QString label READ label WRITE setLabel)
2397  Q_PROPERTY(int barWidth READ barWidth WRITE setBarWidth)
2398  Q_PROPERTY(bool rangeDrag READ rangeDrag WRITE setRangeDrag)
2399  Q_PROPERTY(bool rangeZoom READ rangeZoom WRITE setRangeZoom)
2401 public:
2402  explicit QCPColorScale(QCustomPlot *parentPlot);
2403  virtual ~QCPColorScale();
2404 
2405  // getters:
2406  QCPAxis *axis() const { return mColorAxis.data(); }
2407  QCPAxis::AxisType type() const { return mType; }
2408  QCPRange dataRange() const { return mDataRange; }
2409  QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
2410  QCPColorGradient gradient() const { return mGradient; }
2411  QString label() const;
2412  int barWidth () const { return mBarWidth; }
2413  bool rangeDrag() const;
2414  bool rangeZoom() const;
2415 
2416  // setters:
2417  void setType(QCPAxis::AxisType type);
2418  Q_SLOT void setDataRange(const QCPRange &dataRange);
2419  Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
2420  Q_SLOT void setGradient(const QCPColorGradient &gradient);
2421  void setLabel(const QString &str);
2422  void setBarWidth(int width);
2423  void setRangeDrag(bool enabled);
2424  void setRangeZoom(bool enabled);
2425 
2426  // non-property methods:
2427  QList<QCPColorMap*> colorMaps() const;
2428  void rescaleDataRange(bool onlyVisibleMaps);
2429 
2430  // reimplemented virtual methods:
2431  virtual void update(UpdatePhase phase);
2432 
2433 signals:
2434  void dataRangeChanged(QCPRange newRange);
2435  void dataScaleTypeChanged(QCPAxis::ScaleType scaleType);
2436  void gradientChanged(QCPColorGradient newGradient);
2437 
2438 protected:
2439  // property members:
2440  QCPAxis::AxisType mType;
2441  QCPRange mDataRange;
2442  QCPAxis::ScaleType mDataScaleType;
2443  QCPColorGradient mGradient;
2444  int mBarWidth;
2445 
2446  // non-property members:
2447  QPointer<QCPColorScaleAxisRectPrivate> mAxisRect;
2448  QPointer<QCPAxis> mColorAxis;
2449 
2450  // reimplemented virtual methods:
2451  virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
2452  // events:
2453  virtual void mousePressEvent(QMouseEvent *event);
2454  virtual void mouseMoveEvent(QMouseEvent *event);
2455  virtual void mouseReleaseEvent(QMouseEvent *event);
2456  virtual void wheelEvent(QWheelEvent *event);
2457 
2458 private:
2459  Q_DISABLE_COPY(QCPColorScale)
2460 
2461  friend class QCPColorScaleAxisRectPrivate;
2462 };
2463 
2464 
2469 class QCP_LIB_DECL QCPData
2470 {
2471 public:
2472  QCPData();
2473  QCPData(double key, double value);
2474  double key, value;
2475  double keyErrorPlus, keyErrorMinus;
2476  double valueErrorPlus, valueErrorMinus;
2477 };
2478 Q_DECLARE_TYPEINFO(QCPData, Q_MOVABLE_TYPE);
2479 
2487 typedef QMap<double, QCPData> QCPDataMap;
2488 typedef QMapIterator<double, QCPData> QCPDataMapIterator;
2489 typedef QMutableMapIterator<double, QCPData> QCPDataMutableMapIterator;
2490 
2491 
2492 class QCP_LIB_DECL QCPGraph : public QCPAbstractPlottable
2493 {
2494  Q_OBJECT
2496  Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
2497  Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
2498  Q_PROPERTY(ErrorType errorType READ errorType WRITE setErrorType)
2499  Q_PROPERTY(QPen errorPen READ errorPen WRITE setErrorPen)
2500  Q_PROPERTY(double errorBarSize READ errorBarSize WRITE setErrorBarSize)
2501  Q_PROPERTY(bool errorBarSkipSymbol READ errorBarSkipSymbol WRITE setErrorBarSkipSymbol)
2502  Q_PROPERTY(QCPGraph* channelFillGraph READ channelFillGraph WRITE setChannelFillGraph)
2503  Q_PROPERTY(bool adaptiveSampling READ adaptiveSampling WRITE setAdaptiveSampling)
2505 public:
2511  enum LineStyle { lsNone
2512  ,lsLine
2514  ,lsStepLeft
2515  ,lsStepRight
2516  ,lsStepCenter
2517  ,lsImpulse
2518  };
2519  Q_ENUMS(LineStyle)
2523  enum ErrorType { etNone
2524  ,etKey
2525  ,etValue
2526  ,etBoth
2527  };
2528  Q_ENUMS(ErrorType)
2529 
2530  explicit QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis);
2531  virtual ~QCPGraph();
2532 
2533  // getters:
2534  QCPDataMap *data() const { return mData; }
2535  LineStyle lineStyle() const { return mLineStyle; }
2536  QCPScatterStyle scatterStyle() const { return mScatterStyle; }
2537  ErrorType errorType() const { return mErrorType; }
2538  QPen errorPen() const { return mErrorPen; }
2539  double errorBarSize() const { return mErrorBarSize; }
2540  bool errorBarSkipSymbol() const { return mErrorBarSkipSymbol; }
2541  QCPGraph *channelFillGraph() const { return mChannelFillGraph.data(); }
2542  bool adaptiveSampling() const { return mAdaptiveSampling; }
2543 
2544  // setters:
2545  void setData(QCPDataMap *data, bool copy=false);
2546  void setData(const QVector<double> &key, const QVector<double> &value);
2547  void setDataKeyError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyError);
2548  void setDataKeyError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyErrorMinus, const QVector<double> &keyErrorPlus);
2549  void setDataValueError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &valueError);
2550  void setDataValueError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &valueErrorMinus, const QVector<double> &valueErrorPlus);
2551  void setDataBothError(const QVector<double> &key, const QVector<double> &value, const QVector<double> &keyError, const QVector<double> &valueError);
2552  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);
2553  void setLineStyle(LineStyle ls);
2554  void setScatterStyle(const QCPScatterStyle &style);
2555  void setErrorType(ErrorType errorType);
2556  void setErrorPen(const QPen &pen);
2557  void setErrorBarSize(double size);
2558  void setErrorBarSkipSymbol(bool enabled);
2559  void setChannelFillGraph(QCPGraph *targetGraph);
2560  void setAdaptiveSampling(bool enabled);
2561 
2562  // non-property methods:
2563  void addData(const QCPDataMap &dataMap);
2564  void addData(const QCPData &data);
2565  void addData(double key, double value);
2566  void addData(const QVector<double> &keys, const QVector<double> &values);
2567  void removeDataBefore(double key);
2568  void removeDataAfter(double key);
2569  void removeData(double fromKey, double toKey);
2570  void removeData(double key);
2571 
2572  // reimplemented virtual methods:
2573  virtual void clearData();
2574  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2578  void rescaleAxes(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
2579  void rescaleKeyAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
2580  void rescaleValueAxis(bool onlyEnlarge, bool includeErrorBars) const; // overloads base class interface
2581 
2582 protected:
2583  // property members:
2584  QCPDataMap *mData;
2585  QPen mErrorPen;
2586  LineStyle mLineStyle;
2587  QCPScatterStyle mScatterStyle;
2588  ErrorType mErrorType;
2589  double mErrorBarSize;
2590  bool mErrorBarSkipSymbol;
2591  QPointer<QCPGraph> mChannelFillGraph;
2592  bool mAdaptiveSampling;
2593 
2594  // reimplemented virtual methods:
2595  virtual void draw(QCPPainter *painter);
2596  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2597  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2598  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2599  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
2600  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
2601 
2602  // introduced virtual methods:
2603  virtual void drawFill(QCPPainter *painter, QVector<QPointF> *lineData) const;
2604  virtual void drawScatterPlot(QCPPainter *painter, QVector<QCPData> *scatterData) const;
2605  virtual void drawLinePlot(QCPPainter *painter, QVector<QPointF> *lineData) const;
2606  virtual void drawImpulsePlot(QCPPainter *painter, QVector<QPointF> *lineData) const;
2607 
2608  // non-virtual methods:
2609  void getPreparedData(QVector<QCPData> *lineData, QVector<QCPData> *scatterData) const;
2610  void getPlotData(QVector<QPointF> *lineData, QVector<QCPData> *scatterData) const;
2611  void getScatterPlotData(QVector<QCPData> *scatterData) const;
2612  void getLinePlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2613  void getStepLeftPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2614  void getStepRightPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2615  void getStepCenterPlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2616  void getImpulsePlotData(QVector<QPointF> *linePixelData, QVector<QCPData> *scatterData) const;
2617  void drawError(QCPPainter *painter, double x, double y, const QCPData &data) const;
2618  void getVisibleDataBounds(QCPDataMap::const_iterator &lower, QCPDataMap::const_iterator &upper) const;
2619  int countDataInBounds(const QCPDataMap::const_iterator &lower, const QCPDataMap::const_iterator &upper, int maxCount) const;
2620  void addFillBasePoints(QVector<QPointF> *lineData) const;
2621  void removeFillBasePoints(QVector<QPointF> *lineData) const;
2622  QPointF lowerFillBasePoint(double lowerKey) const;
2623  QPointF upperFillBasePoint(double upperKey) const;
2624  const QPolygonF getChannelFillPolygon(const QVector<QPointF> *lineData) const;
2625  int findIndexBelowX(const QVector<QPointF> *data, double x) const;
2626  int findIndexAboveX(const QVector<QPointF> *data, double x) const;
2627  int findIndexBelowY(const QVector<QPointF> *data, double y) const;
2628  int findIndexAboveY(const QVector<QPointF> *data, double y) const;
2629  double pointDistance(const QPointF &pixelPoint) const;
2630 
2631  friend class QCustomPlot;
2632  friend class QCPLegend;
2633 };
2634 
2635 
2640 class QCP_LIB_DECL QCPCurveData
2641 {
2642 public:
2643  QCPCurveData();
2644  QCPCurveData(double t, double key, double value);
2645  double t, key, value;
2646 };
2647 Q_DECLARE_TYPEINFO(QCPCurveData, Q_MOVABLE_TYPE);
2648 
2657 typedef QMap<double, QCPCurveData> QCPCurveDataMap;
2658 typedef QMapIterator<double, QCPCurveData> QCPCurveDataMapIterator;
2659 typedef QMutableMapIterator<double, QCPCurveData> QCPCurveDataMutableMapIterator;
2660 
2661 
2662 class QCP_LIB_DECL QCPCurve : public QCPAbstractPlottable
2663 {
2664  Q_OBJECT
2666  Q_PROPERTY(QCPScatterStyle scatterStyle READ scatterStyle WRITE setScatterStyle)
2667  Q_PROPERTY(LineStyle lineStyle READ lineStyle WRITE setLineStyle)
2669 public:
2675  enum LineStyle { lsNone
2676  ,lsLine
2677  };
2678  explicit QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis);
2679  virtual ~QCPCurve();
2680 
2681  // getters:
2682  QCPCurveDataMap *data() const { return mData; }
2683  QCPScatterStyle scatterStyle() const { return mScatterStyle; }
2684  LineStyle lineStyle() const { return mLineStyle; }
2685 
2686  // setters:
2687  void setData(QCPCurveDataMap *data, bool copy=false);
2688  void setData(const QVector<double> &t, const QVector<double> &key, const QVector<double> &value);
2689  void setData(const QVector<double> &key, const QVector<double> &value);
2690  void setScatterStyle(const QCPScatterStyle &style);
2691  void setLineStyle(LineStyle style);
2692 
2693  // non-property methods:
2694  void addData(const QCPCurveDataMap &dataMap);
2695  void addData(const QCPCurveData &data);
2696  void addData(double t, double key, double value);
2697  void addData(double key, double value);
2698  void addData(const QVector<double> &ts, const QVector<double> &keys, const QVector<double> &values);
2699  void removeDataBefore(double t);
2700  void removeDataAfter(double t);
2701  void removeData(double fromt, double tot);
2702  void removeData(double t);
2703 
2704  // reimplemented virtual methods:
2705  virtual void clearData();
2706  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2707 
2708 protected:
2709  // property members:
2710  QCPCurveDataMap *mData;
2711  QCPScatterStyle mScatterStyle;
2712  LineStyle mLineStyle;
2713 
2714  // reimplemented virtual methods:
2715  virtual void draw(QCPPainter *painter);
2716  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2717  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2718  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2719 
2720  // introduced virtual methods:
2721  virtual void drawScatterPlot(QCPPainter *painter, const QVector<QPointF> *pointData) const;
2722 
2723  // non-virtual methods:
2724  void getCurveData(QVector<QPointF> *lineData) const;
2725  int getRegion(double x, double y, double rectLeft, double rectTop, double rectRight, double rectBottom) const;
2726  QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const;
2727  QVector<QPointF> getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const;
2728  bool mayTraverse(int prevRegion, int currentRegion) const;
2729  bool getTraverse(double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom, QPointF &crossA, QPointF &crossB) const;
2730  void getTraverseCornerPoints(int prevRegion, int currentRegion, double rectLeft, double rectTop, double rectRight, double rectBottom, QVector<QPointF> &beforeTraverse, QVector<QPointF> &afterTraverse) const;
2731  double pointDistance(const QPointF &pixelPoint) const;
2732 
2733  friend class QCustomPlot;
2734  friend class QCPLegend;
2735 };
2736 
2737 
2742 class QCP_LIB_DECL QCPBarsGroup : public QObject
2743 {
2744  Q_OBJECT
2746  Q_PROPERTY(SpacingType spacingType READ spacingType WRITE setSpacingType)
2747  Q_PROPERTY(double spacing READ spacing WRITE setSpacing)
2749 public:
2756  enum SpacingType { stAbsolute
2757  ,stAxisRectRatio
2758  ,stPlotCoords
2759  };
2760  QCPBarsGroup(QCustomPlot *parentPlot);
2761  ~QCPBarsGroup();
2762 
2763  // getters:
2764  SpacingType spacingType() const { return mSpacingType; }
2765  double spacing() const { return mSpacing; }
2766 
2767  // setters:
2768  void setSpacingType(SpacingType spacingType);
2769  void setSpacing(double spacing);
2770 
2771  // non-virtual methods:
2772  QList<QCPBars*> bars() const { return mBars; }
2773  QCPBars* bars(int index) const;
2774  int size() const { return mBars.size(); }
2775  bool isEmpty() const { return mBars.isEmpty(); }
2776  void clear();
2777  bool contains(QCPBars *bars) const { return mBars.contains(bars); }
2778  void append(QCPBars *bars);
2779  void insert(int i, QCPBars *bars);
2780  void remove(QCPBars *bars);
2781 
2782 protected:
2783  // non-property members:
2784  QCustomPlot *mParentPlot;
2785  SpacingType mSpacingType;
2786  double mSpacing;
2787  QList<QCPBars*> mBars;
2788 
2789  // non-virtual methods:
2790  void registerBars(QCPBars *bars);
2791  void unregisterBars(QCPBars *bars);
2792 
2793  // virtual methods:
2794  double keyPixelOffset(const QCPBars *bars, double keyCoord);
2795  double getPixelSpacing(const QCPBars *bars, double keyCoord);
2796 
2797 private:
2798  Q_DISABLE_COPY(QCPBarsGroup)
2799 
2800  friend class QCPBars;
2801 };
2802 
2803 
2804 class QCP_LIB_DECL QCPBarData
2805 {
2806 public:
2807  QCPBarData();
2808  QCPBarData(double key, double value);
2809  double key, value;
2810 };
2811 Q_DECLARE_TYPEINFO(QCPBarData, Q_MOVABLE_TYPE);
2812 
2820 typedef QMap<double, QCPBarData> QCPBarDataMap;
2821 typedef QMapIterator<double, QCPBarData> QCPBarDataMapIterator;
2822 typedef QMutableMapIterator<double, QCPBarData> QCPBarDataMutableMapIterator;
2823 
2824 
2825 class QCP_LIB_DECL QCPBars : public QCPAbstractPlottable
2826 {
2827  Q_OBJECT
2829  Q_PROPERTY(double width READ width WRITE setWidth)
2830  Q_PROPERTY(WidthType widthType READ widthType WRITE setWidthType)
2831  Q_PROPERTY(QCPBarsGroup* barsGroup READ barsGroup WRITE setBarsGroup)
2832  Q_PROPERTY(double baseValue READ baseValue WRITE setBaseValue)
2833  Q_PROPERTY(QCPBars* barBelow READ barBelow)
2834  Q_PROPERTY(QCPBars* barAbove READ barAbove)
2836 public:
2843  enum WidthType { wtAbsolute
2844  ,wtAxisRectRatio
2845  ,wtPlotCoords
2846  };
2847  Q_ENUMS(WidthType)
2848 
2849  explicit QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis);
2850  virtual ~QCPBars();
2851 
2852  // getters:
2853  double width() const { return mWidth; }
2854  WidthType widthType() const { return mWidthType; }
2855  QCPBarsGroup *barsGroup() const { return mBarsGroup; }
2856  double baseValue() const { return mBaseValue; }
2857  QCPBars *barBelow() const { return mBarBelow.data(); }
2858  QCPBars *barAbove() const { return mBarAbove.data(); }
2859  QCPBarDataMap *data() const { return mData; }
2860 
2861  // setters:
2862  void setWidth(double width);
2863  void setWidthType(WidthType widthType);
2864  void setBarsGroup(QCPBarsGroup *barsGroup);
2865  void setBaseValue(double baseValue);
2866  void setData(QCPBarDataMap *data, bool copy=false);
2867  void setData(const QVector<double> &key, const QVector<double> &value);
2868 
2869  // non-property methods:
2870  void moveBelow(QCPBars *bars);
2871  void moveAbove(QCPBars *bars);
2872  void addData(const QCPBarDataMap &dataMap);
2873  void addData(const QCPBarData &data);
2874  void addData(double key, double value);
2875  void addData(const QVector<double> &keys, const QVector<double> &values);
2876  void removeDataBefore(double key);
2877  void removeDataAfter(double key);
2878  void removeData(double fromKey, double toKey);
2879  void removeData(double key);
2880 
2881  // reimplemented virtual methods:
2882  virtual void clearData();
2883  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2884 
2885 protected:
2886  // property members:
2887  QCPBarDataMap *mData;
2888  double mWidth;
2889  WidthType mWidthType;
2890  QCPBarsGroup *mBarsGroup;
2891  double mBaseValue;
2892  QPointer<QCPBars> mBarBelow, mBarAbove;
2893 
2894  // reimplemented virtual methods:
2895  virtual void draw(QCPPainter *painter);
2896  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2897  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2898  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2899 
2900  // non-virtual methods:
2901  void getVisibleDataBounds(QCPBarDataMap::const_iterator &lower, QCPBarDataMap::const_iterator &upperEnd) const;
2902  QPolygonF getBarPolygon(double key, double value) const;
2903  void getPixelWidth(double key, double &lower, double &upper) const;
2904  double getStackedBaseValue(double key, bool positive) const;
2905  static void connectBars(QCPBars* lower, QCPBars* upper);
2906 
2907  friend class QCustomPlot;
2908  friend class QCPLegend;
2909  friend class QCPBarsGroup;
2910 };
2911 
2912 
2917 class QCP_LIB_DECL QCPStatisticalBox : public QCPAbstractPlottable
2918 {
2919  Q_OBJECT
2921  Q_PROPERTY(double key READ key WRITE setKey)
2922  Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
2923  Q_PROPERTY(double lowerQuartile READ lowerQuartile WRITE setLowerQuartile)
2924  Q_PROPERTY(double median READ median WRITE setMedian)
2925  Q_PROPERTY(double upperQuartile READ upperQuartile WRITE setUpperQuartile)
2926  Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
2927  Q_PROPERTY(QVector<double> outliers READ outliers WRITE setOutliers)
2928  Q_PROPERTY(double width READ width WRITE setWidth)
2929  Q_PROPERTY(double whiskerWidth READ whiskerWidth WRITE setWhiskerWidth)
2930  Q_PROPERTY(QPen whiskerPen READ whiskerPen WRITE setWhiskerPen)
2931  Q_PROPERTY(QPen whiskerBarPen READ whiskerBarPen WRITE setWhiskerBarPen)
2932  Q_PROPERTY(QPen medianPen READ medianPen WRITE setMedianPen)
2933  Q_PROPERTY(QCPScatterStyle outlierStyle READ outlierStyle WRITE setOutlierStyle)
2935 public:
2936  explicit QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis);
2937 
2938  // getters:
2939  double key() const { return mKey; }
2940  double minimum() const { return mMinimum; }
2941  double lowerQuartile() const { return mLowerQuartile; }
2942  double median() const { return mMedian; }
2943  double upperQuartile() const { return mUpperQuartile; }
2944  double maximum() const { return mMaximum; }
2945  QVector<double> outliers() const { return mOutliers; }
2946  double width() const { return mWidth; }
2947  double whiskerWidth() const { return mWhiskerWidth; }
2948  QPen whiskerPen() const { return mWhiskerPen; }
2949  QPen whiskerBarPen() const { return mWhiskerBarPen; }
2950  QPen medianPen() const { return mMedianPen; }
2951  QCPScatterStyle outlierStyle() const { return mOutlierStyle; }
2952 
2953  // setters:
2954  void setKey(double key);
2955  void setMinimum(double value);
2956  void setLowerQuartile(double value);
2957  void setMedian(double value);
2958  void setUpperQuartile(double value);
2959  void setMaximum(double value);
2960  void setOutliers(const QVector<double> &values);
2961  void setData(double key, double minimum, double lowerQuartile, double median, double upperQuartile, double maximum);
2962  void setWidth(double width);
2963  void setWhiskerWidth(double width);
2964  void setWhiskerPen(const QPen &pen);
2965  void setWhiskerBarPen(const QPen &pen);
2966  void setMedianPen(const QPen &pen);
2967  void setOutlierStyle(const QCPScatterStyle &style);
2968 
2969  // non-property methods:
2970  virtual void clearData();
2971  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
2972 
2973 protected:
2974  // property members:
2975  QVector<double> mOutliers;
2976  double mKey, mMinimum, mLowerQuartile, mMedian, mUpperQuartile, mMaximum;
2977  double mWidth;
2978  double mWhiskerWidth;
2979  QPen mWhiskerPen, mWhiskerBarPen, mMedianPen;
2980  QCPScatterStyle mOutlierStyle;
2981 
2982  // reimplemented virtual methods:
2983  virtual void draw(QCPPainter *painter);
2984  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
2985  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2986  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
2987 
2988  // introduced virtual methods:
2989  virtual void drawQuartileBox(QCPPainter *painter, QRectF *quartileBox=0) const;
2990  virtual void drawMedian(QCPPainter *painter) const;
2991  virtual void drawWhiskers(QCPPainter *painter) const;
2992  virtual void drawOutliers(QCPPainter *painter) const;
2993 
2994  friend class QCustomPlot;
2995  friend class QCPLegend;
2996 };
2997 
2998 
2999 class QCP_LIB_DECL QCPColorMapData
3000 {
3001 public:
3002  QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange);
3003  ~QCPColorMapData();
3004  QCPColorMapData(const QCPColorMapData &other);
3005  QCPColorMapData &operator=(const QCPColorMapData &other);
3006 
3007  // getters:
3008  int keySize() const { return mKeySize; }
3009  int valueSize() const { return mValueSize; }
3010  QCPRange keyRange() const { return mKeyRange; }
3011  QCPRange valueRange() const { return mValueRange; }
3012  QCPRange dataBounds() const { return mDataBounds; }
3013  double data(double key, double value);
3014  double cell(int keyIndex, int valueIndex);
3015 
3016  // setters:
3017  void setSize(int keySize, int valueSize);
3018  void setKeySize(int keySize);
3019  void setValueSize(int valueSize);
3020  void setRange(const QCPRange &keyRange, const QCPRange &valueRange);
3021  void setKeyRange(const QCPRange &keyRange);
3022  void setValueRange(const QCPRange &valueRange);
3023  void setData(double key, double value, double z);
3024  void setCell(int keyIndex, int valueIndex, double z);
3025 
3026  // non-property methods:
3027  void recalculateDataBounds();
3028  void clear();
3029  void fill(double z);
3030  bool isEmpty() const { return mIsEmpty; }
3031  void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const;
3032  void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const;
3033 
3034 protected:
3035  // property members:
3036  int mKeySize, mValueSize;
3037  QCPRange mKeyRange, mValueRange;
3038  bool mIsEmpty;
3039  // non-property members:
3040  double *mData;
3041  QCPRange mDataBounds;
3042  bool mDataModified;
3043 
3044  friend class QCPColorMap;
3045 };
3046 
3047 
3048 class QCP_LIB_DECL QCPColorMap : public QCPAbstractPlottable
3049 {
3050  Q_OBJECT
3052  Q_PROPERTY(QCPRange dataRange READ dataRange WRITE setDataRange NOTIFY dataRangeChanged)
3053  Q_PROPERTY(QCPAxis::ScaleType dataScaleType READ dataScaleType WRITE setDataScaleType NOTIFY dataScaleTypeChanged)
3054  Q_PROPERTY(QCPColorGradient gradient READ gradient WRITE setGradient NOTIFY gradientChanged)
3055  Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate)
3056  Q_PROPERTY(bool tightBoundary READ tightBoundary WRITE setTightBoundary)
3057  Q_PROPERTY(QCPColorScale* colorScale READ colorScale WRITE setColorScale)
3059 public:
3060  explicit QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis);
3061  virtual ~QCPColorMap();
3062 
3063  // getters:
3064  QCPColorMapData *data() const { return mMapData; }
3065  QCPRange dataRange() const { return mDataRange; }
3066  QCPAxis::ScaleType dataScaleType() const { return mDataScaleType; }
3067  bool interpolate() const { return mInterpolate; }
3068  bool tightBoundary() const { return mTightBoundary; }
3069  QCPColorGradient gradient() const { return mGradient; }
3070  QCPColorScale *colorScale() const { return mColorScale.data(); }
3071 
3072  // setters:
3073  void setData(QCPColorMapData *data, bool copy=false);
3074  Q_SLOT void setDataRange(const QCPRange &dataRange);
3075  Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType);
3076  Q_SLOT void setGradient(const QCPColorGradient &gradient);
3077  void setInterpolate(bool enabled);
3078  void setTightBoundary(bool enabled);
3079  void setColorScale(QCPColorScale *colorScale);
3080 
3081  // non-property methods:
3082  void rescaleDataRange(bool recalculateDataBounds=false);
3083  Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18));
3084 
3085  // reimplemented virtual methods:
3086  virtual void clearData();
3087  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3088 
3089 signals:
3090  void dataRangeChanged(QCPRange newRange);
3091  void dataScaleTypeChanged(QCPAxis::ScaleType scaleType);
3092  void gradientChanged(QCPColorGradient newGradient);
3093 
3094 protected:
3095  // property members:
3096  QCPRange mDataRange;
3097  QCPAxis::ScaleType mDataScaleType;
3098  QCPColorMapData *mMapData;
3099  QCPColorGradient mGradient;
3100  bool mInterpolate;
3101  bool mTightBoundary;
3102  QPointer<QCPColorScale> mColorScale;
3103  // non-property members:
3104  QImage mMapImage;
3105  QPixmap mLegendIcon;
3106  bool mMapImageInvalidated;
3107 
3108  // introduced virtual methods:
3109  virtual void updateMapImage();
3110 
3111  // reimplemented virtual methods:
3112  virtual void draw(QCPPainter *painter);
3113  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
3114  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
3115  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
3116 
3117  friend class QCustomPlot;
3118  friend class QCPLegend;
3119 };
3120 
3121 
3126 class QCP_LIB_DECL QCPFinancialData
3127 {
3128 public:
3129  QCPFinancialData();
3130  QCPFinancialData(double key, double open, double high, double low, double close);
3131  double key, open, high, low, close;
3132 };
3133 Q_DECLARE_TYPEINFO(QCPFinancialData, Q_MOVABLE_TYPE);
3134 
3142 typedef QMap<double, QCPFinancialData> QCPFinancialDataMap;
3143 typedef QMapIterator<double, QCPFinancialData> QCPFinancialDataMapIterator;
3144 typedef QMutableMapIterator<double, QCPFinancialData> QCPFinancialDataMutableMapIterator;
3145 
3146 
3147 class QCP_LIB_DECL QCPFinancial : public QCPAbstractPlottable
3148 {
3149  Q_OBJECT
3151  Q_PROPERTY(ChartStyle chartStyle READ chartStyle WRITE setChartStyle)
3152  Q_PROPERTY(double width READ width WRITE setWidth)
3153  Q_PROPERTY(bool twoColored READ twoColored WRITE setTwoColored)
3154  Q_PROPERTY(QBrush brushPositive READ brushPositive WRITE setBrushPositive)
3155  Q_PROPERTY(QBrush brushNegative READ brushNegative WRITE setBrushNegative)
3156  Q_PROPERTY(QPen penPositive READ penPositive WRITE setPenPositive)
3157  Q_PROPERTY(QPen penNegative READ penNegative WRITE setPenNegative)
3159 public:
3165  enum ChartStyle { csOhlc
3166  ,csCandlestick
3167  };
3168  Q_ENUMS(ChartStyle)
3169 
3170  explicit QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis);
3171  virtual ~QCPFinancial();
3172 
3173  // getters:
3174  QCPFinancialDataMap *data() const { return mData; }
3175  ChartStyle chartStyle() const { return mChartStyle; }
3176  double width() const { return mWidth; }
3177  bool twoColored() const { return mTwoColored; }
3178  QBrush brushPositive() const { return mBrushPositive; }
3179  QBrush brushNegative() const { return mBrushNegative; }
3180  QPen penPositive() const { return mPenPositive; }
3181  QPen penNegative() const { return mPenNegative; }
3182 
3183 
3184  // setters:
3185  void setData(QCPFinancialDataMap *data, bool copy=false);
3186  void setData(const QVector<double> &key, const QVector<double> &open, const QVector<double> &high, const QVector<double> &low, const QVector<double> &close);
3187  void setChartStyle(ChartStyle style);
3188  void setWidth(double width);
3189  void setTwoColored(bool twoColored);
3190  void setBrushPositive(const QBrush &brush);
3191  void setBrushNegative(const QBrush &brush);
3192  void setPenPositive(const QPen &pen);
3193  void setPenNegative(const QPen &pen);
3194 
3195  // non-property methods:
3196  void addData(const QCPFinancialDataMap &dataMap);
3197  void addData(const QCPFinancialData &data);
3198  void addData(double key, double open, double high, double low, double close);
3199  void addData(const QVector<double> &key, const QVector<double> &open, const QVector<double> &high, const QVector<double> &low, const QVector<double> &close);
3200  void removeDataBefore(double key);
3201  void removeDataAfter(double key);
3202  void removeData(double fromKey, double toKey);
3203  void removeData(double key);
3204 
3205  // reimplemented virtual methods:
3206  virtual void clearData();
3207  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3208 
3209  // static methods:
3210  static QCPFinancialDataMap timeSeriesToOhlc(const QVector<double> &time, const QVector<double> &value, double timeBinSize, double timeBinOffset = 0);
3211 
3212 protected:
3213  // property members:
3214  QCPFinancialDataMap *mData;
3215  ChartStyle mChartStyle;
3216  double mWidth;
3217  bool mTwoColored;
3218  QBrush mBrushPositive, mBrushNegative;
3219  QPen mPenPositive, mPenNegative;
3220 
3221  // reimplemented virtual methods:
3222  virtual void draw(QCPPainter *painter);
3223  virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const;
3224  virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
3225  virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const;
3226 
3227  // non-virtual methods:
3228  void drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end);
3229  void drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end);
3230  double ohlcSelectTest(const QPointF &pos, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end) const;
3231  double candlestickSelectTest(const QPointF &pos, const QCPFinancialDataMap::const_iterator &begin, const QCPFinancialDataMap::const_iterator &end) const;
3232  void getVisibleDataBounds(QCPFinancialDataMap::const_iterator &lower, QCPFinancialDataMap::const_iterator &upper) const;
3233 
3234  friend class QCustomPlot;
3235  friend class QCPLegend;
3236 };
3237 
3238 
3239 class QCP_LIB_DECL QCPItemStraightLine : public QCPAbstractItem
3240 {
3241  Q_OBJECT
3243  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3244  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3246 public:
3247  QCPItemStraightLine(QCustomPlot *parentPlot);
3248  virtual ~QCPItemStraightLine();
3249 
3250  // getters:
3251  QPen pen() const { return mPen; }
3252  QPen selectedPen() const { return mSelectedPen; }
3253 
3254  // setters;
3255  void setPen(const QPen &pen);
3256  void setSelectedPen(const QPen &pen);
3257 
3258  // reimplemented virtual methods:
3259  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3260 
3261  QCPItemPosition * const point1;
3262  QCPItemPosition * const point2;
3263 
3264 protected:
3265  // property members:
3266  QPen mPen, mSelectedPen;
3267 
3268  // reimplemented virtual methods:
3269  virtual void draw(QCPPainter *painter);
3270 
3271  // non-virtual methods:
3272  double distToStraightLine(const QVector2D &point1, const QVector2D &vec, const QVector2D &point) const;
3273  QLineF getRectClippedStraightLine(const QVector2D &point1, const QVector2D &vec, const QRect &rect) const;
3274  QPen mainPen() const;
3275 };
3276 
3277 
3278 class QCP_LIB_DECL QCPItemLine : public QCPAbstractItem
3279 {
3280  Q_OBJECT
3282  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3283  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3284  Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
3285  Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
3287 public:
3288  QCPItemLine(QCustomPlot *parentPlot);
3289  virtual ~QCPItemLine();
3290 
3291  // getters:
3292  QPen pen() const { return mPen; }
3293  QPen selectedPen() const { return mSelectedPen; }
3294  QCPLineEnding head() const { return mHead; }
3295  QCPLineEnding tail() const { return mTail; }
3296 
3297  // setters;
3298  void setPen(const QPen &pen);
3299  void setSelectedPen(const QPen &pen);
3300  void setHead(const QCPLineEnding &head);
3301  void setTail(const QCPLineEnding &tail);
3302 
3303  // reimplemented virtual methods:
3304  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3305 
3306  QCPItemPosition * const start;
3307  QCPItemPosition * const end;
3308 
3309 protected:
3310  // property members:
3311  QPen mPen, mSelectedPen;
3312  QCPLineEnding mHead, mTail;
3313 
3314  // reimplemented virtual methods:
3315  virtual void draw(QCPPainter *painter);
3316 
3317  // non-virtual methods:
3318  QLineF getRectClippedLine(const QVector2D &start, const QVector2D &end, const QRect &rect) const;
3319  QPen mainPen() const;
3320 };
3321 
3322 
3323 class QCP_LIB_DECL QCPItemCurve : public QCPAbstractItem
3324 {
3325  Q_OBJECT
3327  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3328  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3329  Q_PROPERTY(QCPLineEnding head READ head WRITE setHead)
3330  Q_PROPERTY(QCPLineEnding tail READ tail WRITE setTail)
3332 public:
3333  QCPItemCurve(QCustomPlot *parentPlot);
3334  virtual ~QCPItemCurve();
3335 
3336  // getters:
3337  QPen pen() const { return mPen; }
3338  QPen selectedPen() const { return mSelectedPen; }
3339  QCPLineEnding head() const { return mHead; }
3340  QCPLineEnding tail() const { return mTail; }
3341 
3342  // setters;
3343  void setPen(const QPen &pen);
3344  void setSelectedPen(const QPen &pen);
3345  void setHead(const QCPLineEnding &head);
3346  void setTail(const QCPLineEnding &tail);
3347 
3348  // reimplemented virtual methods:
3349  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3350 
3351  QCPItemPosition * const start;
3352  QCPItemPosition * const startDir;
3353  QCPItemPosition * const endDir;
3354  QCPItemPosition * const end;
3355 
3356 protected:
3357  // property members:
3358  QPen mPen, mSelectedPen;
3359  QCPLineEnding mHead, mTail;
3360 
3361  // reimplemented virtual methods:
3362  virtual void draw(QCPPainter *painter);
3363 
3364  // non-virtual methods:
3365  QPen mainPen() const;
3366 };
3367 
3368 
3369 class QCP_LIB_DECL QCPItemRect : public QCPAbstractItem
3370 {
3371  Q_OBJECT
3373  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3374  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3375  Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3376  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
3378 public:
3379  QCPItemRect(QCustomPlot *parentPlot);
3380  virtual ~QCPItemRect();
3381 
3382  // getters:
3383  QPen pen() const { return mPen; }
3384  QPen selectedPen() const { return mSelectedPen; }
3385  QBrush brush() const { return mBrush; }
3386  QBrush selectedBrush() const { return mSelectedBrush; }
3387 
3388  // setters;
3389  void setPen(const QPen &pen);
3390  void setSelectedPen(const QPen &pen);
3391  void setBrush(const QBrush &brush);
3392  void setSelectedBrush(const QBrush &brush);
3393 
3394  // reimplemented virtual methods:
3395  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3396 
3397  QCPItemPosition * const topLeft;
3398  QCPItemPosition * const bottomRight;
3399  QCPItemAnchor * const top;
3400  QCPItemAnchor * const topRight;
3401  QCPItemAnchor * const right;
3402  QCPItemAnchor * const bottom;
3403  QCPItemAnchor * const bottomLeft;
3404  QCPItemAnchor * const left;
3405 
3406 protected:
3407  enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
3408 
3409  // property members:
3410  QPen mPen, mSelectedPen;
3411  QBrush mBrush, mSelectedBrush;
3412 
3413  // reimplemented virtual methods:
3414  virtual void draw(QCPPainter *painter);
3415  virtual QPointF anchorPixelPoint(int anchorId) const;
3416 
3417  // non-virtual methods:
3418  QPen mainPen() const;
3419  QBrush mainBrush() const;
3420 };
3421 
3422 
3423 class QCP_LIB_DECL QCPItemText : public QCPAbstractItem
3424 {
3425  Q_OBJECT
3427  Q_PROPERTY(QColor color READ color WRITE setColor)
3428  Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
3429  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3430  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3431  Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3432  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
3433  Q_PROPERTY(QFont font READ font WRITE setFont)
3434  Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
3435  Q_PROPERTY(QString text READ text WRITE setText)
3436  Q_PROPERTY(Qt::Alignment positionAlignment READ positionAlignment WRITE setPositionAlignment)
3437  Q_PROPERTY(Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment)
3438  Q_PROPERTY(double rotation READ rotation WRITE setRotation)
3439  Q_PROPERTY(QMargins padding READ padding WRITE setPadding)
3441 public:
3442  QCPItemText(QCustomPlot *parentPlot);
3443  virtual ~QCPItemText();
3444 
3445  // getters:
3446  QColor color() const { return mColor; }
3447  QColor selectedColor() const { return mSelectedColor; }
3448  QPen pen() const { return mPen; }
3449  QPen selectedPen() const { return mSelectedPen; }
3450  QBrush brush() const { return mBrush; }
3451  QBrush selectedBrush() const { return mSelectedBrush; }
3452  QFont font() const { return mFont; }
3453  QFont selectedFont() const { return mSelectedFont; }
3454  QString text() const { return mText; }
3455  Qt::Alignment positionAlignment() const { return mPositionAlignment; }
3456  Qt::Alignment textAlignment() const { return mTextAlignment; }
3457  double rotation() const { return mRotation; }
3458  QMargins padding() const { return mPadding; }
3459 
3460  // setters;
3461  void setColor(const QColor &color);
3462  void setSelectedColor(const QColor &color);
3463  void setPen(const QPen &pen);
3464  void setSelectedPen(const QPen &pen);
3465  void setBrush(const QBrush &brush);
3466  void setSelectedBrush(const QBrush &brush);
3467  void setFont(const QFont &font);
3468  void setSelectedFont(const QFont &font);
3469  void setText(const QString &text);
3470  void setPositionAlignment(Qt::Alignment alignment);
3471  void setTextAlignment(Qt::Alignment alignment);
3472  void setRotation(double degrees);
3473  void setPadding(const QMargins &padding);
3474 
3475  // reimplemented virtual methods:
3476  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3477 
3478  QCPItemPosition * const position;
3479  QCPItemAnchor * const topLeft;
3480  QCPItemAnchor * const top;
3481  QCPItemAnchor * const topRight;
3482  QCPItemAnchor * const right;
3483  QCPItemAnchor * const bottomRight;
3484  QCPItemAnchor * const bottom;
3485  QCPItemAnchor * const bottomLeft;
3486  QCPItemAnchor * const left;
3487 
3488 protected:
3489  enum AnchorIndex {aiTopLeft, aiTop, aiTopRight, aiRight, aiBottomRight, aiBottom, aiBottomLeft, aiLeft};
3490 
3491  // property members:
3492  QColor mColor, mSelectedColor;
3493  QPen mPen, mSelectedPen;
3494  QBrush mBrush, mSelectedBrush;
3495  QFont mFont, mSelectedFont;
3496  QString mText;
3497  Qt::Alignment mPositionAlignment;
3498  Qt::Alignment mTextAlignment;
3499  double mRotation;
3500  QMargins mPadding;
3501 
3502  // reimplemented virtual methods:
3503  virtual void draw(QCPPainter *painter);
3504  virtual QPointF anchorPixelPoint(int anchorId) const;
3505 
3506  // non-virtual methods:
3507  QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const;
3508  QFont mainFont() const;
3509  QColor mainColor() const;
3510  QPen mainPen() const;
3511  QBrush mainBrush() const;
3512 };
3513 
3514 
3515 class QCP_LIB_DECL QCPItemEllipse : public QCPAbstractItem
3516 {
3517  Q_OBJECT
3519  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3520  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3521  Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3522  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
3524 public:
3525  QCPItemEllipse(QCustomPlot *parentPlot);
3526  virtual ~QCPItemEllipse();
3527 
3528  // getters:
3529  QPen pen() const { return mPen; }
3530  QPen selectedPen() const { return mSelectedPen; }
3531  QBrush brush() const { return mBrush; }
3532  QBrush selectedBrush() const { return mSelectedBrush; }
3533 
3534  // setters;
3535  void setPen(const QPen &pen);
3536  void setSelectedPen(const QPen &pen);
3537  void setBrush(const QBrush &brush);
3538  void setSelectedBrush(const QBrush &brush);
3539 
3540  // reimplemented virtual methods:
3541  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3542 
3543  QCPItemPosition * const topLeft;
3544  QCPItemPosition * const bottomRight;
3545  QCPItemAnchor * const topLeftRim;
3546  QCPItemAnchor * const top;
3547  QCPItemAnchor * const topRightRim;
3548  QCPItemAnchor * const right;
3549  QCPItemAnchor * const bottomRightRim;
3550  QCPItemAnchor * const bottom;
3551  QCPItemAnchor * const bottomLeftRim;
3552  QCPItemAnchor * const left;
3553  QCPItemAnchor * const center;
3554 
3555 protected:
3556  enum AnchorIndex {aiTopLeftRim, aiTop, aiTopRightRim, aiRight, aiBottomRightRim, aiBottom, aiBottomLeftRim, aiLeft, aiCenter};
3557 
3558  // property members:
3559  QPen mPen, mSelectedPen;
3560  QBrush mBrush, mSelectedBrush;
3561 
3562  // reimplemented virtual methods:
3563  virtual void draw(QCPPainter *painter);
3564  virtual QPointF anchorPixelPoint(int anchorId) const;
3565 
3566  // non-virtual methods:
3567  QPen mainPen() const;
3568  QBrush mainBrush() const;
3569 };
3570 
3571 
3572 class QCP_LIB_DECL QCPItemPixmap : public QCPAbstractItem
3573 {
3574  Q_OBJECT
3576  Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
3577  Q_PROPERTY(bool scaled READ scaled WRITE setScaled)
3578  Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode)
3579  Q_PROPERTY(Qt::TransformationMode transformationMode READ transformationMode)
3580  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3581  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3583 public:
3584  QCPItemPixmap(QCustomPlot *parentPlot);
3585  virtual ~QCPItemPixmap();
3586 
3587  // getters:
3588  QPixmap pixmap() const { return mPixmap; }
3589  bool scaled() const { return mScaled; }
3590  Qt::AspectRatioMode aspectRatioMode() const { return mAspectRatioMode; }
3591  Qt::TransformationMode transformationMode() const { return mTransformationMode; }
3592  QPen pen() const { return mPen; }
3593  QPen selectedPen() const { return mSelectedPen; }
3594 
3595  // setters;
3596  void setPixmap(const QPixmap &pixmap);
3597  void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio, Qt::TransformationMode transformationMode=Qt::SmoothTransformation);
3598  void setPen(const QPen &pen);
3599  void setSelectedPen(const QPen &pen);
3600 
3601  // reimplemented virtual methods:
3602  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3603 
3604  QCPItemPosition * const topLeft;
3605  QCPItemPosition * const bottomRight;
3606  QCPItemAnchor * const top;
3607  QCPItemAnchor * const topRight;
3608  QCPItemAnchor * const right;
3609  QCPItemAnchor * const bottom;
3610  QCPItemAnchor * const bottomLeft;
3611  QCPItemAnchor * const left;
3612 
3613 protected:
3614  enum AnchorIndex {aiTop, aiTopRight, aiRight, aiBottom, aiBottomLeft, aiLeft};
3615 
3616  // property members:
3617  QPixmap mPixmap;
3618  QPixmap mScaledPixmap;
3619  bool mScaled;
3620  Qt::AspectRatioMode mAspectRatioMode;
3621  Qt::TransformationMode mTransformationMode;
3622  QPen mPen, mSelectedPen;
3623 
3624  // reimplemented virtual methods:
3625  virtual void draw(QCPPainter *painter);
3626  virtual QPointF anchorPixelPoint(int anchorId) const;
3627 
3628  // non-virtual methods:
3629  void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false);
3630  QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const;
3631  QPen mainPen() const;
3632 };
3633 
3634 
3635 class QCP_LIB_DECL QCPItemTracer : public QCPAbstractItem
3636 {
3637  Q_OBJECT
3639  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3640  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3641  Q_PROPERTY(QBrush brush READ brush WRITE setBrush)
3642  Q_PROPERTY(QBrush selectedBrush READ selectedBrush WRITE setSelectedBrush)
3643  Q_PROPERTY(double size READ size WRITE setSize)
3644  Q_PROPERTY(TracerStyle style READ style WRITE setStyle)
3645  Q_PROPERTY(QCPGraph* graph READ graph WRITE setGraph)
3646  Q_PROPERTY(double graphKey READ graphKey WRITE setGraphKey)
3647  Q_PROPERTY(bool interpolating READ interpolating WRITE setInterpolating)
3649 public:
3655  enum TracerStyle { tsNone
3656  ,tsPlus
3657  ,tsCrosshair
3658  ,tsCircle
3659  ,tsSquare
3660  };
3661  Q_ENUMS(TracerStyle)
3662 
3663  QCPItemTracer(QCustomPlot *parentPlot);
3664  virtual ~QCPItemTracer();
3665 
3666  // getters:
3667  QPen pen() const { return mPen; }
3668  QPen selectedPen() const { return mSelectedPen; }
3669  QBrush brush() const { return mBrush; }
3670  QBrush selectedBrush() const { return mSelectedBrush; }
3671  double size() const { return mSize; }
3672  TracerStyle style() const { return mStyle; }
3673  QCPGraph *graph() const { return mGraph; }
3674  double graphKey() const { return mGraphKey; }
3675  bool interpolating() const { return mInterpolating; }
3676 
3677  // setters;
3678  void setPen(const QPen &pen);
3679  void setSelectedPen(const QPen &pen);
3680  void setBrush(const QBrush &brush);
3681  void setSelectedBrush(const QBrush &brush);
3682  void setSize(double size);
3683  void setStyle(TracerStyle style);
3684  void setGraph(QCPGraph *graph);
3685  void setGraphKey(double key);
3686  void setInterpolating(bool enabled);
3687 
3688  // reimplemented virtual methods:
3689  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3690 
3691  // non-virtual methods:
3692  void updatePosition();
3693 
3694  QCPItemPosition * const position;
3695 
3696 protected:
3697  // property members:
3698  QPen mPen, mSelectedPen;
3699  QBrush mBrush, mSelectedBrush;
3700  double mSize;
3701  TracerStyle mStyle;
3702  QCPGraph *mGraph;
3703  double mGraphKey;
3704  bool mInterpolating;
3705 
3706  // reimplemented virtual methods:
3707  virtual void draw(QCPPainter *painter);
3708 
3709  // non-virtual methods:
3710  QPen mainPen() const;
3711  QBrush mainBrush() const;
3712 };
3713 
3714 
3715 class QCP_LIB_DECL QCPItemBracket : public QCPAbstractItem
3716 {
3717  Q_OBJECT
3719  Q_PROPERTY(QPen pen READ pen WRITE setPen)
3720  Q_PROPERTY(QPen selectedPen READ selectedPen WRITE setSelectedPen)
3721  Q_PROPERTY(double length READ length WRITE setLength)
3722  Q_PROPERTY(BracketStyle style READ style WRITE setStyle)
3724 public:
3725  enum BracketStyle { bsSquare
3726  ,bsRound
3727  ,bsCurly
3728  ,bsCalligraphic
3729  };
3730 
3731  QCPItemBracket(QCustomPlot *parentPlot);
3732  virtual ~QCPItemBracket();
3733 
3734  // getters:
3735  QPen pen() const { return mPen; }
3736  QPen selectedPen() const { return mSelectedPen; }
3737  double length() const { return mLength; }
3738  BracketStyle style() const { return mStyle; }
3739 
3740  // setters;
3741  void setPen(const QPen &pen);
3742  void setSelectedPen(const QPen &pen);
3743  void setLength(double length);
3744  void setStyle(BracketStyle style);
3745 
3746  // reimplemented virtual methods:
3747  virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
3748 
3749  QCPItemPosition * const left;
3750  QCPItemPosition * const right;
3751  QCPItemAnchor * const center;
3752 
3753 protected:
3754  // property members:
3755  enum AnchorIndex {aiCenter};
3756  QPen mPen, mSelectedPen;
3757  double mLength;
3758  BracketStyle mStyle;
3759 
3760  // reimplemented virtual methods:
3761  virtual void draw(QCPPainter *painter);
3762  virtual QPointF anchorPixelPoint(int anchorId) const;
3763 
3764  // non-virtual methods:
3765  QPen mainPen() const;
3766 };
3767 
3768 // Legend Title - Added to Wireshark
3769 // From: http://www.qcustomplot.com/index.php/support/forum/443
3770 
3772 {
3773  Q_OBJECT
3774 
3775 public:
3776  explicit QCPStringLegendItem(QCPLegend *pParent, const QString& strText);
3777 
3778  QString text() const;
3779  void setText(const QString& strText);
3780 
3781 protected:
3782  virtual void draw(QCPPainter *painter);
3783  virtual QSize minimumSizeHint() const;
3784 
3785 private:
3786  QString m_strText;
3787 };
3788 
3789 #endif // QCUSTOMPLOT_H
3790 
AxisType
Definition: qcustomplot.h:1044
QCPLayoutGrid * plotLayout() const
Definition: qcustomplot.h:1725
A bracket for referencing/highlighting certain parts in the plot.
Definition: qcustomplot.h:3715
A margin group allows synchronization of margin sides if working with multiple layout elements...
Definition: qcustomplot.h:602
An arbitrary pixmap.
Definition: qcustomplot.h:3572
0xFFFF All elements
Definition: qcustomplot.h:131
QList< QCPLayoutElement * > elements(QCP::MarginSide side) const
Definition: qcustomplot.h:610
LayerInsertMode
Definition: qcustomplot.h:1702
static const double maxRange
Definition: qcustomplot.h:512
Whether to use immediate repaint or queued update depends on whether the plotting hint QCP::phForceRe...
Definition: qcustomplot.h:1714
0x08 bottom margin
Definition: qcustomplot.h:105
Definition: qcustomplot.h:3771
QMap< double, QCPData > QCPDataMap
Definition: qcustomplot.h:2487
Holds the data of one single data point for QCPCurve.
Definition: qcustomplot.h:2640
void rescaleKeyAxis(bool onlyEnlarge=false) const
Definition: qcustomplot.cpp:7057
A legend item representing a plottable with an icon and the plottable name.
Definition: qcustomplot.h:2147
ScaleType
Definition: qcustomplot.h:1074
void selectionChanged(bool selected)
Definition: moc_qcustomplot.cpp:3324
PainterMode
Definition: qcustomplot.h:322
ChartStyle
Definition: qcustomplot.h:3165
Definition: qcustomplot.h:144
int bottom() const
Definition: qcustomplot.h:2030
bool isEmpty() const
Definition: qcustomplot.h:2775
The abstract base class for all entries in a QCPLegend.
Definition: qcustomplot.h:2083
virtual void mousePressEvent(QMouseEvent *)
Definition: qcustomplot.h:701
0x0001 Axis base line and tick marks
Definition: qcustomplot.h:120
0x0008 Legend box
Definition: qcustomplot.h:123
Responsible for drawing the grid of a QCPAxis.
Definition: qcustomplot.h:932
0x001 Axis ranges are draggable (see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeDragAxes) ...
Definition: qcustomplot.h:157
QCPItemAnchor * parentAnchor() const
Definition: qcustomplot.h:1568
EndingStyle
Definition: qcustomplot.h:890
0x00 no margin
Definition: qcustomplot.h:107
0x04 top margin
Definition: qcustomplot.h:104
QCPColorMapData * data() const
Definition: qcustomplot.h:3064
An anchor of an item to which positions can be attached to.
Definition: qcustomplot.h:1505
0x0004 Sub grid lines
Definition: qcustomplot.h:122
virtual void mouseReleaseEvent(QMouseEvent *event)
Definition: qcustomplot.cpp:12585
0x0002 Grid lines
Definition: qcustomplot.h:121
0x01 left margin
Definition: qcustomplot.h:102
QCPRange & operator*=(const double &value)
Definition: qcustomplot.h:491
Base class for all drawable objects.
Definition: qcustomplot.h:410
TracerStyle
Definition: qcustomplot.h:3655
A plottable representing a bar chart in a plot.
Definition: qcustomplot.h:2825
QCPRange & operator+=(const double &value)
Definition: qcustomplot.h:489
0x080 All other objects are selectable (e.g. your own derived layerables, the plot title...
Definition: qcustomplot.h:164
A curved line from one point to another.
Definition: qcustomplot.h:3323
0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap) ...
Definition: qcustomplot.h:127
Q_SLOT void setSelectable(bool selectable)
Definition: qcustomplot.cpp:12739
QList< QCPLayerable * > children() const
Definition: qcustomplot.h:385
A layout that arranges child elements in a grid.
Definition: qcustomplot.h:759
virtual void mousePressEvent(QMouseEvent *event)
Definition: qcustomplot.cpp:12510
void setFont(const QFont &font)
Definition: qcustomplot.cpp:12697
ErrorType
Definition: qcustomplot.h:2523
QPoint bottomLeft() const
Definition: qcustomplot.h:2036
0x0040 Main lines of items
Definition: qcustomplot.h:126
The abstract base class for all data representing objects in a plot.
Definition: qcustomplot.h:1390
ScatterShape
Definition: qcustomplot.h:248
A plottable representing a single statistical box in a plot.
Definition: qcustomplot.h:2917
QList< QCPBars * > bars() const
Definition: qcustomplot.h:2772
0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable) ...
Definition: qcustomplot.h:160
virtual QSize minimumSizeHint() const
Definition: qcustomplot.cpp:1972
Definition: qcustomplot.h:142
Definition: qcustomplot.h:1364
SpacingType
Definition: qcustomplot.h:2756
Definition: qcustomplot.h:2364
Definition: qcustomplot.h:1369
void setTextColor(const QColor &color)
Definition: qcustomplot.cpp:12707
A plottable representing a graph in a plot.
Definition: qcustomplot.h:2492
The abstract base class for all items in a plot.
Definition: qcustomplot.h:1609
0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance.
Definition: qcustomplot.h:146
Item that sticks to QCPGraph data points.
Definition: qcustomplot.h:3635
virtual QSize maximumSizeHint() const
Definition: qcustomplot.cpp:1984
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
Definition: qcustomplot.h:1682
int size() const
Definition: qcustomplot.h:2774
LabelSide
Definition: qcustomplot.h:1066
0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see QCPAbstractItem) ...
Definition: qcustomplot.h:163
Manages a single axis inside a QCustomPlot.
Definition: qcustomplot.h:982
QList< QCPItemAnchor * > anchors() const
Definition: qcustomplot.h:1639
bool isPenDefined() const
Definition: qcustomplot.h:294
PositionType type() const
Definition: qcustomplot.h:1565
Represents the visual appearance of scatter points.
Definition: qcustomplot.h:236
int index() const
Definition: qcustomplot.h:384
Manages a legend inside a QCustomPlot.
Definition: qcustomplot.h:2171
QList< QCPItemPosition * > positions() const
Definition: qcustomplot.h:1638
QCPLayerable * parentLayerable() const
Definition: qcustomplot.h:427
virtual void mouseReleaseEvent(QMouseEvent *)
Definition: qcustomplot.h:703
0x0200 Borders of fills (e.g. under or between graphs)
Definition: qcustomplot.h:129
0x004 The user can select multiple objects by holding the modifier set by QCustomPlot::setMultiSelect...
Definition: qcustomplot.h:159
bool isEmpty() const
Definition: qcustomplot.h:3030
int height() const
Definition: qcustomplot.h:2032
A layer that may contain objects, to control the rendering order.
Definition: qcustomplot.h:367
Qt::Orientation orientation() const
Definition: qcustomplot.h:1208
A rectangle.
Definition: qcustomplot.h:3369
The abstract base class for all objects that form the layout system.
Definition: qcustomplot.h:631
PlottingHint
Definition: qcustomplot.h:141
A straight line that spans infinitely in both directions.
Definition: qcustomplot.h:3239
QMap< double, QCPBarData > QCPBarDataMap
Definition: qcustomplot.h:2820
SelectablePart
Definition: qcustomplot.h:2196
A layout that places child elements aligned to the border or arbitrarily positioned.
Definition: qcustomplot.h:825
0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts) ...
Definition: qcustomplot.h:162
Handles the different ending decorations for line-like items.
Definition: qcustomplot.h:874
A color scale for use with color coding data such as QCPColorMap.
Definition: qcustomplot.h:2388
QCPDataMap * data() const
Definition: qcustomplot.h:2534
QPoint center() const
Definition: qcustomplot.h:2038
Holds the data of one single data point for QCPGraph.
Definition: qcustomplot.h:2469
virtual QCPItemPosition * toQCPItemPosition()
Definition: qcustomplot.h:1526
QPainter subclass used internally.
Definition: qcustomplot.h:314
Q_SLOT void setSelected(bool selected)
Definition: qcustomplot.cpp:12756
LineStyle
Definition: qcustomplot.h:2511
LineStyle
Definition: qcustomplot.h:2675
int left() const
Definition: qcustomplot.h:2027
Definition: qcustomplot.h:1323
0x0100 Error bars
Definition: qcustomplot.h:128
virtual void mouseMoveEvent(QMouseEvent *event)
Definition: qcustomplot.cpp:12540
QCPAxis * yAxis2
Definition: qcustomplot.h:1821
SignDomain
Definition: qcustomplot.h:1457
QCPRange & operator/=(const double &value)
Definition: qcustomplot.h:492
static const double minRange
Definition: qcustomplot.h:511
bool isNone() const
Definition: qcustomplot.h:293
BracketStyle
Definition: qcustomplot.h:3725
void rescaleAxes(bool onlyEnlarge=false) const
Definition: qcustomplot.cpp:7046
0x0020 Main lines of plottables (excluding error bars, see element aeErrorBars)
Definition: qcustomplot.h:125
Interaction
Definition: qcustomplot.h:157
QCPBars * barBelow() const
Definition: qcustomplot.h:2857
int top() const
Definition: qcustomplot.h:2029
0x000 No hints are set
Definition: qcustomplot.h:141
virtual QCPItemPosition * toQCPItemPosition()
Definition: qcustomplot.h:1601
A plottable representing a parametric curve in a plot.
Definition: qcustomplot.h:2662
QMap< double, QCPFinancialData > QCPFinancialDataMap
Definition: qcustomplot.h:3142
0x0000 No elements
Definition: qcustomplot.h:132
void rescaleValueAxis(bool onlyEnlarge=false) const
Definition: qcustomplot.cpp:7097
virtual void wheelEvent(QWheelEvent *)
Definition: qcustomplot.h:705
A layout element displaying a plot title text.
Definition: qcustomplot.h:2295
0x02 right margin
Definition: qcustomplot.h:103
QCPLayoutInset * insetLayout() const
Definition: qcustomplot.h:2019
UpdatePhase
Definition: qcustomplot.h:648
An ellipse.
Definition: qcustomplot.h:3515
QPoint topLeft() const
Definition: qcustomplot.h:2034
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const
Definition: qcustomplot.cpp:12766
void setSelectedFont(const QFont &font)
Definition: qcustomplot.cpp:12718
QRect rect() const
Definition: qcustomplot.h:659
GradientPreset
Definition: qcustomplot.h:1920
SelectablePart
Definition: qcustomplot.h:1082
Holds the two-dimensional data of a QCPColorMap plottable.
Definition: qcustomplot.h:2999
virtual void update(UpdatePhase phase)
Definition: qcustomplot.cpp:12160
0x002 Axis ranges are zoomable with the mouse wheel (see QCPAxisRect::setRangeZoom, QCPAxisRect::setRangeZoomAxes)
Definition: qcustomplot.h:158
A plottable representing a financial stock chart.
Definition: qcustomplot.h:3147
0x0010 Legend items
Definition: qcustomplot.h:124
The abstract base class for layouts.
Definition: qcustomplot.h:721
Holds the data of one single data point for QCPFinancial.
Definition: qcustomplot.h:3126
A text label.
Definition: qcustomplot.h:3423
QCPAxis * axis() const
Definition: qcustomplot.h:2406
QCPBars * barAbove() const
Definition: qcustomplot.h:2858
QSize size() const
Definition: qcustomplot.h:2033
A plottable representing a two-dimensional color map in a plot.
Definition: qcustomplot.h:3048
virtual void mouseDoubleClickEvent(QMouseEvent *)
Definition: qcustomplot.h:704
QRect viewport() const
Definition: qcustomplot.h:1721
PositionType
Definition: qcustomplot.h:1551
QPoint bottomRight() const
Definition: qcustomplot.h:2037
QPoint topRight() const
Definition: qcustomplot.h:2035
void setSelectedTextColor(const QColor &color)
Definition: qcustomplot.cpp:12729
A line from one point to another.
Definition: qcustomplot.h:3278
bool contains(QCPBars *bars) const
Definition: qcustomplot.h:2777
const QCPRange operator*(const QCPRange &range, double value)
Definition: qcustomplot.h:574
Definition: qcustomplot.h:95
0x0400 Zero-lines, see QCPGrid::setZeroLinePen
Definition: qcustomplot.h:130
Manages the position of an item.
Definition: qcustomplot.h:1542
ColorInterpolation
Definition: qcustomplot.h:1911
Defines a color gradient for use with e.g. QCPColorMap.
Definition: qcustomplot.h:1902
QCPGrid * grid() const
Definition: qcustomplot.h:1145
static Qt::Orientation orientation(AxisType type)
Definition: qcustomplot.h:1221
Represents the range an axis is encompassing.
Definition: qcustomplot.h:478
virtual void mouseMoveEvent(QMouseEvent *)
Definition: qcustomplot.h:702
Groups multiple QCPBars together so they appear side by side.
Definition: qcustomplot.h:2742
0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
Definition: qcustomplot.h:161
WidthType
Definition: qcustomplot.h:2843
0xFF all margins
Definition: qcustomplot.h:106
Holds multiple axes and arranges them in a rectangular shape.
Definition: qcustomplot.h:1974
int width() const
Definition: qcustomplot.h:2031
const QCPRange operator-(const QCPRange &range, double value)
Definition: qcustomplot.h:564
InsetPlacement
Definition: qcustomplot.h:832
virtual void simplify()
Definition: qcustomplot.h:855
QCPLegend * legend
Definition: qcustomplot.h:1822
QMap< double, QCPCurveData > QCPCurveDataMap
Definition: qcustomplot.h:2657
QCPRange & operator-=(const double &value)
Definition: qcustomplot.h:490
const QCPRange operator/(const QCPRange &range, double value)
Definition: qcustomplot.h:594
MarginSide
Definition: qcustomplot.h:102
AntialiasedElement
Definition: qcustomplot.h:120
const QCPRange operator+(const QCPRange &range, double value)
Definition: qcustomplot.h:544
LabelType
Definition: qcustomplot.h:1057
RefreshPriority
Definition: qcustomplot.h:1712
virtual void wheelEvent(QWheelEvent *event)
Definition: qcustomplot.cpp:12609
int right() const
Definition: qcustomplot.h:2028
Holds the data of one single data point (one bar) for QCPBars.
Definition: qcustomplot.h:2804