MRPT  2.0.4
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends
mrpt::gui::CBaseGUIWindow Class Referenceabstract

Detailed Description

The base class for GUI window classes based on wxWidgets.

This class can be observed (see mrpt::system::CObserver) for the following events (see mrpt::system::mrptEvent):

See derived classes to check if they emit other additional events.

IMPORTANTE NOTICE: Event handlers in your observer class will be invoked from the wxWidgets internal MRPT thread, so all your code in the handler must be thread safe.

Definition at line 40 of file CBaseGUIWindow.h.

#include <mrpt/gui/CBaseGUIWindow.h>

Inheritance diagram for mrpt::gui::CBaseGUIWindow:

Public Member Functions

void * getWxObject ()
 Read-only access to the wxDialog object. More...
 
void notifyChildWindowDestruction ()
 Called by wx main thread to set m_hwnd to NULL. More...
 
void notifySemThreadReady ()
 Called by wx main thread to signal the semaphore that the wx window is built and ready. More...
 
 CBaseGUIWindow (void *winobj_voidptr, int CMD_CREATE_WIN, int CMD_DESTROY_WIN, const std::string &initial_caption=std::string())
 CMD_DESTROY_WIN can be 299,399,499... More...
 
 ~CBaseGUIWindow () override
 
bool isOpen ()
 Returns false if the user has already closed the window. More...
 
virtual void resize (unsigned int width, unsigned int height)=0
 Resizes the window, stretching the image to fit into the display area. More...
 
virtual void setPos (int x, int y)=0
 Changes the position of the window on the screen. More...
 
virtual void setWindowTitle (const std::string &str)=0
 Changes the window title text. More...
 
virtual bool getLastMousePosition (int &x, int &y) const =0
 Gets the last x,y pixel coordinates of the mouse. More...
 
virtual void setCursorCross (bool cursorIsCross)=0
 Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true) More...
 
int waitForKey (bool ignoreControlKeys=true, mrptKeyModifier *out_pushModifier=nullptr)
 Waits for any key to be pushed on the image or the console, and returns the key code. More...
 
bool keyHit () const
 Returns true if a key has been pushed, without blocking waiting for a new key being pushed. More...
 
void clearKeyHitFlag ()
 Assure that "keyHit" will return false until the next pushed key. More...
 
int getPushedKey (mrptKeyModifier *out_pushModifier=nullptr)
 Returns the latest pushed key, or 0 if there is no new key stroke. More...
 

Protected Member Functions

void createWxWindow (unsigned int initialWidth, unsigned int initialHeight)
 Must be called by child classes just within the constructor. More...
 
void destroyWxWindow ()
 Must be called by child classes in their destructors. More...
 
void publishEvent (const mrptEvent &e) const
 Called when you want this object to emit an event to all the observers currently subscribed to this object. More...
 
bool hasSubscribers () const
 Can be called by a derived class before preparing an event for publishing with publishEvent to determine if there is no one subscribed, so it can save the wasted time preparing an event that will be not read. More...
 

Protected Attributes

std::promise< void > m_threadReady
 This semaphore will be signaled when the wx window is built and ready. More...
 
std::promise< void > m_windowDestroyed
 This semaphore will be signaled when the wx window is destroyed. More...
 
std::string m_caption
 The caption of the window. More...
 
mrpt::void_ptr_noncopy m_hwnd
 The window handle. More...
 
std::atomic_bool m_keyPushed = false
 
std::atomic_int m_keyPushedCode = 0
 
std::atomic< mrptKeyModifierm_keyPushedModifier
 

Private Attributes

const int m_CMD_CREATE_WIN
 can be 200,300,400... More...
 
const int m_CMD_DESTROY_WIN
 can be 299,399,499... More...
 
void * m_winobj_voidptr
 

Friends

class CWindowDialog
 
class C3DWindowDialog
 
class CWindowDialogPlots
 

Constructor & Destructor Documentation

◆ CBaseGUIWindow()

CBaseGUIWindow::CBaseGUIWindow ( void *  winobj_voidptr,
int  CMD_CREATE_WIN,
int  CMD_DESTROY_WIN,
const std::string &  initial_caption = std::string() 
)

