Main MRPT website > C++ reference for MRPT 1.4.0
List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
mrpt::gui::CDisplayWindow Class Reference

Detailed Description

This class creates a window as a graphical user interface (GUI) for displaying images to the user.

For a list of supported events with the observer/observable pattern, see the discussion in mrpt::gui::CBaseGUIWindow.

Definition at line 29 of file CDisplayWindow.h.

#include <mrpt/gui/CDisplayWindow.h>

Inheritance diagram for mrpt::gui::CDisplayWindow:
Inheritance graph

Public Member Functions

 CDisplayWindow (const std::string &windowCaption=std::string(), unsigned int initWidth=400, unsigned int initHeight=400)
 Constructor.
 
virtual ~CDisplayWindow ()
 Destructor.
 
virtual bool getLastMousePosition (int &x, int &y) const MRPT_OVERRIDE
 Gets the last x,y pixel coordinates of the mouse.
 
virtual void setCursorCross (bool cursorIsCross) MRPT_OVERRIDE
 Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true)
 
void showImageAndPoints (const mrpt::utils::CImage &img, const mrpt::math::CVectorFloat &x, const mrpt::math::CVectorFloat &y, const mrpt::utils::TColor &color=mrpt::utils::TColor::red, const bool &showNumbers=false)
 Show a given color or grayscale image on the window and print a set of points on it.
 
void showImageAndPoints (const mrpt::utils::CImage &img, const std::vector< float > &x, const std::vector< float > &y, const mrpt::utils::TColor &color=mrpt::utils::TColor::red, const bool &showNumbers=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<class FEATURELIST >
void showImageAndPoints (const mrpt::utils::CImage &img, const FEATURELIST &list, const mrpt::utils::TColor &color=mrpt::utils::TColor::red, const bool &showIDs=false)
 Show a given color or grayscale image on the window and print a set of points on it.
 
template<class FEATURELIST >
void showTiledImageAndPoints (const mrpt::utils::CImage &img, const FEATURELIST &list, const mrpt::utils::TColor &color=mrpt::utils::TColor::red)
 Show a given color or grayscale image on the window and print a set of points on it and a set of lines splitting the image in tiles.
 
template<class MATCHEDLIST >
void showImagesAndMatchedPoints (const mrpt::utils::CImage &img1, const mrpt::utils::CImage &img2, const MATCHEDLIST &mList, const mrpt::utils::TColor &color=mrpt::utils::TColor::red, bool showNumbers=false)
 Show a pair of given color or grayscale images (put together) on the window and print a set of matches on them.
 
template<class FEATURELIST >
void showImagesAndMatchedPoints (const mrpt::utils::CImage &img1, const mrpt::utils::CImage &img2, const FEATURELIST &leftList, const FEATURELIST &rightList, const mrpt::utils::TColor &color=mrpt::utils::TColor::red)
 Show a pair of given color or grayscale images (put together) on the window and print a set of matches on them.
 
void showImage (const mrpt::utils::CImage &img)
 Show a given color or grayscale image on the window.
 
void plot (const mrpt::math::CVectorFloat &x, const mrpt::math::CVectorFloat &y)
 Plots a graph in MATLAB-like style.
 
void plot (const mrpt::math::CVectorFloat &y)
 Plots a graph in MATLAB-like style.
 
void resize (unsigned int width, unsigned int height) MRPT_OVERRIDE
 Resizes the window, stretching the image to fit into the display area.
 
void setPos (int x, int y) MRPT_OVERRIDE
 Changes the position of the window on the screen.
 
void enableCursorCoordinatesVisualization (bool enable)
 Enables or disables the visualization of cursor coordinates on the window caption (default = enabled).
 
void setWindowTitle (const std::string &str) MRPT_OVERRIDE
 Changes the window title text.
 
void * getWxObject ()
 Read-only access to the wxDialog object.
 
void notifyChildWindowDestruction ()
 Called by wx main thread to set m_hwnd to NULL.
 
void notifySemThreadReady ()
 Called by wx main thread to signal the semaphore that the wx window is built and ready.
 
bool isOpen ()
 Returns false if the user has already closed the window.
 
int waitForKey (bool ignoreControlKeys=true, mrptKeyModifier *out_pushModifier=NULL)
 Waits for any key to be pushed on the image or the console, and returns the key code.
 
bool keyHit () const
 Returns true if a key has been pushed, without blocking waiting for a new key being pushed.
 
void clearKeyHitFlag ()
 Assure that "keyHit" will return false until the next pushed key.
 
int getPushedKey (mrptKeyModifier *out_pushModifier=NULL)
 Returns the latest pushed key, or 0 if there is no new key stroke.
 
mrpt::utils::CObjectPtr duplicateGetSmartPtr () const
 Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer).
 
