forked from dimv36/QCustomPlot-PyQt5
-
Notifications
You must be signed in to change notification settings - Fork 2
/
qcustomplot.sip
3403 lines (2852 loc) · 111 KB
/
qcustomplot.sip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
** **
** QCustomPlot, an easy to use, modern plotting widget for Qt **
** Copyright (C) 2011-2015 Emanuel Eichhammer **
** **
** This program is free software: you can redistribute it and/or modify **
** it under the terms of the GNU General Public License as published by **
** the Free Software Foundation, either version 3 of the License, or **
** (at your option) any later version. **
** **
** This program is distributed in the hope that it will be useful, **
** but WITHOUT ANY WARRANTY; without even the implied warranty of **
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
** GNU General Public License for more details. **
** **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see http://www.gnu.org/licenses/. **
** **
****************************************************************************
** Author: Emanuel Eichhammer **
** Website/Contact: http://www.qcustomplot.com/ **
** Date: 25.04.15 **
** Version: 1.3.1-mod **
** Modified: Dmitry Voronin **
** date: 18.07.15 **
****************************************************************************/
%Module qcustomplot
%Import QtGui/QtGuimod.sip
%Import QtWidgets/QtWidgetsmod.sip
namespace QCP
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
enum MarginSide { msLeft = 0x01 ///< <tt>0x01</tt> left margin
,msRight = 0x02 ///< <tt>0x02</tt> right margin
,msTop = 0x04 ///< <tt>0x04</tt> top margin
,msBottom = 0x08 ///< <tt>0x08</tt> bottom margin
,msAll = 0xFF ///< <tt>0xFF</tt> all margins
,msNone = 0x00 ///< <tt>0x00</tt> no margin
};
typedef QFlags<QCP::MarginSide> MarginSides;
enum AntialiasedElement { aeAxes = 0x0001 ///< <tt>0x0001</tt> Axis base line and tick marks
,aeGrid = 0x0002 ///< <tt>0x0002</tt> Grid lines
,aeSubGrid = 0x0004 ///< <tt>0x0004</tt> Sub grid lines
,aeLegend = 0x0008 ///< <tt>0x0008</tt> Legend box
,aeLegendItems = 0x0010 ///< <tt>0x0010</tt> Legend items
,aePlottables = 0x0020 ///< <tt>0x0020</tt> Main lines of plottables (excluding error bars, see element \ref aeErrorBars)
,aeItems = 0x0040 ///< <tt>0x0040</tt> Main lines of items
,aeScatters = 0x0080 ///< <tt>0x0080</tt> Scatter symbols of plottables (excluding scatter symbols of type ssPixmap)
,aeErrorBars = 0x0100 ///< <tt>0x0100</tt> Error bars
,aeFills = 0x0200 ///< <tt>0x0200</tt> Borders of fills (e.g. under or between graphs)
,aeZeroLine = 0x0400 ///< <tt>0x0400</tt> Zero-lines, see \ref QCPAxis::setZeroLinePen
,aeAll = 0xFFFF ///< <tt>0xFFFF</tt> All elements
,aeNone = 0x0000 ///< <tt>0x0000</tt> No elements
};
typedef QFlags<QCP::AntialiasedElement> AntialiasedElements;
enum PlottingHint { phNone = 0x000 ///< <tt>0x000</tt> No hints are set
,phFastPolylines = 0x001 ///< <tt>0x001</tt> Graph/Curve lines are drawn with a faster method. This reduces the quality
///< especially of the line segment joins. (Only relevant for solid line pens.)
,phForceRepaint = 0x002 ///< <tt>0x002</tt> causes an immediate repaint() instead of a soft update() when QCustomPlot::replot() is called with parameter \ref QCustomPlot::rpHint.
///< This is set by default to prevent the plot from freezing on fast consecutive replots (e.g. user drags ranges with mouse).
,phCacheLabels = 0x004 ///< <tt>0x004</tt> axis (tick) labels will be cached as pixmaps, increasing replot performance.
};
typedef QFlags<QCP::PlottingHint> PlottingHints;
enum Interaction { iRangeDrag = 0x001 ///< <tt>0x001</tt> Axis ranges are draggable (see \ref QCPAxisRect::setRangeDrag, \ref QCPAxisRect::setRangeDragAxes)
,iRangeZoom = 0x002 ///< <tt>0x002</tt> Axis ranges are zoomable with the mouse wheel (see \ref QCPAxisRect::setRangeZoom, \ref QCPAxisRect::setRangeZoomAxes)
,iMultiSelect = 0x004 ///< <tt>0x004</tt> The user can select multiple objects by holding the modifier set by \ref QCustomPlot::setMultiSelectModifier while clicking
,iSelectPlottables = 0x008 ///< <tt>0x008</tt> Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable)
,iSelectAxes = 0x010 ///< <tt>0x010</tt> Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
,iSelectLegend = 0x020 ///< <tt>0x020</tt> Legends are selectable (or their child items, see QCPLegend::setSelectableParts)
,iSelectItems = 0x040 ///< <tt>0x040</tt> Items are selectable (Rectangles, Arrows, Textitems, etc. see \ref QCPAbstractItem)
,iSelectOther = 0x080 ///< <tt>0x080</tt> All other objects are selectable (e.g. your own derived layerables, the plot title,...)
};
typedef QFlags<QCP::Interaction> Interactions;
bool isInvalidData(double value);
bool isInvalidData(double value1, double value2);
void setMarginValue(QMargins &margins, QCP::MarginSide side, int value);
int getMarginValue(const QMargins &margins, QCP::MarginSide side);
};
class QCPScatterStyle
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
enum ScatterShape { ssNone ///< no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines)
,ssDot ///< \enumimage{ssDot.png} a single pixel (use \ref ssDisc or \ref ssCircle if you want a round shape with a certain radius)
,ssCross ///< \enumimage{ssCross.png} a cross
,ssPlus ///< \enumimage{ssPlus.png} a plus
,ssCircle ///< \enumimage{ssCircle.png} a circle
,ssDisc ///< \enumimage{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle)
,ssSquare ///< \enumimage{ssSquare.png} a square
,ssDiamond ///< \enumimage{ssDiamond.png} a diamond
,ssStar ///< \enumimage{ssStar.png} a star with eight arms, i.e. a combination of cross and plus
,ssTriangle ///< \enumimage{ssTriangle.png} an equilateral triangle, standing on baseline
,ssTriangleInverted ///< \enumimage{ssTriangleInverted.png} an equilateral triangle, standing on corner
,ssCrossSquare ///< \enumimage{ssCrossSquare.png} a square with a cross inside
,ssPlusSquare ///< \enumimage{ssPlusSquare.png} a square with a plus inside
,ssCrossCircle ///< \enumimage{ssCrossCircle.png} a circle with a cross inside
,ssPlusCircle ///< \enumimage{ssPlusCircle.png} a circle with a plus inside
,ssPeace ///< \enumimage{ssPeace.png} a circle, with one vertical and two downward diagonal lines
,ssPixmap ///< a custom pixmap specified by \ref setPixmap, centered on the data point coordinates
,ssCustom ///< custom painter operations are performed per scatter (As QPainterPath, see \ref setCustomPath)
};
QCPScatterStyle();
QCPScatterStyle(ScatterShape shape, double size=6);
QCPScatterStyle(ScatterShape shape, const QColor &color, double size);
QCPScatterStyle(ScatterShape shape, const QColor &color, const QColor &fill, double size);
QCPScatterStyle(ScatterShape shape, const QPen &pen, const QBrush &brush, double size);
QCPScatterStyle(const QPixmap &pixmap);
QCPScatterStyle(const QPainterPath &customPath, const QPen &pen, const QBrush &brush=Qt::NoBrush, double size=6);
// getters:
double size() const;
ScatterShape shape() const;
QPen pen() const;
QBrush brush() const;
QPixmap pixmap() const;
QPainterPath customPath() const;
// setters:
void setSize(double size);
void setShape(ScatterShape shape);
void setPen(const QPen &pen);
void setBrush(const QBrush &brush);
void setPixmap(const QPixmap &pixmap);
void setCustomPath(const QPainterPath &customPath);
// non-property methods:
bool isNone() const;
bool isPenDefined();
void applyTo(QCPPainter *painter, const QPen &defaultPen) const;
void drawShape(QCPPainter *painter, QPointF pos) const;
void drawShape(QCPPainter *painter, double x, double y) const;
};
class QCPPainter : public QPainter
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
enum PainterMode { pmDefault = 0x00 ///< <tt>0x00</tt> Default mode for painting on screen devices
,pmVectorized = 0x01 ///< <tt>0x01</tt> Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fixes.
,pmNoCaching = 0x02 ///< <tt>0x02</tt> Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixmap labels
,pmNonCosmetic = 0x04 ///< <tt>0x04</tt> Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width 1 pixel in the vector image/pdf viewer, independent of zoom.)
};
typedef QFlags<QCPPainter::PainterMode> PainterModes;
QCPPainter();
QCPPainter(QPaintDevice *device);
~QCPPainter();
// getters:
bool antialiasing() const;
PainterModes modes() const;
// setters:
void setAntialiasing(bool enabled);
void setMode(PainterMode mode, bool enabled=true);
void setModes(PainterModes modes);
// methods hiding non-virtual base class functions (QPainter bug workarounds):
bool begin(QPaintDevice *device);
void setPen(const QPen &pen);
void setPen(const QColor &color);
void setPen(Qt::PenStyle penStyle);
void drawLine(const QLineF &line);
void drawLine(const QPointF &p1, const QPointF &p2);
void save();
void restore();
// non-virtual methods:
void makeNonCosmetic();
};
class QCPLayer
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
QCPLayer(QCustomPlot* parentPlot, const QString &layerName);
~QCPLayer();
// getters:
QCustomPlot *parentPlot() const;
QString name() const;
int index() const;
QList<QCPLayerable*> children() const;
bool visible() const;
// setters:
void setVisible(bool visible);
protected:
// non-virtual methods:
void addChild(QCPLayerable *layerable, bool prepend);
void removeChild(QCPLayerable *layerable);
private:
QCPLayer(const QCPLayer &);
};
class QCPLayerable : public QObject
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
QCPLayerable(QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0);
~QCPLayerable();
// getters:
bool visible() const;
QCustomPlot *parentPlot() const;
QCPLayerable *parentLayerable() const;
QCPLayer *layer() const;
bool antialiased() const;
// setters:
void setVisible(bool on);
Q_SLOT bool setLayer(QCPLayer *layer);
bool setLayer(const QString &layerName);
void setAntialiased(bool enabled);
// introduced virtual methods:
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
// non-property methods:
bool realVisibility() const;
signals:
void layerChanged(QCPLayer *newLayer);
protected:
// introduced virtual methods:
virtual void parentPlotInitialized(QCustomPlot *parentPlot);
virtual QCP::Interaction selectionCategory() const;
virtual QRect clipRect() const;
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const = 0;
virtual void draw(QCPPainter *painter) = 0;
// events:
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
virtual void deselectEvent(bool *selectionStateChanged);
// non-property methods:
void initializeParentPlot(QCustomPlot *parentPlot);
void setParentLayerable(QCPLayerable* parentLayerable);
bool moveToLayer(QCPLayer *layer, bool prepend);
void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const;
};
class QCPRange
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
double lower;
double upper;
QCPRange();
QCPRange(double lower, double upper);
double size() const;
double center() const;
void normalize();
void expand(const QCPRange &otherRange);
QCPRange expanded(const QCPRange &otherRange) const;
QCPRange sanitizedForLogScale() const;
QCPRange sanitizedForLinScale() const;
bool contains(double value) const;
static bool validRange(double lower, double upper);
static bool validRange(const QCPRange &range);
static const double minRange; //1e-280;
static const double maxRange; //1e280;
};
class QCPMarginGroup : public QObject
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
QCPMarginGroup(QCustomPlot *parentPlot);
~QCPMarginGroup();
// non-virtual methods:
QList<QCPLayoutElement*> elements(QCP::MarginSide side) const;
bool isEmpty() const;
void clear();
protected:
// non-virtual methods:
int commonMargin(QCP::MarginSide side) const;
void addChild(QCP::MarginSide side, QCPLayoutElement *element);
void removeChild(QCP::MarginSide side, QCPLayoutElement *element);
};
class QCPLayoutElement : public QCPLayerable
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
enum UpdatePhase { upPreparation ///< Phase used for any type of preparation that needs to be done before margin calculation and layout
,upMargins ///< Phase in which the margins are calculated and set
,upLayout ///< Final phase in which the layout system places the rects of the elements
};
explicit QCPLayoutElement(QCustomPlot *parentPlot=0);
virtual ~QCPLayoutElement();
// getters:
QCPLayout *layout() const;
QRect rect() const;
QRect outerRect() const;
QMargins margins() const;
QMargins minimumMargins() const;
QCP::MarginSides autoMargins() const;
QSize minimumSize() const;
QSize maximumSize() const;
QCPMarginGroup *marginGroup(QCP::MarginSide side) const;
QHash<QCP::MarginSide, QCPMarginGroup*> marginGroups() const;
// setters:
void setOuterRect(const QRect &rect);
void setMargins(const QMargins &margins);
void setMinimumMargins(const QMargins &margins);
void setAutoMargins(QCP::MarginSides sides);
void setMinimumSize(const QSize &size);
void setMinimumSize(int width, int height);
void setMaximumSize(const QSize &size);
void setMaximumSize(int width, int height);
void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group);
// introduced virtual methods:
virtual void update(UpdatePhase phase);
virtual QSize minimumSizeHint() const;
virtual QSize maximumSizeHint() const;
virtual QList<QCPLayoutElement*> elements(bool recursive) const;
// reimplemented virtual methods:
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
protected:
// introduced virtual methods:
virtual int calculateAutoMargin(QCP::MarginSide side);
// events:
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void wheelEvent(QWheelEvent *event);
// reimplemented virtual methods:
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
virtual void draw(QCPPainter *painter);
virtual void parentPlotInitialized(QCustomPlot *parentPlot);
};
class QCPLayout : public QCPLayoutElement
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
explicit QCPLayout();
// reimplemented virtual methods:
virtual void update(UpdatePhase phase);
virtual QList<QCPLayoutElement*> elements(bool recursive) const;
// introduced virtual methods:
virtual int elementCount() const = 0;
virtual QCPLayoutElement* elementAt(int index) const = 0;
virtual QCPLayoutElement* takeAt(int index) = 0;
virtual bool take(QCPLayoutElement* element) = 0;
virtual void simplify();
// non-virtual methods:
bool removeAt(int index);
bool remove(QCPLayoutElement* element);
void clear();
protected:
// introduced virtual methods:
virtual void updateLayout();
// non-virtual methods:
void sizeConstraintsChanged() const;
void adoptElement(QCPLayoutElement *el);
void releaseElement(QCPLayoutElement *el);
QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const;
};
class QCPLayoutGrid : public QCPLayout
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
explicit QCPLayoutGrid();
virtual ~QCPLayoutGrid();
// getters:
int rowCount() const;
int columnCount() const;
QList<double> columnStretchFactors() const;
QList<double> rowStretchFactors() const;
int columnSpacing() const;
int rowSpacing() const;
// setters:
void setColumnStretchFactor(int column, double factor);
void setColumnStretchFactors(const QList<double> &factors);
void setRowStretchFactor(int row, double factor);
void setRowStretchFactors(const QList<double> &factors);
void setColumnSpacing(int pixels);
void setRowSpacing(int pixels);
// reimplemented virtual methods:
virtual void updateLayout();
virtual int elementCount() const;
virtual QCPLayoutElement* elementAt(int index) const;
virtual QCPLayoutElement* takeAt(int index);
virtual bool take(QCPLayoutElement* element);
virtual QList<QCPLayoutElement*> elements(bool recursive) const;
virtual void simplify();
virtual QSize minimumSizeHint() const;
virtual QSize maximumSizeHint() const;
// non-virtual methods:
QCPLayoutElement *element(int row, int column) const;
bool addElement(int row, int column, QCPLayoutElement *element);
bool hasElement(int row, int column);
void expandTo(int newRowCount, int newColumnCount);
void insertRow(int newIndex);
void insertColumn(int newIndex);
protected:
// non-virtual methods:
void getMinimumRowColSizes(QVector<int> *minColWidths, QVector<int> *minRowHeights) const;
void getMaximumRowColSizes(QVector<int> *maxColWidths, QVector<int> *maxRowHeights) const;
};
class QCPLayoutInset : public QCPLayout
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
enum InsetPlacement { ipFree ///< The element may be positioned/sized arbitrarily, see \ref setInsetRect
,ipBorderAligned ///< The element is aligned to one of the layout sides, see \ref setInsetAlignment
};
explicit QCPLayoutInset();
virtual ~QCPLayoutInset();
// getters:
InsetPlacement insetPlacement(int index) const;
Qt::Alignment insetAlignment(int index) const;
QRectF insetRect(int index) const;
// setters:
void setInsetPlacement(int index, InsetPlacement placement);
void setInsetAlignment(int index, Qt::Alignment alignment);
void setInsetRect(int index, const QRectF &rect);
// reimplemented virtual methods:
virtual void updateLayout();
virtual int elementCount() const;
virtual QCPLayoutElement* elementAt(int index) const;
virtual QCPLayoutElement* takeAt(int index);
virtual bool take(QCPLayoutElement* element);
virtual void simplify();
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
// non-virtual methods:
void addElement(QCPLayoutElement *element, Qt::Alignment alignment);
void addElement(QCPLayoutElement *element, const QRectF &rect);
};
class QCPLineEnding
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
enum EndingStyle { esNone ///< No ending decoration
,esFlatArrow ///< A filled arrow head with a straight/flat back (a triangle)
,esSpikeArrow ///< A filled arrow head with an indented back
,esLineArrow ///< A non-filled arrow head with open back
,esDisc ///< A filled circle
,esSquare ///< A filled square
,esDiamond ///< A filled diamond (45° rotated square)
,esBar ///< A bar perpendicular to the line
,esHalfBar ///< A bar perpendicular to the line, pointing out to only one side (to which side can be changed with \ref setInverted)
,esSkewedBar ///< A bar that is skewed (skew controllable via \ref setLength)
};
QCPLineEnding();
QCPLineEnding(EndingStyle style, double width=8, double length=10, bool inverted=false);
// getters:
EndingStyle style() const;
double width() const;
double length() const;
bool inverted() const;
// setters:
void setStyle(EndingStyle style);
void setWidth(double width);
void setLength(double length);
void setInverted(bool inverted);
// non-property methods:
double boundingDistance() const;
double realLength() const;
void draw(QCPPainter *painter, const QVector2D &pos, const QVector2D &dir) const;
void draw(QCPPainter *painter, const QVector2D &pos, double angle) const;
};
class QCPGrid : public QCPLayerable
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
QCPGrid(QCPAxis *parentAxis);
// getters:
bool subGridVisible() const;
bool antialiasedSubGrid() const;
bool antialiasedZeroLine() const;
QPen pen() const;
QPen subGridPen() const;
QPen zeroLinePen() const;
// setters:
void setSubGridVisible(bool visible);
void setAntialiasedSubGrid(bool enabled);
void setAntialiasedZeroLine(bool enabled);
void setPen(const QPen &pen);
void setSubGridPen(const QPen &pen);
void setZeroLinePen(const QPen &pen);
protected:
// reimplemented virtual methods:
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
virtual void draw(QCPPainter *painter);
// non-virtual methods:
void drawGridLines(QCPPainter *painter) const;
void drawSubGridLines(QCPPainter *painter) const;
};
class QCPAxis : public QCPLayerable
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
enum AxisType { atLeft = 0x01 ///< <tt>0x01</tt> Axis is vertical and on the left side of the axis rect
,atRight = 0x02 ///< <tt>0x02</tt> Axis is vertical and on the right side of the axis rect
,atTop = 0x04 ///< <tt>0x04</tt> Axis is horizontal and on the top side of the axis rect
,atBottom = 0x08 ///< <tt>0x08</tt> Axis is horizontal and on the bottom side of the axis rect
};
typedef QFlags<QCPAxis::AxisType> AxisTypes;
enum LabelType { ltNumber ///< Tick coordinate is regarded as normal number and will be displayed as such. (see \ref setNumberFormat)
,ltDateTime ///< Tick coordinate is regarded as a date/time (seconds since 1970-01-01T00:00:00 UTC) and will be displayed and formatted as such. (for details, see \ref setDateTimeFormat)
};
enum LabelSide { lsInside ///< Tick labels will be displayed inside the axis rect and clipped to the inner axis rect
,lsOutside ///< Tick labels will be displayed outside the axis rect
};
enum ScaleType { stLinear ///< Linear scaling
,stLogarithmic ///< Logarithmic scaling with correspondingly transformed plots and (major) tick marks at every base power (see \ref setScaleLogBase).
};
enum SelectablePart { spNone = 0 ///< None of the selectable parts
,spAxis = 0x001 ///< The axis backbone and tick marks
,spTickLabels = 0x002 ///< Tick labels (numbers) of this axis (as a whole, not individually)
,spAxisLabel = 0x004 ///< The axis label
};
// Q_DECLARE_FLAGS(SelectableParts, SelectablePart)
typedef QFlags<QCPAxis::SelectablePart> SelectableParts;
explicit QCPAxis(QCPAxisRect *parent, AxisType type);
virtual ~QCPAxis();
// getters:
AxisType axisType() const;
QCPAxisRect *axisRect() const;
ScaleType scaleType() const;
double scaleLogBase() const;
const QCPRange range() const;
bool rangeReversed() const;
bool autoTicks() const;
int autoTickCount() const;
bool autoTickLabels() const;
bool autoTickStep() const;
bool autoSubTicks() const;
bool ticks() const;
bool tickLabels() const;
int tickLabelPadding() const;
LabelType tickLabelType() const;
QFont tickLabelFont() const;
QColor tickLabelColor() const;
double tickLabelRotation() const;
LabelSide tickLabelSide() const;
QString dateTimeFormat() const;
Qt::TimeSpec dateTimeSpec() const;
QString numberFormat() const;
int numberPrecision() const;
double tickStep() const;
QVector<double> tickVector() const;
QVector<QString> tickVectorLabels() const;
int tickLengthIn() const;
int tickLengthOut() const;
int subTickCount() const;
int subTickLengthIn() const;
int subTickLengthOut() const;
QPen basePen() const;
QPen tickPen() const;
QPen subTickPen() const;
QFont labelFont() const;
QColor labelColor() const;
QString label() const;
int labelPadding() const;
int padding() const;
int offset() const;
SelectableParts selectedParts() const;
SelectableParts selectableParts() const;
QFont selectedTickLabelFont() const;
QFont selectedLabelFont() const;
QColor selectedTickLabelColor() const;
QColor selectedLabelColor() const;
QPen selectedBasePen() const;
QPen selectedTickPen() const;
QPen selectedSubTickPen() const;
QCPLineEnding lowerEnding() const;
QCPLineEnding upperEnding() const;
QCPGrid *grid() const;
// setters:
Q_SLOT void setScaleType(QCPAxis::ScaleType type);
void setScaleLogBase(double base);
Q_SLOT void setRange(const QCPRange &range);
void setRange(double lower, double upper);
void setRange(double position, double size, Qt::AlignmentFlag alignment);
void setRangeLower(double lower);
void setRangeUpper(double upper);
void setRangeReversed(bool reversed);
void setAutoTicks(bool on);
void setAutoTickCount(int approximateCount);
void setAutoTickLabels(bool on);
void setAutoTickStep(bool on);
void setAutoSubTicks(bool on);
void setTicks(bool show);
void setTickLabels(bool show);
void setTickLabelPadding(int padding);
void setTickLabelType(LabelType type);
void setTickLabelFont(const QFont &font);
void setTickLabelColor(const QColor &color);
void setTickLabelRotation(double degrees);
void setTickLabelSide(LabelSide side);
void setDateTimeFormat(const QString &format);
void setDateTimeSpec(const Qt::TimeSpec &timeSpec);
void setNumberFormat(const QString &formatCode);
void setNumberPrecision(int precision);
void setTickStep(double step);
void setTickVector(const QVector<double> &vec);
void setTickVectorLabels(const QVector<QString> &vec);
void setTickLength(int inside, int outside=0);
void setTickLengthIn(int inside);
void setTickLengthOut(int outside);
void setSubTickCount(int count);
void setSubTickLength(int inside, int outside=0);
void setSubTickLengthIn(int inside);
void setSubTickLengthOut(int outside);
void setBasePen(const QPen &pen);
void setTickPen(const QPen &pen);
void setSubTickPen(const QPen &pen);
void setLabelFont(const QFont &font);
void setLabelColor(const QColor &color);
void setLabel(const QString &str);
void setLabelPadding(int padding);
void setPadding(int padding);
void setOffset(int offset);
void setSelectedTickLabelFont(const QFont &font);
void setSelectedLabelFont(const QFont &font);
void setSelectedTickLabelColor(const QColor &color);
void setSelectedLabelColor(const QColor &color);
void setSelectedBasePen(const QPen &pen);
void setSelectedTickPen(const QPen &pen);
void setSelectedSubTickPen(const QPen &pen);
Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts);
Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts);
void setLowerEnding(const QCPLineEnding &ending);
void setUpperEnding(const QCPLineEnding &ending);
// reimplemented virtual methods:
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
// non-property methods:
Qt::Orientation orientation() const;
void moveRange(double diff);
void scaleRange(double factor, double center);
void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0);
void rescale(bool onlyVisiblePlottables=false);
double pixelToCoord(double value) const;
double coordToPixel(double value) const;
SelectablePart getPartAt(const QPointF &pos) const;
QList<QCPAbstractPlottable*> plottables() const;
QList<QCPGraph*> graphs() const;
QList<QCPAbstractItem*> items() const;
static AxisType marginSideToAxisType(QCP::MarginSide side);
static Qt::Orientation orientation(AxisType type);
static AxisType opposite(AxisType type);
signals:
void ticksRequest();
void rangeChanged(const QCPRange &newRange);
void rangeChanged(const QCPRange &newRange, const QCPRange &oldRange);
void scaleTypeChanged(QCPAxis::ScaleType scaleType);
void selectionChanged(const QCPAxis::SelectableParts &parts);
void selectableChanged(const QCPAxis::SelectableParts &parts);
protected:
// introduced virtual methods:
virtual void setupTickVectors();
virtual void generateAutoTicks();
virtual int calculateAutoSubTickCount(double tickStep) const;
virtual int calculateMargin();
// reimplemented virtual methods:
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
virtual void draw(QCPPainter *painter);
virtual QCP::Interaction selectionCategory() const;
// events:
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
virtual void deselectEvent(bool *selectionStateChanged);
// non-virtual methods:
void visibleTickBounds(int &lowIndex, int &highIndex) const;
double baseLog(double value) const;
double basePow(double value) const;
QPen getBasePen() const;
QPen getTickPen() const;
QPen getSubTickPen() const;
QFont getTickLabelFont() const;
QFont getLabelFont() const;
QColor getTickLabelColor() const;
QColor getLabelColor() const;
};
class QCPAbstractPlottable : public QCPLayerable /Abstract/
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis);
// getters:
QString name() const;
bool antialiasedFill() const;
bool antialiasedScatters() const;
bool antialiasedErrorBars() const;
QPen pen() const;
QPen selectedPen() const;
QBrush brush() const;
QBrush selectedBrush() const;
QCPAxis *keyAxis() const;
QCPAxis *valueAxis() const;
bool selectable() const;
bool selected() const;
// setters:
void setName(const QString &name);
void setAntialiasedFill(bool enabled);
void setAntialiasedScatters(bool enabled);
void setAntialiasedErrorBars(bool enabled);
void setPen(const QPen &pen);
void setSelectedPen(const QPen &pen);
void setBrush(const QBrush &brush);
void setSelectedBrush(const QBrush &brush);
void setKeyAxis(QCPAxis *axis);
void setValueAxis(QCPAxis *axis);
Q_SLOT void setSelectable(bool selectable);
Q_SLOT void setSelected(bool selected);
// introduced virtual methods:
virtual void clearData() = 0;
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0;
virtual bool addToLegend();
virtual bool removeFromLegend() const;
// non-property methods:
void rescaleAxes(bool onlyEnlarge=false) const;
void rescaleKeyAxis(bool onlyEnlarge=false) const;
void rescaleValueAxis(bool onlyEnlarge=false) const;
public:
/*!
Represents negative and positive sign domain for passing to \ref getKeyRange and \ref getValueRange.
*/
enum SignDomain { sdNegative ///< The negative sign domain, i.e. numbers smaller than zero
,sdBoth ///< Both sign domains, including zero, i.e. all (rational) numbers
,sdPositive ///< The positive sign domain, i.e. numbers greater than zero
};
signals:
void selectionChanged(bool selected);
void selectableChanged(bool selectable);
protected:
// reimplemented virtual methods:
virtual QRect clipRect() const;
virtual void draw(QCPPainter *painter) = 0;
virtual QCP::Interaction selectionCategory() const;
void applyDefaultAntialiasingHint(QCPPainter *painter) const;
// events:
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
virtual void deselectEvent(bool *selectionStateChanged);
// introduced virtual methods:
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const = 0;
virtual QCPRange getKeyRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0;
virtual QCPRange getValueRange(bool &foundRange, SignDomain inSignDomain=sdBoth) const = 0;
// non-virtual methods:
//void coordsToPixels(double key, double value, double &x, double &y) const;
const QPointF coordsToPixels(double key, double value) const;
//void pixelsToCoords(double x, double y, double &key, double &value) const;
void pixelsToCoords(const QPointF &pixelPos, double &key, double &value) const;
QPen mainPen() const;
QBrush mainBrush() const;
void applyFillAntialiasingHint(QCPPainter *painter) const;
void applyScattersAntialiasingHint(QCPPainter *painter) const;
void applyErrorBarsAntialiasingHint(QCPPainter *painter) const;
double distSqrToLine(const QPointF &start, const QPointF &end, const QPointF &point) const;
};
class QCPItemAnchor
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name, int anchorId=-1);
virtual ~QCPItemAnchor();
// getters:
QString name() const;
virtual QPointF pixelPoint() const;
protected:
// introduced virtual methods:
virtual QCPItemPosition *toQCPItemPosition();
// non-virtual methods:
void addChildX(QCPItemPosition* pos); // called from pos when this anchor is set as parent
void removeChildX(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
void addChildY(QCPItemPosition* pos); // called from pos when this anchor is set as parent
void removeChildY(QCPItemPosition *pos); // called from pos when its parent anchor is reset or pos deleted
private:
QCPItemAnchor(const QCPItemAnchor &);
};
class QCPItemPosition : public QCPItemAnchor
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
enum PositionType { ptAbsolute ///< Static positioning in pixels, starting from the top left corner of the viewport/widget.
,ptViewportRatio ///< Static positioning given by a fraction of the viewport size. For example, if you call setCoords(0, 0), the position will be at the top
///< left corner of the viewport/widget. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and
///< vertically at the top of the viewport/widget, etc.
,ptAxisRectRatio ///< Static positioning given by a fraction of the axis rect size (see \ref setAxisRect). For example, if you call setCoords(0, 0), the position will be at the top
///< left corner of the axis rect. setCoords(1, 1) will be at the bottom right corner, setCoords(0.5, 0) will be horizontally centered and
///< vertically at the top of the axis rect, etc. You can also go beyond the axis rect by providing negative coordinates or coordinates larger than 1.
,ptPlotCoords ///< Dynamic positioning at a plot coordinate defined by two axes (see \ref setAxes).
};
QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString name);
virtual ~QCPItemPosition();
// getters:
PositionType type() const;
PositionType typeX() const;
PositionType typeY() const;
QCPItemAnchor *parentAnchor() const;
QCPItemAnchor *parentAnchorX() const;
QCPItemAnchor *parentAnchorY() const;
double key() const;
double value() const;
QPointF coords() const;
QCPAxis *keyAxis() const;
QCPAxis *valueAxis() const;
QCPAxisRect *axisRect() const;
virtual QPointF pixelPoint() const;
// setters:
void setType(PositionType type);
void setTypeX(PositionType type);
void setTypeY(PositionType type);
bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false);
void setCoords(double key, double value);
void setCoords(const QPointF &coords);
void setAxes(QCPAxis* keyAxis, QCPAxis* valueAxis);
void setAxisRect(QCPAxisRect *axisRect);
void setPixelPoint(const QPointF &pixelPoint);
protected:
// reimplemented virtual methods:
virtual QCPItemPosition *toQCPItemPosition();
};
class QCPAbstractItem : public QCPLayerable /Abstract/
{
%TypeHeaderCode
#include <qcustomplot.h>
%End
public:
QCPAbstractItem(QCustomPlot *parentPlot);
virtual ~QCPAbstractItem();
// getters:
bool clipToAxisRect() const;
QCPAxisRect *clipAxisRect() const;
bool selectable() const;
bool selected() const;
// setters:
void setClipToAxisRect(bool clip);
void setClipAxisRect(QCPAxisRect *rect);
Q_SLOT void setSelectable(bool selectable);
Q_SLOT void setSelected(bool selected);
// reimplemented virtual methods:
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0;
// non-virtual methods:
QList<QCPItemPosition*> positions() const;
QList<QCPItemAnchor*> anchors() const;
QCPItemPosition *position(const QString &name) const;
QCPItemAnchor *anchor(const QString &name) const;
bool hasAnchor(const QString &name) const;