2,000 changes: 2,000 additions & 0 deletions pyKst/demo/demodata.dat

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions pyKst/demo/equation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/python2.7
import pykst as kst

client=kst.Client("TestX2")

v1 = client.new_generated_vector(-10, 10, 1000)
e1 = client.new_equation(v1, "sin(x)")
c1 = client.new_curve(e1.x(), e1.y())
p1 = client.new_plot()
p1.add(c1)
25 changes: 12 additions & 13 deletions pyKst/demo/testdataobjects.py → pyKst/demo/equation_histogram.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
#!/usr/bin/python2.7
import pykst as kst

client=kst.Client("TestPlugins")
client=kst.Client("EqHist")

v1 = client.new_generated_vector(0, 10, 1000)
v4 = client.new_generated_vector(0, 20, 10000)

e1 = client.new_equation(v1, "x^2")
e1.set_x(v4)
v2 = e1.Y()
v3 = e1.X()
print v2.name(), v2.value(3), v3.value(3), v2.description_tip()
v2 = e1.y()
v3 = e1.x()
print "vector 2 name: ", v2.name()
print "vector 2 Value at 4th element: ", v2.value(3)

print v1.type_str(), v3.type_str()
print "vector 1 type: ", v1.type_str()

c1 = client.new_curve(e1.X(), e1.Y())
c1 = client.new_curve(e1.x(), e1.y())
c1.set_color("blue")

p1 = client.new_plot((0.5,0.25), (1,0.5))
p1.add(c1)

psd1 = client.new_spectrum(e1.X())
c2 = client.new_curve(psd1.X(), psd1.Y())
psd1 = client.new_spectrum(e1.x())
c2 = client.new_curve(psd1.x(), psd1.y())
c2.set_color("green")

p2 = client.new_plot((0.5,0.75), (1,0.5))
#p2.add(c2)

print "average?", psd1.interleaved_average()

h1 = client.new_histogram(v2)

c3 = client.new_curve(h1.X(), h1.Y())
c3 = client.new_curve(h1.x(), h1.y())
c3.set_color("black")
c3.set_has_bars(True)
c3.set_has_lines(False)
Expand All @@ -40,5 +38,6 @@

h1.change(v2, 0, 400, 10)

print h1.bin_min(), h1.bin_max(), h1.n_bins(), h1.auto_bin()
print "histogram 1 range: ", h1.bin_min(), h1.bin_max()
print "histogram 1 num bins: ", h1.num_bins()

118 changes: 0 additions & 118 deletions pyKst/demo/kstOwl.py

This file was deleted.

18 changes: 10 additions & 8 deletions pyKst/demo/matrix.py → pyKst/demo/numpy_matrix.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/python
import pykst as kst
from datetime import datetime
from numpy import *
from PyQt4 import QtCore, QtNetwork, QtGui
#from PyQt4 import QtCore, QtNetwork, QtGui

