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, const window_name_t&parentWin, MolaViz*instance, const mrpt::containers::yaml*extra_parameters)> update_handler_t; typedef std::string class_name_t; // structs struct DataPerDatasetUI; struct DecayingCloud; 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; // construction MolaViz(); MolaViz(const MolaViz&); MolaViz(MolaViz&&); // methods virtual std::future<nanogui::Window*> create_subwindow( const std::string& subWindowTitle, const std::string& parentWindow = DEFAULT_WINDOW_NAME ); virtual std::future<void> subwindow_grid_layout( const std::string& subWindowTitle, const bool orientationVertical, int resolution, const std::string& parentWindow = DEFAULT_WINDOW_NAME ); virtual std::future<void> subwindow_move_resize( const std::string& subWindowTitle, const mrpt::math::TPoint2D_<int>& location, const mrpt::math::TPoint2D_<int>& size, 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 mrpt::containers::yaml* extra_parameters = nullptr, 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> insert_point_cloud_with_decay( const std::shared_ptr<mrpt::opengl::CPointCloudColoured>& cloud, const double decay_time_seconds, const std::string& viewportName = "main", const std::string& parentWindow = "main" ); virtual std::future<bool> clear_all_point_clouds_with_decay( const std::string& viewportName = "main", const std::string& parentWindow = "main" ); 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> update_viewport_camera_orthographic( const bool orthographic, const std::string& viewportName = "main", const std::string& parentWindow = "main" ); virtual std::future<bool> execute_custom_code_on_background_scene( const std::function<void(mrpt::opengl::Scene&)>& userCode, 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( const class_name_t& name, const update_handler_t& handler ); MolaViz& operator = (const MolaViz&); MolaViz& operator = (MolaViz&&); 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; // structs struct DiagnosticsOutput; // methods virtual void initialize(const Yaml& cfg) = 0; virtual void spinOnce() = 0; ExecutableBase& operator = (const ExecutableBase&); ExecutableBase& operator = (ExecutableBase&&); virtual std::future<nanogui::Window*> create_subwindow( const std::string& title, const std::string& parentWindow = "main" ) = 0; virtual std::future<void> subwindow_grid_layout( const std::string& subWindowTitle, const bool orientationVertical, int resolution, const std::string& parentWindow = "main" ) = 0; virtual std::future<void> subwindow_move_resize( const std::string& subWindowTitle, const mrpt::math::TPoint2D_<int>& location, const mrpt::math::TPoint2D_<int>& size, const std::string& parentWindow = "main" ) = 0; virtual std::future<bool> subwindow_update_visualization( const mrpt::rtti::CObject::Ptr& obj, const std::string& subWindowTitle, const mrpt::containers::yaml* extra_parameters = nullptr, 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> insert_point_cloud_with_decay( const std::shared_ptr<mrpt::opengl::CPointCloudColoured>& cloud, const double decay_time_seconds, const std::string& viewportName = "main", const std::string& parentWindow = "main" ) = 0; virtual std::future<bool> clear_all_point_clouds_with_decay( 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<bool> update_viewport_camera_orthographic( const bool orthographic, const std::string& viewportName = "main", const std::string& parentWindow = "main" ) = 0; virtual std::future<bool> execute_custom_code_on_background_scene( const std::function<void(mrpt::opengl::Scene&)>& userCode, 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 mrpt::containers::yaml* extra_parameters = nullptr, 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 )
Updates or inserts a 3D object in the background scene of a specified window.
This method schedules a task to update (or insert if not present) a named 3D object (objName) in the background scene of the given parent window (parentWindow), optionally within a specific viewport (viewportName). The object is provided as a shared pointer to a mrpt::opengl::CSetOfObjects.
The update is performed in the GUI thread. If the object already exists, its contents and properties are updated by copying the shared pointers contained into obj.
Parameters:
objName |
The name of the 3D object to update or insert. |
obj |
Shared pointer to the 3D object ( |
viewportName |
The name of the viewport where the object should be placed. |
parentWindow |
The name of the parent window containing the background scene. |
Returns:
A future<bool>, will return true when the task is run in its thread.
virtual std::future<bool> insert_point_cloud_with_decay( const std::shared_ptr<mrpt::opengl::CPointCloudColoured>& cloud, const double decay_time_seconds, const std::string& viewportName = "main", const std::string& parentWindow = "main" )
Inserts a temporary point cloud, which will be visible only during decay_time_seconds
Parameters:
obj |
Shared pointer to the cloud ( |
decay_time_seconds |
Seconds that the cloud will be visible before disappearing. |
viewportName |
The name of the viewport where the object should be placed. |
parentWindow |
The name of the parent window containing the background scene. |
Returns:
A future<bool>, will return true when the task is run in its thread.
virtual std::future<bool> clear_all_point_clouds_with_decay( const std::string& viewportName = "main", const std::string& parentWindow = "main" )
Removes from the visualization all clouds inserted with insert_point_cloud_with_decay()
Parameters:
viewportName |
The name of the viewport where the object should be placed. |
parentWindow |
The name of the parent window containing the background scene. |
Returns:
A future<bool>, will return true when the task is run in its thread.
virtual std::future<bool> execute_custom_code_on_background_scene( const std::function<void(mrpt::opengl::Scene&)>& userCode, const std::string& parentWindow = "main" )
Executes arbitrary user code on the 3D Scene in the background of the main window space.
This can be used to modify the viewport, create new sub-viewports, etc. The user-provided code will be executed in the main GUI thread, so mutexes must be used as needed.
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