2013-11-24 16:10:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
// Python includes
|
2017-10-13 17:49:29 +02:00
|
|
|
// collide of qt slots macro
|
|
|
|
#undef slots
|
2013-11-26 21:38:24 +01:00
|
|
|
#include <Python.h>
|
2017-10-13 17:49:29 +02:00
|
|
|
#define slots
|
2013-11-26 21:38:24 +01:00
|
|
|
|
2013-11-30 17:41:38 +01:00
|
|
|
// Qt includes
|
|
|
|
#include <QThread>
|
2016-09-21 22:01:50 +02:00
|
|
|
#include <QSize>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QPainter>
|
2017-04-14 07:58:34 +02:00
|
|
|
#include <QMap>
|
2013-11-30 17:41:38 +01:00
|
|
|
|
2013-11-28 14:38:07 +01:00
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/ImageProcessor.h>
|
2016-10-10 18:29:54 +02:00
|
|
|
#include <utils/Components.h>
|
2013-11-28 14:38:07 +01:00
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
class Effect : public QThread
|
2013-11-24 16:10:48 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-10-13 17:49:29 +02:00
|
|
|
Effect(PyThreadState* mainThreadState, int priority, int timeout, const QString & script, const QString & name, const QJsonObject & args = QJsonObject(), const QString & origin="System", unsigned smoothCfg=0);
|
2013-11-24 16:10:48 +01:00
|
|
|
virtual ~Effect();
|
2013-11-26 21:38:24 +01:00
|
|
|
|
|
|
|
virtual void run();
|
|
|
|
|
2017-10-12 11:55:03 +02:00
|
|
|
int getPriority() const { return _priority; };
|
|
|
|
|
2016-09-13 11:51:16 +02:00
|
|
|
QString getScript() const { return _script; }
|
|
|
|
QString getName() const { return _name; }
|
2017-10-12 11:55:03 +02:00
|
|
|
|
2016-04-24 17:07:31 +02:00
|
|
|
int getTimeout() const {return _timeout; }
|
2013-11-26 21:38:24 +01:00
|
|
|
|
2017-10-12 11:55:03 +02:00
|
|
|
QJsonObject getArgs() const { return _args; }
|
2013-11-30 15:54:47 +01:00
|
|
|
|
2014-02-26 18:10:17 +01:00
|
|
|
/// This function registers the extension module in Python
|
|
|
|
static void registerHyperionExtensionModule();
|
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
signals:
|
2017-08-04 12:01:45 +02:00
|
|
|
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects, hyperion::Components componentconst, QString origin, unsigned smoothCfg);
|
2013-11-29 23:22:49 +01:00
|
|
|
|
2013-11-28 14:15:52 +01:00
|
|
|
private:
|
2016-10-09 22:22:17 +02:00
|
|
|
PyObject * json2python(const QJsonValue & jsonData) const;
|
2013-11-30 17:41:38 +01:00
|
|
|
|
2013-11-28 14:15:52 +01:00
|
|
|
// Wrapper methods for Python interpreter extra buildin methods
|
2016-09-21 22:01:50 +02:00
|
|
|
static PyMethodDef effectMethods[];
|
2017-02-16 07:33:58 +01:00
|
|
|
static PyObject* wrapSetColor (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapSetImage (PyObject *self, PyObject *args);
|
2017-10-12 12:00:32 +02:00
|
|
|
static PyObject* wrapGetImage (PyObject *self, PyObject *args);
|
2017-02-16 07:33:58 +01:00
|
|
|
static PyObject* wrapAbort (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageShow (PyObject *self, PyObject *args);
|
2017-07-30 14:36:23 +02:00
|
|
|
static PyObject* wrapImageLinearGradient (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageConicalGradient (PyObject *self, PyObject *args);
|
2017-02-16 07:33:58 +01:00
|
|
|
static PyObject* wrapImageRadialGradient (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageSolidFill (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageDrawLine (PyObject *self, PyObject *args);
|
2017-07-30 14:36:23 +02:00
|
|
|
static PyObject* wrapImageDrawPoint (PyObject *self, PyObject *args);
|
2017-02-16 07:33:58 +01:00
|
|
|
static PyObject* wrapImageDrawRect (PyObject *self, PyObject *args);
|
2017-07-30 14:36:23 +02:00
|
|
|
static PyObject* wrapImageDrawPolygon (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageDrawPie (PyObject *self, PyObject *args);
|
2017-02-16 07:33:58 +01:00
|
|
|
static PyObject* wrapImageSetPixel (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageGetPixel (PyObject *self, PyObject *args);
|
2017-04-14 07:58:34 +02:00
|
|
|
static PyObject* wrapImageSave (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageMinSize (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageWidth (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageHeight (PyObject *self, PyObject *args);
|
2017-07-30 14:36:23 +02:00
|
|
|
static PyObject* wrapImageCRotate (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageCOffset (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageCShear (PyObject *self, PyObject *args);
|
|
|
|
static PyObject* wrapImageResetT (PyObject *self, PyObject *args);
|
2016-09-21 22:01:50 +02:00
|
|
|
static Effect * getEffect();
|
2014-02-26 18:10:17 +01:00
|
|
|
|
2016-09-21 22:01:50 +02:00
|
|
|
static struct PyModuleDef moduleDef;
|
|
|
|
static PyObject* PyInit_hyperion();
|
2013-11-28 14:15:52 +01:00
|
|
|
|
2017-04-14 07:58:34 +02:00
|
|
|
void addImage();
|
|
|
|
|
2017-10-13 17:49:29 +02:00
|
|
|
PyThreadState* _mainThreadState;
|
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
const int _priority;
|
|
|
|
|
|
|
|
const int _timeout;
|
2013-11-29 23:22:49 +01:00
|
|
|
|
2016-09-13 11:51:16 +02:00
|
|
|
const QString _script;
|
|
|
|
const QString _name;
|
2017-08-04 12:01:45 +02:00
|
|
|
unsigned _smoothCfg;
|
2013-11-30 00:28:04 +01:00
|
|
|
|
2016-10-09 22:22:17 +02:00
|
|
|
const QJsonObject _args;
|
2013-11-30 00:28:04 +01:00
|
|
|
|
2013-11-28 14:29:31 +01:00
|
|
|
int64_t _endTime;
|
2013-11-26 21:38:24 +01:00
|
|
|
|
2013-11-28 14:38:07 +01:00
|
|
|
/// The processor for translating images to led-values
|
|
|
|
ImageProcessor * _imageProcessor;
|
2013-12-08 12:46:33 +01:00
|
|
|
|
|
|
|
/// Buffer for colorData
|
2017-04-14 07:58:34 +02:00
|
|
|
QVector<ColorRgb> _colors;
|
2017-10-12 11:55:03 +02:00
|
|
|
|
|
|
|
Logger* _log;
|
|
|
|
|
2017-08-04 12:01:45 +02:00
|
|
|
QString _origin;
|
|
|
|
QSize _imageSize;
|
|
|
|
QImage _image;
|
|
|
|
QPainter* _painter;
|
2017-04-14 07:58:34 +02:00
|
|
|
QVector<QImage> _imageStack;
|
2013-11-24 16:10:48 +01:00
|
|
|
};
|