ToolboxInterface.hh 6.74 KB
 Jan Möbius committed Aug 05, 2009 1 /*===========================================================================*\  Jan Möbius committed Nov 25, 2010 2 3 * * * OpenFlipper *  Jan Möbius committed Feb 05, 2014 4 * Copyright (C) 2001-2014 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   Jan Möbius committed Feb 22, 2011 43 44 #ifndef TOOLBOXINTERFACE_HH #define TOOLBOXINTERFACE_HH  Jan Möbius committed Aug 29, 2008 45   Matthias Möller committed Jul 19, 2013 46 47 48 49 50 51 52  #if QT_VERSION >= 0x050000 #include #else #include #endif  Jan Möbius committed Feb 22, 2011 53 54 55 #include #include #include  Jan Möbius committed Aug 29, 2008 56   Jan Möbius committed Feb 22, 2011 57 58 59 60 /** \file ToolboxInterface.hh * * Interface for adding per plugin toolboxes to OpenFlippers UI.\ref toolboxInterfacePage */  Jan Möbius committed Aug 29, 2008 61   Jan Möbius committed Feb 22, 2011 62   Jan Möbius committed Aug 29, 2008 63  /**  Mike Kremer committed Feb 04, 2009 64  * \brief Plugins can add its own toolbox to the main widget's toolbox area by using this interface.  Jan Möbius committed Mar 06, 2009 65  *  Jan Möbius committed Feb 22, 2011 66 67 68 69  * \ref toolboxInterfacePage "Detailed description" * \n * * This Interface can be used by plugins which will provide a toolbox widget.  Jan Möbius committed Feb 25, 2011 70  * Each Plugin can create own Widgets in the toolbox area. Just create your widget and then add it with \n  Jan Möbius committed Oct 01, 2009 71  * emit addToolbox( QString _name , QWidget* _widget ) \n  Jan Möbius committed Feb 22, 2011 72 73  * to the user interface. You can create extra signals and slots in your Plugin. * These can be connected between your toolbox and your plugin.\n  Mike Kremer committed Mar 26, 2009 74 75 76  * * See our tutorials \ref ex2 and \ref ex3 for an example of to add custom toolboxes to * OpenFlipper.  Mike Kremer committed Feb 04, 2009 77  */  Jan Möbius committed Aug 29, 2008 78 79 80 81 82 83 84 85 86 87 class ToolboxInterface { private slots : public : /// Destructor virtual ~ToolboxInterface() {}; signals :  Dirk Wilden committed Jan 05, 2011 88   Jan Möbius committed Mar 06, 2009 89 90  /** \brief Add a toolbox widget to the gui with the given name *  Jan Möbius committed Feb 25, 2011 91  * This signal adds a toolbox widget to the toolbox area on the right.  Jan Möbius committed Feb 24, 2011 92 93 94  * * @param _name Visible name of the toolbox * @param _widget Pointer to the toolbox widget  Jan Möbius committed Mar 06, 2009 95  */  Jan Möbius committed Feb 24, 2011 96  virtual void addToolbox( QString _name , QWidget* _widget ) {};  Jan Möbius committed Mar 06, 2009 97   Jan Möbius committed Jan 06, 2011 98  /** \brief Add a toolbox widget to the gui with the given name and an icon  Dirk Wilden committed Jan 05, 2011 99  *  Jan Möbius committed Feb 25, 2011 100  * This signal adds a toolbox widget to the toolbox area on the right. And sets an icon for it  Jan Möbius committed Feb 24, 2011 101 102 103 104  * * @param _name Visible name of the toolbox * @param _widget Pointer to the toolbox widget * @param _icon Icon for the toolbox  Dirk Wilden committed Jan 05, 2011 105  */  Jan Möbius committed Feb 24, 2011 106  virtual void addToolbox( QString _name , QWidget* _widget, QIcon* _icon) {};  Jan Möbius committed Aug 29, 2008 107 108 };  109 110 111 112 113 114  /** \page toolboxInterfacePage Toolbox Interface \image html ToolboxInterface.png The ToolboxInterface can be used by plugins to add widgets to the list of toolboxes in OpenFlippers  Jan Möbius committed Feb 25, 2011 115 UI. The toolboxes are located left or right of the GL viewer (See image).  116 117 118 119 120 121 122 123 124 125 126  The list can be hidden by pressing Ctrl + t. To use the ToolboxInterface:
 Jan Möbius committed Feb 24, 2011 127 Usually you should implement the BaseInterface::pluginsInitialized() function from BaseInterface. In this function you can setup  Jan Möbius committed Feb 25, 2011 128 your toolbox ( some kind of QWidget, can also be any widget created with QT-designer). Optionally you can also  129 130 131 132 add an icon to the toolbox. The following code shows a simple example to create an empty toolbox. \code  Jan Möbius committed Feb 25, 2011 133 void ExamplePlugin::pluginsInitialized()  134 135 136 137 138 { // Create the Toolbox Widget QWidget* toolBox = new QWidget(); // Create an icon which is shown along with the toolbox  Jan Möbius committed Feb 25, 2011 139  QIcon* toolIcon = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"exampleIcon.png");  140 141  // Tell the core to include the new toolbox widget with the name Simple Smoother, a pointer to the widget and a pointer to the icon  Jan Möbius committed Feb 25, 2011 142  emit addToolbox( tr("Example Plugin Toolbox") , toolBox, toolIcon );  143 144 145 146 147 148 149 150 } \endcode Signals and slots of your toolbox (e.g. from a QPushButton inside it) can be directly connected to signals and slots in your plugin. Therefore the embedding of the widget into the toolbox list is fully transparent. */  Dirk Wilden committed Feb 25, 2009 151 Q_DECLARE_INTERFACE(ToolboxInterface,"OpenFlipper.ToolboxInterface/1.1")  Jan Möbius committed Aug 29, 2008 152 153  #endif // TOOLBOXINTERFACE_HH