mouse_event.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2011, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  */
00038 
00039 #ifndef PCL_VISUALIZATION_MOUSE_EVENT_H_
00040 #define PCL_VISUALIZATION_MOUSE_EVENT_H_
00041 
00042 #include <pcl/visualization/keyboard_event.h>
00043 
00044 namespace pcl
00045 {
00046   namespace visualization
00047   {
00048     class MouseEvent
00049     {
00050       public:
00051         typedef enum
00052         {
00053           MouseMove = 1,
00054           MouseButtonPress,
00055           MouseButtonRelease,
00056           MouseScrollDown,
00057           MouseScrollUp,
00058           MouseDblClick
00059         } Type;
00060 
00061         typedef enum
00062         {
00063           NoButton      = 0,
00064           LeftButton,
00065           MiddleButton,
00066           RightButton,
00067           VScroll /*other buttons, scroll wheels etc. may follow*/
00068         } MouseButton;
00069 
00080         inline MouseEvent (const Type& type, const MouseButton& button, 
00081                            unsigned int x, unsigned int y, 
00082                            bool alt, bool ctrl, bool shift,
00083                            bool selection_mode = false);
00084 
00088         inline const Type& 
00089         getType () const;
00090 
00094         inline void 
00095         setType (const Type& type);
00096         
00100         inline const MouseButton& 
00101         getButton () const;
00102 
00104         inline void 
00105         setButton (const MouseButton& button);
00106 
00110         inline unsigned int 
00111         getX () const;
00112 
00116         inline unsigned int 
00117         getY () const;
00118 
00122         inline unsigned int 
00123         getKeyboardModifiers () const;
00124 
00128         inline bool
00129         getSelectionMode () const;
00130 
00131       protected:
00132         Type type_;
00133         MouseButton button_;
00134         unsigned int pointer_x_;
00135         unsigned int pointer_y_;
00136         unsigned int key_state_;
00137         bool selection_mode_;
00138     };
00139 
00140     MouseEvent::MouseEvent (const Type& type, const MouseButton& button,
00141                             unsigned x, unsigned y, 
00142                             bool alt, bool ctrl, bool shift,
00143                             bool selection_mode)
00144     : type_ (type)
00145     , button_ (button)
00146     , pointer_x_ (x)
00147     , pointer_y_ (y)
00148     , key_state_ (0)
00149     , selection_mode_ (selection_mode)
00150     {
00151       if (alt)
00152         key_state_ = KeyboardEvent::Alt;
00153 
00154       if (ctrl)
00155         key_state_ |= KeyboardEvent::Ctrl;
00156 
00157       if (shift)
00158         key_state_ |= KeyboardEvent::Shift;
00159     }
00160 
00161     const MouseEvent::Type& 
00162     MouseEvent::getType () const
00163     {
00164       return (type_);
00165     }
00166 
00167     void 
00168     MouseEvent::setType (const Type& type)
00169     {
00170       type_ = type;
00171     }
00172     
00173     const MouseEvent::MouseButton& 
00174     MouseEvent::getButton () const
00175     {
00176       return (button_);
00177     }
00178 
00179     void 
00180     MouseEvent::setButton (const MouseButton& button)
00181     {
00182       button_ = button;
00183     }
00184     
00185     unsigned int 
00186     MouseEvent::getX () const
00187     {
00188       return (pointer_x_);
00189     }
00190 
00191     unsigned int 
00192     MouseEvent::getY () const
00193     {
00194       return (pointer_y_);
00195     }
00196 
00197     unsigned int 
00198     MouseEvent::getKeyboardModifiers () const
00199     {
00200       return (key_state_);
00201     }
00202 
00203     bool
00204     MouseEvent::getSelectionMode () const
00205     {
00206       return (selection_mode_);
00207     }
00208 
00209   } //namespace visualization
00210 } //namespace pcl
00211 
00212 #endif  /* PCL_VISUALIZATION_MOUSE_EVENT_H_ */
00213 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:25:40