MRPT  2.0.2
List of all members | Protected Member Functions | Protected Attributes
mrpt::gui::CDisplayWindowGUI Class Reference

Detailed Description

A window with powerful GUI capabilities, via the nanogui library.

You can add a background mrpt::opengl::COpenGLScene object rendered on the background of the entire window by setting an object in field background_scene, locking its mutex background_scene_mtx.

Refer to nanogui API docs or MRPT examples for further usage examples. A typical lifecycle of a GUI app with this class might look like:

.. code-block:: cpp

nanogui::init(); { mrpt::gui::CDisplayWindowGUI win; win.drawAll(); win.setVisible(true); nanogui::mainloop(); } nanogui::shutdown();

preview_CDisplayWindowGUI.png
mrpt::gui::CDisplayWindowGUI screenshot

Definition at line 71 of file CDisplayWindowGUI.h.

#include <mrpt/gui/CDisplayWindowGUI.h>

Inheritance diagram for mrpt::gui::CDisplayWindowGUI:

Public Member Functions

Direct access to underlying nanogui API
nanogui::Window * nanogui_win ()
 

Protected Member Functions

 CDisplayWindowGUI (const CDisplayWindowGUI &)=delete
 
CDisplayWindowGUIoperator= (const CDisplayWindowGUI &)=delete
 
 CDisplayWindowGUI (CDisplayWindowGUI &&)=delete
 
CDisplayWindowGUIoperator= (CDisplayWindowGUI &&)=delete
 
virtual bool keyboardEvent (int key, int scancode, int action, int modifiers) override
 
virtual void drawContents () override
 
Internal virtual functions to handle GUI events
virtual bool mouseMotionEvent (const nanogui::Vector2i &p, const nanogui::Vector2i &rel, int button, int modifiers) override
 
virtual bool mouseButtonEvent (const nanogui::Vector2i &p, int button, bool down, int modifiers) override
 
virtual bool scrollEvent (const nanogui::Vector2i &p, const nanogui::Vector2f &rel) override
 
virtual bool dropEvent (const std::vector< std::string > &filenames) override
 

Protected Attributes

nanogui::Window * m_window = nullptr
 the pointer is owned by the parent class Screen, no need to delete it More...
 
internal::NanoGUICanvasHeadless m_background_canvas
 Used to keep track of mouse events on the camera. More...
 
std::function< void(void)> m_loopCallback
 
std::function< bool(const std::vector< std::string > &)> m_dropFilesCallback
 
std::function< bool(int, int, int, int)> m_keyboardCallback
 

Ctor and basic window set up

using Ptr = std::shared_ptr< CDisplayWindowGUI >
 
using ConstPtr = std::shared_ptr< const CDisplayWindowGUI >
 
 CDisplayWindowGUI (const std::string &caption=std::string(), unsigned int width=400, unsigned int height=300, const CDisplayWindowGUI_Params &p=CDisplayWindowGUI_Params())
 
virtual ~CDisplayWindowGUI () override
 
void resize (unsigned int width, unsigned int height)
 Resizes the window. More...
 
void setPos (int x, int y)
 Changes the position of the window on the screen. More...
 
void setWindowTitle (const std::string &str)
 Changes the window title. More...
 
void setLoopCallback (const std::function< void(void)> &callback)
 Every time the window is about to be repainted, an optional callback can be called, if provided via this method. More...
 
const auto & loopCallback () const
 
void setDropFilesCallback (const std::function< bool(const std::vector< std::string > &)> &callback)
 Sets a handle for file drop events. More...
 
const auto & dropFilesCallback () const
 
void setKeyboardCallback (const std::function< bool(int, int, int, int)> &callback)
 
const auto & keyboardCallback () const
 
template<typename... Args>
static Ptr Create (Args &&... args)
 Class factory returning a smart pointer. More...
 

Access to full-window (background) GL scene

mrpt::opengl::COpenGLScene::Ptr background_scene
 
std::mutex background_scene_mtx
 
CGlCanvasBasecamera ()
 
const CGlCanvasBasecamera () const
 

Member Typedef Documentation

◆ ConstPtr

Definition at line 77 of file CDisplayWindowGUI.h.

◆ Ptr

Definition at line 76 of file CDisplayWindowGUI.h.

Constructor & Destructor Documentation

◆ CDisplayWindowGUI() [1/3]

CDisplayWindowGUI::CDisplayWindowGUI ( const std::string &  caption = std::string(),
unsigned int  width = 400,
unsigned int  height = 300,
const CDisplayWindowGUI_Params p = CDisplayWindowGUI_Params() 
)

Definition at line 20 of file CDisplayWindowGUI.cpp.

References mrpt::gui::default_mrpt_glfw_icon(), and images.

Here is the call graph for this function:

◆ ~CDisplayWindowGUI()

CDisplayWindowGUI::~CDisplayWindowGUI ( )
overridevirtual

Definition at line 41 of file CDisplayWindowGUI.cpp.

◆ CDisplayWindowGUI() [2/3]

mrpt::gui::CDisplayWindowGUI::CDisplayWindowGUI ( const CDisplayWindowGUI )
protecteddelete

◆ CDisplayWindowGUI() [3/3]

mrpt::gui::CDisplayWindowGUI::CDisplayWindowGUI ( CDisplayWindowGUI &&  )
protecteddelete

Member Function Documentation

◆ camera() [1/2]

CGlCanvasBase& mrpt::gui::CDisplayWindowGUI::camera ( )
inline

Definition at line 135 of file CDisplayWindowGUI.h.

References m_background_canvas.

◆ camera() [2/2]

const CGlCanvasBase& mrpt::gui::CDisplayWindowGUI::camera ( ) const
inline

Definition at line 136 of file CDisplayWindowGUI.h.

References m_background_canvas.

◆ Create()

template<typename... Args>
static Ptr mrpt::gui::CDisplayWindowGUI::Create ( Args &&...  args)
inlinestatic

Class factory returning a smart pointer.

Definition at line 88 of file CDisplayWindowGUI.h.

◆ drawContents()

void CDisplayWindowGUI::drawContents ( )
overrideprotectedvirtual

Definition at line 47 of file CDisplayWindowGUI.cpp.

References background_scene, background_scene_mtx, mrpt::exception_to_str(), m_background_canvas, m_loopCallback, mrpt::opengl::CCamera::render(), THROW_EXCEPTION, and mrpt::gui::CGlCanvasBase::updateCameraParams().

Here is the call graph for this function:

◆ dropEvent()

bool CDisplayWindowGUI::dropEvent ( const std::vector< std::string > &  filenames)
overrideprotectedvirtual

Definition at line 121 of file CDisplayWindowGUI.cpp.

References m_dropFilesCallback.

◆ dropFilesCallback()

const auto& mrpt::gui::CDisplayWindowGUI::dropFilesCallback ( ) const
inline

Definition at line 117 of file CDisplayWindowGUI.h.

References m_dropFilesCallback.

◆ keyboardCallback()

const auto& mrpt::gui::CDisplayWindowGUI::keyboardCallback ( ) const
inline

Definition at line 125 of file CDisplayWindowGUI.h.

References m_keyboardCallback.

◆ keyboardEvent()

bool CDisplayWindowGUI::keyboardEvent ( int  key,
int  scancode,
int  action,
int  modifiers 
)
overrideprotectedvirtual

Definition at line 129 of file CDisplayWindowGUI.cpp.

References m_keyboardCallback.

◆ loopCallback()

const auto& mrpt::gui::CDisplayWindowGUI::loopCallback ( ) const
inline

Definition at line 108 of file CDisplayWindowGUI.h.

References m_loopCallback.

◆ mouseButtonEvent()

bool CDisplayWindowGUI::mouseButtonEvent ( const nanogui::Vector2i &  p,
int  button,
bool  down,
int  modifiers 
)
overrideprotectedvirtual

Definition at line 94 of file CDisplayWindowGUI.cpp.

References m_background_canvas, and mrpt::gui::internal::NanoGUICanvasHeadless::mouseButtonEvent().

Here is the call graph for this function:

◆ mouseMotionEvent()

bool CDisplayWindowGUI::mouseMotionEvent ( const nanogui::Vector2i &  p,
const nanogui::Vector2i &  rel,
int  button,
int  modifiers 
)
overrideprotectedvirtual

Definition at line 103 of file CDisplayWindowGUI.cpp.

References m_background_canvas, and mrpt::gui::internal::NanoGUICanvasHeadless::mouseMotionEvent().

Here is the call graph for this function:

◆ nanogui_win()

nanogui::Window* mrpt::gui::CDisplayWindowGUI::nanogui_win ( )
inline

Definition at line 143 of file CDisplayWindowGUI.h.

