mouse_event.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2011, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#pragma once
#include <pcl/visualization/keyboard_event.h>
namespace pcl
{
namespace visualization
{
class MouseEvent
{
public:
enum Type
{
MouseMove = 1,
MouseButtonPress,
MouseButtonRelease,
MouseScrollDown,
MouseScrollUp,
MouseDblClick
};
enum MouseButton
{
NoButton = 0,
LeftButton,
MiddleButton,
RightButton,
VScroll /*other buttons, scroll wheels etc. may follow*/
};
/** Constructor.
* \param[in] type event type
* \param[in] button The Button that causes the event
* \param[in] x x position of mouse pointer at that time where event got fired
* \param[in] y y position of mouse pointer at that time where event got fired
* \param[in] alt whether the ALT key was pressed at that time where event got fired
* \param[in] ctrl whether the CTRL key was pressed at that time where event got fired
* \param[in] shift whether the Shift key was pressed at that time where event got fired
* \param[in] selection_mode whether we are in selection mode
*/
inline MouseEvent (const Type& type, const MouseButton& button,
unsigned int x, unsigned int y,
bool alt, bool ctrl, bool shift,
bool selection_mode = false);
/**
* \return type of mouse event
*/
inline const Type&
getType () const;
/**
* \brief Sets the mouse event type
*/
inline void
setType (const Type& type);
/**
* \return the Button that caused the action
*/
inline const MouseButton&
getButton () const;
/** \brief Set the button that caused the event */
inline void
setButton (const MouseButton& button);
/**
* \return the x position of the mouse pointer at that time where the event got fired
*/
inline unsigned int
getX () const;
/**
* \return the y position of the mouse pointer at that time where the event got fired
*/
inline unsigned int
getY () const;
/**
* \return returns the keyboard modifiers state at that time where the event got fired
*/
inline unsigned int
getKeyboardModifiers () const;
/**
* \return selection mode status
*/
inline bool
getSelectionMode () const;
protected:
Type type_;
MouseButton button_;
unsigned int pointer_x_;
unsigned int pointer_y_;
unsigned int key_state_;
bool selection_mode_;
};
MouseEvent::MouseEvent (const Type& type, const MouseButton& button,
unsigned x, unsigned y,
bool alt, bool ctrl, bool shift,
bool selection_mode)
: type_ (type)
, button_ (button)
, pointer_x_ (x)
, pointer_y_ (y)
, key_state_ (0)
, selection_mode_ (selection_mode)
{
if (alt)
key_state_ = KeyboardEvent::Alt;
if (ctrl)
key_state_ |= KeyboardEvent::Ctrl;
if (shift)
key_state_ |= KeyboardEvent::Shift;
}
const MouseEvent::Type&
MouseEvent::getType () const
{
return (type_);
}
void
MouseEvent::setType (const Type& type)
{
type_ = type;
}
const MouseEvent::MouseButton&
MouseEvent::getButton () const
{
return (button_);
}
void
MouseEvent::setButton (const MouseButton& button)
{
button_ = button;
}
unsigned int
MouseEvent::getX () const
{
return (pointer_x_);
}
unsigned int
MouseEvent::getY () const
{
return (pointer_y_);
}
unsigned int
MouseEvent::getKeyboardModifiers () const
{
return (key_state_);
}
bool
MouseEvent::getSelectionMode () const
{
return (selection_mode_);
}
} //namespace visualization
} //namespace pcl
pcl::visualization::MouseEvent::setType
void setType(const Type &type)
Sets the mouse event type.
Definition: mouse_event.h:167
pcl::visualization::MouseEvent::button_
MouseButton button_
Definition: mouse_event.h:132
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::visualization::MouseEvent::getSelectionMode
bool getSelectionMode() const
Definition: mouse_event.h:203
pcl::visualization::MouseEvent::MouseMove
Definition: mouse_event.h:52
pcl::visualization::MouseEvent::MouseScrollUp
Definition: mouse_event.h:56
pcl::visualization::MouseEvent::pointer_y_
unsigned int pointer_y_
Definition: mouse_event.h:134
pcl::visualization::MouseEvent::type_
Type type_
Definition: mouse_event.h:131
pcl::visualization::KeyboardEvent::Shift
static const unsigned int Shift
bit patter for the Shift key
Definition: keyboard_event.h:56
pcl::visualization::MouseEvent::Type
Type
Definition: mouse_event.h:50
pcl::visualization::MouseEvent::MouseButtonPress
Definition: mouse_event.h:53
pcl::visualization::MouseEvent::MiddleButton
Definition: mouse_event.h:64
pcl::visualization::MouseEvent::VScroll
Definition: mouse_event.h:66
pcl::visualization::MouseEvent::LeftButton
Definition: mouse_event.h:63
pcl::visualization::MouseEvent::MouseButtonRelease
Definition: mouse_event.h:54
pcl::visualization::MouseEvent::getType
const Type & getType() const
Definition: mouse_event.h:161
pcl::visualization::MouseEvent::getKeyboardModifiers
unsigned int getKeyboardModifiers() const
Definition: mouse_event.h:197
pcl::visualization::MouseEvent::MouseButton
MouseButton
Definition: mouse_event.h:60
pcl::visualization::MouseEvent::MouseDblClick
Definition: mouse_event.h:57
pcl::visualization::MouseEvent::MouseEvent
MouseEvent(const Type &type, const MouseButton &button, unsigned int x, unsigned int y, bool alt, bool ctrl, bool shift, bool selection_mode=false)
Constructor.
Definition: mouse_event.h:139
pcl::visualization::MouseEvent::NoButton
Definition: mouse_event.h:62
pcl::visualization::MouseEvent::key_state_
unsigned int key_state_
Definition: mouse_event.h:135
pcl::visualization::KeyboardEvent::Ctrl
static const unsigned int Ctrl
bit patter for the Control key
Definition: keyboard_event.h:54
pcl::visualization::KeyboardEvent::Alt
static const unsigned int Alt
bit patter for the ALT key
Definition: keyboard_event.h:52
pcl::visualization::MouseEvent
Definition: mouse_event.h:47
pcl::visualization::MouseEvent::pointer_x_
unsigned int pointer_x_
Definition: mouse_event.h:133
pcl::visualization::MouseEvent::getButton
const MouseButton & getButton() const
Definition: mouse_event.h:173
pcl::visualization::MouseEvent::MouseScrollDown
Definition: mouse_event.h:55
pcl::visualization::MouseEvent::setButton
void setButton(const MouseButton &button)
Set the button that caused the event.
Definition: mouse_event.h:179
pcl::visualization::MouseEvent::getY
unsigned int getY() const
Definition: mouse_event.h:191
pcl::visualization::MouseEvent::getX
unsigned int getX() const
Definition: mouse_event.h:185
pcl::visualization::MouseEvent::selection_mode_
bool selection_mode_
Definition: mouse_event.h:136
pcl::visualization::MouseEvent::RightButton
Definition: mouse_event.h:65