Sfoglia il codice sorgente

wxplot: use wxpython plotting instead of our old copy, adjust to use python properties

Anna Petrasova 5 anni fa
parent
commit
7618b63b28

File diff suppressed because it is too large
+ 0 - 2560
gui/wxpython/gui_core/wxlibplot.py


+ 6 - 6
gui/wxpython/iclass/plots.py

@@ -17,7 +17,7 @@ for details.
 
 
 import wx
 import wx
 
 
-import gui_core.wxlibplot as plot
+import wx.lib.plot as plot
 import wx.lib.scrolledpanel as scrolled
 import wx.lib.scrolledpanel as scrolled
 from core.gcmd import GError
 from core.gcmd import GError
 
 
@@ -146,7 +146,7 @@ class PlotPanel(scrolled.ScrolledPanel):
 
 
     def EnableZoom(self, type, enable=True):
     def EnableZoom(self, type, enable=True):
         for canvas in self.canvasList:
         for canvas in self.canvasList:
-            canvas.SetEnableZoom(enable)
+            canvas.enableZoom = enable
 
 
         #canvas.zoom = type
         #canvas.zoom = type
 
 
@@ -177,8 +177,8 @@ class PlotPanel(scrolled.ScrolledPanel):
         for band in self.bandList:
         for band in self.bandList:
             canvas = plot.PlotCanvas(self.canvasPanel)
             canvas = plot.PlotCanvas(self.canvasPanel)
             canvas.SetMinSize((-1, 140))
             canvas.SetMinSize((-1, 140))
