[GRASS-SVN] r70178 - in grass/branches/releasebranch_7_2/gui/wxpython: . location_wizard
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Dec 31 13:59:38 PST 2016
Author: martinl
Date: 2016-12-31 13:59:38 -0800 (Sat, 31 Dec 2016)
New Revision: 70178
Modified:
grass/branches/releasebranch_7_2/gui/wxpython/gis_set.py
grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/base.py
grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/dialogs.py
grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/wizard.py
Log:
wxGUI/location wizard simplification: decrease number of dialogs shown by default
(merge r69985 from trunk)
Modified: grass/branches/releasebranch_7_2/gui/wxpython/gis_set.py
===================================================================
--- grass/branches/releasebranch_7_2/gui/wxpython/gis_set.py 2016-12-30 20:56:29 UTC (rev 70177)
+++ grass/branches/releasebranch_7_2/gui/wxpython/gis_set.py 2016-12-31 21:59:38 UTC (rev 70178)
@@ -546,46 +546,31 @@
dlg.CenterOnScreen()
if dlg.ShowModal() == wx.ID_YES:
self.ImportFile(gWizard.georeffile)
- else:
- self.SetDefaultRegion(location=gWizard.location)
dlg.Destroy()
- else:
- self.SetDefaultRegion(location=gWizard.location)
+ if gWizard.default_region:
+ defineRegion = RegionDef(self, location=gWizard.location)
+ defineRegion.CenterOnScreen()
+ defineRegion.ShowModal()
+ defineRegion.Destroy()
- dlg = TextEntryDialog(
- parent=self,
- message=_("Do you want to create new mapset?"),
- caption=_("Create new mapset"),
- defaultValue=self._getDefaultMapsetName(),
- validator=GenericValidator(
- grass.legal_name,
- self._nameValidationFailed),
- style=wx.OK | wx.CANCEL | wx.HELP)
- help = dlg.FindWindowById(wx.ID_HELP)
- help.Bind(wx.EVT_BUTTON, self.OnHelp)
- if dlg.ShowModal() == wx.ID_OK:
- mapsetName = dlg.GetValue()
- self.CreateNewMapset(mapsetName)
+ if gWizard.user_mapset:
+ dlg = TextEntryDialog(
+ parent=self,
+ message=_("New mapset:"),
+ caption=_("Create new mapset"),
+ defaultValue=self._getDefaultMapsetName(),
+ validator=GenericValidator(
+ grass.legal_name,
+ self._nameValidationFailed
+ ),
+ style=wx.OK | wx.CANCEL | wx.HELP
+ )
+ help = dlg.FindWindowById(wx.ID_HELP)
+ help.Bind(wx.EVT_BUTTON, self.OnHelp)
+ if dlg.ShowModal() == wx.ID_OK:
+ mapsetName = dlg.GetValue()
+ self.CreateNewMapset(mapsetName)
- def SetDefaultRegion(self, location):
- """Asks to set default region."""
- caption = _("Location <%s> created") % location
- message = _("Do you want to set the default "
- "region extents and resolution now?")
- dlg = wx.MessageDialog(
- parent=self, message="%(caption)s.\n\n%(extent)s" %
- ({'caption': caption, 'extent': message}),
- caption=caption, style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
- dlg.CenterOnScreen()
- if dlg.ShowModal() == wx.ID_YES:
- dlg.Destroy()
- defineRegion = RegionDef(self, location=location)
- defineRegion.CenterOnScreen()
- defineRegion.ShowModal()
- defineRegion.Destroy()
- else:
- dlg.Destroy()
-
def ImportFile(self, filePath):
"""Tries to import file as vector or raster.
Modified: grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/base.py
===================================================================
--- grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/base.py 2016-12-30 20:56:29 UTC (rev 70177)
+++ grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/base.py 2016-12-31 21:59:38 UTC (rev 70178)
@@ -36,9 +36,8 @@
label.SetToolTipString(tooltip)
return label
- def MakeTextCtrl(
- self, text='', size=(100, -1),
- style=0, parent=None, tooltip=None):
+ def MakeTextCtrl(self, text='', size=(100, -1),
+ style=0, parent=None, tooltip=None):
"""Generic text control"""
if not parent:
parent = self
@@ -48,9 +47,8 @@
textCtrl.SetToolTipString(tooltip)
return textCtrl
- def MakeButton(
- self, text, id=wx.ID_ANY, size=(-1, -1),
- parent=None, tooltip=None):
+ def MakeButton(self, text, id=wx.ID_ANY, size=(-1, -1),
+ parent=None, tooltip=None):
"""Generic button"""
if not parent:
parent = self
@@ -59,3 +57,14 @@
if tooltip:
button.SetToolTipString(tooltip)
return button
+
+ def MakeCheckBox(self, text, id=wx.ID_ANY, size=(-1, -1),
+ parent=None, tooltip=None):
+ """Generic checkbox"""
+ if not parent:
+ parent = self
+ chbox = wx.CheckBox(parent=parent, id=id, label=text,
+ size=size)
+ if tooltip:
+ chbox.SetToolTipString(tooltip)
+ return chbox
Modified: grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/dialogs.py
===================================================================
--- grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/dialogs.py 2016-12-30 20:56:29 UTC (rev 70177)
+++ grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/dialogs.py 2016-12-31 21:59:38 UTC (rev 70178)
@@ -506,11 +506,20 @@
def __UpdateInfo(self):
"""Update number of rows/cols/cells"""
- self.rows = int((self.north - self.south) / self.nsres)
- self.cols = int((self.east - self.west) / self.ewres)
+ try:
+ rows = int((self.north - self.south) / self.nsres)
+ cols = int((self.east - self.west) / self.ewres)
+ except ZeroDivisionError:
+ return
+ self.rows = rows
+ self.cols = cols
self.cells = self.rows * self.cols
- self.depth = int((self.top - self.bottom) / self.tbres)
+ try:
+ depth = int((self.top - self.bottom) / self.tbres)
+ except ZeroDivisionError:
+ return
+ self.depth = depth
self.cells3 = self.rows * self.cols * self.depth
# 2D
@@ -524,7 +533,7 @@
def OnSetButton(self, event=None):
"""Set default region"""
ret = RunCommand('g.region',
- flags='sgpa',
+ flags='sa',
n=self.north,
s=self.south,
e=self.east,
Modified: grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/wizard.py
===================================================================
--- grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/wizard.py 2016-12-30 20:56:29 UTC (rev 70177)
+++ grass/branches/releasebranch_7_2/gui/wxpython/location_wizard/wizard.py 2016-12-31 21:59:38 UTC (rev 70178)
@@ -22,7 +22,7 @@
- wizard::LocationWizard
- wizard::WizardWithHelpButton
-(C) 2007-2013 by the GRASS Development Team
+(C) 2007-2016 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.
@@ -122,6 +122,20 @@
self._nameValidationFailed))
self.tlocTitle = self.MakeTextCtrl(size=(400, -1))
+ # checkbox
+ self.tlocRegion = self.MakeCheckBox(_("Set default region extent and resolution"),
+ tooltip=_("This option allows setting default "
+ "computation region immediately after "
+ "new location is created. Default "
+ "computation region can be defined later "
+ "using g.region based on imported data."))
+
+ self.tlocUserMapset = self.MakeCheckBox(_("Create user mapset"),
+ tooltip=_("This option allows creating user "
+ "mapset immediately after new location "
+ "is created. Note that GRASS always creates "
+ "PERMANENT mapset."))
+
# layout
self.sizer.Add(item=self.MakeLabel(_("GIS Data Directory:")),
flag=wx.ALIGN_RIGHT |
@@ -146,9 +160,8 @@
tooltip=_("Name of location directory in GIS Data Directory")),
flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
border=5,
- pos=(
- 2,
- 1))
+ pos=(2, 1)
+ )
self.sizer.Add(item=self.tlocation,
flag=wx.ALIGN_LEFT |
wx.ALIGN_CENTER_VERTICAL |
@@ -164,14 +177,23 @@
"you can leave this field blank.")),
flag=wx.ALIGN_RIGHT | wx.ALIGN_TOP | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
border=5,
- pos=(
- 3,
- 1))
+ pos=(3, 1)
+ )
self.sizer.Add(item=self.tlocTitle,
flag=wx.ALIGN_LEFT |
wx.ALIGN_CENTER_VERTICAL |
wx.ALL, border=5,
pos=(3, 2), span=(1, 2))
+ self.sizer.Add(item=self.tlocRegion,
+ flag=wx.ALIGN_LEFT |
+ wx.ALIGN_CENTER_VERTICAL |
+ wx.ALL, border=5,
+ pos=(4, 2), span=(1, 2))
+ self.sizer.Add(item=self.tlocUserMapset,
+ flag=wx.ALIGN_LEFT |
+ wx.ALIGN_CENTER_VERTICAL |
+ wx.ALL, border=5,
+ pos=(5, 2), span=(1, 2))
self.sizer.AddGrowableCol(3)
# bindings
@@ -2233,6 +2255,10 @@
# file from which new location is created
self.georeffile = None
+ # additional settings
+ self.default_region = False
+ self.user_mapset = False
+
#
# define wizard pages
#
@@ -2330,6 +2356,8 @@
self.location = self.startpage.location
self.grassdatabase = self.startpage.grassdatabase
self.georeffile = self.filepage.georeffile
+ self.default_region = self.startpage.tlocRegion.IsChecked()
+ self.user_mapset = self.startpage.tlocUserMapset.IsChecked()
# FIXME here was code for setting default region, what for is this if:
# if self.altdb == False:
More information about the grass-commit
mailing list