[Kst] branches/work/kst/portto4/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Fri Oct 7 01:43:16 UTC 2011
SVN commit 1257657 by netterfield:
Add more plot control scripting options.
Add get range info from matrixes.
M +48 -3 pyKst/pykst.py
M +1 -1 src/libkstapp/plotitem.cpp
M +1 -1 src/libkstapp/plotitemdialog.cpp
M +66 -2 src/libkstapp/plotscriptinterface.cpp
M +8 -0 src/libkstapp/plotscriptinterface.h
--- branches/work/kst/portto4/kst/pyKst/pykst.py #1257656:1257657
@@ -45,9 +45,9 @@
return x
def send_si(self, handle, command):
- x = self.send(b2str("beginEdit("+handle.toAscii()+")"))
- x = x + self.send(command)
- x = x + self.send(b2str("endEdit()"))
+ self.send(b2str("beginEdit("+handle.toAscii()+")"))
+ x = self.send(command)
+ self.send(b2str("endEdit()"))
return x
def getArray(self,command):
@@ -560,18 +560,34 @@
""" set the left edge of the map defined by the matrix """
self.client.send_si(self.handle, b2str("setXMinimum("+b2str(x0)+")"))
+ def getXMin(self) :
+ """ get the left edge of the map defined by the matrix """
+ return self.client.send_si(self.handle, b2str("getXMinimum()"))
+
def setYMin(self,y0=0) :
""" set the bottom edge of the map defined by the matrix """
self.client.send_si(self.handle, b2str("setYMinimum("+b2str(y0)+")"))
+ def getYMin(self) :
+ """ get the bottom edge of the map defined by the matrix """
+ return self.client.send_si(self.handle, b2str("getYMinimum()"))
+
def setXStep(self,dx=0) :
""" set the x step size of the map defined by the matrix """
self.client.send_si(self.handle, b2str("setXStepSize("+b2str(dx)+")"))
+ def getXStep(self) :
+ """ get the x step size of the map defined by the matrix """
+ return self.client.send_si(self.handle, b2str("getXStepSize()"))
+
def setYStep(self,dy=0) :
""" set the y step size of the map defined by the matrix """
self.client.send_si(self.handle, b2str("setYStepSize("+b2str(dy)+")"))
+ def getYStep(self) :
+ """ get the y step size of the map defined by the matrix """
+ return self.client.send_si(self.handle, b2str("getYStepSize()"))
+
class DataMatrix(Matrix) :
""" This class represents a matrix you would create via "Create>Matrix" from the menubar inside kst.
@@ -1386,6 +1402,35 @@
""" Set the right label to auto generated. """
self.client.send_si(self.handle,b2str("setRightLabelAuto()"))
+ def normalizeXtoY(self) :
+ """ Adjust the X zoom range so X and Y have the same scale per unit (square pixels) """
+ self.client.send_si(self.handle, b2str("normalizeXtoY()"))
+
+ def setLogX(self) :
+ """ Set X axis to log mode. """
+ self.client.send_si(self.handle, b2str("setLogX()"))
+
+ def setLogY(self) :
+ """ Set X axis to log mode. """
+ self.client.send_si(self.handle, b2str("setLogY()"))
+
+ def setXAxisReversed(self) :
+ """ set the X axis to decreasing from left to right. """
+ self.client.send_si(self.handle, b2str("setXAxisReversed()"))
+
+ def setYAxisReversed(self) :
+ """ set the Y axis to decreasing from bottom to top. """
+ self.client.send_si(self.handle, b2str("setYAxisReversed()"))
+
+ def setXAxisNotReversed(self) :
+ """ set the X axis to increasing from left to right. """
+ self.client.send_si(self.handle, b2str("setXAxisNotReversed()"))
+
+ def setYAxisNotReversed(self) :
+ """ set the Y axis to increasing from bottom to top. """
+ self.client.send_si(self.handle, b2str("setYAxisNotReversed()"))
+
+
class ExistingPlot(Plot):
def __init__(self,client,handle):
ViewItem.__init__(self,client)
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1257656:1257657
@@ -3269,7 +3269,7 @@
#endif
if (xAxis()->axisLog() || yAxis()->axisLog())
- return; //apparently we don't want to do anything here according to kst2dplot...
+ return; //FIXME: if both are log, this could be supported
if (isInSharedAxisBox() && !force) {
sharedAxisBox()->zoomNormalizeXtoY(this);
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #1257656:1257657
@@ -1,4 +1,4 @@
-/***************************************************************************
+/*******************F********************************************************
* *
* copyright : (C) 2007 The University of Toronto *
* netterfield at astro.utoronto.ca *
--- branches/work/kst/portto4/kst/src/libkstapp/plotscriptinterface.cpp #1257656:1257657
@@ -30,7 +30,15 @@
_fnMap.insert("setBottomLabelAuto",&PlotSI::setBottomLabelAuto);
_fnMap.insert("setLeftLabelAuto",&PlotSI::setLeftLabelAuto);
_fnMap.insert("setRightLabelAuto",&PlotSI::setRightLabelAuto);
+ _fnMap.insert("setLogX",&PlotSI::setLogX);
+ _fnMap.insert("setLogY",&PlotSI::setLogY);
+ _fnMap.insert("normalizeXtoY",&PlotSI::normalizeXtoY);
+ _fnMap.insert("setXAxisReversed",&PlotSI::setXAxisReversed);
+ _fnMap.insert("setYAxisReversed",&PlotSI::setYAxisReversed);
+ _fnMap.insert("setXAxisNotReversed",&PlotSI::setXAxisNotReversed);
+ _fnMap.insert("setYAxisNotReversed",&PlotSI::setYAxisNotReversed);
+
}
QByteArrayList PlotSI::commands() {
@@ -200,8 +208,6 @@
QString PlotSI::setYNoSpike(QString &) {
-
-
if (_item) {
_item->zoomYNoSpike();
}
@@ -234,6 +240,64 @@
}
+QString PlotSI::normalizeXtoY(QString &) {
+ if (_item) {
+ _item->zoomNormalizeXtoY();
+ }
+ return "Done.";
+}
+
+
+QString PlotSI::setLogX(QString &) {
+
+ if (_item) {
+ _item->zoomLogX();
+ }
+ return "Done.";
+}
+
+
+QString PlotSI::setLogY(QString &) {
+
+ if (_item) {
+ _item->zoomLogY();
+ }
+ return "Done.";
+}
+
+
+QString PlotSI::setXAxisReversed(QString &) {
+ if (_item) {
+ _item->xAxis()->setAxisReversed(true);
+ }
+ return "Done.";
+}
+
+
+QString PlotSI::setYAxisReversed(QString &) {
+ if (_item) {
+ _item->yAxis()->setAxisReversed(true);
+ }
+ return "Done.";
+}
+
+
+QString PlotSI::setXAxisNotReversed(QString &) {
+ if (_item) {
+ _item->xAxis()->setAxisReversed(false);
+ }
+ return "Done.";
+}
+
+
+QString PlotSI::setYAxisNotReversed(QString &) {
+ if (_item) {
+ _item->yAxis()->setAxisReversed(false);
+ }
+ return "Done.";
+}
+
+
QString PlotSI::setGlobalFont(QString &command) {
QStringList vars = getArgs(command);
--- branches/work/kst/portto4/kst/src/libkstapp/plotscriptinterface.h #1257656:1257657
@@ -52,7 +52,15 @@
QString setYNoSpike(QString& command);
QString setXAC(QString& command);
QString setYAC(QString& command);
+ QString normalizeXtoY(QString& command);
+ QString setLogX(QString& command);
+ QString setLogY(QString& command);
+ QString setXAxisReversed(QString& command);
+ QString setYAxisReversed(QString& command);
+ QString setXAxisNotReversed(QString& command);
+ QString setYAxisNotReversed(QString& command);
+
QString setGlobalFont(QString& command);
QString setTopLabel(QString& command);
More information about the Kst
mailing list