|
From: Zbigniew R. <zre...@ce...> - 2015-07-03 14:43:03
|
Hi Carlos,
Your patch was applied to the develop branch.
Thanks fro your contribution,
Zibi
On 05/18/2015 12:06 PM, cpascual wrote:
> When exporting data from a plot (or trend) to ascii, the sorting
> order is alphabetical, which may not correspond to the order in
> which the curves are ordered in the plot, and this confuses the
> users. Use Z-order of the plot instead of alphabetical.
>
> Also, fix a bug preventing the export of "all sets in one file"
> feature.
> ---
> lib/taurus/qt/qtgui/panel/qdataexportdialog.py | 29 ++++++++++++++++----------
> lib/taurus/qt/qtgui/plot/taurusplot.py | 3 ++-
> 2 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/lib/taurus/qt/qtgui/panel/qdataexportdialog.py b/lib/taurus/qt/qtgui/panel/qdataexportdialog.py
> index 7dfaaaf..ecd2cb9 100644
> --- a/lib/taurus/qt/qtgui/panel/qdataexportdialog.py
> +++ b/lib/taurus/qt/qtgui/panel/qdataexportdialog.py
> @@ -50,7 +50,7 @@ class QDataExportDialog(Qt.QDialog):
> allInSingleFile = "All sets in a single file (table like)"
> allInMultipleFiles = "All set in multiple files"
>
> - def __init__(self, parent=None, datadict=None):
> + def __init__(self, parent=None, datadict=None, sortedNames=None):
> super(QDataExportDialog,self).__init__(parent)
> self.loadUi()
> self._xIsTime = False
> @@ -59,17 +59,21 @@ class QDataExportDialog(Qt.QDialog):
> Qt.QObject.connect(self.exportBT,Qt.SIGNAL("clicked()"),self.exportData)
> Qt.QObject.connect(self.dataSetCB,Qt.SIGNAL("currentIndexChanged(const QString&)"),self.onDataSetCBChange)
>
> - self.setDataSets(datadict)
> + self.setDataSets(datadict, sortedNames)
> +
>
>
> - def setDataSets(self, datadict):
> + def setDataSets(self, datadict, sortedNames=None):
> """Used to set the sets that are to be offered for exporting. It overwrites previous values.
> """
> if datadict is None: return
> + if sortedNames is None:
> + sortedNames = sorted(self.datadict.keys())
> + self.sortedNames = sortedNames
> self.datatime=datetime.now()
> self.datadict=datadict
> self.dataSetCB.clear()
> - self.dataSetCB.insertItems(0,sorted(self.datadict.keys()))
> + self.dataSetCB.insertItems(0, sortedNames)
> if len(self.datadict.keys()) > 1:
> self.dataSetCB.insertItems(0,[self.allInSingleFile, self.allInMultipleFiles])
>
> @@ -118,7 +122,7 @@ class QDataExportDialog(Qt.QDialog):
> outputdir=Qt.QFileDialog.getExistingDirectory (self, 'Export Directory', Qt.QString())
> if not outputdir:return False
> preffix=os.path.join(str(outputdir),"set")
> - for i,k in zip(range(len(self.datadict)),sorted(self.datadict.keys())):
> + for i,k in zip(range(len(self.datadict)), self.sortedNames):
> ofile="%s%03i.dat"%(preffix,i+1)
> try:
> self.exportCurrentData(set=k,ofile=ofile,verbose=False,AllowCloseAfter=False)
> @@ -143,9 +147,12 @@ class QDataExportDialog(Qt.QDialog):
> header = "# DATASET= "
> body = ""
> previous = None
> - for curve_name in sorted(self.datadict.keys()):
> + for curve_name in self.sortedNames:
> xdata, ydata = self.datadict[curve_name]
> - if (previous is not None) and (previous != xdata):
> + if previous is None:
> + previous = xdata
> + header +=' "abscissa"'
> + elif previous != xdata:
> if (key==self.allInSingleFile):
> self.dataTE.clear()
> Qt.QMessageBox.critical(self,\
> @@ -158,17 +165,17 @@ class QDataExportDialog(Qt.QDialog):
> self.dataTE.insertPlainText("Unable to display because abscissas are different.\n"\
> "Curves will be saved each one in its own file")
> return
> - else:
> - previous = xdata
> - header +=' "abscissa", "%s"' % curve_name
> + header +=' , "%s"' % curve_name
> +
> header+="\n# SNAPSHOT_TIME= %s\n"%self.datatime.isoformat('_')
> #if we reached this point x axes are equal, so fill the editor with the data
> for i, x in enumerate(previous):
> if self.xIsTime():
> + t=datetime.fromtimestamp(x)
> body += "%s" % t.isoformat('_')
> else:
> body += "%g" % x
> - for curve_name in sorted(self.datadict.keys()):
> + for curve_name in self.sortedNames:
> xdata, ydata = self.datadict[curve_name]
> body += ("\t%g" % ydata[i])
> body+="\n"
> diff --git a/lib/taurus/qt/qtgui/plot/taurusplot.py b/lib/taurus/qt/qtgui/plot/taurusplot.py
> index d67f826..f841615 100644
> --- a/lib/taurus/qt/qtgui/plot/taurusplot.py
> +++ b/lib/taurus/qt/qtgui/plot/taurusplot.py
> @@ -2535,7 +2535,8 @@ class TaurusPlot(Qwt5.QwtPlot, TaurusBaseWidget):
> if klass is None:
> from taurus.qt.qtgui.panel import QDataExportDialog
> klass = QDataExportDialog
> - dialog = klass(parent=self, datadict=frozendata)
> + dialog = klass(parent=self, datadict=frozendata,
> + sortedNames=self.getCurveNamesSorted())
> dialog.setXIsTime(self.getXIsTime())
> return dialog.exec_()
>
--
--
ALBA Synchrotron <http://www.albasynchrotron.es>
Zbigniew Reszela
Controls Section - Computing Division
ALBA SYNCHROTRON LIGHT SOURCE
Ctra. BP 1413 km. 3,3 | 08290 | Cerdanyola del Vallès| Barcelona | Spain
<http://www.albasynchrotron.es/AboutUs/Access>
(+34) 93 592 4407
www.albasynchrotron.es <http://www.albasynchrotron.es>|
zre...@ce... <mailto:zre...@ce...>
**Please, do not print this e-mail unless it is absolutely necessary.
**Si heu rebut aquest correu per error, us informo que pot contenir
informació confidencial i privada i que està prohibit el seu ús. Us
agrairíem que ho comuniqueu al remitent i l'elimineu. Gràcies.
Si ha recibido este correo por error, le informo de que puede contener
información confidencial y privada y que está prohibido su uso. Le
agradeceré que lo comunique a su remitente y lo elimine. Gracias.
If you have received this e-mail in error, please note that it may
contain confidential and private information, therefore, the use of this
information is strictly forbidden. Please inform the sender of the error
and delete the information received. Thank you.
|