[GRASS-SVN] r49435 - in grass/trunk/gui/wxpython: gcp gui_core
mapdisp
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Nov 30 11:17:59 EST 2011
Author: martinl
Date: 2011-11-30 08:17:59 -0800 (Wed, 30 Nov 2011)
New Revision: 49435
Added:
grass/trunk/gui/wxpython/mapdisp/main.py
Modified:
grass/trunk/gui/wxpython/gcp/mapdisplay.py
grass/trunk/gui/wxpython/gui_core/mapdisp.py
grass/trunk/gui/wxpython/mapdisp/frame.py
Log:
wxGUI: added 'mapdisp.main' for standalone app
Modified: grass/trunk/gui/wxpython/gcp/mapdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/mapdisplay.py 2011-11-30 16:04:22 UTC (rev 49434)
+++ grass/trunk/gui/wxpython/gcp/mapdisplay.py 2011-11-30 16:17:59 UTC (rev 49435)
@@ -127,8 +127,8 @@
#
# initialize region values
#
- self._initMap(map = self.SrcMap)
- self._initMap(map = self.TgtMap)
+ self._initMap(Map = self.SrcMap)
+ self._initMap(Map = self.TgtMap)
#
# Bind various events
Modified: grass/trunk/gui/wxpython/gui_core/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapdisp.py 2011-11-30 16:04:22 UTC (rev 49434)
+++ grass/trunk/gui/wxpython/gui_core/mapdisp.py 2011-11-30 16:17:59 UTC (rev 49435)
@@ -76,7 +76,7 @@
#
self._mgr = wx.aui.AuiManager(self)
- def _initMap(self, map):
+ def _initMap(self, Map):
"""!Initialize map display, set dimensions and map region
"""
if not grass.find_program('g.region', ['--help']):
@@ -86,8 +86,8 @@
self.width, self.height = self.GetClientSize()
Debug.msg(2, "MapFrame._initMap():")
- map.ChangeMapSize(self.GetClientSize())
- map.region = map.GetRegion() # g.region -upgc
+ Map.ChangeMapSize(self.GetClientSize())
+ Map.region = Map.GetRegion() # g.region -upgc
# self.Map.SetRegion() # adjust region to match display window
def SetProperty(self, name, value):
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2011-11-30 16:04:22 UTC (rev 49434)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2011-11-30 16:17:59 UTC (rev 49435)
@@ -8,11 +8,7 @@
Classes:
- mapdisp::MapFrame
- - mapdisp::MapApp
-Usage:
-python mapdisp.py monitor-identifier /path/to/map/file /path/to/command/file /path/to/env/file
-
(C) 2006-2011 by the GRASS Development Team
This program is free software under the GNU General Public License
@@ -62,14 +58,6 @@
from grass.script import core as grass
-# for standalone app
-monFile = { 'cmd' : None,
- 'map' : None,
- 'env' : None,
- }
-monName = None
-monSize = list(globalvar.MAP_WINDOW_SIZE)
-
haveCtypes = False
class MapFrame(MapFrameBase):
@@ -155,7 +143,7 @@
#
# initialize region values
#
- self._initMap(map = self.Map)
+ self._initMap(Map = self.Map)
#
# Bind various events
@@ -1405,101 +1393,3 @@
def GetMapToolbar(self):
"""!Returns toolbar with zooming tools"""
return self.toolbars['map']
-
-class MapApp(wx.App):
- def OnInit(self):
- wx.InitAllImageHandlers()
- if __name__ == "__main__":
- self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
- Map = Map(cmdfile = monFile['cmd'], mapfile = monFile['map'],
- envfile = monFile['env'], monitor = monName)
- else:
- Map = None
-
- self.mapFrm = MapFrame(parent = None, id = wx.ID_ANY, Map = Map,
- size = monSize)
- # self.SetTopWindow(Map)
- self.mapFrm.Show()
-
- if __name__ == "__main__":
- self.timer = wx.PyTimer(self.watcher)
- #check each 0.5s
- global mtime
- mtime = 500
- self.timer.Start(mtime)
-
- return True
-
- def OnExit(self):
- if __name__ == "__main__":
- # stop the timer
- # self.timer.Stop()
- # terminate thread
- for f in monFile.itervalues():
- grass.try_remove(f)
-
- def watcher(self):
- """!Redraw, if new layer appears (check's timestamp of
- cmdfile)
- """
- # todo: events
- if os.path.getmtime(monFile['cmd']) > self.cmdTimeStamp:
- 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
- if len(sys.argv) < 5:
- print __doc__
- sys.exit(1)
-
- monName = sys.argv[1]
- monFile = { 'map' : sys.argv[2],
- 'cmd' : sys.argv[3],
- 'env' : sys.argv[4],
- }
- if len(sys.argv) >= 6:
- try:
- monSize[0] = int(sys.argv[5])
- except ValueError:
- pass
-
- if len(sys.argv) == 7:
- try:
- monSize[1] = int(sys.argv[6])
- except ValueError:
- pass
-
- import gettext
- gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
-
- grass.verbose(_("Starting map display <%s>...") % (monName))
-
- RunCommand('g.gisenv',
- set = 'MONITOR_%s_PID=%d' % (monName, os.getpid()))
-
- gm_map = MapApp(0)
- # set title
- gm_map.mapFrm.SetTitle(_("GRASS GIS Map Display: " +
- monName +
- " - Location: " + grass.gisenv()["LOCATION_NAME"]))
-
- gm_map.MainLoop()
-
- grass.verbose(_("Stopping map display <%s>...") % (monName))
-
- # clean up GRASS env variables
- env = grass.gisenv()
- env_name = 'MONITOR_%s' % monName
- for key in env.keys():
- if key.find(env_name) == 0:
- RunCommand('g.gisenv',
- set = '%s=' % key)
- if key == 'MONITOR' and env[key] == monName:
- RunCommand('g.gisenv',
- set = '%s=' % key)
-
- sys.exit(0)
Added: grass/trunk/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/main.py (rev 0)
+++ grass/trunk/gui/wxpython/mapdisp/main.py 2011-11-30 16:17:59 UTC (rev 49435)
@@ -0,0 +1,141 @@
+"""!
+ at package mapdisp.main
+
+ at brief Start Map Display as standalone application
+
+Classes:
+ - mapdisp::MapApp
+
+Usage:
+python mapdisp/main.py monitor-identifier /path/to/map/file /path/to/command/file /path/to/env/file
+
+(C) 2006-2011 by the GRASS Development Team
+
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+ at author Michael Barton
+ at author Jachym Cepicky
+ at author Martin Landa <landa.martin gmail.com>
+ at author Vaclav Petras <wenzeslaus gmail.com> (MapFrameBase)
+ at author Anna Kratochvilova <kratochanna gmail.com> (MapFrameBase)
+"""
+
+import os
+import sys
+
+import wx
+
+sys.path.append(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython'))
+from core import globalvar
+from core.gcmd import RunCommand
+from core.render import Map
+from mapdisp.frame import MapFrame
+from grass.script import core as grass
+
+# for standalone app
+monFile = { 'cmd' : None,
+ 'map' : None,
+ 'env' : None,
+ }
+monName = None
+monSize = list(globalvar.MAP_WINDOW_SIZE)
+
+
+class MapApp(wx.App):
+ def OnInit(self):
+ wx.InitAllImageHandlers()
+ if __name__ == "__main__":
+ self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
+ self.Map = Map(cmdfile = monFile['cmd'], mapfile = monFile['map'],
+ envfile = monFile['env'], monitor = monName)
+ else:
+ self.Map = None
+
+ self.mapFrm = MapFrame(parent = None, id = wx.ID_ANY, Map = self.Map,
+ size = monSize)
+ # self.SetTopWindow(Map)
+ self.mapFrm.Show()
+
+ if __name__ == "__main__":
+ self.timer = wx.PyTimer(self.watcher)
+ #check each 0.5s
+ global mtime
+ mtime = 500
+ self.timer.Start(mtime)
+
+ return True
+
+ def OnExit(self):
+ if __name__ == "__main__":
+ # stop the timer
+ # self.timer.Stop()
+ # terminate thread
+ for f in monFile.itervalues():
+ grass.try_remove(f)
+
+ def watcher(self):
+ """!Redraw, if new layer appears (check's timestamp of
+ cmdfile)
+ """
+ # todo: events
+ if os.path.getmtime(monFile['cmd']) > self.cmdTimeStamp:
+ 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
+ if len(sys.argv) < 5:
+ print __doc__
+ sys.exit(1)
+
+ monName = sys.argv[1]
+ monFile = { 'map' : sys.argv[2],
+ 'cmd' : sys.argv[3],
+ 'env' : sys.argv[4],
+ }
+ if len(sys.argv) >= 6:
+ try:
+ monSize[0] = int(sys.argv[5])
+ except ValueError:
+ pass
+
+ if len(sys.argv) == 7:
+ try:
+ monSize[1] = int(sys.argv[6])
+ except ValueError:
+ pass
+
+ import gettext
+ gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
+
+ grass.verbose(_("Starting map display <%s>...") % (monName))
+
+ RunCommand('g.gisenv',
+ set = 'MONITOR_%s_PID=%d' % (monName, os.getpid()))
+
+ gmMap = MapApp(0)
+ # set title
+ gmMap.mapFrm.SetTitle(_("GRASS GIS Map Display: " +
+ monName +
+ " - Location: " + grass.gisenv()["LOCATION_NAME"]))
+
+ gmMap.MainLoop()
+
+ grass.verbose(_("Stopping map display <%s>...") % (monName))
+
+ # clean up GRASS env variables
+ env = grass.gisenv()
+ env_name = 'MONITOR_%s' % monName
+ for key in env.keys():
+ if key.find(env_name) == 0:
+ RunCommand('g.gisenv',
+ set = '%s=' % key)
+ if key == 'MONITOR' and env[key] == monName:
+ RunCommand('g.gisenv',
+ set = '%s=' % key)
+
+ sys.exit(0)
Property changes on: grass/trunk/gui/wxpython/mapdisp/main.py
___________________________________________________________________
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list