| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| /*************************************************************************** | ||
| * * | ||
| * copyright : (C) 2014 Barth Netterfield * | ||
| * netterfield@astro.utoronto.ca * | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "matrixscriptinterface.h" | ||
|
|
||
| #include "objectstore.h" | ||
| #include "datasourcepluginmanager.h" | ||
| #include "updatemanager.h" | ||
| #include "updateserver.h" | ||
|
|
||
| #include <QStringBuilder> | ||
|
|
||
|
|
||
| namespace Kst { | ||
|
|
||
| QString doMatrixScriptCommand(QString command,Matrix *matrix) { | ||
|
|
||
| QString v=ScriptInterface::doNamedObjectCommand(command, matrix); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if (command.startsWith("value(")) { | ||
| command.remove("value(").chop(1); | ||
| QStringList p = command.split(','); | ||
| return QString::number(matrix->value(p[0].toDouble(), p[1].toDouble())); | ||
| } else if (command.startsWith("length(")) { | ||
| return QString::number(matrix->sampleCount()); | ||
| } else if (command.startsWith("min(")) { | ||
| return QString::number(matrix->minValue()); | ||
| } else if (command.startsWith("max(")) { | ||
| return QString::number(matrix->maxValue()); | ||
| } else if (command.startsWith("mean(")) { | ||
| return QString::number(matrix->meanValue()); | ||
| } else if (command.startsWith("width(")) { | ||
| return QString::number(matrix->xNumSteps()); | ||
| } else if (command.startsWith("height(")) { | ||
| return QString::number(matrix->yNumSteps()); | ||
| } else if (command.startsWith("dX(")) { | ||
| return QString::number(matrix->xStepSize()); | ||
| } else if (command.startsWith("dY(")) { | ||
| return QString::number(matrix->yStepSize()); | ||
| } else if (command.startsWith("minX(")) { | ||
| return QString::number(matrix->minX()); | ||
| } else if (command.startsWith("minY(")) { | ||
| return QString::number(matrix->minY()); | ||
| } else if (command.startsWith("descriptionTip(")) { | ||
| return matrix->descriptionTip(); | ||
| } | ||
|
|
||
| return QString(); | ||
| } | ||
|
|
||
|
|
||
| /******************************************************/ | ||
| /* Data Matrixs */ | ||
| /******************************************************/ | ||
| MatrixDataSI::MatrixDataSI(DataMatrixPtr it) { | ||
| matrix=it; | ||
| } | ||
|
|
||
| QString MatrixDataSI::doCommand(QString command) { | ||
|
|
||
| QString v=doMatrixScriptCommand(command, matrix); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
|
|
||
| if (command.startsWith(QLatin1String("change("))) { | ||
| command.remove("change(").remove(')'); | ||
| QStringList p = command.split(','); | ||
| DataSourcePtr ds = DataSourcePluginManager::findOrLoadSource( | ||
| matrix->store(), p.at(0)); | ||
|
|
||
| matrix->writeLock(); | ||
| matrix->change(ds, | ||
| p.at(1), // field | ||
| p.at(2).toInt(), // x start | ||
| p.at(3).toInt(), // y start | ||
| p.at(4).toInt(), // num x steps | ||
| p.at(5).toInt(), // num y steps | ||
|
|
||
| false, false, 0, | ||
|
|
||
| p.at(6).toDouble(), // min x | ||
| p.at(7).toDouble(), // min y | ||
| p.at(8).toDouble(), // step x | ||
| p.at(9).toDouble() // step y | ||
| ); | ||
| matrix->unlock(); | ||
| return "Done"; | ||
| } else if (command.startsWith("field(")) { | ||
| return matrix->field(); | ||
| } else if (command.startsWith("filename(")) { | ||
| return matrix->filename(); | ||
| } else if (command.startsWith("startX(")) { | ||
| return QString::number(matrix->reqXStart()); | ||
| } else if (command.startsWith("startY(")) { | ||
| return QString::number(matrix->reqYStart()); | ||
| } | ||
|
|
||
| return "No such command"; | ||
| } | ||
|
|
||
| bool MatrixDataSI::isValid() { | ||
| return matrix.isPtrValid(); | ||
| } | ||
|
|
||
| ScriptInterface* MatrixDataSI::newMatrix(ObjectStore *store) { | ||
| DataMatrixPtr matrix; | ||
| matrix = store->createObject<DataMatrix>(); | ||
| return new MatrixDataSI(matrix); | ||
| } | ||
|
|
||
| QByteArray MatrixDataSI::endEditUpdate() { | ||
| matrix->registerChange(); | ||
| UpdateManager::self()->doUpdates(true); | ||
| UpdateServer::self()->requestUpdateSignal(); | ||
| return ("Finished editing "+matrix->Name()).toLatin1(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /*************************************************************************** | ||
| * * | ||
| * copyright : (C) 2014 Barth Netterfield * | ||
| * netterfield@astro.utoronto.ca * | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef MATRIXSCRIPTINTERFACE_H | ||
| #define MATRIXSCRIPTINTERFACE_H | ||
|
|
||
| #include <QString> | ||
|
|
||
| #include "scriptinterface.h" | ||
| #include "datamatrix.h" | ||
|
|
||
| namespace Kst { | ||
|
|
||
| class MatrixDataSI : public ScriptInterface | ||
| { | ||
| Q_OBJECT | ||
| DataMatrixPtr matrix; | ||
| public: | ||
| explicit MatrixDataSI(DataMatrixPtr it); | ||
| QString doCommand(QString); | ||
| bool isValid(); | ||
| QByteArray endEditUpdate(); | ||
|
|
||
| static ScriptInterface* newMatrix(ObjectStore *store); | ||
| }; | ||
|
|
||
| } | ||
| #endif // MATRIXSCRIPTINTERFACE_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| /*************************************************************************** | ||
| * * | ||
| * copyright : (C) 2014 Barth Netterfield * | ||
| * netterfield@astro.utoronto.ca * | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "scalarscriptinterface.h" | ||
|
|
||
| #include "objectstore.h" | ||
| #include "datasourcepluginmanager.h" | ||
| #include "updatemanager.h" | ||
| #include "updateserver.h" | ||
|
|
||
| #include <QStringBuilder> | ||
|
|
||
|
|
||
| namespace Kst { | ||
|
|
||
| /******************************************************/ | ||
| /* Generated Scalars */ | ||
| /******************************************************/ | ||
| ScalarGenSI::ScalarGenSI(ScalarPtr it) { | ||
| scalar=it; | ||
| } | ||
|
|
||
| QString ScalarGenSI::doCommand(QString x) { | ||
|
|
||
| QString v=doNamedObjectCommand(x, scalar); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if (x.startsWith(QLatin1String("setValue("))) { | ||
| scalar->writeLock(); | ||
| scalar->setValue(x.remove("setValue(").remove(')').toDouble()); | ||
| scalar->unlock(); | ||
| return "Done"; | ||
| } else if (x.startsWith(QLatin1String("value()"))) { | ||
| return QString::number(scalar->value()); | ||
| } | ||
| return "No such command"; | ||
| } | ||
|
|
||
| bool ScalarGenSI::isValid() { | ||
| return scalar.isPtrValid(); | ||
| } | ||
|
|
||
| ScriptInterface* ScalarGenSI::newScalar(ObjectStore *store) { | ||
| ScalarPtr scalar; | ||
| scalar = store->createObject<Scalar>(); | ||
| scalar->setOrphan(true); | ||
| scalar->setEditable(true); | ||
| return new ScalarGenSI(scalar); | ||
| } | ||
|
|
||
| QByteArray ScalarGenSI::endEditUpdate() { | ||
| UpdateManager::self()->doUpdates(true); | ||
| UpdateServer::self()->requestUpdateSignal(); | ||
| return ("Finished editing "+scalar->Name()).toLatin1(); | ||
| } | ||
|
|
||
| /******************************************************/ | ||
| /* Data Scalars */ | ||
| /******************************************************/ | ||
| ScalarDataSI::ScalarDataSI(DataScalarPtr it) { | ||
| scalar=it; | ||
| } | ||
|
|
||
| QString ScalarDataSI::doCommand(QString x) { | ||
|
|
||
| QString v=doNamedObjectCommand(x, scalar); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if (x.startsWith(QLatin1String("change("))) { | ||
| x.remove("change(").remove(')'); | ||
| QStringList p = x.split(','); | ||
| DataSourcePtr ds = DataSourcePluginManager::findOrLoadSource( | ||
| scalar->store(), p.at(0)); | ||
| scalar->writeLock(); | ||
| scalar->change(ds,p.at(1)); | ||
| scalar->unlock(); | ||
| return "Done"; | ||
| } else if (x.startsWith(QLatin1String("file()"))) { | ||
| return scalar->filename(); | ||
| } else if (x.startsWith(QLatin1String("field()"))) { | ||
| return scalar->field(); | ||
| } else if (x.startsWith(QLatin1String("value()"))) { | ||
| return QString::number(scalar->value()); | ||
| } | ||
| return "No such command"; | ||
| } | ||
|
|
||
| bool ScalarDataSI::isValid() { | ||
| return scalar.isPtrValid(); | ||
| } | ||
|
|
||
| ScriptInterface* ScalarDataSI::newScalar(ObjectStore *store) { | ||
| DataScalarPtr scalar; | ||
| scalar = store->createObject<DataScalar>(); | ||
| return new ScalarDataSI(scalar); | ||
| } | ||
|
|
||
| QByteArray ScalarDataSI::endEditUpdate() { | ||
| scalar->registerChange(); | ||
| UpdateManager::self()->doUpdates(true); | ||
| UpdateServer::self()->requestUpdateSignal(); | ||
| return ("Finished editing "+scalar->Name()).toLatin1(); | ||
| } | ||
|
|
||
| /******************************************************/ | ||
| /* Vector Scalars */ | ||
| /******************************************************/ | ||
| ScalarVectorSI::ScalarVectorSI(VScalarPtr it) { | ||
| scalar=it; | ||
| } | ||
|
|
||
| QString ScalarVectorSI::doCommand(QString x) { | ||
|
|
||
| QString v=doNamedObjectCommand(x, scalar); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if (x.startsWith(QLatin1String("change("))) { | ||
| x.remove("change(").remove(')'); | ||
| QStringList p = x.split(','); | ||
| DataSourcePtr ds = DataSourcePluginManager::findOrLoadSource( | ||
| scalar->store(), p.at(0)); | ||
| scalar->writeLock(); | ||
| scalar->change(ds,p.at(1), p.at(2).toInt()); | ||
| scalar->unlock(); | ||
| return "Done"; | ||
| } else if (x.startsWith(QLatin1String("value()"))) { | ||
| return QString::number(scalar->value()); | ||
| } else if (x.startsWith(QLatin1String("file()"))) { | ||
| return scalar->filename(); | ||
| } else if (x.startsWith(QLatin1String("field()"))) { | ||
| return scalar->field(); | ||
| } else if (x.startsWith(QLatin1String("frame()"))) { | ||
| return QString::number(scalar->F0()); | ||
| } | ||
| return "No such command"; | ||
| } | ||
|
|
||
| bool ScalarVectorSI::isValid() { | ||
| return scalar.isPtrValid(); | ||
| } | ||
|
|
||
| ScriptInterface* ScalarVectorSI::newScalar(ObjectStore *store) { | ||
| VScalarPtr scalar; | ||
| scalar = store->createObject<VScalar>(); | ||
| return new ScalarVectorSI(scalar); | ||
| } | ||
|
|
||
| QByteArray ScalarVectorSI::endEditUpdate() { | ||
| scalar->registerChange(); | ||
| UpdateManager::self()->doUpdates(true); | ||
| UpdateServer::self()->requestUpdateSignal(); | ||
| return ("Finished editing "+scalar->Name()).toLatin1(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /*************************************************************************** | ||
| * * | ||
| * copyright : (C) 2014 Barth Netterfield * | ||
| * netterfield@astro.utoronto.ca * | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef SCALARSCRIPTINTERFACE_H | ||
| #define SCALARSCRIPTINTERFACE_H | ||
|
|
||
| #include <QString> | ||
|
|
||
| #include "scriptinterface.h" | ||
| #include "datascalar.h" | ||
| #include "vscalar.h" | ||
|
|
||
| namespace Kst { | ||
|
|
||
| class ScalarGenSI : public ScriptInterface | ||
| { | ||
| Q_OBJECT | ||
| ScalarPtr scalar; | ||
| public: | ||
| explicit ScalarGenSI(ScalarPtr it); | ||
| QString doCommand(QString); | ||
| bool isValid(); | ||
| QByteArray endEditUpdate(); | ||
|
|
||
| static ScriptInterface* newScalar(ObjectStore *store); | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| class ScalarDataSI : public ScriptInterface | ||
| { | ||
| Q_OBJECT | ||
| DataScalarPtr scalar; | ||
| public: | ||
| explicit ScalarDataSI(DataScalarPtr it); | ||
| QString doCommand(QString); | ||
| bool isValid(); | ||
| QByteArray endEditUpdate(); | ||
|
|
||
| static ScriptInterface* newScalar(ObjectStore *store); | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| class ScalarVectorSI : public ScriptInterface | ||
| { | ||
| Q_OBJECT | ||
| VScalarPtr scalar; | ||
| public: | ||
| explicit ScalarVectorSI(VScalarPtr it); | ||
| QString doCommand(QString); | ||
| bool isValid(); | ||
| QByteArray endEditUpdate(); | ||
|
|
||
| static ScriptInterface* newScalar(ObjectStore *store); | ||
|
|
||
| }; | ||
|
|
||
| } | ||
| #endif // SCALARSCRIPTINTERFACE_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| /*************************************************************************** | ||
| * * | ||
| * copyright : (C) 2014 Barth Netterfield * | ||
| * netterfield@astro.utoronto.ca * | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "stringscriptinterface.h" | ||
|
|
||
| #include "objectstore.h" | ||
| #include "datasourcepluginmanager.h" | ||
| #include "updatemanager.h" | ||
| #include "updateserver.h" | ||
|
|
||
| #include <QStringBuilder> | ||
|
|
||
| namespace Kst { | ||
|
|
||
| StringGenSI::StringGenSI(StringPtr it) { | ||
| str=it; | ||
| } | ||
|
|
||
| QString StringGenSI::doCommand(QString x) { | ||
|
|
||
| QString v=doNamedObjectCommand(x, str); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if (x.startsWith(QLatin1String("setValue("))) { | ||
| str->writeLock(); | ||
| str->setValue(x.remove("setValue(").remove(')')); | ||
| str->unlock(); | ||
| return "Done"; | ||
| } else if (x.startsWith(QLatin1String("value()"))) { | ||
| return str->value(); | ||
| } | ||
| return "No such command"; | ||
| } | ||
|
|
||
| bool StringGenSI::isValid() { | ||
| return str.isPtrValid(); | ||
| } | ||
|
|
||
| ScriptInterface* StringGenSI::newString(ObjectStore *store) { | ||
| StringPtr string; | ||
| string = store->createObject<String>(); | ||
| string->setOrphan(true); | ||
| string->setEditable(true); | ||
| return new StringGenSI(string); | ||
| } | ||
|
|
||
| QByteArray StringGenSI::endEditUpdate() { | ||
| UpdateManager::self()->doUpdates(true); | ||
| UpdateServer::self()->requestUpdateSignal(); | ||
| return ("Finished editing "+str->Name()).toLatin1(); | ||
| } | ||
|
|
||
| ///////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| StringDataSI::StringDataSI(DataStringPtr it) { | ||
| str=it; | ||
| } | ||
|
|
||
| QString StringDataSI::doCommand(QString x) { | ||
|
|
||
| QString v=doNamedObjectCommand(x, str); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if(x.startsWith(QLatin1String("change("))) { | ||
| x.remove("change(").remove(')'); | ||
| QStringList p = x.split(','); | ||
| DataSourcePtr ds = DataSourcePluginManager::findOrLoadSource( | ||
| str->store(), p.at(0)); | ||
| str->writeLock(); | ||
| str->change(ds,p.at(1)); | ||
| str->unlock(); | ||
| return "Done"; | ||
| } else if (x.startsWith(QLatin1String("value()"))) { | ||
| return str->value(); | ||
| } | ||
| return "No such command"; | ||
| } | ||
|
|
||
| bool StringDataSI::isValid() { | ||
| return str.isPtrValid(); | ||
| } | ||
|
|
||
| ScriptInterface* StringDataSI::newString(ObjectStore *store) { | ||
| DataStringPtr string; | ||
| string = store->createObject<DataString>(); | ||
|
|
||
| return new StringDataSI(string); | ||
| } | ||
|
|
||
| QByteArray StringDataSI::endEditUpdate() { | ||
| UpdateManager::self()->doUpdates(true); | ||
| UpdateServer::self()->requestUpdateSignal(); | ||
| return ("Finished editing "+str->Name()).toLatin1(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| /*************************************************************************** | ||
| * * | ||
| * copyright : (C) 2014 Barth Netterfield * | ||
| * netterfield@astro.utoronto.ca * | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "vectorscriptinterface.h" | ||
|
|
||
| #include "objectstore.h" | ||
| #include "datasourcepluginmanager.h" | ||
| #include "updatemanager.h" | ||
| #include "updateserver.h" | ||
|
|
||
| #include <QStringBuilder> | ||
|
|
||
|
|
||
| namespace Kst { | ||
|
|
||
| QString doVectorScriptCommand(QString command,Vector *vector) { | ||
|
|
||
| QString v=ScriptInterface::doNamedObjectCommand(command, vector); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if (command.startsWith("value(")) { | ||
| command.remove("value(").chop(1); | ||
| return QString::number(vector->value(command.toInt())); | ||
| } else if (command.startsWith("length(")) { | ||
| return QString::number(vector->length()); | ||
| } else if (command.startsWith("min(")) { | ||
| return QString::number(vector->min()); | ||
| } else if (command.startsWith("max(")) { | ||
| return QString::number(vector->max()); | ||
| } else if (command.startsWith("mean(")) { | ||
| return QString::number(vector->mean()); | ||
| } else if (command.startsWith("descriptionTip(")) { | ||
| return vector->descriptionTip(); | ||
| } | ||
|
|
||
| return QString(); | ||
| } | ||
|
|
||
|
|
||
| /******************************************************/ | ||
| /* Data Vectors */ | ||
| /******************************************************/ | ||
| VectorDataSI::VectorDataSI(DataVectorPtr it) { | ||
| vector=it; | ||
| } | ||
|
|
||
| QString VectorDataSI::doCommand(QString command) { | ||
|
|
||
| QString v=doVectorScriptCommand(command, vector); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if (command.startsWith(QLatin1String("change("))) { | ||
| command.remove("change(").remove(')'); | ||
| QStringList p = command.split(','); | ||
| DataSourcePtr ds = DataSourcePluginManager::findOrLoadSource( | ||
| vector->store(), p.at(0)); | ||
| vector->writeLock(); | ||
| vector->change(ds, | ||
| p.at(1), // field | ||
| p.at(2).toInt(), // f0 | ||
| p.at(3).toInt(), // n | ||
| p.at(4).toInt(), // skip | ||
| p.at(4).toInt() > 0, // do skip | ||
| p.at(5) == "True" // do average | ||
| ); | ||
| vector->unlock(); | ||
| return "Done"; | ||
| } else if (command.startsWith("field(")) { | ||
| return vector->field(); | ||
| } else if (command.startsWith("filename(")) { | ||
| return vector->filename(); | ||
| } else if (command.startsWith("start(")) { | ||
| return QString::number(vector->startFrame()); | ||
| } else if (command.startsWith("NFrames(")) { | ||
| return QString::number(vector->numFrames()); | ||
| } else if (command.startsWith("skip(")) { | ||
| return QString::number(vector->skip()); | ||
| } else if (command.startsWith("boxcarFirst(")) { | ||
| return vector->doAve()?"True":"False"; | ||
| } | ||
|
|
||
| return "No such command"; | ||
| } | ||
|
|
||
| bool VectorDataSI::isValid() { | ||
| return vector.isPtrValid(); | ||
| } | ||
|
|
||
| ScriptInterface* VectorDataSI::newVector(ObjectStore *store) { | ||
| DataVectorPtr vector; | ||
| vector = store->createObject<DataVector>(); | ||
| return new VectorDataSI(vector); | ||
| } | ||
|
|
||
| QByteArray VectorDataSI::endEditUpdate() { | ||
| vector->registerChange(); | ||
| UpdateManager::self()->doUpdates(true); | ||
| UpdateServer::self()->requestUpdateSignal(); | ||
| return ("Finished editing "+vector->Name()).toLatin1(); | ||
| } | ||
|
|
||
| /******************************************************/ | ||
| /* Generated Vectors */ | ||
| /******************************************************/ | ||
| VectorGenSI::VectorGenSI(GeneratedVectorPtr it) { | ||
| vector=it; | ||
| } | ||
|
|
||
| QString VectorGenSI::doCommand(QString command) { | ||
|
|
||
| QString v=doVectorScriptCommand(command, vector); | ||
| if (!v.isEmpty()) { | ||
| return v; | ||
| } | ||
|
|
||
| if (command.startsWith(QLatin1String("change("))) { | ||
| command.remove("change(").remove(')'); | ||
| QStringList p = command.split(','); | ||
|
|
||
| vector->writeLock(); | ||
|
|
||
| vector->changeRange( | ||
| p.at(0).toDouble(), // start | ||
| p.at(1).toDouble(), // end | ||
| p.at(2).toInt() // number of points | ||
| ); | ||
| vector->unlock(); | ||
| return "Done"; | ||
| } | ||
|
|
||
| return "No such command"; | ||
| } | ||
|
|
||
| bool VectorGenSI::isValid() { | ||
| return vector.isPtrValid(); | ||
| } | ||
|
|
||
| ScriptInterface* VectorGenSI::newVector(ObjectStore *store) { | ||
| GeneratedVectorPtr vector; | ||
| vector = store->createObject<GeneratedVector>(); | ||
| return new VectorGenSI(vector); | ||
| } | ||
|
|
||
| QByteArray VectorGenSI::endEditUpdate() { | ||
| vector->registerChange(); | ||
| UpdateManager::self()->doUpdates(true); | ||
| UpdateServer::self()->requestUpdateSignal(); | ||
| return ("Finished editing "+vector->Name()).toLatin1(); | ||
| } | ||
|
|
||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /*************************************************************************** | ||
| * * | ||
| * copyright : (C) 2014 Barth Netterfield * | ||
| * netterfield@astro.utoronto.ca * | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef VECTORSCRIPTINTERFACE_H | ||
| #define VECTORSCRIPTINTERFACE_H | ||
|
|
||
| #include <QString> | ||
|
|
||
| #include "scriptinterface.h" | ||
| #include "datavector.h" | ||
| #include "generatedvector.h" | ||
|
|
||
| namespace Kst { | ||
|
|
||
| class VectorDataSI : public ScriptInterface | ||
| { | ||
| Q_OBJECT | ||
| DataVectorPtr vector; | ||
| public: | ||
| explicit VectorDataSI(DataVectorPtr it); | ||
| QString doCommand(QString); | ||
| bool isValid(); | ||
| QByteArray endEditUpdate(); | ||
|
|
||
| static ScriptInterface* newVector(ObjectStore *store); | ||
| }; | ||
|
|
||
| class VectorGenSI : public ScriptInterface | ||
| { | ||
| Q_OBJECT | ||
| GeneratedVectorPtr vector; | ||
| public: | ||
| explicit VectorGenSI(GeneratedVectorPtr it); | ||
| QString doCommand(QString); | ||
| bool isValid(); | ||
| QByteArray endEditUpdate(); | ||
|
|
||
| static ScriptInterface* newVector(ObjectStore *store); | ||
| }; | ||
|
|
||
| } | ||
| #endif // VECTORSCRIPTINTERFACE_H |