Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ScriptingPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef SCRIPTINGPLUGIN_HH
51 #define SCRIPTINGPLUGIN_HH
52
53 #include <QObject>
54 #include <QMenuBar>
55
56 #include <OpenFlipper/common/Types.hh>
57 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
58 #include <OpenFlipper/BasePlugin/MenuInterface.hh>
59 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
60 #include <OpenFlipper/BasePlugin/RPCInterface.hh>
61 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
62
63 // Include the scripttools for qt script debugging if available
64 #ifdef QT_SCRIPTTOOLS_LIB
65 #include <QtScriptTools/QScriptEngineDebugger>
66 #endif
67
68 #include "highLighter.hh"
69 #include "scriptingWidget.hh"
70
71
72
73 class ScriptingPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface, RPCInterface, LoggingInterface
74 {
75 Q_OBJECT
76 Q_INTERFACES(BaseInterface)
77 Q_INTERFACES(MenuInterface)
78 Q_INTERFACES(ScriptInterface)
79 Q_INTERFACES(RPCInterface)
80 Q_INTERFACES(LoggingInterface)
81
82 #if QT_VERSION >= 0x050000
83 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Scripting")
84 #endif
85
86 signals:
87 void updateView();
88
89 void getScriptingEngine( QScriptEngine*& _engine );
90 void getAvailableFunctions( QStringList& _functions );
91
92 void log(Logtype _type, QString _message);
93 void log(QString _message);
94
95 void getMenubarMenu (QString _name, QMenu *& _menu, bool _create);
96
97 void getDescription(QString _function, QString& _description,
98 QStringList& _parameters, QStringList& _descriptions);
99
100 private slots:
101
102 void slotScriptInfo( QString _pluginName , QString _functionName );
103 void slotExecuteScript( QString _script );
104 void slotExecuteFileScript( QString _filename );
105
106 void slotLoadScript();
107 void slotSaveScript();
108 void slotSaveScriptAs();
109 void pluginsInitialized();
110
111 void noguiSupported( ) {} ;
112
113 public :
114
115 ScriptingPlugin();
116
117 QString name() { return (QString(tr("Scripting"))); };
118 QString description( ) { return (QString(tr("Provides Scripting for OpenFlipper"))); };
119
120 private slots :
121
122 void slotExecuteScriptButton();
123
128 void slotScriptChanged();
129
130 void slotFunctionClicked(QListWidgetItem* _item);
131 void slotFunctionDoubleClicked(QListWidgetItem* _item);
132
133 void slotApplyFilter();
134
136 void slotHighlightError();
137
139 void slotDebuggerButton();
140
141 private:
142
144 int lastProblemLine_;
145
147 QString lastError_;
148
150 QTimer* errorTimer_;
151
152 QList< QLabel* > descriptionLabels_;
153 QVBoxLayout* descrLayout_;
154
155 //===========================================================================
158 //===========================================================================
159
160 public slots:
161
165 void showScriptWidget();
166
170 void hideScriptWidget();
171
176 void showScriptInEditor (QString _code);
177
184 void slotLoadScript( QString _filename );
185
189 void clearEditor();
190
193 //===========================================================================
196 //===========================================================================
197
198 public slots:
199
203 void waitContinue( );
204
209 void waitContinue( QString _msg, int _x=-1, int _y=-1);
210
211
213 void sleep( int _seconds );
214
216 void sleepmsecs( int _mseconds );
217
219 void frameStart( );
220
222 void waitFrameEnd( int _mseconds );
223
227 private :
228 QString mangleScript( QString _input );
229
231 QTime frameTime_;
232
233 private :
234 ScriptWidget* scriptWidget_;
235
236 QStatusBar* statusBar_;
237
238 Highlighter* highlighterCurrent_;
239 Highlighter* highlighterLive_;
240 Highlighter* highlighterList_;
241
242 QString lastFile_;
243
247 QString scriptPath_;
248
249 QAction* debuggerButton_;
250
251 #ifdef ENABLE_SCRIPT_DEBUGGER
252 #ifdef QT_SCRIPTTOOLS_LIB
253 QScriptEngineDebugger* debugger_;
254 #endif
255 #endif
256
257
258
259 public slots:
260 QString version() { return QString("1.0"); };
261 };
262
263 #endif //SCRIPTINGPLUGIN_HH
264
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:76
ScriptingPlugin::pluginsInitialized
void pluginsInitialized()
Definition: ScriptingPlugin.cc:82
ScriptingPlugin::lastProblemLine_
int lastProblemLine_
Store the last line that contained an error.
Definition: ScriptingPlugin.hh:144
ScriptingPlugin::frameStart
void frameStart()
Marks the current time as the frame start ( Use wait sleepFrameLength to wait until _mseconds have pa...
Definition: ScriptingPlugin.cc:526
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:103
ScriptingPlugin
Definition: ScriptingPlugin.hh:73
Highlighter
Definition: highLighter.hh:60
ScriptingPlugin::lastError_
QString lastError_
Store the last error message.
Definition: ScriptingPlugin.hh:147
ScriptWidget
Definition: scriptingWidget.hh:58
ScriptingPlugin::slotDebuggerButton
void slotDebuggerButton()
Triggered by the debugger button.
Definition: ScriptingPlugin.cc:466
LoggingInterface.hh
ScriptingPlugin::name
QString name()
Return a name for the plugin.
Definition: ScriptingPlugin.hh:117
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:123
ScriptingPlugin::scriptPath_
QString scriptPath_
Definition: ScriptingPlugin.hh:247
RPCInterface
Interface to call functions across plugins.
Definition: RPCInterface.hh:71
ScriptingPlugin::sleep
void sleep(int _seconds)
Sleeps for some seconds in script execution ( Gui will remain functional)
Definition: ScriptingPlugin.cc:496
ScriptingPlugin::clearEditor
void clearEditor()
Clear the editor window Clears the script editor window.
Definition: ScriptingPlugin.cc:767
ScriptingPlugin::showScriptWidget
void showScriptWidget()
Show the script editor widget.
Definition: ScriptingPlugin.cc:265
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:67
ScriptingPlugin::sleepmsecs
void sleepmsecs(int _mseconds)
Sleeps for some mseconds in script execution ( Gui will remain functional)
Definition: ScriptingPlugin.cc:511
RPCInterface.hh
ScriptingPlugin::slotExecuteScript
void slotExecuteScript(QString _script)
Definition: ScriptingPlugin.cc:341
ScriptingPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: ScriptingPlugin.hh:118
ScriptingPlugin::waitContinue
void waitContinue()
Definition: ScriptingPlugin.cc:544
ScriptingPlugin::frameTime_
QTime frameTime_
Counts mseconds since a frame start has occured.
Definition: ScriptingPlugin.hh:231
ScriptingPlugin::errorTimer_
QTimer * errorTimer_
Timer to wait until the user stopped typing before showing an error.
Definition: ScriptingPlugin.hh:150
ScriptingPlugin::slotScriptChanged
void slotScriptChanged()
Called everytime the text in the scriptingwidget is changed by the user.
Definition: ScriptingPlugin.cc:237
ScriptInterface.hh
BaseInterface.hh
ScriptingPlugin::waitFrameEnd
void waitFrameEnd(int _mseconds)
wait until _mseconds have passed since frameStart (if more time has passed, it will return immediatel...
Definition: ScriptingPlugin.cc:530
ScriptingPlugin::slotHighlightError
void slotHighlightError()
Called when an error is detected when checking the syntax.
Definition: ScriptingPlugin.cc:260
ScriptingPlugin::showScriptInEditor
void showScriptInEditor(QString _code)
Show the given Code in the script editor.
Definition: ScriptingPlugin.cc:750
Types.hh
MenuInterface.hh
MenuInterface
Interface for all plugins which provide entries to the main menubar.
Definition: MenuInterface.hh:91
ScriptingPlugin::hideScriptWidget
void hideScriptWidget()
Hide the script editor widget.
Definition: ScriptingPlugin.cc:323