gepetto-viewer  6.0.0
An user-friendly Graphical Interface
decorator.hh
Go to the documentation of this file.
1 #include <qcustomplot.h>
2 
3 #include <QObject>
4 #include <qcpitemrichtext.hh>
5 
7 
10 class QCustomPlotDecorator : public QObject {
11  Q_OBJECT
12  public Q_SLOTS:
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(); }
26  o->addPlottable(ap);
27  }
28 
29  QCPGraph* graph(QCustomPlot* o, int graphnum) { return o->graph(graphnum); }
31  QCustomPlot* o,
32  bool v = true) // rescale axis automatically if data does not fit
33  {
34  o->rescaleAxes(v);
35  }
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  }
75 
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  }
103 
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(); }
123 
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(); }
140 
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(); }
157 
160  void rescaleAxes(QCPAbstractPlottable* ap, bool v = true) {
161  ap->rescaleAxes(v);
162  }
164 
168 
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  }
185 
188  void setRangeZoomAxes(QCPAxisRect* ar, QCPAxis* horizontal,
189  QCPAxis* vertical) {
190  ar->setRangeZoomAxes(horizontal, vertical);
191  }
193 
196  void setType(QCPItemPosition* ip, int type) {
197  return ip->setType((QCPItemPosition::PositionType)type);
198  }
200  return ip->setParentAnchor(a);
201  }
202  void setCoords(QCPItemPosition* ip, double k, double v) {
203  return ip->setCoords(k, v);
204  }
206 
210  return ai->position(p);
211  }
213  return ai->anchor(a);
214  }
216 
220  return new QCPItemTracer(parent);
221  }
222  void delete_QCPItemTracer(QCPItemTracer* it) { delete it; }
224 
228  return new QCPItemRichText(parent);
229  }
230  void delete_QCPItemRichText(QCPItemRichText* it) { delete it; }
232 
236  return new QCPItemText(parent);
237  }
238  void delete_QCPItemText(QCPItemText* it) { delete it; }
240 
244  return new QCPItemEllipse(parent);
245  }
246  void delete_QCPItemEllipse(QCPItemEllipse* it) { delete it; }
248 };
Definition: qcustomplot.h:1847
QCPItemPosition * position(const QString &name) const
QCPItemAnchor * anchor(const QString &name) const
Definition: qcustomplot.h:1595
void rescaleAxes(bool onlyEnlarge=false) const
Definition: qcustomplot.h:2297
void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical)
Definition: qcustomplot.h:1137
Q_SLOT void setRange(const QCPRange &range)
void setLabel(const QString &str)
double pixelToCoord(double value) const
void setTickLength(int inside, int outside=0)
void setTickVector(const QVector< double > &vec)
SelectableParts selectedParts() const
Definition: qcustomplot.h:1328
void setTickVectorLabels(const QVector< QString > &vec)
void setAutoTickLabels(bool on)
void setSubTickLength(int inside, int outside=0)
void setAutoSubTicks(bool on)
Definition: qcustomplot.h:3241
void addData(const QCPBarDataMap &dataMap)
void setData(QCPBarDataMap *data, bool copy=false)
virtual void clearData()
Definition: qcustomplot.h:3058
void addData(const QCPCurveDataMap &dataMap)
void setData(QCPCurveDataMap *data, bool copy=false)
virtual void clearData()
Definition: qcustomplot.h:2833
virtual void clearData()
void setData(QCPDataMap *data, bool copy=false)
void addData(const QCPDataMap &dataMap)
Definition: qcustomplot.h:1724
Definition: qcustomplot.h:3980
Definition: qcustomplot.h:1763
void setType(PositionType type)
void setCoords(double key, double value)
PositionType
Definition: qcustomplot.h:1771
bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
Definition: qcpitemrichtext.hh:7
Definition: qcustomplot.h:3877
Definition: qcustomplot.h:4121
Definition: qcustomplot.h:755
Definition: qcustomplot.h:894
void insertColumn(int newIndex)
void insertRow(int newIndex)
bool addElement(int row, int column, QCPLayoutElement *element)
Definition: qcustomplot.h:2500
Definition: decorator.hh:10
QCPItemRichText * new_QCPItemRichText(QCustomPlot *parent)
Definition: decorator.hh:227
void setInteraction(QCustomPlot *o, int interaction, bool enabled=true)
Definition: decorator.hh:37
void setCoords(QCPItemPosition *ip, double k, double v)
Definition: decorator.hh:202
void clearData(QCPGraph *o)
Definition: decorator.hh:121
void delete_QCPItemText(QCPItemText *it)
Definition: decorator.hh:238
QCPGraph * graph(QCustomPlot *o, int graphnum)
Definition: decorator.hh:29
void delete_QCPCurve(QCPCurve *g)
Definition: decorator.hh:129
void setTickVector(QCPAxis *a, const QVector< double > &ticks)
Definition: decorator.hh:87
QCPItemText * new_QCPItemText(QCustomPlot *parent)
Definition: decorator.hh:235
bool saveJpg(QCustomPlot *o, const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
Definition: decorator.hh:52
void delete_QCustomPlot(QCustomPlot *o)
Definition: decorator.hh:18
void setRange(QCPAxis *a, double position, double size)
Definition: decorator.hh:82
void rescaleAxes(QCPAbstractPlottable *ap, bool v=true)
Definition: decorator.hh:160
QCPGraph * new_QCPGraph(QCPAxis *key, QCPAxis *value)
Definition: decorator.hh:106
bool saveBmp(QCustomPlot *o, const QString &fileName, int width=0, int height=0, double scale=1.0)
Definition: decorator.hh:56
QCPAxis * xAxis2(QCustomPlot *o)
Definition: decorator.hh:67
void insertColumn(QCPLayoutGrid *lg, int column)
Definition: decorator.hh:175
QCPAxis * yAxis(QCustomPlot *o)
Definition: decorator.hh:68
QCPItemAnchor * anchor(QCPAbstractItem *ai, QString a)
Definition: decorator.hh:212
QCPBars * new_QCPBars(QCPAxis *key, QCPAxis *value)
Definition: decorator.hh:143
bool savePng(QCustomPlot *o, const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
Definition: decorator.hh:48
bool saveRastered(QCustomPlot *o, const QString &fileName, int width, int height, double scale, const char *format, int quality=-1)
Definition: decorator.hh:60
QCPAxis * yAxis2(QCustomPlot *o)
Definition: decorator.hh:69
QCPGraph * addGraph(QCustomPlot *o)
Definition: decorator.hh:24
QCPItemTracer * new_QCPItemTracer(QCustomPlot *parent)
Definition: decorator.hh:219
void clearData(QCPCurve *o)
Definition: decorator.hh:138
QCPLegend * legend(QCustomPlot *o)
Definition: decorator.hh:70
void delete_QCPItemTracer(QCPItemTracer *it)
Definition: decorator.hh:222
void addPlottable(QCustomPlot *o, QCPAbstractPlottable *ap)
Definition: decorator.hh:25
void clearGraphs(QCustomPlot *o)
Definition: decorator.hh:22
bool setParentAnchor(QCPItemPosition *ip, QCPItemAnchor *a)
Definition: decorator.hh:199
void delete_QCPItemEllipse(QCPItemEllipse *it)
Definition: decorator.hh:246
void delete_QCPGraph(QCPGraph *g)
Definition: decorator.hh:109
void setAutoTickLabels(QCPAxis *a, bool on)
Definition: decorator.hh:86
void addData(QCPCurve *c, const QVector< double > &ts, const QVector< double > &keys, const QVector< double > &values)
Definition: decorator.hh:134
bool savePdf(QCustomPlot *o, const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator=QString(), const QString &pdfTitle=QString())
Definition: decorator.hh:41
void addData(QCPGraph *g, const QVector< double > &keys, const QVector< double > &values)
Definition: decorator.hh:114
QCPItemPosition * position(QCPAbstractItem *ai, QString p)
Definition: decorator.hh:209
void rescaleAxes(QCustomPlot *o, bool v=true)
Definition: decorator.hh:30
void delete_QCPBars(QCPBars *g)
Definition: decorator.hh:146
QCPAxisRect * axisRect(QCustomPlot *o, int index=0)
Definition: decorator.hh:71
void setAutoTicks(QCPAxis *a, bool on)
Definition: decorator.hh:85
QCPCurve * new_QCPCurve(QCPAxis *key, QCPAxis *value)
Definition: decorator.hh:126
QCustomPlot * new_QCustomPlot(QWidget *parent=0)
Definition: decorator.hh:15
void addElement(QCPLayoutGrid *lg, int row, int column, QCPLayoutElement *element)
Definition: decorator.hh:179
void addData(QCPBars *c, const QVector< double > &keys, const QVector< double > &values)
Definition: decorator.hh:151
double pixelToCoord(QCPAxis *a, double pixel)
Definition: decorator.hh:99
QCPItemEllipse * new_QCPItemEllipse(QCustomPlot *parent)
Definition: decorator.hh:243
int selectedParts(const QCPAxis *a)
Definition: decorator.hh:80
void setTickLength(QCPAxis *a, int inside, int outside)
Definition: decorator.hh:93
void addData(QCPGraph *g, const double &key, const double &value)
Definition: decorator.hh:118
void setData(QCPGraph *g, const QVector< double > &keys, const QVector< double > &values)
Definition: decorator.hh:110
void setLabel(QCPAxis *a, const QString text)
Definition: decorator.hh:81
void setTickVectorLabels(QCPAxis *a, const QVector< QString > &labels)
Definition: decorator.hh:90
void insertRow(QCPLayoutGrid *lg, int row)
Definition: decorator.hh:171
void setSubTickLength(QCPAxis *a, int inside, int outside)
Definition: decorator.hh:96
void delete_QCPItemRichText(QCPItemRichText *it)
Definition: decorator.hh:230
void setRangeZoomAxes(QCPAxisRect *ar, QCPAxis *horizontal, QCPAxis *vertical)
Definition: decorator.hh:188
void setType(QCPItemPosition *ip, int type)
Definition: decorator.hh:196
void setData(QCPCurve *c, const QVector< double > &keys, const QVector< double > &values)
Definition: decorator.hh:130
QCPAxis * xAxis(QCustomPlot *o)
Definition: decorator.hh:66
void setData(QCPBars *c, const QVector< double > &keys, const QVector< double > &values)
Definition: decorator.hh:147
void clearData(QCPBars *o)
Definition: decorator.hh:155
Definition: qcustomplot.h:1925
void setInteraction(const QCP::Interaction &interaction, bool enabled=true)
bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
QCPLegend * legend
Definition: qcustomplot.h:2106
bool savePdf(const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator=QString(), const QString &pdfTitle=QString())
bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0)
bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
QCPGraph * addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0)
Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false)
QCPAxis * xAxis
Definition: qcustomplot.h:2105
int clearGraphs()
bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1)
bool addPlottable(QCPAbstractPlottable *plottable)
QCPAxis * xAxis2
Definition: qcustomplot.h:2105
QCPGraph * graph(int index) const
QCPAxis * yAxis2
Definition: qcustomplot.h:2105
QCPAxisRect * axisRect(int index=0) const
QCPAxis * yAxis
Definition: qcustomplot.h:2105
Interaction
Definition: qcustomplot.h:195
void registerQCustomPlot()