Create a GUI window and display plots with MATLAB-like interfaces and commands.
For a list of supported events with the observer/observable pattern, see the discussion in mrpt::gui::CBaseGUIWindow.
Definition at line 34 of file CDisplayWindowPlots.h.
#include <mrpt/gui/CDisplayWindowPlots.h>
Public Types | |
typedef void(* | TCallbackMenu) (int menuID, float cursor_x, float cursor_y, void *userParam) |
Type for the callback function used in setMenuCallback. | |
Public Member Functions | |
CDisplayWindowPlots (const std::string &windowCaption=std::string(), unsigned int initialWidth=350, unsigned int initialHeight=300) | |
Constructor. | |
virtual | ~CDisplayWindowPlots () |
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 | 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 | setWindowTitle (const std::string &str) MRPT_OVERRIDE |
Changes the window title text. | |
void | enableMousePanZoom (bool enabled) |
Enable/disable the feature of pan/zoom with the mouse (default=enabled) | |
template<typename T1 , typename T2 > | |
void | plot (const std::vector< T1 > &x, const std::vector< T2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY")) |
Adds a new layer with a 2D plot based on two vectors of X and Y points, using a MATLAB-like syntax. | |
template<typename T1 , typename Derived2 > | |
void | plot (const std::vector< T1 > &x, const Eigen::MatrixBase< Derived2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY")) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename Derived1 , typename T2 > | |
void | plot (const Eigen::MatrixBase< Derived1 > &x, const std::vector< T2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY")) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename Derived1 , typename Derived2 > | |
void | plot (const Eigen::MatrixBase< Derived1 > &x, const Eigen::MatrixBase< Derived2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY")) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename T > | |
void | plot (const std::vector< T > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY")) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename Derived > | |
void | plot (const Eigen::MatrixBase< Derived > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY")) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | axis (float x_min, float x_max, float y_min, float y_max, bool aspectRatioFix=false) |
Set the view area according to the passed coordinated. | |
void | axis_equal (bool enable=true) |
Enable/disable the fixed X/Y aspect ratio fix feature (default=disabled). | |
void | axis_fit (bool aspectRatioFix=false) |
Fix automatically the view area according to existing graphs. | |
template<typename T > | |
void GUI_IMPEXP | plotEllipse (const T mean_x, const T mean_y, const mrpt::math::CMatrixTemplateNumeric< T > &cov22, const float quantiles, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotEllipse"), bool showName=false) |
Plots a 2D ellipse given its mean, covariance matrix, and Each call to this function creates a new plot, unless the plot name coincides with an already existing plot: in this case the new values are used to update this existing layer (this also applies to using the default plot name). | |
template<typename T > | |
void GUI_IMPEXP | plotEllipse (const T mean_x, const T mean_y, const mrpt::math::CMatrixFixedNumeric< T, 2, 2 > &cov22, const float quantiles, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotEllipse"), bool showName=false) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | image (const utils::CImage &img, const float &x_left, const float &y_bottom, const float &x_width, const float &y_height, const std::string &plotName=std::string("image")) |
Adds a bitmap image layer. | |
void | clear () |
Remove all plot objects in the display. | |
void | clf () |
Remove all plot objects in the display (clear and clf do exactly the same). | |
void | hold_on () |
Enables keeping all the graphs, instead of overwritting them. | |
void | hold_off () |
Disables keeping all the graphs (this is the default behavior). | |
void | addPopupMenuEntry (const std::string &label, int menuID) |
Disables keeping all the graphs (this is the default behavior). | |
void | setMenuCallback (TCallbackMenu userFunction, void *userParam=NULL) |
Must be called to have a callback when the user selects one of the user-defined entries in the popup menu. | |
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 CDisplayWindowPlotsPtr | Create (const std::string &windowCaption, unsigned int initialWindowWidth=400, unsigned int initialWindowHeight=300) |
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 | internal_plot (mrpt::math::CVectorFloat &x, mrpt::math::CVectorFloat &y, const std::string &lineFormat, const std::string &plotName) |
template<typename VECTOR1 , typename VECTOR2 > | |
void | internal_plot_interface (const VECTOR1 &x, const VECTOR2 &y, const std::string &lineFormat, const std::string &plotName) |
template<typename VECTOR1 > | |
void | internal_plot_interface (const VECTOR1 &y, const std::string &lineFormat, const std::string &plotName) |
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_holdon |
Whether hold_on is enabled. | |
bool | m_holdon_just_disabled |
uint32_t | m_holdon_cnt |
Counter for hold_on. | |
TCallbackMenu | m_callback |
void * | m_callback_param |
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 |
Friends | |
class | CWindowDialogPlots |
RTTI stuff <br> | |
typedef CDisplayWindowPlotsPtr | SmartPtr |
static mrpt::utils::CLASSINIT | _init_CDisplayWindowPlots |
static mrpt::utils::TRuntimeClassId | classCDisplayWindowPlots |
static const mrpt::utils::TRuntimeClassId * | classinfo |
static const mrpt::utils::TRuntimeClassId * | _GetBaseClass () |
virtual const mrpt::utils::TRuntimeClassId * | GetRuntimeClass () const MRPT_OVERRIDE |
Returns information about the class of an object in runtime. | |
virtual mrpt::utils::CObject * | duplicate () const MRPT_OVERRIDE |
Returns a copy of the object, indepently of its class. | |
static mrpt::utils::CObject * | CreateObject () |
static CDisplayWindowPlotsPtr | Create () |
A typedef for the associated smart pointer
Definition at line 37 of file CDisplayWindowPlots.h.
typedef void(* mrpt::gui::CDisplayWindowPlots::TCallbackMenu) (int menuID, float cursor_x, float cursor_y, void *userParam) |
Type for the callback function used in setMenuCallback.
Definition at line 40 of file CDisplayWindowPlots.h.
mrpt::gui::CDisplayWindowPlots::CDisplayWindowPlots | ( | const std::string & | windowCaption = std::string() , |
unsigned int | initialWidth = 350 , |
||
unsigned int | initialHeight = 300 |
||
) |
Constructor.
|
virtual |
Destructor.
|
staticprotected |
void mrpt::gui::CDisplayWindowPlots::addPopupMenuEntry | ( | const std::string & | label, |
int | menuID | ||
) |
Disables keeping all the graphs (this is the default behavior).
label | The text that appears in the new popup menu item. |
menuID | Any positive number (0,1,..). Used to tell which menu was selected in the user callback. |
void mrpt::gui::CDisplayWindowPlots::axis | ( | float | x_min, |
float | x_max, | ||
float | y_min, | ||
float | y_max, | ||
bool | aspectRatioFix = false |
||
) |
Set the view area according to the passed coordinated.
void mrpt::gui::CDisplayWindowPlots::axis_equal | ( | bool | enable = true | ) |
Enable/disable the fixed X/Y aspect ratio fix feature (default=disabled).
void mrpt::gui::CDisplayWindowPlots::axis_fit | ( | bool | aspectRatioFix = false | ) |
Fix automatically the view area according to existing graphs.
void mrpt::gui::CDisplayWindowPlots::clear | ( | ) |
Remove all plot objects in the display.
|
inlineinherited |
Assure that "keyHit" will return false until the next pushed key.
Definition at line 127 of file CBaseGUIWindow.h.
|
inline |
Remove all plot objects in the display (clear and clf do exactly the same).
Definition at line 216 of file CDisplayWindowPlots.h.
|
inlineinherited |
|
static |
|
static |
Class factory returning a smart pointer.
|
static |
|
protectedinherited |
Must be called by child classes just within the constructor.
|
protectedinherited |
Must be called by child classes in their destructors. The code cannot be put into this class' destructor.
|
virtual |
Returns a copy of the object, indepently of its class.
Implements mrpt::utils::CObject.
|
inlineinherited |
void mrpt::gui::CDisplayWindowPlots::enableMousePanZoom | ( | bool | enabled | ) |
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
|
virtual |
Gets the last x,y pixel coordinates of the mouse.
Implements mrpt::gui::CBaseGUIWindow.
|
inherited |
Returns the latest pushed key, or 0 if there is no new key stroke.
out_pushModifier | If set to !=NULL, the modifiers of the key stroke will be saved here. |
|
virtual |
Returns information about the class of an object in runtime.
Reimplemented from mrpt::gui::CBaseGUIWindow.
|
inlineinherited |
Read-only access to the wxDialog object.
Definition at line 75 of file CBaseGUIWindow.h.
|
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.
void mrpt::gui::CDisplayWindowPlots::hold_off | ( | ) |
void mrpt::gui::CDisplayWindowPlots::hold_on | ( | ) |
void mrpt::gui::CDisplayWindowPlots::image | ( | const utils::CImage & | img, |
const float & | x_left, | ||
const float & | y_bottom, | ||
const float & | x_width, | ||
const float & | y_height, | ||
const std::string & | plotName = std::string("image") |
||
) |
Adds a bitmap image layer.
Each call to this function creates a new layer, unless the plot name coincides with an already existing plot: in this case the new values are used to update this existing layer (this also applies to using the default plot name).
|
privateinherited |
|
privateinherited |
|
protected |
|
inlineprotected |
Definition at line 53 of file CDisplayWindowPlots.h.
|
inlineprotected |
Definition at line 63 of file CDisplayWindowPlots.h.
|
inherited |
Returns false if the user has already closed the window.
|
inlineinherited |
Returns true if a key has been pushed, without blocking waiting for a new key being pushed.
Definition at line 122 of file CBaseGUIWindow.h.
|
inherited |
Called by wx main thread to set m_hwnd to NULL.
|
inherited |
Called by wx main thread to signal the semaphore that the wx window is built and ready.
|
inline |
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 149 of file CDisplayWindowPlots.h.
|
inline |
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 144 of file CDisplayWindowPlots.h.
|
inline |
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 142 of file CDisplayWindowPlots.h.
|
inline |
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 147 of file CDisplayWindowPlots.h.
|
inline |
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 140 of file CDisplayWindowPlots.h.
|
inline |
Adds a new layer with a 2D plot based on two vectors of X and Y points, using a MATLAB-like syntax.
Each call to this function creates a new plot, unless the plot name coincides with an already existing plot: in this case the X & Y points are used to update this existing layer (this also applies to using the default plot name). If "hold_on" is enabled, then every call will always create a new plot, even if no "plotName" is provided.
The lineFormat string is a combination of the following characters:
Line width:
Examples:
VECTOR | Can be std::vector<float/double> or mrpt::dynamicsize_vector<float/double> or a column/row Eigen::Matrix<> |
Definition at line 138 of file CDisplayWindowPlots.h.
void GUI_IMPEXP mrpt::gui::CDisplayWindowPlots::plotEllipse | ( | const T | mean_x, |
const T | mean_y, | ||
const mrpt::math::CMatrixFixedNumeric< T, 2, 2 > & | cov22, | ||
const float | quantiles, | ||
const std::string & | lineFormat = std::string("b-") , |
||
const std::string & | plotName = std::string("plotEllipse") , |
||
bool | showName = false |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void GUI_IMPEXP mrpt::gui::CDisplayWindowPlots::plotEllipse | ( | const T | mean_x, |
const T | mean_y, | ||
const mrpt::math::CMatrixTemplateNumeric< T > & | cov22, | ||
const float | quantiles, | ||
const std::string & | lineFormat = std::string("b-") , |
||
const std::string & | plotName = std::string("plotEllipse") , |
||
bool | showName = false |
||
) |
Plots a 2D ellipse given its mean, covariance matrix, and Each call to this function creates a new plot, unless the plot name coincides with an already existing plot: in this case the new values are used to update this existing layer (this also applies to using the default plot name).
If "hold_on" is enabled, then every call will always create a new plot, even if no "plotName" is provided.
For a description of lineFormat see CDisplayWindowPlots::plot. The "quantiles" value determines the confidence interval for the ellipse:
|
protectedinherited |
Called when you want this object to emit an event to all the observers currently subscribed to this object.
|
virtual |
Resizes the window, stretching the image to fit into the display area.
Implements mrpt::gui::CBaseGUIWindow.
|
virtual |
Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true)
Implements mrpt::gui::CBaseGUIWindow.
void mrpt::gui::CDisplayWindowPlots::setMenuCallback | ( | TCallbackMenu | userFunction, |
void * | userParam = NULL |
||
) |
Must be called to have a callback when the user selects one of the user-defined entries in the popup menu.
|
virtual |
Changes the position of the window on the screen.
Implements mrpt::gui::CBaseGUIWindow.
|
virtual |
Changes the window title text.
Implements mrpt::gui::CBaseGUIWindow.
|
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
ignoreControlKeys | If set to false, any push of shift, cmd, control, etc... will make this method to return. |
out_pushModifier | If set to !=NULL, the modifiers of the key stroke will be saved here. |
|
friend |
Definition at line 43 of file CDisplayWindowPlots.h.
|
staticprotected |
Definition at line 37 of file CDisplayWindowPlots.h.
|
staticinherited |
Definition at line 49 of file CBaseGUIWindow.h.
|
static |
Definition at line 37 of file CDisplayWindowPlots.h.
|
staticinherited |
|
static |
Definition at line 37 of file CDisplayWindowPlots.h.
|
protected |
Definition at line 48 of file CDisplayWindowPlots.h.
|
protected |
Definition at line 49 of file CDisplayWindowPlots.h.
|
protectedinherited |
The caption of the window.
Definition at line 63 of file CBaseGUIWindow.h.
|
privateinherited |
can be 200,300,400... See WxSubsystem
Definition at line 56 of file CBaseGUIWindow.h.
|
privateinherited |
can be 299,399,499... See WxSubsystem
Definition at line 57 of file CBaseGUIWindow.h.
|
protected |
Whether hold_on is enabled.
Definition at line 45 of file CDisplayWindowPlots.h.
|
protected |
Counter for hold_on.
Definition at line 47 of file CDisplayWindowPlots.h.
|
protected |
Definition at line 46 of file CDisplayWindowPlots.h.
|
protectedinherited |
The window handle.
Definition at line 64 of file CBaseGUIWindow.h.
|
protectedinherited |
Definition at line 67 of file CBaseGUIWindow.h.
|
protectedinherited |
Definition at line 68 of file CBaseGUIWindow.h.
|
protectedinherited |
Definition at line 69 of file CBaseGUIWindow.h.
|
protectedinherited |
This semaphore will be signaled when the wx window is built and ready.
Definition at line 61 of file CBaseGUIWindow.h.
|
protectedinherited |
This semaphore will be signaled when the wx window is destroyed.
Definition at line 62 of file CBaseGUIWindow.h.
|
privateinherited |
Definition at line 42 of file CObservable.h.
|
privateinherited |
Definition at line 58 of file CBaseGUIWindow.h.
Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Sat Jan 21 06:46:15 UTC 2023 |