References ASSERT_, and m_window.

◆ operator=() [1/2]

CDisplayWindowGUI& mrpt::gui::CDisplayWindowGUI::operator= ( const CDisplayWindowGUI )
protecteddelete

◆ operator=() [2/2]

CDisplayWindowGUI& mrpt::gui::CDisplayWindowGUI::operator= ( CDisplayWindowGUI &&  )
protecteddelete

◆ resize()

void CDisplayWindowGUI::resize ( unsigned int  width,
unsigned int  height 
)

Resizes the window.

Definition at line 82 of file CDisplayWindowGUI.cpp.

◆ scrollEvent()

bool CDisplayWindowGUI::scrollEvent ( const nanogui::Vector2i &  p,
const nanogui::Vector2f &  rel 
)
overrideprotectedvirtual

Definition at line 113 of file CDisplayWindowGUI.cpp.

References m_background_canvas, and mrpt::gui::internal::NanoGUICanvasHeadless::scrollEvent().

Here is the call graph for this function:

◆ setDropFilesCallback()

void mrpt::gui::CDisplayWindowGUI::setDropFilesCallback ( const std::function< bool(const std::vector< std::string > &)> &  callback)
inline

Sets a handle for file drop events.

Definition at line 111 of file CDisplayWindowGUI.h.

References m_dropFilesCallback.

◆ setKeyboardCallback()

void mrpt::gui::CDisplayWindowGUI::setKeyboardCallback ( const std::function< bool(int, int, int, int)> &  callback)
inline

Definition at line 119 of file CDisplayWindowGUI.h.

References m_keyboardCallback.

◆ setLoopCallback()

void mrpt::gui::CDisplayWindowGUI::setLoopCallback ( const std::function< void(void)> &  callback)
inline

Every time the window is about to be repainted, an optional callback can be called, if provided via this method.

Definition at line 104 of file CDisplayWindowGUI.h.

References m_loopCallback.

◆ setPos()

void CDisplayWindowGUI::setPos ( int  x,
int  y 
)

Changes the position of the window on the screen.

Definition at line 87 of file CDisplayWindowGUI.cpp.

◆ setWindowTitle()

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

Changes the window title.

Definition at line 89 of file CDisplayWindowGUI.cpp.

Member Data Documentation

◆ background_scene

mrpt::opengl::COpenGLScene::Ptr mrpt::gui::CDisplayWindowGUI::background_scene

Definition at line 132 of file CDisplayWindowGUI.h.

Referenced by drawContents().

◆ background_scene_mtx

std::mutex mrpt::gui::CDisplayWindowGUI::background_scene_mtx

Definition at line 133 of file CDisplayWindowGUI.h.

Referenced by drawContents().

◆ m_background_canvas

internal::NanoGUICanvasHeadless mrpt::gui::CDisplayWindowGUI::m_background_canvas
protected

Used to keep track of mouse events on the camera.

Definition at line 180 of file CDisplayWindowGUI.h.

Referenced by camera(), drawContents(), mouseButtonEvent(), mouseMotionEvent(), and scrollEvent().

◆ m_dropFilesCallback

std::function<bool(const std::vector<std::string>& )> mrpt::gui::CDisplayWindowGUI::m_dropFilesCallback
protected

Definition at line 185 of file CDisplayWindowGUI.h.

Referenced by dropEvent(), dropFilesCallback(), and setDropFilesCallback().

◆ m_keyboardCallback

std::function<bool( int , int , int , int )> mrpt::gui::CDisplayWindowGUI::m_keyboardCallback
protected

Definition at line 189 of file CDisplayWindowGUI.h.

Referenced by keyboardCallback(), keyboardEvent(), and setKeyboardCallback().

◆ m_loopCallback

std::function<void(void)> mrpt::gui::CDisplayWindowGUI::m_loopCallback
protected

Definition at line 182 of file CDisplayWindowGUI.h.

Referenced by drawContents(), loopCallback(), and setLoopCallback().

◆ m_window

nanogui::Window* mrpt::gui::CDisplayWindowGUI::m_window = nullptr
protected

the pointer is owned by the parent class Screen, no need to delete it

Definition at line 160 of file CDisplayWindowGUI.h.

Referenced by nanogui_win().




Page generated by Doxygen 1.8.14 for MRPT 2.0.2 Git: 9b4fd2465 Mon May 4 16:59:08 2020 +0200 at lun may 4 17:26:07 CEST 2020