ScriptInterface.hh 10.9 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   Jan Möbius committed Oct 16, 2008 50 51 #ifndef SCRIPTINTERFACE_HH #define SCRIPTINTERFACE_HH  Jan Möbius committed Aug 29, 2008 52 53 54  #include  Jan Möbius committed Mar 01, 2011 55 56 57 58 59 /** \file ScriptInterface.hh * * Interface for controlling OpenFlippers scripting system. \ref scriptInterfacePage */  Jan Möbius committed Jun 21, 2012 60 /** \brief Interface for all Plugins which provide scriptable Functions.  Jan Möbius committed Mar 01, 2011 61 62 63 64 65  * * \ref scriptInterfacePage "Detailed description" * \n * *  Jan Möbius committed Aug 29, 2008 66 67 */ class ScriptInterface {  Jan Möbius committed Oct 16, 2008 68   Mike Kremer committed Feb 10, 2009 69 70 71 72  public: /// Destructor virtual ~ScriptInterface() {};  Jan Möbius committed Oct 16, 2008 73   Jan Möbius committed Mar 01, 2011 74 75 76 77  //=========================================================================== /** @name Script execution * @{ */ //===========================================================================  Jan Möbius committed Oct 16, 2008 78   Jan Möbius committed Mar 01, 2011 79  signals:  Jan Möbius committed Aug 29, 2008 80  /** Emit this signal to execute a script  Jan Möbius committed Mar 01, 2011 81 82 83 84 85 86 87 88 89 90 91  * * @param _script The script to execute */ virtual void executeScript( QString _script ) {}; /** Emit this signal to execute a script from a file * @param _filename Filename of the script to execute */ virtual void executeFileScript( QString _filename ) {}; /** @} */  Jan Möbius committed Oct 16, 2008 92   Jan Möbius committed Mar 01, 2011 93 94 95 96 97 98  //=========================================================================== /** @name Function Information * @{ */ //=========================================================================== signals:  Jan Möbius committed Oct 16, 2008 99   Jan Möbius committed Aug 29, 2008 100  /** With this signal you can get a list of all available scripting functions  Jan Möbius committed Mar 01, 2011 101  * @param _functions All available functions  Jan Möbius committed Aug 29, 2008 102  */  Jan Möbius committed Mar 01, 2011 103  virtual void getAvailableFunctions(QStringList& _functions) { };  Dirk Wilden committed Oct 15, 2008 104 105 106 107 108 109 110 111  /** With this signal you can get descriptions about a given function if available * * @param _function name of the function (e.g. plugin.function) * @param _description a description for the function * @param _parameters list of names for the parameters * @param _descriptions list of descriptions for the parameters (_descriptions[i] corresponds to _parameters[i]) */  Jan Möbius committed Mar 01, 2011 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 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  virtual void getDescription(QString _function, QString& _description, QStringList& _parameters, QStringList& _descriptions) { }; /** @} */ //=========================================================================== /** @name Scripting History * @{ */ //=========================================================================== signals: /** \brief Emit this signal if a scriptable function is executed * * e.g. selectAllVertices( ObjectId ) * * If you execute this function, you can append your functions to the script * execution history in OpenFlipper. In this history OpenFlipper records operations * that are scriptable. Later this list can be executed again and therefore * reruns the recorded operations. * * The following example code shows a function called translate in a plugin, * that gets an ObjectId as a parameter. The plugin which emits this function * will automatically be added in the history ( e.g. \code move.translate( ObjectId , Vector(1 , 0 , 0 ) ) \endcode ) * \code * emit scriptInfo( "translate( ObjectId , Vector(1 , 0 , 0 ) )" ); * \endcode * * @param _functionWithParameters The called function with all parameters */ virtual void scriptInfo( QString _functionWithParameters ) {}; /** @} */ //=========================================================================== /** @name Others * @{ */ //=========================================================================== signals: /** Emit this signal to get a reference to the core scripting engine * * @param _engine The scripting Engine */ virtual void getScriptingEngine( QScriptEngine*& _engine ) {}; /** @} */ //=========================================================================== /** @name Slots for a scripting control plugin like Plugin-Script * @{ */ //===========================================================================  Jan Möbius committed Oct 16, 2008 164   Jan Möbius committed Aug 29, 2008 165  private slots:  Jan Möbius committed Oct 16, 2008 166   Jan Möbius committed Aug 29, 2008 167  /** Slot for a scripting plugin. Gets the Script and executes it.  Jan Möbius committed Oct 16, 2008 168  *  Jan Möbius committed Aug 29, 2008 169  * @param _pluginName Name of the plugin that executed a scriptable function  Jan Möbius committed Mar 01, 2011 170  * @param _functionWithParameters Name with parameters (values!) of the function to call.  Jan Möbius committed Aug 29, 2008 171  */  Jan Möbius committed Mar 01, 2011 172  virtual void slotScriptInfo( QString _pluginName , QString _functionWithParameters ) {};  Jan Möbius committed Oct 16, 2008 173 174   Jan Möbius committed Mar 01, 2011 175  /** Slot for a scripting plugin. Gets the Script as QString and executes it.  Jan Möbius committed Oct 16, 2008 176  *  Jan Möbius committed Mar 01, 2011 177  * @param _script Script to execute as a QString  Jan Möbius committed Aug 29, 2008 178  */  Jan Möbius committed Mar 01, 2011 179  virtual void slotExecuteScript( QString _script ) {};  Jan Möbius committed Oct 16, 2008 180 181   Jan Möbius committed Mar 01, 2011 182  /** Slot for a scripting plugin. Gets the Script as a filename, opens and executes it.  Jan Möbius committed Aug 29, 2008 183  */  Jan Möbius committed Mar 01, 2011 184  virtual void slotExecuteFileScript( QString _filename ) {};  Jan Möbius committed Oct 16, 2008 185   Jan Möbius committed Mar 01, 2011 186  /** @} */  Jan Möbius committed Oct 16, 2008 187   Jan Möbius committed Aug 29, 2008 188 189 };  Jan Möbius committed Mar 01, 2011 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 /** \page scriptInterfacePage Scripting Interface \n \image html ScriptInterface.png \n OpenFlipper uses QTs scripting system to provide scripting functions to the user and to the plugins. It also includes a batch mode where OpenFlipper is started without an user interface. All plugins which support this mode can than be controlled by command line supplied batch scripts without any user interaction. The ScriptingInterface has several functions to support scripting.
An easier interface to call functions is available by the \ref RPCInterfacePage "RPC Interface". Additionally it is  Jan Möbius committed Mar 01, 2011 246 possible to connect signals and slots across plugins via the \ref pluginConnectionInterfacePage "Plugin Connection Interface"  Jan Möbius committed Mar 01, 2011 247 248 249 250  */  Jan Möbius committed Oct 16, 2008 251 252 Q_DECLARE_INTERFACE(ScriptInterface,"OpenFlipper.ScriptInterface/1.1")  Jan Möbius committed Aug 29, 2008 253 #endif // SCRIPTINTERFACE_HH