Kaynağa Gözat

wxgui:fix wms in vdigit

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59312 15284696-431f-4ddb-bdfa-cd5b030d7da7
Štěpán Turek 11 yıl önce
ebeveyn
işleme
0ea4044e2b

+ 12 - 5
gui/wxpython/mapdisp/frame.py

@@ -292,7 +292,7 @@ class MapFrame(SingleMapFrame):
                           CloseButton(False).DestroyOnClose(True).
                           Layer(0))
         
-        self.MapWindow = self.MapWindowVDigit
+        self._switchMapWindow(self.MapWindowVDigit)
         
         if self._mgr.GetPane('2d').IsShown():
             self._mgr.GetPane('2d').Hide()
@@ -362,7 +362,7 @@ class MapFrame(SingleMapFrame):
                                         Map = self.Map, tree = self.tree, lmgr = self._layerManager)
             self._setUpMapWindow(self.MapWindow3D)
             self.MapWindow3D.mapQueried.connect(self.Query)
-            self.MapWindow = self.MapWindow3D
+            self._switchMapWindow(self.MapWindow3D)
             self.MapWindow.SetNamedCursor('default')
 
             # here was AddNvizTools in lmgr
@@ -382,7 +382,7 @@ class MapFrame(SingleMapFrame):
             self.MapWindow3D.overlayHidden.connect(self._hideOverlay)
             self.legend.overlayChanged.connect(self.MapWindow3D.UpdateOverlays)
         else:
-            self.MapWindow = self.MapWindow3D
+            self._switchMapWindow(self.MapWindow3D)
             os.environ['GRASS_REGION'] = self.Map.SetRegion(windres = True, windres3 = True)
             self.MapWindow3D.GetDisplay().Init()
             del os.environ['GRASS_REGION']
@@ -436,7 +436,7 @@ class MapFrame(SingleMapFrame):
         self._mgr.GetPane('2d').Show()
         self._mgr.GetPane('3d').Hide()
 
-        self.MapWindow = self.MapWindow2D
+        self._switchMapWindow(self.MapWindow2D)
         # here was RemoveNvizTools form lmgr
         self.ending3dMode.emit()
         try:
@@ -503,7 +503,7 @@ class MapFrame(SingleMapFrame):
         if name == 'vdigit':
             self._mgr.GetPane('vdigit').Hide()
             self._mgr.GetPane('2d').Show()
-            self.MapWindow = self.MapWindow2D
+            self._switchMapWindow(self.MapWindow2D)
             
         self.toolbars['map'].combo.SetValue(_("2D view"))
         self.toolbars['map'].Enable2D(True)
@@ -1334,3 +1334,10 @@ class MapFrame(SingleMapFrame):
         handler).
         """
         self.GetMapToolbar().SelectDefault()
+
+    def _switchMapWindow(self, map_win):
+        """!Notifies activated and disactivated map_wins."""
+        self.MapWindow.DisactivateWin()
+        map_win.ActivateWin()
+
+        self.MapWindow = map_win

+ 8 - 0
gui/wxpython/mapwin/base.py

@@ -383,3 +383,11 @@ class MapWindowBase(object):
         self.zoomtype = zoomType
         self.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
         self.SetNamedCursor('cross')
+
+    def DisactivateWin(self):
+        """!Use when the class instance is hidden in MapFrame."""
+        raise NotImplementedError()
+
+    def ActivateWin(self):
+        """!Used when the class instance is activated in MapFrame."""
+        raise NotImplementedError()

+ 16 - 2
gui/wxpython/mapwin/buffered.py

@@ -175,8 +175,9 @@ class BufferedMapWindow(MapWindowBase, wx.Window):
         self._buffer = wx.EmptyBitmap(max(1, self.Map.width), max(1, self.Map.height))
         
         self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x:None)
+
         # rerender when Map reports change
-        self.Map.layerChanged.connect(lambda: self.UpdateMap())
+        self.Map.layerChanged.connect(self.OnUpdateMap)
         
         # vars for handling mouse clicks
         self.dragid   = -1
@@ -184,7 +185,20 @@ class BufferedMapWindow(MapWindowBase, wx.Window):
         
         # list for registration of graphics to draw
         self.graphicsSetList = []
-  
+
+    def OnUpdateMap(self):
+        # before lambda func was used, however it was problem 
+        # to disconnect it from signal
+        self.UpdateMap()
+
+    def DisactivateWin(self):
+        """!Use when the class instance is hidden in MapFrame."""
+        self.Map.layerChanged.disconnect(self.OnUpdateMap)
+
+    def ActivateWin(self):
+        """!Used when the class instance is activated in MapFrame."""
+        self.Map.layerChanged.connect(self.OnUpdateMap)
+
     def _definePseudoDC(self):
         """!Define PseudoDC objects to use
         """

+ 8 - 0
gui/wxpython/nviz/mapwindow.py

@@ -2590,3 +2590,11 @@ class GLWindow(MapWindowBase, glcanvas.GLCanvas):
         @param textinfo text metadata (text, font, color, rotation)
         """
         return self.parent.MapWindow2D.TextBounds(textinfo, relcoords = True)
+
+    def DisactivateWin(self):
+        """!Use when the class instance is hidden in MapFrame."""
+        pass
+
+    def ActivateWin(self):
+        """!Used when the class instance is activated in MapFrame."""
+        pass