-            canvas.SetFontSizeTitle(10)
-            canvas.SetFontSizeAxis(8)
+            canvas.fontSizeTitle = 10
+            canvas.fontSizeAxis = 8
             self.canvasList.append(canvas)
             self.canvasList.append(canvas)
 
 
             self.canvasSizer.Add(
             self.canvasSizer.Add(
@@ -218,7 +218,7 @@ class PlotPanel(scrolled.ScrolledPanel):
     def DrawCoincidencePlots(self):
     def DrawCoincidencePlots(self):
         """Draw coincidence plots"""
         """Draw coincidence plots"""
         for bandIdx in range(len(self.bandList)):
         for bandIdx in range(len(self.bandList)):
-            self.canvasList[bandIdx].SetYSpec(type='none')
+            self.canvasList[bandIdx].ySpec = 'none'
             lines = []
             lines = []
             level = 0.5
             level = 0.5
             lines.append(self.DrawInvisibleLine(level))
             lines.append(self.DrawInvisibleLine(level))
@@ -267,7 +267,7 @@ class PlotPanel(scrolled.ScrolledPanel):
         self.histogramLines = []
         self.histogramLines = []
         for bandIdx in range(len(self.bandList)):
         for bandIdx in range(len(self.bandList)):
             self.canvasList[bandIdx].Clear()
             self.canvasList[bandIdx].Clear()
-            self.canvasList[bandIdx].SetYSpec(type='auto')
+            self.canvasList[bandIdx].ySpec = 'auto'
             histgramLine = self.CreateHistogramLine(
             histgramLine = self.CreateHistogramLine(
                 bandValues=statistics.bands[bandIdx])
                 bandValues=statistics.bands[bandIdx])
 
 

+ 41 - 49
gui/wxpython/wxplot/base.py

@@ -21,7 +21,7 @@ import six
 
 
 import wx
 import wx
 
 
-import gui_core.wxlibplot as plot
+import wx.lib.plot as plot
 from core.globalvar import ICONDIR
 from core.globalvar import ICONDIR
 from core.settings import UserSettings
 from core.settings import UserSettings
 from wxplot.dialogs import TextDialog, OptDialog
 from wxplot.dialogs import TextDialog, OptDialog
@@ -105,7 +105,7 @@ class BasePlotFrame(wx.Frame):
         self.client = plot.PlotCanvas(self)
         self.client = plot.PlotCanvas(self)
 
 
         # define the function for drawing pointLabels
         # define the function for drawing pointLabels
-        self.client.SetPointLabelFunc(self.DrawPointLabel)
+        self.client.pointLabelFunc = self.DrawPointLabel
 
 
         # Create mouse event for showing cursor coords in status bar
         # Create mouse event for showing cursor coords in status bar
         self.client.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
         self.client.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
@@ -187,19 +187,19 @@ class BasePlotFrame(wx.Frame):
         self.zoom = False  # zooming disabled
         self.zoom = False  # zooming disabled
         self.drag = False  # draging disabled
         self.drag = False  # draging disabled
         # vertical and horizontal scrollbars
         # vertical and horizontal scrollbars
-        self.client.SetShowScrollbars(True)
+        self.client.showScrollbars = True
 
 
         # x and y axis set to normal (non-log)
         # x and y axis set to normal (non-log)
-        self.client.setLogScale((False, False))
+        self.client.logScale = (False, False)
         if self.properties['x-axis']['prop']['type']:
         if self.properties['x-axis']['prop']['type']:
-            self.client.SetXSpec(self.properties['x-axis']['prop']['type'])
+            self.client.xSpec = self.properties['x-axis']['prop']['type']
         else:
         else:
-            self.client.SetXSpec('auto')
+            self.client.xSpec = 'auto'
 
 
         if self.properties['y-axis']['prop']['type']:
         if self.properties['y-axis']['prop']['type']:
-            self.client.SetYSpec(self.properties['y-axis']['prop']['type'])
+            self.client.ySpec = self.properties['y-axis']['prop']['type']
         else:
         else:
-            self.client.SetYSpec('auto')
+            self.client.ySpec = 'auto'
 
 
     def InitRasterOpts(self, rasterList, plottype):
     def InitRasterOpts(self, rasterList, plottype):
         """Initialize or update raster dictionary for plotting
         """Initialize or update raster dictionary for plotting
@@ -337,26 +337,24 @@ class BasePlotFrame(wx.Frame):
         """Set plot and text options
         """Set plot and text options
         """
         """
         self.client.SetFont(self.properties['font']['wxfont'])
         self.client.SetFont(self.properties['font']['wxfont'])
-        self.client.SetFontSizeTitle(
-            self.properties['font']['prop']['titleSize'])
-        self.client.SetFontSizeAxis(
-            self.properties['font']['prop']['axisSize'])
+        self.client.fontSizeTitle = self.properties['font']['prop']['titleSize']
+        self.client.fontSizeAxis = self.properties['font']['prop']['axisSize']
 
 
-        self.client.SetEnableZoom(self.zoom)
-        self.client.SetEnableDrag(self.drag)
+        self.client.enableZoom = self.zoom
+        self.client.enableDrag = self.drag
 
 
         #
         #
         # axis settings
         # axis settings
         #
         #
         if self.properties['x-axis']['prop']['type'] == 'custom':
         if self.properties['x-axis']['prop']['type'] == 'custom':
-            self.client.SetXSpec('min')
+            self.client.xSpec = 'min'
         else:
         else:
-            self.client.SetXSpec(self.properties['x-axis']['prop']['type'])
+            self.client.xSpec = self.properties['x-axis']['prop']['type']
 
 
         if self.properties['y-axis']['prop']['type'] == 'custom':
         if self.properties['y-axis']['prop']['type'] == 'custom':
-            self.client.SetYSpec('min')
+            self.client.ySpec = 'min'
         else:
         else:
-            self.client.SetYSpec(self.properties['y-axis']['prop'])
+            self.client.ySpec = self.properties['y-axis']['prop']['type']
 
 
         if self.properties['x-axis']['prop']['type'] == 'custom' and self.properties[
         if self.properties['x-axis']['prop']['type'] == 'custom' and self.properties[
                 'x-axis']['prop']['min'] < self.properties['x-axis']['prop']['max']:
                 'x-axis']['prop']['min'] < self.properties['x-axis']['prop']['max']:
@@ -376,32 +374,28 @@ class BasePlotFrame(wx.Frame):
 
 
         if self.properties['x-axis']['prop']['log'] == True:
         if self.properties['x-axis']['prop']['log'] == True:
             self.properties['x-axis']['axis'] = None
             self.properties['x-axis']['axis'] = None
-            self.client.SetXSpec('min')
+            self.client.xSpec = 'min'
         if self.properties['y-axis']['prop']['log'] == True:
         if self.properties['y-axis']['prop']['log'] == True:
             self.properties['y-axis']['axis'] = None
             self.properties['y-axis']['axis'] = None
-            self.client.SetYSpec('min')
+            self.client.ySpec = 'min'
 
 
-        self.client.setLogScale((self.properties['x-axis']['prop']['log'],
-                                 self.properties['y-axis']['prop']['log']))
+        self.client.logScale = (self.properties['x-axis']['prop']['log'],
+                                self.properties['y-axis']['prop']['log'])
 
 
         #
         #
         # grid settings
         # grid settings
         #
         #
-        self.client.SetEnableGrid(self.properties['grid']['enabled'])
-
-        self.client.SetGridColour(
-            wx.Colour(
-                self.properties['grid']['color'][0],
-                self.properties['grid']['color'][1],
-                self.properties['grid']['color'][2],
-                255))
+        self.client.enableGrid = self.properties['grid']['enabled']
+        gridpen = wx.Pen(colour=wx.Colour(self.properties['grid']['color'][0],
+                                          self.properties['grid']['color'][1],
+                                          self.properties['grid']['color'][2], 255))
+        self.client.gridPen = gridpen
 
 
         #
         #
         # legend settings
         # legend settings
         #
         #
-        self.client.SetFontSizeLegend(
-            self.properties['font']['prop']['legendSize'])
-        self.client.SetEnableLegend(self.properties['legend']['enabled'])
+        self.client.fontSizeLegend = self.properties['font']['prop']['legendSize']
+        self.client.enableLegend = self.properties['legend']['enabled']
 
 
     def DrawPlot(self, plotlist):
     def DrawPlot(self, plotlist):
         """Draw line and point plot from list plot elements.
         """Draw line and point plot from list plot elements.
@@ -413,14 +407,14 @@ class BasePlotFrame(wx.Frame):
                                       ylabel)
                                       ylabel)
 
 
         if self.properties['x-axis']['prop']['type'] == 'custom':
         if self.properties['x-axis']['prop']['type'] == 'custom':
