[GRASS-SVN] r63534 - in grass/trunk/gui/wxpython: gui_core mapdisp
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Dec 14 04:49:28 PST 2014
Author: martinl
Date: 2014-12-14 04:49:28 -0800 (Sun, 14 Dec 2014)
New Revision: 63534
Modified:
grass/trunk/gui/wxpython/gui_core/mapdisp.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/mapdisp/main.py
Log:
wxGUI: allow start monitor without toolbar and statusbar
Modified: grass/trunk/gui/wxpython/gui_core/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapdisp.py 2014-12-14 09:58:50 UTC (rev 63533)
+++ grass/trunk/gui/wxpython/gui_core/mapdisp.py 2014-12-14 12:49:28 UTC (rev 63534)
@@ -276,8 +276,9 @@
def StatusbarUpdate(self):
"""Update statusbar content"""
- Debug.msg(5, "MapFrameBase.StatusbarUpdate()")
- self.statusbarManager.Update()
+ if self.statusbarManager:
+ Debug.msg(5, "MapFrameBase.StatusbarUpdate()")
+ self.statusbarManager.Update()
def IsAutoRendered(self):
"""Check if auto-rendering is enabled"""
@@ -292,12 +293,14 @@
"""
# assuming that the first mode is coordinates
# probably shold not be here but good solution is not available now
- if self.statusbarManager.GetMode() == 0:
- self.statusbarManager.ShowItem('coordinates')
+ if self.statusbarManager:
+ if self.statusbarManager.GetMode() == 0:
+ self.statusbarManager.ShowItem('coordinates')
def StatusbarReposition(self):
"""Reposition items in statusbar"""
- self.statusbarManager.Reposition()
+ if self.statusbarManager:
+ self.statusbarManager.Reposition()
def StatusbarEnableLongHelp(self, enable = True):
"""Enable/disable toolbars long help"""
@@ -334,12 +337,13 @@
def _setUpMapWindow(self, mapWindow):
"""Binds map windows' zoom history signals to map toolbar."""
# enable or disable zoom history tool
- mapWindow.zoomHistoryAvailable.connect(
- lambda:
- self.GetMapToolbar().Enable('zoomBack', enable=True))
- mapWindow.zoomHistoryUnavailable.connect(
- lambda:
- self.GetMapToolbar().Enable('zoomBack', enable=False))
+ if self.GetMapToolbar():
+ mapWindow.zoomHistoryAvailable.connect(
+ lambda:
+ self.GetMapToolbar().Enable('zoomBack', enable=True))
+ mapWindow.zoomHistoryUnavailable.connect(
+ lambda:
+ self.GetMapToolbar().Enable('zoomBack', enable=False))
mapWindow.mouseMoving.connect(self.CoordinatesChanged)
def OnPointer(self, event):
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2014-12-14 09:58:50 UTC (rev 63533)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2014-12-14 12:49:28 UTC (rev 63534)
@@ -67,18 +67,20 @@
child double buffered drawing window.
"""
def __init__(self, parent, giface, title = _("GRASS GIS - Map display"),
- toolbars = ["map"], tree = None, notebook = None, lmgr = None,
+ toolbars = ["map"], statusbar = True,
+ tree = None, notebook = None, lmgr = None,
page = None, Map = None, auimgr = None, name = 'MapWindow', **kwargs):
"""Main map display window with toolbars, statusbar and
2D map window, 3D map window and digitizer.
:param toolbars: array of activated toolbars, e.g. ['map', 'digit']
+ :param statusbar: True to add statusbar
:param tree: reference to layer tree
:param notebook: control book ID in Layer Manager
:param lmgr: Layer Manager
:param page: notebook page with layer tree
:param map: instance of render.Map
- :param auimgs: AUI manager
+ :param auimgr: AUI manager
:param name: frame name
:param kwargs: wx.Frame attributes
"""
@@ -119,41 +121,10 @@
#
# Add statusbar
#
+ self.statusbarManager = None
+ if statusbar:
+ self.CreateStatusbar()
- # items for choice
- self.statusbarItems = [sb.SbCoordinates,
- sb.SbRegionExtent,
- sb.SbCompRegionExtent,
- sb.SbShowRegion,
- sb.SbAlignExtent,
- sb.SbResolution,
- sb.SbDisplayGeometry,
- sb.SbMapScale,
- sb.SbGoTo,
- sb.SbProjection]
-
- self.statusbarItemsHiddenInNviz = (sb.SbAlignExtent,
- sb.SbDisplayGeometry,
- sb.SbShowRegion,
- sb.SbResolution,
- sb.SbMapScale)
-
- # create statusbar and its manager
- statusbar = self.CreateStatusBar(number = 4, style = 0)
- statusbar.SetStatusWidths([-5, -2, -1, -1])
- self.statusbarManager = sb.SbManager(mapframe = self, statusbar = statusbar)
-
- # fill statusbar manager
- self.statusbarManager.AddStatusbarItemsByClass(self.statusbarItems, mapframe = self, statusbar = statusbar)
- self.statusbarManager.AddStatusbarItem(sb.SbMask(self, statusbar = statusbar, position = 2))
- sbRender = sb.SbRender(self, statusbar = statusbar, position = 3)
- self.statusbarManager.AddStatusbarItem(sbRender)
-
- self.statusbarManager.Update()
-
- #
- self.Map.updateProgress.connect(self.statusbarManager.SetProgress)
-
# init decoration objects
self.decorations = {}
self.legend = LegendController(self.Map, self._giface)
@@ -196,7 +167,9 @@
# used by Nviz (3D display mode)
self.MapWindow3D = None
- self.toolbars['map'].SelectDefault()
+ if 'map' in self.toolbars:
+ self.toolbars['map'].SelectDefault()
+
#
# Bind various events
#
@@ -233,7 +206,45 @@
self.measureController = None
self._resize()
-
+
+ def CreateStatusbar(self):
+ if self.statusbarManager:
+ return
+
+ # items for choice
+ self.statusbarItems = [sb.SbCoordinates,
+ sb.SbRegionExtent,
+ sb.SbCompRegionExtent,
+ sb.SbShowRegion,
+ sb.SbAlignExtent,
+ sb.SbResolution,
+ sb.SbDisplayGeometry,
+ sb.SbMapScale,
+ sb.SbGoTo,
+ sb.SbProjection]
+
+ self.statusbarItemsHiddenInNviz = (sb.SbAlignExtent,
+ sb.SbDisplayGeometry,
+ sb.SbShowRegion,
+ sb.SbResolution,
+ sb.SbMapScale)
+
+ # create statusbar and its manager
+ statusbar = self.CreateStatusBar(number = 4, style = 0)
+ statusbar.SetStatusWidths([-5, -2, -1, -1])
+ self.statusbarManager = sb.SbManager(mapframe = self, statusbar = statusbar)
+
+ # fill statusbar manager
+ self.statusbarManager.AddStatusbarItemsByClass(self.statusbarItems, mapframe = self, statusbar = statusbar)
+ self.statusbarManager.AddStatusbarItem(sb.SbMask(self, statusbar = statusbar, position = 2))
+ sbRender = sb.SbRender(self, statusbar = statusbar, position = 3)
+ self.statusbarManager.AddStatusbarItem(sbRender)
+
+ self.statusbarManager.Update()
+
+ #
+ self.Map.updateProgress.connect(self.statusbarManager.SetProgress)
+
def GetMapWindow(self):
return self.MapWindow
Modified: grass/trunk/gui/wxpython/mapdisp/main.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/main.py 2014-12-14 09:58:50 UTC (rev 63533)
+++ grass/trunk/gui/wxpython/mapdisp/main.py 2014-12-14 12:49:28 UTC (rev 63534)
@@ -52,6 +52,7 @@
}
monName = None
monSize = list(globalvar.MAP_WINDOW_SIZE)
+monDecor = False
class DMonMap(Map):
def __init__(self, giface, cmdfile=None, mapfile=None):
@@ -341,9 +342,15 @@
return self._mapframe.GetProgressBar()
def ShowStatusbar(self, show=True):
+ if not self._mapframe.statusbarManager:
+ self._mapframe.CreateStatusbar()
+
self._mapframe.statusbarManager.Show(show)
def IsStatusbarShown(self):
+ if not self._mapframe.statusbarManager:
+ return False
+
return self._mapframe.statusbarManager.IsShown()
def ShowAllToolbars(self, show=True):
@@ -351,11 +358,18 @@
action = self._mapframe.RemoveToolbar
else:
action = self._mapframe.AddToolbar
- for toolbar in self._mapframe.GetToolbarNames():
+ toolbars = self._mapframe.GetToolbarNames()
+ if not toolbars:
+ toolbars.append('map')
+ for toolbar in toolbars:
action(toolbar)
def AreAllToolbarsShown(self):
- return self._mapframe.GetMapToolbar().IsShown()
+ toolbar = self._mapframe.GetMapToolbar()
+ if toolbar is None:
+ return False
+
+ return toolbar.IsShown()
class DMonFrame(MapFrame):
def OnZoomToMap(self, event):
@@ -371,26 +385,25 @@
grass.set_raise_on_error(True)
# actual use of StandaloneGrassInterface not yet tested
# needed for adding functionality in future
- giface = DMonGrassInterface(None)
+ self._giface = DMonGrassInterface(None)
if __name__ == "__main__":
self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
- self.Map = DMonMap(giface=giface, cmdfile=monFile['cmd'],
+ self.Map = DMonMap(giface=self._giface, cmdfile=monFile['cmd'],
mapfile = monFile['map'])
else:
self.Map = None
self.mapFrm = DMonFrame(parent = None, id = wx.ID_ANY, Map = self.Map,
- giface = giface, size = monSize)
+ giface = self._giface, size = monSize, toolbars = [], statusbar = False)
# FIXME: hack to solve dependency
- giface._mapframe = self.mapFrm
+ self._giface._mapframe = self.mapFrm
# self.SetTopWindow(Map)
self.mapFrm.GetMapWindow().SetAlwaysRenderEnabled(True)
self.Map.saveToFile.connect(lambda cmd: self.mapFrm.DOutFile(cmd))
self.Map.dToRast.connect(lambda cmd: self.mapFrm.DToRast(cmd))
self.Map.query.connect(lambda ltype, maps: self.mapFrm.SetQueryLayersAndActivate(ltype=ltype, maps=maps))
- self.mapFrm.Show()
-
+
if __name__ == "__main__":
self.timer = wx.PyTimer(self.watcher)
#check each 0.5s
@@ -459,12 +472,17 @@
except ValueError:
pass
- if len(sys.argv) == 7:
+ if len(sys.argv) >= 7:
try:
monSize[1] = int(sys.argv[6])
except ValueError:
pass
+ if len(sys.argv) == 8:
+ try:
+ monDecor = True if sys.argv[7] == "0" else False
+ except ValueError:
+ monDecor = True
grass.verbose(_("Starting map display <%s>...") % (monName))
@@ -472,8 +490,12 @@
set = 'MONITOR_%s_PID=%d' % (monName.upper(), os.getpid()))
gmMap = MapApp(0)
- # set title
- gmMap.mapFrm.SetTitle(monName)
+ mapFrame = gmMap.GetMapFrame()
+ mapFrame.SetTitle(monName)
+ if monDecor:
+ mapFrame._giface.ShowAllToolbars(monDecor)
+ mapFrame._giface.ShowStatusbar(monDecor)
+ mapFrame.Show()
gmMap.MainLoop()
More information about the grass-commit
mailing list