MouseInterface.hh 7.97 KB
 Jan Möbius committed Aug 05, 2009 1 /*===========================================================================*\  Jan Möbius committed Nov 25, 2010 2 3 * * * OpenFlipper *  Martin Schultz committed Jul 16, 2015 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38  * Copyright (c) 2001-2015, RWTH-Aachen University * * Department of Computer Graphics and Multimedia * * All rights reserved. * * www.openflipper.org * * * *---------------------------------------------------------------------------* * This file is part of OpenFlipper. * *---------------------------------------------------------------------------* * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted provided that the following conditions * * are met: * * * * 1. Redistributions of source code must retain the above copyright notice, * * this list of conditions and the following disclaimer. * * * * 2. 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. * * * * 3. Neither the name of the copyright holder 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 HOLDER * * 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. *  Jan Möbius committed Nov 25, 2010 39 * *  Jan Möbius committed Aug 05, 2009 40 41 42 \*===========================================================================*/ /*===========================================================================*\  Jan Möbius committed Nov 25, 2010 43 44 45 46 47 * * * $Revision$ * * $LastChangedBy$ * * $Date$ * * *  Jan Möbius committed Aug 05, 2009 48 \*===========================================================================*/  Jan Möbius committed Aug 29, 2008 49 50   Jan Möbius committed Jan 14, 2009 51 52 #ifndef MOUSEINTERFACE_HH #define MOUSEINTERFACE_HH  Jan Möbius committed Aug 29, 2008 53   Matthias Möller committed Jul 19, 2013 54 55 56 57 58 59  #if QT_VERSION >= 0x050000 #include #else #include #endif  Jan Möbius committed Mar 01, 2011 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74  /** \file MouseInterface.hh * * Interface for registering types in OpenFlipper. \ref mouseInterfacePage */ /** \brief Interface class for receiving mouse events * * \n * \ref mouseInterfacePage "Detailed description" * \n * */  Jan Möbius committed Aug 29, 2008 75 class MouseInterface {  Jan Möbius committed Jan 14, 2009 76   Jan Möbius committed Aug 29, 2008 77  private slots :  Jan Möbius committed Jan 14, 2009 78   Jan Möbius committed Apr 11, 2012 79  /** \brief Wheel Event from main application  Jan Möbius committed Jan 14, 2009 80  *  Jan Möbius committed Apr 11, 2012 81  * This slot is called if a wheel event occurred in the Viewer and is extended by  Jan Möbius committed Aug 29, 2008 82  * the current Mode set in the Viewer. You can add additional Picking Modes to  Jan Möbius committed Jan 14, 2009 83  * the Viewer by using the picking interface.  Jan Möbius committed Aug 29, 2008 84  * This slot will only get called in pickingMode.  Jan Möbius committed Apr 11, 2012 85  * @param _event Mouse event  Jan Möbius committed Aug 29, 2008 86 87  * @param _mode Name of the current Picking Mode. */  Jan Möbius committed Mar 15, 2011 88  virtual void slotMouseWheelEvent(QWheelEvent * _event, const std::string & _mode) {};  Jan Möbius committed Jan 14, 2009 89   Jan Möbius committed Apr 11, 2012 90  /** \brief Mouse Event from main application ( Picking Mode )  Jan Möbius committed Jan 14, 2009 91  *  Jan Möbius committed Apr 11, 2012 92  * This slot is called if a mouse event occurred in the Viewer  Jan Möbius committed Jan 14, 2009 93  * This slot will only get called in pickingMode.  Jan Möbius committed Aug 29, 2008 94  * Right button clicks will not be passed to the plugins as this is reserved for  Jan Möbius committed Jan 14, 2009 95 96  * the context Menu. *  Jan Möbius committed Apr 11, 2012 97  * @param _event Mouse event  Jan Möbius committed Aug 29, 2008 98  */  Jan Möbius committed Mar 15, 2011 99  virtual void slotMouseEvent( QMouseEvent* _event ) {};  Jan Möbius committed Jul 09, 2010 100   Jan Möbius committed Apr 11, 2012 101  /** \brief Mouse Event from main application ( Light Mode )  Jan Möbius committed Jul 09, 2010 102  *  Jan Möbius committed Apr 11, 2012 103  * This slot is called if a mouse event occurred in the Viewer  Jan Möbius committed Jul 09, 2010 104 105 106 107  * This slot will only get called in LightMode. * Right button clicks will not be passed to the plugins as this is reserved for * the context Menu. *  Jan Möbius committed Apr 11, 2012 108  * @param _event Mouse event  Jan Möbius committed Jul 09, 2010 109  */  Jan Möbius committed Mar 15, 2011 110  virtual void slotMouseEventLight( QMouseEvent* _event ) {};  Jan Möbius committed Jan 14, 2009 111 112 113  public :  Jan Möbius committed Aug 29, 2008 114 115  /// Destructor virtual ~MouseInterface() {};  Jan Möbius committed Jan 14, 2009 116   Jan Möbius committed Aug 29, 2008 117 118 };  Jan Möbius committed Mar 01, 2011 119 120 121 122 123 124 125 126 127 128 129 /** \page mouseInterfacePage Mouse Interface \n \image html mouseInterface.png \n The mouse interface can be used to receive mouse events which occur in the glViewer. There are 4 main viewer modes:
• Move Mode events are never passed to one of the plugins and is only used for scene navigation  Jan Möbius committed Mar 02, 2015 130 131 132 133 inside the viewers.
•  Jan Möbius committed Mar 01, 2011 134 135 136 137 
You can add handlers for these mouse events in your plugin. Remember that all plugins receive these signals.\n  Jan Möbius committed Mar 16, 2011 138 139 140 The picking action is only a global mode which is divided into several other picking modes that can be managed through the PickingInterface. If you react on mouse events, you should check if the current picking mode is yours and of course define such a mode for your plugin.  Jan Möbius committed Mar 01, 2011 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 \code void MousePlugin::slotMouseEvent(QMouseEvent* _event) { // Check if your pick mode is currently active if ( PluginFunctions::pickMode() == "YourPickMode" && PluginFunctions::actionMode() == Viewer::PickingMode ) { // If double click has been performed if (_event->type() == QEvent::MouseButtonDblClick) { unsigned int node_idx, target_idx; OpenMesh::Vec3d hitPoint; // Get picked object's identifier by picking in scenegraph if ( PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_ANYTHING,_event->pos(), node_idx, target_idx, &hitPoint) ) { BaseObjectData* object; // Get picked object if ( PluginFunctions::getPickedObject(node_idx, object) ) { // Do something with the object } } } } } \endcode See our tutorial \ref ex3 for an example of how to use mouse and keyboard events within a plugin. To use the MouseInterface:
*/  Jan Möbius committed Aug 29, 2008 185 Q_DECLARE_INTERFACE(MouseInterface,"OpenFlipper.MouseInterface/1.0")  Jan Möbius committed Jan 14, 2009 186   Jan Möbius committed Aug 29, 2008 187 #endif // MOUSEINTERFACE_HH