CObject * clone () const
 Cloning interface for smart pointers.
 

Static Public Member Functions

static CDisplayWindowPtr Create (const std::string &windowCaption, unsigned int initWidth=400, unsigned int initHeight=400)
 Class factory returning a smart pointer.
 

Static Public Attributes

static const mrpt::utils::TRuntimeClassId classCObject
 
RTTI stuff <br>
static const mrpt::utils::TRuntimeClassId classCBaseGUIWindow
 

Protected Member Functions

void createWxWindow (unsigned int initialWidth, unsigned int initialHeight)
 Must be called by child classes just within the constructor.
 
void destroyWxWindow ()
 Must be called by child classes in their destructors. The code cannot be put into this class' destructor.
 
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.
 
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.
 

Protected Attributes

bool m_enableCursorCoordinates
 Enables or disables the visualization of cursor coordinates on the window caption.
 
synch::CSemaphore m_semThreadReady
 This semaphore will be signaled when the wx window is built and ready.
 
synch::CSemaphore m_semWindowDestroyed
 This semaphore will be signaled when the wx window is destroyed.
 
std::string m_caption
 The caption of the window.
 
mrpt::utils::void_ptr_noncopy m_hwnd
 The window handle.
 
volatile bool m_keyPushed
 
volatile int m_keyPushedCode
 
volatile mrptKeyModifier m_keyPushedModifier
 

Private Member Functions

void internal_observer_begin (CObserver *)
 
void internal_observer_end (CObserver *)
 

Private Attributes

const int m_CMD_CREATE_WIN
 can be 200,300,400... See WxSubsystem
 
const int m_CMD_DESTROY_WIN
 can be 299,399,499... See WxSubsystem
 
void * m_winobj_voidptr
 
std::set< CObserver * > m_subscribers
 

RTTI stuff <br>

typedef CDisplayWindowPtr SmartPtr
 
static mrpt::utils::CLASSINIT _init_CDisplayWindow
 
static mrpt::utils::TRuntimeClassId classCDisplayWindow
 
static const mrpt::utils::TRuntimeClassIdclassinfo
 
static const mrpt::utils::TRuntimeClassId_GetBaseClass ()
 
virtual const mrpt::utils::TRuntimeClassIdGetRuntimeClass () const MRPT_OVERRIDE
 Returns information about the class of an object in runtime.
 
virtual mrpt::utils::CObjectduplicate () const MRPT_OVERRIDE
 Returns a copy of the object, indepently of its class.
 
static mrpt::utils::CObjectCreateObject ()
 
static CDisplayWindowPtr Create ()
 

Member Typedef Documentation

◆ SmartPtr

A typedef for the associated smart pointer

Definition at line 32 of file CDisplayWindow.h.

Constructor & Destructor Documentation

◆ CDisplayWindow()

mrpt::gui::CDisplayWindow::CDisplayWindow ( const std::string &  windowCaption = std::string(),
unsigned int  initWidth = 400,
unsigned int  initHeight = 400 
)

Constructor.

◆ ~CDisplayWindow()

virtual mrpt::gui::CDisplayWindow::~CDisplayWindow ( )
virtual

Destructor.

Member Function Documentation

◆ _GetBaseClass()

static const mrpt::utils::TRuntimeClassId * mrpt::gui::CDisplayWindow::_GetBaseClass ( )
staticprotected

◆ clearKeyHitFlag()

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

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

See also
keyHit, waitForKey

Definition at line 127 of file CBaseGUIWindow.h.

◆ clone()

CObject * mrpt::utils::CObject::clone ( ) const
inlineinherited

Cloning interface for smart pointers.

