[GRASS-SVN] r60982 - grass/trunk/gui/wxpython/tplot

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 26 08:24:22 PDT 2014


Author: annakrat
Date: 2014-06-26 08:24:21 -0700 (Thu, 26 Jun 2014)
New Revision: 60982

Modified:
   grass/trunk/gui/wxpython/tplot/frame.py
   grass/trunk/gui/wxpython/tplot/g.gui.tplot.py
Log:
wxGUI/tplot: clean up

Modified: grass/trunk/gui/wxpython/tplot/frame.py
===================================================================
--- grass/trunk/gui/wxpython/tplot/frame.py	2014-06-26 13:50:20 UTC (rev 60981)
+++ grass/trunk/gui/wxpython/tplot/frame.py	2014-06-26 15:24:21 UTC (rev 60982)
@@ -40,7 +40,6 @@
 import grass.temporal as tgis
 from core.gcmd import GError, GException, RunCommand
 from gui_core import gselect
-from core import globalvar
 from grass.pygrass.vector.geometry import Point
 from grass.pygrass.raster import RasterRow
 from collections import OrderedDict
@@ -71,6 +70,7 @@
 
         tgis.init(True)
         self.datasets = []
+        self.output = None
         self.timeData = {}
         self._layout()
         self.temporalType = None
@@ -121,19 +121,11 @@
         gridSizer = wx.GridBagSizer(hgap=5, vgap=5)
 
         self.datasetSelect = gselect.Select(parent=self.panel, id=wx.ID_ANY,
-#                                            size=globalvar.DIALOG_GSELECT_SIZE,
-                                            type='stds', size=(150, -1))
+                                            type='strds', multiple=True, size=(150, -1))
         self.drawButton = wx.Button(self.panel, id=wx.ID_ANY, label=_("Draw"))
         self.drawButton.Bind(wx.EVT_BUTTON, self.OnRedraw)
         self.helpButton = wx.Button(self.panel, id=wx.ID_ANY, label=_("Help"))
         self.helpButton.Bind(wx.EVT_BUTTON, self.OnHelp)
-#        self.view3dCheck = wx.CheckBox(self.panel, id=wx.ID_ANY,
-#                                       label=_("3D plot of queried data"))
-#        self.view3dCheck.Bind(wx.EVT_CHECKBOX, self.OnRedraw)
-#        if not check_version(1, 0, 0):
-#            self.view3dCheck.SetLabel(_("3D plot of queried data "
-#                                        "(matplotlib >= 1.0.0)"))
-#            self.view3dCheck.Disable()
 
         self.xcoor = wx.StaticText(parent=self.panel, id=wx.ID_ANY,
                                    label=_('Insert longitude (x) coordinate'))
@@ -159,7 +151,6 @@
         gridSizer.Add(self.drawButton, pos=(3, 2), flag=wx.EXPAND)
         gridSizer.Add(self.helpButton, pos=(3, 3), flag=wx.EXPAND)
 
-#        gridSizer.Add(self.view3dCheck, pos=(4, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
         self.vbox.Add(gridSizer, proportion=0, flag=wx.EXPAND | wx.ALL,
                       border=10)
 
@@ -228,60 +219,7 @@
         self.temporalType = mode
         return
 
-    def _draw3dFigure(self):
-        """Draws 3d view (spatio-temporal extents).
-
-
-        Only for matplotlib versions >= 1.0.0.
-        Earlier versions cannot draw time ticks and alpha
-        and it has a slightly different API.
-        """
-        pass
-#        self.axes3d.clear()
-#        self.axes3d.grid(False)
-#        # self.axes3d.grid(True)
-#        if self.temporalType == 'absolute':
-#            if check_version(1, 1, 0):
-#                self.axes3d.zaxis_date()
-#            convert = mdates.date2num
-#        else:
-#            convert = lambda x: x
-#
-#        colors = cycle(COLORS)
-#        plots = []
-#        for name in self.datasets:
-#            name = name[0] + '@' + name[1]
-#            startZ = convert(self.timeData[name]['start_datetime'])
-#            mapType = self.timeData[name]['temporalMapType']
-#            if mapType == 'interval':
-#                dZ = convert(self.timeData[name]['end_datetime']) - startZ
-#
-#            else:
-#                dZ = [0] * len(startZ)
-#
-#            startX = self.timeData[name]['west']
-#            dX = self.timeData[name]['east'] - np.array(startX)
-#            startY = self.timeData[name]['south']
-#            dY = self.timeData[name]['north'] - np.array(startY)
-#
-#            color = colors.next()
-#            plots.append(self.axes3d.bar3d(startX, startY, startZ, dX, dY, dZ,
-#                                           color=color, alpha=ALPHA))
-
-#        params = grass.read_command('g.proj', flags='g')
-#        params = grass.parse_key_val(params)
-#        if 'unit' in params:
-#            self.axes3d.set_xlabel(_("X [%s]") % params['unit'])
-#            self.axes3d.set_ylabel(_("Y [%s]") % params['unit'])
-#        else:
-#            self.axes3d.set_xlabel(_("X"))
-#            self.axes3d.set_ylabel(_("Y"))
-#
-#        self.axes3d.set_zlabel(_('Time'))
-#        self.axes3d.mouse_init()
-#        self.canvas.draw()
-
-    def _draw2dFigure(self):
+    def _drawFigure(self):
         """Draws or print 2D plot (temporal extents)"""
         self.axes2d.clear()
         self.axes2d.grid(False)
