Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected 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 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::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. More...
 
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)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void showImage (const mrpt::utils::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::utils::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

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

Definition at line 34 of file CDisplayWindow.h.

◆ Ptr

Definition at line 33 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 369 of file CDisplayWindow.cpp.

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

Referenced by Create().

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

◆ ~CDisplayWindow()

CDisplayWindow::~CDisplayWindow ( )
virtual

Destructor.

Definition at line 381 of file CDisplayWindow.cpp.

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

Here is the call graph for this function:

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

Here is the call graph for this function:

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

References mrpt::utils::non_copiable_ptr_basic< T >::get(), mrpt::gui::CBaseGUIWindow::m_hwnd, mrpt::gui::CWindowDialog::m_image, mrpt::gui::CWindowDialog::wxMRPTImageControl::m_last_mouse_point, and MRPT_UNUSED_PARAM.

Here is the call graph for this function:

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

Here is the call graph for this function:

◆ getWxObject()

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

Read-only access to the wxDialog object.

Definition at line 81 of file CBaseGUIWindow.h.

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

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

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

◆ 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 57 of file CObservable.h.

References mrpt::utils::CObservable::m_subscribers.

Referenced by mrpt::gui::CWindowDialog::OnMouseDown(), mrpt::gui::CWindowDialog::OnMouseMove(), mrpt::gui::CWindowDialog::OnResize(), and mrpt::opengl::COpenGLViewport::render().

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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

Here is the caller graph for this function:

◆ plot() [1/2]

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

Plots a graph in MATLAB-like style.

Definition at line 488 of file CDisplayWindow.cpp.

References ASSERT_, mrpt::utils::CCanvas::cross(), mrpt::utils::CCanvas::filledRectangle(), mrpt::utils::CImage::line(), MRPT_END, MRPT_START, mrpt::utils::CImage::resize(), and showImage().

Here is the call graph for this function:

◆ plot() [2/2]

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

Plots a graph in MATLAB-like style.

Definition at line 541 of file CDisplayWindow.cpp.

References ASSERT_, mrpt::utils::CCanvas::cross(), mrpt::utils::CCanvas::filledRectangle(), mrpt::utils::CImage::line(), MRPT_END, MRPT_START, red, mrpt::utils::CImage::resize(), showImage(), and mrpt::utils::CCanvas::textOut().

Here is the call graph for this function:

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

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

Here is the call graph for this function:

◆ setPos()

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

◆ setWindowTitle()

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

◆ showImage()

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

◆ showImageAndPoints() [1/3]

void 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.

Definition at line 443 of file CDisplayWindow.cpp.

Referenced by showTiledImageAndPoints().

Here is the caller graph for this function:

◆ showImageAndPoints() [2/3]

void 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.

Definition at line 453 of file CDisplayWindow.cpp.

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:

◆ showImagesAndMatchedPoints() [2/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 188 of file CDisplayWindow.h.

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

Here is the call graph for this function:

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

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

Here is the call graph for this function:

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

Referenced by find_chessboard_corners_multiple(), and mrpt::vision::CFeature::internal_distanceBetweenPolarImages().

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

Member Data Documentation

◆ m_caption

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

◆ 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

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

◆ m_keyPushed

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

◆ 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 60 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 62 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: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019