185 changes: 142 additions & 43 deletions pyKst/pykst.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import os
import ctypes
#from time import sleep
#from PyQt4 import QtCore, QtNetwork
from PySide import QtCore, QtNetwork
from PyQt4 import QtCore, QtNetwork
#from PySide import QtCore, QtNetwork
from numpy import *
import tempfile
import time
import subprocess


#from pykstpp import *

Expand Down Expand Up @@ -38,7 +41,10 @@ def __init__(self,serverName="kstScript"):
self.ls.waitForConnected(300)
self.serverName=serverName
if self.ls.state()==QtNetwork.QLocalSocket.UnconnectedState:
os.system("kst2 --serverName="+str(serverName)+"&")
#os.system("kst2 --serverName="+str(serverName)+"&")
subprocess.Popen(["kst2", "--serverName="+str(serverName)])
#time.sleep(1)

while self.ls.state()==QtNetwork.QLocalSocket.UnconnectedState:
self.ls.connectToServer(serverName)
self.ls.waitForConnected(300)
Expand Down Expand Up @@ -238,7 +244,7 @@ def editable_vector(self, name):
See :class:`EditableVector`
"""
return Editable(self, None, name, new=False)
return EditableVector(self, None, name, new=False)

def new_data_matrix(self, filename, field, startX=0, startY=0, nX=-1, nY=-1,
minX=0, minY=0, dX=1, dY=1,name="") :
Expand All @@ -256,6 +262,20 @@ def data_matrix(self, name):
"""
return DataMatrix(self, "", "", name=name, new=False)

def new_editable_matrix(self, np_array = None, name=""):
""" Create a New Editable Matrix in kst.
See :class:`EditableMatrix`
"""
return EditableMatrix(self, np_array, name)

def editable_matrix(self, name):
""" Returns an Editable Matrix from kst given its name.
See :class:`EditableMatrix`
"""
return EditableMatrix(self, None, name, new=False)

def new_curve(self, xVector, yVector, name=""):
""" Create a New Curve in kst.
Expand Down Expand Up @@ -488,7 +508,7 @@ def new_arrow(self,pos=(0.1,0.1), length=0.1, rot=0,
strokeCapStyle, name)

def arrow(self, name):
""" Returns a Arrow from kst given its name.
""" Returns an Arrow from kst given its name.
See :class:`Arrow`
"""
Expand Down Expand Up @@ -555,12 +575,26 @@ def name(self):
""" Returns the name of the object from inside kst. """
return self.client.send_si(self.handle, "name()")

def description_tip(self):
""" Returns a string describing the vector """
return self.client.send_si(self.handle, "descriptionTip()")

class String(NamedObject) :

class Object(NamedObject) :
""" Convenience class. You should not use it directly."""
def __init__(self,client) :
NamedObject.__init__(self,client)

def type_str(self):
""" Returns the type of the object from inside kst. """
return self.client.send_si(self.handle, "type()")


class String(Object) :
""" Convenience class. You should not use it directly."""
def __init__(self,client) :
Object.__init__(self,client)

def value(self) :
""" Returns the string. """
return self.client.send_si(self.handle, "value()")
Expand Down Expand Up @@ -635,10 +669,10 @@ def change(self,filename,field):
self.client.send_si(self.handle, b2str("change("+b2str(filename)+","+b2str(field)+")"))


class Scalar(NamedObject) :
class Scalar(Object) :
""" Convenience class. You should not use it directly."""
def __init__(self,client) :
NamedObject.__init__(self,client)
Object.__init__(self,client)

def value(self) :
""" Returns the scalar. """
Expand Down Expand Up @@ -779,10 +813,10 @@ def frame(self) :
""" Returns the fame. """
return self.client.send_si(self.handle, "frame()")

class VectorBase(NamedObject):
class VectorBase(Object):
""" Convenience class. You should not use it directly."""
def __init__(self,client) :
NamedObject.__init__(self,client)
Object.__init__(self,client)

def value(self,index):
""" Returns element i of this vector. """
Expand All @@ -804,10 +838,6 @@ def max(self):
""" Returns the maximum value in the vector. """
return self.client.send_si(self.handle, "max()")

def description_tip(self):
""" Returns a string describing the vector """
return self.client.send_si(self.handle, "descriptionTip()")

def get_numpy_array(self) :
""" get a numpy array which contains the kst vector values """
with tempfile.NamedTemporaryFile() as f:
Expand Down Expand Up @@ -974,11 +1004,22 @@ def __init__(self, client, np_array = None, name="", new=True) :
else:
self.handle = name

def load(self, np_array):
""" sets the value of the vector to that of the float64
1D np array """

assert(np_array.dtype == float64)

with tempfile.NamedTemporaryFile() as f:
np_array.tofile(f.name)
retval = self.client.send_si(self.handle, "load(" + f.name + ")")

return retval

class Matrix(NamedObject):
class Matrix(Object):
""" Convenience class. You should not use it directly."""
def __init__(self,client) :
NamedObject.__init__(self,client)
Object.__init__(self,client)

def value(self,i_x, i_y):
""" Returns element (i_x, i_y} of this matrix. """
Expand Down Expand Up @@ -1024,10 +1065,17 @@ def min_x(self):
def min_y(self):
""" Returns the minimum X location of the matrix, for when the matrix is used in an image. """
return self.client.send_si(self.handle, "minX()")

def get_numpy_array(self) :
""" get a numpy array which contains the kst matrix values """
with tempfile.NamedTemporaryFile() as f:
args = str(self.client.send_si(self.handle, "store(" + f.name + ")"))
dims = tuple(map(int, args.split()))
array = fromfile(f.name, dtype = float64)
array = array.reshape((dims))

return array

def description_tip(self):
""" Returns a string describing the vector """
return self.client.send_si(self.handle, "descriptionTip()")

