MRPT  1.9.9
mrpt::gui::WxSubsystem Class Reference

Detailed Description

This class implements the GUI thread required for the wxWidgets-based GUI.

This system is employed internally by gui::CDisplayWindow and gui::CDisplayWindow3D, and must be not used in any way directly by the MRPT user.

The system works by creating a invisible wxFrame that process timer events where it checks a queue of requests sent from the main MRPT thread. The requests include the creation, deletion,... of windows (2D/3D). In that way, just one thread is required for all the GUI windows, and the wxWidgets is initialized and clean-up correctly.

This header should be included just from the implementation files of CDisplayWindow and CDisplayWindow3D, since it uses wxWidgets classes.

See also
gui::CDisplayWindow, gui::CDisplayWindow3D

Definition at line 96 of file WxSubsystem.h.

#include <mrpt/gui/WxSubsystem.h>

Classes

class  CAuxWxSubsystemShutdowner
 An auxiliary global object used just to launch a final request to the wxSubsystem for shutdown: More...
 
class  CWXMainFrame
 The main frame of the wxWidgets application. More...
 
struct  TRequestToWxMainThread
 The data structure for each inter-thread request: More...
 
struct  TWxMainThreadData
 

Static Public Member Functions

static void waitWxShutdownsIfNoWindows ()
 This method must be called in the destructor of the user class FROM THE MAIN THREAD, in order to wait for the shutdown of the wx thread if this was the last open window. More...
 
static bool isConsoleApp ()
 Will be set to true at runtime if it's not detected a running wxApp instance. More...
 
static TWxMainThreadDataGetWxMainThreadInstance ()
 
static void wxMainThread ()
 This will be the "MAIN" of wxWidgets: It starts an application object and does not end until all the windows are closed. More...
 
static TRequestToWxMainThreadpopPendingWxRequest ()
 Thread-safe method to return the next pending request, or nullptr if there is none (After usage, FREE the memory!) More...
 
static void pushPendingWxRequest (TRequestToWxMainThread *data)
 Thread-safe method to insert a new pending request (The memory must be dinamically allocated with "new T[1]", will be freed by receiver.) More...
 
static bool createOneInstanceMainThread ()
 Thread-safe method to create one single instance of the main wxWidgets thread: it will create the thread only if it is not running yet. More...
 
static wxBitmap getMRPTDefaultIcon ()
 

Static Public Attributes

static CAuxWxSubsystemShutdowner global_wxsubsystem_shutdown
 

Static Private Attributes

static std::queue< TRequestToWxMainThread * > * listPendingWxRequests = nullptr
 Do not access directly to this, use the thread-safe functions. More...
 
static std::mutex * cs_listPendingWxRequests = nullptr
 

Member Function Documentation

◆ createOneInstanceMainThread()

bool WxSubsystem::createOneInstanceMainThread ( )
static

Thread-safe method to create one single instance of the main wxWidgets thread: it will create the thread only if it is not running yet.

Definition at line 1076 of file WxSubsystem.cpp.

References GetWxMainThreadInstance(), isConsoleApp_value, mrpt::gui::WxSubsystem::TWxMainThreadData::m_csWxMainThreadId, mrpt::gui::WxSubsystem::TWxMainThreadData::m_semWxMainThreadReady, mrpt::gui::WxSubsystem::TWxMainThreadData::m_wxMainThreadId, and mrpt::gui::WxSubsystem::CWXMainFrame::oneInstance.

Referenced by mrpt::gui::CBaseGUIWindow::createWxWindow(), and mrpt::hwdrivers::prepareVideoSourceFromUserSelection().

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

◆ getMRPTDefaultIcon()

wxBitmap WxSubsystem::getMRPTDefaultIcon ( )
static

Definition at line 828 of file WxSubsystem.cpp.

References mrpt_default_icon_xpm.

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

Here is the caller graph for this function:

◆ GetWxMainThreadInstance()

WxSubsystem::TWxMainThreadData & WxSubsystem::GetWxMainThreadInstance ( )
static

Definition at line 1058 of file WxSubsystem.cpp.

Referenced by createOneInstanceMainThread(), CDisplayWindow_WXAPP::OnExit(), CDisplayWindow_WXAPP::OnInit(), and wxMainThread().

Here is the caller graph for this function:

◆ isConsoleApp()

bool WxSubsystem::isConsoleApp ( )
static

Will be set to true at runtime if it's not detected a running wxApp instance.

For console apps, we'll create a new thread and run wxEntry from there. For GUI apps (MRPT-based Windows are a part of a user wxWidget apps), we must leave the control of message dispatching to the current main loop, so we cannot create a different threads, making things a little different (hence this variable).

