Skip to content
Snippets Groups Projects
Commit f06810c1 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Improve QCustomPlot python bindings

parent f9c05e26
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,6 @@ void registerQCustomPlot ()
PythonQt::self()->registerCPPClass ("QCustomPlot" , "QWidget" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPLayoutElement" , "QGraphicsScene", "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPLayout" , "QGraphicsItem" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPAxis" , "QGraphicsItem" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPAxisRect" , "QGraphicsItem" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPAxisPainterPrivate", "QGraphicsItem" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPGraph" , "QCPAbstractPlottable" , "QCustomPlot");
......@@ -49,4 +48,6 @@ void registerQCustomPlot ()
PythonQt::self()->registerCPPClass ("QCPLayout" , "QCPLayoutElement" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPLayoutGrid" , "QCPLayout" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPLegend" , "QCPLayoutGrid" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPAxis" , "QCPLayerable" , "QCustomPlot");
}
......@@ -9,15 +9,16 @@ class QCustomPlotDecorator : public QObject
Q_OBJECT
public Q_SLOTS:
// add a constructor
QCustomPlot* new_QCustomPlot()
QCustomPlot* new_QCustomPlot(QWidget* parent = 0)
{
return new QCustomPlot();
return new QCustomPlot(parent);
}
//wrapper functions
void delete_QCustomPlot(QCustomPlot* o) //delete QCustomPlot object
{
delete o;
}
/// \name QCustomPlot
/// \{
void clearGraphs(QCustomPlot* o) //add a graph inside the QCustomPlot object
{
o->clearGraphs();
......@@ -74,161 +75,58 @@ class QCustomPlotDecorator : public QObject
{
return o->legend;
}
//------------------------------------------------------- Axis adjustment stuff------------------------------------------------
//xAxis stuff
void xAxis_setLabel(QCustomPlot* o, const QString text)
{
o->xAxis->setLabel(text);
}
void xAxis_setVisible(QCustomPlot* o, bool visible)
{
o->setVisible(visible);
}
void xAxis_setRange(QCustomPlot* o, double position, double size)
{
o->xAxis->setRange(position, size);
}
void xAxis_setAutoTicks(QCustomPlot* o, bool on)
{
o->xAxis->setAutoSubTicks(on);
}
void xAxis_setAutoTickLabels(QCustomPlot* o, bool on)
{
o->xAxis->setAutoTickLabels(on);
}
void xAxis_setTickVector(QCustomPlot* o, const QVector<double> &ticks)
{
o->xAxis->setTickVector(ticks);
}
void xAxis_setTickVectorLabels(QCustomPlot* o, const QVector<QString> &labels)
{
o->xAxis->setTickVectorLabels(labels);
}
void xAxis_setTickLength(QCustomPlot* o, int inside, int outside)
{
o->xAxis->setTickLength(inside,outside);
}
void xAxis_setSubTickLength(QCustomPlot* o, int inside, int outside)
{
o->xAxis->setSubTickLength(inside, outside);
}
//xAxis2 stuff
void xAxis2_setLabel(QCustomPlot* o, const QString text)
{
o->xAxis2->setLabel(text);
}
void xAxis2_setVisible(QCustomPlot* o, bool visible)
{
o->setVisible(visible);
}
void xAxis2_setRange(QCustomPlot* o, double position, double size)
{
o->xAxis2->setRange(position, size);
}
void xAxis2_setAutoTicks(QCustomPlot* o, bool on)
{
o->xAxis2->setAutoSubTicks(on);
}
void xAxis2_setAutoTickLabels(QCustomPlot* o, bool on)
{
o->xAxis2->setAutoTickLabels(on);
}
void xAxis2_setTickVector(QCustomPlot* o, const QVector<double> &ticks)
{
o->xAxis2->setTickVector(ticks);
}
void xAxis2_setTickVectorLabels(QCustomPlot* o, const QVector<QString> &labels)
{
o->xAxis2->setTickVectorLabels(labels);
}
void xAxis2_setTickLength(QCustomPlot* o, int inside, int outside)
{
o->xAxis2->setTickLength(inside,outside);
}
void xAxis2_setSubTickLength(QCustomPlot* o, int inside, int outside)
{
o->xAxis2->setSubTickLength(inside, outside);
}
//yAxis stuff
void yAxis_setLabel(QCustomPlot* o, const QString text)
{
o->yAxis->setLabel(text);
}
void yAxis_setVisible(QCustomPlot* o, bool visible)
{
o->setVisible(visible);
}
void yAxis_setRange(QCustomPlot* o, double position, double size)
{
o->yAxis->setRange(position, size);
}
void yAxis_setAutoTicks(QCustomPlot* o, bool on)
{
o->yAxis->setAutoSubTicks(on);
}
void yAxis_setAutoTickLabels(QCustomPlot* o, bool on)
{
o->yAxis->setAutoTickLabels(on);
}
void yAxis_setTickVector(QCustomPlot* o, const QVector<double> &ticks)
{
o->yAxis->setTickVector(ticks);
}
void yAxis_setTickVectorLabels(QCustomPlot* o, const QVector<QString> &labels)
{
o->yAxis->setTickVectorLabels(labels);
}
void yAxis_setTickLength(QCustomPlot* o, int inside, int outside)
{
o->yAxis->setTickLength(inside,outside);
}
void yAxis_setSubTickLength(QCustomPlot* o, int inside, int outside)
{
o->yAxis->setSubTickLength(inside, outside);
}
//yAxis2 stuff
void yAxis2_setLabel(QCustomPlot* o, const QString text)
void setInteraction(QCustomPlot* o, int interaction, bool enabled = true)
{
o->yAxis2->setLabel(text);
o->setInteraction((QCP::Interaction)interaction, enabled);
}
void yAxis2_setVisible(QCustomPlot* o, bool visible)
QCPAxis* xAxis (QCustomPlot* o) { return o->xAxis ; }
QCPAxis* xAxis2 (QCustomPlot* o) { return o->xAxis2; }
QCPAxis* yAxis (QCustomPlot* o) { return o->yAxis ; }
QCPAxis* yAxis2 (QCustomPlot* o) { return o->yAxis2; }
/// \}
/// \name QCPAxis
/// \{
void setLabel(QCPAxis* a, const QString text)
{
o->setVisible(visible);
a->setLabel(text);
}
void yAxis2_setRange(QCustomPlot* o, double position, double size)
void setRange(QCPAxis* a, double position, double size)
{
o->yAxis2->setRange(position, size);
a->setRange(position, size);
}
void yAxis2_setAutoTicks(QCustomPlot* o, bool on)
void setAutoTicks(QCPAxis* a, bool on)
{
o->yAxis2->setAutoSubTicks(on);
a->setAutoSubTicks(on);
}
void yAxis2_setAutoTickLabels(QCustomPlot* o, bool on)
void setAutoTickLabels(QCPAxis* a, bool on)
{
o->yAxis2->setAutoTickLabels(on);
a->setAutoTickLabels(on);
}
void yAxis2_setTickVector(QCustomPlot* o, const QVector<double> &ticks)
void setTickVector(QCPAxis* a, const QVector<double> &ticks)
{
o->yAxis2->setTickVector(ticks);
a->setTickVector(ticks);
}
void yAxis2_setTickVectorLabels(QCustomPlot* o, const QVector<QString> &labels)
void setTickVectorLabels(QCPAxis* a, const QVector<QString> &labels)
{
o->yAxis2->setTickVectorLabels(labels);
a->setTickVectorLabels(labels);
}
void yAxis2_setTickLength(QCustomPlot* o, int inside, int outside)
void setTickLength(QCPAxis* a, int inside, int outside)
{
o->yAxis2->setTickLength(inside,outside);
a->setTickLength(inside,outside);
}
void yAxis2_setSubTickLength(QCustomPlot* o, int inside, int outside)
void setSubTickLength(QCPAxis* a, int inside, int outside)
{
o->yAxis2->setSubTickLength(inside, outside);
a->setSubTickLength(inside, outside);
}
//Interaction
void setInteraction(QCustomPlot* o, int interaction, bool enabled = true)
double pixelToCoord(QCPAxis* a, double pixel)
{
o->setInteraction((QCP::Interaction)interaction, enabled);
return a->pixelToCoord(pixel);
}
//QCPGraph
/// \}
/// \name QCPGraph
/// \{
void rescaleAxes(QCPGraph* g, bool v = true)
{
g->rescaleAxes(v);
......@@ -245,14 +143,21 @@ class QCustomPlotDecorator : public QObject
{
g->setPen(pen);
}
//QCPAbstractPlottable
/// \}
/// \name QCPAbstractPlottable
/// \{
void setName (QCPAbstractPlottable* ap, const QString &n)
{
ap->setName(n);
}
//QCPLayerable
/// \}
/// \name QCPLayerable
/// \{
void setVisible (QCPLayerable* l, const bool &v)
{
l->setVisible(v);
}
/// \}
};
......@@ -24,6 +24,8 @@
namespace PyQCustomPlot {
/// \ingroup pluginlist
/// Provide bindings of QCustomPlot library in PythonQt terminal.
/// See QCustomPlotDecorator for the API available in Python.
///
/// Add the following to your settings file to activate it.
///
/// [plugins]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment