Permalink
Browse files

New mrpt::gui event: mrptEventMouseMove

  • Loading branch information...
jlblancoc committed Oct 8, 2017
1 parent 45129df commit b1368883816288c13aee5802990678eeb474e2e6
@@ -18,6 +18,8 @@
- \ref mrpt_base_grp
- Fix potential uninitialized value in CRobot2DPoseEstimator::getLatestRobotPose()
- MRPT_getCompilationDate() returns time as well
- \ref mrpt_gui_grp
- mrpt::gui::mrptEventMouseMove: Added new mrpt::gui windows event type.
- Smart pointers:
- All mrpt::utils::CObject derived classes:
- In MRPT <=1.5.3, there was a typedef `Foo::SmartPtr` => `FooPtr`.
@@ -187,7 +187,7 @@ namespace mrpt
* IMPORTANTE NOTICE: Event handlers in your observer class will be invoked from the wxWidgets internal MRPT thread,
* so all your code in the handler must be thread safe.
*
* \sa mrptEventMouseDown
* \sa mrptEventMouseMove
*/
class GUI_IMPEXP mrptEventMouseDown : public mrpt::utils::mrptEvent
{
@@ -208,6 +208,30 @@ namespace mrpt
bool rightButton;
}; // End of class def.
/** An event sent by a window when the mouse is moved over it.
* IMPORTANTE NOTICE: Event handlers in your observer class will be invoked from the wxWidgets internal MRPT thread,
* so all your code in the handler must be thread safe.
* \sa mrptEventMouseDown
*/
class GUI_IMPEXP mrptEventMouseMove : public mrpt::utils::mrptEvent
{
protected:
virtual void do_nothing() MRPT_OVERRIDE { } //!< Just to allow this class to be polymorphic
public:
inline mrptEventMouseMove(
CBaseGUIWindow *obj,
mrpt::utils::TPixelCoord _coords,
bool _leftButton,
bool _rightButton
) : source_object(obj), coords(_coords), leftButton(_leftButton), rightButton(_rightButton)
{ }
CBaseGUIWindow *source_object;
mrpt::utils::TPixelCoord coords;
bool leftButton;
bool rightButton;
}; // End of class def.
/** An event sent by a window upon when it's about to be closed, either manually by the user or programatically.
* The event field member \a allow_close is default by default, but can be set to false in the event callback
* to forbid the window to be closed by the user. If the event corresponds to a programatic close, this field is ignored.
@@ -341,6 +341,7 @@ namespace mrpt
void OnKeyDown(wxKeyEvent& event);
void OnResize(wxSizeEvent& event);
void OnMouseDown(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event);
DECLARE_EVENT_TABLE()
}; // end class CWindowDialog
@@ -185,6 +185,7 @@ CWindowDialog::CWindowDialog(
m_image->Connect(wxEVT_LEFT_DOWN,(wxObjectEventFunction)&CWindowDialog::OnMouseDown,NULL,this);
m_image->Connect(wxEVT_RIGHT_DOWN,(wxObjectEventFunction)&CWindowDialog::OnMouseDown,NULL,this);
m_image->Connect(wxEVT_MOTION, (wxObjectEventFunction)&CWindowDialog::OnMouseMove, NULL, this);
// Increment number of windows:
//int winCount =
@@ -249,7 +250,7 @@ void CWindowDialog::OnChar(wxKeyEvent& event)
void CWindowDialog::OnResize(wxSizeEvent& event)
{
// Send the event:
if (m_win2D)
if (m_win2D && m_win2D->hasSubscribers())
{
try {
m_win2D->publishEvent( mrptEventWindowResize(m_win2D,event.GetSize().GetWidth(),event.GetSize().GetHeight()));
@@ -261,7 +262,7 @@ void CWindowDialog::OnResize(wxSizeEvent& event)
void CWindowDialog::OnMouseDown(wxMouseEvent& event)
{
// Send the event:
if (m_win2D)
if (m_win2D && m_win2D->hasSubscribers())
{
try {
m_win2D->publishEvent( mrptEventMouseDown(m_win2D, TPixelCoord(event.GetX(), event.GetY()), event.LeftDown(), event.RightDown() ) );
@@ -270,6 +271,19 @@ void CWindowDialog::OnMouseDown(wxMouseEvent& event)
event.Skip(); // so it's processed by the wx system!
}
void CWindowDialog::OnMouseMove(wxMouseEvent& event)
{
// Send the event:
if (m_win2D && m_win2D->hasSubscribers())
{
try {
m_win2D->publishEvent(mrptEventMouseMove(m_win2D, TPixelCoord(event.GetX(), event.GetY()), event.LeftDown(), event.RightDown()));
}
catch (...) {}
}
event.Skip(); // so it's processed by the wx system!
}
// Menu: Close
void CWindowDialog::OnMenuClose(wxCommandEvent& event)
@@ -86,6 +86,7 @@ namespace mrpt
void OnCharCustom( wxKeyEvent& event );
void OnMouseDown(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event);
void OnPreRender();
void OnPostRender();
@@ -108,6 +109,7 @@ CMyGLCanvas_DisplayWindow3D::CMyGLCanvas_DisplayWindow3D(
Connect(wxEVT_LEFT_DOWN,(wxObjectEventFunction)&CMyGLCanvas_DisplayWindow3D::OnMouseDown);
Connect(wxEVT_RIGHT_DOWN,(wxObjectEventFunction)&CMyGLCanvas_DisplayWindow3D::OnMouseDown);
Connect(wxEVT_MOTION, (wxObjectEventFunction)&CMyGLCanvas_DisplayWindow3D::OnMouseMove);
}
void CMyGLCanvas_DisplayWindow3D::display3D_processKeyEvent(CDisplayWindow3D *m_win3D, wxKeyEvent&ev)
@@ -155,7 +157,7 @@ void CMyGLCanvas_DisplayWindow3D::OnCharCustom( wxKeyEvent& ev )
void CMyGLCanvas_DisplayWindow3D::OnMouseDown(wxMouseEvent& event)
{
// Send the event:
if (m_win3D)
if (m_win3D && m_win3D->hasSubscribers())
{
try {
m_win3D->publishEvent( mrptEventMouseDown(m_win3D, TPixelCoord(event.GetX(), event.GetY()), event.LeftDown(), event.RightDown() ) );
@@ -165,6 +167,19 @@ void CMyGLCanvas_DisplayWindow3D::OnMouseDown(wxMouseEvent& event)
event.Skip(); // so it's processed by the wx system!
}
void CMyGLCanvas_DisplayWindow3D::OnMouseMove(wxMouseEvent& event)
{
// Send the event:
if (m_win3D && m_win3D->hasSubscribers())
{
try {
m_win3D->publishEvent(mrptEventMouseMove(m_win3D, TPixelCoord(event.GetX(), event.GetY()), event.LeftDown(), event.RightDown()));
}
catch (...) {}
}
event.Skip(); // so it's processed by the wx system!
}
CMyGLCanvas_DisplayWindow3D::~CMyGLCanvas_DisplayWindow3D()
{
@@ -265,7 +265,17 @@ void CWindowDialogPlots::OnMouseMove(wxMouseEvent& event)
m_curCursorPos.y = m_plot->p2y(Y);
m_last_mouse_point.x = X;
m_last_mouse_point.y = Y;
event.Skip();
// Send the event:
if (m_winPlots && m_winPlots->hasSubscribers())
{
try {
m_winPlots->publishEvent(mrptEventMouseMove(m_winPlots, TPixelCoord(event.GetX(), event.GetY()), event.LeftDown(), event.RightDown()));
}
catch (...) {}
}
event.Skip(); // so it's processed by the wx system!
}
// Add / Modify a 2D plot using a MATLAB-like format string

0 comments on commit b136888

Please sign in to comment.