Definition at line 139 of file CObject.h.

◆ Create() [1/2]

static CDisplayWindowPtr mrpt::gui::CDisplayWindow::Create ( )
static

◆ Create() [2/2]

static CDisplayWindowPtr mrpt::gui::CDisplayWindow::Create ( const std::string &  windowCaption,
unsigned int  initWidth = 400,
unsigned int  initHeight = 400 
)
static

Class factory returning a smart pointer.

◆ CreateObject()

static mrpt::utils::CObject * mrpt::gui::CDisplayWindow::CreateObject ( )
static

◆ createWxWindow()

void mrpt::gui::CBaseGUIWindow::createWxWindow ( unsigned int  initialWidth,
unsigned int  initialHeight 
)
protectedinherited

Must be called by child classes just within the constructor.

◆ destroyWxWindow()

void mrpt::gui::CBaseGUIWindow::destroyWxWindow ( )
protectedinherited

Must be called by child classes in their destructors. The code cannot be put into this class' destructor.

◆ duplicate()

virtual mrpt::utils::CObject * mrpt::gui::CDisplayWindow::duplicate ( ) const
virtual

Returns a copy of the object, indepently of its class.

Implements mrpt::utils::CObject.

◆ duplicateGetSmartPtr()

mrpt::utils::CObjectPtr mrpt::utils::CObject::duplicateGetSmartPtr ( ) const
inlineinherited

Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer).

Definition at line 136 of file CObject.h.

◆ enableCursorCoordinatesVisualization()

void mrpt::gui::CDisplayWindow::enableCursorCoordinatesVisualization ( bool  enable)
inline

Enables or disables the visualization of cursor coordinates on the window caption (default = enabled).

Definition at line 195 of file CDisplayWindow.h.

◆ getLastMousePosition()

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

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

Returns
False if the window is closed.

Implements mrpt::gui::CBaseGUIWindow.

◆ getPushedKey()

int mrpt::gui::CBaseGUIWindow::getPushedKey ( mrptKeyModifier out_pushModifier = NULL)
inherited

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

Parameters
out_pushModifierIf set to !=NULL, 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

◆ GetRuntimeClass()

virtual const mrpt::utils::TRuntimeClassId * mrpt::gui::CDisplayWindow::GetRuntimeClass ( ) const
virtual

Returns information about the class of an object in runtime.

Reimplemented from mrpt::gui::CBaseGUIWindow.

◆ getWxObject()

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

Read-only access to the wxDialog object.

Definition at line 75 of file CBaseGUIWindow.h.

◆ hasSubscribers()

bool mrpt::utils::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 52 of file CObservable.h.

◆ internal_observer_begin()

void mrpt::utils::CObservable::internal_observer_begin ( CObserver )
privateinherited

◆ internal_observer_end()

void mrpt::utils::CObservable::internal_observer_end ( CObserver )
privateinherited

◆ isOpen()

bool mrpt::gui::CBaseGUIWindow::isOpen ( )
inherited

Returns false if the user has already closed the window.

◆ keyHit()

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

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

See also
waitForKey, clearKeyHitFlag

Definition at line 122 of file CBaseGUIWindow.h.

◆ notifyChildWindowDestruction()

void mrpt::gui::CBaseGUIWindow::notifyChildWindowDestruction ( )
inherited

Called by wx main thread to set m_hwnd to NULL.

◆ notifySemThreadReady()

void mrpt::gui::CBaseGUIWindow::notifySemThreadReady ( )
inherited

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

◆ plot() [1/2]

void mrpt::gui::CDisplayWindow::plot ( const mrpt::math::CVectorFloat x,
const mrpt::math::CVectorFloat y 
)

Plots a graph in MATLAB-like style.

◆ plot() [2/2]

void mrpt::gui::CDisplayWindow::plot ( const mrpt::math::CVectorFloat y)

Plots a graph in MATLAB-like style.

◆ publishEvent()

void mrpt::utils::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.

◆ resize()

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

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

Implements mrpt::gui::CBaseGUIWindow.

◆ setCursorCross()

virtual void mrpt::gui::CDisplayWindow::setCursorCross ( bool  cursorIsCross)
virtual

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

