MRPT  1.9.9
mrpt::gui::CBaseGUIWindow Class Referenceabstract

Detailed Description

The base class for GUI window classes.

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:
Inheritance graph

Public Member Functions

voidgetWxObject ()
 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...
 
virtual ~CBaseGUIWindow ()
 
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< voidm_threadReady
 This semaphore will be signaled when the wx window is built and ready. More...
 
std::promise< voidm_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...
 
volatile bool m_keyPushed
 
volatile int m_keyPushedCode
 
volatile mrptKeyModifier m_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...
 
voidm_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 ( )
virtual

Definition at line 101 of file CBaseGUIWindow.cpp.

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()

◆ destroyWxWindow()

◆ 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 190 of file CBaseGUIWindow.cpp.

References isOpen(), 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().

◆ 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(), and mrpt::opengl::COpenGLViewport::render().

◆ 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 152 of file CBaseGUIWindow.cpp.

References m_hwnd.

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

◆ notifySemThreadReady()

void CBaseGUIWindow::notifySemThreadReady ( )

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

Definition at line 217 of file CBaseGUIWindow.cpp.

References m_threadReady.

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

◆ publishEvent()

◆ 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 156 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.

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

◆ 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

◆ m_keyPushed

volatile bool mrpt::gui::CBaseGUIWindow::m_keyPushed
protected

◆ m_keyPushedCode

volatile int mrpt::gui::CBaseGUIWindow::m_keyPushedCode
protected

Definition at line 66 of file CBaseGUIWindow.h.

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

◆ m_keyPushedModifier

volatile 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 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020