class mola::MolaViz

Overview

MOLA GUI and visualization API

#include <MolaViz.h>

class MolaViz:
    public mola::ExecutableBase,
    public mola::VizInterface
{
public:
    // typedefs

    typedef std::string window_name_t;
    typedef std::string subwindow_name_t;
    typedef std::function<void(const mrpt::rtti::CObject::Ptr&, nanogui::Window*subWin, window_name_t parentWin, MolaViz*instance)> update_handler_t;
    typedef std::string class_name_t;

    // structs

    struct DataPerDatasetUI;
    struct PerWindowData;

    // fields

    static const window_name_t DEFAULT_WINDOW_NAME = "main";
    double console_text_font_size_ = 9.0;
    unsigned int max_console_lines_ = 5;
    bool show_rgbd_as_point_cloud_ = false;

    // methods

    virtual std::future<nanogui::Window*> create_subwindow(
        const std::string& subWindowTitle,
        const std::string& parentWindow = DEFAULT_WINDOW_NAME
        );

    virtual std::future<bool> subwindow_update_visualization(
        const mrpt::rtti::CObject::Ptr& obj,
        const std::string& subWindowTitle,
        const std::string& parentWindow = DEFAULT_WINDOW_NAME
        );

    virtual std::future<bool> update_3d_object(
        const std::string& objName,
        const std::shared_ptr<mrpt::opengl::CSetOfObjects>& obj,
        const std::string& viewportName = "main",
        const std::string& parentWindow = DEFAULT_WINDOW_NAME
        );

    virtual std::future<bool> update_viewport_look_at(
        const mrpt::math::TPoint3Df& lookAt,
        const std::string& viewportName = "main",
        const std::string& parentWindow = DEFAULT_WINDOW_NAME
        );

    virtual std::future<bool> update_viewport_camera_azimuth(
        const double azimuth,
        bool absolute_falseForRelative = true,
        const std::string& viewportName = "main",
        const std::string& parentWindow = "main"
        );

    virtual std::future<bool> output_console_message(
        const std::string& msg,
        const std::string& parentWindow = "main"
        );

    virtual std::future<void> enqueue_custom_nanogui_code(const std::function<void(void)>& userCode);
    static bool IsRunning();
    static MolaViz* Instance();

    static void register_gui_handler(
        class_name_t name,
        update_handler_t handler
        );

    virtual void initialize(const Yaml& cfg);
    virtual void spinOnce();
    void markWindowForReLayout(const window_name_t& name);
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<VizInterface> Ptr;

    // methods

    virtual void initialize(const Yaml& cfg) = 0;

    virtual std::future<nanogui::Window*> create_subwindow(
        const std::string& title,
        const std::string& parentWindow = "main"
        ) = 0;

    virtual std::future<bool> subwindow_update_visualization(
        const mrpt::rtti::CObject::Ptr& obj,
        const std::string& subWindowTitle,
        const std::string& parentWindow = "main"
        ) = 0;

    virtual std::future<bool> update_3d_object(
        const std::string& objName,
        const std::shared_ptr<mrpt::opengl::CSetOfObjects>& obj,
        const std::string& viewportName = "main",
        const std::string& parentWindow = "main"
        ) = 0;

    virtual std::future<bool> update_viewport_look_at(
        const mrpt::math::TPoint3Df& lookAt,
        const std::string& viewportName = "main",
        const std::string& parentWindow = "main"
        ) = 0;

    virtual std::future<bool> update_viewport_camera_azimuth(
        const double azimuth,
        bool absolute_falseForRelative = true,
        const std::string& viewportName = "main",
        const std::string& parentWindow = "main"
        ) = 0;

    virtual std::future<void> enqueue_custom_nanogui_code(const std::function<void(void)>& userCode) = 0;

    virtual std::future<bool> output_console_message(
        const std::string& msg,
        const std::string& parentWindow = "main"
        ) = 0;

Methods

virtual std::future<nanogui::Window*> create_subwindow(
    const std::string& subWindowTitle,
    const std::string& parentWindow = DEFAULT_WINDOW_NAME
    )

Returned object is owned by the VizInterface, do NOT delete it. Updates to it must be done via enqueue_custom_nanogui_code()

virtual std::future<bool> subwindow_update_visualization(
    const mrpt::rtti::CObject::Ptr& obj,
    const std::string& subWindowTitle,
    const std::string& parentWindow = DEFAULT_WINDOW_NAME
    )

Updates the contents of a subwindow from a given object, typically a mrpt::obs::CObservation, but custom handlers can be installed for arbitrary classes.

Depending on the object class RTTI, the corresponding handler is called.

Returns:

false if no handler is found for the given object.

See also:

virtual std::future<bool> update_3d_object(
    const std::string& objName,
    const std::shared_ptr<mrpt::opengl::CSetOfObjects>& obj,
    const std::string& viewportName = "main",
    const std::string& parentWindow = DEFAULT_WINDOW_NAME
    )

Update (or adds if not found) a 3D object in the main 3D view area.

virtual std::future<void> enqueue_custom_nanogui_code(const std::function<void(void)>& userCode)

Updates to nanogui window controls must happen via this method to ensure it is run by the correct thread, in the next available time slot.

virtual void initialize(const Yaml& cfg)

This must be implemented to read all the required parameters

This should be reimplemented to read all the required parameters

virtual void spinOnce()

Runs any required action on a timely manner