-            self.client.SetXSpec('min')
+            self.client.xSpec = 'min'
         else:
         else:
-            self.client.SetXSpec(self.properties['x-axis']['prop']['type'])
+            self.client.xSpec = self.properties['x-axis']['prop']['type']
 
 
         if self.properties['y-axis']['prop']['type'] == 'custom':
         if self.properties['y-axis']['prop']['type'] == 'custom':
-            self.client.SetYSpec('min')
+            self.client.ySpec = 'min'
         else:
         else:
-            self.client.SetYSpec(self.properties['y-axis']['prop']['type'])
+            self.client.ySpec = self.properties['y-axis']['prop']['type']
 
 
         self.client.Draw(self.plot, self.properties['x-axis']['axis'],
         self.client.Draw(self.plot, self.properties['x-axis']['axis'],
                          self.properties['y-axis']['axis'])
                          self.properties['y-axis']['axis'])
@@ -454,16 +448,16 @@ class BasePlotFrame(wx.Frame):
         """
         """
         self.zoom = True
         self.zoom = True
         self.drag = False
         self.drag = False
-        self.client.SetEnableZoom(self.zoom)
-        self.client.SetEnableDrag(self.drag)
+        self.client.enableZoom = self.zoom
+        self.client.enableDrag = self.drag
 
 
     def OnDrag(self, event):
     def OnDrag(self, event):
         """Enable dragging and disable zooming
         """Enable dragging and disable zooming
         """
         """
         self.zoom = False
         self.zoom = False
         self.drag = True
         self.drag = True
