class mrpt::gui::CDisplayWindow

Overview

This class creates a window as a graphical user interface (GUI) for displaying images to the user.

For a list of supported events with the observer/observable pattern, see the discussion in mrpt::gui::CBaseGUIWindow.

mrpt::gui::CDisplayWindow screenshot
#include <mrpt/gui/CDisplayWindow.h>

class CDisplayWindow: public mrpt::gui::CBaseGUIWindow
{
public:
    // typedefs

    typedef std::shared_ptr<CDisplayWindow> Ptr;
    typedef std::shared_ptr<const CDisplayWindow> ConstPtr;

    // construction

    CDisplayWindow(
        const std::string& windowCaption = std::string(),
        unsigned int initWidth = 400,
        unsigned int initHeight = 400
        );

    // methods

    virtual std::optional<mrpt::img::TPixelCoord> getLastMousePosition() const;
    virtual void setCursorCross(bool cursorIsCross);
    void showImage(const mrpt::img::CImage& img);
    void plot(const mrpt::math::CVectorFloat& x, const mrpt::math::CVectorFloat& y);
    void plot(const mrpt::math::CVectorFloat& y);
    virtual void resize(unsigned int width, unsigned int height);
    virtual void setPos(int x, int y);
    void enableCursorCoordinatesVisualization(bool enable);
    virtual void setWindowTitle(const std::string& str);

    static CDisplayWindow::Ptr Create(
        const std::string& windowCaption,
        unsigned int initWidth = 400,
        unsigned int initHeight = 400
        );
};

Inherited Members

public:
    // methods

    void* getWxObject();
    void notifyChildWindowDestruction();
    void notifySemThreadReady();
    CBaseGUIWindow& operator = (const CBaseGUIWindow&);
    CBaseGUIWindow& operator = (CBaseGUIWindow&&);
    bool isOpen();
    virtual void resize(unsigned int width, unsigned int height) = 0;
    virtual void setPos(int x, int y) = 0;
    virtual void setWindowTitle(const std::string& str) = 0;
    virtual std::optional<mrpt::img::TPixelCoord> getLastMousePosition() const = 0;
    virtual void setCursorCross(bool cursorIsCross) = 0;
    int waitForKey(bool ignoreControlKeys = true, mrptKeyModifier* out_pushModifier = nullptr);
    bool keyHit() const;
    void clearKeyHitFlag();
    int getPushedKey(mrptKeyModifier* out_pushModifier = nullptr);

Construction

CDisplayWindow(
    const std::string& windowCaption = std::string(),
    unsigned int initWidth = 400,
    unsigned int initHeight = 400
    )

Constructor.

Methods

virtual std::optional<mrpt::img::TPixelCoord> getLastMousePosition() const

Gets the last x,y pixel coordinates of the mouse.

Returns:

nullopt if the window is closed.

virtual void setCursorCross(bool cursorIsCross)

Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true)

void showImage(const mrpt::img::CImage& img)

Show a given color or grayscale image on the window.

It adapts the size of the window to that of the image.

void plot(const mrpt::math::CVectorFloat& x, const mrpt::math::CVectorFloat& y)

Plots a graph in MATLAB-like style.

void plot(const mrpt::math::CVectorFloat& y)

Plots a graph in MATLAB-like style.

virtual void resize(unsigned int width, unsigned int height)

Resizes the window, stretching the image to fit into the display area.

virtual void setPos(int x, int y)

Changes the position of the window on the screen.

void enableCursorCoordinatesVisualization(bool enable)

Enables or disables the visualization of cursor coordinates on the window caption (default = enabled).

virtual void setWindowTitle(const std::string& str)

Changes the window title text.

static CDisplayWindow::Ptr Create(
    const std::string& windowCaption,
    unsigned int initWidth = 400,
    unsigned int initHeight = 400
    )

Class factory returning a smart pointer, equivalent to std::make_shared<>(...)