class DataMatrix(Matrix):
""" Create a Data Matrix which reads from a data source inside kst.
Expand Down Expand Up @@ -1103,10 +1151,61 @@ def start_y(self):
""" Returns the Y index of the matrix in the file """
return self.client.send_si(self.handle, "startX()")

class Relation(NamedObject):
class EditableMatrix(Matrix):
""" A matrix in kst, which is editable from python.
This matrix in kst can be created from 2D float64 numpy array,
(with ''load()'') or edited point by point (with ''setValue()'').
:param np_array: initialize the matrix in kst to this 2D numpy array.
To create an editable matrix from the num py array np::
import pykst as kst
client = kst.Client()
m = client.new_editable_matrix(np)
"""
def __init__(self, client, np_array = None, name="", new=True) :
Matrix.__init__(self,client)

if (new == True):
self.client.send("newEditableMatrix()")
if (np_array != None) :
assert(np_array.dtype == float64)
nx = np_array.shape[0]
ny = np_array.shape[1]

with tempfile.NamedTemporaryFile() as f:
np_array.tofile(f.name)
self.client.send("load(" + f.name + ","+b2str(nx)+","+b2str(ny)+")")

self.handle=self.client.send("endEdit()")
self.handle.remove(0,self.handle.indexOf("ing ")+4)

self.set_name(name)
else:
self.handle = name

def load(self, np_array):
""" sets the values of the matrix in kst to that of the float64
2D np array """

assert(np_array.dtype == float64)
nx = np_array.shape[0]
ny = np_array.shape[1]

with tempfile.NamedTemporaryFile() as f:
np_array.tofile(f.name)
retval = self.client.send_si(self.handle, "load(" + f.name + ","+b2str(nx)+","+b2str(ny)+")")

return retval


class Relation(Object):
""" Convenience class. You should not use it directly."""
def __init__(self,client) :
NamedObject.__init__(self,client)
Object.__init__(self,client)

def max_x(self):
""" Returns the max X value of the curve or image. """
Expand Down Expand Up @@ -1422,33 +1521,33 @@ def __init__(self,client, matrix, name="", new=True) :
else:
self.handle = name

def setMatrix(self, matrix):
def set_matrix(self, matrix):
""" change the matrix which is the source of the image. """
self.client.send_si(self.handle, "setMatrix("+matrix.handle+")")

def setPalette(self, palette):
def set_palette(self, palette):
""" set the palette, selected by index.
The available palettes are::
0: Grey
1: Red
2: Spectrum
3: EOS-A
4: EOS-B
5: 8 colors
6: Cyclical Spectrum
0: Grey
1: Red
2: Spectrum
3: EOS-A
4: EOS-B
5: 8 colors
6: Cyclical Spectrum
Note: this is not the same order as the dialog.
"""
self.client.send_si(self.handle, "setPalette("+b2str(palette)+")")

def setRange(self, zmin, zmax):
def set_range(self, zmin, zmax):
""" sets the z range of the color map."""
self.client.send_si(self.handle, "setFixedColorRange("+
b2str(zmin)+","+b2str(zmax)+")")

def setAutoRange(self, saturated=0):
def set_auto_range(self, saturated=0):
""" Automatically set the z range of the color map
:param saturated: The colormap range is set so that this fraction
Expand All @@ -1467,7 +1566,7 @@ def min_z(self):
return self.client.send_si(self.handle, "minZ()")

# Equation ############################################################
class Equation(NamedObject) :
class Equation(Object) :
""" An equation inside kst.
:param xvector: the x vector of the equation
Expand All @@ -1476,7 +1575,7 @@ class Equation(NamedObject) :
Vectors inside kst are refered to as [vectorname] or [scalarname].
"""
def __init__(self, client, xvector, equation, name="", new=True) :
NamedObject.__init__(self,client)
Object.__init__(self,client)

if (new == True):
self.client.send("newEquation()")
Expand Down Expand Up @@ -1505,7 +1604,7 @@ def set_x(self, xvector):
self.client.send_si(self.handle, "setInputVector(X,"+xvector.handle+")")

# Histogram ############################################################
class Histogram(NamedObject) :
class Histogram(Object) :
""" A Histogram inside kst.
:param vector: the vector to take the histogram of
Expand All @@ -1524,7 +1623,7 @@ class Histogram(NamedObject) :
def __init__(self, client, vector, bin_min, bin_max, n_bins,
normalization = 0, auto_bin = False,
name="", new=True) :
NamedObject.__init__(self,client)
Object.__init__(self,client)

if (new == True):
self.client.send("newHistogram()")
Expand Down Expand Up @@ -1604,7 +1703,7 @@ def auto_bin(self):
return retval

# Spectrum ############################################################
class Spectrum(NamedObject) :
class Spectrum(Object) :
""" An spectrum inside kst.
:param vector: the vector to take the spectrum of
Expand Down Expand Up @@ -1650,7 +1749,7 @@ def __init__(self, client,
interpolate_over_holes = True,
name="", new=True) :

NamedObject.__init__(self,client)
Object.__init__(self,client)

if (new == True):
self.client.send("newSpectrum()")
Expand Down Expand Up @@ -1765,10 +1864,10 @@ def interpolate_over_holes(self):


# FIT ###################################################################
class Fit(NamedObject) :
class Fit(Object) :
""" This is a class which provides some methods common to all fits """
def __init__(self,client) :
NamedObject.__init__(self,client)
Object.__init__(self,client)

