[Kst] branches/work/kst/portto4/kst
Mike Fenton
mike at staikos.net
Fri May 30 17:51:01 CEST 2008
SVN commit 814534 by fenton:
Update plugin to use new config. Add support for Load/Save of Plugin DataObjects.
M +2 -2 kst.pro
M +2 -0 src/libkst/primitive.h
M +25 -17 src/libkstmath/basicplugin.cpp
M +1 -0 src/libkstmath/basicplugin.h
A src/libkstmath/basicpluginfactory.cpp [License: GPL (v2+)]
A src/libkstmath/basicpluginfactory.h [License: GPL (v2+)]
M +2 -0 src/libkstmath/builtinobjects.cpp
M +13 -2 src/libkstmath/dataobject.cpp
M +3 -1 src/libkstmath/dataobject.h
M +1 -2 src/libkstmath/dataobjectplugin.h
M +2 -0 src/libkstmath/libkstmath.pro
M +25 -8 src/plugins/sampleplugin/sampleplugin.cpp
M +4 -3 src/plugins/sampleplugin/sampleplugin.h
--- branches/work/kst/portto4/kst/kst.pro #814533:814534
@@ -10,7 +10,7 @@
src/kst \
src/d2asc \
# src/d2d \
- tests
-# src/plugins \
+ tests \
+ src/plugins
# src/extensions \
# misc
--- branches/work/kst/portto4/kst/src/libkst/primitive.h #814533:814534
@@ -45,6 +45,8 @@
UpdateType update();
void setSlaveName(QString slaveName);
+ QString slaveName() { return _slaveName; }
+
protected:
Primitive(ObjectStore *store, Object* provider = 0L);
--- branches/work/kst/portto4/kst/src/libkstmath/basicplugin.cpp #814533:814534
@@ -366,47 +366,55 @@
}
-
void BasicPlugin::save(QXmlStreamWriter &s) {
s.writeStartElement(staticTypeTag);
- s.writeAttribute("name", propertyString());
+ s.writeAttribute("type", _pluginName);
+ saveNameInfo(s, VNUM|HNUM|XNUM);
for (VectorMap::Iterator i = _inputVectors.begin(); i != _inputVectors.end(); ++i) {
- s.writeStartElement("ivector");
- s.writeAttribute("name", i.key());
+ s.writeStartElement("inputvector");
+ s.writeAttribute("type", i.key());
+ s.writeAttribute("tag", i.value()->Name());
s.writeEndElement();
}
for (ScalarMap::Iterator i = _inputScalars.begin(); i != _inputScalars.end(); ++i) {
- s.writeStartElement("iscalar");
- s.writeAttribute("name", i.key());
+ s.writeStartElement("inputscalar");
+ s.writeAttribute("type", i.key());
+ s.writeAttribute("tag", i.value()->Name());
s.writeEndElement();
}
for (StringMap::Iterator i = _inputStrings.begin(); i != _inputStrings.end(); ++i) {
- s.writeStartElement("istring");
- s.writeAttribute("name", i.key());
+ s.writeStartElement("inputstring");
+ s.writeAttribute("type", i.key());
+ s.writeAttribute("tag", i.value()->Name());
s.writeEndElement();
}
for (VectorMap::Iterator i = _outputVectors.begin(); i != _outputVectors.end(); ++i) {
- s.writeStartElement("ovector");
- s.writeAttribute("name", i.key());
- if (i.value()->isScalarList()) {
- s.writeAttribute("scalarlist", "true");
- }
+ s.writeStartElement("outputvector");
+ s.writeAttribute("type", i.key());
+ s.writeAttribute("tag", i.value()->slaveName());
s.writeEndElement();
}
for (ScalarMap::Iterator i = _outputScalars.begin(); i != _outputScalars.end(); ++i) {
- s.writeStartElement("oscalar");
- s.writeAttribute("name", i.key());
+ s.writeStartElement("outputscalar");
+ s.writeAttribute("type", i.key());
+ s.writeAttribute("tag", i.value()->slaveName());
s.writeEndElement();
}
for (StringMap::Iterator i = _outputStrings.begin(); i != _outputStrings.end(); ++i) {
- s.writeStartElement("ostring");
- s.writeAttribute("name", i.key());
+ s.writeStartElement("outputstring");
+ s.writeAttribute("type", i.key());
+ s.writeAttribute("tag", i.value()->slaveName());
s.writeEndElement();
}
s.writeEndElement();
}
+void BasicPlugin::saveProperties(QXmlStreamWriter &s) {
+ Q_UNUSED(s);
+}
+
+
//TODO Could use some templates perhaps...
bool BasicPlugin::inputsExist() const {
//First, check the inputVectors...
--- branches/work/kst/portto4/kst/src/libkstmath/basicplugin.h #814533:814534
@@ -85,6 +85,7 @@
//Regular virtual methods from DataObject
// void load(const QDomElement &e);
virtual void save(QXmlStreamWriter &s);
+ virtual void saveProperties(QXmlStreamWriter &s);
bool isFit() const { return _isFit; }
// FIXME: remove this
--- branches/work/kst/portto4/kst/src/libkstmath/builtinobjects.cpp #814533:814534
@@ -15,6 +15,7 @@
#include "histogramfactory.h"
#include "psdfactory.h"
#include "eventmonitorfactory.h"
+#include "basicpluginfactory.h"
namespace Kst {
namespace Builtins {
@@ -24,6 +25,7 @@
new HistogramFactory;
new PSDFactory;
new EventMonitorFactory;
+ new BasicPluginFactory;
}
}
}
--- branches/work/kst/portto4/kst/src/libkstmath/dataobject.cpp #814533:814534
@@ -128,6 +128,10 @@
DataObjectConfigWidget* DataObject::pluginWidget(const QString& name) {
+ if (_pluginList.isEmpty()) {
+ scanPlugins();
+ }
+
for (DataObjectPluginList::ConstIterator it = _pluginList.begin(); it != _pluginList.end(); ++it) {
if ((*it)->pluginName() == name) {
if ((*it)->hasConfigWidget()) {
@@ -140,10 +144,10 @@
}
-DataObjectPtr DataObject::createPlugin(const QString& name, ObjectStore *store, DataObjectConfigWidget *configWidget) {
+DataObjectPtr DataObject::createPlugin(const QString& name, ObjectStore *store, DataObjectConfigWidget *configWidget, bool setupInputsOutputs) {
for (DataObjectPluginList::ConstIterator it = _pluginList.begin(); it != _pluginList.end(); ++it) {
if ((*it)->pluginName() == name) {
- if (DataObjectPtr object = (*it)->create(store, configWidget)) {
+ if (DataObjectPtr object = (*it)->create(store, configWidget, setupInputsOutputs)) {
return object;
}
}
@@ -850,5 +854,12 @@
}
+bool DataObjectConfigWidget::configurePropertiesFromXml(ObjectStore *store, QXmlStreamAttributes& attrs) {
+ Q_UNUSED(store);
+ Q_UNUSED(attrs);
+ return true;
}
+
+
+}
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstmath/dataobject.h #814533:814534
@@ -59,7 +59,7 @@
// static QWidget* pluginWidget(const QString& name, ObjectPtr objectPtr = 0, VectorPtr vector = 0);
static DataObjectPtr createPlugin(const QString& name, ObjectStore *store, VectorPtr vector);
static DataObjectConfigWidget* pluginWidget(const QString& name);
- static DataObjectPtr createPlugin(const QString& name, ObjectStore *store, DataObjectConfigWidget *configWidget);
+ static DataObjectPtr createPlugin(const QString& name, ObjectStore *store, DataObjectConfigWidget *configWidget, bool setupInputsOutputs = true);
virtual UpdateType update() = 0;
virtual const QString& typeString() const { return _typeString; }
@@ -193,6 +193,8 @@
virtual void setupFromObject(Object* dataObject);
virtual void setupSlots(QWidget* dialog);
+ virtual bool configurePropertiesFromXml(ObjectStore *store, QXmlStreamAttributes& attrs);
+
KST_EXPORT void setInstance(DataObjectPtr inst);
KST_EXPORT DataObjectPtr instance() const;
--- branches/work/kst/portto4/kst/src/libkstmath/dataobjectplugin.h #814533:814534
@@ -27,8 +27,7 @@
public:
virtual ~DataObjectPluginInterface() {}
- virtual DataObject *create(ObjectStore *store,
- DataObjectConfigWidget *configWidget) const = 0;
+ virtual DataObject *create(ObjectStore *store, DataObjectConfigWidget *configWidget, bool setupInputsOutputs = true) const = 0;
virtual DataObjectConfigWidget *configWidget() const = 0;
};
--- branches/work/kst/portto4/kst/src/libkstmath/libkstmath.pro #814533:814534
@@ -23,6 +23,7 @@
SOURCES += \
basicplugin.cpp \
+ basicpluginfactory.cpp \
builtinobjects.cpp \
builtinrelations.cpp \
colorsequence.cpp \
@@ -65,6 +66,7 @@
HEADERS += \
basicplugin.h \
+ basicpluginfactory.h \
builtinobjects.h \
builtinrelations.h \
colorsequence.h \
--- branches/work/kst/portto4/kst/src/plugins/sampleplugin/sampleplugin.cpp #814533:814534
@@ -46,11 +46,23 @@
setSelectedVector(source->vector());
}
}
+
+ virtual bool configurePropertiesFromXml(Kst::ObjectStore *store, QXmlStreamAttributes& attrs) {
+ bool validTag = true;
+
+// QStringRef av;
+// av = attrs.value("value");
+// if (!av.isNull()) {
+// _configValue = QVariant(av.toString()).toBool();
+// }
+
+ return validTag;
+ }
};
-SamplePluginSource::SamplePluginSource(Kst::ObjectStore *store, const Kst::ObjectTag& tag)
-: Kst::BasicPlugin(store, tag) {
+SamplePluginSource::SamplePluginSource(Kst::ObjectStore *store)
+: Kst::BasicPlugin(store) {
}
@@ -76,7 +88,6 @@
bool SamplePluginSource::algorithm() {
- //Do nothing
Kst::VectorPtr inputVector = _inputVectors[VECTOR_IN];
Kst::VectorPtr outputVector = _outputVectors[VECTOR_OUT];
@@ -124,17 +135,23 @@
}
+void SamplePluginSource::saveProperties(QXmlStreamWriter &s) {
+// s.writeAttribute("tag", tag().tagString());
+}
+
+
QString SamplePlugin::pluginName() const { return "Sample DataObject Plugin"; }
-Kst::DataObject *SamplePlugin::create(Kst::ObjectStore *store,
- Kst::ObjectTag &tag, Kst::DataObjectConfigWidget *configWidget) const {
+Kst::DataObject *SamplePlugin::create(Kst::ObjectStore *store, Kst::DataObjectConfigWidget *configWidget, bool setupInputsOutputs) const {
if (ConfigWidgetSamplePlugin* config = static_cast<ConfigWidgetSamplePlugin*>(configWidget)) {
- SamplePluginSource* object = store->createObject<SamplePluginSource>(tag);
+ SamplePluginSource* object = store->createObject<SamplePluginSource>();
- object->setInputVector(VECTOR_IN, config->selectedVector());
- object->setupOutputs();
+ if (setupInputsOutputs) {
+ object->setInputVector(VECTOR_IN, config->selectedVector());
+ object->setupOutputs();
+ }
object->setPluginName(pluginName());
--- branches/work/kst/portto4/kst/src/plugins/sampleplugin/sampleplugin.h #814533:814534
@@ -21,7 +21,7 @@
Q_OBJECT
public:
- SamplePluginSource(Kst::ObjectStore *store, const Kst::ObjectTag& tag);
+ SamplePluginSource(Kst::ObjectStore *store);
~SamplePluginSource();
@@ -40,6 +40,8 @@
virtual QStringList outputVectorList() const;
virtual QStringList outputScalarList() const;
virtual QStringList outputStringList() const;
+
+ virtual void saveProperties(QXmlStreamWriter &s);
};
@@ -53,8 +55,7 @@
virtual bool hasConfigWidget() const { return true; }
- virtual Kst::DataObject *create(Kst::ObjectStore *store,
- Kst::ObjectTag &tag, Kst::DataObjectConfigWidget *configWidget) const;
+ virtual Kst::DataObject *create(Kst::ObjectStore *store, Kst::DataObjectConfigWidget *configWidget, bool setupInputsOutputs = true) const;
virtual Kst::DataObjectConfigWidget *configWidget() const;
};
More information about the Kst
mailing list