MRPT  2.0.3
List of all members | Public Types | Public Member Functions | Static Public Member Functions | 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.

mrpt::gui::CDisplayWindow screenshot

Definition at line 33 of file CDisplayWindow.h.

#include <mrpt/gui/CDisplayWindow.h>

Inheritance diagram for mrpt::gui::CDisplayWindow:

Public Types

using Ptr = std::shared_ptr< CDisplayWindow >
 
using ConstPtr = std::shared_ptr< const CDisplayWindow >
 

Public Member Functions

 CDisplayWindow (const std::string &windowCaption=std::string(), unsigned int initWidth=400, unsigned int initHeight=400)
 Constructor. More...
 
 ~CDisplayWindow () override
 Destructor. More...
 
bool getLastMousePosition (int &x, int &y) const override
 Gets the last x,y pixel coordinates of the mouse. More...
 
void setCursorCross (bool cursorIsCross) override
 Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true) More...
 
void showImageAndPoints (const mrpt::img::CImage &img, const mrpt::math::CVectorFloat &x, const mrpt::math::CVectorFloat &y, const mrpt::img::TColor &color=mrpt::img::TColor::red(), bool showNumbers=false)
 Show a given color or grayscale image on the window and print a set of points on it. More...
 
void showImageAndPoints (const mrpt::img::CImage &img, const std::vector< float > &x, const std::vector< float > &y, const mrpt::img::TColor &color=mrpt::img::TColor::red(), 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. More...
 
template<class FEATURELIST >
void showImageAndPoints (const mrpt::img::CImage &img, const FEATURELIST &list, const mrpt::img::TColor &color=mrpt::img::TColor::red(), bool showIDs=false)
 Show a given color or grayscale image on the window and print a set of points on it. More...
 
template<class FEATURELIST >
void showTiledImageAndPoints (const mrpt::img::CImage &img, const FEATURELIST &list, const mrpt::img::TColor &color=mrpt::img::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. More...
 
template<class MATCHEDLIST >
void showImagesAndMatchedPoints (const mrpt::img::CImage &img1, const mrpt::img::CImage &img2, const MATCHEDLIST &mList, const mrpt::img::TColor &color=mrpt::img::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. More...
 
template<class FEATURELIST >
void showImagesAndMatchedPoints (const mrpt::img::CImage &img1, const mrpt::img::CImage &img2, const FEATURELIST &leftList, const FEATURELIST &rightList, const mrpt::img::TColor &color=mrpt::img::TColor::red())
 Show a pair of given color or grayscale images (put together) on the window and print a set of matches on them. More...
 
void showImage (const mrpt::img::CImage &img)
 Show a given color or grayscale image on the window. More...
 
void plot (const mrpt::math::CVectorFloat &x, const mrpt::math::CVectorFloat &y)
 Plots a graph in MATLAB-like style. More...
 
void plot (const mrpt::math::CVectorFloat &y)
 Plots a graph in MATLAB-like style. More...
 
void resize (unsigned int width, unsigned int height) override
 Resizes the window, stretching the image to fit into the display area. More...
 
void setPos (int x, int y) override
 Changes the position of the window on the screen. More...
 
void enableCursorCoordinatesVisualization (bool enable)
 Enables or disables the visualization of cursor coordinates on the window caption (default = enabled). More...
 
void setWindowTitle (const std::string &str) override
 Changes the window title text. More...
 
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...
 
bool isOpen ()
 Returns false if the user has already closed the window. 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...
 

Static Public Member Functions

static CDisplayWindow::Ptr Create (const std::string &windowCaption, unsigned int initWidth=400, unsigned int initHeight=400)
 Class factory returning a smart pointer. 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

bool m_enableCursorCoordinates {true}
 Enables or disables the visualization of cursor coordinates on the window caption. More...
 
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< mrptKeyModifierm_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... More...
 
const int m_CMD_DESTROY_WIN
 can be 299,399,499... More...
 
void * m_winobj_voidptr
 
std::set< CObserver * > m_subscribers
 

Member Typedef Documentation

◆ ConstPtr

using mrpt::gui::CDisplayWindow::ConstPtr = std::shared_ptr<const CDisplayWindow>

Definition at line 37 of file CDisplayWindow.h.

◆ Ptr

Definition at line 36 of file CDisplayWindow.h.

Constructor & Destructor Documentation

◆ CDisplayWindow()

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

Constructor.

Definition at line 319 of file CDisplayWindow.cpp.

References mrpt::gui::CBaseGUIWindow::createWxWindow().

◆ ~CDisplayWindow()

CDisplayWindow::~CDisplayWindow ( )
override

Destructor.

Definition at line 331 of file CDisplayWindow.cpp.

References mrpt::gui::CBaseGUIWindow::destroyWxWindow().

Member Function Documentation

◆ 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 143 of file CBaseGUIWindow.h.

References mrpt::gui::CBaseGUIWindow::m_keyPushed.

◆ Create()

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

◆ createWxWindow()

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

◆ destroyWxWindow()

void CBaseGUIWindow::destroyWxWindow ( )
protectedinherited

◆ 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 243 of file CDisplayWindow.h.

References m_enableCursorCoordinates.

◆ getLastMousePosition()

bool CDisplayWindow::getLastMousePosition ( int &  x,
int &  y 
) const
overridevirtual

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

Returns
False if the window is closed.

Implements mrpt::gui::CBaseGUIWindow.

Definition at line 347 of file CDisplayWindow.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), mrpt::gui::CBaseGUIWindow::m_hwnd, and win.

◆ getPushedKey()

int CBaseGUIWindow::getPushedKey ( mrptKeyModifier out_pushModifier = nullptr)
inherited

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

References mrpt::gui::CBaseGUIWindow::m_keyPushed, mrpt::gui::CBaseGUIWindow::m_keyPushedCode, mrpt::gui::CBaseGUIWindow::m_keyPushedModifier, and mrpt::gui::MRPTKMOD_NONE.

◆ getWxObject()

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

Read-only access to the wxDialog object.

Definition at line 77 of file CBaseGUIWindow.h.

References mrpt::non_copiable_ptr_basic< T >::get(), and mrpt::gui::CBaseGUIWindow::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(), mrpt::opengl::COpenGLViewport::render(), and mrpt::opengl::COpenGLViewport::renderNormalSceneMode().

◆ internal_observer_begin()

void CObservable::internal_observer_begin ( CObserver o)
privateinherited

Definition at line 38 of file CObservable.cpp.

Referenced by mrpt::system::CObserver::observeBegin().

◆ internal_observer_end()

void CObservable::internal_observer_end ( CObserver o)
privateinherited

Definition at line 43 of file CObservable.cpp.

References ASSERTMSG_, MRPT_END, and MRPT_START.

◆ isOpen()

bool CBaseGUIWindow::isOpen ( )
inherited

◆ 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 139 of file CBaseGUIWindow.h.

References mrpt::gui::CBaseGUIWindow::m_keyPushed.

◆ notifyChildWindowDestruction()

void CBaseGUIWindow::notifyChildWindowDestruction ( )
inherited

Called by wx main thread to set m_hwnd to NULL.

Definition at line 148 of file CBaseGUIWindow.cpp.

References mrpt::gui::CBaseGUIWindow::m_hwnd.

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

◆ notifySemThreadReady()

void CBaseGUIWindow::notifySemThreadReady ( )
inherited

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 mrpt::gui::CBaseGUIWindow::m_threadReady.

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

◆ plot() [1/2]

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

◆ plot() [2/2]

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

◆ publishEvent()

void CObservable::publishEvent ( const mrptEvent e) const
protectedinherited

◆ resize()

void CDisplayWindow::resize ( unsigned int  width,
unsigned int  height 
)
overridevirtual

◆ setCursorCross()

void CDisplayWindow::setCursorCross ( bool  cursorIsCross)
overridevirtual

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

Implements mrpt::gui::CBaseGUIWindow.

Definition at line 334 of file CDisplayWindow.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), mrpt::gui::CBaseGUIWindow::m_hwnd, and win.

◆ setPos()

void CDisplayWindow::setPos ( int  x,
int  y 
)
overridevirtual

◆ setWindowTitle()

void CDisplayWindow::setWindowTitle ( const std::string &  str)
overridevirtual

◆ showImage()

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

◆ showImageAndPoints() [1/3]

template<class FEATURELIST >
void mrpt::gui::CDisplayWindow::showImageAndPoints ( const mrpt::img::CImage img,
const FEATURELIST &  list,
const mrpt::img::TColor color = mrpt::img::TColor::red(),
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 92 of file CDisplayWindow.h.

References mrpt::img::CImage::colorImage(), mrpt::img::CCanvas::drawFeatures(), MRPT_END, MRPT_START, and showImage().

◆ showImageAndPoints() [2/3]

void CDisplayWindow::showImageAndPoints ( const mrpt::img::CImage img,
const mrpt::math::CVectorFloat x,
const mrpt::math::CVectorFloat y,
const mrpt::img::TColor color = mrpt::img::TColor::red(),
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.

Definition at line 387 of file CDisplayWindow.cpp.

References mrpt::math::CVectorDynamic< T >::size().

Referenced by showTiledImageAndPoints().

◆ showImageAndPoints() [3/3]

void mrpt::gui::CDisplayWindow::showImageAndPoints ( const mrpt::img::CImage img,
const std::vector< float > &  x,
const std::vector< float > &  y,
const mrpt::img::TColor color = mrpt::img::TColor::red(),
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::img::CImage img1,
const mrpt::img::CImage img2,
const FEATURELIST &  leftList,
const FEATURELIST &  rightList,
const mrpt::img::TColor color = mrpt::img::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 188 of file CDisplayWindow.h.

References ASSERT_, mrpt::img::CImage::getWidth(), MRPT_END, MRPT_START, mrpt::round(), and showImage().

◆ showImagesAndMatchedPoints() [2/2]

template<class MATCHEDLIST >
void mrpt::gui::CDisplayWindow::showImagesAndMatchedPoints ( const mrpt::img::CImage img1,
const mrpt::img::CImage img2,
const MATCHEDLIST &  mList,
const mrpt::img::TColor color = mrpt::img::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 139 of file CDisplayWindow.h.

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

◆ showTiledImageAndPoints()

template<class FEATURELIST >
void mrpt::gui::CDisplayWindow::showTiledImageAndPoints ( const mrpt::img::CImage img,
const FEATURELIST &  list,
const mrpt::img::TColor color = mrpt::img::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 110 of file CDisplayWindow.h.

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

◆ waitForKey()

int CBaseGUIWindow::waitForKey ( bool  ignoreControlKeys = true,
mrptKeyModifier out_pushModifier = nullptr 
)
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 !=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 152 of file CBaseGUIWindow.cpp.

References mrpt::system::os::getch(), mrpt::gui::CBaseGUIWindow::isOpen(), mrpt::system::os::kbhit(), mrpt::gui::CBaseGUIWindow::m_keyPushed, mrpt::gui::CBaseGUIWindow::m_keyPushedCode, mrpt::gui::CBaseGUIWindow::m_keyPushedModifier, and mrpt::gui::MRPTKMOD_NONE.

Member Data Documentation

◆ m_caption

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

◆ m_CMD_CREATE_WIN

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

can be 200,300,400...

See WxSubsystem

Definition at line 48 of file CBaseGUIWindow.h.

Referenced by mrpt::gui::CBaseGUIWindow::createWxWindow().

◆ m_CMD_DESTROY_WIN

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

can be 299,399,499...

See WxSubsystem

Definition at line 50 of file CBaseGUIWindow.h.

Referenced by mrpt::gui::CBaseGUIWindow::destroyWxWindow().

◆ m_enableCursorCoordinates

bool mrpt::gui::CDisplayWindow::m_enableCursorCoordinates {true}
protected

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

Definition at line 43 of file CDisplayWindow.h.

Referenced by enableCursorCoordinatesVisualization().

◆ m_hwnd

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

◆ m_keyPushed

std::atomic_bool mrpt::gui::CBaseGUIWindow::m_keyPushed = false
protectedinherited

◆ m_keyPushedCode

std::atomic_int mrpt::gui::CBaseGUIWindow::m_keyPushedCode = 0
protectedinherited

◆ m_keyPushedModifier

std::atomic<mrptKeyModifier> mrpt::gui::CBaseGUIWindow::m_keyPushedModifier
protectedinherited

◆ m_subscribers

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

Definition at line 40 of file CObservable.h.

Referenced by mrpt::system::CObservable::hasSubscribers().

◆ m_threadReady

std::promise<void> mrpt::gui::CBaseGUIWindow::m_threadReady
mutableprotectedinherited

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

Definition at line 56 of file CBaseGUIWindow.h.

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

◆ m_windowDestroyed

std::promise<void> mrpt::gui::CBaseGUIWindow::m_windowDestroyed
mutableprotectedinherited

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

Definition at line 58 of file CBaseGUIWindow.h.

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

◆ m_winobj_voidptr

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



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 23:51:15 UTC 2020