def parameters(self) :
""" a vector containing the Parameters of the fit """
Expand Down Expand Up @@ -2126,9 +2225,9 @@ def set_text(self,text):
When the scalar is updated, the label is updated.
The format is::
Scalar: [scalarname] eg [GYRO1:Mean(X4)]
Vector Element: [vectorName[index]] eg [GYRO1 (V2)[4]]
Equation: [=equation] eg [=[GYRO1:Mean(X4)]/[GYRO1:Sigma (X4)]]
Scalar: [scalarname] eg [GYRO1:Mean(X4)]
Vector Element: [vectorName[index]] eg [GYRO1 (V2)[4]]
Equation: [=equation] eg [=[GYRO1:Mean(X4)]/[GYRO1:Sigma (X4)]]
Labels in kst support a derrivitive subset of LaTeX. For example,
to display the equation for the area of a circle, you could set the
Expand Down
2 changes: 1 addition & 1 deletion src/libkst/datamatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ DataMatrix::~DataMatrix() {
}

ScriptInterface* DataMatrix::createScriptInterface() {
return new MatrixDataSI(this);
return new DataMatrixSI(this);
}


Expand Down
30 changes: 30 additions & 0 deletions src/libkst/editablematrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// qCompress the bytearray

#include "editablematrix.h"
#include "matrixscriptinterface.h"

#include "debug.h"
#include <qbytearray.h>
#include <QXmlStreamWriter>
Expand Down Expand Up @@ -60,5 +62,33 @@ void EditableMatrix::save(QXmlStreamWriter &xml) {
}


QString EditableMatrix::descriptionTip() const {
return tr("%1:\n"
" %2 x %3").arg(Name()).arg(xNumSteps()).arg(yNumSteps());
}

QString EditableMatrix::_automaticDescriptiveName() const {
return tr("Editable Matrix");
}

/** used for scripting IPC.
accepts an open readable file.
fails silently */
void EditableMatrix::loadFromTmpFile(QFile &fp, int nx, int ny ) {
int size = nx*ny*sizeof(double);

resize(nx, ny);

fp.read((char *)_z, size);

internalUpdate(); // not sure if we need this here.
}


ScriptInterface* EditableMatrix::createScriptInterface() {
return new EditableMatrixSI(this);
}


}
// vim: ts=2 sw=2 et
8 changes: 8 additions & 0 deletions src/libkst/editablematrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ class KSTCORE_EXPORT EditableMatrix : public Matrix {

virtual void save(QXmlStreamWriter &xml);

virtual QString descriptionTip() const;

void loadFromTmpFile(QFile &fp, int nx, int ny);

protected:
EditableMatrix(ObjectStore *store);

friend class ObjectStore;

virtual QString _automaticDescriptiveName() const;

ScriptInterface* createScriptInterface();
};

typedef SharedPtr<EditableMatrix> EditableMatrixPtr;
Expand Down
2 changes: 1 addition & 1 deletion src/libkst/editablevector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "vector.h"
#include "kst_export.h"

#include <QFile>
//#include <QFile>

/**A vector with n editable pts
*@author cbn
Expand Down
17 changes: 17 additions & 0 deletions src/libkst/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,5 +704,22 @@ QByteArray Matrix::getBinaryArray() const {
return ret;
}

/* used for scripting IPC
accepts an open writable file.
returns false on failure */
bool Matrix::saveToTmpFile(QFile &fp) {
qint64 n_written;
qint64 n_write;

n_write = _nX*_nY*sizeof(double);

n_written = fp.write((char *)_z, n_write);

fp.flush();

return (n_write == n_written);
}


}
// vim: ts=2 sw=2 et
3 changes: 3 additions & 0 deletions src/libkst/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class KSTCORE_EXPORT Matrix : public Primitive

QByteArray getBinaryArray() const;

/** dump the matrix values to a raw binary file */
bool saveToTmpFile(QFile &fp);

protected:
int _NS;
int _NRealS; // number of samples with real values
Expand Down
302 changes: 225 additions & 77 deletions src/libkst/matrixscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,111 +22,259 @@

