MRPT  1.9.9
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 30 of file CDisplayWindow.h.

#include <mrpt/gui/CDisplayWindow.h>

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

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...
 
virtual ~CDisplayWindow ()
 Destructor. More...
 
virtual bool getLastMousePosition (int &x, int &y) const override
 Gets the last x,y pixel coordinates of the mouse. More...
 
virtual 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(), const 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(), const bool &showNumbers=false)
 
template<class FEATURELIST >
void showImageAndPoints (const mrpt::img::CImage &img, const FEATURELIST &list, const mrpt::img::TColor &color=mrpt::img::TColor::red(), const 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...
 
voidgetWxObject ()
 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
 Enables or disables the visualization of cursor coordinates on the window caption. More...
 
std::promise< voidm_threadReady
 This semaphore will be signaled when the wx window is built and ready. More...
 
std::promise< voidm_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...
 
volatile bool m_keyPushed
 
volatile int m_keyPushedCode
 
volatile mrptKeyModifier m_keyPushedModifier
 

Member Typedef Documentation

◆ ConstPtr

◆ Ptr

Constructor & Destructor Documentation

◆ CDisplayWindow()

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

Constructor.

Definition at line 369 of file CDisplayWindow.cpp.

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

Referenced by Create().

◆ ~CDisplayWindow()

CDisplayWindow::~CDisplayWindow ( )
virtual

Destructor.

Definition at line 381 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

Class factory returning a smart pointer.

Definition at line 359 of file CDisplayWindow.cpp.

References CDisplayWindow().

◆ createWxWindow()

◆ destroyWxWindow()

◆ 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 399 of file CDisplayWindow.cpp.

References mrpt::non_copiable_ptr_basic< T >::get(), mrpt::gui::CBaseGUIWindow::m_hwnd, MRPT_UNUSED_PARAM, 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 190 of file CBaseGUIWindow.cpp.

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

◆ isOpen()

◆ 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 152 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 217 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]

◆ publishEvent()

◆ resize()

◆ 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 384 of file CDisplayWindow.cpp.

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

◆ setPos()

◆ setWindowTitle()

◆ showImage()

◆ showImageAndPoints() [1/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(),
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.

Definition at line 443 of file CDisplayWindow.cpp.

Referenced by showTiledImageAndPoints().

◆ showImageAndPoints() [2/3]

void 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(),
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.

Definition at line 453 of file CDisplayWindow.cpp.

References ASSERT_, MRPT_END, MRPT_START, MRPT_UNUSED_PARAM, mrpt::round(), showImage(), and mrpt::system::os::sprintf().

◆ showImageAndPoints() [3/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(),
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 89 of file CDisplayWindow.h.

References CH_RGB, MRPT_END, MRPT_START, and showImage().

◆ showImagesAndMatchedPoints() [1/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 138 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().

◆ showImagesAndMatchedPoints() [2/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().

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

References 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 156 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

◆ m_enableCursorCoordinates

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

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

Definition at line 40 of file CDisplayWindow.h.

Referenced by enableCursorCoordinatesVisualization().

◆ m_hwnd

◆ m_keyPushed

◆ m_keyPushedCode

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

◆ m_keyPushedModifier

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

◆ 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().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020