def mandelbrot( h,w, maxit=10 ):
'''Returns an image of the Mandelbrot fractal of size (h,w).
Expand All @@ -17,12 +16,15 @@ def mandelbrot( h,w, maxit=10 ):
diverge = z*conj(z) > 2**2 # who is diverging
div_now = diverge & (divtime==maxit) # who is diverging now
divtime[div_now] = i # note when
z[diverge] = 2 # avoid diverging too much
z[diverge] = 2.0 # avoid diverging too much

return divtime

client=kst.Client()
dt=datetime.now()
client.plot(mandelbrot(100,100))
arr_2d=kst.ExistingMatrix.getList(client)[-1].getNumPyArray()
client.plot(arr_2d)
client=kst.Client("numpy_matrix_demo")
np = mandelbrot(1000,1000)

M = client.new_editable_matrix(np)
I = client.new_image(M)
P = client.new_plot()
P.add(I)

43 changes: 43 additions & 0 deletions pyKst/demo/numpy_vector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/python2.7
import pykst as kst
from numpy import *
import time

client=kst.Client("VectorIO")

t0 = time.clock()

# create a pair of numpy arrays
x = linspace( 0, 50, 500000)
y = sin(x)

t1 = time.clock()

# copy the numpy arrays into kst and plot them
V1 = client.new_editable_vector(x)
V2 = client.new_editable_vector(y)
c1 = client.new_curve(V1, V2)
p1 = client.new_plot()
p1.add(c1)

t2 = time.clock()

# copy numpy array back into python.
A = V2.get_numpy_array()

t3 = time.clock()

# manipulate the array in python, and plot it in kst
A = A*A
V3 = client.new_editable_vector(A)
c2 = client.new_curve(V1, V3)
p1.add(c2)

# manipulate it again, and replace it in kst
A = A/2
V2.load(A)

print "creation of numpy arrays took", t1 - t0, "s"
print "copying onto kst and plotting took", t2-t1, "s"
print "copying from kst into python took:", t3-t2, "s"

27 changes: 27 additions & 0 deletions pyKst/demo/plot_layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python2.7
import pykst as kst

client=kst.Client("PlotLayoutDemo")

#autolayout in tab 1
p1 = client.new_plot(font_size = 12)

client.new_plot(font_size = 12)
client.new_plot(font_size = 12)
client.new_plot(font_size = 12)
client.new_plot(font_size = 12)
client.new_plot(font_size = 12)
client.new_plot(font_size = 12)
client.new_plot(font_size = 12)
client.new_plot(font_size = 12)

client.cleanup_layout(3)

p1.set_global_font(family = "Courier", font_size = 6)

# manual grid
client.new_tab()
for x in [.125, 0.375, 0.625, 0.875]:
for y in [.125, 0.375, 0.625, 0.875]:
client.new_plot((x,y),(0.25,0.25))

39 changes: 0 additions & 39 deletions pyKst/demo/primitives.py

This file was deleted.

33 changes: 33 additions & 0 deletions pyKst/demo/renamevector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/python2.7
import pykst as kst

client=kst.Client("RenameDemo")
V1=client.new_data_vector("/home/cbn/programs/KDE/kst_tutorial/gyrodata.dat",
field="INDEX",
start=0,num_frames=1000)

V2=client.new_data_vector("/home/cbn/programs/KDE/kst_tutorial/gyrodata.dat",
field="Column 2",
start=0,num_frames=1000)

c1 = client.new_curve(V1, V2)

p1 = client.new_plot(font_size = 12)

p1.add(c1)

print "-------------- Scalar list -------------"
print client.get_scalar_list()

print "-------------- Vector list -------------"
vectors = client.get_vector_list()
print vectors
print "----------"

# change the name of the vector made from field "Column 1"
for Vname in vectors:
Vr = client.data_vector(Vname)
if Vr.field() == "Column 2":
print "Changing name of ", Vr.name(), " to A Gyro"
Vr.set_name("A Gyro")

27 changes: 0 additions & 27 deletions pyKst/demo/testmatrix.py

This file was deleted.

36 changes: 0 additions & 36 deletions pyKst/demo/testplugins.py

This file was deleted.

49 changes: 0 additions & 49 deletions pyKst/demo/testvectorIO.py

This file was deleted.

46 changes: 0 additions & 46 deletions pyKst/demo/testviewitems.py

This file was deleted.

13 changes: 9 additions & 4 deletions pyKst/demo/ksnspire.py → pyKst/demo/textinput.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/python

# demonstrate buttons and line inputs:
# plot an equation the user inputs

import sip
sip.setapi('QString', 1)
import pykst as kst
Expand All @@ -16,12 +20,13 @@ def __init__(self,client):
self.s2.readyRead.connect(self.changeValue)
self.l=kst.LineEdit(client,"",self.s2,0.47,0.975,0.93,0.025)
self.b=kst.Button(client,"Go!",self.s,0.97,0.975,0.05,0.025)
self.plot=kst.Plot(client,0.5,0.4885,0.9,0.8,0,"KsNspirePLOT")
self.genVec=kst.GeneratedVector(self.client,-100,100,1000)
self.plot=client.new_plot((0.5,0.4885),(0.9,0.8))
self.genVec=client.new_generated_vector(-100,100,1000)

def create(self):
eq = kst.NewEquation(self.client,self.text,self.genVec)
kst.NewCurve(client,eq.X(), eq.Y(), curvecolor="black", curveweight=1, placeinexistingplot=self.plot)
eq = client.new_equation(self.genVec, self.text)
c = client.new_curve(eq.x(), eq.y())
self.plot.add(c)

def changeValue(self):
strx=QtCore.QString(self.s2.read(8000))
Expand Down
19 changes: 0 additions & 19 deletions pyKst/demo/vectors.py

This file was deleted.

27 changes: 27 additions & 0 deletions pyKst/demo/viewitems.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python2.7
import pykst as kst

client=kst.Client("viewitems")


P1=client.new_plot((0.25,0.25),(0.5,0.5),0)
P1.set_x_range(-10.0,10.0)
P1.set_global_font("courier",12,False,False)

C1 = client.new_circle((0.9,0.3),0.1, stroke_width = 2, stroke_brush_color="red")
C1.set_fill_color("Green")

B1 = client.new_box((0.9,0.9), (0.1,0.1), fill_color="pink")

E1 = client.new_ellipse((0.1, 0.7), (0.1, 0.1), 45, fill_color="blue")

A1 = client.new_arrow((0.1, 0.5), 0.1, 45, False, True, 18)
A1.set_stroke_style(3)

L1 = client.new_line((0.1, 0.5), 0.1, 15, stroke_width=4, stroke_brush_color="green")
L1.set_stroke_style(2)

Label = client.new_label("Label Here", (0.7,0.7), 0, 16, font_family="courier")
Label.set_font_italic(True)


21 changes: 15 additions & 6 deletions pyKst/html/index.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
.. toctree::
:maxdepth: 2

Welcome to pykst's documentation!
PyKst documentation
=================================
PyKst is a python interface to kst. With PyKst, scripts can control and share data with a kst session.

Clients
*******************
To interact with a kst session, you must create a client. To open an interface with the last kst session started, or if none open, a new one, try::
The following minimal example plots sin(x) from -10 to 10::

import pykst as kst

client=kst.Client("TestSinX")

import pykst as kst
client = kst.Client()
v1 = client.new_generated_vector(-10, 10, 1000)
e1 = client.new_equation(v1, "sin(x)")
c1 = client.new_curve(e1.x(), e1.y())
p1 = client.new_plot()
p1.add(c1)



Clients
*******************
.. automodule:: pykst
:members: Client
:exclude-members: getArray, getList, send
Expand Down
562 changes: 296 additions & 266 deletions pyKst/pykst.py

Large diffs are not rendered by default.

2,478 changes: 0 additions & 2,478 deletions pyKst/pykst_old.py

This file was deleted.

265 changes: 0 additions & 265 deletions pyKst/pykstpp.py

This file was deleted.

9 changes: 0 additions & 9 deletions pyKst/pykstpp_h.py

This file was deleted.

11 changes: 6 additions & 5 deletions src/datasources/ascii/asciidatareader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,17 @@ bool AsciiDataReader::findDataRows(const Buffer& buffer, qint64 bufstart, qint64
bool row_has_data = false;
bool is_comment = false;
const qint64 row_offset = bufstart + isLineBreak.size;
qint64 row_start = 0;
const qint64 old_numFrames = _numFrames;

// _rowIndex[_numFrames] already set, find next row

// _rowIndex[_numFrames] already set, find following rows
// buffer points to next row
qint64 row_start = _rowIndex[_numFrames];
for (qint64 i = 0; i < bufread; ++i) {
if (comment_del(buffer[i])) {
is_comment = true;
} else if (isLineBreak(buffer[i])) {
if (row_has_data) {
_rowIndex[_numFrames] = row_start;
++_numFrames;
if (_numFrames + 1 >= _rowIndex.size()) {
if (_rowIndex.capacity() < _numFrames + 1) {
Expand All @@ -202,10 +204,9 @@ bool AsciiDataReader::findDataRows(const Buffer& buffer, qint64 bufstart, qint64
_rowIndex.resize(_numFrames + 1);
}
row_start = row_offset + i;
_rowIndex[_numFrames] = row_start;
new_data = true;
} else if (is_comment) {
row_start = row_offset+i;
row_start = row_offset + i;
}
row_has_data = false;
is_comment = false;
Expand Down
27 changes: 15 additions & 12 deletions src/datasources/ascii/asciisource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ AsciiSource::AsciiSource(Kst::ObjectStore *store, QSettings *cfg, const QString&
_read_count(0),
_showFieldProgress(false),
is(new DataInterfaceAsciiString(*this)),
iv(new DataInterfaceAsciiVector(*this))
iv(new DataInterfaceAsciiVector(*this)),
_updatesDisabled(true)
{
setInterface(is);
setInterface(iv);
Expand All @@ -93,8 +94,7 @@ AsciiSource::AsciiSource(Kst::ObjectStore *store, QSettings *cfg, const QString&

_valid = true;
registerChange();
internalDataSourceUpdate(false);

internalDataSourceUpdate();
_progressTimer.restart();
}

Expand All @@ -115,6 +115,7 @@ void AsciiSource::reset()

_valid = false;
_fileSize = 0;
_lastFileSize = 0;
_haveHeader = false;
_fieldListComplete = false;

Expand Down Expand Up @@ -143,20 +144,18 @@ bool AsciiSource::initRowIndex()
}
qint64 header_row = 0;
qint64 left = _config._dataLine;
qint64 didRead = 0;
while (left > 0) {
QByteArray line = file.readLine();
if (line.isEmpty() || file.atEnd()) {
return false;
}
didRead += line.size();
--left;
if (header_row != _config._fieldsLine && header_row != _config._unitsLine) {
_strings[QString("Header %1").arg(header_row, 2, 10, QChar('0'))] = QString::fromAscii(line).trimmed();
}
header_row++;
}
_reader.setRow0Begin(didRead);
_reader.setRow0Begin(file.pos());
}

return true;
Expand Down Expand Up @@ -197,7 +196,6 @@ Kst::Object::UpdateType AsciiSource::internalDataSourceUpdate()
Kst::Object::UpdateType AsciiSource::internalDataSourceUpdate(bool read_completely)
{
//MeasureTime t("AsciiSource::internalDataSourceUpdate: " + _filename);

if (_busy)
return NoChange;

Expand All @@ -218,22 +216,24 @@ Kst::Object::UpdateType AsciiSource::internalDataSourceUpdate(bool read_complete
return NoChange;
}

if (_updatesDisabled) {
_fileSize = 0;
} else {
_fileSize = file.size();
}

bool force_update = true;
if (_fileSize == file.size()) {
force_update = false;
}

const qint64 oldFileSite = _fileSize;
if (read_completely) { // Update _fileSize only when we read the file completely
_fileSize = file.size();
}
_fileCreationTime_t = QFileInfo(file).created().toTime_t();

int col_count = _fieldList.size() - 1; // minus INDEX

bool new_data = false;
// emit progress message if there are more than 100 MB to parse
if (file.size() - oldFileSite > 100 * 1024 * 1024 && read_completely) {
if (_fileSize - _lastFileSize > 100 * 1024 * 1024 && read_completely) {
_showFieldProgress = true;
emitProgress(1, tr("Parsing '%1' ...").arg(_filename));
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
Expand All @@ -258,6 +258,9 @@ Kst::Object::UpdateType AsciiSource::internalDataSourceUpdate(bool read_complete
_showFieldProgress = false;
new_data = _reader.findAllDataRows(read_completely, &file, _fileSize, col_count);
}

_lastFileSize = _fileSize;

return (!new_data && !force_update ? NoChange : Updated);
}

Expand Down
6 changes: 6 additions & 0 deletions src/datasources/ascii/asciisource.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class AsciiSource : public Kst::DataSource

void triggerRowProgress() { emit signalRowProgress(); }

virtual void enableUpdates() {_updatesDisabled = false;}

signals:
void signalRowProgress();

Expand All @@ -94,6 +96,8 @@ class AsciiSource : public Kst::DataSource
mutable AsciiSourceConfig _config;

qint64 _fileSize;
qint64 _lastFileSize;

bool _haveHeader;
bool _fieldListComplete;
bool _haveWarned;
Expand Down Expand Up @@ -133,6 +137,8 @@ class AsciiSource : public Kst::DataSource
// TODO remove
friend class DataInterfaceAsciiString;
friend class DataInterfaceAsciiVector;

bool _updatesDisabled;
};


Expand Down
11 changes: 7 additions & 4 deletions src/libkst/datasource.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class KSTCORE_EXPORT DataSource : public Object

virtual UpdateType objectUpdate(qint64 newSerial);

void internalUpdate() {return;}
void internalUpdate() {return;} // unused - just here for linkage.

qint64 minInputSerial() const {return 0;}
qint64 maxInputSerialOfLastChange() const {return 0;}

Expand All @@ -121,7 +122,11 @@ class KSTCORE_EXPORT DataSource : public Object
It must be implemented by the datasource. */
virtual UpdateType internalDataSourceUpdate() = 0;


/** some constructors create their datasource with their updates disabled
because it may be expensive to parse the whole file.
Call this function before actually using the data source (eg,
in 'apply'. **/
virtual void enableUpdates() {return;}
/************************************************************/
/* Methods for handling time in vectors. */
/* not currently used - may be reworked (remove this note */
Expand Down Expand Up @@ -240,8 +245,6 @@ class KSTCORE_EXPORT DataSource : public Object

bool _writable;



/** The filename. Populated by the base class constructor. */
QString _filename;

Expand Down
7 changes: 6 additions & 1 deletion src/libkst/datasourcepluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,18 @@ DataSourcePtr DataSourcePluginManager::loadSource(ObjectStore *store, const QStr
}


DataSourcePtr DataSourcePluginManager::findOrLoadSource(ObjectStore *store, const QString& filename) {
DataSourcePtr DataSourcePluginManager::findOrLoadSource(ObjectStore *store, const QString& filename, bool updatesDisabled) {
Q_ASSERT(store);

DataSourcePtr dataSource = store->dataSourceList().findReusableFileName(filename);

if (!dataSource) {
dataSource = DataSourcePluginManager::loadSource(store, filename);
if (!updatesDisabled) {
if (dataSource) {
dataSource->enableUpdates();
}
}
}

return dataSource;
Expand Down
4 changes: 2 additions & 2 deletions src/libkst/datasourcepluginmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class KSTCORE_EXPORT DataSourcePluginManager
static QString pluginFileName(const QString& pluginName);

static SharedPtr<DataSource> loadSource(ObjectStore *store, const QString& filename, const QString& type = QString());
static SharedPtr<DataSource> loadSource(ObjectStore *store, QDomElement& e);
static SharedPtr<DataSource> findOrLoadSource(ObjectStore *store, const QString& filename);
//static SharedPtr<DataSource> loadSource(ObjectStore *store, QDomElement& e, bool updatesDisabled = false);
static SharedPtr<DataSource> findOrLoadSource(ObjectStore *store, const QString& filename, bool updatesDisabled = false);
static bool validSource(const QString& filename);

static bool sourceHasConfigWidget(const QString& filename, const QString& type = QString());
Expand Down
19 changes: 19 additions & 0 deletions src/libkst/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ double Vector::value(int i) const {
void Vector::CreateScalars(ObjectStore *store) {
if (!_isScalarList) {
_min = _max = _mean = _minPos = 0.0;
_imin = _imax = 0;

Q_ASSERT(store);
ScalarPtr sp;
Expand Down Expand Up @@ -309,6 +310,14 @@ void Vector::CreateScalars(ObjectStore *store) {
sp->setProvider(this);
sp->setSlaveName("MinPos");

_scalars.insert("imax", sp = store->createObject<Scalar>());
sp->setProvider(this);
sp->setSlaveName("iMax");

_scalars.insert("imin", sp = store->createObject<Scalar>());
sp->setProvider(this);
sp->setSlaveName("iMin");

}
}

Expand Down Expand Up @@ -411,6 +420,7 @@ void Vector::internalUpdate() {
const double epsilon=1e-300;

_max = _min = sum = sum2 = _minPos = last = first = NOPOINT;
_imax = _imin = 0;
_nsum = 0;

if (_size > 0) {
Expand All @@ -426,7 +436,9 @@ void Vector::internalUpdate() {
_scalars["sum"]->setValue(sum);
_scalars["sumsquared"]->setValue(sum2);
_scalars["max"]->setValue(_max);
_scalars["imax"]->setValue(_imax);
_scalars["min"]->setValue(_min);
_scalars["imin"]->setValue(_imin);
_scalars["minpos"]->setValue(_minPos);
_scalars["last"]->setValue(last);
_scalars["first"]->setValue(first);
Expand All @@ -445,6 +457,7 @@ void Vector::internalUpdate() {
}

_max = _min = _v[i0];
_imax = _imin = i0;
sum = sum2 = 0.0;

if (_v[i0] > epsilon) {
Expand Down Expand Up @@ -476,8 +489,10 @@ void Vector::internalUpdate() {

if (v > _max) {
_max = v;
_imax = i;
} else if (v < _min) {
_min = v;
_imin = i;
}
if (v < _minPos && v > epsilon) {
_minPos = v;
Expand Down Expand Up @@ -516,11 +531,14 @@ void Vector::internalUpdate() {

if (_isScalarList) {
_max = _min = _minPos = 0.0;
_imax =_imin = 0;
} else {
_scalars["sum"]->setValue(sum);
_scalars["sumsquared"]->setValue(sum2);
_scalars["max"]->setValue(_max);
_scalars["min"]->setValue(_min);
_scalars["imax"]->setValue(_imax);
_scalars["imin"]->setValue(_imin);
_scalars["minpos"]->setValue(_minPos);
_scalars["last"]->setValue(last);
_scalars["first"]->setValue(first);
Expand Down Expand Up @@ -612,6 +630,7 @@ void Vector::oldChange(QByteArray &data) {
qds >> _v[i];
if(!i) {
_min=_max=_minPos=sum=_v[i];
_imin = _imax = i;
_minPos=qMax(_minPos,qreal(0.0));
} else {
_min=qMin(_v[i],_min);
Expand Down
1 change: 1 addition & 0 deletions src/libkst/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class KSTCORE_EXPORT Vector : public Primitive
bool _saveData : 1;

double _min, _max, _mean, _minPos;
int _imax, _imin;

/** Scalar Maintenance methods */
void CreateScalars(ObjectStore *store);
Expand Down
2 changes: 2 additions & 0 deletions src/libkstapp/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ bool CommandLineParser::processCommandLine(bool *ok) {
} else if (arg == "--letter") {
_paperSize = QPrinter::Letter;
#endif
} else if (arg.startsWith("--serverName=")) {
/* scriptServer has already handled this. Skip it. */
} else { // arg is not an option... must be a file
if (new_fileList) { // if the file list has been used, clear it.
if (dataPlotted) {
Expand Down
1 change: 1 addition & 0 deletions src/libkstapp/datasourcepluginfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ DataSourcePtr DataSourcePluginFactory::generateDataSource(ObjectStore *store, QX
dataSource->setAlternateFilename(alternate_filename);
}
dataSource->setUpdateType(updateCheckType);
dataSource->enableUpdates();
return dataSource;
} else {
alternate_filename = fileName;
Expand Down
6 changes: 3 additions & 3 deletions src/libkstapp/datawizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ void DataWizardPageDataSource::sourceValid(QString filename, int requestID) {
return;
}
_pageValid = true;

_dataSource = DataSourcePluginManager::findOrLoadSource(_store, filename);
_dataSource = DataSourcePluginManager::findOrLoadSource(_store, filename, true);
connect(_dataSource, SIGNAL(progress(int,QString)), kstApp->mainWindow(), SLOT(updateProgress(int,QString)));
_fileType->setText(_dataSource->fileType());

Expand All @@ -157,7 +156,6 @@ void DataWizardPageDataSource::sourceValid(QString filename, int requestID) {
}

updateUpdateBox();

emit completeChanged();
emit dataSourceChanged();
}
Expand Down Expand Up @@ -808,6 +806,8 @@ void DataWizard::finished() {
return;
}

ds->enableUpdates();

emit dataSourceLoaded(ds->fileName());

// check for sufficient memory
Expand Down
1 change: 1 addition & 0 deletions src/libkstapp/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Document::Document(MainWindow *window)
_session = new SessionModel(objectStore());

_fileName.clear();

UpdateManager::self()->setStore(objectStore());
}

Expand Down
1 change: 1 addition & 0 deletions src/libkstapp/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Document : public CoreDocument {

void updateRecentDataFiles(const QStringList &datafiles);


private:
QPointer<MainWindow> _win;
SessionModel *_session;
Expand Down
78 changes: 39 additions & 39 deletions src/libkstapp/generaltab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,35 @@
<rect>
<x>0</x>
<y>0</y>
<width>587</width>
<width>325</width>
<height>246</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1" colspan="2">
<widget class="QSpinBox" name="_maxUpdate">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="_useRaster">
<property name="toolTip">
<string>Dynamic files update this fast or slower.</string>
<string>Render using &quot;raster&quot;. This is faster, except for remote X.</string>
</property>
<property name="whatsThis">
<string>Minimum time between updates when looking at dynamic files. If there is a lot of processing, it might take longer.</string>
</property>
<property name="minimum">
<number>10</number>
<string>Rendering using &quot;raster&quot; is faster unless you are running kst over a remote X connection.</string>
</property>
<property name="maximum">
<number>60000</number>
<property name="text">
<string>Use &quot;raster&quot; engine on (Kst restart needed)</string>
</property>
<property name="singleStep">
<number>500</number>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="_transparentDrag">
<property name="text">
<string>Use transparency when dragging</string>
</property>
<property name="value">
<number>2000</number>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="_antialiasPlots">
<property name="text">
<string>&amp;Antialias Plots</string>
</property>
</widget>
</item>
Expand All @@ -52,23 +51,31 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="_transparentDrag">
<property name="text">
<string>Use transparency when dragging</string>
<item row="3" column="1">
<widget class="QSpinBox" name="_maxUpdate">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="_useRaster">
<property name="toolTip">
<string>Render using &quot;raster&quot;. This is always better.</string>
<string>Dynamic files update this fast or slower.</string>
</property>
<property name="whatsThis">
<string>Rendering using &quot;raster&quot; is faster on some architectures, but very buggy on others (depending on the video driver). This might help, or might cause things to go horribly wrong.</string>
<string>Minimum time between updates when looking at dynamic files. If there is a lot of processing, it might take longer.</string>
</property>
<property name="text">
<string>Use &quot;raster&quot; engine on (Kst restart needed)</string>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>60000</number>
</property>
<property name="singleStep">
<number>500</number>
</property>
<property name="value">
<number>2000</number>
</property>
</widget>
</item>
Expand All @@ -85,13 +92,6 @@
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="_antialiasPlots">
<property name="text">
<string>&amp;Antialias Plots</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
Expand Down
30 changes: 23 additions & 7 deletions src/libkstapp/plotscriptinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,28 @@ QString PlotSI::normalizeXtoY(QString &) {
}


QString PlotSI::setLogX(QString &) {
QString PlotSI::setLogX(QString &command) {

if (_item) {
_item->zoomLogX();
QString arg = getArg(command);
if (arg.toLower()=="true") {
_item->zoomLogX(false, false, true);
} else {
_item->zoomLogX(false, false, false);
}
}
return "Done.";
}


QString PlotSI::setLogY(QString &) {

QString PlotSI::setLogY(QString &command) {
if (_item) {
_item->zoomLogY();
QString arg = getArg(command);
if (arg.toLower()=="true") {
_item->zoomLogY(false, false, true);
} else {
_item->zoomLogY(false, false, false);
}
}
return "Done.";
}
Expand Down Expand Up @@ -333,15 +342,22 @@ QString PlotSI::setGlobalFont(QString &command) {
if (_item) {
QFont font = _item->globalFont();
QString family = vars.at(0);
bool bold = ((vars.at(1)=="bold") || (vars.at(1)=="true"));
bool italic = ((vars.at(2)=="italic") || (vars.at(2)=="true"));
qreal size = vars.at(1).toDouble();
bool bold = ((vars.at(2)=="bold") || (vars.at(2)=="true"));
bool italic = ((vars.at(3)=="italic") || (vars.at(3)=="true"));
if (!family.isEmpty()) {
font.setFamily(family);
}


font.setItalic(italic);
font.setBold(bold);

_item->setGlobalFont(font);
if (size>1.0) {
_item->setGlobalFontScale(size);
}

}
return "Done.";
}
Expand Down
110 changes: 24 additions & 86 deletions src/libkstapp/scriptserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ namespace Kst {
ScriptServer::ScriptServer(ObjectStore *obj) : _server(new QLocalServer(this)), _store(obj),_interface(0) {

QString initial="kstScript";


// The command line hasn't been parsed yet, so
// we can't rely on that to get the server name.
QStringList args= qApp->arguments();
for(int i=0;i<args.size();i++) {
if(args.at(i).startsWith("--serverName=")) {
Expand Down Expand Up @@ -196,6 +200,8 @@ ScriptServer::ScriptServer(ObjectStore *obj) : _server(new QLocalServer(this)),
_fnMap.insert("fileOpen()", &ScriptServer::fileOpen);
_fnMap.insert("fileSave()", &ScriptServer::fileSave);

_fnMap.insert("cleanupLayout()", &ScriptServer::cleanupLayout);

#if 0

_fnMap.insert("EditableVector::setBinaryArray()",&ScriptServer::editableVectorSetBinaryArray);
Expand Down Expand Up @@ -347,79 +353,6 @@ QByteArray ScriptServer::exec(QByteArray command, QLocalSocket *s)
return "?";
}

#if 0
QByteArray ScriptServer::checkPrimatives(QByteArray &command, QLocalSocket *s)
{
///
if(command.startsWith("DataVector::")) {
command.replace("DataVector::","");
QByteArray actc=command;
command.remove(command.indexOf("("),999999);
actc.remove(0,actc.indexOf("("));
actc.remove(actc.lastIndexOf(")"),909099);
QByteArrayList m;
m.push_back(command);
m<<actc.split(',');
if(m.size()<2) {
return handleResponse("Invalid call to vector",s);
} else {
QByteArray b=m.takeAt(1);
ObjectPtr o=_store->retrieveObject(b);
DataVectorPtr v=kst_cast<DataVector>(o);
if(v) {
return handleResponse(v->scriptInterface(m),s);
} else {
return handleResponse("No such object",s);
}
}
} else if(command.startsWith("Vector::")) {
command.replace("Vector::","");
QByteArray actc=command;
command.remove(command.indexOf("("),999999);
actc.remove(0,actc.indexOf("("));
actc.remove(actc.lastIndexOf(")"),909099);
QByteArrayList m;
m.push_back(command);
m<<actc.split(',');
if(m.size()<2) {
return handleResponse("Invalid call to vector",s);
} else {
QByteArray b=m.takeAt(1);
ObjectPtr o=_store->retrieveObject(b);
VectorPtr v=kst_cast<Vector>(o);
if(v) {
return handleResponse(v->scriptInterface(m),s);
} else {
return handleResponse("No such object",s);
}
}
} else if(command.startsWith("DataObject::")) {
command.replace("DataObject::","");
QByteArray actc=command;
command.remove(command.indexOf("("),999999);
actc.remove(0,actc.indexOf("("));
actc.remove(actc.lastIndexOf(")"),909099);
QByteArrayList m;
m.push_back(command);
m<<actc.split(',');
if(m.size()<2) {
return handleResponse("Invalid call to dataobject",s);
} else {
QByteArray b=m.takeAt(1);
ObjectPtr o=_store->retrieveObject(b);
DataObjectPtr x=kst_cast<DataObject>(o);
if (x) {
return handleResponse(x->scriptInterface(m),s);
} else {
return handleResponse("No such object",s);
}
}
}

return "";
}
#endif

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

QByteArray ScriptServer::getVectorList(QByteArray&, QLocalSocket* s,ObjectStore*_store) {
Expand Down Expand Up @@ -453,19 +386,6 @@ QByteArray ScriptServer::newEditableVector(QByteArray&, QLocalSocket* s,ObjectSt
}


/*
QByteArray ScriptServer::newEditableVectorAndGetHandle(QByteArray&, QLocalSocket* s,ObjectStore*) {
EditableVectorPtr objectPtr=_store->createObject<EditableVector>();
objectPtr->writeLock();
objectPtr->setDescriptiveName("Script Vector");
objectPtr->unlock();
UpdateManager::self()->doUpdates(1);
UpdateServer::self()->requestUpdateSignal();
return handleResponse("Finished editing "+objectPtr->Name().toLatin1(),s);
}
*/

QByteArray ScriptServer::newDataVector(QByteArray&, QLocalSocket* s,ObjectStore*) {
if(_interface) {
return handleResponse("To access this function, first call endEdit()",s);
Expand Down Expand Up @@ -1028,5 +948,23 @@ QByteArray ScriptServer::fileSave(QByteArray&command, QLocalSocket* s, ObjectSto
return handleResponse("Done",s);
}

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

QString param = command.replace("cleanupLayout(","").replace(")","");
bool isNum = true;
int n_cols = param.toInt(&isNum);

if (isNum) { // columns
kstApp->mainWindow()->tabWidget()->currentView()->createLayout(false, n_cols);
} else if (param.toLower() == "protect") {
kstApp->mainWindow()->tabWidget()->currentView()->createLayout();
} else {
kstApp->mainWindow()->tabWidget()->currentView()->createUnprotectedLayout();
}

kstApp->mainWindow()->tabWidget()->setCurrentIndex(command.replace("setTab(","").replace(")","").toInt());
return handleResponse("Done",s);
}


}
2 changes: 2 additions & 0 deletions src/libkstapp/scriptserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public slots:
QByteArray fileOpen(QByteArray& command, QLocalSocket* s,ObjectStore*_store);
QByteArray fileSave(QByteArray& command, QLocalSocket* s,ObjectStore*_store);

QByteArray cleanupLayout(QByteArray& command, QLocalSocket* s,ObjectStore*_store);

};


Expand Down