CMD_DESTROY_WIN can be 299,399,499...

See WxSubsystem

Definition at line 25 of file CBaseGUIWindow.cpp.

◆ ~CBaseGUIWindow()

CBaseGUIWindow::~CBaseGUIWindow ( )
overridedefault

Member Function Documentation

◆ clearKeyHitFlag()

void mrpt::gui::CBaseGUIWindow::clearKeyHitFlag ( )
inline

Assure that "keyHit" will return false until the next pushed key.

See also
keyHit, waitForKey

Definition at line 143 of file CBaseGUIWindow.h.

References m_keyPushed.

◆ createWxWindow()

void CBaseGUIWindow::createWxWindow ( unsigned int  initialWidth,
unsigned int  initialHeight 
)
protected

Must be called by child classes just within the constructor.

Definition at line 42 of file CBaseGUIWindow.cpp.

References mrpt::gui::WxSubsystem::createOneInstanceMainThread(), mrpt::non_copiable_ptr_basic< T >::getPtrToPtr(), mrpt::gui::WxSubsystem::isConsoleApp(), m_caption, m_CMD_CREATE_WIN, m_hwnd, m_threadReady, m_winobj_voidptr, MRPT_END, MRPT_START, mrpt::gui::WxSubsystem::pushPendingWxRequest(), mrpt::gui::WxSubsystem::TRequestToWxMainThread::source2D, and THROW_EXCEPTION.

Referenced by mrpt::gui::CDisplayWindow::CDisplayWindow(), mrpt::gui::CDisplayWindow3D::CDisplayWindow3D(), and mrpt::gui::CDisplayWindowPlots::CDisplayWindowPlots().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroyWxWindow()

void CBaseGUIWindow::destroyWxWindow ( )
protected

Must be called by child classes in their destructors.

The code cannot be put into this class' destructor.

Definition at line 103 of file CBaseGUIWindow.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), mrpt::gui::WxSubsystem::isConsoleApp(), m_CMD_DESTROY_WIN, m_hwnd, m_windowDestroyed, m_winobj_voidptr, MRPT_END, MRPT_START, mrpt::gui::WxSubsystem::TRequestToWxMainThread::OPCODE, mrpt::gui::WxSubsystem::pushPendingWxRequest(), and mrpt::gui::WxSubsystem::waitWxShutdownsIfNoWindows().

Referenced by mrpt::gui::CDisplayWindow::~CDisplayWindow(), mrpt::gui::CDisplayWindow3D::~CDisplayWindow3D(), and mrpt::gui::CDisplayWindowPlots::~CDisplayWindowPlots().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLastMousePosition()

virtual bool mrpt::gui::CBaseGUIWindow::getLastMousePosition ( int &  x,
int &  y 
) const
pure virtual

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

Returns
False if the window is closed.

Implemented in mrpt::gui::CDisplayWindow3D, mrpt::gui::CDisplayWindowPlots, and mrpt::gui::CDisplayWindow.

◆ getPushedKey()

int CBaseGUIWindow::getPushedKey ( mrptKeyModifier out_pushModifier = nullptr)

Returns the latest pushed key, or 0 if there is no new key stroke.

Parameters
out_pushModifierIf set to !=nullptr, the modifiers of the key stroke will be saved here.
Returns
The virtual key code, as defined in <mrpt/gui/keycodes.h> (a replication of wxWidgets key codes).
See also
keyHit, waitForKey

Definition at line 186 of file CBaseGUIWindow.cpp.

References m_keyPushed, m_keyPushedCode, m_keyPushedModifier, and mrpt::gui::MRPTKMOD_NONE.

◆ getWxObject()

void* mrpt::gui::CBaseGUIWindow::getWxObject ( )
inline

Read-only access to the wxDialog object.

Definition at line 77 of file CBaseGUIWindow.h.

References mrpt::non_copiable_ptr_basic< T >::get(), and m_hwnd.

Referenced by mrpt::gui::WxSubsystem::CWXMainFrame::OnTimerProcessRequests().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasSubscribers()

