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

Add plugin pyqcustomplot (GPL License)

parent 0dedb857
No related branches found
No related tags found
No related merge requests found
......@@ -28,4 +28,5 @@ ENDIF(PYTHONQT_FOUND)
IF(PYTHONQT_FOUND AND BUILD_PY_QGV)
ADD_SUBDIRECTORY(pyqgv)
ADD_SUBDIRECTORY(pyqcustomplot)
ENDIF(PYTHONQT_FOUND AND BUILD_PY_QGV)
# Copyright (c) 2018 CNRS
# Authors: Joseph Mirabel
#
#
# This file is part of gepetto-viewer-corba
# gepetto-viewer-corba is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# gepetto-viewer-corba 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 Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# gepetto-viewer-corba If not, see
# <http://www.gnu.org/licenses/>.
SET(PLUGIN_NAME pyqcustomplot)
SET(${PLUGIN_NAME}_HEADERS_NO_MOC
)
SET(${PLUGIN_NAME}_HEADERS
qcustomplot.h
plugin.hh
decorator.hh
)
SET(${PLUGIN_NAME}_FORMS
)
SET(${PLUGIN_NAME}_RESOURCES
)
IF(USE_QT4)
QT4_WRAP_CPP(${PLUGIN_NAME}_HEADERS_MOC ${${PLUGIN_NAME}_HEADERS})
QT4_WRAP_UI(${PLUGIN_NAME}_FORMS_HEADERS ${${PLUGIN_NAME}_FORMS})
QT4_ADD_RESOURCES(${PLUGIN_NAME}_RESOURCES_RCC ${${PLUGIN_NAME}_RESOURCES})
INCLUDE(${QT_USE_FILE})
ELSE(USE_QT4)
QT5_WRAP_CPP(${PLUGIN_NAME}_HEADERS_MOC ${${PLUGIN_NAME}_HEADERS})
QT5_WRAP_UI(${PLUGIN_NAME}_FORMS_HEADERS ${${PLUGIN_NAME}_FORMS})
QT5_ADD_RESOURCES(${PLUGIN_NAME}_RESOURCES_RCC ${${PLUGIN_NAME}_RESOURCES})
ENDIF(USE_QT4)
INCLUDE_DIRECTORIES("${PYTHON_INCLUDE_DIR}" "${PYTHONQT_INCLUDE_DIR}")
ADD_DEFINITIONS(${QT_DEFINITIONS}
-DQT_PLUGIN
-DQT_NO_DEBUG
-DQT_SHARED
-DQCUSTOMPLOT_COMPILE_LIBRARY)
SET (${PLUGIN_NAME}_SOURCES
qcustomplot.cpp
plugin.cc
decorator.cc
)
ADD_LIBRARY(${PLUGIN_NAME} SHARED ${${PLUGIN_NAME}_SOURCES}
${${PLUGIN_NAME}_HEADERS_NO_MOC}
${${PLUGIN_NAME}_HEADERS_MOC}
${${PLUGIN_NAME}_FORMS_HEADERS}
${${PLUGIN_NAME}_RESOURCES_RCC}
)
TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} ${PYTHONQT_LIBRARIES})
# Uncomment to install
INSTALL(TARGETS ${PLUGIN_NAME} DESTINATION lib/gepetto-gui-plugins)
// Copyright (c) 2018, Joseph Mirabel
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
//
// This file is part of gepetto-viewer-corba.
// gepetto-viewer-corba is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// gepetto-viewer-corba 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 Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// gepetto-viewer-corba. If not, see <http://www.gnu.org/licenses/>.
#include <decorator.hh>
#include <PythonQt.h>
void registerQCustomPlot ()
{
PythonQt::self()->addDecorators (new QCustomPlotDecorator ());
PythonQt::self()->registerCPPClass ("QCPPainter" , "QPainter", "QCustomPlot");
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");
// PythonQt::self()->registerCPPClass ("QCPItemPosition" , "QGraphicsItem" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPLayer" , "QObject" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPPlotTitle" , "QGraphicsItem" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPAbstractLegendItem", "QGraphicsItem" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPColorMap" , "QGraphicsItem" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPColorScale" , "QGraphicsItem" , "QCustomPlot");
// PythonQt::self()->registerCPPClass ("QCPBars" , "QGraphicsItem" , "QCustomPlot");
// Children of QCPLayerable
PythonQt::self()->registerCPPClass ("QCPLayerable" , "QObject" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPAbstractItem" , "QCPLayerable" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPItemEllipse" , "QCPAbstractItem" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPAbstractPlottable" , "QCPLayerable" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPLayoutElement" , "QCPLayerable" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPLayout" , "QCPLayoutElement" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPLayoutGrid" , "QCPLayout" , "QCustomPlot");
PythonQt::self()->registerCPPClass ("QCPLegend" , "QCPLayoutGrid" , "QCustomPlot");
}
#include <qcustomplot.h>
#include <QObject>
void registerQCustomPlot ();
class QCustomPlotDecorator : public QObject
{
Q_OBJECT
public Q_SLOTS:
// add a constructor
QCustomPlot* new_QCustomPlot()
{
return new QCustomPlot();
}
//wrapper functions
void delete_QCustomPlot(QCustomPlot* o) //delete QCustomPlot object
{
delete o;
}
void clearGraphs(QCustomPlot* o) //add a graph inside the QCustomPlot object
{
o->clearGraphs();
}
QCPGraph* addGraph(QCustomPlot* o) //add a graph inside the QCustomPlot object
{
return o->addGraph();
}
QCPGraph* graph(QCustomPlot* o, int graphnum)
{
return o->graph(graphnum);
}
void setData (QCustomPlot* o,int graphnum, const QVector<double> &keys, const QVector<double> &values) //set data to a certain graph. Deletes existing data inside the graph
{
o->graph(graphnum)->setData(keys,values);
}
void addData (QCustomPlot* o,int graphnum, const QVector<double> &keys, const QVector<double> &values) //set data to a certain graph. Deletes existing data inside the graph
{
o->graph(graphnum)->addData(keys,values);
}
void replot (QCustomPlot* o) //replot object to visualise new data
{
o->replot();
}
void show (QCustomPlot* o) //open new window with graph
{
o->show();
}
void setWindowTitle(QCustomPlot* o,QString title) //set title of window of graph
{
o->setWindowTitle(title);
}
void rescaleAxes(QCustomPlot* o, bool v = true) //rescale axis automatically if data does not fit
{
o->rescaleAxes(v);
}
void plotLayout_insertRow(QCustomPlot* o, int row) //insert row above graph
{
o->plotLayout()->insertRow(row);
}
void plotLayout_insertColumn(QCustomPlot* o, int column) //insert column above graph
{
o->plotLayout()->insertColumn(column);
}
void plotLayout_addElement(QCustomPlot* o, int row, int column, QCPLayoutElement *element) //add text to graph at row,column
{
o->plotLayout()->addElement(row,column,element);
}
void setAutoAddPlottableToLegend (QCustomPlot* o, bool v)
{
o->setAutoAddPlottableToLegend (v);
}
QCPLegend* legend (QCustomPlot* o)
{
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)
{
o->yAxis2->setLabel(text);
}
void yAxis2_setVisible(QCustomPlot* o, bool visible)
{
o->setVisible(visible);
}
void yAxis2_setRange(QCustomPlot* o, double position, double size)
{
o->yAxis2->setRange(position, size);
}
void yAxis2_setAutoTicks(QCustomPlot* o, bool on)
{
o->yAxis2->setAutoSubTicks(on);
}
void yAxis2_setAutoTickLabels(QCustomPlot* o, bool on)
{
o->yAxis2->setAutoTickLabels(on);
}
void yAxis2_setTickVector(QCustomPlot* o, const QVector<double> &ticks)
{
o->yAxis2->setTickVector(ticks);
}
void yAxis2_setTickVectorLabels(QCustomPlot* o, const QVector<QString> &labels)
{
o->yAxis2->setTickVectorLabels(labels);
}
void yAxis2_setTickLength(QCustomPlot* o, int inside, int outside)
{
o->yAxis2->setTickLength(inside,outside);
}
void yAxis2_setSubTickLength(QCustomPlot* o, int inside, int outside)
{
o->yAxis2->setSubTickLength(inside, outside);
}
//Interaction
void setInteraction(QCustomPlot* o, int interaction, bool enabled = true)
{
o->setInteraction((QCP::Interaction)interaction, enabled);
}
//QCPGraph
void rescaleAxes(QCPGraph* g, bool v = true)
{
g->rescaleAxes(v);
}
void setData (QCPGraph* g, const QVector<double> &keys, const QVector<double> &values)
{
g->setData(keys,values);
}
void addData (QCPGraph* g, const QVector<double> &keys, const QVector<double> &values)
{
g->addData(keys,values);
}
void setPen (QCPGraph* g, const QPen &pen)
{
g->setPen(pen);
}
//QCPAbstractPlottable
void setName (QCPAbstractPlottable* ap, const QString &n)
{
ap->setName(n);
}
//QCPLayerable
void setVisible (QCPLayerable* l, const bool &v)
{
l->setVisible(v);
}
};
// Copyright (c) 2018 CNRS
// Authors: Joseph Mirabel
//
//
// This file is part of gepetto-viewer-corba
// gepetto-viewer-corba is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// gepetto-viewer-corba 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 Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// gepetto-viewer-corba If not, see
// <http://www.gnu.org/licenses/>.
#include <plugin.hh>
#include <decorator.hh>
namespace PyQCustomPlot {
void Plugin::init() {
registerQCustomPlot();
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
Q_EXPORT_PLUGIN2 (pyqcustomplot, Plugin)
#endif
} // namespace PyQCustomPlot
// Copyright (c) 2018 CNRS
// Authors: Joseph Mirabel
//
//
// This file is part of gepetto-viewer-corba
// gepetto-viewer-corba is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// gepetto-viewer-corba 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 Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// gepetto-viewer-corba If not, see
// <http://www.gnu.org/licenses/>.
#include <QObject>
#include <QtGlobal>
#include <gepetto/gui/plugin-interface.hh>
namespace PyQCustomPlot {
/// \ingroup pluginlist
/// Provide bindings of QCustomPlot library in PythonQt terminal.
/// Add the following to your settings file to activate it.
///
/// [plugins]
/// libpyqcustomplot.so=true
///
class Plugin : public QObject, public gepetto::gui::PluginInterface {
Q_OBJECT
Q_INTERFACES (gepetto::gui::PluginInterface)
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
Q_PLUGIN_METADATA (IID "gepetto-viewer-corba.pyqcustomplot")
#endif
public:
QString name () const { return QString("PyQCustomPlot"); }
/// Calls \ref registerQCustomPlot
void init();
};
} // namespace PyQgv
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
qcustomplot-1.3.2/qcustomplot.cpp
\ No newline at end of file
qcustomplot-1.3.2/qcustomplot.h
\ No newline at end of file
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