1 |
|
|
#include <qcustomplot.h> |
2 |
|
|
|
3 |
|
|
#include <QObject> |
4 |
|
|
#include <qcpitemrichtext.hh> |
5 |
|
|
|
6 |
|
|
void registerQCustomPlot(); |
7 |
|
|
|
8 |
|
|
/// \sa See examples \ref pyplugin/qcustomplot_example_1.py |
9 |
|
|
/// and \ref pyplugin/qcustomplot_example_2.py |
10 |
|
|
class QCustomPlotDecorator : public QObject { |
11 |
|
|
Q_OBJECT |
12 |
|
|
public Q_SLOTS: |
13 |
|
|
/// \name QCustomPlot |
14 |
|
|
/// \{ |
15 |
|
|
QCustomPlot* new_QCustomPlot(QWidget* parent = 0) { |
16 |
|
|
return new QCustomPlot(parent); |
17 |
|
|
} |
18 |
|
|
void delete_QCustomPlot(QCustomPlot* o) // delete QCustomPlot object |
19 |
|
|
{ |
20 |
|
|
delete o; |
21 |
|
|
} |
22 |
|
|
void clearGraphs(QCustomPlot* o) { o->clearGraphs(); } |
23 |
|
|
|
24 |
|
|
QCPGraph* addGraph(QCustomPlot* o) { return o->addGraph(); } |
25 |
|
|
void addPlottable(QCustomPlot* o, QCPAbstractPlottable* ap) { |
26 |
|
|
o->addPlottable(ap); |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
QCPGraph* graph(QCustomPlot* o, int graphnum) { return o->graph(graphnum); } |
30 |
|
|
void rescaleAxes( |
31 |
|
|
QCustomPlot* o, |
32 |
|
|
bool v = true) // rescale axis automatically if data does not fit |
33 |
|
|
{ |
34 |
|
|
o->rescaleAxes(v); |
35 |
|
|
} |
36 |
|
|
/// \param interaction See QCP::Interaction |
37 |
|
|
void setInteraction(QCustomPlot* o, int interaction, bool enabled = true) { |
38 |
|
|
o->setInteraction((QCP::Interaction)interaction, enabled); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
bool savePdf(QCustomPlot* o, const QString& fileName, |
42 |
|
|
bool noCosmeticPen = false, int width = 0, int height = 0, |
43 |
|
|
const QString& pdfCreator = QString(), |
44 |
|
|
const QString& pdfTitle = QString()) { |
45 |
|
|
return o->savePdf(fileName, noCosmeticPen, width, height, pdfCreator, |
46 |
|
|
pdfTitle); |
47 |
|
|
} |
48 |
|
|
bool savePng(QCustomPlot* o, const QString& fileName, int width = 0, |
49 |
|
|
int height = 0, double scale = 1.0, int quality = -1) { |
50 |
|
|
return o->savePng(fileName, width, height, scale, quality); |
51 |
|
|
} |
52 |
|
|
bool saveJpg(QCustomPlot* o, const QString& fileName, int width = 0, |
53 |
|
|
int height = 0, double scale = 1.0, int quality = -1) { |
54 |
|
|
return o->saveJpg(fileName, width, height, scale, quality); |
55 |
|
|
} |
56 |
|
|
bool saveBmp(QCustomPlot* o, const QString& fileName, int width = 0, |
57 |
|
|
int height = 0, double scale = 1.0) { |
58 |
|
|
return o->saveBmp(fileName, width, height, scale); |
59 |
|
|
} |
60 |
|
|
bool saveRastered(QCustomPlot* o, const QString& fileName, int width, |
61 |
|
|
int height, double scale, const char* format, |
62 |
|
|
int quality = -1) { |
63 |
|
|
return o->saveRastered(fileName, width, height, scale, format, quality); |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
QCPAxis* xAxis(QCustomPlot* o) { return o->xAxis; } |
67 |
|
|
QCPAxis* xAxis2(QCustomPlot* o) { return o->xAxis2; } |
68 |
|
|
QCPAxis* yAxis(QCustomPlot* o) { return o->yAxis; } |
69 |
|
|
QCPAxis* yAxis2(QCustomPlot* o) { return o->yAxis2; } |
70 |
|
|
QCPLegend* legend(QCustomPlot* o) { return o->legend; } |
71 |
|
|
QCPAxisRect* axisRect(QCustomPlot* o, int index = 0) { |
72 |
|
|
return o->axisRect(index); |
73 |
|
|
} |
74 |
|
|
/// \} |
75 |
|
|
|
76 |
|
|
/// \name QCPAxis |
77 |
|
|
/// \todo Most of this function should be removed as they duplicates the |
78 |
|
|
/// QProperty methods. |
79 |
|
|
/// \{ |
80 |
|
|
int selectedParts(const QCPAxis* a) { return a->selectedParts(); } |
81 |
|
|
void setLabel(QCPAxis* a, const QString text) { a->setLabel(text); } |
82 |
|
|
void setRange(QCPAxis* a, double position, double size) { |
83 |
|
|
a->setRange(position, size); |
84 |
|
|
} |
85 |
|
|
void setAutoTicks(QCPAxis* a, bool on) { a->setAutoSubTicks(on); } |
86 |
|
|
void setAutoTickLabels(QCPAxis* a, bool on) { a->setAutoTickLabels(on); } |
87 |
|
|
void setTickVector(QCPAxis* a, const QVector<double>& ticks) { |
88 |
|
|
a->setTickVector(ticks); |
89 |
|
|
} |
90 |
|
|
void setTickVectorLabels(QCPAxis* a, const QVector<QString>& labels) { |
91 |
|
|
a->setTickVectorLabels(labels); |
92 |
|
|
} |
93 |
|
|
void setTickLength(QCPAxis* a, int inside, int outside) { |
94 |
|
|
a->setTickLength(inside, outside); |
95 |
|
|
} |
96 |
|
|
void setSubTickLength(QCPAxis* a, int inside, int outside) { |
97 |
|
|
a->setSubTickLength(inside, outside); |
98 |
|
|
} |
99 |
|
|
double pixelToCoord(QCPAxis* a, double pixel) { |
100 |
|
|
return a->pixelToCoord(pixel); |
101 |
|
|
} |
102 |
|
|
/// \} |
103 |
|
|
|
104 |
|
|
/// \name QCPGraph |
105 |
|
|
/// \{ |
106 |
|
|
QCPGraph* new_QCPGraph(QCPAxis* key, QCPAxis* value) { |
107 |
|
|
return new QCPGraph(key, value); |
108 |
|
|
} |
109 |
|
|
void delete_QCPGraph(QCPGraph* g) { delete g; } |
110 |
|
|
void setData(QCPGraph* g, const QVector<double>& keys, |
111 |
|
|
const QVector<double>& values) { |
112 |
|
|
g->setData(keys, values); |
113 |
|
|
} |
114 |
|
|
void addData(QCPGraph* g, const QVector<double>& keys, |
115 |
|
|
const QVector<double>& values) { |
116 |
|
|
g->addData(keys, values); |
117 |
|
|
} |
118 |
|
|
void addData(QCPGraph* g, const double& key, const double& value) { |
119 |
|
|
g->addData(key, value); |
120 |
|
|
} |
121 |
|
|
void clearData(QCPGraph* o) { o->clearData(); } |
122 |
|
|
/// \} |
123 |
|
|
|
124 |
|
|
/// \name QCPCurve |
125 |
|
|
/// \{ |
126 |
|
|
QCPCurve* new_QCPCurve(QCPAxis* key, QCPAxis* value) { |
127 |
|
|
return new QCPCurve(key, value); |
128 |
|
|
} |
129 |
|
|
void delete_QCPCurve(QCPCurve* g) { delete g; } |
130 |
|
|
void setData(QCPCurve* c, const QVector<double>& keys, |
131 |
|
|
const QVector<double>& values) { |
132 |
|
|
c->setData(keys, values); |
133 |
|
|
} |
134 |
|
|
void addData(QCPCurve* c, const QVector<double>& ts, |
135 |
|
|
const QVector<double>& keys, const QVector<double>& values) { |
136 |
|
|
c->addData(ts, keys, values); |
137 |
|
|
} |
138 |
|
|
void clearData(QCPCurve* o) { o->clearData(); } |
139 |
|
|
/// \} |
140 |
|
|
|
141 |
|
|
/// \name QCPBars |
142 |
|
|
/// \{ |
143 |
|
|
QCPBars* new_QCPBars(QCPAxis* key, QCPAxis* value) { |
144 |
|
|
return new QCPBars(key, value); |
145 |
|
|
} |
146 |
|
|
void delete_QCPBars(QCPBars* g) { delete g; } |
147 |
|
|
void setData(QCPBars* c, const QVector<double>& keys, |
148 |
|
|
const QVector<double>& values) { |
149 |
|
|
c->setData(keys, values); |
150 |
|
|
} |
151 |
|
|
void addData(QCPBars* c, const QVector<double>& keys, |
152 |
|
|
const QVector<double>& values) { |
153 |
|
|
c->addData(keys, values); |
154 |
|
|
} |
155 |
|
|
void clearData(QCPBars* o) { o->clearData(); } |
156 |
|
|
/// \} |
157 |
|
|
|
158 |
|
|
/// \name QCPAbstractPlottable |
159 |
|
|
/// \{ |
160 |
|
|
void rescaleAxes(QCPAbstractPlottable* ap, bool v = true) { |
161 |
|
|
ap->rescaleAxes(v); |
162 |
|
|
} |
163 |
|
|
/// \} |
164 |
|
|
|
165 |
|
|
/// \name QCPLayerable |
166 |
|
|
/// \{ |
167 |
|
|
/// \} |
168 |
|
|
|
169 |
|
|
/// \name QCPLayoutGrid |
170 |
|
|
/// \{ |
171 |
|
|
void insertRow(QCPLayoutGrid* lg, int row) // insert row above graph |
172 |
|
|
{ |
173 |
|
|
lg->insertRow(row); |
174 |
|
|
} |
175 |
|
|
void insertColumn(QCPLayoutGrid* lg, int column) // insert column above graph |
176 |
|
|
{ |
177 |
|
|
lg->insertColumn(column); |
178 |
|
|
} |
179 |
|
|
void addElement(QCPLayoutGrid* lg, int row, int column, |
180 |
|
|
QCPLayoutElement* element) // add text to graph at row,column |
181 |
|
|
{ |
182 |
|
|
lg->addElement(row, column, element); |
183 |
|
|
} |
184 |
|
|
/// \} |
185 |
|
|
|
186 |
|
|
/// \name QCPAxisRect |
187 |
|
|
/// \{ |
188 |
|
|
void setRangeZoomAxes(QCPAxisRect* ar, QCPAxis* horizontal, |
189 |
|
|
QCPAxis* vertical) { |
190 |
|
|
ar->setRangeZoomAxes(horizontal, vertical); |
191 |
|
|
} |
192 |
|
|
/// \} |
193 |
|
|
|
194 |
|
|
/// \name QCPItemPosition |
195 |
|
|
/// \{ |
196 |
|
|
void setType(QCPItemPosition* ip, int type) { |
197 |
|
|
return ip->setType((QCPItemPosition::PositionType)type); |
198 |
|
|
} |
199 |
|
|
bool setParentAnchor(QCPItemPosition* ip, QCPItemAnchor* a) { |
200 |
|
|
return ip->setParentAnchor(a); |
201 |
|
|
} |
202 |
|
|
void setCoords(QCPItemPosition* ip, double k, double v) { |
203 |
|
|
return ip->setCoords(k, v); |
204 |
|
|
} |
205 |
|
|
/// \} |
206 |
|
|
|
207 |
|
|
/// \name QCPAbstractItem |
208 |
|
|
/// \{ |
209 |
|
|
QCPItemPosition* position(QCPAbstractItem* ai, QString p) { |
210 |
|
|
return ai->position(p); |
211 |
|
|
} |
212 |
|
|
QCPItemAnchor* anchor(QCPAbstractItem* ai, QString a) { |
213 |
|
|
return ai->anchor(a); |
214 |
|
|
} |
215 |
|
|
/// \} |
216 |
|
|
|
217 |
|
|
/// \name QCPItemTracer |
218 |
|
|
/// \{ |
219 |
|
|
QCPItemTracer* new_QCPItemTracer(QCustomPlot* parent) { |
220 |
|
|
return new QCPItemTracer(parent); |
221 |
|
|
} |
222 |
|
|
void delete_QCPItemTracer(QCPItemTracer* it) { delete it; } |
223 |
|
|
/// \} |
224 |
|
|
|
225 |
|
|
/// \name QCPItemRichText |
226 |
|
|
/// \{ |
227 |
|
|
QCPItemRichText* new_QCPItemRichText(QCustomPlot* parent) { |
228 |
|
|
return new QCPItemRichText(parent); |
229 |
|
|
} |
230 |
|
|
void delete_QCPItemRichText(QCPItemRichText* it) { delete it; } |
231 |
|
|
/// \} |
232 |
|
|
|
233 |
|
|
/// \name QCPItemText |
234 |
|
|
/// \{ |
235 |
|
|
QCPItemText* new_QCPItemText(QCustomPlot* parent) { |
236 |
|
|
return new QCPItemText(parent); |
237 |
|
|
} |
238 |
|
|
void delete_QCPItemText(QCPItemText* it) { delete it; } |
239 |
|
|
/// \} |
240 |
|
|
|
241 |
|
|
/// \name QCPItemEllipse |
242 |
|
|
/// \{ |
243 |
|
|
QCPItemEllipse* new_QCPItemEllipse(QCustomPlot* parent) { |
244 |
|
|
return new QCPItemEllipse(parent); |
245 |
|
|
} |
246 |
|
|
void delete_QCPItemEllipse(QCPItemEllipse* it) { delete it; } |
247 |
|
|
/// \} |
248 |
|
|
}; |