Implements mrpt::gui::CBaseGUIWindow.

◆ setPos()

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

Changes the position of the window on the screen.

Implements mrpt::gui::CBaseGUIWindow.

◆ setWindowTitle()

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

Changes the window title text.

Implements mrpt::gui::CBaseGUIWindow.

◆ showImage()

void mrpt::gui::CDisplayWindow::showImage ( const mrpt::utils::CImage img)

Show a given color or grayscale image on the window.

It adapts the size of the window to that of the image.

◆ showImageAndPoints() [1/3]

template<class FEATURELIST >
void mrpt::gui::CDisplayWindow::showImageAndPoints ( const mrpt::utils::CImage img,
const FEATURELIST &  list,
const mrpt::utils::TColor color = mrpt::utils::TColor::red,
const bool &  showIDs = false 
)
inline

Show a given color or grayscale image on the window and print a set of points on it.

It adapts the size of the window to that of the image. The class of FEATURELIST can be: mrpt::vision::CFeatureList or any STL container of entities having "x","y" and "ID" fields.

Definition at line 73 of file CDisplayWindow.h.

References CH_RGB, mrpt::utils::CImage::colorImage(), MRPT_END, and MRPT_START.

◆ showImageAndPoints() [2/3]

void mrpt::gui::CDisplayWindow::showImageAndPoints ( const mrpt::utils::CImage img,
const mrpt::math::CVectorFloat x,
const mrpt::math::CVectorFloat y,
const mrpt::utils::TColor color = mrpt::utils::TColor::red,
const bool &  showNumbers = false 
)

Show a given color or grayscale image on the window and print a set of points on it.

It adapts the size of the window to that of the image.

◆ showImageAndPoints() [3/3]

