Main MRPT website > C++ reference for MRPT 1.5.9
List of all members | Classes | Static Public Member Functions | Static Public Attributes | Static Private Attributes
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 99 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 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 NULL 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 volatile bool isConsoleApp = true
 Will be set to true at runtime if it's not detected a running wxApp instance. More...
 
static CAuxWxSubsystemShutdowner global_wxsubsystem_shutdown
 

Static Private Attributes

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

Member Function Documentation

◆ createOneInstanceMainThread()

bool WxSubsystem::createOneInstanceMainThread ( )
static

◆ getMRPTDefaultIcon()

wxBitmap WxSubsystem::getMRPTDefaultIcon ( )
static

◆ GetWxMainThreadInstance()

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

◆ popPendingWxRequest()

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

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

Definition at line 230 of file WxSubsystem.cpp.

◆ pushPendingWxRequest()

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

◆ waitWxShutdownsIfNoWindows()

void WxSubsystem::waitWxShutdownsIfNoWindows ( )
static

◆ 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 929 of file WxSubsystem.cpp.

References mrpt::system::TThreadHandle::clear(), GetWxMainThreadInstance(), mrpt::gui::WxSubsystem::TWxMainThreadData::m_semWxMainThreadReady, mrpt::gui::WxSubsystem::TWxMainThreadData::m_wxMainThreadId, MRPT_END, MRPT_START, mrpt_wxCreateApp(), mrpt_wxEntryReal(), and mrpt::synch::CSemaphore::release().

Referenced by createOneInstanceMainThread().

Member Data Documentation

◆ cs_listPendingWxRequests

synch::CCriticalSection * WxSubsystem::cs_listPendingWxRequests = NULL
staticprivate

◆ global_wxsubsystem_shutdown

WxSubsystem::CAuxWxSubsystemShutdowner WxSubsystem::global_wxsubsystem_shutdown
static

Definition at line 125 of file WxSubsystem.h.

◆ isConsoleApp

volatile bool WxSubsystem::isConsoleApp = true
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 114 of file WxSubsystem.h.

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

◆ listPendingWxRequests

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

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

Definition at line 280 of file WxSubsystem.h.

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




Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020