On 12/09/11 18:20, mimisa...@gmail.com wrote:
In my opinion it would be great if....
1. The point picker could recognize DateTime datasets and show the point
coordinates in ISO data format.
2. One could use ISO data format to set the values of axes min and max.
3. One could decide from which dataset the picker picks the points.

I've just put together a patch for the first part. It seems to work ok.

BKS - have you got a better way to get this into your picker code?

The second point would definitely be good. The axis should also autodetect when dates are plotted rather than have to be set like that. It should then display min and max as dates.

I wonder what would be the correct user interface for the 3rd idea. Seems quite tricky... Maybe some sort of drop down menu from the pick button to enable/disable datasets. At the moment you should just be able to hide the datasets you don't want to pick from.

Thanks

Jeremy
diff --git a/document/datasets.py b/document/datasets.py
index c396428..cd866a4 100644
--- a/document/datasets.py
+++ b/document/datasets.py
@@ -592,6 +592,12 @@ class DatasetBase(object):
         """Return dataset as text (for use by user)."""
         return ''
 
+    @staticmethod
+    def pickerText(val):
+        """Convert an item of the dataset to a picker text value."""
+        # default is floating point value
+        return '%0.5g' % val
+
 class Dataset2D(DatasetBase):
     '''Represents a two-dimensional dataset.'''
 
@@ -980,6 +986,11 @@ class DatasetDateTime(Dataset):
         """Returns version of dataset with no linking."""
         return DatasetDateTime(data=N.array(self.data))
 
+    @staticmethod
+    def pickerText(val):
+        """Convert an item of the dataset to a picker text value."""
+        return utils.dateFloatToString(val)
+
 class DatasetText(DatasetBase):
     """Represents a text dataset: holding an array of strings."""
 
@@ -1070,6 +1081,11 @@ class DatasetText(DatasetBase):
         """Returns version of dataset with no linking."""
         return DatasetText(self.data)
 
+    @staticmethod
+    def pickerText(val):
+        """Convert an item of the dataset to a picker text value."""
+        return val
+
 class DatasetExpressionException(DatasetException):
     """Raised if there is an error evaluating a dataset expression."""
     pass
diff --git a/widgets/pickable.py b/widgets/pickable.py
index 8928f71..8d2ad21 100644
--- a/widgets/pickable.py
+++ b/widgets/pickable.py
@@ -19,8 +19,6 @@
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 ###############################################################################
 
-# $Id: $
-
 import numpy as N
 
 import veusz.document as document
@@ -152,6 +150,8 @@ class GenericPickable:
 
         info.screenpos = self.xscreen[i], self.yscreen[i]
         info.coords = self.xvals[i], self.yvals[i]
+        info.coordstext = ('%0.5g' % self.xvals[i],
+                           '%0.5g' % self.yvals[i])
         info.distance = m
         info.index = Index(self.xvals[i], i, self._pickSign(i))
 
@@ -229,6 +229,10 @@ class DiscretePickable(GenericPickable):
 
         xs, ys = mapdata_fn(x, y)
 
+        # functions to convert to text for each axis
+        self.xPickText = xdata.pickerText
+        self.yPickText = ydata.pickerText
+
         # and set us up with the mapped data
         GenericPickable.__init__( self, widget, labels, (x, y), (xs, ys) )
 
@@ -240,6 +244,11 @@ class DiscretePickable(GenericPickable):
 
         # indicies are persistent
         info.index.useindex = True
+
+        # use dataset to convert value->text
+        info.coordstext = (self.xPickText(info.coords[0]),
+                           self.yPickText(info.coords[1]))
+
         return info
 
     def pickIndex(self, oldindex, direction, bounds):
diff --git a/windows/mainwindow.py b/windows/mainwindow.py
index d14e716..73d2796 100644
--- a/windows/mainwindow.py
+++ b/windows/mainwindow.py
@@ -1251,12 +1251,12 @@ class MainWindow(qt4.QMainWindow):
 
     def slotUpdatePickerLabel(self, info):
         """Display the picked point"""
-        xv, yv = info.coords
+        xv, yv = info.coordstext
         xn, yn = info.labels
         ix = str(info.index)
         if ix:
             ix = '[' + ix + ']'
-        t = '%s: %s%s = %0.5g, %s%s = %0.5g' % (
+        t = '%s: %s%s = %s, %s%s = %s' % (
                 info.widget.name, xn, ix, xv, yn, ix, yv)
         self.pickerlabel.setText(t)
 
_______________________________________________
Veusz-discuss mailing list
Veusz-discuss@gna.org
https://mail.gna.org/listinfo/veusz-discuss

Répondre à