MRPT
2.0.1
|
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>
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< 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... | |
void * | m_winobj_voidptr |
Friends | |
class | CWindowDialog |
class | C3DWindowDialog |
class | CWindowDialogPlots |
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.
|
overridedefault |
|
inline |
Assure that "keyHit" will return false until the next pushed key.
Definition at line 143 of file CBaseGUIWindow.h.
References m_keyPushed.
|
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().
|
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().
|
pure virtual |
Gets the last x,y pixel coordinates of the mouse.
Implemented in mrpt::gui::CDisplayWindow3D, mrpt::gui::CDisplayWindowPlots, and mrpt::gui::CDisplayWindow.
int CBaseGUIWindow::getPushedKey | ( | mrptKeyModifier * | out_pushModifier = nullptr | ) |
Returns the latest pushed key, or 0 if there is no new key stroke.
out_pushModifier | If set to !=nullptr, the modifiers of the key stroke will be saved here. |
Definition at line 186 of file CBaseGUIWindow.cpp.
References m_keyPushed, m_keyPushedCode, m_keyPushedModifier, and mrpt::gui::MRPTKMOD_NONE.
|
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().
|
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().
bool CBaseGUIWindow::isOpen | ( | ) |
Returns false if the user has already closed the window.
Definition at line 201 of file CBaseGUIWindow.cpp.
References m_hwnd.
Referenced by mrpt::gui::CDisplayWindowPlots::addPopupMenuEntry(), mrpt::gui::CDisplayWindowPlots::axis(), mrpt::gui::CDisplayWindowPlots::axis_equal(), mrpt::gui::CDisplayWindowPlots::axis_fit(), mrpt::gui::CDisplayWindowPlots::clear(), mrpt::math::CMonteCarlo< T, NUM, OTHER >::doExperiment(), mrpt::gui::CDisplayWindowPlots::enableMousePanZoom(), mrpt::gui::CDisplayWindowPlots::image(), mrpt::gui::CDisplayWindowPlots::internal_plot(), mrpt::graphslam::CWindowManager::isOpen(), mrpt::gui::CDisplayWindowPlots::plotEllipse(), mrpt::gui::CDisplayWindowPlots::resize(), mrpt::gui::CDisplayWindow3D::resize(), mrpt::gui::CDisplayWindow::resize(), mrpt::gui::CDisplayWindowPlots::setPos(), mrpt::gui::CDisplayWindow3D::setPos(), mrpt::gui::CDisplayWindow::setPos(), mrpt::gui::CDisplayWindowPlots::setWindowTitle(), mrpt::gui::CDisplayWindow3D::setWindowTitle(), mrpt::gui::CDisplayWindow::setWindowTitle(), waitForKey(), and CGraphSlamHandler< GRAPH_T >::~CGraphSlamHandler().
|
inline |
Returns true if a key has been pushed, without blocking waiting for a new key being pushed.
Definition at line 139 of file CBaseGUIWindow.h.
References m_keyPushed.
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().
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().
|
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().
|
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.
|
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.
|
pure virtual |
Changes the position of the window on the screen.
Implemented in mrpt::gui::CDisplayWindow, mrpt::gui::CDisplayWindow3D, and mrpt::gui::CDisplayWindowPlots.
|
pure virtual |
Changes the window title text.
Implemented in mrpt::gui::CDisplayWindow, mrpt::gui::CDisplayWindow3D, and mrpt::gui::CDisplayWindowPlots.
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
ignoreControlKeys | If set to false, any push of shift, cmd, control, etc... will make this method to return. |
out_pushModifier | If set to !=nullptr, the modifiers of the key stroke will be saved here. |
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.
|
friend |
Definition at line 43 of file CBaseGUIWindow.h.
|
friend |
Definition at line 42 of file CBaseGUIWindow.h.
|
friend |
Definition at line 44 of file CBaseGUIWindow.h.
|
protected |
The caption of the window.
Definition at line 60 of file CBaseGUIWindow.h.
Referenced by createWxWindow(), mrpt::gui::CDisplayWindowPlots::resize(), mrpt::gui::CDisplayWindow3D::resize(), mrpt::gui::CDisplayWindow::resize(), mrpt::gui::CDisplayWindowPlots::setPos(), mrpt::gui::CDisplayWindow3D::setPos(), mrpt::gui::CDisplayWindow::setPos(), mrpt::gui::CDisplayWindowPlots::setWindowTitle(), mrpt::gui::CDisplayWindow3D::setWindowTitle(), and mrpt::gui::CDisplayWindow::setWindowTitle().
|
private |
can be 200,300,400...
See WxSubsystem
Definition at line 48 of file CBaseGUIWindow.h.
Referenced by createWxWindow().
|
private |
can be 299,399,499...
See WxSubsystem
Definition at line 50 of file CBaseGUIWindow.h.
Referenced by destroyWxWindow().
|
protected |
The window handle.
Definition at line 62 of file CBaseGUIWindow.h.
Referenced by createWxWindow(), destroyWxWindow(), mrpt::gui::CDisplayWindow3D::forceRepaint(), mrpt::gui::CDisplayWindow3D::getCameraAzimuthDeg(), mrpt::gui::CDisplayWindow3D::getCameraElevationDeg(), mrpt::gui::CDisplayWindow3D::getCameraPointingToPoint(), mrpt::gui::CDisplayWindow3D::getCameraZoom(), mrpt::gui::CDisplayWindow3D::getFOV(), mrpt::gui::CDisplayWindow::getLastMousePosition(), mrpt::gui::CDisplayWindowPlots::getLastMousePosition(), mrpt::gui::CDisplayWindow3D::getLastMousePosition(), getWxObject(), mrpt::gui::CDisplayWindow3D::isCameraProjective(), isOpen(), notifyChildWindowDestruction(), mrpt::gui::CDisplayWindow3D::setCameraAzimuthDeg(), mrpt::gui::CDisplayWindow3D::setCameraElevationDeg(), mrpt::gui::CDisplayWindow3D::setCameraPointingToPoint(), mrpt::gui::CDisplayWindow3D::setCameraProjective(), mrpt::gui::CDisplayWindow3D::setCameraZoom(), mrpt::gui::CDisplayWindow::setCursorCross(), mrpt::gui::CDisplayWindowPlots::setCursorCross(), mrpt::gui::CDisplayWindow3D::setCursorCross(), mrpt::gui::CDisplayWindow3D::setFOV(), mrpt::gui::CDisplayWindow::showImage(), and mrpt::gui::CDisplayWindow3D::useCameraFromScene().
|
protected |
Definition at line 65 of file CBaseGUIWindow.h.
Referenced by clearKeyHitFlag(), getPushedKey(), keyHit(), mrpt::gui::CWindowDialog::OnChar(), and waitForKey().
|
protected |
Definition at line 66 of file CBaseGUIWindow.h.
Referenced by getPushedKey(), mrpt::gui::CWindowDialog::OnChar(), and waitForKey().
|
protected |
Definition at line 67 of file CBaseGUIWindow.h.
Referenced by getPushedKey(), mrpt::gui::CWindowDialog::OnChar(), and waitForKey().
|
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().
|
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().
|
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.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020 |