Definition at line 53 of file WxSubsystem.cpp.

References isConsoleApp_value.

Referenced by mrpt::gui::CBaseGUIWindow::createWxWindow(), mrpt::gui::CBaseGUIWindow::destroyWxWindow(), waitWxShutdownsIfNoWindows(), and mrpt::gui::WxSubsystem::CAuxWxSubsystemShutdowner::~CAuxWxSubsystemShutdowner().

Here is the caller graph for this function:

◆ popPendingWxRequest()

WxSubsystem::TRequestToWxMainThread * WxSubsystem::popPendingWxRequest ( )
static

Thread-safe method to return the next pending request, or nullptr if there is none (After usage, FREE the memory!)

Definition at line 236 of file WxSubsystem.cpp.

◆ pushPendingWxRequest()

void WxSubsystem::pushPendingWxRequest ( WxSubsystem::TRequestToWxMainThread data)
static

Thread-safe method to insert a new pending request (The memory must be dinamically allocated with "new T[1]", will be freed by receiver.)

Definition at line 258 of file WxSubsystem.cpp.

References mrpt::gui::WxSubsystem::CWXMainFrame::oneInstance.

Referenced by mrpt::gui::CDisplayWindowPlots::addPopupMenuEntry(), mrpt::gui::CDisplayWindow3D::addTextMessage(), mrpt::gui::CDisplayWindowPlots::axis(), mrpt::gui::CDisplayWindowPlots::axis_equal(), mrpt::gui::CDisplayWindowPlots::axis_fit(), mrpt::gui::CDisplayWindowPlots::clear(), mrpt::gui::CDisplayWindow3D::clearTextMessages(), mrpt::gui::CBaseGUIWindow::createWxWindow(), mrpt::gui::CBaseGUIWindow::destroyWxWindow(), mrpt::gui::CDisplayWindowPlots::enableMousePanZoom(), mrpt::gui::CDisplayWindow3D::forceRepaint(), mrpt::gui::CDisplayWindowPlots::image(), mrpt::gui::CDisplayWindowPlots::internal_plot(), 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(), mrpt::gui::CDisplayWindow::showImage(), and mrpt::gui::WxSubsystem::CAuxWxSubsystemShutdowner::~CAuxWxSubsystemShutdowner().

Here is the caller graph for this function:

◆ waitWxShutdownsIfNoWindows()

void WxSubsystem::waitWxShutdownsIfNoWindows ( )
static

This method must be called in the destructor of the user class FROM THE MAIN THREAD, in order to wait for the shutdown of the wx thread if this was the last open window.

Definition at line 894 of file WxSubsystem.cpp.

References isConsoleApp().

Referenced by mrpt::gui::CBaseGUIWindow::destroyWxWindow(), and mrpt::gui::WxSubsystem::CAuxWxSubsystemShutdowner::~CAuxWxSubsystemShutdowner().

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

◆ wxMainThread()

void WxSubsystem::wxMainThread ( )
static

This will be the "MAIN" of wxWidgets: It starts an application object and does not end until all the windows are closed.

Only one instance of this thread can be running at a given instant, no matter how many windows are open.

Definition at line 998 of file WxSubsystem.cpp.

References GetWxMainThreadInstance(), mrpt::gui::WxSubsystem::TWxMainThreadData::m_done, mrpt::gui::WxSubsystem::TWxMainThreadData::m_semWxMainThreadReady, MRPT_END, MRPT_START, mrpt_wxCreateApp(), and mrpt_wxEntryReal().

Here is the call graph for this function:

Member Data Documentation

◆ cs_listPendingWxRequests

std::mutex * WxSubsystem::cs_listPendingWxRequests = nullptr
staticprivate

◆ global_wxsubsystem_shutdown

WxSubsystem::CAuxWxSubsystemShutdowner WxSubsystem::global_wxsubsystem_shutdown
static

Definition at line 128 of file WxSubsystem.h.

◆ listPendingWxRequests

std::queue< WxSubsystem::TRequestToWxMainThread * > * WxSubsystem::listPendingWxRequests = nullptr
staticprivate

Do not access directly to this, use the thread-safe functions.

Definition at line 308 of file WxSubsystem.h.

Referenced by mrpt::gui::WxSubsystem::CAuxWxSubsystemShutdowner::~CAuxWxSubsystemShutdowner().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ce1a28c9f Fri Aug 23 08:02:09 2019 +0200 at vie ago 23 08:10:11 CEST 2019