namespace Kst {

QString doMatrixScriptCommand(QString command,Matrix *matrix) {
/***************************/
/* common matrix commands */
/***************************/

QString v=ScriptInterface::doNamedObjectCommand(command, matrix);
QString MatrixCommonSI::value(QString &command) {
QStringList vars = getArgs(command);

return QString::number(_matrix->value(vars[0].toDouble(), vars[1].toDouble()));
}

QString MatrixCommonSI::length(QString &) {
return QString::number(_matrix->sampleCount());
}

QString MatrixCommonSI::min(QString &) {
return QString::number(_matrix->minValue());
}

QString MatrixCommonSI::max(QString &) {
return QString::number(_matrix->maxValue());
}

QString MatrixCommonSI::mean(QString &) {
return QString::number(_matrix->meanValue());
}

QString MatrixCommonSI::width(QString &) {
return QString::number(_matrix->xNumSteps());
}

QString MatrixCommonSI::height(QString &) {
return QString::number(_matrix->yNumSteps());
}

QString MatrixCommonSI::dX(QString &) {
return QString::number(_matrix->xStepSize());
}

QString MatrixCommonSI::dY(QString &) {
return QString::number(_matrix->yStepSize());
}

QString MatrixCommonSI::minX(QString &) {
return QString::number(_matrix->minX());
}

QString MatrixCommonSI::minY(QString &) {
return QString::number(_matrix->minY());
}

QString MatrixCommonSI::store(QString & command) {
QString arg = getArg(command);
QFile tmpfile(arg);

bool ok = tmpfile.open(QIODevice::WriteOnly);
ok |= _matrix->saveToTmpFile(tmpfile);
tmpfile.close();

if (ok) {
return QString("%1 %2").arg(_matrix->xNumSteps()).arg(_matrix->yNumSteps());
} else {
return "Error writing tmp file";
}
}


/******************************************************/
/* Data Matrix */
/******************************************************/
DataMatrixSI::DataMatrixSI(DataMatrixPtr it) {
_datamatrix = it;
_matrix = it;

_fnMap.insert("change",&DataMatrixSI::change);
_fnMap.insert("field",&DataMatrixSI::field);
_fnMap.insert("filename",&DataMatrixSI::filename);
_fnMap.insert("startX",&DataMatrixSI::startX);
_fnMap.insert("startY",&DataMatrixSI::startY);

// Matrix Common Commands
_fnMap.insert("value",&DataMatrixSI::value);
_fnMap.insert("length",&DataMatrixSI::length);
_fnMap.insert("min",&DataMatrixSI::min);
_fnMap.insert("max",&DataMatrixSI::max);
_fnMap.insert("mean",&DataMatrixSI::mean);
_fnMap.insert("width",&DataMatrixSI::width);
_fnMap.insert("height",&DataMatrixSI::height);
_fnMap.insert("dX",&DataMatrixSI::dX);
_fnMap.insert("dY",&DataMatrixSI::dY);
_fnMap.insert("minX",&DataMatrixSI::minX);
_fnMap.insert("minY",&DataMatrixSI::minY);
_fnMap.insert("store",&DataMatrixSI::store);
}

QString DataMatrixSI::doCommand(QString command_in) {

if (!_datamatrix) {
return "invalid";
}

QString command = command_in.left(command_in.indexOf('('));

DataMatrixInterfaceMemberFn fn=_fnMap.value(command,&DataMatrixSI::noSuchFn);

if(fn!=&DataMatrixSI::noSuchFn) {
return CALL_MEMBER_FN(*this,fn)(command_in);
}

QString v=doObjectCommand(command_in, _datamatrix);
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 "No such command";
}

return QString();
bool DataMatrixSI::isValid() {
return _datamatrix.isPtrValid();
}

ScriptInterface* DataMatrixSI::newMatrix(ObjectStore *store) {
DataMatrixPtr matrix;
matrix = store->createObject<DataMatrix>();
return new DataMatrixSI(matrix);
}

QByteArray DataMatrixSI::endEditUpdate() {
_datamatrix->registerChange();
UpdateManager::self()->doUpdates(true);
UpdateServer::self()->requestUpdateSignal();
return ("Finished editing "+_datamatrix->Name()).toLatin1();
}

/***************************/
/* data matrix commands */
/***************************/

QString DataMatrixSI::change(QString& command) {
QStringList vars = getArgs(command);

DataSourcePtr ds = DataSourcePluginManager::findOrLoadSource(
_datamatrix->store(), vars.at(0));
_datamatrix->writeLock();
_datamatrix->change(ds,
vars.at(1), // field
vars.at(2).toInt(), // x start
vars.at(3).toInt(), // y start
vars.at(4).toInt(), // num x steps
vars.at(5).toInt(), // num y steps

false, false, 0,

vars.at(6).toDouble(), // min x
vars.at(7).toDouble(), // min y
vars.at(8).toDouble(), // step x
vars.at(9).toDouble() // step y
);
_datamatrix->unlock();
return "Done";
}

QString DataMatrixSI::field(QString& command) {
QString arg = getArg(command);
return _datamatrix->field();
}

QString DataMatrixSI::filename(QString& command) {
QString arg = getArg(command);
return _datamatrix->filename();
}

QString DataMatrixSI::startX(QString& command) {
QString arg = getArg(command);
return QString::number(_datamatrix->reqXStart());
}

QString DataMatrixSI::startY(QString& command) {
QString arg = getArg(command);
return QString::number(_datamatrix->reqYStart());
}


/******************************************************/
/* Data Matrixs */
/* Editable Matrix */
/******************************************************/
MatrixDataSI::MatrixDataSI(DataMatrixPtr it) {
matrix=it;
EditableMatrixSI::EditableMatrixSI(EditableMatrixPtr it) {
_editablematrix = it;
_matrix = it;

_fnMap.insert("load", &EditableMatrixSI::load);

// Matrix Common Commands
_fnMap.insert("value",&EditableMatrixSI::value);
_fnMap.insert("length",&EditableMatrixSI::length);
_fnMap.insert("min",&EditableMatrixSI::min);
_fnMap.insert("max",&EditableMatrixSI::max);
_fnMap.insert("mean",&EditableMatrixSI::mean);
_fnMap.insert("width",&EditableMatrixSI::width);
_fnMap.insert("height",&EditableMatrixSI::height);
_fnMap.insert("dX",&EditableMatrixSI::dX);
_fnMap.insert("dY",&EditableMatrixSI::dY);
_fnMap.insert("minX",&EditableMatrixSI::minX);
_fnMap.insert("minY",&EditableMatrixSI::minY);
_fnMap.insert("store",&EditableMatrixSI::store);
}

QString MatrixDataSI::doCommand(QString command) {
QString EditableMatrixSI::doCommand(QString command_in) {

QString v=doMatrixScriptCommand(command, matrix);
if (!v.isEmpty()) {
return v;
if (!_editablematrix) {
return "invalid";
}

QString command = command_in.left(command_in.indexOf('('));

EditableMatrixInterfaceMemberFn fn=_fnMap.value(command,&EditableMatrixSI::noSuchFn);

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());
if(fn!=&EditableMatrixSI::noSuchFn) {
return CALL_MEMBER_FN(*this,fn)(command_in);
}

QString v=doObjectCommand(command_in, _editablematrix);
if (!v.isEmpty()) {
return v;
}

return "No such command";
}

bool MatrixDataSI::isValid() {
return matrix.isPtrValid();
bool EditableMatrixSI::isValid() {
return _editablematrix.isPtrValid();
}

ScriptInterface* MatrixDataSI::newMatrix(ObjectStore *store) {
DataMatrixPtr matrix;
matrix = store->createObject<DataMatrix>();
return new MatrixDataSI(matrix);
ScriptInterface* EditableMatrixSI::newMatrix(ObjectStore *store) {
EditableMatrixPtr matrix;
matrix = store->createObject<EditableMatrix>();
return new EditableMatrixSI(matrix);
}

QByteArray MatrixDataSI::endEditUpdate() {
matrix->registerChange();
QByteArray EditableMatrixSI::endEditUpdate() {
_editablematrix->registerChange();
UpdateManager::self()->doUpdates(true);
UpdateServer::self()->requestUpdateSignal();
return ("Finished editing "+matrix->Name()).toLatin1();
return ("Finished editing "+_editablematrix->Name()).toLatin1();
}

QString EditableMatrixSI::load(QString& command) {
QStringList vars = getArgs(command);

QFile tmpfile(vars[0]);
tmpfile.open(QIODevice::ReadOnly);

_editablematrix->loadFromTmpFile(tmpfile, vars[1].toInt(), vars[2].toInt());
return "done";
}

}
68 changes: 65 additions & 3 deletions src/libkst/matrixscriptinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,82 @@

#include "scriptinterface.h"
#include "datamatrix.h"
#include "editablematrix.h"

namespace Kst {

class KSTCORE_EXPORT MatrixDataSI : public ScriptInterface
/*******************/
class KSTCORE_EXPORT MatrixCommonSI : public ScriptInterface
{
Q_OBJECT

public:
QString value(QString& command);
QString length(QString&);
QString min(QString&);
QString max(QString&);
QString mean(QString&);
QString width(QString&);
QString height(QString&);
QString dX(QString&);
QString dY(QString&);
QString minX(QString&);
QString minY(QString&);
QString store(QString &command);

protected:
MatrixPtr _matrix;
QString noSuchFn(QString&) {return ""; }

};


/*******************/
class DataMatrixSI;
typedef QString (DataMatrixSI::*DataMatrixInterfaceMemberFn)(QString& command);

class KSTCORE_EXPORT DataMatrixSI : public MatrixCommonSI
{
Q_OBJECT
public:
explicit DataMatrixSI(DataMatrixPtr it);
QString doCommand(QString);
bool isValid();
QByteArray endEditUpdate();

static ScriptInterface* newMatrix(ObjectStore *store);

QString change(QString &);
QString field(QString &);
QString filename(QString &);
QString startX(QString &);
QString startY(QString &);

private:
QMap<QString,DataMatrixInterfaceMemberFn> _fnMap;
DataMatrixPtr _datamatrix;
};

/*******************/
class EditableMatrixSI;
typedef QString (EditableMatrixSI::*EditableMatrixInterfaceMemberFn)(QString& command);

class KSTCORE_EXPORT EditableMatrixSI : public MatrixCommonSI
{
Q_OBJECT
DataMatrixPtr matrix;
public:
explicit MatrixDataSI(DataMatrixPtr it);
explicit EditableMatrixSI(EditableMatrixPtr it);
QString doCommand(QString);
bool isValid();
QByteArray endEditUpdate();

static ScriptInterface* newMatrix(ObjectStore *store);

QString load(QString &);

private:
QMap<QString,EditableMatrixInterfaceMemberFn> _fnMap;
EditableMatrixPtr _editablematrix;
};

}
Expand Down
6 changes: 3 additions & 3 deletions src/libkst/scalarscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ScalarGenSI::ScalarGenSI(ScalarPtr it) {

QString ScalarGenSI::doCommand(QString x) {

QString v=doNamedObjectCommand(x, scalar);
QString v=doObjectCommand(x, scalar);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -74,7 +74,7 @@ ScalarDataSI::ScalarDataSI(DataScalarPtr it) {

QString ScalarDataSI::doCommand(QString x) {

QString v=doNamedObjectCommand(x, scalar);
QString v=doObjectCommand(x, scalar);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ ScalarVectorSI::ScalarVectorSI(VScalarPtr it) {

QString ScalarVectorSI::doCommand(QString x) {

QString v=doNamedObjectCommand(x, scalar);
QString v=doObjectCommand(x, scalar);
if (!v.isEmpty()) {
return v;
}
Expand Down
17 changes: 17 additions & 0 deletions src/libkst/scriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "scriptinterface.h"

#include "namedobject.h"
#include "object.h"

#include <QStringList>

Expand All @@ -25,6 +26,22 @@ namespace Kst {
return QString("Done");
} else if (command.startsWith("name(")) {
return n->Name();
} else if (command.startsWith("descriptionTip(")) {
return n->descriptionTip();
}

return QString();
}

QString ScriptInterface::doObjectCommand(QString command, ObjectPtr ob) {

QString v=doNamedObjectCommand(command, ob);
if (!v.isEmpty()) {
return v;
}

if (command.startsWith("type(")) {
return ob->typeString();
}

return QString();
Expand Down
3 changes: 2 additions & 1 deletion src/libkst/scriptinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QObject>

#include "kst_export.h"
#include "object.h"

typedef QList<QByteArray> QByteArrayList;

Expand All @@ -41,7 +42,7 @@ class KSTCORE_EXPORT ScriptInterface : public QObject
virtual bool isValid()=0;
virtual QByteArray endEditUpdate()=0;
static QString doNamedObjectCommand(QString command, NamedObject *n);

static QString doObjectCommand(QString command, ObjectPtr ob);

QStringList getArgs(const QString &command);
QString getArg(const QString &command);
Expand Down
4 changes: 2 additions & 2 deletions src/libkst/stringscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ StringGenSI::StringGenSI(StringPtr it) {

QString StringGenSI::doCommand(QString x) {

QString v=doNamedObjectCommand(x, str);
QString v=doObjectCommand(x, str);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -69,7 +69,7 @@ StringDataSI::StringDataSI(DataStringPtr it) {

QString StringDataSI::doCommand(QString x) {

QString v=doNamedObjectCommand(x, str);
QString v=doObjectCommand(x, str);
if (!v.isEmpty()) {
return v;
}
Expand Down
16 changes: 4 additions & 12 deletions src/libkst/vectorscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ QString VectorCommonSI::mean(QString &) {
return QString::number(_vector->mean());
}

QString VectorCommonSI::descriptionTip(QString &) {
return _vector->descriptionTip();
}

QString VectorCommonSI::store(QString & command) {
QString arg = getArg(command);
QFile tmpfile(arg);
Expand Down Expand Up @@ -82,7 +78,6 @@ VectorSI::VectorSI(VectorPtr it) {
_fnMap.insert("min",&VectorSI::min);
_fnMap.insert("max",&VectorSI::max);
_fnMap.insert("mean",&VectorSI::mean);
_fnMap.insert("descriptionTip",&VectorSI::descriptionTip);
_fnMap.insert("store",&VectorSI::store);
}

Expand All @@ -100,7 +95,7 @@ QString VectorSI::doCommand(QString command_in) {
return CALL_MEMBER_FN(*this,fn)(command_in);
}

QString v=doNamedObjectCommand(command_in, _vector);
QString v=doObjectCommand(command_in, _vector);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -149,7 +144,6 @@ DataVectorSI::DataVectorSI(DataVectorPtr it) {
_fnMap.insert("min",&DataVectorSI::min);
_fnMap.insert("max",&DataVectorSI::max);
_fnMap.insert("mean",&DataVectorSI::mean);
_fnMap.insert("descriptionTip",&DataVectorSI::descriptionTip);
_fnMap.insert("store",&DataVectorSI::store);

}
Expand All @@ -168,7 +162,7 @@ QString DataVectorSI::doCommand(QString command_in) {
return CALL_MEMBER_FN(*this,fn)(command_in);
}

QString v=doNamedObjectCommand(command_in, _vector);
QString v=doObjectCommand(command_in, _vector);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -264,7 +258,6 @@ GeneratedVectorSI::GeneratedVectorSI(GeneratedVectorPtr it) {
_fnMap.insert("min",&GeneratedVectorSI::min);
_fnMap.insert("max",&GeneratedVectorSI::max);
_fnMap.insert("mean",&GeneratedVectorSI::mean);
_fnMap.insert("descriptionTip",&GeneratedVectorSI::descriptionTip);
_fnMap.insert("store",&GeneratedVectorSI::store);
}

Expand All @@ -282,7 +275,7 @@ QString GeneratedVectorSI::doCommand(QString command_in) {
return CALL_MEMBER_FN(*this,fn)(command_in);
}

QString v=doNamedObjectCommand(command_in, _vector);
QString v=doObjectCommand(command_in, _vector);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -351,7 +344,6 @@ EditableVectorSI::EditableVectorSI(EditableVectorPtr it) {
_fnMap.insert("min",&EditableVectorSI::min);
_fnMap.insert("max",&EditableVectorSI::max);
_fnMap.insert("mean",&EditableVectorSI::mean);
_fnMap.insert("descriptionTip",&EditableVectorSI::descriptionTip);

}

Expand All @@ -369,7 +361,7 @@ QString EditableVectorSI::doCommand(QString command_in) {
return CALL_MEMBER_FN(*this,fn)(command_in);
}

QString v=doNamedObjectCommand(command_in, _vector);
QString v=doObjectCommand(command_in, _vector);
if (!v.isEmpty()) {
return v;
}
Expand Down
1 change: 0 additions & 1 deletion src/libkst/vectorscriptinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class KSTCORE_EXPORT VectorCommonSI : public ScriptInterface
QString min(QString&);
QString max(QString&);
QString mean(QString&);
QString descriptionTip(QString&);
QString store(QString &command);

protected:
Expand Down
269 changes: 8 additions & 261 deletions src/libkstapp/scriptserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ScriptServer::ScriptServer(ObjectStore *obj) : _server(new QLocalServer(this)),
_fnMap.insert("newDataMatrix()",&ScriptServer::newDataMatrix);

_fnMap.insert("getEditableMatrixList()",&ScriptServer::getEditableMatrixList);
_fnMap.insert("newEditableMatrixAndGetHandle()",&ScriptServer::newEditableMatrixAndGetHandle);
_fnMap.insert("newEditableMatrix()",&ScriptServer::newEditableMatrix);

_fnMap.insert("getScalarList()",&ScriptServer::getScalarList);
_fnMap.insert("newGeneratedScalar()",&ScriptServer::newGeneratedScalar);
Expand Down Expand Up @@ -528,7 +528,7 @@ QByteArray ScriptServer::newDataMatrix(QByteArray&, QLocalSocket* s,ObjectStore*
if(_interface) {
return handleResponse("To access this function, first call endEdit()",s);
} else {
_interface = MatrixDataSI::newMatrix(_store); return handleResponse("Ok",s);
_interface = DataMatrixSI::newMatrix(_store); return handleResponse("Ok",s);
}
}

Expand All @@ -538,15 +538,12 @@ QByteArray ScriptServer::getEditableMatrixList(QByteArray&, QLocalSocket* s,Obje
return outputObjectList<EditableMatrix>(s,_store);
}

QByteArray ScriptServer::newEditableMatrixAndGetHandle(QByteArray&, QLocalSocket* s,ObjectStore*) {

EditableMatrixPtr objectPtr=_store->createObject<EditableMatrix>();
objectPtr->writeLock();
objectPtr->setDescriptiveName("Script Matrix");
objectPtr->unlock();
UpdateManager::self()->doUpdates(1);
UpdateServer::self()->requestUpdateSignal();
return handleResponse("Finished editing "+objectPtr->Name().toLatin1(),s);
QByteArray ScriptServer::newEditableMatrix(QByteArray&, QLocalSocket* s,ObjectStore*) {
if(_interface) {
return handleResponse("To access this function, first call endEdit()",s);
} else {
_interface = EditableMatrixSI::newMatrix(_store); return handleResponse("Ok",s);
}
}


Expand Down Expand Up @@ -1031,255 +1028,5 @@ QByteArray ScriptServer::fileSave(QByteArray&command, QLocalSocket* s, ObjectSto
return handleResponse("Done",s);
}

/*
QByteArray ScriptServer::editableVectorSetBinaryArray(QByteArray&command, QLocalSocket* s, ObjectStore*) {
command.replace("EditableVector::setBinaryArray(","");
command.chop(1);
s->write("Handshake");
ObjectPtr o=_store->retrieveObject(command);
EditableVectorPtr v=kst_cast<EditableVector>(o);
if(!v) {
s->write("No such object.");
s->flush();
return "No such object.";
}
s->flush();
QDataStream ds(s);
s->waitForReadyRead(200000);
QByteArray copy;
QDataStream out(&copy,QIODevice::WriteOnly);
qint64 count;
ds>>count;
out<<count;
double x;
int bl=0;
for(int i=0;i<count;i++) {
while(!bl--) {
s->waitForReadyRead(-1);
bl=s->bytesAvailable()/sizeof(double);
}
ds>>x;
out<<x;
}
v->writeLock();
v->change(copy);
v->unlock();
s->write("Done.");
s->waitForBytesWritten(-1);
return "Done.";
}
*/

QByteArray ScriptServer::editableMatrixSetBinaryArray(QByteArray &command, QLocalSocket *s, ObjectStore *_store)
{
command.replace("EditableMatrix::setBinaryArray(","");
command.chop(1);
QByteArrayList params=command.split(',');
if(params.count()!=7) {
s->write("Invalid param count. Need 7.");
s->waitForBytesWritten(-1);
return "Invalid param count. Need 7.";
}
ObjectPtr o=_store->retrieveObject(params[0]);
EditableMatrixPtr v=kst_cast<EditableMatrix>(o);
if(!v) {
s->write("No such object.");
s->waitForBytesWritten(-1);
return "No such object.";
}
s->write("Handshake");
s->waitForBytesWritten(-1);

QDataStream ds(s);
s->waitForReadyRead(300);
QByteArray copy;
QDataStream out(&copy,QIODevice::WriteOnly);
qint64 _nX=params.at(1).toInt();
qint64 _nY=params.at(2).toInt();
double x;
int bl=0;
for(int i=0;i<_nX*_nY;i++) {
while(!bl--) {
s->waitForReadyRead(-1);
bl=s->bytesAvailable()/sizeof(double);
}
ds>>x;
out<<x;
}

v->writeLock();
v->change(copy,_nX,_nY,params[3].toDouble(),params[4].toDouble(),params[5].toDouble(),params[6].toDouble());
v->unlock();
s->write("Done.");
s->waitForBytesWritten(-1);
return "Done.";
}

/*
QByteArray ScriptServer::editableVectorSet(QByteArray&command, QLocalSocket* s, ObjectStore* _store) {
command.remove(0,20); //editableVectorSet(
command.chop(1);
QByteArrayList b=command.split(',');
if(b.size()<3) {
s->write("Invalid parameter count.");
s->waitForBytesWritten(-1);
return "Invalid parameter count.";
}
ObjectPtr o=_store->retrieveObject(b[0]);
EditableVectorPtr v=kst_cast<EditableVector>(o);
if(!v) {
s->write("No such object.");
s->waitForBytesWritten(-1);
return "No such object.";
}
v->setValue(b[1].toInt(),b[2].toDouble());
s->write("Done.");
s->waitForBytesWritten(-1);
return "Done.";
}
QByteArray ScriptServer::vectorGetBinaryArray(QByteArray&command, QLocalSocket* s, ObjectStore*) {
Q_ASSERT(sizeof(double)==sizeof(qint64)&&4096%sizeof(double)==0);
command.replace("Vector::getBinaryArray(","");
command.remove(command.indexOf(")"),99999);
ObjectPtr o=_store->retrieveObject(command);
VectorPtr v=kst_cast<Vector>(o);
if(!v) {
QByteArray ba;
QDataStream ds(&ba,QIODevice::WriteOnly);
ds<<(qint64)0;
s->write(ba,ba.size());
s->waitForReadyRead(30000);
s->read(3000000);
s->waitForBytesWritten(-1);
return "No object";
}
QByteArray x=v->getBinaryArray();
const char* d=x.data();
int pos=-8;
while(pos<x.size()) {
int thisProc=s->write(d,qMin(40960,x.size()-pos))/sizeof(double);
while(s->bytesToWrite()) {
s->waitForBytesWritten(-1);
}
d=&d[thisProc*8];
pos+=thisProc*8;
}
return "Data sent via handleResponse(...)";
}
*/

QByteArray ScriptServer::matrixGetBinaryArray(QByteArray&command, QLocalSocket* s, ObjectStore*) {

Q_ASSERT(sizeof(double)==sizeof(qint64)&&4096%sizeof(double)==0);

command.replace("Matrix::getBinaryArray(","");
command.remove(command.indexOf(")"),99999);
ObjectPtr o=_store->retrieveObject(command);
MatrixPtr m=kst_cast<Matrix>(o);
if(!m) {
QByteArray ba;
QDataStream ds(&ba,QIODevice::WriteOnly);
ds<<(qint64)0;
s->write(ba,ba.size());
s->waitForReadyRead(30000);
s->read(3000000);
s->waitForBytesWritten(-1);
return "No object";
}
QByteArray x=m->getBinaryArray();
const char* d=x.data();
int pos=-8;
while(pos<x.size()) {
int thisProc=s->write(d,qMin(40960,x.size()-pos))/sizeof(double);
while(s->bytesToWrite()) {
s->waitForBytesWritten(-1);
}
d=&d[thisProc*8];
pos+=thisProc*8;
}
return "Data sent via handleResponse(...)";
}

QByteArray ScriptServer::stringValue(QByteArray&command, QLocalSocket* s, ObjectStore*) {

command.replace("String::value(","");
command.remove(command.lastIndexOf(")"),999999);
ObjectPtr o=_store->retrieveObject(command);
StringPtr str=kst_cast<String>(o);
if(str) {
return handleResponse(str->value().toLatin1(),s);
} else {
return handleResponse("No such object (variables not supported)",s);;
}
}

QByteArray ScriptServer::stringSetValue(QByteArray&command, QLocalSocket* s, ObjectStore*) {

command.replace("String::setValue(","");
command.remove(command.lastIndexOf(")"),999999);
QByteArrayList x;
x.push_back(command);
x[0].remove(x.at(0).indexOf(","),99999);
x.push_back(command);
x[1].remove(0,x.at(1).indexOf(",")+1);
if(!x.at(0).size()) {
return handleResponse("Invalid call to setValueOfString(",s);
}
ObjectPtr o=_store->retrieveObject(x[0]);
StringPtr str=kst_cast<String>(o);
if(str) {
str->writeLock();
str->setValue(x[1]);
str->registerChange();
str->unlock();
return handleResponse("Okay",s);
} else {
return handleResponse("No such object (variables not supported)",s);;
}
}

QByteArray ScriptServer::scalarValue(QByteArray&command, QLocalSocket* s, ObjectStore*) {

command.replace("Scalar::value(","");
command.remove(command.lastIndexOf(")"),999999);
ObjectPtr o=_store->retrieveObject(command);
ScalarPtr sca=kst_cast<Scalar>(o);
if(sca) {
return handleResponse(QByteArray::number(sca->value()),s);
} else {
return handleResponse("No such object (variables not supported)",s);;
}
}

QByteArray ScriptServer::scalarSetValue(QByteArray&command, QLocalSocket* s, ObjectStore*) {

command.replace("Scalar::setValue(","");
command.remove(command.lastIndexOf(")"),999999);
QByteArrayList x;
x.push_back(command);
x[0].remove(x.at(0).indexOf(","),99999);
x.push_back(command);
x[1].remove(0,x.at(1).indexOf(",")+1);
if(!x.at(0).size()) {
return handleResponse("Invalid call to setValueOfScalar(",s);
}
ObjectPtr o=_store->retrieveObject(x[0]);
ScalarPtr sca=kst_cast<Scalar>(o);
if(sca) {
sca->writeLock();
sca->setValue(x[1].toDouble());
sca->registerChange();
sca->unlock();
return handleResponse("Okay",s);
} else {
return handleResponse("No such object (variables not supported)",s);;
}
}

}
31 changes: 1 addition & 30 deletions src/libkstapp/scriptserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public slots:
QByteArray newDataMatrix(QByteArray& command, QLocalSocket* s,ObjectStore*_store);

QByteArray getEditableMatrixList(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
QByteArray newEditableMatrixAndGetHandle(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
QByteArray newEditableMatrix(QByteArray& command, QLocalSocket* s,ObjectStore*_store);

QByteArray getScalarList(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
QByteArray newGeneratedScalar(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
Expand Down Expand Up @@ -166,35 +166,6 @@ public slots:
QByteArray fileOpen(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
QByteArray fileSave(QByteArray& command, QLocalSocket* s,ObjectStore*_store);


// Hacks
//QByteArray editableVectorSetBinaryArray(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
//EditableVector::setBinaryArray(

QByteArray editableMatrixSetBinaryArray(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
//EditableMatrix::setBinaryArray(

//QByteArray editableVectorSet(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
//EditableVector::set(

//QByteArray vectorGetBinaryArray(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
//Vector::getBinaryArray(

QByteArray matrixGetBinaryArray(QByteArray& command, QLocalSocket*s,ObjectStore*_store);
//Matrix::getBinaryArray(

QByteArray stringValue(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
//String::value(

QByteArray stringSetValue(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
//String::setValue(

QByteArray scalarValue(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
//Scalar::value(

QByteArray scalarSetValue(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
//Scalar::setValue(

};


Expand Down
8 changes: 4 additions & 4 deletions src/libkstmath/dataobjectscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ QString PluginSI::doCommand(QString command_in) {
}


QString v=doNamedObjectCommand(command_in, _plugin);
QString v=doObjectCommand(command_in, _plugin);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -200,7 +200,7 @@ QString EquationSI::doCommand(QString command_in) {
}


QString v=doNamedObjectCommand(command_in, _equation);
QString v=doObjectCommand(command_in, _equation);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -299,7 +299,7 @@ QString SpectrumSI::doCommand(QString command_in) {
}


QString v=doNamedObjectCommand(command_in, _psd);
QString v=doObjectCommand(command_in, _psd);
if (!v.isEmpty()) {
return v;
}
Expand Down Expand Up @@ -503,7 +503,7 @@ QString HistogramSI::doCommand(QString command_in) {
return CALL_MEMBER_FN(*this,fn)(command_in);
}

QString v=doNamedObjectCommand(command_in, _histogram);
QString v=doObjectCommand(command_in, _histogram);
if (!v.isEmpty()) {
return v;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libkstmath/relationscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Kst {

QString doRelationScriptCommand(QString command,Relation *relation) {

QString v=ScriptInterface::doNamedObjectCommand(command, relation);
QString v=ScriptInterface::doObjectCommand(command, relation);
if (!v.isEmpty()) {
return v;
}
Expand Down