[GRASS-SVN] r30783 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 28 16:43:21 EDT 2008
Author: martinl
Date: 2008-03-28 16:43:21 -0400 (Fri, 28 Mar 2008)
New Revision: 30783
Modified:
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
Log:
wxGUI: measuring log output fixed (use WriteLog() instead of AddText())
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-03-28 20:18:47 UTC (rev 30782)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-03-28 20:43:21 UTC (rev 30783)
@@ -98,22 +98,38 @@
self.SetAutoLayout(True)
self.SetSizer(boxsizer1)
- def WriteCmdLog(self, line, pid=None):
- """Write out line in selected style"""
+ def WriteLog(self, line, style=None):
+ """Generic method for writing log message in
+ given style
+
+ @param line text line
+ @param style text style (see GMStc)
+ @param stdout write to stdout or stderr
+ """
+ if not style:
+ style = self.cmd_output.StyleDefault
+
self.cmd_output.GotoPos(self.cmd_output.GetEndStyled())
p1 = self.cmd_output.GetCurrentPos()
- if pid:
- line = '(' + str(pid) + ') ' + line
+
# fill space
if len(line) < self.lineWidth:
diff = 80 - len(line)
line += diff * ' '
+
self.cmd_output.AddText(line + '%s' % os.linesep)
self.cmd_output.EnsureCaretVisible()
p2 = self.cmd_output.GetCurrentPos()
self.cmd_output.StartStyling(p1, 0xff)
- self.cmd_output.SetStyling(p2 - p1, self.cmd_output.StyleCommand)
-
+ self.cmd_output.SetStyling(p2 - p1, style)
+
+ def WriteCmdLog(self, line, pid=None):
+ """Write out line in selected style"""
+ if pid:
+ line = '(' + str(pid) + ') ' + line
+
+ self.WriteLog(line, self.cmd_output.StyleCommand)
+
def RunCmd(self, command):
"""
Run in GUI GRASS (or other) commands typed into
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-03-28 20:18:47 UTC (rev 30782)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-03-28 20:43:21 UTC (rev 30783)
@@ -452,8 +452,7 @@
# Make new off screen bitmap: this bitmap will always have the
# current drawing in it, so it can be used to save the image to
# a file, or whatever.
- self.buffer = wx.EmptyBitmap(max(1, self.Map.width), max(1,self.Map.height))
- #self.buffer = wx.EmptyBitmap(mwidth, mheight)
+ self.buffer = wx.EmptyBitmap(max(1, self.Map.width), max(1, self.Map.height))
# get the image to be rendered
self.img = self.GetImage()
@@ -461,7 +460,8 @@
# update map display
if self.img and self.Map.width + self.Map.height > 0: # scale image during resize
self.img = self.img.Scale(self.Map.width, self.Map.height)
- self.UpdateMap()
+ if len(self.Map.GetListOfLayers()) > 0:
+ self.UpdateMap()
# re-render image on idle
self.resize = True
@@ -474,10 +474,9 @@
def OnIdle(self, event):
"""
- Only re-render a compsite map image from GRASS during
+ Only re-render a composite map image from GRASS during
idle time instead of multiple times during resizing.
"""
-
if self.resize:
self.UpdateMap(render=True)
@@ -537,6 +536,11 @@
start = time.clock()
+ self.resize = False
+
+ if len(self.Map.GetListOfLayers()) == 0:
+ return False
+
if self.img is None:
render = True
@@ -557,7 +561,6 @@
self.Map.ChangeMapSize(self.GetClientSize())
self.mapfile = self.Map.Render(force=True, mapWindow=self.parent)
self.img = self.GetImage() # id=99
- self.resize = False
#
# clear pseudoDcs
@@ -613,8 +616,6 @@
self.Draw(self.pdc, img=self.textdict[id], drawid=id,
pdctype='text', coords=self.ovlcoords[id])
- self.resize = False
-
#
# render region border (to self.pdcTmp)
#
@@ -2445,7 +2446,7 @@
def OnDraw(self, event):
"""
- Redraw button clicked
+ Re-display current map composition
"""
self.MapWindow.UpdateMap(render=False)
@@ -2455,9 +2456,9 @@
def OnRender(self, event):
"""
- Rerender button clicked
+ Re-render map composition (each map layer)
"""
- # redraw map composition
+ # detele tmp map layers (queries)
qlayer = self.Map.GetListOfLayers(l_name=globalvar.QUERYLAYER)
for layer in qlayer:
self.Map.DeleteLayer(layer)
@@ -3044,21 +3045,20 @@
# initiating output
style = self.gismanager.goutput.cmd_output.StyleWarning
- self.gismanager.goutput.cmd_output.write('Click and drag with left mouse button '
- 'to measure.%s'
- 'Double click with left button to clear.%s' % \
- (os.linesep, os.linesep), style)
+ self.gismanager.goutput.WriteLog(_('Click and drag with left mouse button '
+ 'to measure.%s'
+ 'Double click with left button to clear.%s') % \
+ (os.linesep, os.linesep), style)
if self.projinfo['proj'] != 'xy':
units = self.projinfo['units']
style = self.gismanager.goutput.cmd_output.StyleCommand
- self.gismanager.goutput.cmd_output.write('Measuring distance ('
- + units + '):%s' % os.linesep,
- style)
+ self.gismanager.goutput.WriteLog(_('Measuring distance ('
+ + units + '):'),
+ style)
else:
- self.gismanager.goutput.cmd_output.write('Measuring distance:%s' % os.linesep,
- style)
+ self.gismanager.goutput.WriteLog(_('Measuring distance:'),
+ style)
-
def MeasureDist(self, beginpt, endpt):
"""
Calculate map distance from screen distance
@@ -3084,13 +3084,13 @@
angle = angle+90
if angle < 0: angle = 360+angle
- mstring = 'segment = %s %s\ttotal distance = %s %s\tbearing = %d deg\n' \
+ mstring = 'segment = %s %s\ttotal distance = %s %s\tbearing = %d deg' \
% (strdist,dunits,strtotdist,tdunits,angle)
else:
- mstring = 'segment = %s %s\ttotal distance = %s %s\n' \
+ mstring = 'segment = %s %s\ttotal distance = %s %s' \
% (strdist,dunits,strtotdist,tdunits)
- self.gismanager.goutput.cmd_output.AddText(mstring)
+ self.gismanager.goutput.WriteLog(mstring)
return dist
More information about the grass-commit
mailing list