bool mrpt::system::CObservable::hasSubscribers ( ) const
inlineprotectedinherited

Can be called by a derived class before preparing an event for publishing with publishEvent to determine if there is no one subscribed, so it can save the wasted time preparing an event that will be not read.

Definition at line 53 of file CObservable.h.

References mrpt::system::CObservable::m_subscribers.

Referenced by mrpt::gui::CWindowDialog::OnMouseDown(), mrpt::gui::CWindowDialog::OnMouseMove(), mrpt::gui::CWindowDialog::OnResize(), mrpt::opengl::COpenGLViewport::render(), and mrpt::opengl::COpenGLViewport::renderNormalSceneMode().

Here is the caller graph for this function:

◆ isOpen()

bool CBaseGUIWindow::isOpen ( )

◆ keyHit()

bool mrpt::gui::CBaseGUIWindow::keyHit ( ) const
inline

Returns true if a key has been pushed, without blocking waiting for a new key being pushed.

See also
waitForKey, clearKeyHitFlag

Definition at line 139 of file CBaseGUIWindow.h.

References m_keyPushed.

◆ notifyChildWindowDestruction()

void CBaseGUIWindow::notifyChildWindowDestruction ( )

Called by wx main thread to set m_hwnd to NULL.

Definition at line 148 of file CBaseGUIWindow.cpp.

References m_hwnd.

Referenced by mrpt::gui::CWindowDialog::OnClose(), and mrpt::gui::C3DWindowDialog::OnClose().

Here is the caller graph for this function:

◆ notifySemThreadReady()

void CBaseGUIWindow::notifySemThreadReady ( )

Called by wx main thread to signal the semaphore that the wx window is built and ready.

Definition at line 205 of file CBaseGUIWindow.cpp.

References m_threadReady.

Referenced by mrpt::gui::WxSubsystem::CWXMainFrame::OnTimerProcessRequests().

Here is the caller graph for this function:

◆ publishEvent()

void CObservable::publishEvent ( const mrptEvent e) const
protectedinherited

Called when you want this object to emit an event to all the observers currently subscribed to this object.

Definition at line 57 of file CObservable.cpp.

References MRPT_END, and MRPT_START.

Referenced by mrpt::gui::CDisplayWindow3D::internal_emitGrabImageEvent(), mrpt::gui::CWindowDialog::OnChar(), mrpt::gui::CWindowDialog::OnClose(), mrpt::gui::C3DWindowDialog::OnClose(), mrpt::gui::CWindowDialog::OnMouseDown(), mrpt::gui::CWindowDialog::OnMouseMove(), mrpt::gui::CWindowDialog::OnResize(), mrpt::gui::C3DWindowDialog::OnResize(), mrpt::opengl::COpenGLViewport::render(), and mrpt::opengl::COpenGLViewport::renderNormalSceneMode().

Here is the caller graph for this function:

◆ resize()

virtual void mrpt::gui::CBaseGUIWindow::resize ( unsigned int  width,
unsigned int  height 
)
pure virtual

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

Implemented in mrpt::gui::CDisplayWindow, mrpt::gui::CDisplayWindow3D, and mrpt::gui::CDisplayWindowPlots.

◆ setCursorCross()

virtual void mrpt::gui::CBaseGUIWindow::setCursorCross ( bool  cursorIsCross)
pure virtual

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

Implemented in mrpt::gui::CDisplayWindow3D, mrpt::gui::CDisplayWindowPlots, and mrpt::gui::CDisplayWindow.

◆ setPos()

virtual void mrpt::gui::CBaseGUIWindow::setPos ( int  x,
int  y 
)
pure virtual

Changes the position of the window on the screen.

Implemented in mrpt::gui::CDisplayWindow, mrpt::gui::CDisplayWindow3D, and mrpt::gui::CDisplayWindowPlots.

◆ setWindowTitle()

virtual void mrpt::gui::CBaseGUIWindow::setWindowTitle ( const std::string &  str)
pure virtual

Changes the window title text.

