[GRASS-SVN] r31034 - in grass/trunk/gui/wxpython: . gui_modules xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Apr 19 07:14:22 EDT 2008
Author: martinl
Date: 2008-04-19 07:14:21 -0400 (Sat, 19 Apr 2008)
New Revision: 31034
Modified:
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/workspace.py
grass/trunk/gui/wxpython/wxgui.py
grass/trunk/gui/wxpython/xml/grass-gxw.dtd
Log:
wxGUI: store the position of windows in workspace file, related to trac #130
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-04-19 09:46:19 UTC (rev 31033)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-04-19 11:14:21 UTC (rev 31034)
@@ -78,19 +78,26 @@
# Attribute Table Manager
#
'atm' : {
- 'highlight' : { 'color' : (255, 255, 0, 255), 'width' : 2},
- 'leftDbClick' : { 'selection' : 0 },
+ 'highlight' : { 'color' : (255, 255, 0, 255), 'width' : 2},
+ 'leftDbClick' : { 'selection' : 0 },
},
#
# Command
#
'cmd': {
- 'overwrite' : { 'enabled' : False },
- 'closeDlg' : { 'enabled' : False },
- 'verbosity' : { 'selection' : 'grassenv' },
- 'rasterOverlay' : { 'enabled' : False },
- },
+ 'overwrite' : { 'enabled' : False },
+ 'closeDlg' : { 'enabled' : False },
+ 'verbosity' : { 'selection' : 'grassenv' },
+ 'rasterOverlay' : { 'enabled' : False },
+ },
#
+ # Workspace
+ #
+ 'workspace' : {
+ 'posDisplay' : { 'enabled' : False },
+ 'posManager' : { 'enabled' : False },
+ },
+ #
# vdigit
#
'vdigit' : {
@@ -349,7 +356,7 @@
self.parent = parent # GMFrame
self.title = title
wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title,
- style=style)
+ style=style, size=(-1, -1))
self.settings = settings
# notebook
@@ -363,6 +370,7 @@
self.__CreateDisplayPage(notebook)
self.__CreateCmdPage(notebook)
self.__CreateAttributeManagerPage(notebook)
+ self.__CreateWorkspacePage(notebook)
self.__CreateAdvancedPage(notebook)
# buttons
@@ -407,7 +415,7 @@
self.SetSize((500, 375))
def __CreateGeneralPage(self, notebook):
- """Create notebook page concerning with symbology settings"""
+ """Create notebook page for general settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("General"))
@@ -472,7 +480,7 @@
return panel
def __CreateDisplayPage(self, notebook):
- """Create notebook page concerning for display settings"""
+ """Create notebook page for display settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Display"))
@@ -656,9 +664,9 @@
return panel
def __CreateAttributeManagerPage(self, notebook):
- """Create notebook page concerning for 'Attribute Table Manager' settings"""
+ """Create notebook page for 'Attribute Table Manager' settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
- notebook.AddPage(page=panel, text=_("Attribute Table Manager"))
+ notebook.AddPage(page=panel, text=_("Attributes"))
pageSizer = wx.BoxSizer(wx.VERTICAL)
@@ -732,8 +740,52 @@
return panel
+ def __CreateWorkspacePage(self, notebook):
+ """Create notebook page for workspace settings"""
+ panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
+ notebook.AddPage(page=panel, text=_("Workspace"))
+
+ border = wx.BoxSizer(wx.VERTICAL)
+ box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Loading workspace"))
+ sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+ gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
+ gridSizer.AddGrowableCol(0)
+
+ row = 0
+
+ #
+ # positioning
+ #
+ posDisplay = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+ label=_("Suppress positioning Map Display Window(s)"),
+ name='IsChecked')
+ posDisplay.SetValue(self.settings.Get(group='workspace', key='posDisplay', subkey='enabled'))
+ self.winId['workspace:posDisplay:enabled'] = posDisplay.GetId()
+
+ gridSizer.Add(item=posDisplay,
+ pos=(row, 0), span=(1, 2))
+
+ row +=1
+
+ posManager = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+ label=_("Suppress positioning Layer Manager window"),
+ name='IsChecked')
+ posManager.SetValue(self.settings.Get(group='workspace', key='posManager', subkey='enabled'))
+ self.winId['workspace:posManager:enabled'] = posManager.GetId()
+
+ gridSizer.Add(item=posManager,
+ pos=(row, 0), span=(1, 2))
+
+ sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
+ border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
+
+ panel.SetSizer(border)
+
+ return panel
+
def __CreateAdvancedPage(self, notebook):
- """Create notebook page concerning with symbology settings"""
+ """Create notebook page for advanced settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Advanced"))
Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2008-04-19 09:46:19 UTC (rev 31033)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2008-04-19 11:14:21 UTC (rev 31034)
@@ -45,10 +45,17 @@
self.inValue = False
self.inGroup = False
self.inDisplay = False
-
- # list of layers
+ self.inLayerManager = False
+
+ # layer manager properties
+ self.layerManager = {}
+ self.layerManager['pos'] = None # window position
+ self.layerManager['size'] = None # window size
+ # list of mapdisplays
self.displays = []
+ # list of map layers
self.layers = []
+
self.cmd = []
self.displayIndex = -1 # first display has index '0'
@@ -59,10 +66,25 @@
elif name == 'display':
self.inDisplay = True
self.displayIndex += 1
+ posAttr = attrs.get('dim', '')
+ if posAttr:
+ posVal = map(int, posAttr.split(','))
+ try:
+ pos = (posVal[0], posVal[1])
+ size = (posVal[2], posVal[3])
+ except:
+ pos = None
+ size = None
+ else:
+ pos = None
+ size = None
+
self.displays.append({
"render" : bool(int(attrs.get('render', "0"))),
"mode" : int(attrs.get('mode', 0)),
- "showCompExtent" : bool(int(attrs.get('showCompExtent', "0")))})
+ "showCompExtent" : bool(int(attrs.get('showCompExtent', "0"))),
+ "pos" : pos,
+ "size" : size})
elif name == 'group':
self.groupName = attrs.get('name', None)
@@ -107,7 +129,20 @@
elif name == 'selected':
if self.inLayer:
self.layerSelected = True;
-
+
+ elif name == 'layer_manager':
+ self.inLayerManager = True
+ posAttr = attrs.get('dim', '')
+ if posAttr:
+ posVal = map(int, posAttr.split(','))
+ try:
+ self.layerManager['pos'] = (posVal[0], posVal[1])
+ self.layerManager['size'] = (posVal[2], posVal[3])
+ except:
+ pass
+ else:
+ pass
+
def endElement(self, name):
if name == 'gxw':
self.inGxw = False
@@ -153,6 +188,9 @@
elif name == 'flag':
self.inFlag = False
+ elif name == 'layer_manager':
+ self.inLayerManager = False
+
def characters(self, ch):
self.my_characters(ch)
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2008-04-19 09:46:19 UTC (rev 31033)
+++ grass/trunk/gui/wxpython/wxgui.py 2008-04-19 11:14:21 UTC (rev 31034)
@@ -152,10 +152,6 @@
wx.CallAfter(self.notebook.SetSelection, 0)
- # start default initial display
- self.NewDisplay(show=False)
- self.Show()
-
# load workspace file if requested
if (self.workspaceFile):
# load given workspace file
@@ -163,10 +159,13 @@
self.SetTitle(self.baseTitle + " - " + os.path.basename(self.workspaceFile))
else:
self.workspaceFile = None
+ else:
+ # start default initial display
+ self.NewDisplay(show=False)
# show map display widnow
# -> OnSize() -> UpdateMap()
- if not self.curr_page.maptree.mapdisplay.IsShown():
+ if self.curr_page and not self.curr_page.maptree.mapdisplay.IsShown():
self.curr_page.maptree.mapdisplay.Show()
def __doLayout(self):
@@ -533,9 +532,8 @@
Debug.msg(4, "GMFrame.OnWorkspaceOpen(): filename=%s" % filename)
- # start new map display if no display is available
- if not self.curr_page:
- self.NewDisplay()
+ # delete current layer tree content
+ self.OnWorkspaceClose()
self.LoadWorkspaceFile(filename)
@@ -568,9 +566,6 @@
# dlg.Destroy()
# return False
- # delete current layer tree content
- self.OnWorkspaceNew()
-
# read file and fix patch to dtd
try:
file = open(filename, "r")
@@ -600,22 +595,42 @@
parent=self)
wx.Yield()
- maptree = None
+ #
+ # load layer manager window properties
+ #
+ if UserSettings.Get(group='workspace', key='posManager', subkey='enabled') is False:
+ if gxwXml.layerManager['pos']:
+ self.SetPosition(gxwXml.layerManager['pos'])
+ if gxwXml.layerManager['size']:
+ self.SetSize(gxwXml.layerManager['size'])
+
+ #
+ # start map displays first (list of layers can be empty)
+ #
+ for display in gxwXml.displays:
+ mapdisplay = self.NewDisplay(show=False)
+ # set windows properties
+ mapdisplay.SetProperties(render=display['render'],
+ mode=display['mode'],
+ showCompExtent=display['showCompExtent'])
+
+ # set position and size of map display
+ if UserSettings.Get(group='workspace', key='posDisplay', subkey='enabled') is False:
+ if display['pos']:
+ mapdisplay.SetPosition(display['pos'])
+ if display['size']:
+ mapdisplay.SetSize(display['size'])
+
+ mapdisplay.Show()
+
+ maptree = None
selected = [] # list of selected layers
+ #
+ # load list of map layers
+ #
for layer in gxwXml.layers:
- if layer['display'] >= self.disp_idx:
- # start new map display if no display is available
- self.NewDisplay()
-
- maptree = self.gm_cb.GetPage(layer['display']).maptree
- mapdisplay = maptree.mapdisplay
- mapdisplay.SetProperties(render=gxwXml.displays[layer['display']]['render'],
- mode=gxwXml.displays[layer['display']]['mode'],
- showCompExtent=gxwXml.displays[layer['display']]['showCompExtent'])
-
- if not maptree.mapdisplay.IsShown():
- # show map display
- maptree.mapdisplay.Show()
+ display = layer['display']
+ maptree = self.gm_cb.GetPage(display).maptree
newItem = maptree.AddLayer(ltype=layer['type'],
lname=layer['name'],
@@ -846,22 +861,47 @@
file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
file.write('<!DOCTYPE gxw SYSTEM "grass-gxw.dtd">\n')
file.write('%s<gxw>\n' % (' ' * self.indent))
+
+ self.indent =+ 4
+
+ # layer manager
+ windowPos = self.GetPosition()
+ windowSize = self.GetSize()
+ file.write('%s<layer_manager dim="%d,%d,%d,%d">\n' % (' ' * self.indent,
+ windowPos[0],
+ windowPos[1],
+ windowSize[0],
+ windowSize[1]
+ ))
+
+ file.write('%s</layer_manager>\n' % (' ' * self.indent))
+
# list of displays
for page in range(0, self.gm_cb.GetPageCount()):
mapTree = self.gm_cb.GetPage(page).maptree
- self.indent =+ 4
+ displayPos = mapTree.mapdisplay.GetPosition()
+ displaySize = mapTree.mapdisplay.GetSize()
+
+
+
file.write('%s<display render="%d" '
- 'mode="%d" showCompExtent="%d">\n' % (' ' * self.indent,
- int(mapTree.mapdisplay.autoRender.IsChecked()),
- mapTree.mapdisplay.toggleStatus.GetSelection(),
- int(mapTree.mapdisplay.showRegion.IsChecked()),
- ))
+ 'mode="%d" showCompExtent="%d" '
+ 'dim="%d,%d,%d,%d">\n' % (' ' * self.indent,
+ int(mapTree.mapdisplay.autoRender.IsChecked()),
+ mapTree.mapdisplay.toggleStatus.GetSelection(),
+ int(mapTree.mapdisplay.showRegion.IsChecked()),
+ displayPos[0],
+ displayPos[1],
+ displaySize[0],
+ displaySize[1]
+ ))
# list of layers
item = mapTree.GetFirstChild(mapTree.root)[0]
self.WriteLayersToWorkspaceFile(file, mapTree, item)
file.write('%s</display>\n' % (' ' * self.indent))
+
self.indent =- 4
file.write('%s</gxw>\n' % (' ' * self.indent))
del self.indent
@@ -885,6 +925,16 @@
self.workspaceFile = None
self.SetTitle(self.baseTitle)
+ displays = []
+ for page in range(0, self.gm_cb.GetPageCount()):
+ displays.append(self.gm_cb.GetPage(page).maptree.mapdisplay)
+
+ for display in displays:
+ display.Close()
+
+ self.disp_idx = 0
+ self.curr_page = None
+
def RulesCmd(self, event):
"""
Launches dialog for commands that need rules
@@ -1104,6 +1154,10 @@
def NewDisplay(self, show=True):
"""Create new layer tree, which will
create an associated map display frame
+
+ @param show show map display window if True
+
+ @return reference to mapdisplay intance
"""
Debug.msg(1, "GMFrame.NewDisplay(): idx=%d" % self.disp_idx)
@@ -1140,6 +1194,8 @@
#
# self._auimgr.Update()
+ return self.curr_page.maptree.mapdisplay
+
# toolBar button handlers
def OnAddRaster(self, event):
"""Add raster menu"""
Modified: grass/trunk/gui/wxpython/xml/grass-gxw.dtd
===================================================================
--- grass/trunk/gui/wxpython/xml/grass-gxw.dtd 2008-04-19 09:46:19 UTC (rev 31033)
+++ grass/trunk/gui/wxpython/xml/grass-gxw.dtd 2008-04-19 11:14:21 UTC (rev 31034)
@@ -14,8 +14,17 @@
<!ELEMENT grass-gxw (gxw)>
-<!ELEMENT gxw (display*)>
+<!ELEMENT gxw (layer_manager?, display*)>
+<!-- a layer_manager defines properties of Layer Manager
+ GUI component
+
+ element added 2008/04
+-->
+<!ELEMENT layer_manager ANY>
+<!-- window dimenstion (x, y (ur), width, heigth -->
+<!ATTLIST layer_manager dim CDATA #IMPLIED>
+
<!-- a display element defines map layer connected to given
map display widnow
@@ -25,6 +34,8 @@
<!ATTLIST display render (0 | 1) #IMPLIED>
<!ATTLIST display mode (0 | 1 | 2 | 3 | 4 | 5 | 6) #IMPLIED>
<!ATTLIST display showCompExtent (0 | 1) #IMPLIED>
+<!-- window dimenstion (x, y (ur), width, heigth -->
+<!ATTLIST display dim CDATA #IMPLIED>
<!-- group of map layers
-->
More information about the grass-commit
mailing list