[GRASS-SVN] r45831 - grass-addons/gui/wxpython/wx.psmap/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Apr 3 06:09:55 EDT 2011
Author: annakrat
Date: 2011-04-03 03:09:55 -0700 (Sun, 03 Apr 2011)
New Revision: 45831
Modified:
grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap.py
grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap_dialogs.py
Log:
wxGUI/psmap: set max resolution
Modified: grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap.py
===================================================================
--- grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap.py 2011-04-03 07:53:36 UTC (rev 45830)
+++ grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap.py 2011-04-03 10:09:55 UTC (rev 45831)
@@ -841,10 +841,16 @@
resol = grass.parse_key_val(resol, val_type = float)
RunCommand('g.region', nsres = resol['nsres'], ewres = resol['ewres'])
# change current raster in raster legend
+
if 'rasterLegend' in self.openDialogs:
self.openDialogs['rasterLegend'].updateDialog()
id = self.instruction.FindInstructionByType('map').id
-
+
+ #check resolution
+ if itype == 'raster':
+ SetResolution(dpi = self.instruction[id]['resolution'],
+ width = self.instruction[id]['rect'].width,
+ height = self.instruction[id]['rect'].height)
rectCanvas = self.canvas.CanvasPaperCoordinates(rect = self.instruction[id]['rect'],
canvasToPaper = False)
self.canvas.RecalculateEN()
@@ -1235,20 +1241,13 @@
self.Refresh()
return
rectPaper = self.CanvasPaperCoordinates(rect = rectTmp, canvasToPaper = True)
-##
-## dlg = MapDialog(parent = self.parent, id = [None, None, None], settings = self.instruction,
-## rect = rectPaper)
-## dlg.ShowModal()
dlg = MapDialog(parent = self.parent, id = [None, None, None], settings = self.instruction,
rect = rectPaper)
self.openDialogs['map'] = dlg
self.openDialogs['map'].Show()
-## if self.instruction.FindInstructionByType('map'):
-## #redraw objects to lower map to the bottom
-
self.mouse['use'] = self.parent.mouseOld
self.SetCursor(self.parent.cursorOld)
@@ -1256,8 +1255,6 @@
self.parent.toolbar.ToggleTool(self.parent.toolbar.action['id'], False)
self.parent.toolbar.action['id'] = self.parent.actionOld
-## self.pdcTmp.RemoveId(self.idZoomBoxTmp)
-## self.Refresh()
# resize resizable objects (only map sofar)
@@ -1294,6 +1291,10 @@
elif self.instruction[mapId]['scaleType'] == 3:
ComputeSetRegion(self, mapDict = self.instruction[mapId].GetInstruction())
+ #check resolution
+ SetResolution(dpi = self.instruction[mapId]['resolution'],
+ width = self.instruction[mapId]['rect'].width,
+ height = self.instruction[mapId]['rect'].height)
self.RedrawSelectBox(mapId)
self.Zoom(zoomFactor = 1, view = (0, 0))
Modified: grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap_dialogs.py
===================================================================
--- grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap_dialogs.py 2011-04-03 07:53:36 UTC (rev 45830)
+++ grass-addons/gui/wxpython/wx.psmap/gui_modules/psmap_dialogs.py 2011-04-03 10:09:55 UTC (rev 45831)
@@ -309,6 +309,8 @@
w = units.convert(value = mapRect.Get()[2], fromUnit = 'inch', toUnit = 'meter') / toM
map['scale'] = w / abs((region['w'] - region['e']))
+ SetResolution(dpi = 300, width = map['rect'].width, height = map['rect'].height)
+
# read file again, now with information about map bounds
isBuffer = False
buffer = []
@@ -626,7 +628,7 @@
# default values
self.defaultInstruction = dict( map = None, mapType = None, drawMap = True, region = None,
rect = wx.Rect2D(), scaleType = 0, scale = None, center = None,
- border = 'y', width = 1, color = '0:0:0')
+ resolution = 300, border = 'y', width = 1, color = '0:0:0')
# current values
self.instruction = dict(self.defaultInstruction)
@@ -2020,6 +2022,19 @@
sizerC.Add(self.centerSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
gridBagSizer.Add(sizerC, pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
+
+ #resolution
+ flexSizer = wx.FlexGridSizer(rows = 1, cols = 2, hgap = 5, vgap = 5)
+
+ resolutionText = wx.StaticText(self, id = wx.ID_ANY, label = _("Map max resolution (dpi):"))
+ self.resolutionSpin = wx.SpinCtrl(self, id = wx.ID_ANY, min = 1, max = 1000, initial = 300)
+
+ flexSizer.Add(resolutionText, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
+ flexSizer.Add(self.resolutionSpin, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
+ self.resolutionSpin.SetValue(self.mapFrameDict['resolution'])
+
+ gridBagSizer.Add(flexSizer, pos = (4, 0), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
+
sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
@@ -2185,7 +2200,8 @@
def update(self):
"""!Save changes"""
mapFrameDict = dict(self.mapFrameDict)
-
+ # resolution
+ mapFrameDict['resolution'] = self.resolutionSpin.GetValue()
#scale
scaleType = self.scaleType
mapFrameDict['scaleType'] = scaleType
@@ -2258,6 +2274,9 @@
RunCommand('g.region', vect = mapFrameDict['map'], rast = self.instruction[rasterId]['raster'])
else:
RunCommand('g.region', vect = mapFrameDict['map'])
+
+
+
else:
wx.MessageBox(message = _("No map selected!"),
caption = _('Invalid input'), style = wx.OK|wx.ICON_ERROR)
@@ -2327,6 +2346,9 @@
ComputeSetRegion(self, mapDict = mapFrameDict)
+ # check resolution
+ SetResolution(dpi = mapFrameDict['resolution'], width = mapFrameDict['rect'].width,
+ height = mapFrameDict['rect'].height)
# border
mapFrameDict['border'] = 'y' if self.borderCheck.GetValue() else 'n'
if mapFrameDict['border'] == 'y':
@@ -5260,6 +5282,20 @@
cN = (currRegionDict['n'] + currRegionDict['s'])/2
return scale, (cE, cN), wx.Rect2D(x, y, rWNew, rHNew) #inch
+def SetResolution(dpi, width, height):
+ """!If resolution is too high, lower it
+
+ @param dpi max DPI
+ @param width map frame width
+ @param height map frame height
+ """
+ region = grass.region()
+ if region['cols'] > width * dpi or region['rows'] > height * dpi:
+ rows = height * dpi
+ cols = width * dpi
+ RunCommand('g.region', rows = rows, cols = cols)
+
+
def ComputeSetRegion(self, mapDict):
"""!Computes and sets region from current scale, map center coordinates and map rectangle"""
More information about the grass-commit
mailing list