Developer Documentation
vsiPlugin.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//== INCLUDES =================================================================
45
46#ifndef VSIPLUGIN_HH
47#define VSIPLUGIN_HH
48
49#include <QObject>
50
56
57#include <QPushButton>
58#include <QHBoxLayout>
59
60//== FORWARDDECLARATIONS ======================================================
61
62namespace VSI {
63 class Context;
64 class BaseWidget;
65}
66
67//== CLASS DEFINITION =========================================================
68
72{
73 Q_OBJECT
74 Q_INTERFACES(BaseInterface)
75 Q_INTERFACES(MenuInterface)
76 Q_INTERFACES(RPCInterface)
77 Q_INTERFACES(LoggingInterface)
78 Q_INTERFACES(PythonInterface)
79
80 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-VSI")
81
82 signals:
83
84 // MenuInterface
85 void getMenubarMenu (QString _name, QMenu *& _menu, bool _create);
86
87 // RPC Interface
88 void pluginExists (QString _pluginName, bool& _exists) ;
89 void functionExists (QString _pluginName, QString _functionName, bool& _exists);
90
91 // LoggingInterface
92 void log(Logtype _type, QString _message);
93 void log(QString _message);
94
95 // Python Interface
96 void executePythonScript(QString _script);
97 void openPythonScriptInEditor(QString _script);
98
99public:
100
102 VsiPlugin ();
103
105 ~VsiPlugin ();
106
108 QString name () { return QString ("VisualScripting"); };
109
111 QString description () { return QString ("Visual Scripting interface for OpenFlipper"); };
112
113 public slots:
114
116 QString askForInputs (QString _element, QString _inputs);
117
119 void messageBox (QString _message);
120
122 bool questionBox (QString _message);
123
125 bool continueBox(QString _message);
126
127 QString version () { return QString("1.0"); };
128
129 private slots:
130 void pluginsInitialized ();
131
132 void noguiSupported () {};
133
135 void showScriptEditor ();
136
138 void showInScriptEditor (const QString& _script);
139
140 private:
141
143 void initContext ();
144
145 private:
146
147 VSI::Context *context_;
148 VSI::BaseWidget *baseWidget_;
149};
150
151//=============================================================================
152
153class QContinueBox : public QWidget {
154 Q_OBJECT
155
156public:
157 QContinueBox(QString _message,QWidget* _parent = 0) :
158 QWidget(_parent),
159 continue_(true)
160 {
161 QPushButton* stopButton = new QPushButton("Stop",this);
162 QHBoxLayout* layout = new QHBoxLayout(this);
163
164 this->setWindowTitle(_message);
165
166 layout->addWidget(stopButton);
167 this->setLayout(layout);
168
169 connect(stopButton,SIGNAL(clicked()), this, SLOT(clicked()));
170 }
171
172public slots:
173 void clicked( ) {
174 continue_ = false;
175 }
176
177public:
178 bool continueBox() { return continue_; };
179
180private:
181 bool continue_;
182};
183
184
185//=============================================================================
186//=============================================================================
187
188#endif
Logtype
Log types for Message Window.
Interface class from which all plugins have to be created.
Interface for all Plugins which do logging to the logging window of the framework.
Interface for all plugins which provide entries to the main menubar.
Interface class for exporting functions to python.
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
void messageBox(QString _message)
Scripting function, that displays a message box.
Definition: vsiPlugin.cc:244
bool continueBox(QString _message)
Shows a non blocking stop box for use inside loops.
Definition: vsiPlugin.cc:267
void showScriptEditor()
Shows visual script editor.
Definition: vsiPlugin.cc:111
VsiPlugin()
Constructor.
Definition: vsiPlugin.cc:69
bool questionBox(QString _message)
Scripting function, that displays a Yes/No message box.
Definition: vsiPlugin.cc:254
void showInScriptEditor(const QString &_script)
Opens the text based script editor with the given script.
Definition: vsiPlugin.cc:226
QString askForInputs(QString _element, QString _inputs)
Scripting function, that allows to ask the user for inputs during script execution.
Definition: vsiPlugin.cc:169
QString description()
Description of the Plugin.
Definition: vsiPlugin.hh:111
void initContext()
initalisation
Definition: vsiPlugin.cc:125
~VsiPlugin()
Destructor.
Definition: vsiPlugin.cc:78
void pluginsInitialized()
Register in menubar.
Definition: vsiPlugin.cc:89
QString name()
Name of the Plugin.
Definition: vsiPlugin.hh:108