MouseInterface.hh 6.99 KB
 Jan Möbius committed Aug 05, 2009 1 /*===========================================================================*\  Jan Möbius committed Nov 25, 2010 2 3 * * * OpenFlipper *  Jan Möbius committed Jan 26, 2011 4 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *  Jan Möbius committed Nov 25, 2010 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 * www.openflipper.org * * * *--------------------------------------------------------------------------- * * This file is part of OpenFlipper. * * * * OpenFlipper is free software: you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * * published by the Free Software Foundation, either version 3 of * * the License, or (at your option) any later version with the * * following exceptions: * * * * If other files instantiate templates or use macros * * or inline functions from this file, or you compile this file and * * link it with other files to produce an executable, this file does * * not by itself cause the resulting executable to be covered by the * * GNU Lesser General Public License. This exception does not however * * invalidate any other reasons why the executable file might be * * covered by the GNU Lesser General Public License. * * * * OpenFlipper is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Lesser General Public License for more details. * * * * You should have received a copy of the GNU LesserGeneral Public * * License along with OpenFlipper. If not, * * see . * * *  Jan Möbius committed Aug 05, 2009 33 34 35 \*===========================================================================*/ /*===========================================================================*\  Jan Möbius committed Nov 25, 2010 36 37 38 39 40 * * * $Revision$ * * $LastChangedBy$ * * $Date$ * * *  Jan Möbius committed Aug 05, 2009 41 \*===========================================================================*/  Jan Möbius committed Aug 29, 2008 42 43   Jan Möbius committed Jan 14, 2009 44 45 #ifndef MOUSEINTERFACE_HH #define MOUSEINTERFACE_HH  Jan Möbius committed Aug 29, 2008 46   Jan Möbius committed Mar 01, 2011 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 #include /** \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 63 class MouseInterface {  Jan Möbius committed Jan 14, 2009 64   Jan Möbius committed Aug 29, 2008 65  private slots :  Jan Möbius committed Jan 14, 2009 66   Jan Möbius committed Aug 29, 2008 67  /** \brief Wheel Event from Main App  Jan Möbius committed Jan 14, 2009 68  *  Jan Möbius committed Aug 29, 2008 69 70  * This slot is called if a wheel event occured in the Viewer and is extended by * the current Mode set in the Viewer. You can add additional Picking Modes to  Jan Möbius committed Jan 14, 2009 71  * the Viewer by using the picking interface.  Jan Möbius committed Aug 29, 2008 72 73 74 75  * This slot will only get called in pickingMode. * @param _event Mousevent * @param _mode Name of the current Picking Mode. */  Jan Möbius committed Mar 15, 2011 76  virtual void slotMouseWheelEvent(QWheelEvent * _event, const std::string & _mode) {};  Jan Möbius committed Jan 14, 2009 77   Jan Möbius committed Aug 29, 2008 78  /** \brief Mouse Event from Main App ( Picking Mode )  Jan Möbius committed Jan 14, 2009 79 80 81  * * This slot is called if a mouse event occured in the Viewer * This slot will only get called in pickingMode.  Jan Möbius committed Aug 29, 2008 82  * Right button clicks will not be passed to the plugins as this is reserved for  Jan Möbius committed Jan 14, 2009 83 84  * the context Menu. *  Jan Möbius committed Aug 29, 2008 85 86  * @param _event Mousevent */  Jan Möbius committed Mar 15, 2011 87  virtual void slotMouseEvent( QMouseEvent* _event ) {};  Jan Möbius committed Jul 09, 2010 88 89 90 91 92 93 94 95 96 97  /** \brief Mouse Event from Main App ( Light Mode ) * * This slot is called if a mouse event occured in the Viewer * 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. * * @param _event Mousevent */  Jan Möbius committed Mar 15, 2011 98  virtual void slotMouseEventLight( QMouseEvent* _event ) {};  Jan Möbius committed Jan 14, 2009 99 100 101  public :  Jan Möbius committed Aug 29, 2008 102 103  /// Destructor virtual ~MouseInterface() {};  Jan Möbius committed Jan 14, 2009 104   Jan Möbius committed Aug 29, 2008 105 106 };  Jan Möbius committed Mar 01, 2011 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 /** \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:
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 125 126 127 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 128 129 130 131 132 133 134 135 136 137 138 139 140 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 \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 172 Q_DECLARE_INTERFACE(MouseInterface,"OpenFlipper.MouseInterface/1.0")  Jan Möbius committed Jan 14, 2009 173   Jan Möbius committed Aug 29, 2008 174 #endif // MOUSEINTERFACE_HH