Warning, /graphics/kst-plot/pyKst/AddingInterfaces is written in an unsupported language. File is not indexed.
0001 How to add an interface for a new NamedObject.
0002
0003 -Create a class which inherits from ScriptInterface.
0004 eg, ScalarGenSI in scalarsscriptinterface.cpp
0005
0006 -Implement the 5 methods.
0007 -doCommand actually parses the commands from pyKst.py
0008 -you probably want to call doNamedObjectCommand as is done
0009 in ScalarGenSI::doCommand()
0010
0011 -Add virtual ScriptInterface* createScriptInterface() to the
0012 class you are making an interface for. eg, Scalar.
0013
0014 ScriptInterface* Scalar::createScriptInterface() {
0015 return new ScalarGenSI(this);
0016 }
0017
0018 -Create a command in ScripServer.h
0019 eg, QByteArray newGeneratedScalar(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
0020
0021 -Implement it in ScripServer.cpp
0022
0023 QByteArray ScriptServer::newGeneratedScalar(QByteArray&, QLocalSocket* s,ObjectStore*) {
0024 if(_interface) {
0025 return handleResponse("To access this function, first call endEdit()",s);
0026 } else {
0027 _interface = ScalarGenSI::newScalar(_store); return handleResponse("Ok",s);
0028 }
0029 }
0030
0031 -register it in _fnMap
0032 _fnMap.insert("newGeneratedScalar()",&ScriptServer::newGeneratedScalar);
0033
0034 -Call the interface you just wrote in pyKst.py
0035 search for GeneratedScalar as an example.
0036