Skip to content

grey_display

Alexandre Marcireau edited this page Apr 16, 2019 · 5 revisions

In header "../third_party/chameleon/source/grey_display.hpp"

chameleon::grey_display displays a stream of grey events without tone-mapping.

namespace chameleon {
    class grey_display : public QQuickItem {
        Q_OBJECT
        Q_INTERFACES(QQmlParserStatus)
        Q_PROPERTY(QSize canvas_size READ canvas_size WRITE set_canvas_size)
        Q_PROPERTY(QRectF paint_area READ paint_area)
        public:
        grey_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;

        /// 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:

        /// paintAreaChanged notifies a paint area change.
        void paintAreaChanged(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, if x is in the range [0, 319] and y is in the range [0, 239], canvas_size must be QSize(320, 240).
  • Event must have at least the properties x, y, and exposure. exposure must be in the range [0, 1].
  • begin and end are the begin and past-the-end iterators to a range of canvas_size.width() * canvas_size.height() objects with at least the property exposure. The object associated with the pixel at coordinates [x, y] must be at the index x + 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) as canvas_size.

chameleon::grey_display is associated with a chameleon::grey_display_renderer to handle OpenGL calls.

namespace chameleon {
    class dvs_display_renderer : public QObject, public QOpenGLFunctions_3_3_Core {
        Q_OBJECT
        public:
        grey_display_renderer(QSize canvas_size);

        /// 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.
  • window_height is the total window height (used to convert from Qt coordinates to OpenGL coordinates).

A typical QML instantiation has the following syntax:

GreyDisplay {
    canvas_size: "320x240" // required
}
Clone this wiki locally