Implemented in mrpt::gui::CDisplayWindow, mrpt::gui::CDisplayWindow3D, and mrpt::gui::CDisplayWindowPlots.

◆ waitForKey()

int CBaseGUIWindow::waitForKey ( bool  ignoreControlKeys = true,
mrptKeyModifier out_pushModifier = nullptr 
)

Waits for any key to be pushed on the image or the console, and returns the key code.

This method remove key strokes previous to its call, so it will always wait. To get the latest pushed key, see

Parameters
ignoreControlKeysIf set to false, any push of shift, cmd, control, etc... will make this method to return.
out_pushModifierIf set to !=nullptr, the modifiers of the key stroke will be saved here.
Returns
The virtual key code, as defined in mrptKeyCode (a replication of wxWidgets key codes).
See also
getPushedKey, Key codes in the enum mrptKeyCode

Definition at line 152 of file CBaseGUIWindow.cpp.

References mrpt::system::os::getch(), isOpen(), mrpt::system::os::kbhit(), m_keyPushed, m_keyPushedCode, m_keyPushedModifier, and mrpt::gui::MRPTKMOD_NONE.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ C3DWindowDialog

friend class C3DWindowDialog
friend

Definition at line 43 of file CBaseGUIWindow.h.

◆ CWindowDialog

friend class CWindowDialog
friend

Definition at line 42 of file CBaseGUIWindow.h.

◆ CWindowDialogPlots

friend class CWindowDialogPlots
friend

Definition at line 44 of file CBaseGUIWindow.h.

Member Data Documentation

◆ m_caption

std::string mrpt::gui::CBaseGUIWindow::m_caption
protected

◆ m_CMD_CREATE_WIN

const int mrpt::gui::CBaseGUIWindow::m_CMD_CREATE_WIN
private

can be 200,300,400...

See WxSubsystem

Definition at line 48 of file CBaseGUIWindow.h.

Referenced by createWxWindow().

◆ m_CMD_DESTROY_WIN

const int mrpt::gui::CBaseGUIWindow::m_CMD_DESTROY_WIN
private

can be 299,399,499...

See WxSubsystem

Definition at line 50 of file CBaseGUIWindow.h.

Referenced by destroyWxWindow().

◆ m_hwnd

mrpt::void_ptr_noncopy mrpt::gui::CBaseGUIWindow::m_hwnd
protected

◆ m_keyPushed

std::atomic_bool mrpt::gui::CBaseGUIWindow::m_keyPushed = false
protected

◆ m_keyPushedCode

std::atomic_int mrpt::gui::CBaseGUIWindow::m_keyPushedCode = 0
protected

Definition at line 66 of file CBaseGUIWindow.h.

Referenced by getPushedKey(), mrpt::gui::CWindowDialog::OnChar(), and waitForKey().

◆ m_keyPushedModifier

std::atomic<mrptKeyModifier> mrpt::gui::CBaseGUIWindow::m_keyPushedModifier
protected

Definition at line 67 of file CBaseGUIWindow.h.

Referenced by getPushedKey(), mrpt::gui::CWindowDialog::OnChar(), and waitForKey().

◆ m_threadReady

std::promise<void> mrpt::gui::CBaseGUIWindow::m_threadReady
mutableprotected

This semaphore will be signaled when the wx window is built and ready.

Definition at line 56 of file CBaseGUIWindow.h.

Referenced by createWxWindow(), and notifySemThreadReady().

◆ m_windowDestroyed

std::promise<void> mrpt::gui::CBaseGUIWindow::m_windowDestroyed
mutableprotected

This semaphore will be signaled when the wx window is destroyed.

Definition at line 58 of file CBaseGUIWindow.h.

Referenced by destroyWxWindow(), mrpt::gui::CWindowDialog::OnClose(), and mrpt::gui::C3DWindowDialog::OnClose().

◆ m_winobj_voidptr

void* mrpt::gui::CBaseGUIWindow::m_winobj_voidptr
private

Definition at line 51 of file CBaseGUIWindow.h.

Referenced by createWxWindow(), and destroyWxWindow().




Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020