void mrpt::gui::CDisplayWindow::showImageAndPoints ( const mrpt::utils::CImage img,
const std::vector< float > &  x,
const std::vector< float > &  y,
const mrpt::utils::TColor color = mrpt::utils::TColor::red,
const bool &  showNumbers = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ showImagesAndMatchedPoints() [1/2]

template<class FEATURELIST >
void mrpt::gui::CDisplayWindow::showImagesAndMatchedPoints ( const mrpt::utils::CImage img1,
const mrpt::utils::CImage img2,
const FEATURELIST &  leftList,
const FEATURELIST &  rightList,
const mrpt::utils::TColor color = mrpt::utils::TColor::red 
)
inline

Show a pair of given color or grayscale images (put together) on the window and print a set of matches on them.

It adapts the size of the window to that of the image. FEATURELIST can be of the class: mrpt::vision::CFeatureList

Definition at line 149 of file CDisplayWindow.h.

References ASSERT_, mrpt::utils::CImage::getWidth(), MRPT_END, and MRPT_START.

◆ showImagesAndMatchedPoints() [2/2]

template<class MATCHEDLIST >
void mrpt::gui::CDisplayWindow::showImagesAndMatchedPoints ( const mrpt::utils::CImage img1,
const mrpt::utils::CImage img2,
const MATCHEDLIST &  mList,
const mrpt::utils::TColor color = mrpt::utils::TColor::red,
bool  showNumbers = false 
)
inline

Show a pair of given color or grayscale images (put together) on the window and print a set of matches on them.

It adapts the size of the window to that of the image. MATCHEDLIST can be of the class: mrpt::vision::CMatchedFeatureList, or any STL container of pairs of anything having ".x" and ".y" (e.g. mrpt::math::TPoint2D)

Definition at line 113 of file CDisplayWindow.h.

References mrpt::utils::CImage::getWidth(), mrpt::utils::CImage::joinImagesHorz(), MRPT_END, MRPT_START, and mrpt::system::os::sprintf().

◆ showTiledImageAndPoints()

template<class FEATURELIST >
void mrpt::gui::CDisplayWindow::showTiledImageAndPoints ( const mrpt::utils::CImage img,
const FEATURELIST &  list,
const mrpt::utils::TColor color = mrpt::utils::TColor::red 
)
inline

Show a given color or grayscale image on the window and print a set of points on it and a set of lines splitting the image in tiles.

It adapts the size of the window to that of the image. The class of FEATURELIST can be: mrpt::vision::CFeatureList

Definition at line 88 of file CDisplayWindow.h.

References mrpt::utils::CImage::colorImage(), mrpt::utils::CImage::getHeight(), mrpt::utils::CImage::getWidth(), mrpt::utils::CImage::line(), MRPT_END, and MRPT_START.

◆ waitForKey()

int mrpt::gui::CBaseGUIWindow::waitForKey ( bool  ignoreControlKeys = true,
mrptKeyModifier out_pushModifier = NULL 
)
inherited

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 !=NULL, 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

Member Data Documentation

◆ _init_CDisplayWindow

mrpt::utils::CLASSINIT mrpt::gui::CDisplayWindow::_init_CDisplayWindow
staticprotected

Definition at line 32 of file CDisplayWindow.h.

◆ classCBaseGUIWindow

const mrpt::utils::TRuntimeClassId mrpt::gui::CBaseGUIWindow::classCBaseGUIWindow
staticinherited

Definition at line 49 of file CBaseGUIWindow.h.

◆ classCDisplayWindow

mrpt::utils::TRuntimeClassId mrpt::gui::CDisplayWindow::classCDisplayWindow
static

Definition at line 32 of file CDisplayWindow.h.

◆ classCObject

const mrpt::utils::TRuntimeClassId mrpt::utils::CObject::classCObject
staticinherited

Definition at line 124 of file CObject.h.

◆ classinfo

const mrpt::utils::TRuntimeClassId* mrpt::gui::CDisplayWindow::classinfo
static

Definition at line 32 of file CDisplayWindow.h.

◆ m_caption

std::string mrpt::gui::CBaseGUIWindow::m_caption
protectedinherited

The caption of the window.

Definition at line 63 of file CBaseGUIWindow.h.

◆ m_CMD_CREATE_WIN

const int mrpt::gui::CBaseGUIWindow::m_CMD_CREATE_WIN
privateinherited

can be 200,300,400... See WxSubsystem

Definition at line 56 of file CBaseGUIWindow.h.

◆ m_CMD_DESTROY_WIN

const int mrpt::gui::CBaseGUIWindow::m_CMD_DESTROY_WIN
privateinherited

can be 299,399,499... See WxSubsystem

Definition at line 57 of file CBaseGUIWindow.h.

◆ m_enableCursorCoordinates

bool mrpt::gui::CDisplayWindow::m_enableCursorCoordinates
protected

Enables or disables the visualization of cursor coordinates on the window caption.

Definition at line 38 of file CDisplayWindow.h.

◆ m_hwnd

mrpt::utils::void_ptr_noncopy mrpt::gui::CBaseGUIWindow::m_hwnd
protectedinherited

The window handle.

Definition at line 64 of file CBaseGUIWindow.h.

◆ m_keyPushed

volatile bool mrpt::gui::CBaseGUIWindow::m_keyPushed
protectedinherited

Definition at line 67 of file CBaseGUIWindow.h.

◆ m_keyPushedCode

volatile int mrpt::gui::CBaseGUIWindow::m_keyPushedCode
protectedinherited

Definition at line 68 of file CBaseGUIWindow.h.

◆ m_keyPushedModifier

volatile mrptKeyModifier mrpt::gui::CBaseGUIWindow::m_keyPushedModifier
protectedinherited

Definition at line 69 of file CBaseGUIWindow.h.

◆ m_semThreadReady

synch::CSemaphore mrpt::gui::CBaseGUIWindow::m_semThreadReady
protectedinherited

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

Definition at line 61 of file CBaseGUIWindow.h.

◆ m_semWindowDestroyed

synch::CSemaphore mrpt::gui::CBaseGUIWindow::m_semWindowDestroyed
protectedinherited

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

Definition at line 62 of file CBaseGUIWindow.h.

◆ m_subscribers

std::set<CObserver*> mrpt::utils::CObservable::m_subscribers
privateinherited

Definition at line 42 of file CObservable.h.

◆ m_winobj_voidptr

void* mrpt::gui::CBaseGUIWindow::m_winobj_voidptr
privateinherited

Definition at line 58 of file CBaseGUIWindow.h.




Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Wed Mar 22 06:16:42 UTC 2023