[GRASS-SVN] r63937 - in grass/trunk/gui/wxpython: mapwin rdigit rlisetup

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 2 19:33:24 PST 2015


Author: annakrat
Date: 2015-01-02 19:33:24 -0800 (Fri, 02 Jan 2015)
New Revision: 63937

Modified:
   grass/trunk/gui/wxpython/mapwin/analysis.py
   grass/trunk/gui/wxpython/mapwin/buffered.py
   grass/trunk/gui/wxpython/mapwin/graphics.py
   grass/trunk/gui/wxpython/rdigit/controller.py
   grass/trunk/gui/wxpython/rlisetup/sampling_frame.py
Log:
wxGUI: specify pdc in Graphics API, change pdc where rdigit objects are drawn to avoid problems with pen styles (other than solid) when drawing using wx.GCDC

Modified: grass/trunk/gui/wxpython/mapwin/analysis.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/analysis.py	2015-01-03 01:43:55 UTC (rev 63936)
+++ grass/trunk/gui/wxpython/mapwin/analysis.py	2015-01-03 03:33:24 UTC (rev 63937)
@@ -76,7 +76,7 @@
         item.SetCoords(coords)
         # draw
         self._mapWindow.ClearLines()
-        self._registeredGraphics.Draw(pdc=self._mapWindow.pdcTmp)
+        self._registeredGraphics.Draw()
         self._mapWindow.Refresh()
         wx.Yield()
 

Modified: grass/trunk/gui/wxpython/mapwin/buffered.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/buffered.py	2015-01-03 01:43:55 UTC (rev 63936)
+++ grass/trunk/gui/wxpython/mapwin/buffered.py	2015-01-03 03:33:24 UTC (rev 63937)
@@ -209,8 +209,8 @@
         self.pdc = wx.PseudoDC()
         # used for digitization tool
         self.pdcVector = None
-        # decorations (region box, etc.)
-        self.pdcDec = wx.PseudoDC()
+        # transparent objects (region box, raster digitizer)
+        self.pdcTransparent = wx.PseudoDC()
         # pseudoDC for temporal objects (select box, measurement tool, etc.)
         self.pdcTmp = wx.PseudoDC()
 
@@ -555,22 +555,17 @@
             self.pdc.DrawBitmap(self.bufferLast, 0, 0, False)
             self.pdc.DrawToDC(dc)
 
-        # draw decorations (e.g. region box)
+        # draw semitransparent objects (e.g. region box, raster digitizer objects)
         try:
             gcdc = wx.GCDC(dc)
-            self.pdcDec.DrawToDC(gcdc)
+            self.pdcTransparent.DrawToDC(gcdc)
         except NotImplementedError as e:
             print >> sys.stderr, e
-            self.pdcDec.DrawToDC(dc)
+            self.pdcTransparent.DrawToDC(dc)
+
         # draw temporary object on the foreground
-        try:
-            gcdc = wx.GCDC(dc)
-            self.pdcTmp.DrawToDC(gcdc)
-        except NotImplementedError as e:
-            print >> sys.stderr, e
-            self.pdcTmp.DrawToDC(dc)
+        self.pdcTmp.DrawToDC(dc)
 
-
         if switchDraw:
             self.redrawAll = False
 
@@ -854,7 +849,7 @@
         # clear pseudoDcs
         #
         for pdc in (self.pdc,
-                    self.pdcDec,
+                    self.pdcTransparent,
                     self.pdcTmp):
             pdc.Clear()
             pdc.RemoveAll()
@@ -905,7 +900,7 @@
 
             for item in self.graphicsSetList:
                 try:
