[GRASS-SVN] r32649 - in grass/trunk/gui/wxpython: . gui_modules
vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 8 19:10:20 EDT 2008
Author: martinl
Date: 2008-08-08 19:10:20 -0400 (Fri, 08 Aug 2008)
New Revision: 32649
Modified:
grass/trunk/gui/wxpython/gui_modules/dbm.py
grass/trunk/gui/wxpython/gui_modules/gcmd.py
grass/trunk/gui/wxpython/gui_modules/gdialogs.py
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/gui_modules/vdigit.py
grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
grass/trunk/gui/wxpython/vdigit/driver.cpp
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: vdigit - settings cosmetics, don't crash when all features are disabled
overwrite checkbox removed from NewVectorDialog? (there is already this option in GUI preferences)
some cosmetics in goutput module, print data/time instead thread number
(merge from devbr6, r32647)
Modified: grass/trunk/gui/wxpython/gui_modules/dbm.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/dbm.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/dbm.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -380,12 +380,13 @@
"""
def __init__(self, parent, id, title, vectmap,
size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE,
- pointdata=None):
+ pointdata=None, log=None):
self.vectmap = vectmap
self.pointdata = pointdata
self.parent = parent # GMFrame
-
+ self.cmdLog = log # self.parent.goutput
+
wx.Frame.__init__(self, parent, id, title, style=style)
# icon
@@ -1721,32 +1722,16 @@
wx.MessageBox(parent=self,
message=_('Nothing to extract.'),
caption=_('Extract selected'), style=wx.CENTRE)
- return False
+ return
else:
# dialog to get file name
- dlg = gdialogs.NewVectorDialog(parent=self, id=wx.ID_ANY, title=_('Extract selected'))
-
- if dlg.ShowModal() == wx.ID_OK:
- outmap, overwrite = dlg.GetName()
-
- if outmap == '': # should not happen
- return False
-
- cmd = ["v.extract",
- "input=%s" % self.vectmap,
- "output=%s" % outmap,
- "list=%s" % utils.ListOfCatsToRange(cats)]
-
- if overwrite is True:
- cmd.append('--overwrite')
-
- p = gcmd.Command(cmd, stderr=None)
+ gdialogs.CreateNewVector(parent=self, title=_('Extract selected'),
+ log=self.cmdLog,
+ cmdDef=(["v.extract",
+ "input=%s" % self.vectmap,
+ "list=%s" % utils.ListOfCatsToRange(cats)],
+ "output"))
- if p.returncode == 0:
- return True
-
- return False
-
def AddQueryMapLayer(self):
"""Redraw a map
Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -67,6 +67,11 @@
message=self.message,
style=wx.ICON_ERROR | wx.CENTRE)
dlg.SetIcon(wx.Icon(os.path.join(globalvar.ETCDIR, 'grass_error.ico'), wx.BITMAP_TYPE_ICO))
+ if self.parent:
+ dlg.CentreOnParent()
+ else:
+ dlg.CentreOnScreen()
+
dlg.ShowModal()
return ''
Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -60,12 +60,7 @@
type='vector', mapsets=[grassenv.GetGRASSVariable('MAPSET'),])
self.mapName.Bind(wx.EVT_TEXT, self.OnMapName)
-
- # TODO remove (see Preferences dialog)
- self.overwrite = wx.CheckBox(parent=self.panel, id=wx.ID_ANY,
- label=_("Allow output files to overwrite existing files"))
- self.overwrite.SetValue(UserSettings.Get(group='cmd', key='overwrite', subkey='enabled'))
-
+
self.__Layout()
self.SetMinSize(self.GetSize())
@@ -86,9 +81,7 @@
flag=wx.ALL, border=1)
dataSizer.Add(self.mapName, proportion=0,
flag=wx.EXPAND | wx.ALL, border=1)
- dataSizer.Add(self.overwrite, proportion=0,
- flag=wx.ALL, border=1)
-
+
# buttons
btnSizer = wx.StdDialogButtonSizer()
btnSizer.AddButton(self.btnCancel)
@@ -108,46 +101,64 @@
"""Return (mapName, overwrite)"""
mapName = self.mapName.GetValue().split('@', 1)[0]
- return (mapName,
- self.overwrite.IsChecked())
-
-def CreateNewVector(parent, title=_('Create new vector map'),
- exceptMap=None):
+ return mapName
+
+def CreateNewVector(parent, cmdDef, title=_('Create new vector map'),
+ exceptMap=None, log=None):
"""Create new vector map layer
+ @cmdList tuple/list (cmd list, output paramater)
+
@return name of create vector map
@return None of failure
"""
+ cmd = cmdDef[0]
dlg = NewVectorDialog(parent=parent, id=wx.ID_ANY, title=title)
if dlg.ShowModal() == wx.ID_OK:
- outmap, overwrite = dlg.GetName()
+ outmap = dlg.GetName()
if outmap == exceptMap:
wx.MessageBox(parent=parent,
message=_("Unable to create vector map <%s>.") % outmap,
caption=_("Error"),
style=wx.ID_OK | wx.ICON_ERROR | wx.CENTRE)
return False
-
+
if outmap == '': # should not happen
return False
- cmd = ["v.edit",
- "map=%s" % outmap,
- "tool=create"]
-
- if overwrite is True:
+ cmd.append("%s=%s" % (cmdDef[1], outmap))
+
+ if not UserSettings.Get(group='cmd', key='overwrite', subkey='enabled') and \
+ outmap in grass.list_grouped('vect')[grass.gisenv()['MAPSET']]:
+ dlg = wx.MessageDialog(parent, message=_("Vector map <%s> already exists "
+ "in the current mapset. "
+ "Do you want to overwrite it?") % outmap,
+ caption=_("Overwrite?"),
+ style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
+ if dlg.ShowModal() == wx.ID_YES:
+ cmd.append('--overwrite')
+ else:
+ dlg.Destroy()
+ return False
+
+ if UserSettings.Get(group='cmd', key='overwrite', subkey='enabled') is True:
cmd.append('--overwrite')
-
+
try:
- p = gcmd.Command(cmd, stderr=None)
+ gcmd.Command(cmd)
except gcmd.CmdError, e:
print >> sys.stderr, e
return None
- if p.returncode == 0:
- # return fully qualified map name
- return outmap + '@' + grassenv.GetGRASSVariable('MAPSET')
+ # return fully qualified map name
+ if '@' not in outmap:
+ outmap += '@' + grassenv.GetGRASSVariable('MAPSET')
+ if log:
+ log.WriteLog(_("New vector map <%s> created") % outmap)
+
+ return outmap
+
return None
class SavedRegion(wx.Dialog):
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -193,14 +193,14 @@
"""
if Debug.get_level() == 0:
# don't redirect when debugging is enabled
- sys.stdout = self.cmd_stdout
- sys.stderr = self.cmd_stderr
+ #sys.stdout = self.cmd_stdout
+ #sys.stderr = self.cmd_stderr
return True
return False
- def WriteLog(self, line, style=None, wrap=None):
+ def WriteLog(self, text, style=None, wrap=None):
"""Generic method for writing log message in
given style
@@ -210,21 +210,24 @@
"""
if not style:
style = self.cmd_output.StyleDefault
-
- self.cmd_output.GotoPos(self.cmd_output.GetLength())
- p1 = self.cmd_output.GetCurrentPos()
- # fill space
- if len(line) < self.lineWidth:
- diff = 80 - len(line)
+ # p1 = self.cmd_output.GetCurrentPos()
+ p1 = self.cmd_output.GetEndStyled()
+ self.cmd_output.GotoPos(p1)
+
+ for line in text.split('\n'):
+ # fill space
+ if len(line) < self.lineWidth:
+ diff = 80 - len(line)
line += diff * ' '
-
- self.cmd_output.AddTextWrapped(line, wrap=wrap) # adds os.linesep
-
- p2 = self.cmd_output.GetCurrentPos()
- self.cmd_output.StartStyling(p1, 0xff)
- self.cmd_output.SetStyling(p2 - p1, style)
-
+
+ self.cmd_output.AddTextWrapped(line, wrap=wrap) # adds os.linesep
+
+ p2 = self.cmd_output.GetCurrentPos()
+
+ self.cmd_output.StartStyling(p1, 0xff)
+ self.cmd_output.SetStyling(p2 - p1, style)
+
self.cmd_output.EnsureCaretVisible()
def WriteCmdLog(self, line, pid=None):
@@ -372,14 +375,16 @@
# switch to 'Command output'
if self.parent.notebook.GetSelection() != self.parent.goutput.pageid:
self.parent.notebook.SetSelection(self.parent.goutput.pageid)
-
+
# message prefix
if type == 'warning':
messege = 'WARNING: ' + message
elif type == 'error':
message = 'ERROR: ' + message
-
- p1 = self.cmd_output.GetCurrentPos()
+
+ # p1 = self.cmd_output.GetCurrentPos()
+ p1 = self.cmd_output.GetEndStyled()
+ self.cmd_output.GotoPos(p1)
self.linePos = self.cmd_output.GetCurrentPos()
pc = -1
@@ -409,16 +414,17 @@
self.cmd_output.AddTextWrapped(message, wrap=None)
p2 = self.cmd_output.GetCurrentPos()
+
self.cmd_output.StartStyling(p1, 0xff)
if type == 'error':
- self.cmd_output.SetStyling(p2 - p1 + 1, self.cmd_output.StyleError)
+ self.cmd_output.SetStyling(p2 - p1, self.cmd_output.StyleError)
elif type == 'warning':
- self.cmd_output.SetStyling(p2 - p1 + 1, self.cmd_output.StyleWarning)
+ self.cmd_output.SetStyling(p2 - p1, self.cmd_output.StyleWarning)
elif type == 'message':
- self.cmd_output.SetStyling(p2 - p1 + 1, self.cmd_output.StyleMessage)
+ self.cmd_output.SetStyling(p2 - p1, self.cmd_output.StyleMessage)
else: # unknown
- self.cmd_output.SetStyling(p2 - p1 + 1, self.cmd_output.StyleUnknown)
+ self.cmd_output.SetStyling(p2 - p1, self.cmd_output.StyleUnknown)
if pc > 0:
self.cmd_output.SetCurrentPos(pc)
@@ -435,7 +441,7 @@
def OnCmdRun(self, event):
"""Run command"""
- self.WriteCmdLog('%s' % ' '.join(event.cmd), pid=event.pid)
+ self.WriteCmdLog('(%s)\n%s' % (str(time.ctime()), ' '.join(event.cmd)))
def OnCmdDone(self, event):
"""Command done (or aborted)"""
@@ -443,13 +449,16 @@
# Thread aborted (using our convention of None return)
self.WriteLog(_('Please note that the data are left in incosistent stage '
'and can be corrupted'), self.cmd_output.StyleWarning)
- self.WriteCmdLog(_('Command aborted'),
- pid=self.cmdThread.requestId)
+ self.WriteCmdLog('(%s) %s' % (str(time.ctime()),
+ _('Command aborted')))
+ # pid=self.cmdThread.requestId)
else:
try:
# Process results here
- self.WriteCmdLog(_('Command finished (%d sec)') % (time.time() - event.time),
- pid=event.pid)
+ self.WriteCmdLog('(%s) %s (%d sec)' % (str(time.ctime()),
+ _('Command finished'),
+ (time.time() - event.time)))
+ # pid=event.pid)
except KeyError:
# stopped deamon
pass
@@ -704,6 +713,3 @@
else:
self.parent.linePos = self.GetCurrentPos()
self.AddText(txt)
-
-
-
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -626,7 +626,7 @@
# if len(self.Map.GetListOfLayers()) == 0:
# return False
-
+
if self.img is None:
render = True
@@ -689,8 +689,12 @@
# draw map
self.pdcVector.Clear()
self.pdcVector.RemoveAll()
- item = self.tree.FindItemByData('maplayer', digitToolbar.GetLayer())
- if self.tree.IsItemChecked(item):
+ try:
+ item = self.tree.FindItemByData('maplayer', digitToolbar.GetLayer())
+ except TypeError:
+ item = None
+
+ if item and self.tree.IsItemChecked(item):
self.parent.digit.driver.DrawMap()
#
@@ -1156,7 +1160,9 @@
self.moveIds = []
if digitToolbar.action in ["moveVertex", "editLine"]:
# set pen
- self.pen = self.polypen = wx.Pen(colour=UserSettings.Get(group='vdigit', key="symbolHighlight", subkey='color'),
+ pcolor = UserSettings.Get(group='vdigit', key="symbol",
+ subkey=["highlight", "color"])
+ self.pen = self.polypen = wx.Pen(colour=pcolor,
width=2, style=wx.SHORT_DASH)
self.pdcTmp.SetPen(self.polypen)
@@ -1549,7 +1555,8 @@
# copy features from background map
self.copyIds = digitClass.SelectLinesFromBackgroundMap(pos1, pos2)
if len(self.copyIds) > 0:
- color = UserSettings.Get(group='vdigit', key='symbolHighlight', subkey='color')
+ color = UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['highlight', 'color'])
colorStr = str(color[0]) + ":" + \
str(color[1]) + ":" + \
str(color[2]) + ":"
@@ -2573,7 +2580,9 @@
CloseButton(False).Layer(2))
# vector digitizer
elif name == "vdigit":
- self.toolbars['vdigit'] = toolbars.VDigitToolbar(self, self.Map, self.tree)
+ self.toolbars['vdigit'] = toolbars.VDigitToolbar(parent=self, map=self.Map,
+ layerTree=self.tree,
+ log=self.gismanager.goutput)
for toolRow in range(0, self.toolbars['vdigit'].numOfRows):
self._mgr.AddPane(self.toolbars['vdigit'].toolbar[toolRow],
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -142,9 +142,31 @@
'verbosity' : {
'selection' : 'grassenv'
},
+ # d.rast
'rasterOverlay' : {
'enabled' : False
},
+ # d.vect
+ 'showType': {
+ 'point' : {
+ 'enabled' : True
+ },
+ 'line' : {
+ 'enabled' : True
+ },
+ 'centroid' : {
+ 'enabled' : True
+ },
+ 'boundary' : {
+ 'enabled' : True
+ },
+ 'area' : {
+ 'enabled' : True
+ },
+ 'face' : {
+ 'enabled' : True
+ },
+ },
'addNewLayer' : {
'enabled' : False
},
@@ -165,66 +187,68 @@
#
'vdigit' : {
# symbology
- 'symbolHighlight' : {
- 'enabled' : None,
- 'color' : (255, 255, 0, 255)
- }, # yellow
- 'symbolHighlightDupl' : {
- 'enabled' : None,
- 'color' : (255, 72, 0, 255)
- }, # red
- 'symbolPoint' : {
- 'enabled' : True,
- 'color' : (0, 0, 0, 255)
- }, # black
- 'symbolLine' : {
- 'enabled' : True,
- 'color' : (0, 0, 0, 255)
- }, # black
- 'symbolBoundaryNo' : {
- 'enabled' : True,
- 'color' : (126, 126, 126, 255)
- }, # grey
- 'symbolBoundaryOne' : {
- 'enabled' : True,
- 'color' : (0, 255, 0, 255)
- }, # green
- 'symbolBoundaryTwo' : {
- 'enabled' : True,
- 'color' : (255, 135, 0, 255)
- }, # orange
- 'symbolCentroidIn' : {
- 'enabled' : True,
- 'color' : (0, 0, 255, 255)
- }, # blue
- 'symbolCentroidOut' : {
- 'enabled' : True,
- 'color' : (165, 42, 42, 255)
- }, # brown
- 'symbolCentroidDup' : {
- 'enabled' : True,
- 'color' : (156, 62, 206, 255)
- }, # violet
- 'symbolNodeOne' : {
- 'enabled' : True,
- 'color' : (255, 0, 0, 255)
- }, # red
- 'symbolNodeTwo' : {
- 'enabled' : True,
- 'color' : (0, 86, 45, 255)
- }, # dark green
- 'symbolVertex' : {
- 'enabled' : False,
- 'color' : (255, 20, 147, 255)
- }, # deep pink
- 'symbolArea' : {
- 'enabled' : False,
- 'color' : (217, 255, 217, 255)
- }, # green
- 'symbolDirection' : {
- 'enabled' : False,
- 'color' : (255, 0, 0, 255)
- }, # red
+ 'symbol' : {
+ 'highlight' : {
+ 'enabled' : None,
+ 'color' : (255, 255, 0, 255)
+ }, # yellow
+ 'highlightDupl' : {
+ 'enabled' : None,
+ 'color' : (255, 72, 0, 255)
+ }, # red
+ 'point' : {
+ 'enabled' : True,
+ 'color' : (0, 0, 0, 255)
+ }, # black
+ 'line' : {
+ 'enabled' : True,
+ 'color' : (0, 0, 0, 255)
+ }, # black
+ 'boundaryNo' : {
+ 'enabled' : True,
+ 'color' : (126, 126, 126, 255)
+ }, # grey
+ 'boundaryOne' : {
+ 'enabled' : True,
+ 'color' : (0, 255, 0, 255)
+ }, # green
+ 'boundaryTwo' : {
+ 'enabled' : True,
+ 'color' : (255, 135, 0, 255)
+ }, # orange
+ 'centroidIn' : {
+ 'enabled' : True,
+ 'color' : (0, 0, 255, 255)
+ }, # blue
+ 'centroidOut' : {
+ 'enabled' : True,
+ 'color' : (165, 42, 42, 255)
+ }, # brown
+ 'centroidDup' : {
+ 'enabled' : True,
+ 'color' : (156, 62, 206, 255)
+ }, # violet
+ 'nodeOne' : {
+ 'enabled' : True,
+ 'color' : (255, 0, 0, 255)
+ }, # red
+ 'nodeTwo' : {
+ 'enabled' : True,
+ 'color' : (0, 86, 45, 255)
+ }, # dark green
+ 'vertex' : {
+ 'enabled' : False,
+ 'color' : (255, 20, 147, 255)
+ }, # deep pink
+ 'area' : {
+ 'enabled' : False,
+ 'color' : (217, 255, 217, 255)
+ }, # green
+ 'direction' : {
+ 'enabled' : False,
+ 'color' : (255, 0, 0, 255)
+ }, # red
+ },
# display
'lineWidth' : {
'value' : 2,
@@ -272,18 +296,20 @@
'thresh' : 0
},
# select feature (point, line, centroid, boundary)
- 'selectFeaturePoint' : {
- 'enabled' : True
+ 'selectType': {
+ 'point' : {
+ 'enabled' : True
+ },
+ 'line' : {
+ 'enabled' : True
+ },
+ 'centroid' : {
+ 'enabled' : True
+ },
+ 'boundary' : {
+ 'enabled' : True
+ },
},
- 'selectFeatureLine' : {
- 'enabled' : True
- },
- 'selectFeatureCentroid' : {
- 'enabled' : True
- },
- 'selectFeatureBoundary' : {
- 'enabled' : True
- },
'selectThresh' : {
'value' : 10,
'units' : 'screen pixels'
@@ -613,7 +639,7 @@
'detail' : e })
file.close()
-
+
return filePath
def __parseValue(self, value, read=False):
@@ -676,8 +702,10 @@
return settings[group][key][subkey]
except KeyError:
- raise gcmd.SettingsError("%s %s:%s:%s." % (_("Unable to get value"),
- group, key, subkey))
+ #raise gcmd.SettingsError("%s %s:%s:%s." % (_("Unable to get value"),
+ # group, key, subkey))
+ print >> sys.stderr, "Settings: unable to get value '%s:%s:%s'\n" % \
+ (group, key, subkey)
def Set(self, group, value, key=None, subkey=None, internal=False):
"""Set value of key/subkey
@@ -1013,14 +1041,14 @@
"""Create notebook page for commad dialog settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Command"))
-
+
border = wx.BoxSizer(wx.VERTICAL)
box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Command dialog settings"))
sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
-
+
gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
gridSizer.AddGrowableCol(0)
-
+
#
# command dialog settings
#
@@ -1031,7 +1059,7 @@
name="IsChecked")
overwrite.SetValue(self.settings.Get(group='cmd', key='overwrite', subkey='enabled'))
self.winId['cmd:overwrite:enabled'] = overwrite.GetId()
-
+
gridSizer.Add(item=overwrite,
pos=(row, 0), span=(1, 2))
row += 1
@@ -1041,7 +1069,7 @@
name="IsChecked")
close.SetValue(self.settings.Get(group='cmd', key='closeDlg', subkey='enabled'))
self.winId['cmd:closeDlg:enabled'] = close.GetId()
-
+
gridSizer.Add(item=close,
pos=(row, 0), span=(1, 2))
row += 1
@@ -1051,7 +1079,7 @@
name="IsChecked")
add.SetValue(self.settings.Get(group='cmd', key='addNewLayer', subkey='enabled'))
self.winId['cmd:addNewLayer:enabled'] = add.GetId()
-
+
gridSizer.Add(item=add,
pos=(row, 0), span=(1, 2))
row += 1
@@ -1066,22 +1094,22 @@
name="GetStringSelection")
verbosity.SetStringSelection(self.settings.Get(group='cmd', key='verbosity', subkey='selection'))
self.winId['cmd:verbosity:selection'] = verbosity.GetId()
-
+
gridSizer.Add(item=verbosity,
pos=(row, 1))
-
+
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)
-
+
#
# raster settings
#
box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Raster settings"))
sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
-
+
gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
gridSizer.AddGrowableCol(0)
-
+
#
# raster overlay
#
@@ -1091,13 +1119,33 @@
name='IsChecked')
rasterOverlay.SetValue(self.settings.Get(group='cmd', key='rasterOverlay', subkey='enabled'))
self.winId['cmd:rasterOverlay:enabled'] = rasterOverlay.GetId()
-
+
gridSizer.Add(item=rasterOverlay,
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.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
+
+ #
+ # vector settings
+ #
+ box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Vector settings"))
+ sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+ gridSizer = wx.FlexGridSizer (cols=6, hgap=3, vgap=3)
+
+ for type in ('point', 'line', 'centroid', 'boundary',
+ 'area', 'face'):
+ chkbox = wx.CheckBox(parent=panel, label=type)
+ checked = self.settings.Get(group='cmd', key='showType',
+ subkey=[type, 'enabled'])
+ chkbox.SetValue(checked)
+ self.winId['cmd:showType:%s:enabled' % type] = chkbox.GetId()
+ gridSizer.Add(item=chkbox)
+ sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
+ border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
+
panel.SetSizer(border)
return panel
@@ -1407,7 +1455,12 @@
def __UpdateSettings(self):
"""Update user settings"""
for item in self.winId.keys():
- group, key, subkey = item.split(':')
+ try:
+ group, key, subkey = item.split(':')
+ subkey1 = None
+ except ValueError:
+ group, key, subkey, subkey1 = item.split(':')
+
id = self.winId[item]
win = self.FindWindowById(id)
if win.GetName() == 'GetValue':
@@ -1422,9 +1475,12 @@
value = tuple(win.GetValue())
else:
value = win.GetValue()
-
- self.settings.Set(group, value, key, subkey)
+ if subkey1:
+ self.settings.Set(group, value, key, [subkey, subkey1])
+ else:
+ self.settings.Set(group, value, key, subkey)
+
#
# update default window dimension
#
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -353,11 +353,12 @@
Toolbar for digitization
"""
- def __init__(self, parent, map, layerTree=None):
+ def __init__(self, parent, map, layerTree=None, log=None):
self.mapcontent = map # Map class instance
self.parent = parent # MapFrame
self.layerTree = layerTree # reference to layer tree associated to map display
-
+ self.log = log # log area
+
# currently selected map layer for editing (reference to MapLayer instance)
self.mapLayer = None
# list of vector layers from Layer Manager (only in the current mapset)
@@ -769,7 +770,8 @@
else:
openVectorMap = None
mapName = gdialogs.CreateNewVector(self.parent,
- exceptMap=openVectorMap)
+ exceptMap=openVectorMap, log=self.log,
+ cmdDef=(['v.edit', 'tool=create'], "map"))
if mapName:
# add layer to map layer tree
if self.layerTree:
Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -191,11 +191,12 @@
Used by SelectLinesByBox() and SelectLinesByPoint()"""
type = 0
- for feature in (('Point', wxvdigit.GV_POINT),
- ('Line', wxvdigit.GV_LINE),
- ('Centroid', wxvdigit.GV_CENTROID),
- ('Boundary', wxvdigit.GV_BOUNDARY)):
- if UserSettings.Get(group='vdigit', key='selectFeature'+feature[0], subkey='enabled') is True:
+ for feature in (('point', wxvdigit.GV_POINT),
+ ('line', wxvdigit.GV_LINE),
+ ('centroid', wxvdigit.GV_CENTROID),
+ ('boundary', wxvdigit.GV_BOUNDARY)):
+ if UserSettings.Get(group='vdigit', key='selectType',
+ subkey=[feature[0], 'enabled']) is True:
type |= feature[1]
return type
@@ -1521,81 +1522,75 @@
if not self.__display:
return
- self.__display.UpdateSettings (wx.Color(UserSettings.Get(group='vdigit', key='symbolHighlight', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolHighlight', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolHighlight', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='checkForDupl', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolHighlightDupl', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolHighlightDupl', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolHighlightDupl', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolPoint', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolPoint', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolPoint', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolPoint', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolLine', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolLine', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolLine', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolLine', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolBoundaryNo', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolBoundaryNo', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolBoundaryNo', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolBoundaryNo', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolBoundaryOne', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolBoundaryOne', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolBoundaryOne', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolBoundaryOne', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolBoundaryTwo', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolBoundaryTwo', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolBoundaryTwo', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolBoundaryTwo', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolCentroidIn', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolCentroidIn', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolCentroidIn', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolCentroidIn', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolCentroidOut', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolCentroidOut', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolCentroidOut', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolCentroidOut', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolCentroidDup', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolCentroidDup', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolCentroidDup', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolCentroidDup', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolNodeOne', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolNodeOne', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolNodeOne', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolNodeOne', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolNodeTwo', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolNodeTwo', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolNodeTwo', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolNodeTwo', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolVertex', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolVertex', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolVertex', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolVertex', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolArea', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolArea', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolArea', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolArea', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='symbolDirection', subkey='enabled'),
- wx.Color(UserSettings.Get(group='vdigit', key='symbolDirection', subkey='color')[0],
- UserSettings.Get(group='vdigit', key='symbolDirection', subkey='color')[1],
- UserSettings.Get(group='vdigit', key='symbolDirection', subkey='color')[2],
- 255).GetRGB(),
- UserSettings.Get(group='vdigit', key='lineWidth', subkey='value'))
+ color = {}
+ for symbol in ("highlight",
+ "highlightDupl",
+ "point",
+ "line",
+ "boundaryNo",
+ "boundaryOne",
+ "boundaryTwo",
+ "centroidIn",
+ "centroidOut",
+ "centroidDup",
+ "nodeOne",
+ "nodeTwo",
+ "vertex",
+ "area",
+ "direction"):
+ color[symbol] = wx.Color(UserSettings.Get(group='vdigit', key='symbol',
+ subkey=[symbol, 'color'])[0],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=[symbol, 'color'])[1],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=[symbol, 'color'])[2],
+ 255).GetRGB()
+
+ self.__display.UpdateSettings (color['highlight'],
+ UserSettings.Get(group='vdigit', key='checkForDupl',
+ subkey='enabled'),
+ color['highlightDupl'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['point', 'enabled']),
+ color['point'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['line', 'enabled']),
+ color['line'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['boundaryNo', 'enabled']),
+ color['boundaryNo'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['boundaryOne', 'enabled']),
+ color['boundaryOne'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['boundaryTwo', 'enabled']),
+ color['boundaryTwo'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['centroidIn', 'enabled']),
+ color['centroidIn'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['centroidOut', 'enabled']),
+ color['centroidOut'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['centroidDup', 'enabled']),
+ color['centroidDup'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['nodeOne', 'enabled']),
+ color['nodeOne'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['nodeTwo', 'enabled']),
+ color['nodeTwo'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['vertex', 'enabled']),
+ color['vertex'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['area', 'enabled']),
+ color['area'],
+ UserSettings.Get(group='vdigit', key='symbol',
+ subkey=['direction', 'enabled']),
+ color['direction'],
+ UserSettings.Get(group='vdigit', key='lineWidth',
+ subkey='value'))
class VDigitSettingsDialog(wx.Dialog):
"""
@@ -1661,8 +1656,10 @@
for label, key in self.__SymbologyData():
textLabel = wx.StaticText(panel, wx.ID_ANY, label)
color = csel.ColourSelect(panel, id=wx.ID_ANY,
- colour=UserSettings.Get(group='vdigit', key=key, subkey='color'), size=(25, 25))
- isEnabled = UserSettings.Get(group='vdigit', key=key, subkey='enabled')
+ colour=UserSettings.Get(group='vdigit', key='symbol',
+ subkey=[key, 'color']), size=(25, 25))
+ isEnabled = UserSettings.Get(group='vdigit', key='symbol',
+ subkey=[key, 'enabled'])
if isEnabled is not None:
enabled = wx.CheckBox(panel, id=wx.ID_ANY, label="")
enabled.SetValue(isEnabled)
@@ -1782,11 +1779,12 @@
sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
inSizer = wx.BoxSizer(wx.HORIZONTAL)
self.selectFeature = {}
- for feature in ('Point', 'Line',
- 'Centroid', 'Boundary'):
+ for feature in ('point', 'line',
+ 'centroid', 'boundary'):
chkbox = wx.CheckBox(parent=panel, label=feature)
self.selectFeature[feature] = chkbox.GetId()
- chkbox.SetValue(UserSettings.Get(group='vdigit', key='selectFeature'+feature, subkey='enabled'))
+ chkbox.SetValue(UserSettings.Get(group='vdigit', key='selectType',
+ subkey=[feature, 'enabled']))
inSizer.Add(item=chkbox, proportion=0,
flag=wx.EXPAND | wx.ALL, border=5)
sizer.Add(item=inSizer, proportion=0, flag=wx.EXPAND)
@@ -2025,21 +2023,21 @@
return (
# ("Background", "symbolBackground"),
- (_("Highlight"), "symbolHighlight"),
- (_("Highlight (duplicates)"), "symbolHighlightDupl"),
- (_("Point"), "symbolPoint"),
- (_("Line"), "symbolLine"),
- (_("Boundary (no area)"), "symbolBoundaryNo"),
- (_("Boundary (one area)"), "symbolBoundaryOne"),
- (_("Boundary (two areas)"), "symbolBoundaryTwo"),
- (_("Centroid (in area)"), "symbolCentroidIn"),
- (_("Centroid (outside area)"), "symbolCentroidOut"),
- (_("Centroid (duplicate in area)"), "symbolCentroidDup"),
- (_("Node (one line)"), "symbolNodeOne"),
- (_("Node (two lines)"), "symbolNodeTwo"),
- (_("Vertex"), "symbolVertex"),
- (_("Area (closed boundary + centroid)"), "symbolArea"),
- (_("Direction"), "symbolDirection"),)
+ (_("Highlight"), "highlight"),
+ (_("Highlight (duplicates)"), "highlightDupl"),
+ (_("Point"), "point"),
+ (_("Line"), "line"),
+ (_("Boundary (no area)"), "boundaryNo"),
+ (_("Boundary (one area)"), "boundaryOne"),
+ (_("Boundary (two areas)"), "boundaryTwo"),
+ (_("Centroid (in area)"), "centroidIn"),
+ (_("Centroid (outside area)"), "centroidOut"),
+ (_("Centroid (duplicate in area)"), "centroidDup"),
+ (_("Node (one line)"), "nodeOne"),
+ (_("Node (two lines)"), "nodeTwo"),
+ (_("Vertex"), "vertex"),
+ (_("Area (closed boundary + centroid)"), "area"),
+ (_("Direction"), "direction"),)
def OnChangeCategoryMode(self, event):
"""Change category mode"""
@@ -2132,11 +2130,14 @@
fileSettings = {}
UserSettings.ReadSettingsFile(settings=fileSettings)
fileSettings['vdigit'] = UserSettings.Get(group='vdigit')
+
file = UserSettings.SaveToFile(fileSettings)
self.parent.gismanager.goutput.WriteLog(_('Vector digitizer settings saved to file <%s>.') % file)
+
+ self.Destroy()
- self.Close()
-
+ event.Skip()
+
def OnApply(self, event):
"""Button 'Apply' clicked"""
self.UpdateSettings()
@@ -2144,7 +2145,7 @@
def OnCancel(self, event):
"""Button 'Cancel' clicked"""
self.parent.toolbars['vdigit'].settingsDialog = None
- self.Close()
+ self.Destroy()
if event:
event.Skip()
@@ -2155,12 +2156,15 @@
# symbology
for key, (enabled, color) in self.symbology.iteritems():
if enabled:
- UserSettings.Set(group='vdigit', key=key, subkey='enabled',
+ UserSettings.Set(group='vdigit', key='symbol',
+ subkey=[key, 'enabled'],
value=enabled.IsChecked())
- UserSettings.Set(group='vdigit', key=key, subkey='color',
+ UserSettings.Set(group='vdigit', key='symbol',
+ subkey=[key, 'color'],
value=tuple(color.GetColour()))
else:
- UserSettings.Set(group='vdigit', key=key, subkey='color',
+ UserSettings.Set(group='vdigit', key='symbol',
+ subkey=[key, 'color'],
value=tuple(color.GetColour()))
# display
UserSettings.Set(group='vdigit', key="lineWidth", subkey='value',
@@ -2210,10 +2214,11 @@
value=int(self.queryDangleValue.GetValue()))
# select features
- for feature in ('Point', 'Line',
- 'Centroid', 'Boundary'):
- UserSettings.Set(group='vdigit', key='selectFeature'+feature, subkey='enabled',
- value=self.FindWindowById(self.selectFeature[feature]).IsChecked())
+ for feature in ('point', 'line',
+ 'centroid', 'boundary'):
+ UserSettings.Set(group='vdigit', key='selectType',
+ subkey=[feature, 'enabled'],
+ value=self.FindWindowById(self.selectFeature[feature]).IsChecked())
UserSettings.Set(group='vdigit', key="selectThresh", subkey='value',
value=int(self.selectThreshValue.GetValue()))
UserSettings.Set(group='vdigit', key="checkForDupl", subkey='enabled',
Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -742,8 +742,15 @@
menuform.GUI().ParseCommand(['d.rast.num'], completed=(self.GetOptData,layer,params),
parentframe=self)
elif ltype == 'vector':
- menuform.GUI().ParseCommand(['d.vect'], completed=(self.GetOptData,layer,params),
- parentframe=self)
+ types = ''
+ for type in UserSettings.Get(group='cmd', key='showType').keys():
+ if UserSettings.Get(group='cmd', key='showType', subkey=[type, 'enabled']):
+ types += type + ','
+ types = types.rstrip(',')
+
+ menuform.GUI().ParseCommand(['d.vect', 'type=%s' % types],
+ completed=(self.GetOptData,layer,params),
+ parentframe=self)
elif ltype == 'thememap':
# -s flag requested, otherwise only first thematic category is displayed
# should be fixed by C-based d.thematic.* modules
Modified: grass/trunk/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.cpp 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/vdigit/driver.cpp 2008-08-08 23:10:20 UTC (rev 32649)
@@ -377,9 +377,9 @@
}
dc->SetId(dcId); /* 0 | 1 (selected) */
- dc->SetPen(*pen);
-
+
if (draw) {
+ dc->SetPen(*pen);
if (type & GV_POINTS) {
DrawCross(line, (const wxPoint *) pointsScreen->GetFirst()->GetData());
}
@@ -821,13 +821,13 @@
int lineWidth)
{
settings.highlight.Set(highlight);
-
+
settings.highlightDupl.enabled = ehighlightDupl;
settings.highlightDupl.color.Set(chighlightDupl);
settings.point.enabled = ePoint;
settings.point.color.Set(cPoint);
-
+
settings.line.enabled = eLine;
settings.line.color.Set(cLine);
@@ -865,7 +865,7 @@
settings.direction.color.Set(cDirection);
settings.lineWidth = lineWidth;
-
+
return;
}
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2008-08-08 23:02:24 UTC (rev 32648)
+++ grass/trunk/gui/wxpython/wxgui.py 2008-08-08 23:10:20 UTC (rev 32649)
@@ -456,9 +456,8 @@
def OnNewVector(self, event):
"""Create new vector map layer"""
- name = gdialogs.CreateNewVector(self)
- if name:
- self.goutput.WriteCmdLog('New vector map <%s> created' % name)
+ name = gdialogs.CreateNewVector(self, log=self.goutput,
+ cmdDef=(['v.edit', 'tool=create'], "map"))
def OnAboutGRASS(self, event):
"""Display 'About GRASS' dialog"""
@@ -1101,7 +1100,7 @@
title="%s - <%s>" % (_("GRASS GIS Attribute Table Manager"),
mapname),
size=wx.Size(500,300), vectmap=mapname,
- pointdata=pointdata)
+ pointdata=pointdata, log=self.goutput)
busy.Destroy()
More information about the grass-commit
mailing list