Parcourir la source

wxGUI: dmon supports zoom to extent and warns about missing cmd file (author Vaclav Petras)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51836 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová il y a 13 ans
Parent
commit
7e2c1d2312
1 fichiers modifiés avec 16 ajouts et 6 suppressions
  1. 16 6
      gui/wxpython/mapdisp/main.py

+ 16 - 6
gui/wxpython/mapdisp/main.py

@@ -222,6 +222,11 @@ class DMonMap(Map):
         """
         return self._renderCmdFile(force, windres)
 
+class DMonFrame(MapFrame):
+    def OnZoomToMap(self, event):
+        layers = self.MapWindow.GetMap().GetListOfLayers()
+        self.MapWindow.ZoomToMap(layers = layers)
+        
 
 class MapApp(wx.App):
     def OnInit(self):
@@ -233,7 +238,7 @@ class MapApp(wx.App):
         else:
             self.Map = None
 
-        self.mapFrm = MapFrame(parent = None, id = wx.ID_ANY, Map = self.Map,
+        self.mapFrm = DMonFrame(parent = None, id = wx.ID_ANY, Map = self.Map,
                                size = monSize)
         # self.SetTopWindow(Map)
         self.mapFrm.GetMapWindow().SetAlwaysRenderEnabled(True)
@@ -270,12 +275,17 @@ class MapApp(wx.App):
             return
         
         # todo: events
-        if os.path.getmtime(monFile['cmd']) > self.cmdTimeStamp:
+        try:
+            currentCmdFileTime = os.path.getmtime(monFile['cmd'])
+            if currentCmdFileTime > self.cmdTimeStamp:
+                self.timer.Stop()
+                self.cmdTimeStamp = currentCmdFileTime
+                self.mapFrm.OnDraw(None)
+                self.mapFrm.GetMap().GetLayersFromCmdFile()
+                self.timer.Start(mtime)
+        except OSError, e:
+            grass.warning("%s" % e)
             self.timer.Stop()
-            self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
-            self.mapFrm.OnDraw(None)
-            self.mapFrm.GetMap().GetLayersFromCmdFile()
-            self.timer.Start(mtime)
 
 if __name__ == "__main__":
     # set command variable