@@ -301,7 +239,6 @@
         plots = []
         lookUp = LookUp(self.timeData, self.invconvert)
         for i, name in enumerate(self.datasets):
-            fullname = name[0] + '@' + name[1]
             name = name[0]
             yticksNames.append(name)  # just name; with mapset it would be long
             yticksPos.append(i)
@@ -324,10 +261,10 @@
         else:
             self.axes2d.set_xlabel(_("Time [%s]") % self.unit)
         self.axes2d.set_ylabel(', '.join(yticksNames))
-        
+
         #legend
         handles, labels = self.axes2d.get_legend_handles_labels()
-        self.axes2d.legend()
+        self.axes2d.legend(loc=0)
         if self.output:
             self.canvas.print_figure(filename=self.output, dpi=self.dpi)
         else:
@@ -368,29 +305,13 @@
         # axes3d are physically removed
         if not self.axes2d:
             self.axes2d = self.fig.add_subplot(1, 1, 1)
-        self._draw2dFigure()
-#        if check_version(1, 0, 0):
-#            if self.view3dCheck.IsChecked():
-#                self.axes2d.change_geometry(2, 1, 1)
-#                if not self.axes3d:
-#                    # do not remove this import - unused but it is required for 3D
-#                    from mpl_toolkits.mplot3d import Axes3D  # pylint: disable=W0611
-#                    self.axes3d = self.fig.add_subplot(2, 1, 2, projection='3d')
-#
-#                self.axes3d.set_visible(True)
-#                self._draw3dFigure()
-#            else:
-#                if self.axes3d:
-#                    self.fig.delaxes(self.axes3d)
-#                    self.axes3d = None
-#                self.axes2d.change_geometry(1, 1, 1)
-#                self.canvas.draw()
+        self._drawFigure()
 
     def _checkDatasets(self, datasets):
         """Checks and validates datasets.
 
         Reports also type of dataset (e.g. 'strds').
-        
+
         :param list datasets: list of temporal dataset's name
         :return: (mapName, mapset, type)
         """
@@ -477,12 +398,7 @@
         self.ycoorval.SetValue(str(coors[1]))
         self._redraw()
 
-#    def Show3D(self, show):
-#        """Show also 3D if possible"""
-#        if check_version(1, 0, 0):
-#            self.view3dCheck.SetValue(show)
 
-
 class LookUp:
     """Helper class for searching info by coordinates"""
     def __init__(self, timeData, convert):

Modified: grass/trunk/gui/wxpython/tplot/g.gui.tplot.py
===================================================================
--- grass/trunk/gui/wxpython/tplot/g.gui.tplot.py	2014-06-26 13:50:20 UTC (rev 60981)
+++ grass/trunk/gui/wxpython/tplot/g.gui.tplot.py	2014-06-26 15:24:21 UTC (rev 60982)
@@ -34,20 +34,17 @@
 #%end
 #%option G_OPT_F_OUTPUT
 #% required: no
+#% label: Name for output file
+#% description: Add extension to specify format (.png, .pdf, .svg)
 #%end
 #%option
 #% key: dpi
 #% type: integer
 #% label: The DPI for output image
-#% description: To use only with output parameters
+#% description: To use only with output parameter
 #% required: no
 #%end
 
-## #%flag
-## #% key: 3
-## #% description: Show also 3D plot of spatio-temporal extents
-## #%end
-
 import  wx
 
 import grass.script as grass
@@ -65,7 +62,7 @@
     coords = options['coordinates'].strip().split(',')
     output = options['output']
     dpi = options['dpi']
-#    view3d = flags['3']
+    dpi = int(dpi) if dpi else None
     if dpi and not output:
         grass.warning(_("No output filename set, so DPI option will not used"))
 
@@ -73,8 +70,8 @@
     frame = TplotFrame(None)
     frame.SetDatasets(datasets, coords, output, dpi)
     if output:
-        return 
-#    frame.Show3D(view3d)
+        return
+
     frame.Show()
     app.MainLoop()
 



More information about the grass-commit mailing list