-
Notifications
You must be signed in to change notification settings - Fork 1
color_display
Alexandre Marcireau edited this page Jun 1, 2018
·
11 revisions
In header "../third_party/chameleon/source/color_display.hpp".
chameleon::color_display
displays a stream of color events without tone-mapping.
namespace chameleon {
class color_display : public QQuickItem {
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QSize canvas_size READ canvas_size WRITE set_canvas_size)
Q_PROPERTY(QColor background_color READ background_color WRITE set_background_color)
Q_PROPERTY(QRectF paint_area READ paint_area)
public:
color_display();
/// set_canvas_size defines the display coordinates.
/// The canvas size will be passed to the openGL renderer, therefore it should only be set during qml
/// construction.
virtual void set_canvas_size(QSize canvas_size);
/// canvas_size returns the currently used canvas_size.
virtual QSize canvas_size() const;
/// set_background_color defines the background color used to compensate the parent's shape.
/// The background color will be passed to the openGL renderer, therefore it should only be set during qml
/// construction.
virtual void set_background_color(QColor background_color);
/// background_color returns the currently used background_color.
virtual QColor background_color() const;
/// paint_area returns the paint area in window coordinates.
virtual QRectF paint_area() const;
/// push adds an event to the display.
template <typename Event>
void push(Event event);
/// assign sets all the pixels at once.
template <typename Iterator>
void assign(Iterator begin, Iterator end);
/// componentComplete is called when all the qml values are bound.
virtual void componentComplete() override;
signals:
/// paint_area_changed notifies a paint area change.
void paint_area_changed(QRectF paint_area);
public slots:
/// sync adapts the renderer to external changes.
void sync();
/// cleanup frees the owned renderer.
void cleanup();
/// trigger_draw requests a window refresh.
void trigger_draw();
};
}
-
canvas_size
is the pixel array size. As an example, ifx
is in the range[0, 319]
andy
is in the range[0, 239]
,canvas_size
must beQSize(320, 240)
. -
background_color
is the color used to fill the component's strips used to compensate for the parent shape. -
Event
must have at least the propertiest
, ``x,
y` and `is_increase`. -
begin
andend
are the begin and past-the-end iterators to a range ofcanvas_size.width() * canvas_size.height()
objects with at least the propertiesr
,g
andb
. The object associated with the pixel at coordinates[x, y]
must be at the indexx + y * canvas_size.width()
in the range. -
paint_area
is the rectangle in which the events will actually be drawn.paint_area
has the same shape (ratio of width over height) ascanvas_size
.
chameleon::color_display
is associated with a chameleon::color_display_renderer
to handle OpenGL calls.
namespace chameleon {
class dvs_display_renderer : public QObject, public QOpenGLFunctions_3_3_Core {
Q_OBJECT
public:
color_display_renderer(QSize canvas_size, QColor background_color);
/// set_rendering_area defines the rendering area.
virtual void set_rendering_area(QRectF clear_area, QRectF paint_area, int window_height);
/// push adds an event to the display.
template <typename Event>
void push(Event event);
/// assign sets all the pixels at once.
template <typename Iterator>
void assign(Iterator begin, Iterator end);
public slots:
/// paint sends commands to the GPU.
void paint();
};
}
-
clear_area
is the rectangle in which the display must be drawn, in screen coordinates. -
paint_area
is the rectangle inside clear_area in which the events will actually be drawn.paint_area
has the same shape (ratio of width over height) ascanvas_size
. -
window_height
is the total window height (used to convert from Qt coordinates to OpenGL coordinates).
A typical QML instantiation has the following syntax:
DvsDisplay {
canvas_size: "320x240" // required
decay: 1e5 // optional, defaults to 1e5
increase_color: "#ffffff" // optional, defaults to "#ffffff"
idle_color: "#808080" // optional, defaults to "#808080"
decrease_color: "#000000" // optional, defaults to "#000000"
background_color: "#000000" // optional, defaults to "#000000"
}