-        self.client.SetEnableDrag(self.drag)
-        self.client.SetEnableZoom(self.zoom)
+        self.client.enableDrag = self.drag
+        self.client.enableZoom = self.zoom
 
 
     def OnRedraw(self, event):
     def OnRedraw(self, event):
         """Redraw the plot window. Unzoom to original size
         """Redraw the plot window. Unzoom to original size
@@ -490,7 +484,7 @@ class BasePlotFrame(wx.Frame):
     def OnMotion(self, event):
     def OnMotion(self, event):
         """Indicate when mouse is outside the plot area
         """Indicate when mouse is outside the plot area
         """
         """
-        if self.client.GetEnablePointLabel() is True:
+        if self.client.enablePointLabel:
             # make up dict with info for the pointLabel
             # make up dict with info for the pointLabel
             # I've decided to mark the closest point on the closest curve
             # I've decided to mark the closest point on the closest curve
             dlst = self.client.GetClosestPoint(
             dlst = self.client.GetClosestPoint(
@@ -560,7 +554,7 @@ class BasePlotFrame(wx.Frame):
         self.ylabel = dlg.ylabel
         self.ylabel = dlg.ylabel
 
 
         if self.plot:
         if self.plot:
-            self.plot.setTitle(dlg.ptitle)
+            self.plot.title = dlg.ptitle
 
 
         self.OnRedraw(event=None)
         self.OnRedraw(event=None)
 
 
@@ -568,14 +562,12 @@ class BasePlotFrame(wx.Frame):
         x, y = self._getPlotLabels()
         x, y = self._getPlotLabels()
 
 
         self.client.SetFont(self.properties['font']['wxfont'])
         self.client.SetFont(self.properties['font']['wxfont'])
-        self.client.SetFontSizeTitle(
-            self.properties['font']['prop']['titleSize'])
-        self.client.SetFontSizeAxis(
-            self.properties['font']['prop']['axisSize'])
+        self.client.fontSizeTitle = self.properties['font']['prop']['titleSize']
+        self.client.fontSizeAxis = self.properties['font']['prop']['axisSize']
 
 
         if self.plot:
         if self.plot:
-            self.plot.setXLabel(x)
-            self.plot.setYLabel(y)
+            self.plot.xLabel = x
+            self.plot.yLabel = y
 
 
     def PlotText(self, event):
     def PlotText(self, event):
         """Set custom text values for profile title and axis labels.
         """Set custom text values for profile title and axis labels.

+ 1 - 1
gui/wxpython/wxplot/histogram.py

@@ -20,7 +20,7 @@ import sys
 import wx
 import wx
 
 
 import grass.script as grass
 import grass.script as grass
-import gui_core.wxlibplot as plot
+import wx.lib.plot as plot
 from gui_core.wrap import StockCursor
 from gui_core.wrap import StockCursor
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from wxplot.base import BasePlotFrame, PlotIcons
 from wxplot.base import BasePlotFrame, PlotIcons

+ 1 - 1
gui/wxpython/wxplot/profile.py

@@ -23,7 +23,7 @@ import numpy
 
 
 import wx
 import wx
 
 
-import gui_core.wxlibplot as plot
+import wx.lib.plot as plot
 import grass.script as grass
 import grass.script as grass
 from wxplot.base import BasePlotFrame, PlotIcons
 from wxplot.base import BasePlotFrame, PlotIcons
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from gui_core.toolbars import BaseToolbar, BaseIcons

+ 1 - 1
gui/wxpython/wxplot/scatter.py

@@ -20,7 +20,7 @@ import sys
 import wx
 import wx
 
 
 import grass.script as grass
 import grass.script as grass
-import gui_core.wxlibplot as plot
+import wx.lib.plot as plot
 from wxplot.base import BasePlotFrame, PlotIcons
 from wxplot.base import BasePlotFrame, PlotIcons
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from gui_core.toolbars import BaseToolbar, BaseIcons
 from gui_core.wrap import StockCursor
 from gui_core.wrap import StockCursor