-                    item.Draw(self.pdcTmp)
+                    item.Draw()
                 except:
                     GError(parent = self,
                            message = _('Unable to draw registered graphics. '
@@ -950,7 +945,7 @@
             regionCoords.append((reg['w'], reg['s']))
             regionCoords.append((reg['w'], reg['n']))
             # draw region extent
-            self.DrawLines(pdc=self.pdcDec, polycoords=regionCoords)
+            self.DrawLines(pdc=self.pdcTransparent, polycoords=regionCoords)
 
     def EraseMap(self):
         """Erase map canvas
@@ -960,7 +955,7 @@
         if hasattr(self, "digit"):
             self.Draw(self.pdcVector, pdctype = 'clear')
 
-        self.Draw(self.pdcDec, pdctype = 'clear')
+        self.Draw(self.pdcTransparent, pdctype='clear')
         self.Draw(self.pdcTmp, pdctype = 'clear')
 
         self.Map.AbortAllThreads()
@@ -2053,11 +2048,12 @@
         """Get render.Map() instance"""
         return self.Map
 
-    def RegisterGraphicsToDraw(self, graphicsType, setStatusFunc=None, drawFunc=None,
+    def RegisterGraphicsToDraw(self, graphicsType, pdc=None, setStatusFunc=None, drawFunc=None,
                                mapCoords=True):
         """This method registers graphics to draw.
 
         :param type: (string) - graphics type: "point", "line" or "rectangle"
+        :param pdc: PseudoDC object, default is pdcTmp
         :param setStatusFunc: function called before drawing each item
                               Status function should be in this form:
                               setStatusFunc(item, itemOrderNum)
@@ -2074,8 +2070,11 @@
 
         :return: reference to GraphicsSet, which was added.
         """
+        if not pdc:
+            pdc = self.pdcTmp
         item = GraphicsSet(parentMapWin=self,
                            graphicsType=graphicsType,
+                           pdc=pdc,
                            setStatusFunc=setStatusFunc,
                            drawFunc=drawFunc,
                            mapCoords=mapCoords)

Modified: grass/trunk/gui/wxpython/mapwin/graphics.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/graphics.py	2015-01-03 01:43:55 UTC (rev 63936)
+++ grass/trunk/gui/wxpython/mapwin/graphics.py	2015-01-03 03:33:24 UTC (rev 63937)
@@ -25,7 +25,7 @@
 
 class GraphicsSet:
 
-    def __init__(self, parentMapWin, graphicsType,
+    def __init__(self, parentMapWin, graphicsType, pdc,
                  setStatusFunc=None, drawFunc=None, mapCoords=True):
         """Class, which contains instances of GraphicsSetItem and
             draws them For description of parameters look at method
@@ -49,6 +49,7 @@
         self.parentMapWin = parentMapWin
         self.setStatusFunc = setStatusFunc
         self.mapCoords = mapCoords
+        self.pdc = pdc
 
         if drawFunc:
             self.drawFunc = drawFunc
@@ -74,14 +75,11 @@
         elif self.graphicsType == "polygon":
             self.drawFunc = self.parentMapWin.DrawPolygon
 
-    def Draw(self, pdc):
-        """Draws all containing items.
-
-        :param pdc: device context, where items are drawn
-        """
+    def Draw(self):
+        """Draws all containing items."""
         itemOrderNum = 0
         for item in self.itemsList:
-            self._clearId(pdc, item.GetId())
+            self._clearId(item.GetId())
             if self.setStatusFunc is not None:
                 self.setStatusFunc(item, itemOrderNum)
 
@@ -111,7 +109,7 @@
                     self.properties["text"]['color'] = self.parentMapWin.pen.GetColour()
                     self.properties["text"]['text'] = label
 
-                self.drawFunc(pdc=pdc, drawid=item.GetId(),
+                self.drawFunc(pdc=self.pdc, drawid=item.GetId(),
                               coords=coords,
                               text=self.properties["text"],
                               size=self.properties["size"])
@@ -127,7 +125,7 @@
                 else:
                     coords = item.GetCoords()
 
-                self.drawFunc(pdc=pdc, pen=pen,
+                self.drawFunc(pdc=self.pdc, pen=pen,
                               coords=coords, drawid=item.GetId())
 
             elif self.graphicsType == "rectangle":
@@ -144,7 +142,7 @@
                 else:
                     coords = item.GetCoords()
 
-                self.drawFunc(pdc=pdc, pen=pen, brush=brush, drawid=item.GetId(),
+                self.drawFunc(pdc=self.pdc, pen=pen, brush=brush, drawid=item.GetId(),
                               point1=coords[0],
                               point2=coords[1])
 
@@ -162,7 +160,7 @@
                 else:
                     coords = item.GetCoords()
 
-                self.drawFunc(pdc=pdc, pen=pen, brush=brush,
+                self.drawFunc(pdc=self.pdc, pen=pen, brush=brush,
                               coords=coords, drawid=item.GetId())
             itemOrderNum += 1
 
@@ -357,10 +355,10 @@
         except ValueError:
             return None
 
-    def _clearId(self, pdc, drawid):
+    def _clearId(self, drawid):
         """Clears old object before drawing new object."""
         try:
-            pdc.ClearId(drawid)
+            self.pdc.ClearId(drawid)
         except:
             pass
 

Modified: grass/trunk/gui/wxpython/rdigit/controller.py
===================================================================
--- grass/trunk/gui/wxpython/rdigit/controller.py	2015-01-03 01:43:55 UTC (rev 63936)
+++ grass/trunk/gui/wxpython/rdigit/controller.py	2015-01-03 03:33:24 UTC (rev 63937)
@@ -157,9 +157,9 @@
             self._finish()
         # draw
         self._mapWindow.ClearLines()
-        self._lines.Draw(pdc=self._mapWindow.pdcTmp)
-        self._areas.Draw(pdc=self._mapWindow.pdcTmp)
-        self._points.Draw(pdc=self._mapWindow.pdcTmp)
+        self._lines.Draw()
+        self._areas.Draw()
+        self._points.Draw()
         self._mapWindow.Refresh()
 
     def _finish(self):
@@ -190,9 +190,9 @@
         self.newFeatureCreated.emit()
 
         self._mapWindow.ClearLines()
-        self._points.Draw(pdc=self._mapWindow.pdcTmp)
-        self._areas.Draw(pdc=self._mapWindow.pdcTmp)
-        self._lines.Draw(pdc=self._mapWindow.pdcTmp)
+        self._points.Draw()
+        self._areas.Draw()
+        self._lines.Draw()
 
         self._mapWindow.Refresh()
 
@@ -255,16 +255,19 @@
 
         color = self._drawColor[:3] + (self._drawTransparency,)
         self._areas = self._mapWindow.RegisterGraphicsToDraw(graphicsType='polygon',
+                                                             pdc=self._mapWindow.pdcTransparent,
                                                              mapCoords=True)
         self._areas.AddPen('pen1', wx.Pen(colour=color, width=2, style=wx.SOLID))
         self._areas.AddBrush('done', wx.Brush(colour=color, style=wx.SOLID))
 
         self._lines = self._mapWindow.RegisterGraphicsToDraw(graphicsType='line',
+                                                             pdc=self._mapWindow.pdcTransparent,
                                                              mapCoords=True)
         self._lines.AddPen('pen1', wx.Pen(colour=color, width=2, style=wx.SOLID))
         self._lines.AddBrush('done', wx.Brush(colour=color, style=wx.SOLID))
 
         self._points = self._mapWindow.RegisterGraphicsToDraw(graphicsType='point',
+                                                              pdc=self._mapWindow.pdcTransparent,
                                                               mapCoords=True)
         self._points.AddPen('pen1', wx.Pen(colour=color, width=2, style=wx.SOLID))
         self._points.AddBrush('done', wx.Brush(colour=color, style=wx.SOLID))

Modified: grass/trunk/gui/wxpython/rlisetup/sampling_frame.py
===================================================================
--- grass/trunk/gui/wxpython/rlisetup/sampling_frame.py	2015-01-03 01:43:55 UTC (rev 63936)
+++ grass/trunk/gui/wxpython/rlisetup/sampling_frame.py	2015-01-03 03:33:24 UTC (rev 63937)
@@ -182,7 +182,7 @@
         item.SetCoords(coords)
         item.SetPropertyVal('hide', False)
         self.mapWindow.ClearLines()
-        self._registeredGraphics.Draw(self.mapWindow.pdcTmp)
+        self._registeredGraphics.Draw()
 
     def _mouseDbClick(self, x, y):
         item = self._registeredGraphics.GetItem(0)
@@ -191,7 +191,7 @@
         item.SetCoords(coords)
         item.SetPropertyVal('hide', False)
         self.mapWindow.ClearLines()
-        self._registeredGraphics.Draw(self.mapWindow.pdc)
+        self._registeredGraphics.Draw()
         self.createRegion()
 
     def createRegion(self):
@@ -294,7 +294,7 @@
         self.mapWindow.pdcTmp.SetPen(pen)
         self.mapWindow.pdcTmp.DrawCircle(circle.point[0], circle.point[1],
                                          circle.radius)
-        self._registeredGraphics.Draw(self.mapWindow.pdcTmp)
+        self._registeredGraphics.Draw()
         self.createCricle(circle)
 
     def createCricle(self, c):
@@ -352,7 +352,7 @@
                   'e': max(p1[0], p2[0])}
         item.SetPropertyVal('hide', False)
         self.mapWindow.ClearLines()
-        self._registeredGraphics.Draw(self.mapWindow.pdcTmp)
+        self._registeredGraphics.Draw()
         if self.samplingtype in [SamplingType.MUNITSR, SamplingType.MMVWINR]:
             dlg = wx.MessageDialog(self, "Is this area ok?",
                                    "select sampling unit",



More information about the grass-commit mailing list