Explorar o código

wxIClass: https://trac.osgeo.org/grass/ticket/1516 fixed

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@49841 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová %!s(int64=13) %!d(string=hai) anos
pai
achega
e0a5abceed
Modificáronse 2 ficheiros con 20 adicións e 8 borrados
  1. 4 0
      gui/wxpython/iclass/frame.py
  2. 16 8
      gui/wxpython/iclass/plots.py

+ 4 - 0
gui/wxpython/iclass/frame.py

@@ -446,6 +446,10 @@ class IClassMapFrame(DoubleMapFrame):
         """!Standard deviation multiplier changed, rerender map, histograms"""
         """!Standard deviation multiplier changed, rerender map, histograms"""
         stat = self.statisticsDict[cat]
         stat = self.statisticsDict[cat]
         stat.nstd = nstd
         stat.nstd = nstd
+        
+        if not stat.IsReady():
+            return
+            
         raster = stat.rasterName
         raster = stat.rasterName
         
         
         cstat = self.cStatisticsDict[cat]
         cstat = self.cStatisticsDict[cat]

+ 16 - 8
gui/wxpython/iclass/plots.py

@@ -47,16 +47,20 @@ class PlotPanel(scrolled.ScrolledPanel):
         self.Layout()
         self.Layout()
         
         
     def _createControlPanel(self):
     def _createControlPanel(self):
-        self.graphSwitch = wx.Choice(self, id = wx.ID_ANY,
+        self.plotSwitch = wx.Choice(self, id = wx.ID_ANY,
                                      choices = [_("Histograms"),
                                      choices = [_("Histograms"),
                                                 _("Coincident plots")])
                                                 _("Coincident plots")])
-        self.mainSizer.Add(self.graphSwitch, proportion = 0, flag = wx.EXPAND|wx.ALL, border = 5)
-        self.graphSwitch.Bind(wx.EVT_CHOICE, self.OnPlotTypeSelected)
+        self.mainSizer.Add(self.plotSwitch, proportion = 0, flag = wx.EXPAND|wx.ALL, border = 5)
+        self.plotSwitch.Bind(wx.EVT_CHOICE, self.OnPlotTypeSelected)
         
         
     def OnPlotTypeSelected(self, event):
     def OnPlotTypeSelected(self, event):
-        """!Graph type selected"""
-        if self.graphSwitch.GetSelection() == 0:
+        """!Plot type selected"""
+        if self.currentCat is None:
+            return
+        
+        if self.plotSwitch.GetSelection() == 0:
             if not self.statDict[self.currentCat].IsReady():
             if not self.statDict[self.currentCat].IsReady():
+                self.ClearPlots()
                 return
                 return
             self.DrawHistograms(self.statDict[self.currentCat])
             self.DrawHistograms(self.statDict[self.currentCat])
         else:
         else:
@@ -64,7 +68,7 @@ class PlotPanel(scrolled.ScrolledPanel):
             
             
     def StddevChanged(self):
     def StddevChanged(self):
         """!Standard deviation multiplier changed, redraw histograms"""
         """!Standard deviation multiplier changed, redraw histograms"""
-        if self.graphSwitch.GetSelection() == 0:
+        if self.plotSwitch.GetSelection() == 0:
             self.UpdateRanges(self.statDict[self.currentCat])
             self.UpdateRanges(self.statDict[self.currentCat])
         
         
     def EnableZoom(self, type, enable = True):
     def EnableZoom(self, type, enable = True):
@@ -84,7 +88,11 @@ class PlotPanel(scrolled.ScrolledPanel):
             
             
         self.canvasList = []
         self.canvasList = []
             
             
-        
+    def ClearPlots(self):
+        """!Clears plot canvases"""
+        for bandIdx in range(len(self.bandList)):
+            self.canvasList[bandIdx].Clear()
+            
     def CreatePlotCanvases(self):
     def CreatePlotCanvases(self):
         """!Create plot canvases according to the number of bands"""
         """!Create plot canvases according to the number of bands"""
         for band in self.bandList:
         for band in self.bandList:
@@ -112,7 +120,7 @@ class PlotPanel(scrolled.ScrolledPanel):
         self.currentCat = currentCat
         self.currentCat = currentCat
         self.bandList = self.parent.GetGroupLayers(group)
         self.bandList = self.parent.GetGroupLayers(group)
         
         
-        graphType = self.graphSwitch.GetSelection()
+        graphType = self.plotSwitch.GetSelection()
         
         
         if not statDict[currentCat].IsReady() and graphType == 0:
         if not statDict[currentCat].IsReady() and graphType == 0:
             return
             return