From barton at grass.itc.it Sun Apr 1 17:44:07 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sun Apr 1 17:44:09 2007
Subject: [grass-addons] r391 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704011544.l31Fi7L6023316@grass.itc.it>
Author: barton
Date: 2007-04-01 17:43:58 +0200 (Sun, 01 Apr 2007)
New Revision: 391
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Major update of display system. Using to buffered PseudoDC for better
manipulation of canvas images and to implement placeable map decorations
like scales and legends. Once tested, I'll clean up commented code.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-03-30 22:46:57 UTC (rev 390)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-01 15:43:58 UTC (rev 391)
@@ -51,10 +51,6 @@
# for cmdlinef
cmdfilename = None
-ovlchk = {} # track whether decoration overlay item is drawn or not
-ovlcoords = {} # positioning coordinates for decoration overlay
-
-
class Command(Thread):
"""
Creates thread, which will observe the command file and see, if there
@@ -190,7 +186,10 @@
self.mapfile = None # image file to be rendered
self.img = "" # wx.Image object (self.mapfile)
self.ovlist = [] # list of images for overlays
- ovlcoords = {} # coordinates for positioning decorative overlays
+ self.ovlcoords = {} # positioning coordinates for decoration overlay
+ self.imagedict = {} # images and their ID's for painting and dragging
+ self.select = {} # selecting/unselecting decorations for dragging
+ self.ovlchk = {} # showing/hiding decorations
#
# mouse attributes like currently pressed buttons, position on
@@ -223,25 +222,129 @@
self.lastpos = (0,0)
- def Draw(self, dc, img=None, dctype='image', coords='0,0'):
- """
- Just here as a place holder.
- This method should be over-ridden when sub-classed
+# def Draw(self, dc, img=None, pdctype='image', coords='0,0'):
+# """
+# Just here as a place holder.
+# This method should be over-ridden when sub-classed
+# """
+# pass
+#
+# def DrawOvl(self, pdc, type, data, pdctype='image', coords=wx.Rect(0,0,0,0)):
+# """
+# Draws map decorations on top of map
+# Just here as a place holder.
+# This method should be over-ridden when sub-classed
+# """
+# pass
+
+# def Draw(self, dc, img=None, pdctype='image', coords=[0, 0]):
+# """
+# Draws image, box and line in the background
+# """
+# dc.BeginDrawing()
+# dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
+# dc.Clear() # make sure you clear the bitmap!
+#
+# if dctype == 'clear': # erase the display
+# dc.EndDrawing()
+# return
+# bitmap = wx.BitmapFromImage(img)
+# dc.DrawBitmap(bitmap, 0, 0, True) # draw the composite map
+#
+# if dctype == 'box': # draw a box on top of the map
+# dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
+# dc.SetPen(self.pen)
+# dc.DrawRectangle(coords[0], coords[1], coords[2], coords[3])
+# elif dctype == 'line': # draw a line on top of the map
+# dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
+# dc.SetPen(self.pen)
+# dc.DrawLine(coords[0], coords[1], coords[2], coords[3])
+#
+# dc.EndDrawing()
+
+ def Draw(self, pdc, img=None, drawid=None, pdctype='image', coords=[0,0,0,0]):
"""
- pass
+ Draws map decorations on top of map
+ """
+ if drawid == None:
+ if pdctype == 'image' :
+ drawid = imagedict[img]
+ elif pdctype == 'clear':
+ drawid == None
+ else:
+ drawid = wx.NewId()
+
+ self.ovlcoords[drawid] = coords
+ self.ovlchk[drawid] = True
+ pdc.SetId(drawid)
+ self.select[drawid] = False
+
+ if pdctype == 'clear': # erase the display
+ pdc.EndDrawing()
+ return
+
+ if pdctype == 'image':
+ bitmap = wx.BitmapFromImage(img)
+ w,h = bitmap.GetSize()
+ pdc.DrawBitmap(bitmap, coords[0], coords[1], True) # draw the composite map
+ pdc.SetIdBounds(drawid, (coords[0],coords[1],w,h))
+
+ elif pdctype == 'box': # draw a box on top of the map
+ pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
+ pdc.SetPen(self.pen)
+ pdc.DrawRectangle(coords[0], coords[1], coords[2], coords[3])
+ pdc.SetIdBounds(drawid,(coords[0], coords[1], coords[2], coords[3]))
+ self.ovlcoords[drawid] = coords
+
+ elif pdctype == 'line': # draw a line on top of the map
+ pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
+ pdc.SetPen(self.pen)
+ dc.DrawLine(coords[0], coords[1], coords[2], coords[3])
+ pdc.SetIdBounds(drawid,(coords[0], coords[1], coords[2], coords[3]))
+ self.ovlcoords[drawid] = coords
+
+ elif pdctype == 'point': #draw point
+ pen = self.RandomPen()
+ pdc.SetPen(pen)
+ pdc.DrawPoint(coords[0], coords[1])
+ pdc.SetIdBounds(drawid,(coords[0], coords[1], coords[2], coords[3]))
+ self.ovlcoords[drawid] = coords
+
+ elif pdctype == 'text': # draw text on top of map
+ text = img
+ w,h = self.GetFullTextExtent(text)[0:2]
+ pdc.SetFont(self.GetFont())
+ pdc.SetTextForeground(self.RandomColor())
+ pdc.SetTextBackground(self.RandomColor())
+ pdc.DrawText(text, coords[0], coords[1])
+ pdc.SetIdBounds(drawid, (coords[0], coords[1], coords[2], coords[3]))
+ self.ovlcoords[drawid] = coords
+
+ pdc.EndDrawing()
+ self.Refresh()
+
def OnPaint(self, event):
"""
All that is needed here is to draw the buffer to screen
"""
dc = wx.BufferedPaintDC(self, self._Buffer)
- # pseudoDC for map decorations like scale and legend
+ # use PrepateDC to set position correctly
+ self.PrepareDC(dc)
+ # we need to clear the dc BEFORE calling PrepareDC
+# bg = wx.TRANSPARENT_BRUSH
+ bg = wx.Brush(self.GetBackgroundColour())
+ dc.SetBackground(bg)
+ dc.Clear()
+ # create a clipping rect from our position and size
+ # and the Update Region
rgn = self.GetUpdateRegion()
- rgn.Offset(0,0)
r = rgn.GetBox()
+ # draw to the dc using the calculated clipping rect
self.pdc.DrawToDCClipped(dc,r)
+
def OnSize(self, event):
"""
The Buffer init is done here, to make sure the buffer is always
@@ -258,8 +361,8 @@
# get the image to be rendered
self.img = self.GetImage()
-# self.ovlist = self.GetOverlay()
+
# update map display
if self.img and Map.width + Map.height > 0: # scale image during resize
self.img = self.img.Scale(Map.width, Map.height)
@@ -288,6 +391,34 @@
"""
self._Buffer.SaveFile(FileName, FileType)
+ def GetOverlay(self):
+ """
+ Converts overlay files to wx.Image
+ """
+ ovlist = []
+ if Map.ovlist:
+ for ovlfile in Map.ovlist:
+ if os.path.isfile(ovlfile) and os.path.getsize(ovlfile):
+ img = wx.Image(ovlfile, wx.BITMAP_TYPE_ANY)
+ img.ConvertAlphaToMask()
+ ovlist.append(img)
+ self.imagedict[img] = ovlist.index(img) # set image PeudoDC ID
+ return ovlist
+
+
+ def GetImage(self):
+ """
+ Converts files to wx.Image
+ """
+ if Map.mapfile and os.path.isfile(Map.mapfile) and \
+ os.path.getsize(Map.mapfile):
+ img = wx.Image(Map.mapfile, wx.BITMAP_TYPE_ANY)
+ else:
+ img = None
+ self.imagedict[img] = 99 # set image PeudoDC ID
+ return img
+
+
def UpdateMap(self, img=None):
"""
This would get called if the drawing needed to change, for whatever reason.
@@ -301,39 +432,32 @@
if DEBUG:
print "Buffered Window.UpdateMap(%s): render=%s" % (img, self.render)
-
if self.render:
+ # render new map images
Map.width, Map.height = self.GetClientSize()
self.mapfile = Map.Render(force=self.render)
self.img = self.GetImage()
self.resize = False
- if not self.img: return
- self.ovlist = self.GetOverlay()
- # redraw decorations on resize event
- if self.ovlist != []:
- for overlay in self.ovlist:
- ovltype = self.ovlist.index(overlay)
- if ovltype not in ovlcoords:
- ovlcoords[ovltype] = wx.Rect(0,0,0,0)
- self.DrawOvl(self.pdc, type=ovltype, data=None, pdctype='clear')
- if ovlchk[ovltype] == True:
- self.DrawOvl(self.pdc, type=ovltype, data=overlay, pdctype='image', rect=ovlcoords[ovltype])
- dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
- self.Draw(dc, self.img)
- else:
- if not self.img: return
- self.ovlist = self.GetOverlay()
- if self.ovlist != []:
- for overlay in self.ovlist:
- ovltype = self.ovlist.index(overlay)
- if ovltype not in ovlcoords:
- ovlcoords[ovltype] = wx.Rect(0,0,0,0)
- self.DrawOvl(self.pdc, type=ovltype, data=None, pdctype='clear')
- if ovlchk[ovltype] == True:
- self.DrawOvl(self.pdc, type=ovltype, data=overlay, pdctype='image', rect=ovlcoords[ovltype])
- dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
- self.Draw(dc, self.img)
+ if not self.img: return
+ id = self.imagedict[self.img]
+ if not id: return
+
+ # paint images to PseudoDC
+ self.pdc.Clear()
+ self.pdc.RemoveAll()
+ self.Draw(self.pdc, self.img, drawid=id) # draw map image background
+ self.ovlist = self.GetOverlay() # list of decoration overlay images
+ if self.ovlist != []:
+ for img in self.ovlist:
+ id = self.imagedict[img]
+ if id not in self.ovlcoords: self.ovlcoords[id] = wx.Rect(0,0,0,0)
+ if id == None: return # ID has not yet been assigned (image not painted)
+ if id not in self.ovlchk: self.ovlchk[id] = False
+ if self.ovlchk[id] == True: # draw any active and defined overlays
+ self.Draw(self.pdc, img=img, drawid=id,
+ pdctype='image', coords=self.ovlcoords[id])
+
self.resize = False
# update statusbar
@@ -345,8 +469,9 @@
"""
Erase the map display
"""
- dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
- self.Draw(dc, dctype='clear')
+# dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
+# self.Draw(dc, dctype='clear')
+ self.Draw(self.pdc, pdctype='clear')
def DragMap(self, moveto):
"""
@@ -364,75 +489,80 @@
self.dragimg.DoDrawImage(dc, moveto)
self.dragimg.EndDrag()
- def DragItem(self, lastpos, event):
- x,y = lastpos
+ def DragItem(self, id, event):
+ x,y = self.lastpos
dx = event.GetX() - x
dy = event.GetY() - y
- r = self.pdc.GetIdBounds(self.dragid)
- self.pdc.TranslateId(self.dragid, dx, dy)
- dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
- dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
- bitmap = wx.BitmapFromImage(self.img)
- dc.Clear() # make sure you clear the bitmap!
- dc.DrawBitmap(bitmap, 0, 0, True) # draw the composite map
- self.pdc.DrawToDC(dc)
- self.RefreshRect(r, True)
+ r = self.pdc.GetIdBounds(id)
+ self.pdc.TranslateId(id, dx, dy)
+ r2 = self.pdc.GetIdBounds(id)
+ r = r.Union(r2)
+ r.Inflate(4,4)
+ self.RefreshRect(r, False)
self.lastpos = (event.GetX(),event.GetY())
- ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
def MouseDraw(self):
"""
Mouse zoom rectangles and lines
"""
- img = self.img # composite map in background
- dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer)
+ boxid = wx.ID_NEW
if self.mouse['box'] == "box":
mousecoords = [self.mouse['begin'][0], self.mouse['begin'][1], \
self.mouse['end'][0] - self.mouse['begin'][0], \
self.mouse['end'][1] - self.mouse['begin'][1]]
- self.Draw(dc, img, dctype='box', coords=mousecoords)
+ r = self.pdc.GetIdBounds(boxid)
+ r.Inflate(4,4)
+ self.pdc.ClearId(boxid)
+ self.RefreshRect(r, False)
+ self.pdc.SetId(boxid)
+ self.Draw(self.pdc, drawid=boxid, pdctype='box', coords=mousecoords)
elif self.mouse['box'] == "line":
mousecoords = [self.mouse['begin'][0], self.mouse['begin'][1], \
self.mouse['end'][0] - self.mouse['begin'][0], \
self.mouse['end'][1] - self.mouse['begin'][1]]
- self.Draw(dc, img, dctype='line', coords=mousecoords)
+ r = self.pdc.GetIdBounds(boxid)
+ r.Inflate(4,4)
+ self.pdc.ClearId(boxid)
+ self.RefreshRect(r, False)
+ self.pdc.SetId(boxid)
+ self.Draw(self.pdc, drawid=boxid, pdctype='line', coords=mousecoords)
def MouseActions(self, event):
"""
Mouse motion and button click notifier
"""
wheel = event.GetWheelRotation() # +- int
- # left mouse button pressed
- hitradius = 0 # distance for selecting map decorations
+ hitradius = 5 # distance for selecting map decorations
+
+ # left mouse button pressed
if event.LeftDown():
- l = []
- id = ''
- # start point of zoom box or drag
self.mouse['begin'] = event.GetPositionTuple()[:]
- #l = self.pdc.FindObjectsByBBox(x, y)
- l = self.pdc.FindObjects(self.mouse['begin'][0], self.mouse['begin'][1], hitradius)
- for id in l:
- self.pdc.SetIdGreyedOut(id, True)
+
+ # double click to select decoration for dragging
+ elif event.ButtonDClick():
+ # start point of drag
+ self.lastpos = event.GetPositionTuple()[:]
+
+ # select decoration and get its ID
+# l = self.pdc.FindObjectsByBBox(self.mouse['begin'][0], self.mouse['begin'][1])
+ idlist = self.pdc.FindObjects(self.lastpos[0], self.lastpos[1], hitradius)
+ if idlist == []: return
+ id = idlist[0]
+ self.select[id] = not self.select[id]
+ if self.select[id] == True:
self.dragid = id
- self.lastpos = (event.GetX(),event.GetY())
- break
+ else:
+ self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
+ self.dragid = None
+ self.UpdateMap()
+ id = None
# left mouse button released and not just a pointer
elif event.LeftUp():
- # dragging map decoration
- if self.mouse['box'] == "point" and self.dragid > -1:
- self.pdc.SetIdGreyedOut(self.dragid, False)
-#
-# r = self.pdc.GetIdBounds(self.dragid)
-# r.Inflate(4,4)
-# self.OffsetRect(r)
-# self.RefreshRect(r, True)
- self.dragid = -1
- self.UpdateMap()
- elif self.mouse['box'] != "point":
+ if self.mouse['box'] != "point":
# end point of zoom box or drag
- self.mouse['end'] = event.SetPositionTuple()[:]
+ self.mouse['end'] = event.GetPositionTuple()[:]
# set region in zoom or pan
self.Zoom(self.mouse['begin'], self.mouse['end'], self.zoomtype)
@@ -448,6 +578,9 @@
# redraw map
self.render=True
self.UpdateMap()
+ elif self.dragid:
+ self.Refresh()
+ self.Update()
elif event.Dragging():
currpos = event.GetPositionTuple()[:]
@@ -456,14 +589,17 @@
# dragging or drawing box with left button
if self.mouse['box'] == 'drag':
self.DragMap(end)
+
# dragging decoration overlay item
+ elif self.mouse['box'] == 'point' and self.dragid != None:
+ self.DragItem(self.dragid, event)
+
+ # dragging something else?
else:
- if self.dragid != -1:
- self.DragItem(self.lastpos,event)
self.mouse['end'] = event.GetPositionTuple()[:]
self.MouseDraw()
- # zoom on mouse wheel
+ # zoom with mouse wheel
elif wheel != 0:
# zoom 1/2 of the screen
@@ -471,35 +607,21 @@
end = [Map.width - Map.width/4,
Map.height - Map.height/4]
+ elif event.RightDown():
+ x,y = event.GetPositionTuple()[:]
+ #l = self.pdc.FindObjectsByBBox(x, y)
+ l = self.pdc.FindObjects(x, y, hitradius)
+ if l:
+ self.pdc.SetIdGreyedOut(id=l[0], greyout=(not self.pdc.GetIdGreyedOut(id=l[0])))
+ self.Refresh()
+ self.Update()
+# r = self.pdc.GetIdBounds(l[0])
+# r.Inflate(4,4)
+# self.RefreshRect(r, False)
+
# store current mouse position
self.mouse['pos'] = event.GetPositionTuple()[:]
- def GetOverlay(self):
- """
- Converts overlay files to wx.Image
- """
- ovlist = []
- if Map.ovlist:
- for ovlfile in Map.ovlist:
- if os.path.isfile(ovlfile) and os.path.getsize(ovlfile):
- img = wx.Image(ovlfile, wx.BITMAP_TYPE_ANY)
- img.ConvertAlphaToMask()
- ovlist.append(img)
-
- return ovlist
-
-
- def GetImage(self):
- """
- Converts files to wx.Image
- """
- if Map.mapfile and os.path.isfile(Map.mapfile) and \
- os.path.getsize(Map.mapfile):
- img = wx.Image(Map.mapfile, wx.BITMAP_TYPE_ANY)
- else:
- img = None
- return img
-
def Pixel2Cell(self, x, y):
"""
Calculates real word coordinates to image coordinates
@@ -557,101 +679,106 @@
Map.region['w'] = newreg['w']
- def DrawOvl(self, pdc, type, data, pdctype='image', rect=wx.Rect(0,0,0,0)):
- """
- Draws map decorations on top of map
- """
- pdc.BeginDrawing()
- id = type
- pdc.SetId(id)# pdc.SetBackground(wx.Brush(self.GetBackgroundColour()))
-# pdc.Clear() # make sure you clear the bitmap!
+#class DrawWindow(BufferedWindow):
+# """
+# Drawing routine for double buffered drawing. Overwrites Draw method
+# in the BufferedWindow class
+# """
+# def __init__(self, parent, id = wx.ID_ANY):
+# """
+# """
+# ## Any data the Draw() function needs must be initialized before
+# ## calling BufferedWindow.__init__, as it will call the Draw
+# ## function.
+# self.dcmd_list = [] # list of display commands to process
+# BufferedWindow.__init__(self, parent, id)
+#
+# def Draw(self, dc, img=None, pdctype='image', coords=[0, 0]):
+# """
+# Draws image, box and line in the background
+# """
+# dc.BeginDrawing()
+# dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
+# dc.Clear() # make sure you clear the bitmap!
+#
+# if dctype == 'clear': # erase the display
+# dc.EndDrawing()
+# return
+# bitmap = wx.BitmapFromImage(img)
+# dc.DrawBitmap(bitmap, 0, 0, True) # draw the composite map
+#
+# if dctype == 'box': # draw a box on top of the map
+# dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
+# dc.SetPen(self.pen)
+# dc.DrawRectangle(coords[0], coords[1], coords[2], coords[3])
+# elif dctype == 'line': # draw a line on top of the map
+# dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
+# dc.SetPen(self.pen)
+# dc.DrawLine(coords[0], coords[1], coords[2], coords[3])
+#
+# dc.EndDrawing()
+#
+# def DrawOvl(self, pdc, img=None, id=None, pdctype='image', coords=[0,0,0,0]):
+# """
+# Draws map decorations on top of map
+# """
+# pdc.BeginDrawing()
+#
+# if id == None:
+# if pdctype == 'image' :
+# id = imagedict[img]
+# else:
+# id = wx.NewId()
+# pdc.SetId(id)
+# self.select[id] = False
+#
+# if pdctype == 'clear': # erase the display
+## if type > -1:
+## pdc.RemoveId(id)
+# pdc.EndDrawing()
+# return
+#
+# elif pdctype == 'image':
+# bitmap = wx.BitmapFromImage(img)
+# w,h = bitmap.GetSize()
+# pdc.DrawBitmap(bitmap, coords[0], coords[1], True) # draw the composite map
+# pdc.SetIdBounds(id, (coords[0],coords[1],w,h))
+#
+# elif pdctype == 'box': # draw a box on top of the map
+# pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
+# pdc.SetPen(self.pen)
+# pdc.DrawRectangle(coords[0], coords[1], coords[2], coords[3])
+# rect.Inflate(pen.GetWidth(),pen.GetWidth())
+# pdc.SetIdBounds(id,(coords[0], coords[1], coords[2], coords[3]))
+#
+# elif pdctype == 'line': # draw a line on top of the map
+# pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
+# pdc.SetPen(self.pen)
+# dc.DrawLine(rect)
+# rect.Inflate(pen.GetWidth(),pen.GetWidth())
+# pdc.SetIdBounds(id,(coords[0], coords[1], coords[2], coords[3]))
+#
+# elif pdctype == 'point': #draw point
+# pen = self.RandomPen()
+# pdc.SetPen(pen)
+# pdc.DrawPoint(coords[0], coords[1])
+# rect.Inflate(pen.GetWidth(),pen.GetWidth())
+# pdc.SetIdBounds(id,(coords[0], coords[1], coords[2], coords[3]))
+#
+# elif pdctype == 'text': # draw text on top of map
+# text = img
+# w,h = self.GetFullTextExtent(text)[0:2]
+# pdc.SetFont(self.GetFont())
+# pdc.SetTextForeground(self.RandomColor())
+# pdc.SetTextBackground(self.RandomColor())
+# pdc.DrawText(text, coords[0], coords[1])
+# rect.Inflate(2,2)
+# pdc.SetIdBounds(id, (coords[0], coords[1], coords[2], coords[3]))
+#
+# pdc.EndDrawing()
+# self.Refresh()
- if pdctype == 'clear': # erase the display
- if type > -1:
- pdc.ClearId(type)
- pdc.EndDrawing()
- return
- elif pdctype == 'image':
- bitmap = wx.BitmapFromImage(data)
- w,h = bitmap.GetSize()
- pdc.DrawBitmap(bitmap, rect.x, rect.y, True) # draw the composite map
- pdc.SetIdBounds(id, (rect[0],rect[1],w,h))
-
- elif pdctype == 'box': # draw a box on top of the map
- pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
- pdc.SetPen(self.pen)
- pdc.DrawRectangleRect(rect)
- rect.Inflate(pen.GetWidth(),pen.GetWidth())
- pdc.SetIdBounds(id,rect)
-
- elif pdctype == 'line': # draw a line on top of the map
- pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
- pdc.SetPen(self.pen)
- dc.DrawLine(rect)
- rect.Inflate(pen.GetWidth(),pen.GetWidth())
- pdc.SetIdBounds(id,rect)
-
- elif pdctype == 'point': #draw point
- pen = self.RandomPen()
- pdc.SetPen(pen)
- pdc.DrawPoint(rect.x, rect.y)
- rect.Inflate(pen.GetWidth(),pen.GetWidth())
- pdc.SetIdBounds(id,rect)
-
- elif pdctype == 'text': # draw text on top of map
- text = data
- w,h = self.GetFullTextExtent(text)[0:2]
- pdc.SetFont(self.GetFont())
- pdc.SetTextForeground(self.RandomColor())
- pdc.SetTextBackground(self.RandomColor())
- pdc.DrawText(text, rect.x, rect.y)
- rect.Inflate(2,2)
- pdc.SetIdBounds(id, rect)
-
- pdc.EndDrawing()
- self.Refresh()
-
-
-class DrawWindow(BufferedWindow):
- """
- Drawing routine for double buffered drawing. Overwrites Draw method
- in the BufferedWindow class
- """
- def __init__(self, parent, id = wx.ID_ANY):
- """
- """
- ## Any data the Draw() function needs must be initialized before
- ## calling BufferedWindow.__init__, as it will call the Draw
- ## function.
- self.dcmd_list = [] # list of display commands to process
- BufferedWindow.__init__(self, parent, id)
-
- def Draw(self, dc, img=None, dctype='image', coords=[0, 0]):
- """
- Draws image, box and line in the background
- """
- dc.BeginDrawing()
- dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
- dc.Clear() # make sure you clear the bitmap!
-
- if dctype == 'clear': # erase the display
- dc.EndDrawing()
- return
- bitmap = wx.BitmapFromImage(img)
- dc.DrawBitmap(bitmap, 0, 0, True) # draw the composite map
-
- if dctype == 'box': # draw a box on top of the map
- dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
- dc.SetPen(self.pen)
- dc.DrawRectangle(coords[0], coords[1], coords[2], coords[3])
- elif dctype == 'line': # draw a line on top of the map
- dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
- dc.SetPen(self.pen)
- dc.DrawLine(coords[0], coords[1], coords[2], coords[3])
-
- dc.EndDrawing()
-
class MapFrame(wx.Frame):
"""
Main frame for map display window. Drawing takes place in child double buffered
@@ -716,20 +843,24 @@
for i in range(len(map_frame_statusbar_fields)):
self.statusbar.SetStatusText(map_frame_statusbar_fields[i], i)
- # decoration overlays
- ovlchk[0] = False
- ovlchk[1] = False
- Map.addOverlay(type=0, command='d.barscale', l_active=True, l_render=False) # d.barscale overlay
- Map.addOverlay(type=1, command='d.barscale', l_active=True, l_render=False) # d.legend overlay
+ # d.barscale overlay added to rendering overlay list
+ Map.addOverlay(type=0, command='d.barscale', l_active=True, l_render=False)
+ # d.barscale overlay added to rendering overlay list as placeholder for d.legend
+ Map.addOverlay(type=1, command='d.barscale', l_active=True, l_render=False)
#
# Init map display
#
self.InitDisplay() # initialize region values
- self.MapWindow = DrawWindow(self) # initialize buffered DC
+# self.MapWindow = DrawWindow(self) # initialize buffered DC
+ self.MapWindow = BufferedWindow(self, id = wx.ID_ANY) # initialize buffered DC
self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
+ # decoration overlays
+ self.ovlchk = self.MapWindow.ovlchk
+ self.ovlcoords = self.MapWindow.ovlcoords
+
#
# Bind various events
# ONLY if we are running from GIS manager
@@ -906,16 +1037,71 @@
"""
Map.getRegion()
Map.getResolution()
- self.draw(dc)
+ self.UpdateMap()
+# self.draw(dc)
event.Skip()
+ def OnAlignRegion(self, event):
+ """
+ Align region
+ """
+ if not Map.alignRegion:
+ Map.alignRegion = True
+ else:
+ Map.alignRegion = False
+ event.Skip()
+
+ def SaveToFile(self, event):
+ """
+ Save to file
+ """
+ dlg = wx.FileDialog(self, "Choose a file name to save the image as a PNG to",
+ defaultDir = "",
+ defaultFile = "",
+ wildcard = "*.png",
+ style=wx.SAVE)
+ if dlg.ShowModal() == wx.ID_OK:
+ self.MapWindow.SaveToFile(dlg.GetPath(), wx.BITMAP_TYPE_PNG)
+ dlg.Destroy()
+
+ def OnCloseWindow(self, event):
+ """
+ Window closed
+ """
+ Map.Clean()
+ self.Destroy()
+
+ #close associated controls book page
+ #get index number of active display
+ self.disp_idx = track.Track().GetDisp_idx(self)
+
+ # delete associated bookcontrol page if it exists
+ if self.disp_idx != None:
+ pg = track.Track().GetCtrls(self.disp_idx, 1)
+ pg_count = self.ctrlbk.GetPageCount()
+ pgnum = '0'
+ if pg_count > 0:
+ for x in range(0,pg_count):
+ if self.ctrlbk.GetPage(x) == pg:
+ pgnum = x
+ track.Track().popCtrl(self.disp_idx)
+ self.ctrlbk.DeletePage(pgnum)
+
+ def getRender(self):
+ """
+ returns the current instance of render.Map()
+ """
+ return Map
+
# toolBar button handlers
def onDecoration(self, event):
- """Add decorations item menu"""
+ """
+ Decorations overlay menu"
+ """
point = wx.GetMousePosition()
decmenu = wx.Menu()
# Add items to the menu
- addscale = wx.MenuItem(decmenu, -1,'Add scalebar and north arrow')
+ addscale = wx.MenuItem(decmenu, -1,'Scalebar and north arrow')
bmp = wx.Image(os.path.join(icons,'module-d.barscale.gif'), wx.BITMAP_TYPE_GIF)
bmp.Rescale(16, 16)
bmp = bmp.ConvertToBitmap()
@@ -923,7 +1109,7 @@
decmenu.AppendItem(addscale)
self.Bind(wx.EVT_MENU, self.addBarscale, addscale)
- addlegend = wx.MenuItem(decmenu, -1,'Add legend')
+ addlegend = wx.MenuItem(decmenu, -1,'Legend')
bmp = wx.Image(os.path.join(icons,'module-d.legend.gif'), wx.BITMAP_TYPE_GIF)
bmp.Rescale(16, 16)
bmp = bmp.ConvertToBitmap()
@@ -937,138 +1123,103 @@
decmenu.Destroy()
def addBarscale(self, event):
- ovltype = 0
- DecDialog(self, wx.ID_ANY, 'Scale and arrow')
+ """
+ Handler for scale/arrow map decoration menu selection.
+ """
+ ovltype = 0 # index for overlay layer in render
+ ovlist = self.MapWindow.GetOverlay()
+ if ovlist == []: return
+ img = ovlist[0]
+ id = self.MapWindow.imagedict[img]
+ if id == None: return
+ if id not in self.ovlcoords: self.ovlcoords[id] = wx.Rect(0,0,0,0)
+ # Decoration overlay control dialog
dlg = DecDialog(self, wx.ID_ANY, 'Scale and North arrow', size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE,
+ ovltype=ovltype,
cmd='d.barscale',
- type=ovltype,
- togletxt = "Show/hide scale and arrow",
+ drawid=id,
+ checktxt = "Show/hide scale and arrow",
ctrltxt = "scale object")
dlg.CenterOnScreen()
- # this does not return until the dialog is closed.
+ # If OK button pressed in decoration control dialog
val = dlg.ShowModal()
- self.MapWindow.UpdateMap()
- if ovltype not in ovlcoords:
- ovlcoords[ovltype] = wx.Rect(0,0,0,0)
-
if val == wx.ID_OK:
- ovlist = self.MapWindow.GetOverlay()
- if ovlist != []:
- self.MapWindow.DrawOvl(self.MapWindow.pdc, type=ovltype, data=None, pdctype='clear')
- if ovlchk[ovltype] == True:
- self.MapWindow.DrawOvl(self.MapWindow.pdc, type=ovltype,
- data=ovlist[ovltype], pdctype='image', rect=ovlcoords[ovltype])
+ if self.ovlchk[id] == True:
+ self.MapWindow.Draw(self.MapWindow.pdc, drawid=id,
+ img=img, pdctype='image',
+ coords=self.ovlcoords[id])
+ self.MapWindow.UpdateMap()
dlg.Destroy()
def addLegend(self, event):
- ovltype = 1
- DecDialog(self, wx.ID_ANY, 'Legend')
+ """
+ Handler for legend map decoration menu selection.
+ """
+ ovltype = 1 # index for overlay layer in render
+ ovlist = self.MapWindow.GetOverlay()
+ if ovlist == []: return
+ img = ovlist[1]
+ id = self.MapWindow.imagedict[img]
+ if id == None: return
+ if id not in self.ovlcoords: self.ovlcoords[id] = wx.Rect(0,0,0,0)
+ # Decoration overlay control dialog
dlg = DecDialog(self, wx.ID_ANY, 'Legend', size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE,
+ ovltype=ovltype,
cmd='d.legend',
- type=ovltype,
- togletxt = "Show/hide legend",
+ drawid=id,
+ checktxt = "Show/hide legend",
ctrltxt = "legend object")
dlg.CenterOnScreen()
- # this does not return until the dialog is closed.
+ # If OK button pressed in decoration control dialog
val = dlg.ShowModal()
- self.MapWindow.UpdateMap()
- if ovltype not in ovlcoords:
- ovlcoords[ovltype] = wx.Rect(0,0,0,0)
-
if val == wx.ID_OK:
- ovlist = self.MapWindow.GetOverlay()
- if ovlist != []:
- self.MapWindow.DrawOvl(self.MapWindow.pdc, type=ovltype, data=None, pdctype='clear')
- if ovlchk[ovltype] == True:
- self.MapWindow.DrawOvl(self.MapWindow.pdc, type=ovltype,
- data=ovlist[ovltype], pdctype='image', rect=ovlcoords[ovltype])
+ if self.ovlchk[id] == True:
+ self.MapWindow.Draw(self.MapWindow.pdc, drawid=id,
+ img=img, pdctype='image',
+ coords=self.ovlcoords[id])
+ self.MapWindow.UpdateMap()
dlg.Destroy()
def getOptData(self, dcmd, type):
-
- Map.changeOverlay(type=type, command=dcmd, l_active=ovlchk, l_render=False)
-
- def OnAlignRegion(self, event):
"""
- Align region
+ Callback method for decoration overlay command generated by
+ dialog created in menuform.py
"""
- if not Map.alignRegion:
- Map.alignRegion = True
- else:
- Map.alignRegion = False
- event.Skip()
- def SaveToFile(self, event):
- """
- Save to file
- """
- dlg = wx.FileDialog(self, "Choose a file name to save the image as a PNG to",
- defaultDir = "",
- defaultFile = "",
- wildcard = "*.png",
- style=wx.SAVE)
- if dlg.ShowModal() == wx.ID_OK:
- self.MapWindow.SaveToFile(dlg.GetPath(), wx.BITMAP_TYPE_PNG)
- dlg.Destroy()
+ # Reset comand and rendering options in render.Map. Always render decoration.
+ # Showing/hiding handled by PseudoDC
+ Map.changeOverlay(type=type, command=dcmd, l_active=True, l_render=False)
- def OnCloseWindow(self, event):
- """
- Window closed
- """
- Map.Clean()
- self.Destroy()
-
- #close associated controls book page
- #get index number of active display
- self.disp_idx = track.Track().GetDisp_idx(self)
-
- # delete associated bookcontrol page if it exists
- if self.disp_idx != None:
- pg = track.Track().GetCtrls(self.disp_idx, 1)
- pg_count = self.ctrlbk.GetPageCount()
- pgnum = '0'
- if pg_count > 0:
- for x in range(0,pg_count):
- if self.ctrlbk.GetPage(x) == pg:
- pgnum = x
- track.Track().popCtrl(self.disp_idx)
- self.ctrlbk.DeletePage(pgnum)
-
- def getRender(self):
- """
- returns the current instance of render.Map()
- """
- return Map
-
# end of class MapFrame
class DecDialog(wx.Dialog):
def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=wx.DEFAULT_DIALOG_STYLE, cmd=None, type=None, togletxt='', ctrltxt=''):
+ style=wx.DEFAULT_DIALOG_STYLE, ovltype=0, cmd='d.barscale', drawid=None, checktxt='', ctrltxt=''):
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
+ """
+ Controls setting options and displaying/hiding map overlay decorations
+ """
- self.type = type
+ self.ovltype = ovltype
+ self.drawid = drawid
self.ovlcmd = cmd
- if type > -1 and type in ovlchk: #tracks toggling of decorations
- check = ovlchk[type]
- else:
- check = False
+ self.ovlchk = self.Parent.MapWindow.ovlchk
sizer = wx.BoxSizer(wx.VERTICAL)
box = wx.BoxSizer(wx.HORIZONTAL)
- self.chkbox = wx.CheckBox(self, wx.ID_ANY, togletxt )
- self.chkbox.SetValue(check)
+ self.chkbox = wx.CheckBox(self, wx.ID_ANY, checktxt)
+ if drawid in self.ovlchk: self.chkbox.SetValue(self.ovlchk[drawid])
box.Add(self.chkbox, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
@@ -1078,7 +1229,7 @@
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
- label = wx.StaticText(self, -1, ("Drag %s with mouse in pointer mode to position" % ctrltxt))
+ label = wx.StaticText(self, -1, ("Double-click %s with mouse in\npointer mode and drag to position.\nDouble-click again to set" % ctrltxt))
box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
@@ -1088,12 +1239,10 @@
btnsizer = wx.StdDialogButtonSizer()
btn = wx.Button(self, wx.ID_OK)
- btn.SetHelpText("The OK button completes the dialog")
btn.SetDefault()
btnsizer.AddButton(btn)
btn = wx.Button(self, wx.ID_CANCEL)
- btn.SetHelpText("The Cancel button cnacels the dialog.")
btnsizer.AddButton(btn)
btnsizer.Realize()
@@ -1102,18 +1251,23 @@
self.SetSizer(sizer)
sizer.Fit(self)
- self.Bind(wx.EVT_CHECKBOX, self.onToggle, self.chkbox)
+ self.Bind(wx.EVT_CHECKBOX, self.onCheck, self.chkbox)
self.Bind(wx.EVT_BUTTON, self.onOptions, optnbtn)
-
- def onToggle(self, event):
+ def onCheck(self, event):
+ """
+ Handler for checkbox for displaying/hiding decoration
+ """
check = event.IsChecked()
- ovlchk[self.type] = check
+ self.ovlchk[self.drawid] = check
def onOptions(self, event):
+ """
+ Sets option for decoration map overlays
+ """
self.params = [] # parameters to insert into dialog (not working)
menuform.GUI().parseCommand(self.ovlcmd, gmpath,
- completed=(self.Parent.getOptData,self.type,self.params),
+ completed=(self.Parent.getOptData,self.ovltype,self.params),
parentframe=None)
class MapApp(wx.App):
From landa at grass.itc.it Mon Apr 2 09:22:52 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Mon Apr 2 09:22:53 2007
Subject: [grass-addons] r392 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704020722.l327MqAp032072@grass.itc.it>
Author: landa
Date: 2007-04-02 09:22:52 +0200 (Mon, 02 Apr 2007)
New Revision: 392
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
fix KeyError when resizing the map window
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-01 15:43:58 UTC (rev 391)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-02 07:22:52 UTC (rev 392)
@@ -415,6 +415,7 @@
img = wx.Image(Map.mapfile, wx.BITMAP_TYPE_ANY)
else:
img = None
+
self.imagedict[img] = 99 # set image PeudoDC ID
return img
@@ -440,8 +441,10 @@
self.resize = False
if not self.img: return
- id = self.imagedict[self.img]
- if not id: return
+ try:
+ id = self.imagedict[self.img]
+ except:
+ return
# paint images to PseudoDC
self.pdc.Clear()
From cepicky at grass.itc.it Mon Apr 2 15:20:08 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Mon Apr 2 15:20:10 2007
Subject: [grass-addons] r393 - trunk/grassaddons/gui
Message-ID: <200704021320.l32DK8kb003460@grass.itc.it>
Author: cepicky
Date: 2007-04-02 15:20:08 +0200 (Mon, 02 Apr 2007)
New Revision: 393
Modified:
trunk/grassaddons/gui/wxgui.py
Log:
added new button
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-02 07:22:52 UTC (rev 392)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-02 13:20:08 UTC (rev 393)
@@ -318,8 +318,13 @@
('addgrp', wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_TOOLBAR, (16,16)), 'Add layer group', self.addGroup),
('addovl', wx.Bitmap(os.path.join(wxgui_utils.icons,'module-d.grid.gif'), wx.BITMAP_TYPE_ANY), 'Add grid or vector labels overlay', self.onOverlay),
('delcmd', wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_TOOLBAR, (16,16)), 'Delete selected layer', self.deleteLayer),
+ ('attributetable',wx.Bitmap(os.path.join(imagepath,'db_open_table.png'),wx.BITMAP_TYPE_ANY), 'Show attribute table', self.ShowAttributeTable),
)
+ def ShowAttributeTable(self,event):
+ print self.maptree.GetSelection().GetText()
+
+
def newDisplay(self, event=None):
"""Create new map display frame"""
From cepicky at grass.itc.it Mon Apr 2 15:38:55 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Mon Apr 2 15:38:56 2007
Subject: [grass-addons] r394 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704021338.l32Dct8c003606@grass.itc.it>
Author: cepicky
Date: 2007-04-02 15:38:55 +0200 (Mon, 02 Apr 2007)
New Revision: 394
Modified:
trunk/grassaddons/gui/gui_modules/grassenv.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
trunk/grassaddons/gui/wxgui.py
Log:
opening vector tables possible
Modified: trunk/grassaddons/gui/gui_modules/grassenv.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/grassenv.py 2007-04-02 13:20:08 UTC (rev 393)
+++ trunk/grassaddons/gui/gui_modules/grassenv.py 2007-04-02 13:38:55 UTC (rev 394)
@@ -40,4 +40,6 @@
for line in os.popen("g.gisenv").readlines():
key,val = line.strip().split("=")
+ val = val.replace("'","")
+ val = val.replace(";","")
env[key] = val
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 13:20:08 UTC (rev 393)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 13:38:55 UTC (rev 394)
@@ -330,6 +330,8 @@
def onExpandNode(self, event):
self.layer_selected = event.GetItem()
+ print "###",self.layertype
+ print "###",self.layer_selected
if self.layertype[self.layer_selected] == 'group':
self.SetItemImage(self.layer_selected, self.folder_open)
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-02 13:20:08 UTC (rev 393)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-02 13:38:55 UTC (rev 394)
@@ -41,7 +41,7 @@
import gui_modules.render as render
import gui_modules.menudata as menudata
import gui_modules.menuform as menuform
-import gui_modules.grassenv as grassevn
+import gui_modules.grassenv as grassenv
"""Main Python app to set up GIS Manager window and trap commands
Only command console is working currently, but windows for
@@ -322,9 +322,18 @@
)
def ShowAttributeTable(self,event):
- print self.maptree.GetSelection().GetText()
+ mapsel = self.maptree.GetSelection()
+ name = mapsel.GetText()
+ if name.find("@") >-1:
+ map,mapset = name.strip().split("@")
+
+ print "#%s#%s#%s" % (map,mapset,grassenv.env["MAPSET"])
+ if mapset == grassenv.env["MAPSET"]:
+ from gui_modules import dbm
+ self.dbmanager = gui_modules.dbm.DBHunter(None, -1,"GRASS Attribute Table Manager: %s" % map,map)
+
def newDisplay(self, event=None):
"""Create new map display frame"""
From cepicky at grass.itc.it Mon Apr 2 15:40:48 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Mon Apr 2 15:40:50 2007
Subject: [grass-addons] r395 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704021340.l32Demfj003651@grass.itc.it>
Author: cepicky
Date: 2007-04-02 15:40:48 +0200 (Mon, 02 Apr 2007)
New Revision: 395
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/wxgui.py
Log:
opening vector tables possible
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-02 13:38:55 UTC (rev 394)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-02 13:40:48 UTC (rev 395)
@@ -157,8 +157,8 @@
#self.sizer.Add(self.sizer2,0,wx.EXPAND)
self.SetSizer(self.sizer)
- size = wx.DisplaySize()
- self.SetSize(size)
+ #size = (wx
+ #self.SetSize(size)
self.sb = self.CreateStatusBar()
self.dbcon = "table: %s; " % self.tablename
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-02 13:38:55 UTC (rev 394)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-02 13:40:48 UTC (rev 395)
@@ -328,7 +328,6 @@
if name.find("@") >-1:
map,mapset = name.strip().split("@")
- print "#%s#%s#%s" % (map,mapset,grassenv.env["MAPSET"])
if mapset == grassenv.env["MAPSET"]:
from gui_modules import dbm
self.dbmanager = gui_modules.dbm.DBHunter(None, -1,"GRASS Attribute Table Manager: %s" % map,map)
From barton at grass.itc.it Mon Apr 2 17:35:51 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 17:35:52 2007
Subject: [grass-addons] r396 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021535.l32FZp8S005001@grass.itc.it>
Author: barton
Date: 2007-04-02 17:35:39 +0200 (Mon, 02 Apr 2007)
New Revision: 396
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
If layer options previously set, these now appear when layer options
dialog reopened. No need to start from nothing when resetting options.
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 13:40:48 UTC (rev 395)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 15:35:39 UTC (rev 396)
@@ -324,18 +324,11 @@
If run standalone, it will allow execution of the command.
The command is checked and sent to the clipboard when clicking "Copy". """
- def __init__(self, parent, ID, task_description, get_dcmd=None, layer=None, dcmd_params=None):
+ def __init__(self, parent, ID, task_description, get_dcmd=None, layer=None):
self.get_dcmd = get_dcmd
- self.dcmd_params = dcmd_params #this should be passed from the layer tree eventually
self.layer = layer
self.task = task_description
- # inserting existing values from d.* command in layer tree
- for p in self.task.params:
- if self.dcmd_params != None:
- for dparam in self.dcmd_params:
- if p == dparam:
- p['value'] = self.dcmd_params[dparam]
wx.Frame.__init__(self, parent, ID, self.task.name,
wx.DefaultPosition, style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
@@ -420,17 +413,17 @@
self.OnCancel(event)
def OnApply(self, event):
- cmd = self.createCmd()
+ cmd,params = self.createCmd()
if cmd is not None and self.get_dcmd is not None:
# return d.* command to layer tree for rendering
- self.get_dcmd(cmd, self.layer)
+ self.get_dcmd(cmd, self.layer,params)
# echo d.* command to output console
# self.parent.writeDCommand(cmd)
return cmd
def OnRun(self, event):
- cmd = self.createCmd()
+ cmd = self.createCmd()[0]
if cmd != None and cmd[0:2] != "d.":
# Send any non-display command to parent window (probably wxgui.py)
@@ -503,12 +496,14 @@
sections = ['Main']
is_section = {}
+
for task in self.task.params + self.task.flags:
if not task.has_key('guisection') or task['guisection']=='':
task['guisection'] = 'Options'
if not is_section.has_key(task['guisection']):
is_section[task['guisection']] = 1
- sections.append( task['guisection'] )
+ if task['guisection'] != 'Main': # check for pre-existing parameters passed from layer tree
+ sections.append( task['guisection'] )
there_is_main = False
for i in self.task.params+self.task.flags:
if i.has_key('required') and i['required'] == 'yes':
@@ -586,10 +581,12 @@
self.cb = wx.ComboBox(which_panel, -1, p['default'],
wx.Point(-1, -1), wx.Size(STRING_ENTRY_WIDTH, -1),
valuelist, wx.CB_DROPDOWN)
+ if p['value'] != '': self.cb.SetValue(p['value']) # parameter previously set
which_sizer.Add(self.cb, 0, wx.ADJUST_MINSIZE, 5)
self.paramdict[self.cb] = ID_PARAM_START + p_count
self.cb.Bind( wx.EVT_COMBOBOX, self.EvtComboBox)
+ # text entry
if (p['type'] in ('string','integer','float')
and len(p['values']) == 0
and p['gisprompt'] == False
@@ -600,6 +597,7 @@
self.txt3 = wx.TextCtrl(which_panel, value = p['default'],
size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
+ if p['value'] != '': self.txt3.SetValue(p['value']) # parameter previously set
which_sizer.Add(self.txt3, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
self.paramdict[self.txt3] = ID_PARAM_START + p_count
self.txt3.Bind(wx.EVT_TEXT, self.EvtText)
@@ -607,12 +605,15 @@
if p['type'] == 'string' and p['gisprompt'] == True:
txt = wx.StaticText(which_panel, label = title + ':')
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
+ # element selection tree combobox (maps, icons, regions, etc.)
if p['prompt'] != 'color':
self.selection = select.Select(which_panel, id=wx.ID_ANY, size=(250,-1),
type=p['element'])
+ if p['value'] != '': self.selection.SetValue(p['value']) # parameter previously set
which_sizer.Add(self.selection, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
self.paramdict[self.selection] = ID_PARAM_START + p_count
self.selection.Bind(wx.EVT_TEXT, self.EvtText)
+ # color entry
elif p['prompt'] == 'color':
if p['default'] != '':
if p['default'][0] in "0123456789":
@@ -629,6 +630,18 @@
else:
default_color = (200,200,200)
label_color = 'Select Color'
+ if p['value'] != '': # parameter previously set
+ if p['value'][0] in "0123456789":
+ default_color = tuple(map(int,p['value'].split( ':' )))
+ label_color = p['value']
+ else:
+ # Convert color names to RGB
+ try:
+ default_color = color_str2rgb[ p['value'] ]
+ label_color = p['value']
+ except KeyError:
+ default_color = (200,200,200)
+ label_color = 'Select Color'
btn_colour = csel.ColourSelect(which_panel, -1, label_color, default_color, wx.DefaultPosition, (150,-1) )
which_sizer.Add(btn_colour, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
self.paramdict[btn_colour] = ID_PARAM_START + p_count
@@ -643,6 +656,7 @@
which_panel = self.tab[ f['guisection'] ]
title = text_beautify(f['description'])
self.chk = wx.CheckBox(which_panel,-1, label = title, style = wx.NO_BORDER)
+ if 'value' in f: self.chk.SetValue(f['value'])
self.chk.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
which_sizer.Add(self.chk, 0, wx.EXPAND| wx.ALL, 5)
self.paramdict[self.chk] = ID_FLAG_START + f_count
@@ -747,6 +761,8 @@
cmd = self.task.name
errors = 0
errStr = ""
+ dcmd_params = {}
+
for flag in self.task.flags:
if 'value' in flag and flag['value']:
cmd += ' -' + flag['name']
@@ -760,8 +776,14 @@
if errors and not ignoreErrors:
self.OnError(errStr)
return None
- return cmd
+ # create paramater dictionary to return to layer tree
+ dcmd_params['flags'] = self.task.flags
+ dcmd_params['params'] = self.task.params
+
+
+ return cmd,dcmd_params
+
def getInterfaceDescription( cmd ):
"""Returns the XML description for the GRASS cmd.
@@ -796,12 +818,16 @@
self.parent = parent
def parseCommand(self, cmd, gmpath, completed=None, parentframe=-1 ):
+
+ dcmd_params = {}
if completed == None:
- self.get_dcmd = None
+ get_dcmd = None
layer = None
+ dcmd_params = None
else:
- self.get_dcmd = completed[0]
+ get_dcmd = completed[0]
layer = completed[1]
+ dcmd_params.update(completed[2])
cmdlst = cmd.split(' ')
if parentframe != -1:
@@ -815,7 +841,11 @@
handler = processTask(self.grass_task)
xml.sax.parseString( getInterfaceDescription( cmd ) , handler )
- self.mf = mainFrame(self.parent ,-1, self.grass_task, self.get_dcmd, layer)
+ # if layer parameters previously set, re-insert them into dialog
+ if 'params' in dcmd_params: self.grass_task.params = dcmd_params['params']
+ if 'flags' in dcmd_params: self.grass_task.flags = dcmd_params['flags']
+
+ self.mf = mainFrame(self.parent ,-1, self.grass_task, get_dcmd, layer)
self.mf.Show(True)
if __name__ == "__main__":
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 13:40:48 UTC (rev 395)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 15:35:39 UTC (rev 396)
@@ -53,12 +53,12 @@
self.saveitem = {} # dictionary to preserve layer attributes for drag and drop
self.first = True # indicates if a layer is just added or not
self.drag = False # flag to indicate a drag event is in process
- self.params = {} # dictionary of existing command parameters
+ self.params = '' # existing command parameters to pass back to options dialog
self.Map = disp.getRender()
self.root = self.AddRoot("Map Layers")
- self.SetPyData(self.root, None)
+ self.SetPyData(self.root, (None,None))
#create image list to use with layer tree
il = wx.ImageList(16, 16, False)
@@ -176,7 +176,7 @@
self.layerctrl[self.ctrl] = layer
# add a data object to hold the layer's command (does not apply to generic command layers)
- self.SetPyData(layer, None)
+ self.SetPyData(layer, (None,None))
#layer is initially unchecked as inactive
self.CheckItem(layer, checked=False)
@@ -424,7 +424,7 @@
self.reorderLayers()
self.drag = False
- def getOptData(self, dcmd, layer):
+ def getOptData(self, dcmd, layer, params):
for item in dcmd.split(' '):
if 'map=' in item:
mapname = item.split('=')[1]
@@ -441,7 +441,7 @@
self.SetItemText(layer, mapname)
# add command to layer's data
- self.SetPyData(layer, dcmd)
+ self.SetPyData(layer, (dcmd,params))
# check layer as active
self.CheckItem(layer, checked=True)
@@ -449,6 +449,9 @@
# change parameters for item in layers list in render.Map
self.changeLayer(layer)
+ self.params = params
+
+
def writeDCommand(self, dcmd):
# echos d.* command to output console
global goutput
@@ -490,8 +493,8 @@
self.Map.changeLayer(item=layer, command=cmd, l_active=chk,
l_hidden=hidden, l_opacity=opac, l_render=False)
else:
- if self.GetPyData(layer) != None:
- cmd = self.GetPyData(layer)
+ if self.GetPyData(layer)[0] != None:
+ cmd = self.GetPyData(layer)[0]
opac = float(self.GetItemWindow(layer).GetValue())/100
chk = self.IsItemChecked(layer)
hidden = not self.IsVisible(layer)
From barton at grass.itc.it Mon Apr 2 17:54:42 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 17:54:44 2007
Subject: [grass-addons] r397 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021554.l32FsgB4005254@grass.itc.it>
Author: barton
Date: 2007-04-02 17:54:33 +0200 (Mon, 02 Apr 2007)
New Revision: 397
Modified:
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Fix bug so that previously set options parameters associated with
layer correctly.
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 15:35:39 UTC (rev 396)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 15:54:33 UTC (rev 397)
@@ -53,7 +53,6 @@
self.saveitem = {} # dictionary to preserve layer attributes for drag and drop
self.first = True # indicates if a layer is just added or not
self.drag = False # flag to indicate a drag event is in process
- self.params = '' # existing command parameters to pass back to options dialog
self.Map = disp.getRender()
@@ -137,6 +136,8 @@
def AddLayer(self, idx, type):
self.first = True
+ params = '' # no initial options parameters
+
if type == 'command':
# generic command layer
self.ctrl = wx.TextCtrl(self, id=wx.ID_ANY, value='',
@@ -190,47 +191,47 @@
self.SetItemImage(layer, self.rast_icon)
self.SetItemText(layer, 'raster (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.rast', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.rast', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'rgb':
self.SetItemImage(layer, self.rgb_icon)
self.SetItemText(layer, 'RGB (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.rgb', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.rgb', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'his':
self.SetItemImage(layer, self.his_icon)
self.SetItemText(layer, 'HIS (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.his', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.his', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'rastleg':
self.SetItemImage(layer, self.leg_icon)
self.SetItemText(layer, 'legend (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.legend', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.legend', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'vector':
self.SetItemImage(layer, self.vect_icon)
self.SetItemText(layer, 'vector (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.vect', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.vect', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'thememap':
self.SetItemImage(layer, self.theme_icon)
self.SetItemText(layer, 'thematic map (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.vect.thematic', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.vect.thematic', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'themechart':
self.SetItemImage(layer, self.chart_icon)
self.SetItemText(layer, 'thematic charts (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.vect.chart', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.vect.chart', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'grid':
self.SetItemImage(layer, self.grid_icon)
self.SetItemText(layer, 'grid (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.grid', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.grid', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'labels':
self.SetItemImage(layer, self.labels_icon)
self.SetItemText(layer, 'vector labels (double click to set properties)')
# launch the properties dialog
- menuform.GUI().parseCommand('d.labels', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.labels', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif type == 'command':
self.SetItemImage(layer, self.cmd_icon)
elif type == 'group':
@@ -245,26 +246,27 @@
layer = event.GetItem()
self.layer_selected = layer
completed = ''
+ params = self.GetPyData(layer)[1]
# When double clicked or first added, open options dialog
if self.layertype[layer] == 'raster':
- menuform.GUI().parseCommand('d.rast', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.rast', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'rgb':
- menuform.GUI().parseCommand('d.rgb', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.rgb', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'his':
- menuform.GUI().parseCommand('d.his', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.his', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'rastleg':
- menuform.GUI().parseCommand('d.legend', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.legend', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'vector':
- menuform.GUI().parseCommand('d.vect', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.vect', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'thememap':
- menuform.GUI().parseCommand('d.vect.thematic', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.vect.thematic', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'themechart':
- menuform.GUI().parseCommand('d.vect.chart', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.vect.chart', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'grid':
- menuform.GUI().parseCommand('d.grid', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.grid', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'labels':
- menuform.GUI().parseCommand('d.labels', gmpath, completed=(self.getOptData,layer,self.params), parentframe=self)
+ menuform.GUI().parseCommand('d.labels', gmpath, completed=(self.getOptData,layer,params), parentframe=self)
elif self.layertype[layer] == 'group':
if self.IsExpanded(layer):
self.Collapse(layer)
@@ -449,9 +451,7 @@
# change parameters for item in layers list in render.Map
self.changeLayer(layer)
- self.params = params
-
def writeDCommand(self, dcmd):
# echos d.* command to output console
global goutput
From barton at grass.itc.it Mon Apr 2 18:04:09 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 18:04:10 2007
Subject: [grass-addons] r398 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021604.l32G49cL005499@grass.itc.it>
Author: barton
Date: 2007-04-02 18:03:59 +0200 (Mon, 02 Apr 2007)
New Revision: 398
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Decoration parameters now also maintain their previously set options
and insert them into the options dialog.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-02 15:54:33 UTC (rev 397)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-02 16:03:59 UTC (rev 398)
@@ -400,7 +400,6 @@
for ovlfile in Map.ovlist:
if os.path.isfile(ovlfile) and os.path.getsize(ovlfile):
img = wx.Image(ovlfile, wx.BITMAP_TYPE_ANY)
- img.ConvertAlphaToMask()
ovlist.append(img)
self.imagedict[img] = ovlist.index(img) # set image PeudoDC ID
return ovlist
@@ -415,7 +414,7 @@
img = wx.Image(Map.mapfile, wx.BITMAP_TYPE_ANY)
else:
img = None
-
+
self.imagedict[img] = 99 # set image PeudoDC ID
return img
@@ -496,11 +495,13 @@
x,y = self.lastpos
dx = event.GetX() - x
dy = event.GetY() - y
+ self.pdc.SetBackground(wx.Brush(self.GetBackgroundColour()))
r = self.pdc.GetIdBounds(id)
self.pdc.TranslateId(id, dx, dy)
- r2 = self.pdc.GetIdBounds(id)
- r = r.Union(r2)
- r.Inflate(4,4)
+ if id != 99:
+ r2 = self.pdc.GetIdBounds(id)
+ r = r.Union(r2)
+ r.Inflate(4,4)
self.RefreshRect(r, False)
self.lastpos = (event.GetX(),event.GetY())
@@ -590,11 +591,12 @@
end = (currpos[0]-self.mouse['begin'][0], \
currpos[1]-self.mouse['begin'][1])
# dragging or drawing box with left button
- if self.mouse['box'] == 'drag':
+ if self.mouse['box'] == 'pan':
self.DragMap(end)
+ self.DragItem(99, event)
# dragging decoration overlay item
- elif self.mouse['box'] == 'point' and self.dragid != None:
+ elif self.mouse['box'] == 'point' and self.dragid != None and self.dragid != 99:
self.DragItem(self.dragid, event)
# dragging something else?
@@ -615,12 +617,15 @@
#l = self.pdc.FindObjectsByBBox(x, y)
l = self.pdc.FindObjects(x, y, hitradius)
if l:
- self.pdc.SetIdGreyedOut(id=l[0], greyout=(not self.pdc.GetIdGreyedOut(id=l[0])))
- self.Refresh()
- self.Update()
-# r = self.pdc.GetIdBounds(l[0])
-# r.Inflate(4,4)
-# self.RefreshRect(r, False)
+ id = l[0]
+ self.pdc.SetId(id)
+ if self.pdc.GetIdGreyedOut(id) == True:
+ self.pdc.SetIdGreyedOut(id, False)
+ else:
+ self.pdc.SetIdGreyedOut(id, True)
+ r = self.pdc.GetIdBounds(id)
+ r.Inflate(4,4)
+ self.RefreshRect(r, False)
# store current mouse position
self.mouse['pos'] = event.GetPositionTuple()[:]
@@ -863,7 +868,7 @@
# decoration overlays
self.ovlchk = self.MapWindow.ovlchk
self.ovlcoords = self.MapWindow.ovlcoords
-
+ self.params = {} # previously set decoration options parameters to insert into options dialog
#
# Bind various events
# ONLY if we are running from GIS manager
@@ -1021,7 +1026,7 @@
"""
Panning, set mouse to drag
"""
- self.MapWindow.mouse['box'] = "drag"
+ self.MapWindow.mouse['box'] = "pan"
self.MapWindow.zoomtype = 0
event.Skip()
@@ -1130,6 +1135,11 @@
Handler for scale/arrow map decoration menu selection.
"""
ovltype = 0 # index for overlay layer in render
+ if ovltype in self.params:
+ params = self.params[ovltype]
+ else:
+ params = ''
+
ovlist = self.MapWindow.GetOverlay()
if ovlist == []: return
img = ovlist[0]
@@ -1144,7 +1154,8 @@
cmd='d.barscale',
drawid=id,
checktxt = "Show/hide scale and arrow",
- ctrltxt = "scale object")
+ ctrltxt = "scale object",
+ params = params)
dlg.CenterOnScreen()
@@ -1164,6 +1175,11 @@
Handler for legend map decoration menu selection.
"""
ovltype = 1 # index for overlay layer in render
+ if ovltype in self.params:
+ params = self.params[ovltype]
+ else:
+ params = ''
+
ovlist = self.MapWindow.GetOverlay()
if ovlist == []: return
img = ovlist[1]
@@ -1178,7 +1194,8 @@
cmd='d.legend',
drawid=id,
checktxt = "Show/hide legend",
- ctrltxt = "legend object")
+ ctrltxt = "legend object",
+ params = params)
dlg.CenterOnScreen()
@@ -1193,7 +1210,7 @@
self.MapWindow.UpdateMap()
dlg.Destroy()
- def getOptData(self, dcmd, type):
+ def getOptData(self, dcmd, type, params):
"""
Callback method for decoration overlay command generated by
dialog created in menuform.py
@@ -1202,12 +1219,14 @@
# Reset comand and rendering options in render.Map. Always render decoration.
# Showing/hiding handled by PseudoDC
Map.changeOverlay(type=type, command=dcmd, l_active=True, l_render=False)
+ self.params[type] = params
# end of class MapFrame
class DecDialog(wx.Dialog):
def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=wx.DEFAULT_DIALOG_STYLE, ovltype=0, cmd='d.barscale', drawid=None, checktxt='', ctrltxt=''):
+ style=wx.DEFAULT_DIALOG_STYLE, ovltype=0, cmd='d.barscale',
+ drawid=None, checktxt='', ctrltxt='', params=''):
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
"""
Controls setting options and displaying/hiding map overlay decorations
@@ -1217,6 +1236,7 @@
self.drawid = drawid
self.ovlcmd = cmd
self.ovlchk = self.Parent.MapWindow.ovlchk
+ self.params = params #previously set decoration options to pass back to options dialog
sizer = wx.BoxSizer(wx.VERTICAL)
@@ -1268,7 +1288,7 @@
"""
Sets option for decoration map overlays
"""
- self.params = [] # parameters to insert into dialog (not working)
+
menuform.GUI().parseCommand(self.ovlcmd, gmpath,
completed=(self.Parent.getOptData,self.ovltype,self.params),
parentframe=None)
From cepicky at grass.itc.it Mon Apr 2 18:29:10 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Mon Apr 2 18:29:11 2007
Subject: [grass-addons] r399 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021629.l32GTAOJ006089@grass.itc.it>
Author: cepicky
Date: 2007-04-02 18:29:10 +0200 (Mon, 02 Apr 2007)
New Revision: 399
Modified:
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
small bugfix
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 16:03:59 UTC (rev 398)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 16:29:10 UTC (rev 399)
@@ -136,7 +136,7 @@
def AddLayer(self, idx, type):
self.first = True
- params = '' # no initial options parameters
+ params = {} # no initial options parameters
if type == 'command':
# generic command layer
From barton at grass.itc.it Mon Apr 2 18:48:15 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 18:48:17 2007
Subject: [grass-addons] r400 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021648.l32GmFAi006526@grass.itc.it>
Author: barton
Date: 2007-04-02 18:48:07 +0200 (Mon, 02 Apr 2007)
New Revision: 400
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
Bug fix for image not found
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-02 16:29:10 UTC (rev 399)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-02 16:48:07 UTC (rev 400)
@@ -55,7 +55,7 @@
self.InsertColumn(i, column)
self.SetColumnWidth(i, 5)
i += 1
- lengths.append(1) #
+ lengths.append(1) #
# FIXME: subprocess.Popen should be used
@@ -77,7 +77,7 @@
if (j % 2) == 0:
self.SetItemBackgroundColour(j, '#e6f1f5')
j = j + 1
-
+
# setting column widths
i = 0
for length in lengths:
@@ -95,8 +95,8 @@
self.table = MyListCtrl(self, -1, self.tablename)
-
+
self.Bind(wx.EVT_SIZE, self.OnSize)
filemenu= wx.Menu()
@@ -118,7 +118,7 @@
self.Bind(wx.EVT_MENU, self.OnExit, id=ID_EXIT)
tb = self.CreateToolBar( wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT)
- tb.AddSimpleTool(10, wx.Bitmap('images/db_open_table.png'), 'Open table')
+ tb.AddSimpleTool(10, wx.Bitmap(os.path.join(imagepath, 'db_open_table.png')), 'Open table')
#tb.AddSimpleTool(20, wx.Bitmap('images/up.png'), 'Up one directory')
#tb.AddSimpleTool(30, wx.Bitmap('images/home.png'), 'Home')
#tb.AddSimpleTool(40, wx.Bitmap('images/refresh.png'), 'Refresh')
From barton at grass.itc.it Mon Apr 2 18:49:02 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 18:49:04 2007
Subject: [grass-addons] r401 - trunk/grassaddons/gui/images
Message-ID: <200704021649.l32Gn2wu006547@grass.itc.it>
Author: barton
Date: 2007-04-02 18:48:53 +0200 (Mon, 02 Apr 2007)
New Revision: 401
Modified:
trunk/grassaddons/gui/images/__init__.py
Log:
update to include new images. I don't know if this is needed or not.
Modified: trunk/grassaddons/gui/images/__init__.py
===================================================================
--- trunk/grassaddons/gui/images/__init__.py 2007-04-02 16:48:07 UTC (rev 400)
+++ trunk/grassaddons/gui/images/__init__.py 2007-04-02 16:48:53 UTC (rev 401)
@@ -2,4 +2,7 @@
"grass.map.gif",
"grass.smlogo.gif",
"grasslogo_big.gif",
+ "db_open_table.png",
+ "grass_db.png",
+ "grass_sql.png",
]
From cepicky at grass.itc.it Mon Apr 2 19:47:27 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Mon Apr 2 19:47:28 2007
Subject: [grass-addons] r402 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704021747.l32HlRvv007247@grass.itc.it>
Author: cepicky
Date: 2007-04-02 19:47:26 +0200 (Mon, 02 Apr 2007)
New Revision: 402
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/gui_modules/menuform.py
trunk/grassaddons/gui/wxgui.py
Log:
new table, sorting possible
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-02 16:48:53 UTC (rev 401)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-02 17:47:26 UTC (rev 402)
@@ -1,195 +1,204 @@
-#!/usr/bin/python
"""
Database browser for GRASS GIS >= 7
This program is based on FileHunter, publicated in "The wxPython Linux
Tutorial" on wxPython WIKI pages.
+It also uses some functions from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/426407
+
Usage:
dbm.py table_name
"""
-############################################################################
-#
-# MODULE: dbm.py
-# AUTHOR(S): Jachym Cepicky jachym les-ejk cz
-# PURPOSE: Database manager for vector attribute tables stored in
-# GRASS GIS
-# COPYRIGHT: (C) 2007 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.
-#
-############################################################################
+import wx
+import wx.lib.mixins.listctrl as listmix
-# discussion:
-# using database drivers is IMHO impossible
-# so, first step: parsing output form db.* commands and using SQL for
-# manipulation
+import sys,os
+
+#----------------------------------------------------------------------
+class Log:
+ r"""\brief Needed by the wxdemos.
+ The log output is redirected to the status bar of the containing frame.
+ """
-import wx
-import os,sys
-import time
+ def WriteText(self,text_string):
+ self.write(text_string)
-import grassenv
-import images
-imagepath = images.__path__[0]
-sys.path.append(imagepath)
+ def write(self,text_string):
+ wx.GetApp().GetTopWindow().SetStatusText(text_string)
-ID_BUTTON=100
-ID_EXIT=200
+#----------------------------------------------------------------------
+# The panel you want to test (TestVirtualList)
+#----------------------------------------------------------------------
-class MyListCtrl(wx.ListCtrl):
- def __init__(self, parent, id, tablename=None):
- wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT, )
+class TestVirtualList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
+ def __init__(self, parent,log,tablename):
+ wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
+ self.log=log
+ self.tablename = tablename
- lengths =[]
+ #adding some attributes (colourful background for each item rows)
+ self.attr1 = wx.ListItemAttr()
+ self.attr1.SetBackgroundColour("light blue")
+ self.attr2 = wx.ListItemAttr()
+ self.attr2.SetBackgroundColour("white")
+
+ #building the columns
+ i = 0
# FIXME: subprocess.Popen should be used
# FIXME: Maximal number of columns, when the GUI is still usable
- i = 0
for column in os.popen("db.columns table=%s" %
- (tablename)).readlines():
+ (self.tablename)).readlines():
column = column.strip()
self.InsertColumn(i, column)
- self.SetColumnWidth(i, 5)
+ self.SetColumnWidth(i, 50)
i += 1
- lengths.append(1) #
-
+ #These two should probably be passed to init more cleanly
+ #setting the numbers of items = number of elements in the dictionary
+ self.itemDataMap = {}
+ self.itemIndexMap = []
# FIXME: subprocess.Popen should be used
# FIXME: Max. number of rows, while the GUI is still usable
- j = 0
- for line in os.popen("""db.select -c sql="SELECT * FROM %s" """ % tablename):
+ i = 0
+ for line in os.popen("""db.select -c sql="SELECT * FROM %s" """ % self.tablename):
attributes = line.strip().split("|")
-
- k = 0
+ self.itemDataMap[i] = []
for attribute in attributes:
- if len(attribute) > lengths[k]:
- lengths[k] = len(attribute)
- if k == 0:
- self.InsertStringItem(j, attribute)
- else:
- self.SetStringItem(j, k, attribute)
- k += 1
+ self.itemDataMap[i].append(attribute)
+ self.itemIndexMap.append(i)
+ i += 1
+ self.SetItemCount(len(self.itemDataMap))
+
+ #mixins
+ listmix.ListCtrlAutoWidthMixin.__init__(self)
+ listmix.ColumnSorterMixin.__init__(self, 3)
- if (j % 2) == 0:
- self.SetItemBackgroundColour(j, '#e6f1f5')
- j = j + 1
+ #sort by genre (column 2), A->Z ascending order (1)
+ self.SortListItems(0, 1)
- # setting column widths
- i = 0
- for length in lengths:
- self.SetColumnWidth(i, (length+5)*12)
- i += 1
+ #events
+ self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected)
+ self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
+ self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected)
+ self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
+ def OnColClick(self,event):
+ event.Skip()
-class DBHunter(wx.Frame):
- def __init__(self, parent, id, title, tablename):
- wx.Frame.__init__(self, parent, -1, title)
+ def OnItemSelected(self, event):
+ self.currentItem = event.m_itemIndex
+ self.log.WriteText('OnItemSelected: "%s", "%s"\n' %
+ (self.currentItem,
+ self.GetItemText(self.currentItem)))
- global imagepath
- self.tablename = tablename
- self.SetIcon(wx.Icon(os.path.join(imagepath,'grass_db.png'), wx.BITMAP_TYPE_ANY))
+ def OnItemActivated(self, event):
+ self.currentItem = event.m_itemIndex
+ self.log.WriteText("OnItemActivated: %s\nTopItem: %s\n" %
+ (self.GetItemText(self.currentItem), self.GetTopItem()))
+ def getColumnText(self, index, col):
+ item = self.GetItem(index, col)
+ return item.GetText()
- self.table = MyListCtrl(self, -1, self.tablename)
+ def OnItemDeselected(self, evt):
+ self.log.WriteText("OnItemDeselected: %s" % evt.m_itemIndex)
- self.Bind(wx.EVT_SIZE, self.OnSize)
+ #---------------------------------------------------
+ # These methods are callbacks for implementing the
+ # "virtualness" of the list...
- filemenu= wx.Menu()
- filemenu.Append(ID_EXIT,"E&xit"," Terminate the program")
- editmenu = wx.Menu()
- netmenu = wx.Menu()
- showmenu = wx.Menu()
- configmenu = wx.Menu()
- helpmenu = wx.Menu()
+ def OnGetItemText(self, item, col):
+ index=self.itemIndexMap[item]
+ s = self.itemDataMap[index][col]
+ return s
- menuBar = wx.MenuBar()
- menuBar.Append(filemenu,"&File")
- menuBar.Append(editmenu, "&Edit")
- menuBar.Append(netmenu, "&Net")
- menuBar.Append(showmenu, "&Show")
- menuBar.Append(configmenu, "&Config")
- menuBar.Append(helpmenu, "&Help")
- self.SetMenuBar(menuBar)
- self.Bind(wx.EVT_MENU, self.OnExit, id=ID_EXIT)
+ # def OnGetItemImage(self, item):
+ # index=self.itemIndexMap[item]
+ # if ( index % 2) == 0:
- tb = self.CreateToolBar( wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT)
- tb.AddSimpleTool(10, wx.Bitmap(os.path.join(imagepath, 'db_open_table.png')), 'Open table')
- #tb.AddSimpleTool(20, wx.Bitmap('images/up.png'), 'Up one directory')
- #tb.AddSimpleTool(30, wx.Bitmap('images/home.png'), 'Home')
- #tb.AddSimpleTool(40, wx.Bitmap('images/refresh.png'), 'Refresh')
- #tb.AddSeparator()
- #tb.AddSimpleTool(50, wx.Bitmap('images/write.png'), 'Editor')
- #tb.AddSimpleTool(60, wx.Bitmap('images/terminal.png'), 'Terminal')
- #tb.AddSeparator()
- #tb.AddSimpleTool(70, wx.Bitmap('images/help.png'), 'Help')
- tb.Realize()
+ def OnGetItemAttr(self, item):
+ index=self.itemIndexMap[item]
- #self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
+ return self.attr2
+ #if ( index % 2) == 0:
+ # return self.attr2
+ #else:
+ # return self.attr1
- #button1 = wx.Button(self, ID_BUTTON + 1, "F3 View")
- #button2 = wx.Button(self, ID_BUTTON + 2, "F4 Edit")
- #button3 = wx.Button(self, ID_BUTTON + 3, "F5 Copy")
- #button4 = wx.Button(self, ID_BUTTON + 4, "F6 Move")
- #button5 = wx.Button(self, ID_BUTTON + 5, "F7 Mkdir")
- #button6 = wx.Button(self, ID_BUTTON + 6, "F8 Delete")
- #button7 = wx.Button(self, ID_BUTTON + 7, "F9 Rename")
- #button8 = wx.Button(self, ID_EXIT, "F10 Quit")
+ #---------------------------------------------------
+ # Matt C, 2006/02/22
+ # Here's a better SortItems() method --
+ # the ColumnSorterMixin.__ColumnSorter() method already handles the ascending/descending,
+ # and it knows to sort on another column if the chosen columns have the same value.
- # self.sizer2.Add(button1, 1, wx.EXPAND)
- # self.sizer2.Add(button2, 1, wx.EXPAND)
- # self.sizer2.Add(button3, 1, wx.EXPAND)
- # self.sizer2.Add(button4, 1, wx.EXPAND)
- # self.sizer2.Add(button5, 1, wx.EXPAND)
- # self.sizer2.Add(button6, 1, wx.EXPAND)
- # self.sizer2.Add(button7, 1, wx.EXPAND)
- # self.sizer2.Add(button8, 1, wx.EXPAND)
+ def SortItems(self,sorter=cmp):
+ items = list(self.itemDataMap.keys())
+ items.sort(sorter)
+ self.itemIndexMap = items
+
+ # redraw the list
+ self.Refresh()
- self.Bind(wx.EVT_BUTTON, self.OnExit, id=ID_EXIT)
+ # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
+ def GetListCtrl(self):
+ return self
- self.sizer = wx.BoxSizer(wx.VERTICAL)
- #self.sizer.Add(self.splitter,1,wx.EXPAND)
- self.sizer.Add(self.table,1, wx.EXPAND | wx.ALL, 3)
- #self.sizer.Add(self.sizer2,0,wx.EXPAND)
- self.SetSizer(self.sizer)
+ # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
+ #def GetSortImages(self):
+ # return (self.sm_dn, self.sm_up)
- #size = (wx
- #self.SetSize(size)
+ #XXX Looks okay to remove this one (was present in the original demo)
+ #def getColumnText(self, index, col):
+ # item = self.GetItem(index, col)
+ # return item.GetText()
- self.sb = self.CreateStatusBar()
- self.dbcon = "table: %s; " % self.tablename
- for line in os.popen("db.connect -p").readlines():
- self.dbcon += line.strip() +"; "
- self.sb.SetStatusText(self.dbcon)
- self.Center()
- self.Show(True)
+#----------------------------------------------------------------------
+# The main window
+#----------------------------------------------------------------------
+# This is where you populate the frame with a panel from the demo.
+# original line in runTest (in the demo source):
+# win = TestPanel(nb, log)
+# this is changed to:
+# self.win=TestPanel(self,log)
+#----------------------------------------------------------------------
+class AttributeManager(wx.Frame):
- def OnExit(self,e):
- self.Close(True)
+ def __init__(self, parent, id, title, size, style = wx.DEFAULT_FRAME_STYLE, table=None ):
- def OnSize(self, event):
- size = self.GetSize()
- #self.splitter.SetSashPosition(size.x / 2)
- self.sb.SetStatusText(self.dbcon)
- event.Skip()
+ wx.Frame.__init__(self, parent, id, title, size=size, style=style)
+ self.CreateStatusBar(1)
- def OnDoubleClick(self, event):
- size = self.GetSize()
- #self.splitter.SetSashPosition(size.x / 2)
+ log=Log()
-if __name__ == "__main__":
+ self.win = TestVirtualList(self, log,tablename=table)
+ self.Show()
- if len(sys.argv) != 2:
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+
+ if len(argv) != 2:
print >>sys.stderr, __doc__
sys.exit()
- app = wx.App(0)
- dbmanager = DBHunter(None, -1, 'GRASS Attribute Table Manager',sys.argv[1])
+ # Command line arguments of the script to be run are preserved by the
+ # hotswap.py wrapper but hotswap.py and its options are removed that
+ # sys.argv looks as if no wrapper was present.
+ #print "argv:", `argv`
+
+ #some applications might require image handlers
+ #wx.InitAllImageHandlers()
+
+ app = wx.PySimpleApp()
+ f = AttributeManager(None, -1, "GRASS Attribute Table Manager",wx.Size(500,300),table=argv[1])
app.MainLoop()
+
+
+if __name__ == '__main__':
+ main()
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 16:48:53 UTC (rev 401)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 17:47:26 UTC (rev 402)
@@ -827,6 +827,7 @@
else:
get_dcmd = completed[0]
layer = completed[1]
+ print completed
dcmd_params.update(completed[2])
cmdlst = cmd.split(' ')
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-02 16:48:53 UTC (rev 401)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-02 17:47:26 UTC (rev 402)
@@ -330,7 +330,7 @@
if mapset == grassenv.env["MAPSET"]:
from gui_modules import dbm
- self.dbmanager = gui_modules.dbm.DBHunter(None, -1,"GRASS Attribute Table Manager: %s" % map,map)
+ self.dbmanager = gui_modules.dbm.AttributeManager(None, -1,"GRASS Attribute Table Manager: %s" % map, size=wx.Size(500,300),table=map)
def newDisplay(self, event=None):
From barton at grass.itc.it Mon Apr 2 20:00:37 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 20:00:37 2007
Subject: [grass-addons] r403 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021800.l32I0bA8008305@grass.itc.it>
Author: barton
Date: 2007-04-02 20:00:28 +0200 (Mon, 02 Apr 2007)
New Revision: 403
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
Fix control for multiple entries that are not check boxes. Changed from
combobox to a text control. Valid range shown in label rather than in
combobox entry.
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 17:47:26 UTC (rev 402)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 18:00:28 UTC (rev 403)
@@ -576,16 +576,17 @@
v_count += 1
which_sizer.Add( hSizer, 0, wx.ADJUST_MINSIZE, 5)
else:
- txt = wx.StaticText(which_panel, label = title + ':' )
+ txt = wx.StaticText(which_panel, label = title +
+ '. Valid range=' + str(valuelist).strip("[]'") + ':' )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
- self.cb = wx.ComboBox(which_panel, -1, p['default'],
- wx.Point(-1, -1), wx.Size(STRING_ENTRY_WIDTH, -1),
- valuelist, wx.CB_DROPDOWN)
- if p['value'] != '': self.cb.SetValue(p['value']) # parameter previously set
- which_sizer.Add(self.cb, 0, wx.ADJUST_MINSIZE, 5)
- self.paramdict[self.cb] = ID_PARAM_START + p_count
- self.cb.Bind( wx.EVT_COMBOBOX, self.EvtComboBox)
+ self.txt2 = wx.TextCtrl(which_panel, value = p['default'],
+ size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
+ if p['value'] != '': self.txt2.SetValue(p['value']) # parameter previously set
+ which_sizer.Add(self.txt2, 0, wx.ADJUST_MINSIZE, 5)
+ self.paramdict[self.txt2] = ID_PARAM_START + p_count
+ self.txt2.Bind(wx.EVT_TEXT, self.EvtText)
+
# text entry
if (p['type'] in ('string','integer','float')
and len(p['values']) == 0
From barton at grass.itc.it Mon Apr 2 21:26:38 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 21:26:38 2007
Subject: [grass-addons] r404 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021926.l32JQcPO010677@grass.itc.it>
Author: barton
Date: 2007-04-02 21:26:32 +0200 (Mon, 02 Apr 2007)
New Revision: 404
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
Removed debugging text
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 18:00:28 UTC (rev 403)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 19:26:32 UTC (rev 404)
@@ -828,7 +828,6 @@
else:
get_dcmd = completed[0]
layer = completed[1]
- print completed
dcmd_params.update(completed[2])
cmdlst = cmd.split(' ')
From barton at grass.itc.it Mon Apr 2 21:39:17 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 21:39:18 2007
Subject: [grass-addons] r405 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021939.l32JdHlS011032@grass.itc.it>
Author: barton
Date: 2007-04-02 21:39:10 +0200 (Mon, 02 Apr 2007)
New Revision: 405
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
Further fix for multiple entry values. Combobox back for lists of
values, text entry for value with range of acceptable, checkboxes for
on/off values.
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 19:26:32 UTC (rev 404)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-02 19:39:10 UTC (rev 405)
@@ -575,7 +575,7 @@
self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBoxMulti)
v_count += 1
which_sizer.Add( hSizer, 0, wx.ADJUST_MINSIZE, 5)
- else:
+ elif len(valuelist) == 1:
txt = wx.StaticText(which_panel, label = title +
'. Valid range=' + str(valuelist).strip("[]'") + ':' )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
@@ -586,6 +586,16 @@
which_sizer.Add(self.txt2, 0, wx.ADJUST_MINSIZE, 5)
self.paramdict[self.txt2] = ID_PARAM_START + p_count
self.txt2.Bind(wx.EVT_TEXT, self.EvtText)
+ else:
+ txt = wx.StaticText(which_panel, label = title + ':' )
+ which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
+ self.cb = wx.ComboBox(which_panel, -1, p['default'],
+ wx.Point(-1, -1), wx.Size(STRING_ENTRY_WIDTH, -1),
+ valuelist, wx.CB_DROPDOWN)
+ if p['value'] != '': self.cb.SetValue(p['value']) # parameter previously set
+ which_sizer.Add(self.cb, 0, wx.ADJUST_MINSIZE, 5)
+ self.paramdict[self.cb] = ID_PARAM_START + p_count
+ self.cb.Bind( wx.EVT_COMBOBOX, self.EvtComboBox)
# text entry
if (p['type'] in ('string','integer','float')
From barton at grass.itc.it Mon Apr 2 21:53:51 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 2 21:53:53 2007
Subject: [grass-addons] r406 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704021953.l32JrprM011089@grass.itc.it>
Author: barton
Date: 2007-04-02 21:53:45 +0200 (Mon, 02 Apr 2007)
New Revision: 406
Modified:
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Fix bug in layer drag and drop. Send only command to render, not parameters.
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 19:39:10 UTC (rev 405)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-02 19:53:45 UTC (rev 406)
@@ -420,7 +420,7 @@
self.Map.addLayer(item=new, command=self.saveitem['windval'], l_active=self.saveitem['check'],
l_hidden=False, l_opacity=1, l_render=False)
else:
- self.Map.addLayer(item=new, command=self.saveitem['data'], l_active=self.saveitem['check'],
+ self.Map.addLayer(item=new, command=self.saveitem['data'][0], l_active=self.saveitem['check'],
l_hidden=False, l_opacity=self.saveitem['windval'], l_render=False)
self.reorderLayers()
From barton at grass.itc.it Tue Apr 3 04:50:38 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 3 04:50:39 2007
Subject: [grass-addons] r407 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704030250.l332ocd1016853@grass.itc.it>
Author: barton
Date: 2007-04-03 04:50:30 +0200 (Tue, 03 Apr 2007)
New Revision: 407
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
Docstring correction
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-02 19:53:45 UTC (rev 406)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-03 02:50:30 UTC (rev 407)
@@ -852,7 +852,7 @@
def delLayer(self, item):
"""
- Removes layer from list of layers, defined by name@mapset or id
+ Removes layer from list of layers, defined by layer ID
Parameters:
name - map name
From barton at grass.itc.it Tue Apr 3 04:53:47 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 3 04:53:49 2007
Subject: [grass-addons] r408 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704030253.l332rlX5016905@grass.itc.it>
Author: barton
Date: 2007-04-03 04:53:39 +0200 (Tue, 03 Apr 2007)
New Revision: 408
Modified:
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Fixing bugs for group layers and in drag and drop. Still an issue with
transparency/opacity.
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-03 02:50:30 UTC (rev 407)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-03 02:53:39 UTC (rev 408)
@@ -34,8 +34,8 @@
id=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.SUNKEN_BORDER,
ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
- CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT,
- disp=None, log=None):
+ CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT|
+ CT.TR_EDIT_LABELS, disp=None, log=None):
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style,ctstyle)
self.SetAutoLayout(True)
@@ -164,7 +164,7 @@
'', ct_type=1, wnd=self.ctrl )
elif (self.layer_selected and self.layer_selected != self.GetRootItem() and \
self.layertype[self.layer_selected] == 'group'):
- layer = self.InsertItem(self.layer_selected, self.GetPrevSibling(self.layer_selected),
+ layer = self.InsertItem(self.layer_selected, self.layer_selected,
'', ct_type=1, wnd=self.ctrl )
self.Expand(self.layer_selected)
else:
@@ -183,7 +183,8 @@
self.CheckItem(layer, checked=False)
# add layer to layers list in render.Map
- self.Map.addLayer(item=layer, command='', l_active=False,
+ if self.layertype[layer] != 'group':
+ self.Map.addLayer(item=layer, command='', l_active=False,
l_hidden=False, l_opacity=1, l_render=False)
# add text and icons for each layer type
@@ -275,11 +276,13 @@
def onDeleteLayer(self, event):
layer = event.GetItem()
- self.layertype.pop(layer)
# delete layer in render.Map
- self.Map.delLayer(item=layer)
+ if self.layertype[layer] != 'group':
+ self.Map.delLayer(item=layer)
+ self.layertype.pop(layer)
+
def onLayerChecked(self, event):
layer = event.GetItem()
checked = layer.IsChecked()
@@ -311,6 +314,7 @@
event.Skip()
def onOpacity(self, event):
+ print 'opacity event:', event.GetString()
if 'Spin' in str(event.GetEventObject()):
layer = self.layerctrl[event.GetEventObject()]
else:
@@ -332,8 +336,6 @@
def onExpandNode(self, event):
self.layer_selected = event.GetItem()
- print "###",self.layertype
- print "###",self.layer_selected
if self.layertype[self.layer_selected] == 'group':
self.SetItemImage(self.layer_selected, self.folder_open)
@@ -352,10 +354,14 @@
self.saveitem['image'] = self.GetItemImage(self.dragItem, 0)
self.saveitem['text'] = self.GetItemText(self.dragItem)
self.saveitem['wind'] = self.GetItemWindow(self.dragItem)
- self.saveitem['windval'] = self.GetItemWindow(self.dragItem).GetValue()
- self.saveitem['data'] = self.GetPyData(self.dragItem)
+ if self.layertype[self.dragItem] == 'group':
+ self.saveitem['windval'] = None
+ self.saveitem['data'] = None
+ else:
+ self.saveitem['windval'] = self.GetItemWindow(self.dragItem).GetValue()
+ self.saveitem['data'] = self.GetPyData(self.dragItem)
else:
- print ("Cant drag a node that has children")
+ print ("Can't drag a node that has children")
def onEndDrag(self, event):
"""
@@ -363,69 +369,78 @@
delete original at old position
"""
-
# Make sure this memeber exists.
try:
old = self.dragItem
except:
return
- # recreate old layer at new position
+ # recreate spin/text control for layer
if self.layertype[old] == 'command':
- self.dragctrl = wx.TextCtrl(self, id=wx.ID_ANY, value='',
+ newctrl = wx.TextCtrl(self, id=wx.ID_ANY, value='',
pos=wx.DefaultPosition, size=(250,40),
style=wx.TE_MULTILINE|wx.TE_WORDWRAP)
- self.dragctrl.Bind(wx.EVT_TEXT_ENTER, self.onCmdChanged)
+ newctrl.Bind(wx.EVT_TEXT_ENTER, self.onCmdChanged)
+ elif self.layertype[old] == 'group':
+ newctrl = None
else:
- self.dragctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50),
+ newctrl = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50),
style=wx.SP_ARROW_KEYS)
- self.dragctrl.SetRange(1,100)
- self.dragctrl.SetValue(100)
- self.dragctrl.Bind(wx.EVT_SPINCTRL, self.onOpacity)
+ newctrl.SetRange(1,100)
+ newctrl.SetValue(100)
+ newctrl.Bind(wx.EVT_TEXT, self.onOpacity)
-
- #If we dropped somewhere that isn't on top of an item, ignore the event
+ # Decide where to put new layer and put it there
flag = self.HitTest(event.GetPoint())[1]
if flag & wx.TREE_HITTEST_ABOVE:
new = self.PrependItem(self.root, text=self.saveitem['text'], \
- ct_type=1, wnd=self.dragctrl, image=self.saveitem['image'], \
+ ct_type=1, wnd=newctrl, image=self.saveitem['image'], \
data=self.saveitem['data'])
elif (flag & wx.TREE_HITTEST_BELOW) or (flag & wx.TREE_HITTEST_NOWHERE):
new = self.AppendItem(self.root, text=self.saveitem['text'], \
- ct_type=1, wnd=self.dragctrl, image=self.saveitem['image'], \
+ ct_type=1, wnd=newctrl, image=self.saveitem['image'], \
data=self.saveitem['data'])
else:
if not event.GetItem():
return
else:
afteritem = event.GetItem()
- parent = self.GetItemParent(afteritem)
- new = self.InsertItem(parent, afteritem, text=self.saveitem['text'], \
- ct_type=1, wnd=self.dragctrl, image=self.saveitem['image'], \
- data=self.saveitem['data'])
+ if self.layertype[afteritem] == 'group':
+ parent = afteritem
+ new = self.AppendItem(parent, text=self.saveitem['text'], \
+ ct_type=1, wnd=newctrl, image=self.saveitem['image'], \
+ data=self.saveitem['data'])
+ else:
+ parent = self.GetItemParent(afteritem)
+ new = self.InsertItem(parent, afteritem, text=self.saveitem['text'], \
+ ct_type=1, wnd=newctrl, image=self.saveitem['image'], \
+ data=self.saveitem['data'])
-
-
-
self.layertype[new] = self.saveitem['type']
self.CheckItem(new, checked=self.saveitem['check'])
- self.GetItemWindow(new).SetValue(self.saveitem['windval'])
+ if self.layertype[new] != 'group':
+ self.layerctrl[newctrl] = new
+ newctrl.SetValue(self.saveitem['windval'])
# delete layer at original position
- self.Delete(old)
+ self.Delete(old) # entry in render.Map layers list automatically deleted by onDeleteLayer handler
- # update layers list in render.Map
+ # Add new layer to layers list in render.Map
if self.saveitem['type'] == 'command':
self.Map.addLayer(item=new, command=self.saveitem['windval'], l_active=self.saveitem['check'],
l_hidden=False, l_opacity=1, l_render=False)
- else:
+
+ elif self.saveitem['type'] != 'group':
self.Map.addLayer(item=new, command=self.saveitem['data'][0], l_active=self.saveitem['check'],
l_hidden=False, l_opacity=self.saveitem['windval'], l_render=False)
- self.reorderLayers()
+ # completed drag and drop
self.drag = False
+ # reorder layers in render.Map to match new order after drag and drop
+ self.reorderLayers()
+
def getOptData(self, dcmd, layer, params):
for item in dcmd.split(' '):
if 'map=' in item:
@@ -462,13 +477,12 @@
add commands from data associated with
any valid and checked layers to layer list
"""
- # first empty the list of old layers
-# self.Map.Clean()
+
# make a list of visible layers
treelayers = []
vislayer = self.GetFirstVisibleItem()
for item in range(0,self.GetCount()):
- if self.IsItemChecked(vislayer):
+ if self.IsItemChecked(vislayer) and self.layertype[vislayer] != 'group':
treelayers.append(vislayer)
if self.GetNextVisible(vislayer) == None:
break
@@ -481,7 +495,8 @@
self.Map.changeOpacity(layer, opacity)
def changeChecked(self, layer, check):
- self.Map.changeActive(layer, check)
+ if self.layertype[layer] != 'group':
+ self.Map.changeActive(layer, check)
def changeLayer(self, layer):
if self.layertype[layer] == 'command':
@@ -492,7 +507,7 @@
hidden = not self.IsVisible(layer)
self.Map.changeLayer(item=layer, command=cmd, l_active=chk,
l_hidden=hidden, l_opacity=opac, l_render=False)
- else:
+ elif self.layertype[layer] != 'group':
if self.GetPyData(layer)[0] != None:
cmd = self.GetPyData(layer)[0]
opac = float(self.GetItemWindow(layer).GetValue())/100
From barton at grass.itc.it Tue Apr 3 06:49:30 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 3 06:49:31 2007
Subject: [grass-addons] r409 - trunk/grassaddons/gui
Message-ID: <200704030449.l334nUid018723@grass.itc.it>
Author: barton
Date: 2007-04-03 06:49:19 +0200 (Tue, 03 Apr 2007)
New Revision: 409
Modified:
trunk/grassaddons/gui/Init.sh
trunk/grassaddons/gui/wxgrass
Log:
Implementing Glynn Clement's suggestions. Change to start gui non-modally from init.sh. Script wxgrass must be called with & run non-modally
Modified: trunk/grassaddons/gui/Init.sh
===================================================================
--- trunk/grassaddons/gui/Init.sh 2007-04-03 02:53:39 UTC (rev 408)
+++ trunk/grassaddons/gui/Init.sh 2007-04-03 04:49:19 UTC (rev 409)
@@ -758,7 +758,7 @@
wx)
# comming soon, see ^
- "$GISBASE/scripts/wxgrass"
+ "$GISBASE/scripts/wxgrass &"
;;
# Ignore others
@@ -792,7 +792,7 @@
if [ "$GRASS_GUI" = "text" ] ; then
echo "Start the graphical user interface with: gis.m"
else
- echo "If required, restart the graphical user interface with: wxgrass"
+ echo "If required, restart the graphical user interface with: wxgrass &"
fi
echo "When ready to quit enter: exit"
Modified: trunk/grassaddons/gui/wxgrass
===================================================================
--- trunk/grassaddons/gui/wxgrass 2007-04-03 02:53:39 UTC (rev 408)
+++ trunk/grassaddons/gui/wxgrass 2007-04-03 04:49:19 UTC (rev 409)
@@ -8,9 +8,9 @@
SYSTEM=`uname -s`
if [ "$SYSTEM" = "Darwin" ] ; then
- pythonw "$GISBASE/etc/wx/wxgui.py" -name wxgui_py &
+ pythonw "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
else
- python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py &
+ python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
fi
exit 0
From barton at grass.itc.it Tue Apr 3 09:07:57 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 3 09:07:58 2007
Subject: [grass-addons] r410 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704030707.l3377vj1020174@grass.itc.it>
Author: barton
Date: 2007-04-03 09:07:44 +0200 (Tue, 03 Apr 2007)
New Revision: 410
Modified:
trunk/grassaddons/gui/gui_modules/render.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Fixed most overlay and opacity bugs.
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-03 04:49:19 UTC (rev 409)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-03 07:07:44 UTC (rev 410)
@@ -813,16 +813,17 @@
def addLayer(self, item, command, mapset=None, l_active=True, l_hidden=False,
l_opacity=1, l_render=False):
"""
- Adds generic layer to list of layers
+ Adds generic display command layer to list of layers
Layer Attributes:
- command - display command
- mapset - mapset name, default: current
+ command - display command
+ mapset - mapset name for backward compatibility.
+ - included in mapname in command
- l_active - see MapLayer class
- l_hidden
- l_opacity
- l_render - render an image
+ l_active - checked/not checked for display in layer tree
+ l_hidden - not used here
+ l_opacity - range from 0-1
+ l_render - render an image if False
Returns:
Added layer on success or None
@@ -852,12 +853,11 @@
def delLayer(self, item):
"""
- Removes layer from list of layers, defined by layer ID
+ Removes layer from list of layers, defined by layer
+ tree item ID
Parameters:
- name - map name
- mapset - mapset name, default: current
- id - index of the layer in layer list
+ item - wxPython ID for layer tree item
Returns:
Removed layer on success or None
@@ -879,19 +879,35 @@
return None
def reorderLayers(self, item_list):
-
- # make a new reordered list
+ """
+ Make a new reordered list to match reordered
+ layer tree - for drag and drop
+ """
temp = []
for item in item_list:
- temp.append(self.lookup[item])
+ layer = self.lookup[item]
+ temp.append(layer)
# replace original layers list with reordered one
self.layers = temp
+ return self.layers[-1]
+ def updateLookup(self, olditem, newitem):
+ """
+ Changes layer tree item associatd with rendering layer
+ in the lookup dictionary. Used with layer drag and drop.
+ """
+ layer = self.lookup[olditem]
+ self.lookup[newitem] = layer
+ # old lookup item will be deleted when layer is deleted
+
def changeLayer(self, item, command, mapset=None, l_active=True, l_hidden=False,
l_opacity=1, l_render=False):
+ """
+ Change the command and other other options for a layer
+ """
if not mapset:
mapset = self.env["MAPSET"]
@@ -919,6 +935,9 @@
return self.layers[-1]
def changeOpacity(self, item, l_opacity):
+ """
+ Changes opacity value for rendering.
+ """
# l_opacity must be <0;1>
if l_opacity < 0: l_opacity = 0
elif l_opacity > 1: l_opacity = 1
@@ -926,6 +945,9 @@
layer.opacity = l_opacity
def changeActive(self, item, activ):
+ """
+ Change the active state of a layer
+ """
layer = self.lookup[item]
layer.active = activ
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-03 04:49:19 UTC (rev 409)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-03 07:07:44 UTC (rev 410)
@@ -164,7 +164,7 @@
'', ct_type=1, wnd=self.ctrl )
elif (self.layer_selected and self.layer_selected != self.GetRootItem() and \
self.layertype[self.layer_selected] == 'group'):
- layer = self.InsertItem(self.layer_selected, self.layer_selected,
+ layer = self.PrependItem(self.layer_selected,
'', ct_type=1, wnd=self.ctrl )
self.Expand(self.layer_selected)
else:
@@ -314,7 +314,6 @@
event.Skip()
def onOpacity(self, event):
- print 'opacity event:', event.GetString()
if 'Spin' in str(event.GetEventObject()):
layer = self.layerctrl[event.GetEventObject()]
else:
@@ -323,8 +322,7 @@
if self.drag == False:
# change opacity parameter for item in layers list in render.Map
- self.changeOpacity(layer, opacity)
- event.Skip()
+ self.Map.changeOpacity(layer, opacity)
def onChangeSel(self, event):
layer = event.GetItem()
@@ -423,24 +421,19 @@
self.layerctrl[newctrl] = new
newctrl.SetValue(self.saveitem['windval'])
+ # update lookup dictionary in render.Map
+ if self.saveitem['type'] != 'group':
+ self.Map.updateLookup(old, new)
+
# delete layer at original position
self.Delete(old) # entry in render.Map layers list automatically deleted by onDeleteLayer handler
- # Add new layer to layers list in render.Map
- if self.saveitem['type'] == 'command':
- self.Map.addLayer(item=new, command=self.saveitem['windval'], l_active=self.saveitem['check'],
- l_hidden=False, l_opacity=1, l_render=False)
+ # reorder layers in render.Map to match new order after drag and drop
+ self.reorderLayers()
- elif self.saveitem['type'] != 'group':
- self.Map.addLayer(item=new, command=self.saveitem['data'][0], l_active=self.saveitem['check'],
- l_hidden=False, l_opacity=self.saveitem['windval'], l_render=False)
-
# completed drag and drop
self.drag = False
- # reorder layers in render.Map to match new order after drag and drop
- self.reorderLayers()
-
def getOptData(self, dcmd, layer, params):
for item in dcmd.split(' '):
if 'map=' in item:
From barton at grass.itc.it Tue Apr 3 09:12:35 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 3 09:12:36 2007
Subject: [grass-addons] r411 - trunk/grassaddons/gui
Message-ID: <200704030712.l337CZoI020203@grass.itc.it>
Author: barton
Date: 2007-04-03 09:12:25 +0200 (Tue, 03 Apr 2007)
New Revision: 411
Modified:
trunk/grassaddons/gui/Init.sh
Log:
Fixed bug in wxgrass startup. Now it starts non-modally.
Modified: trunk/grassaddons/gui/Init.sh
===================================================================
--- trunk/grassaddons/gui/Init.sh 2007-04-03 07:07:44 UTC (rev 410)
+++ trunk/grassaddons/gui/Init.sh 2007-04-03 07:12:25 UTC (rev 411)
@@ -758,7 +758,7 @@
wx)
# comming soon, see ^
- "$GISBASE/scripts/wxgrass &"
+ "$GISBASE/scripts/wxgrass" &
;;
# Ignore others
From cepicky at grass.itc.it Tue Apr 3 10:25:12 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 10:25:13 2007
Subject: [grass-addons] r412 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704030825.l338PCt6020400@grass.itc.it>
Author: cepicky
Date: 2007-04-03 10:25:12 +0200 (Tue, 03 Apr 2007)
New Revision: 412
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
status information works now
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 07:12:25 UTC (rev 411)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 08:25:12 UTC (rev 412)
@@ -20,12 +20,11 @@
r"""\brief Needed by the wxdemos.
The log output is redirected to the status bar of the containing frame.
"""
+ def __init__(self,parent):
+ self.parent = parent
- def WriteText(self,text_string):
- self.write(text_string)
-
def write(self,text_string):
- wx.GetApp().GetTopWindow().SetStatusText(text_string)
+ self.parent.SetStatusText(text_string.strip())
#----------------------------------------------------------------------
# The panel you want to test (TestVirtualList)
@@ -89,13 +88,13 @@
def OnItemSelected(self, event):
self.currentItem = event.m_itemIndex
- self.log.WriteText('OnItemSelected: "%s", "%s"\n' %
+ self.log.write('OnItemSelected: "%s", "%s"\n' %
(self.currentItem,
self.GetItemText(self.currentItem)))
def OnItemActivated(self, event):
self.currentItem = event.m_itemIndex
- self.log.WriteText("OnItemActivated: %s\nTopItem: %s\n" %
+ self.log.write("OnItemActivated: %s\nTopItem: %s\n" %
(self.GetItemText(self.currentItem), self.GetTopItem()))
def getColumnText(self, index, col):
@@ -103,7 +102,7 @@
return item.GetText()
def OnItemDeselected(self, evt):
- self.log.WriteText("OnItemDeselected: %s" % evt.m_itemIndex)
+ self.log.write("OnItemDeselected: %s" % evt.m_itemIndex)
#---------------------------------------------------
@@ -173,7 +172,7 @@
self.CreateStatusBar(1)
- log=Log()
+ log=Log(self)
self.win = TestVirtualList(self, log,tablename=table)
self.Show()
From neteler at grass.itc.it Tue Apr 3 13:35:46 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Tue Apr 3 13:35:47 2007
Subject: [grass-addons] r413 - in trunk/grassaddons: . i.landsat.dehaze
Message-ID: <200704031135.l33BZkUj022602@grass.itc.it>
Author: neteler
Date: 2007-04-03 13:35:46 +0200 (Tue, 03 Apr 2007)
New Revision: 413
Added:
trunk/grassaddons/i.landsat.dehaze/
trunk/grassaddons/i.landsat.dehaze/Makefile
trunk/grassaddons/i.landsat.dehaze/description.html
trunk/grassaddons/i.landsat.dehaze/i.landsat.dehaze
Log:
i.landsat.dehaze ported to GRASS 6 (former i.tm.dehaze)
Added: trunk/grassaddons/i.landsat.dehaze/Makefile
===================================================================
--- trunk/grassaddons/i.landsat.dehaze/Makefile (rev 0)
+++ trunk/grassaddons/i.landsat.dehaze/Makefile 2007-04-03 11:35:46 UTC (rev 413)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = i.landsat.dehaze
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Added: trunk/grassaddons/i.landsat.dehaze/description.html
===================================================================
--- trunk/grassaddons/i.landsat.dehaze/description.html (rev 0)
+++ trunk/grassaddons/i.landsat.dehaze/description.html 2007-04-03 11:35:46 UTC (rev 413)
@@ -0,0 +1,36 @@
+
DESCRIPTION
+
+i.landsat.dehaze applies a bandwise haze correction using tasscap4 (haze)
+and linear regression.
+
+
NOTES
+
+The regression based technique which determines a 'best fit' line for
+multispectral plots of pixels within homogenous cover types. The slope of
+the plot is proportional to the ratio of the reflective material (Crippen
+1987).
+
+
Last changed: $Date: 2006/09/07 09:24:10 $
Added: trunk/grassaddons/i.landsat.dehaze/i.landsat.dehaze
===================================================================
--- trunk/grassaddons/i.landsat.dehaze/i.landsat.dehaze (rev 0)
+++ trunk/grassaddons/i.landsat.dehaze/i.landsat.dehaze 2007-04-03 11:35:46 UTC (rev 413)
@@ -0,0 +1,198 @@
+#!/bin/sh
+
+# $Id: i.tm.dehaze,v 1.5 2002/10/30 08:51:49 markus Exp $
+# copyright Markus Neteler
+# License: GNU GPL
+#
+# Methodology:
+# Bandwise correction using tasscap4 (haze) and linear regression.
+# (Crippen 1987 approach)
+#
+# The regression based technique which determines a 'best fit' line for
+# multispectral plots of pixels within homogenous cover types. The slope of
+# the plot is proportional to the ratio of the reflective material (Crippen
+# 1987).
+#
+# http://www.forestry.umt.edu/academics/courses/FOR503/rs1.htm:
+# The correction technique is based on the fact that Thematic Mapper (TM)
+# band 7 is essentially free from atmospheric effects. Upon examining an
+# area in the image that is in deep shadow or a body of homogeneous deep
+# nonturbid water, the resulting reflectance value in band 7 is either 0 or
+# 1. A histogram of the reflectivity values in band 7 for this area starts
+# from 0 or 1. On the contrary, a histogram of the reflectivity values in
+# bands 1, 2 and 3 for the same area starts from much higher values as a
+# result of haze. This offset, characteristic for each one of the three
+# bands is subtracted from the initial reflectance values and the result is
+# a haze corrected image (Sabins 1987).
+#
+# The formular of linear regression is (r.linear.regression):
+# y=a[0]x[0] + a[1]
+
+
+#%Module
+#% description: De-hazing of a LANDSAT scene
+#% keywords: raster, imagery, dehaze
+#%End
+#%Option
+#% key: band1
+#% type: string
+#% required: yes
+#% multiple: no
+#% description: LANDSAT TM1 channel
+#% gisprompt: old,cell,raster
+#%End
+#%Option
+#% key: band2
+#% type: string
+#% required: yes
+#% multiple: no
+#% description: LANDSAT TM2 channel
+#% gisprompt: old,cell,raster
+#%End
+#%Option
+#% key: band3
+#% type: string
+#% required: yes
+#% multiple: no
+#% description: LANDSAT TM3 channel
+#% gisprompt: old,cell,raster
+#%End
+#%Option
+#% key: band4
+#% type: string
+#% required: yes
+#% multiple: no
+#% description: LANDSAT TM4 channel
+#% gisprompt: old,cell,raster
+#%End
+#%Option
+#% key: band5
+#% type: string
+#% required: yes
+#% multiple: no
+#% description: LANDSAT TM5 channel
+#% gisprompt: old,cell,raster
+#%End
+#%Option
+#% key: band7
+#% type: string
+#% required: yes
+#% multiple: no
+#% description: LANDSAT TM7 channel
+#% gisprompt: old,cell,raster
+#%End
+#%Option
+#% key: tasscap4
+#% type: string
+#% required: yes
+#% multiple: no
+#% description: Tasseled Cap 4 haze map
+#% gisprompt: old,cell,raster
+#%End
+
+if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." 1>&2
+ exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+ exec g.parser "$0" "$@"
+fi
+
+# setting environment, so that awk works properly in all languages
+unset LC_ALL
+LC_NUMERIC=C
+export LC_NUMERIC
+
+PROG=`basename $0`
+
+#define the names:
+tm1=$GIS_OPT_band1
+tm2=$GIS_OPT_band2
+tm3=$GIS_OPT_band3
+tm4=$GIS_OPT_band4
+tm5=$GIS_OPT_band5
+tm7=$GIS_OPT_band7
+tasscap=$GIS_OPT_tasscap4
+
+#test for file:
+eval `g.findfile el=cell file=$GIS_OPT_band1`
+if [ ! "$file" ] ; then
+ echo "Raster map '$GIS_OPT_band1' not found in mapset search path"
+ exit 1
+fi
+eval `g.findfile el=cell file=$GIS_OPT_tasscap4`
+if [ ! "$file" ] ; then
+ echo "Raster map '$GIS_OPT_tasscap4' not found in mapset search path"
+ echo "Did you run i.tasscap?"
+ exit 1
+fi
+
+#get the stats:
+getstats()
+{
+ r.stats -1 $tasscap,$1 > $2
+ r.linear.regression in=$2 out=$3
+ if [ $? -eq 1 ] ; then
+ echo "An error occurred. Stop."
+ exit
+ fi
+# result="`tail $3 | grep a\[1\] | cut -d' ' -f2,3 | tr -s '=' ' '`"
+ result="`tail $3 | grep "a\[1\]" | tr -s '=' ' '`"
+}
+
+
+getstats $tm1 $tasscap.plot1 $tasscap.regress1
+slope_tm1=`echo $result | cut -d' ' -f2`
+intercept_tm1=`echo $result | cut -d' ' -f4`
+# clean up the tmp stuff:
+rm -f $tasscap.plot1 $tasscap.regress1
+echo "Result for channel $tm1: sl:$slope_tm1 i:$intercept_tm1"
+echo ""
+
+getstats $tm2 $tasscap.plot2 $tasscap.regress2
+slope_tm2=`echo $result | cut -d' ' -f2`
+intercept_tm2=`echo $result | cut -d' ' -f4`
+# clean up the tmp stuff:
+rm -f $tasscap.plot2 $tasscap.regress2
+echo "Result for channel $tm2: $slope_tm2 i:$intercept_tm2"
+echo ""
+
+getstats $tm3 $tasscap.plot3 $tasscap.regress3
+slope_tm3=`echo $result | cut -d' ' -f2`
+intercept_tm3=`echo $result | cut -d' ' -f4`
+# clean up the tmp stuff:
+rm -f $tasscap.plot3 $tasscap.regress3
+echo "Result for channel $tm3: $slope_tm3 i:$intercept_tm3"
+echo ""
+
+getstats $tm4 $tasscap.plot4 $tasscap.regress4
+slope_tm4=`echo $result | cut -d' ' -f2`
+intercept_tm4=`echo $result | cut -d' ' -f4`
+# clean up the tmp stuff:
+rm -f $tasscap.plot4 $tasscap.regress4
+echo "Result for channel $tm4: $slope_tm4 i:$intercept_tm4"
+echo ""
+
+getstats $tm5 $tasscap.plot5 $tasscap.regress5
+slope_tm5=`echo $result | cut -d' ' -f2`
+intercept_tm5=`echo $result | cut -d' ' -f4`
+# clean up the tmp stuff:
+rm -f $tasscap.plot5 $tasscap.regress5
+echo "Result for channel $tm5: $slope_tm5 i:$intercept_tm5"
+echo ""
+
+# do the correction:
+echo "Running the dehaze formula: tm.dehaze = tm - [ (tass4 - tm_i) * tm_s]"
+echo " with internally calculated i:intercept, s: slope"
+
+r.mapcalc $tm1.dehaze="$tm1 - ( ($tasscap - $intercept_tm1) * $slope_tm1)"
+r.mapcalc $tm2.dehaze="$tm2 - ( ($tasscap - $intercept_tm2) * $slope_tm2)"
+r.mapcalc $tm3.dehaze="$tm3 - ( ($tasscap - $intercept_tm3) * $slope_tm3)"
+r.mapcalc $tm4.dehaze="$tm4 - ( ($tasscap - $intercept_tm4) * $slope_tm4)"
+r.mapcalc $tm5.dehaze="$tm5 - ( ($tasscap - $intercept_tm5) * $slope_tm5)"
+echo ""
+echo "The new dehazed bands are: "
+echo "$tm1.dehaze, $tm2.dehaze, $tm3.dehaze, $tm4.dehaze, $tm5.dehaze"
+echo ""
+echo "Consider to run r.colors or i.grey.scale to set a grey color table"
Property changes on: trunk/grassaddons/i.landsat.dehaze/i.landsat.dehaze
___________________________________________________________________
Name: svn:executable
+ *
From cepicky at grass.itc.it Tue Apr 3 16:04:40 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 16:04:41 2007
Subject: [grass-addons] r414 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704031404.l33E4eCZ024662@grass.itc.it>
Author: cepicky
Date: 2007-04-03 16:04:39 +0200 (Tue, 03 Apr 2007)
New Revision: 414
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
basic layer queries
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-03 11:35:46 UTC (rev 413)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-03 14:04:39 UTC (rev 414)
@@ -564,7 +564,7 @@
# left mouse button released and not just a pointer
elif event.LeftUp():
- if self.mouse['box'] != "point":
+ if self.mouse['box'] != "point" and self.mouse['box'] != "query":
# end point of zoom box or drag
self.mouse['end'] = event.GetPositionTuple()[:]
@@ -582,6 +582,19 @@
# redraw map
self.render=True
self.UpdateMap()
+
+ # quering
+ elif self.mouse["box"] == "query":
+ east,north = self.Pixel2Cell(self.mouse['end'][0],self.mouse['end'][1])
+ if self.parent.gismanager:
+ layer = self.parent.gismanager.maptree.GetSelection()
+ type = self.parent.gismanager.maptree.layertype[layer]
+ map,mapset = layer.GetText().split("@")
+ self.parent.QueryMap(map,mapset,type,east,north)
+ else:
+ print "Quering without gis manager not implemented yet"
+
+
elif self.dragid:
self.Refresh()
self.Update()
@@ -816,6 +829,9 @@
wx.Frame.__init__(self, parent, id, title, pos, size, style)
+ # most of the thime, this will be the gis manager
+ self.gismanager = parent
+
#
# Set the size
#
@@ -1101,6 +1117,35 @@
"""
return Map
+ def OnQuery(self, event):
+ """
+ Query currrent or last map
+ """
+ print "Quering"
+ self.MapWindow.mouse['box'] = "query"
+ self.MapWindow.zoomtype = 0
+ #event.Skip()
+
+ # change the cursor
+ self.MapWindow.SetCursor (self.cursors["cross"])
+
+ def QueryMap(self,name,mapset,type,x,y):
+ """
+ Run *.what command in gis manager output window
+ """
+ if type == "raster":
+ cmd = "r.what input=%s east_north=%f,%f" %\
+ (name+"@"+mapset, float(x), float(y))
+
+ elif type == "vector":
+ cmd = "v.what map=%s east_north=%f,%f"%\
+ (name+"@"+mapset, float(x), float(y))
+
+ if self.gismanager:
+ self.gismanager.goutput.runCmd(cmd)
+ else:
+ os.system(cmd)
+
# toolBar button handlers
def onDecoration(self, event):
"""
From cepicky at grass.itc.it Tue Apr 3 16:05:07 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 16:05:08 2007
Subject: [grass-addons] r415 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704031405.l33E577Z024693@grass.itc.it>
Author: cepicky
Date: 2007-04-03 16:05:07 +0200 (Tue, 03 Apr 2007)
New Revision: 415
Modified:
trunk/grassaddons/gui/gui_modules/toolbars.py
Log:
basic layer queries
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-03 14:04:39 UTC (rev 414)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-03 14:05:07 UTC (rev 415)
@@ -64,6 +64,11 @@
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
shortHelp="Pan", longHelp="Drag with mouse to pan")
+ self.query = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="query",
+ bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-query.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
+ shortHelp="Query", longHelp="Query selected map")
self.toolbar.AddSeparator()
@@ -73,7 +78,6 @@
bmpDisabled=wx.NullBitmap,
shortHelp="Decoration", longHelp="Add graphic overlays to map")
-
self.toolbar.AddSeparator()
#
@@ -104,6 +108,7 @@
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomOut, self.zoomout)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnPan, self.pan)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onDecoration, self.dec)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnQuery, self.query)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnErase, self.erase)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.SaveToFile, self.savefile)
self.mapdisplay.Bind(wx.EVT_COMBOBOX, self.OnSelect, self.combo)
From cepicky at grass.itc.it Tue Apr 3 16:09:49 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 16:09:51 2007
Subject: [grass-addons] r416 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704031409.l33E9nxc024737@grass.itc.it>
Author: cepicky
Date: 2007-04-03 16:09:49 +0200 (Tue, 03 Apr 2007)
New Revision: 416
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
sorting works better
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 14:05:07 UTC (rev 415)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 14:09:49 UTC (rev 416)
@@ -10,6 +10,18 @@
dbm.py table_name
"""
+############################################################################
+#
+# MODULE: dbm.py
+# AUTHOR(S): Jachym Cepicky
+# PURPOSE: GRASS attribute table manager
+# COPYRIGHT: (C) 2007 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.
+#
+#############################################################################
import wx
import wx.lib.mixins.listctrl as listmix
@@ -33,8 +45,12 @@
class TestVirtualList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
def __init__(self, parent,log,tablename):
wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
+
self.log=log
self.tablename = tablename
+ self.columns = []
+ self.columnNumber = 0
+ self.parent = parent
#adding some attributes (colourful background for each item rows)
self.attr1 = wx.ListItemAttr()
@@ -46,13 +62,26 @@
i = 0
# FIXME: subprocess.Popen should be used
# FIXME: Maximal number of columns, when the GUI is still usable
- for column in os.popen("db.columns table=%s" %
- (self.tablename)).readlines():
+ for line in os.popen("db.describe -c table=%s" %
+ (self.tablename)).readlines()[1:]:
- column = column.strip()
+ x,column,type = line.strip().split(":")
+ # FIXME: here will be more types
+ if type.lower().find("integer") > -1:
+ self.columns.append({"name":column,"type":int})
+ elif type.lower().find("double") > -1:
+ self.columns.append({"name":column,"type":float})
+ elif type.lower().find("float") > -1:
+ self.columns.append({"name":column,"type":float})
+ else:
+ self.columns.append({"name":column,"type":str})
+
self.InsertColumn(i, column)
self.SetColumnWidth(i, 50)
i += 1
+ if i >= 256:
+ self.log.write("Can display only 256 columns")
+ break
#These two should probably be passed to init more cleanly
#setting the numbers of items = number of elements in the dictionary
@@ -68,6 +97,10 @@
self.itemDataMap[i].append(attribute)
self.itemIndexMap.append(i)
i += 1
+ if i >= 32000:
+ self.log.write("Can display only 32000 lines")
+ break
+
self.SetItemCount(len(self.itemDataMap))
#mixins
@@ -84,6 +117,7 @@
self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
def OnColClick(self,event):
+ self.columnNumber = event.GetColumn()
event.Skip()
def OnItemSelected(self, event):
@@ -91,6 +125,7 @@
self.log.write('OnItemSelected: "%s", "%s"\n' %
(self.currentItem,
self.GetItemText(self.currentItem)))
+ print self.parent.gismanager
def OnItemActivated(self, event):
self.currentItem = event.m_itemIndex
@@ -135,7 +170,12 @@
def SortItems(self,sorter=cmp):
items = list(self.itemDataMap.keys())
- items.sort(sorter)
+ # for i in range(len(items)):
+ # items[i] = self.columns[self.columnNumber]["type"](items[i])
+ items.sort(self.Sorter)
+ #items.sort(sorter)
+ # for i in range(len(items)):
+ # items[i] = str(items[i])
self.itemIndexMap = items
# redraw the list
@@ -145,6 +185,33 @@
def GetListCtrl(self):
return self
+ # stolen from python2.4/site-packages/wx-2.8-gtk2-unicode/wx/lib/mixins/listctrl.py
+ def Sorter(self, key1,key2):
+ col = self._col
+ ascending = self._colSortFlag[col]
+ # convert, because the it is allways string
+ item1 = self.columns[col]["type"](self.itemDataMap[key1][col])
+ item2 = self.columns[col]["type"](self.itemDataMap[key2][col])
+
+ #--- Internationalization of string sorting with locale module
+ if type(item1) == type('') or type(item2) == type(''):
+ cmpVal = locale.strcoll(str(item1), str(item2))
+ else:
+ cmpVal = cmp(item1, item2)
+ #---
+
+ # If the items are equal then pick something else to make the sort v ->alue unique
+ if cmpVal == 0:
+ cmpVal = apply(cmp, self.GetSecondarySortValues(col, key1, key2))
+
+ if ascending:
+ return cmpVal
+ else:
+ return -cmpVal
+
+ #return cmp(self.columns[self.columnNumber]["type"](a),
+ # self.columns[self.columnNumber]["type"](b))
+
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
#def GetSortImages(self):
# return (self.sm_dn, self.sm_up)
@@ -173,6 +240,9 @@
self.CreateStatusBar(1)
log=Log(self)
+
+ # probably
+ self.gismanager = parent
self.win = TestVirtualList(self, log,tablename=table)
self.Show()
From neteler at grass.itc.it Tue Apr 3 16:24:38 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Tue Apr 3 16:24:40 2007
Subject: [grass-addons] r417 - in trunk/grassaddons: . r.out.netcdf
Message-ID: <200704031424.l33EOcXj024840@grass.itc.it>
Author: neteler
Date: 2007-04-03 16:24:38 +0200 (Tue, 03 Apr 2007)
New Revision: 417
Added:
trunk/grassaddons/r.out.netcdf/
trunk/grassaddons/r.out.netcdf/COPYING
trunk/grassaddons/r.out.netcdf/LICENSE
trunk/grassaddons/r.out.netcdf/Makefile
trunk/grassaddons/r.out.netcdf/NEWS
trunk/grassaddons/r.out.netcdf/TODO
trunk/grassaddons/r.out.netcdf/description.html
trunk/grassaddons/r.out.netcdf/main.c
Log:
r.out.netcdf added
Added: trunk/grassaddons/r.out.netcdf/COPYING
===================================================================
--- trunk/grassaddons/r.out.netcdf/COPYING (rev 0)
+++ trunk/grassaddons/r.out.netcdf/COPYING 2007-04-03 14:24:38 UTC (rev 417)
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Added: trunk/grassaddons/r.out.netcdf/LICENSE
===================================================================
--- trunk/grassaddons/r.out.netcdf/LICENSE (rev 0)
+++ trunk/grassaddons/r.out.netcdf/LICENSE 2007-04-03 14:24:38 UTC (rev 417)
@@ -0,0 +1,5 @@
+r.out.netcdf is made to be part of GRASS GIS and is relased under the
+terms of General Public license ver.2. that comes together with this
+package (see GPL.txt)
+
+copyright - Alessandro Frigeri, 2003
Added: trunk/grassaddons/r.out.netcdf/Makefile
===================================================================
--- trunk/grassaddons/r.out.netcdf/Makefile (rev 0)
+++ trunk/grassaddons/r.out.netcdf/Makefile 2007-04-03 14:24:38 UTC (rev 417)
@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.out.netcdf
+
+LIBES = $(GISLIB) -lnetcdf
+DEPENDENCIES = $(GISDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd
Added: trunk/grassaddons/r.out.netcdf/NEWS
===================================================================
--- trunk/grassaddons/r.out.netcdf/NEWS (rev 0)
+++ trunk/grassaddons/r.out.netcdf/NEWS 2007-04-03 14:24:38 UTC (rev 417)
@@ -0,0 +1,6 @@
+18 Feb 2007 - M Neteler
+ updated to GRASS 6.3
+11 Feb 2003 - A Frigeri
+ r.out.netcdf (0.1) is out for testing!
+17 Mar 2003 - A Frigeri
+ added support for floating point and double precision raster maps
Added: trunk/grassaddons/r.out.netcdf/TODO
===================================================================
--- trunk/grassaddons/r.out.netcdf/TODO (rev 0)
+++ trunk/grassaddons/r.out.netcdf/TODO 2007-04-03 14:24:38 UTC (rev 417)
@@ -0,0 +1 @@
+-Align netcdf and grass datatypes
Added: trunk/grassaddons/r.out.netcdf/description.html
===================================================================
--- trunk/grassaddons/r.out.netcdf/description.html (rev 0)
+++ trunk/grassaddons/r.out.netcdf/description.html 2007-04-03 14:24:38 UTC (rev 417)
@@ -0,0 +1,19 @@
+
DESCRIPTION
+
+The r.out.netcdf module exports a GRASS raster map to a netcdf file.
+Dimensions, Attributes and variables of netcdf file follow the scheme used
+in Generic Mapping Tools (GMT) grid (.grd) files (-g flag) or are suitable
+to be imported into IBM Data Explorer (-d flag).
+
+
Last changed: $Date: 2004/11/17 17:49:04 $
Added: trunk/grassaddons/r.out.netcdf/main.c
===================================================================
--- trunk/grassaddons/r.out.netcdf/main.c (rev 0)
+++ trunk/grassaddons/r.out.netcdf/main.c 2007-04-03 14:24:38 UTC (rev 417)
@@ -0,0 +1,385 @@
+/****************************************************************************
+ *
+ * MODULE: r.out.netcdf
+ * AUTHOR(S): Alessandro Frigeri - afrigeri@unipg.it
+ *
+ * PURPOSE: Exports a raster map in a netCDF file.
+ * Exported map can be imported easly into IBM data Explorer
+ * or Generic Mapping Tools (GMT)
+ *
+ * COPYRIGHT: (C) 2003 Alessandro Frigeri for 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.
+ *
+ * LAST UPDATE: 10th Feb 2003
+ *
+ * HISTORY: 11th Feb 2003 - r.out.necdf is out
+ *
+ * 16th Mar 2003 - support for FCELL and DCELL added
+ *****************************************************************************/
+
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+
+extern CELL f_c(CELL);
+extern FCELL f_f(FCELL);
+extern DCELL f_d(DCELL);
+
+/* Stuff to make calculation on the raster values */
+
+CELL c_calc(CELL x)
+{
+ return x;
+}
+
+FCELL f_calc(FCELL x)
+{
+ return x;
+}
+
+DCELL d_calc(DCELL x)
+{
+ return x;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct Cell_head cellhd;
+ struct Cell_head region;
+ char *name, *result, *mapset;
+ void *inrast;
+ unsigned char *outrast;
+ int nrows, ncols;
+ int row,col;
+ int infd;
+ int dx,gmt;
+ RASTER_MAP_TYPE data_type;
+ struct GModule *module;
+ struct Option *input, *output;
+ struct Flag *flag1, *flag2;
+
+ /* netcdf stuff */
+ int ncols_dim,nrows_dim,naxes_dim,height_id,ndeltas_dim;
+ int errnc,ncID,zid,xrangeid,yrangeid,zrangeid,spacingid,dimensionid;
+ int fieldid,fielddimid;
+ int locations_id;
+ char title1[NC_MAX_NAME]="GRASS GIS raster map",history[NC_MAX_NAME];
+ static char title[] = "netCDF output from GRASS GIS";
+ static char remark[] = "netCDF output from GRASS GIS";
+ static char degrees[] = "degrees";
+ static char meter[] = "Meter";
+ static float scale_factor[]={1};
+ static int add_offset[]={0};
+ static int node_offset[]={1};
+ int sideid,xysizeid;
+ static size_t a[] = {0};
+ static size_t b[] = {1};
+ int xysize;
+ int vali;
+ float valf;
+ double vald;
+ size_t zstart[1];
+ size_t zcount[1];
+ double fmin,fmax;
+ double domin,domax;
+ int dmin,dmax;
+ struct FPRange fprange;
+ struct Range range;
+ float longitude,latitude;
+
+
+ int locations_dims[2];
+
+ int height_dims[2];
+
+ static size_t index_height[]={0,0};
+ static size_t index_locations[]={0,0};
+
+ double ns;
+
+ G_gisinit(argv[0]);
+
+ module = G_define_module();
+ module->description =
+ _("GRASS module for exporting netCDF data");
+
+ /* Define options */
+
+ input = G_define_standard_option(G_OPT_R_INPUT);
+
+ output = G_define_standard_option(G_OPT_R_OUTPUT);
+ output->gisprompt = "new_file,file,output";
+ output->description= "File name for new netCDF file";
+
+ /* Define the different flags */
+ flag1 = G_define_flag() ;
+ flag1->key = 'd' ;
+ flag1->description = _("OpenDX output") ;
+
+ flag2 = G_define_flag() ;
+ flag2->key = 'g' ;
+ flag2->description = _("GMT output") ;
+
+ if (G_parser(argc, argv))
+ exit (EXIT_FAILURE);
+
+ name = input->answer;
+ result = output->answer;
+ dx = flag1->answer;
+ gmt = flag2->answer;
+
+ /* find map in mapset */
+ mapset = G_find_cell2 (name, "");
+ if (mapset == NULL)
+ G_fatal_error ("cell file [%s] not found", name);
+
+ if (G_legal_filename (result) < 0)
+ G_fatal_error ("[%s] is an illegal name", result);
+
+ /* determine the inputmap type (CELL/FCELL/DCELL) */
+ data_type = G_raster_map_type(name, mapset);
+
+ if ( (infd = G_open_cell_old (name, mapset)) < 0)
+ G_fatal_error ("Cannot open cell file [%s]", name);
+
+ if (G_get_cellhd (name, mapset, &cellhd) < 0)
+ G_fatal_error ("Cannot read file header of [%s]", name);
+
+ /* Allocate input buffer */
+ inrast = G_allocate_raster_buf(data_type);
+
+ /* Allocate output buffer, use input map data_type */
+
+ nrows = G_window_rows();
+ ncols = G_window_cols();
+ outrast = G_allocate_raster_buf(data_type);
+
+ /* Get window boundaries */
+ G_get_window(®ion);
+
+ /* Create the new netCDF file */
+
+ errnc = nc_create(result, NC_WRITE, &ncID);
+ if (errnc == NC_EEXIST)
+ printf("Couldn't create NC file %s, NC file with that name already exists\n",result);
+
+
+
+ /* Dimensions: xysize, side */
+ ncols=region.cols;
+ nrows=region.rows;
+
+ xysize=ncols*nrows;
+
+ if(gmt){
+ nc_def_dim(ncID, "xysize", xysize, &xysizeid);
+ nc_def_dim(ncID, "side", 2, &sideid);
+ nc_def_var(ncID, "x_range", NC_DOUBLE,1, &sideid,&xrangeid);
+ nc_put_att_text(ncID, xrangeid, "units",strlen(degrees), degrees);
+ nc_def_var(ncID, "y_range", NC_DOUBLE,1, &sideid,&yrangeid);
+ nc_put_att_text(ncID, yrangeid, "units",strlen(degrees), degrees);
+ nc_def_var(ncID, "z_range", NC_DOUBLE,1, &sideid,&zrangeid);
+ nc_put_att_text(ncID, zrangeid, "units",strlen(meter), meter);
+ nc_def_var(ncID, "spacing", NC_DOUBLE,1, &sideid,&spacingid);
+ nc_def_var(ncID, "dimension", NC_INT,1, &sideid,&dimensionid);
+
+ switch (data_type)
+ {
+ case CELL_TYPE:
+ nc_def_var(ncID, "z", NC_INT,1, &xysizeid,&zid);
+ break;
+ case FCELL_TYPE:
+ nc_def_var(ncID, "z", NC_FLOAT,1, &xysizeid,&zid);
+ break;
+ case DCELL_TYPE:
+ nc_def_var(ncID, "z", NC_DOUBLE,1, &xysizeid,&zid);
+ break;
+ }
+
+ scale_factor[0]=1;
+
+ nc_put_att_text(ncID, NC_GLOBAL, "title",strlen(title), title);
+ nc_put_att_text(ncID, NC_GLOBAL, "source",strlen(title), title);
+ nc_put_att_text(ncID, zid, "long_name",strlen(title), title);
+ nc_put_att_float(ncID, zid, "scale_factor",NC_FLOAT,1, scale_factor);
+ nc_put_att_int(ncID, zid, "add_offset",NC_INT,1, add_offset);
+ nc_put_att_int(ncID, zid, "node_offset",NC_INT,1, node_offset);
+ }
+
+ if(dx){
+ nc_def_dim(ncID, "lon", ncols , &ncols_dim);
+ nc_def_dim(ncID, "lat", nrows , &nrows_dim);
+ nc_def_dim(ncID, "naxes",2, &naxes_dim);
+ nc_def_dim(ncID, "ndeltas",2, &ndeltas_dim);
+
+ locations_dims[0]=naxes_dim;
+ locations_dims[1]=ndeltas_dim;
+ nc_def_var(ncID, "locations",NC_FLOAT,2,locations_dims,&locations_id);
+
+ height_dims[0]=ncols_dim;
+ height_dims[1]=nrows_dim;
+
+ switch (data_type)
+ {
+ case CELL_TYPE:
+ nc_def_var(ncID, "height",NC_INT,2,height_dims,&height_id);
+ break;
+ case FCELL_TYPE:
+ nc_def_var(ncID, "height",NC_FLOAT,2,height_dims,&height_id);
+ break;
+ case DCELL_TYPE:
+ nc_def_var(ncID, "height",NC_DOUBLE,2,height_dims,&height_id);
+ break;
+ }
+
+
+ nc_put_att_text(ncID, height_id, "field",14,"height, scalar");
+ nc_put_att_text(ncID, height_id, "positions",18,"locations, regular");
+
+ }
+ nc_enddef(ncID);
+
+ if(gmt){
+ nc_put_var1_double(ncID,xrangeid,a,®ion.west);
+ nc_put_var1_double(ncID,xrangeid,b,®ion.east);
+ nc_put_var1_double(ncID,yrangeid,a,®ion.south);
+ nc_put_var1_double(ncID,yrangeid,b,®ion.north);
+ nc_put_var1_double(ncID,spacingid,a,®ion.ew_res);
+ nc_put_var1_double(ncID,spacingid,b,®ion.ns_res);
+ nc_put_var1_int(ncID,dimensionid,a,&ncols);
+ nc_put_var1_int(ncID,dimensionid,b,&nrows);
+ }
+
+ if(dx){
+
+ index_locations[0]=0;
+ index_locations[1]=0;
+ nc_put_var1_double(ncID,locations_id,index_locations,®ion.west);
+ index_locations[0]=0;
+ index_locations[1]=1;
+ nc_put_var1_double(ncID,locations_id,index_locations,®ion.ew_res);
+
+ index_locations[0]=1;
+ index_locations[1]=0;
+ nc_put_var1_double(ncID,locations_id,index_locations,®ion.north);
+ index_locations[0]=1;
+ index_locations[1]=1;
+ ns=-region.ns_res;
+ nc_put_var1_double(ncID,locations_id,index_locations,&ns);
+
+ }
+
+
+ for (row = 0; row < nrows; row++)
+ {
+ CELL c;
+ FCELL f;
+ DCELL d;
+
+ G_percent (row, nrows, 2);
+
+ /* read input map */
+ if (G_get_raster_row (infd, inrast, row, data_type) < 0)
+ G_fatal_error (_("Could not read from <%s>"),name);
+
+
+ /* put the NetCDF data
+ CELL -> int
+ FCELL -> float
+ DCELL -> double
+ */
+ for (col=0; col < ncols; col++)
+ {
+ longitude=region.west+col*region.ew_res;
+ latitude=region.south+row*region.ns_res;
+ index_height[0]=col;
+ index_height[1]=row;
+
+ switch (data_type)
+ {
+ case CELL_TYPE:
+ c = ((CELL *) inrast)[col];
+ c = c_calc(c); /* calculate */
+ zstart[0]=col+(row*ncols); /* position */
+ zcount[0]=1; /* extension */
+
+ vali=c;
+ if(gmt){
+ nc_put_vara_int(ncID,zid,zstart,zcount,&vali);
+ }
+ if(dx){
+ nc_put_var1_int(ncID,height_id,index_height,&vali);
+ }
+ break;
+ case FCELL_TYPE:
+ f = ((FCELL *) inrast)[col];
+ f = f_calc(f); /* calculate */
+ zstart[0]=col+(row*ncols); /* position */
+ zcount[0]=1; /* extension */
+ valf=f;
+ if(gmt){
+ nc_put_vara_float(ncID,zid,zstart,zcount,&valf);
+ }
+ if(dx){
+ nc_put_var1_float(ncID,height_id,index_height,&valf);
+ }
+ break;
+ case DCELL_TYPE:
+ d = ((DCELL *) inrast)[col];
+ d = d_calc(d); /* calculate */
+ zstart[0]=col+(row*ncols); /* position */
+ zcount[0]=1; /* extension */
+ vald=d;
+ if(gmt){
+ nc_put_vara_double(ncID,zid,zstart,zcount,&vald);
+ }
+ if(dx){
+ nc_put_var1_double(ncID,height_id,index_height,&vald);
+ }
+ break;
+ }
+ }
+
+ }
+
+
+ if(gmt)
+ {
+ switch(data_type)
+ {
+ case CELL_TYPE:
+ G_read_range(name, mapset, &range);
+ G_get_range_min_max(&range, &dmin, &dmax);
+ nc_put_var1_int(ncID,zrangeid,a,&dmin);
+ nc_put_var1_int(ncID,zrangeid,b,&dmax);
+ case FCELL_TYPE:
+ G_read_fp_range(name, mapset, &fprange);
+ G_get_fp_range_min_max(&fprange, &fmin, &fmax);
+ nc_put_var1_double(ncID,zrangeid,a,&fmin);
+ nc_put_var1_double(ncID,zrangeid,b,&fmax);
+ case DCELL_TYPE:
+ G_read_fp_range(name, mapset, &fprange);
+ G_get_fp_range_min_max(&fprange, &domin, &domax);
+ nc_put_var1_double(ncID,zrangeid,a,&domin);
+ nc_put_var1_double(ncID,zrangeid,b,&domax);
+ }
+
+ }
+
+ /* Close the netcdf file */
+ nc_close(ncID);
+
+ G_free(inrast);
+ G_close_cell (infd);
+
+ exit(EXIT_SUCCESS);
+}
From cepicky at grass.itc.it Tue Apr 3 17:17:49 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 17:17:51 2007
Subject: [grass-addons] r418 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704031517.l33FHnU7025840@grass.itc.it>
Author: cepicky
Date: 2007-04-03 17:17:49 +0200 (Tue, 03 Apr 2007)
New Revision: 418
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/wxgui.py
Log:
parent for attribute table
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 14:24:38 UTC (rev 417)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 15:17:49 UTC (rev 418)
@@ -125,8 +125,16 @@
self.log.write('OnItemSelected: "%s", "%s"\n' %
(self.currentItem,
self.GetItemText(self.currentItem)))
- print self.parent.gismanager
+ print self.parent.gismanager
+ if self.parent.gismanager:
+ gism = self.parent.gismanager
+ curr_pg = gism.gm_cb.GetCurrentPage()
+ disp_idx = gism.track.Track().GetDisp_idx(curr_pg)
+
+ print self.parent.gismanager.mapdisplays#[self.parent.gismanager.disp_idx]
+ print self.parent.gismanager.disp_idx
+
def OnItemActivated(self, event):
self.currentItem = event.m_itemIndex
self.log.write("OnItemActivated: %s\nTopItem: %s\n" %
@@ -243,6 +251,7 @@
# probably
self.gismanager = parent
+ print self.gismanager
self.win = TestVirtualList(self, log,tablename=table)
self.Show()
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-03 14:24:38 UTC (rev 417)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-03 15:17:49 UTC (rev 418)
@@ -124,6 +124,7 @@
#self.panel = wx.Panel(self,-1, style= wx.EXPAND)
self.sizer= wx.BoxSizer(wx.VERTICAL)
self.cmdsizer = wx.BoxSizer(wx.HORIZONTAL)
+ self.track = track
# do layout
self.SetTitle(_("GRASS GIS Manager - wxPython Prototype"))
@@ -330,7 +331,7 @@
if mapset == grassenv.env["MAPSET"]:
from gui_modules import dbm
- self.dbmanager = gui_modules.dbm.AttributeManager(None, -1,"GRASS Attribute Table Manager: %s" % map, size=wx.Size(500,300),table=map)
+ self.dbmanager = gui_modules.dbm.AttributeManager(self, -1,"GRASS Attribute Table Manager: %s" % map, size=wx.Size(500,300),table=map)
def newDisplay(self, event=None):
From cepicky at grass.itc.it Tue Apr 3 17:18:15 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 17:18:16 2007
Subject: [grass-addons] r419 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704031518.l33FIFlm025860@grass.itc.it>
Author: cepicky
Date: 2007-04-03 17:18:15 +0200 (Tue, 03 Apr 2007)
New Revision: 419
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
parent for attribute table
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 15:17:49 UTC (rev 418)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 15:18:15 UTC (rev 419)
@@ -126,7 +126,6 @@
(self.currentItem,
self.GetItemText(self.currentItem)))
- print self.parent.gismanager
if self.parent.gismanager:
gism = self.parent.gismanager
curr_pg = gism.gm_cb.GetCurrentPage()
@@ -251,7 +250,6 @@
# probably
self.gismanager = parent
- print self.gismanager
self.win = TestVirtualList(self, log,tablename=table)
self.Show()
From cepicky at grass.itc.it Tue Apr 3 17:45:41 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 17:45:42 2007
Subject: [grass-addons] r420 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704031545.l33Fjf3r026344@grass.itc.it>
Author: cepicky
Date: 2007-04-03 17:45:41 +0200 (Tue, 03 Apr 2007)
New Revision: 420
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
better key-value separation
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-03 15:18:15 UTC (rev 419)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-03 15:45:41 UTC (rev 420)
@@ -75,7 +75,7 @@
self.cmd = "d.rast -o map=%s@%s" % (self.name, self.mapset)
for key,value in self.grassLayer.params.iteritems():
- if type(value) == type(""):
+ if type(value) != type(None):
self.cmd += " %s=%s" % \
(key, value)
else:
@@ -99,7 +99,7 @@
self.cmd = "d.vect map=%s@%s" % (self.name, self.mapset)
for key,value in self.grassLayer.params.iteritems():
- if type(value) == type(""):
+ if type(value) != type(None):
self.cmd += " %s=%s" % \
(key, value)
else:
@@ -678,10 +678,12 @@
layer = MapLayer(type="raster", name=name, mapset=mapset,
active=l_active, hidden=l_hidden, opacity=l_opacity,
dispcmd=dispcmd)
+ layer.id = len(self.layers)-1
# add maplayer to the list of layers
self.layers.append(layer)
+
if l_render:
if not layer.Render():
sys.stderr.write("Could not render layer <%s@%s>\n" % \
@@ -721,6 +723,7 @@
coordsinmapunits = coordsinmapunits)
self.layers.append(layer)
+ layer.id = len(self.layers)-1
if l_render:
if not layer.Render():
@@ -761,6 +764,7 @@
active=l_active, hidden=l_hidden, opacity=l_opacity)
self.layers.append(maplayer)
+ maplayer.id = len(self.layers)-1
if l_render:
if not maplayer.Render():
From cepicky at grass.itc.it Tue Apr 3 17:54:01 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 17:54:01 2007
Subject: [grass-addons] r421 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704031554.l33Fs1xb026388@grass.itc.it>
Author: cepicky
Date: 2007-04-03 17:54:01 +0200 (Tue, 03 Apr 2007)
New Revision: 421
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
making Map to attribute of mapdisplay
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-03 15:45:41 UTC (rev 420)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-03 15:54:01 UTC (rev 421)
@@ -158,10 +158,11 @@
def __init__(self, parent, id,
pos = wx.DefaultPosition,
size = wx.DefaultSize,
- style=wx.NO_FULL_REPAINT_ON_RESIZE):
+ style=wx.NO_FULL_REPAINT_ON_RESIZE,map=Map):
wx.Window.__init__(self, parent, id, pos, size, style)
self.parent = parent
+ self.Map = map
#
# Flags
@@ -352,20 +353,20 @@
"""
# set size of the input image
- Map.width, Map.height = self.GetClientSize()
+ self.Map.width, self.Map.height = self.GetClientSize()
# 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(Map.width, Map.height)
+ self._Buffer = wx.EmptyBitmap(self.Map.width, self.Map.height)
# get the image to be rendered
self.img = self.GetImage()
# update map display
- if self.img and Map.width + Map.height > 0: # scale image during resize
- self.img = self.img.Scale(Map.width, Map.height)
+ 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.render = False
self.UpdateMap()
@@ -396,8 +397,8 @@
Converts overlay files to wx.Image
"""
ovlist = []
- if Map.ovlist:
- for ovlfile in Map.ovlist:
+ if self.Map.ovlist:
+ for ovlfile in self.Map.ovlist:
if os.path.isfile(ovlfile) and os.path.getsize(ovlfile):
img = wx.Image(ovlfile, wx.BITMAP_TYPE_ANY)
ovlist.append(img)
@@ -409,9 +410,9 @@
"""
Converts files to wx.Image
"""
- if Map.mapfile and os.path.isfile(Map.mapfile) and \
- os.path.getsize(Map.mapfile):
- img = wx.Image(Map.mapfile, wx.BITMAP_TYPE_ANY)
+ if self.Map.mapfile and os.path.isfile(self.Map.mapfile) and \
+ os.path.getsize(self.Map.mapfile):
+ img = wx.Image(self.Map.mapfile, wx.BITMAP_TYPE_ANY)
else:
img = None
@@ -434,8 +435,8 @@
if self.render:
# render new map images
- Map.width, Map.height = self.GetClientSize()
- self.mapfile = Map.Render(force=self.render)
+ self.Map.width, self.Map.height = self.GetClientSize()
+ self.mapfile = self.Map.Render(force=self.render)
self.img = self.GetImage()
self.resize = False
@@ -464,8 +465,8 @@
# update statusbar
self.parent.statusbar.SetStatusText("Extent: %d,%d : %d,%d" %
- (Map.region["w"], Map.region["e"],
- Map.region["n"], Map.region["s"]), 0)
+ (self.Map.region["w"], self.Map.region["e"],
+ self.Map.region["n"], self.Map.region["s"]), 0)
def EraseMap(self):
"""
@@ -621,9 +622,9 @@
elif wheel != 0:
# zoom 1/2 of the screen
- begin = [Map.width/4, Map.height/4]
- end = [Map.width - Map.width/4,
- Map.height - Map.height/4]
+ begin = [self.Map.width/4, self.Map.height/4]
+ end = [self.Map.width - self.Map.width/4,
+ self.Map.height - self.Map.height/4]
elif event.RightDown():
x,y = event.GetPositionTuple()[:]
@@ -650,8 +651,8 @@
Input : x, y
Output: int x, int y
"""
- newx = Map.region['w'] + x * Map.region["ewres"]
- newy = Map.region['n'] - y * Map.region["nsres"]
+ newx = self.Map.region['w'] + x * self.Map.region["ewres"]
+ newy = self.Map.region['n'] - y * self.Map.region["nsres"]
return newx, newy
@@ -681,23 +682,23 @@
-x1*2,
-y1*2)
newreg['e'], newreg['s'] = self.Pixel2Cell(
- Map.width+2*(Map.width-x2),
- Map.height+2*(Map.height-y2))
+ self.Map.width+2*(self.Map.width-x2),
+ self.Map.height+2*(self.Map.height-y2))
# pan
elif zoomtype == 0:
newreg['w'], newreg['n'] = self.Pixel2Cell(
x1-x2,
y1-y2)
newreg['e'], newreg['s'] = self.Pixel2Cell(
- Map.width+x1-x2,
- Map.height+y1-y2)
+ self.Map.width+x1-x2,
+ self.Map.height+y1-y2)
# if new region has been calculated, set the values
if newreg :
- Map.region['n'] = newreg['n']
- Map.region['s'] = newreg['s']
- Map.region['e'] = newreg['e']
- Map.region['w'] = newreg['w']
+ self.Map.region['n'] = newreg['n']
+ self.Map.region['s'] = newreg['s']
+ self.Map.region['e'] = newreg['e']
+ self.Map.region['w'] = newreg['w']
#class DrawWindow(BufferedWindow):
@@ -831,6 +832,7 @@
# most of the thime, this will be the gis manager
self.gismanager = parent
+ self.Map = Map
#
# Set the size
@@ -861,24 +863,24 @@
self.statusbar = self.CreateStatusBar(number=2, style=0)
self.statusbar.SetStatusWidths([-2, -1])
map_frame_statusbar_fields = ["Extent: %d,%d : %d,%d" %
- (Map.region["w"], Map.region["e"],
- Map.region["n"], Map.region["s"]),
+ (self.Map.region["w"], self.Map.region["e"],
+ self.Map.region["n"], self.Map.region["s"]),
"%s,%s" %(None, None)]
for i in range(len(map_frame_statusbar_fields)):
self.statusbar.SetStatusText(map_frame_statusbar_fields[i], i)
# d.barscale overlay added to rendering overlay list
- Map.addOverlay(type=0, command='d.barscale', l_active=True, l_render=False)
+ self.Map.addOverlay(type=0, command='d.barscale', l_active=True, l_render=False)
# d.barscale overlay added to rendering overlay list as placeholder for d.legend
- Map.addOverlay(type=1, command='d.barscale', l_active=True, l_render=False)
+ self.Map.addOverlay(type=1, command='d.barscale', l_active=True, l_render=False)
#
# Init map display
#
self.InitDisplay() # initialize region values
# self.MapWindow = DrawWindow(self) # initialize buffered DC
- self.MapWindow = BufferedWindow(self, id = wx.ID_ANY) # initialize buffered DC
+ self.MapWindow = BufferedWindow(self, id = wx.ID_ANY,map=self.Map) # initialize buffered DC
self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
# decoration overlays
@@ -917,14 +919,14 @@
* digit
"""
if name == "map":
- self.maptoolbar = toolbars.MapToolbar(self, Map)
+ self.maptoolbar = toolbars.MapToolbar(self, self.Map)
self._mgr.AddPane(self.maptoolbar.toolbar, wx.aui.AuiPaneInfo().
Name("maptoolbar").Caption("Map Toolbar").
ToolbarPane().Top().LeftDockable(False).RightDockable(False).
BottomDockable(True).CloseButton(False))
if name == "digit":
- self.digittoolbar = toolbars.DigitToolbar(self,Map)
+ self.digittoolbar = toolbars.DigitToolbar(self,self.Map)
self._mgr.AddPane(self.digittoolbar.toolbar, wx.aui.AuiPaneInfo().
Name("digittoolbar").Caption("Digit Toolbar").
ToolbarPane().Top().LeftDockable(False).RightDockable(False).
@@ -936,12 +938,12 @@
Initialize map display, set dimensions and map region
"""
self.width, self.height = self.GetClientSize()
- Map.geom = self.width, self.height
- Map.GetRegion()
+ self.Map.geom = self.width, self.height
+ self.Map.GetRegion()
#FIXME
#This was Map.getResolution().
#I'm guessing at the moment that this is replaced by Map.SetRegion()
- Map.SetRegion()
+ self.Map.SetRegion()
def OnFocus(self, event):
"""
@@ -1059,8 +1061,8 @@
"""
Zoom to region
"""
- Map.getRegion()
- Map.getResolution()
+ self.Map.getRegion()
+ self.Map.getResolution()
self.UpdateMap()
# self.draw(dc)
event.Skip()
@@ -1069,10 +1071,10 @@
"""
Align region
"""
- if not Map.alignRegion:
- Map.alignRegion = True
+ if not self.Map.alignRegion:
+ self.Map.alignRegion = True
else:
- Map.alignRegion = False
+ self.Map.alignRegion = False
event.Skip()
def SaveToFile(self, event):
@@ -1092,7 +1094,7 @@
"""
Window closed
"""
- Map.Clean()
+ self.Map.Clean()
self.Destroy()
#close associated controls book page
@@ -1115,7 +1117,7 @@
"""
returns the current instance of render.Map()
"""
- return Map
+ return self.Map
def OnQuery(self, event):
"""
@@ -1263,7 +1265,7 @@
# Reset comand and rendering options in render.Map. Always render decoration.
# Showing/hiding handled by PseudoDC
- Map.changeOverlay(type=type, command=dcmd, l_active=True, l_render=False)
+ self.Map.changeOverlay(type=type, command=dcmd, l_active=True, l_render=False)
self.params[type] = params
# end of class MapFrame
From barton at grass.itc.it Tue Apr 3 17:58:49 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 3 17:58:51 2007
Subject: [grass-addons] r422 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704031558.l33FwnfA026421@grass.itc.it>
Author: barton
Date: 2007-04-03 17:58:40 +0200 (Tue, 03 Apr 2007)
New Revision: 422
Modified:
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Fixed checking/unchecking for layers inside groups.
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-03 15:54:01 UTC (rev 421)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-03 15:58:40 UTC (rev 422)
@@ -298,10 +298,10 @@
childchecked = False
else:
childchecked = child.IsChecked()
- self.changeChecked(child, childchecked)
+ self.Map.changeActive(child, childchecked)
child = self.GetNextChild(layer, cookie)[0]
else:
- self.changeChecked(layer, checked)
+ self.Map.changeActive(layer, checked)
def onCmdChanged(self, event):
@@ -367,6 +367,7 @@
delete original at old position
"""
+ self.drag = True
# Make sure this memeber exists.
try:
old = self.dragItem
@@ -395,10 +396,12 @@
new = self.PrependItem(self.root, text=self.saveitem['text'], \
ct_type=1, wnd=newctrl, image=self.saveitem['image'], \
data=self.saveitem['data'])
- elif (flag & wx.TREE_HITTEST_BELOW) or (flag & wx.TREE_HITTEST_NOWHERE):
+ elif (flag & wx.TREE_HITTEST_BELOW) or (flag & wx.TREE_HITTEST_NOWHERE) \
+ or (flag & wx.TREE_HITTEST_TOLEFT) or (flag & wx.TREE_HITTEST_TORIGHT):
new = self.AppendItem(self.root, text=self.saveitem['text'], \
ct_type=1, wnd=newctrl, image=self.saveitem['image'], \
data=self.saveitem['data'])
+
else:
if not event.GetItem():
return
@@ -409,6 +412,7 @@
new = self.AppendItem(parent, text=self.saveitem['text'], \
ct_type=1, wnd=newctrl, image=self.saveitem['image'], \
data=self.saveitem['data'])
+ self.Expand(afteritem)
else:
parent = self.GetItemParent(afteritem)
new = self.InsertItem(parent, afteritem, text=self.saveitem['text'], \
@@ -422,7 +426,7 @@
newctrl.SetValue(self.saveitem['windval'])
# update lookup dictionary in render.Map
- if self.saveitem['type'] != 'group':
+ if self.layertype[new] != 'group':
self.Map.updateLookup(old, new)
# delete layer at original position
@@ -468,14 +472,15 @@
def reorderLayers(self):
"""
add commands from data associated with
- any valid and checked layers to layer list
+ any valid layers (checked or not) to layer list in order to
+ match layers in layer tree
"""
# make a list of visible layers
treelayers = []
vislayer = self.GetFirstVisibleItem()
for item in range(0,self.GetCount()):
- if self.IsItemChecked(vislayer) and self.layertype[vislayer] != 'group':
+ if self.layertype[vislayer] != 'group':
treelayers.append(vislayer)
if self.GetNextVisible(vislayer) == None:
break
@@ -484,13 +489,6 @@
treelayers.reverse()
self.Map.reorderLayers(treelayers)
- def changeOpacity(self, layer, opacity):
- self.Map.changeOpacity(layer, opacity)
-
- def changeChecked(self, layer, check):
- if self.layertype[layer] != 'group':
- self.Map.changeActive(layer, check)
-
def changeLayer(self, layer):
if self.layertype[layer] == 'command':
if self.GetItemWindow(layer).GetValue() != None:
From cepicky at grass.itc.it Tue Apr 3 18:18:53 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 18:18:54 2007
Subject: [grass-addons] r423 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704031618.l33GIrGR026523@grass.itc.it>
Author: cepicky
Date: 2007-04-03 18:18:53 +0200 (Tue, 03 Apr 2007)
New Revision: 423
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
drawing selected object should work .. but does not
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 15:58:40 UTC (rev 422)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 16:18:53 UTC (rev 423)
@@ -43,11 +43,12 @@
#----------------------------------------------------------------------
class TestVirtualList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
- def __init__(self, parent,log,tablename):
+ def __init__(self, parent,log,tablename,mapset=None):
wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
self.log=log
self.tablename = tablename
+ self.mapset = mapset
self.columns = []
self.columnNumber = 0
self.parent = parent
@@ -127,12 +128,22 @@
self.GetItemText(self.currentItem)))
if self.parent.gismanager:
+
gism = self.parent.gismanager
curr_pg = gism.gm_cb.GetCurrentPage()
disp_idx = gism.track.Track().GetDisp_idx(curr_pg)
- print self.parent.gismanager.mapdisplays#[self.parent.gismanager.disp_idx]
- print self.parent.gismanager.disp_idx
+ mapdisp = self.parent.gismanager.mapdisplays[disp_idx]
+ map = gism.maptree.Map
+ print map.GetListOfLayers()
+ try:
+ map.RemoveLayer(id=self.querylayer.id)
+ except:
+ pass
+ cat = self.GetItemText(self.currentItem)
+ self.querylayer = map.addLayer(item=None, command="d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=3" % (self.tablename, self.mapset, cat), l_active=True,
+ l_hidden=False, l_opacity=1, l_render=False)
+ mapdisp.ReDraw(None)
def OnItemActivated(self, event):
self.currentItem = event.m_itemIndex
@@ -240,7 +251,7 @@
class AttributeManager(wx.Frame):
- def __init__(self, parent, id, title, size, style = wx.DEFAULT_FRAME_STYLE, table=None ):
+ def __init__(self, parent, id, title, size, style = wx.DEFAULT_FRAME_STYLE, table=None,mapset=None ):
wx.Frame.__init__(self, parent, id, title, size=size, style=style)
@@ -251,7 +262,7 @@
# probably
self.gismanager = parent
- self.win = TestVirtualList(self, log,tablename=table)
+ self.win = TestVirtualList(self, log,tablename=table,mapset=mapset)
self.Show()
def main(argv=None):
From cepicky at grass.itc.it Tue Apr 3 18:39:11 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 18:39:12 2007
Subject: [grass-addons] r424 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704031639.l33GdBeQ026632@grass.itc.it>
Author: cepicky
Date: 2007-04-03 18:39:10 +0200 (Tue, 03 Apr 2007)
New Revision: 424
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/gui_modules/render.py
trunk/grassaddons/gui/wxgui.py
Log:
displaying objects works
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 16:18:53 UTC (rev 423)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-03 16:39:10 UTC (rev 424)
@@ -52,6 +52,7 @@
self.columns = []
self.columnNumber = 0
self.parent = parent
+ self.qlayer = None
#adding some attributes (colourful background for each item rows)
self.attr1 = wx.ListItemAttr()
@@ -127,6 +128,7 @@
(self.currentItem,
self.GetItemText(self.currentItem)))
+ # show us the result in map display
if self.parent.gismanager:
gism = self.parent.gismanager
@@ -135,13 +137,11 @@
mapdisp = self.parent.gismanager.mapdisplays[disp_idx]
map = gism.maptree.Map
- print map.GetListOfLayers()
- try:
- map.RemoveLayer(id=self.querylayer.id)
- except:
- pass
+ if self.qlayer:
+ map.RemoveLayer(id=map.layers.index(self.qlayer))
+
cat = self.GetItemText(self.currentItem)
- self.querylayer = map.addLayer(item=None, command="d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=3" % (self.tablename, self.mapset, cat), l_active=True,
+ self.qlayer = map.addLayer(item=None, command="d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=3" % (self.tablename, self.mapset, cat), l_active=True,
l_hidden=False, l_opacity=1, l_render=False)
mapdisp.ReDraw(None)
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-03 16:18:53 UTC (rev 423)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-03 16:39:10 UTC (rev 424)
@@ -855,7 +855,7 @@
return self.layers[-1]
- def delLayer(self, item):
+ def delLayer(self, item, name=None):
"""
Removes layer from list of layers, defined by layer
tree item ID
@@ -866,7 +866,6 @@
Returns:
Removed layer on success or None
"""
- layer = self.lookup[item]
if layer in self.layers:
if layer.mapfile:
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-03 16:18:53 UTC (rev 423)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-03 16:39:10 UTC (rev 424)
@@ -331,7 +331,9 @@
if mapset == grassenv.env["MAPSET"]:
from gui_modules import dbm
- self.dbmanager = gui_modules.dbm.AttributeManager(self, -1,"GRASS Attribute Table Manager: %s" % map, size=wx.Size(500,300),table=map)
+ self.dbmanager = gui_modules.dbm.AttributeManager(self,
+ -1,"GRASS Attribute Table Manager: %s" % map,
+ size=wx.Size(500,300),table=map,mapset=mapset)
def newDisplay(self, event=None):
From cepicky at grass.itc.it Tue Apr 3 18:47:21 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Tue Apr 3 18:47:24 2007
Subject: [grass-addons] r425 - trunk/grassaddons/gui/screenshots
Message-ID: <200704031647.l33GlLq0026704@grass.itc.it>
Author: cepicky
Date: 2007-04-03 18:47:21 +0200 (Tue, 03 Apr 2007)
New Revision: 425
Added:
trunk/grassaddons/gui/screenshots/dbmanager-01.png
Log:
new screenshot
Added: trunk/grassaddons/gui/screenshots/dbmanager-01.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/screenshots/dbmanager-01.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
From barton at grass.itc.it Wed Apr 4 07:50:37 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Apr 4 07:50:40 2007
Subject: [grass-addons] r426 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704040550.l345obCW006036@grass.itc.it>
Author: barton
Date: 2007-04-04 07:48:57 +0200 (Wed, 04 Apr 2007)
New Revision: 426
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
Fix bug in delete layer method.
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-03 16:47:21 UTC (rev 425)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-04 05:48:57 UTC (rev 426)
@@ -866,6 +866,7 @@
Returns:
Removed layer on success or None
"""
+ layer = self.lookup[item]
if layer in self.layers:
if layer.mapfile:
From barton at grass.itc.it Wed Apr 4 07:53:38 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Apr 4 07:53:48 2007
Subject: [grass-addons] r427 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704040553.l345rcQM006088@grass.itc.it>
Author: barton
Date: 2007-04-04 07:53:18 +0200 (Wed, 04 Apr 2007)
New Revision: 427
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Fix bug in map erase routine (Draw method)
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-04 05:48:57 UTC (rev 426)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-04 05:53:18 UTC (rev 427)
@@ -276,11 +276,17 @@
else:
drawid = wx.NewId()
- self.ovlcoords[drawid] = coords
- self.ovlchk[drawid] = True
- pdc.SetId(drawid)
- self.select[drawid] = False
+ if drawid:
+ self.ovlcoords[drawid] = coords
+ self.ovlchk[drawid] = True
+ pdc.SetId(drawid)
+ self.select[drawid] = False
+ pdc.BeginDrawing()
+ pdc.SetBackground(wx.Brush(self.GetBackgroundColour()))
+ pdc.Clear()
+ self.Refresh()
+
if pdctype == 'clear': # erase the display
pdc.EndDrawing()
return
@@ -594,8 +600,8 @@
self.parent.QueryMap(map,mapset,type,east,north)
else:
print "Quering without gis manager not implemented yet"
-
+
elif self.dragid:
self.Refresh()
self.Update()
From barton at grass.itc.it Wed Apr 4 07:58:31 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Apr 4 07:58:44 2007
Subject: [grass-addons] r428 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704040558.l345wV6o006142@grass.itc.it>
Author: barton
Date: 2007-04-04 07:58:00 +0200 (Wed, 04 Apr 2007)
New Revision: 428
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/wxgui.py
Log:
If specific icons and icon sizes specified in map layer, the selection
image will match these icons. Also changed the way that information about
the selected map is obtained to a more reliable algorithm that looks at
the command associated with the layer instead of the layer text (which
can be user edited).
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 05:53:18 UTC (rev 427)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 05:58:00 UTC (rev 428)
@@ -26,7 +26,7 @@
import wx.lib.mixins.listctrl as listmix
import sys,os
-
+
#----------------------------------------------------------------------
class Log:
r"""\brief Needed by the wxdemos.
@@ -43,12 +43,18 @@
#----------------------------------------------------------------------
class TestVirtualList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
- def __init__(self, parent,log,tablename,mapset=None):
+ def __init__(self, parent,log,tablename,mapset=None,pointdata=None):
wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
self.log=log
self.tablename = tablename
self.mapset = mapset
+ self.icon = ''
+ self.pointsize = ''
+
+ self.icon = pointdata[0]
+ self.pointsize = pointdata[1]
+
self.columns = []
self.columnNumber = 0
self.parent = parent
@@ -104,7 +110,7 @@
break
self.SetItemCount(len(self.itemDataMap))
-
+
#mixins
listmix.ListCtrlAutoWidthMixin.__init__(self)
listmix.ColumnSorterMixin.__init__(self, 3)
@@ -117,7 +123,11 @@
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected)
self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
+ self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+ def OnCloseWindow(self, event):
+ if self.qlayer: map.delLayer(item='qlayer')
+
def OnColClick(self,event):
self.columnNumber = event.GetColumn()
event.Skip()
@@ -137,11 +147,15 @@
mapdisp = self.parent.gismanager.mapdisplays[disp_idx]
map = gism.maptree.Map
- if self.qlayer:
- map.RemoveLayer(id=map.layers.index(self.qlayer))
-
+ if self.qlayer: map.delLayer(item='qlayer')
+
cat = self.GetItemText(self.currentItem)
- self.qlayer = map.addLayer(item=None, command="d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=3" % (self.tablename, self.mapset, cat), l_active=True,
+
+ cmd = "d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=3" % (self.tablename, self.mapset, cat)
+ if self.icon: cmd = cmd +" icon=%s" % (self.icon)
+ if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize)
+
+ self.qlayer = map.addLayer(item='qlayer', command=cmd, l_active=True,
l_hidden=False, l_opacity=1, l_render=False)
mapdisp.ReDraw(None)
@@ -195,7 +209,7 @@
# for i in range(len(items)):
# items[i] = str(items[i])
self.itemIndexMap = items
-
+
# redraw the list
self.Refresh()
@@ -251,18 +265,19 @@
class AttributeManager(wx.Frame):
- def __init__(self, parent, id, title, size, style = wx.DEFAULT_FRAME_STYLE, table=None,mapset=None ):
+ def __init__(self, parent, id, title, size, style = wx.DEFAULT_FRAME_STYLE,
+ table=None,mapset=None,pointdata=None):
wx.Frame.__init__(self, parent, id, title, size=size, style=style)
self.CreateStatusBar(1)
log=Log(self)
-
+
# probably
self.gismanager = parent
- self.win = TestVirtualList(self, log,tablename=table,mapset=mapset)
+ self.win = TestVirtualList(self, log,tablename=table,mapset=mapset,pointdata=pointdata)
self.Show()
def main(argv=None):
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-04 05:53:18 UTC (rev 427)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-04 05:58:00 UTC (rev 428)
@@ -323,17 +323,41 @@
)
def ShowAttributeTable(self,event):
- mapsel = self.maptree.GetSelection()
+# mapsel = self.maptree.GetSelection()
+ dcmd = self.maptree.GetPyData(self.maptree.GetSelection())[0]
+ mapname = map = mapset = size = icon = None
+ for item in dcmd.split(' '):
+ if 'map=' in item:
+ mapname = item.split('=')[1]
+ if '@' in mapname:
+ map = mapname.split('@')[0]
+ mapset = mapname.split('@')[1]
+ else:
+ map = mapname
+ elif 'size=' in item:
+ size = item.split('=')[1]
+ print 'size=',size
+ elif 'icon=' in item:
+ icon = item.split('=')[1]
+ print 'icon=',icon
- name = mapsel.GetText()
- if name.find("@") >-1:
- map,mapset = name.strip().split("@")
-
- if mapset == grassenv.env["MAPSET"]:
- from gui_modules import dbm
- self.dbmanager = gui_modules.dbm.AttributeManager(self,
+ pointdata = (icon,size)
+#
+# name = mapsel.GetText()
+# if name.find("@") >-1:
+# map,mapset = name.strip().split("@")
+# if mapset == grassenv.env["MAPSET"]:
+# from gui_modules import dbm
+# self.dbmanager = gui_modules.dbm.AttributeManager(self,
+# -1,"GRASS Attribute Table Manager: %s" % map,
+# size=wx.Size(500,300),table=map,mapset=mapset)
+
+ if mapset == grassenv.env["MAPSET"]:
+ from gui_modules import dbm
+ self.dbmanager = gui_modules.dbm.AttributeManager(self,
-1,"GRASS Attribute Table Manager: %s" % map,
- size=wx.Size(500,300),table=map,mapset=mapset)
+ size=wx.Size(500,300),table=map,mapset=mapset,
+ pointdata=pointdata)
def newDisplay(self, event=None):
From barton at grass.itc.it Wed Apr 4 08:04:57 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Apr 4 08:05:04 2007
Subject: [grass-addons] r429 - trunk/grassaddons/gui
Message-ID: <200704040604.l3464vY7006261@grass.itc.it>
Author: barton
Date: 2007-04-04 08:04:17 +0200 (Wed, 04 Apr 2007)
New Revision: 429
Modified:
trunk/grassaddons/gui/wxgui.py
Log:
Tests for vector file before opening attribute management table
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-04 05:58:00 UTC (rev 428)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-04 06:04:17 UTC (rev 429)
@@ -323,7 +323,12 @@
)
def ShowAttributeTable(self,event):
-# mapsel = self.maptree.GetSelection()
+
+ maptype = self.maptree.layertype[self.maptree.GetSelection()]
+ if maptype != 'vector':
+ print 'Attribute management only available for vector files'
+ return
+
dcmd = self.maptree.GetPyData(self.maptree.GetSelection())[0]
mapname = map = mapset = size = icon = None
for item in dcmd.split(' '):
@@ -342,15 +347,6 @@
print 'icon=',icon
pointdata = (icon,size)
-#
-# name = mapsel.GetText()
-# if name.find("@") >-1:
-# map,mapset = name.strip().split("@")
-# if mapset == grassenv.env["MAPSET"]:
-# from gui_modules import dbm
-# self.dbmanager = gui_modules.dbm.AttributeManager(self,
-# -1,"GRASS Attribute Table Manager: %s" % map,
-# size=wx.Size(500,300),table=map,mapset=mapset)
if mapset == grassenv.env["MAPSET"]:
from gui_modules import dbm
From barton at grass.itc.it Wed Apr 4 08:06:57 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Apr 4 08:07:00 2007
Subject: [grass-addons] r430 - trunk/grassaddons/gui
Message-ID: <200704040606.l3466vMs006285@grass.itc.it>
Author: barton
Date: 2007-04-04 08:05:25 +0200 (Wed, 04 Apr 2007)
New Revision: 430
Modified:
trunk/grassaddons/gui/wxgui.py
Log:
Removed debugging code
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-04 06:04:17 UTC (rev 429)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-04 06:05:25 UTC (rev 430)
@@ -341,10 +341,8 @@
map = mapname
elif 'size=' in item:
size = item.split('=')[1]
- print 'size=',size
elif 'icon=' in item:
icon = item.split('=')[1]
- print 'icon=',icon
pointdata = (icon,size)
From neteler at grass.itc.it Wed Apr 4 09:52:50 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Wed Apr 4 09:53:22 2007
Subject: [grass-addons] r431 - in trunk/grassaddons: . v.curvature
Message-ID: <200704040752.l347qoZP007419@grass.itc.it>
Author: neteler
Date: 2007-04-04 09:51:03 +0200 (Wed, 04 Apr 2007)
New Revision: 431
Added:
trunk/grassaddons/v.curvature/
trunk/grassaddons/v.curvature/Makefile
trunk/grassaddons/v.curvature/description.html
trunk/grassaddons/v.curvature/main.c
Log:
v.curvature from Radim Blazek/ITC-irst
Added: trunk/grassaddons/v.curvature/Makefile
===================================================================
--- trunk/grassaddons/v.curvature/Makefile (rev 0)
+++ trunk/grassaddons/v.curvature/Makefile 2007-04-04 07:51:03 UTC (rev 431)
@@ -0,0 +1,13 @@
+MODULE_TOPDIR = ../..
+
+PGM = v.curvature
+
+LIBES = $(VECTLIB) $(GISLIB)
+DEPENDENCIES= $(VECTDEP) $(GISDEP)
+EXTRA_INC = $(VECT_INC)
+EXTRA_CFLAGS = $(VECT_CFLAGS)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd
+
Added: trunk/grassaddons/v.curvature/description.html
===================================================================
--- trunk/grassaddons/v.curvature/description.html (rev 0)
+++ trunk/grassaddons/v.curvature/description.html 2007-04-04 07:51:03 UTC (rev 431)
@@ -0,0 +1,49 @@
+
DESCRIPTION
+
+v.curvature calculates average curvature along a segment
+given by from/to distance measured along the line specified by
+category.
+
+For individual straight parts of the line, the average curvature as
+calculated from directions of adjacent parts. An average of specified
+segment is then calculated as average from curvatures of line parts
+(lengths of line parts overlapped by specified segment are taken into
+acount).
+
+This method may be used only if line data digitized with appropriate
+accuracy, where 'appropriate' depend on an application we want to use
+it for and on the length of the segment we want to calculate the
+curvature for.
+
+If user needs curvature for too small segments compared to the density
+of vertices on lines, the lines should be smoothed beforehand with
+some other module (this approach is preferred to internal smoothing
+(interpolating) within v.curvature, because automatic smoothing may
+often result in unexpected, unwanted shapes, and user should see which
+data are really processed).
+
+With the 'segment' option, the module reads from 'stdin':
+
+
segment_id line_category from to
+
segment_id - identifier for one segment we need curvature for
+
+
line_category - category of line the segment is on:
+
+
from - distance of segment start from the beginnig of the line
+
to - distance of end of segment from the beginnig of the line
+
+
+Note that if segment limits may exceed the line, segment is cut
+by line ends.
+
+
+Output is written to 'stdout' in format:
+
+ segment_id average_curvature average_radius
+
+
+
AUTHOR
+
+Radim Blazek, ITC-Irst, Trento, Italy
+
+
Last changed: $Date: 2006/01/02 14:44:51 $
Added: trunk/grassaddons/v.curvature/main.c
===================================================================
--- trunk/grassaddons/v.curvature/main.c (rev 0)
+++ trunk/grassaddons/v.curvature/main.c 2007-04-04 07:51:03 UTC (rev 431)
@@ -0,0 +1,358 @@
+/****************************************************************
+*
+* MODULE: v.curvature
+*
+* AUTHOR(S): Radim Blazek
+*
+* PURPOSE: Calculate something similar to curvature of line
+* in specified segment. Module reads from stdin:
+*
+* segment_id line_category from to
+*
+* segment_id - identifier for one segment we need curvature for
+* line_category - category of line the segment is on
+* from - distance of segment start from the beginnig of the line
+* to - distance of end of segment from the beginnig of the line
+*
+* Note that if segment limits may exceed the line, segment is cuted
+* by line ends.
+*
+* Output is written to stdout in format:
+*
+* segment_id average_curvature average_radius
+*
+*
+* COPYRIGHT: (C) 2001 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.
+*
+****************************************************************/
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define OPTION_SEGMENT 1
+#define OPTION_LINES 2
+
+
+double calc_curv (struct line_pnts *Points, int part);
+double part_length (struct line_pnts *Points, int part);
+
+int
+main (int argc, char *argv[])
+{
+ int i, row;
+ char buf[1024];
+ struct Map_info Map;
+ struct line_pnts *Points;
+ struct line_cats *Cats;
+ int field, type, ctype, action;
+ int id, cat, ccat, part, end;
+ double from, to, rad;
+ double line_len, seg_len, calc_len, part_len, rest_len, dist, len;
+ double x, y, z, dx, dy, dz;
+ double cur, curva;
+ int field_index, cinlines;
+ struct GModule *module;
+ struct Option *map_opt, *type_opt, *field_opt, *act_opt;
+ struct Flag *abs_flag;
+
+ module = G_define_module();
+ module->keywords = _("vector, segment, curvature");
+ module->description = _("Calculate curvature. With segment option it reads from standard input:\n"
+ "segment_id line_category from to\n"
+ "and writes to standard output:\n"
+ "segment_id average_curvature average_radius\n"
+ "If a segment given runs outside the line, it is cut. "
+ "If more lines with the same category "
+ "are found, curvature is not calculated and warning is printed.");
+
+ map_opt = G_define_standard_option(G_OPT_V_INPUT);
+ map_opt->key = "map";
+
+ type_opt = G_define_standard_option(G_OPT_V_TYPE) ;
+ type_opt->options = "line,boundary";
+ type_opt->answer = "line";
+
+ field_opt = G_define_standard_option(G_OPT_V_FIELD);
+
+ act_opt = G_define_option() ;
+ act_opt->key = "option" ;
+ act_opt->type = TYPE_STRING ;
+ act_opt->required = NO ;
+ act_opt->multiple = NO;
+ act_opt->answer = "segment" ;
+ act_opt->options = "segment,lines";
+ act_opt->description= _("Option");
+ act_opt->descriptions= _("segment; reads segments from standard input;"
+ "lines; calculate curvature for all sements of all lines");
+
+ abs_flag = G_define_flag ();
+ abs_flag->key = 'a';
+ abs_flag->description = _("Calculate average from absolute values "
+ "(if not used, segment over 2 successive contrary "
+ "curves can result in curvature near 0).");
+
+ G_gisinit(argv[0]);
+ if (G_parser (argc, argv))
+ exit(EXIT_FAILURE);
+
+ field = atoi( field_opt->answer );
+
+ i = 0;
+ ctype = 0;
+ while (type_opt->answers[i])
+ {
+ switch ( type_opt->answers[i][0] )
+ {
+ case 'l':
+ ctype |= GV_LINE;
+ break;
+ case 'b':
+ ctype |= GV_BOUNDARY;
+ break;
+ }
+ i++;
+ }
+
+ action = OPTION_SEGMENT;
+ if ( act_opt->answer[0] == 'l' )
+ action = OPTION_LINES;
+
+ Points = Vect_new_line_struct ();
+ Cats = Vect_new_cats_struct ();
+
+ /* open input vector */
+ Vect_set_open_level (2);
+ Vect_open_old (&Map, map_opt->answer, "");
+
+ cinlines = Vect_cidx_get_type_count ( &Map, field, ctype);
+
+ if ( cinlines == 0 )
+ {
+ G_warning ( _("No lines in layer %d"), field );
+ }
+
+ if ( action == OPTION_SEGMENT && cinlines > 0 ) {
+ int idx, line, type, cincats, dummy1, dummy2;
+
+ field_index = Vect_cidx_get_field_index ( &Map, field );
+ cincats = Vect_cidx_get_num_cats_by_index ( &Map, field_index );
+ G_debug ( 3, "cincats = %d", cincats );
+
+ row = 0;
+ while ( fgets(buf,1024,stdin) != NULL ) {
+ row++;
+ if ( sscanf(buf, "%d %d %lf %lf", &id, &ccat, &from, &to) != 4 ) {
+ G_warning (_("Incorrect format on row %d: %s"), row, buf);
+ continue;
+ }
+
+ G_debug (2, "read: %d %d %f %f", id, ccat, from, to);
+
+ /* Find line by category */
+ idx = Vect_cidx_find_next ( &Map, field_index, ccat, ctype, 0, &type, &line );
+
+ if ( idx < 0 ) {
+ G_warning ( _("Line with category %d not found"), ccat );
+ fprintf (stdout, "%d - -\n", id);
+ continue;
+ }
+
+ if ( (idx + 1 < cincats) &&
+ Vect_cidx_find_next ( &Map, field_index, ccat, ctype, idx+1, &dummy1, &dummy2 ) >= 0 )
+ {
+ /* Second line found */
+ G_warning ( _("More lines with category %d found"), ccat );
+ fprintf (stdout, "%d - -\n", id);
+ continue;
+ }
+
+ Vect_read_line ( &Map, Points, Cats, line );
+
+ G_debug (2, "n_points = %d", Points->n_points );
+ if ( Points->n_points < 2 ) {
+ G_warning ( _("Degenerated line with category %d"), ccat );
+ fprintf (stdout, "%d - -\n", id);
+ continue;
+ }
+
+ line_len = Vect_line_length (Points);
+
+ if ( from > line_len || to < 0 ) {
+ G_warning ( _("Segment outside the line (id = %d)"), id );
+ fprintf (stdout, "%d - -\n", id);
+ continue;
+ }
+
+ if ( from < 0 ) {
+ G_warning ( _("Start of segment %d < 0"), id );
+ from = 0.;
+ }
+ if ( to > line_len ) {
+ G_warning ( _("End of segment %d > line length"), id );
+ to = line_len;
+ }
+ seg_len = to - from;
+ G_debug (2, "seg_len = %f", seg_len);
+
+ /* first segment */
+ part = Vect_point_on_line ( Points, from, &x, &y, &z, NULL, NULL );
+ G_debug (2, "first part = %d", part);
+
+ /* distance from the beginnig of line part */
+ dx = x - Points->x[part-1];
+ dy = y - Points->y[part-1];
+ dz = z - Points->z[part-1];
+ dist = hypot (dx, dy);
+ dist = hypot (dist, dz);
+
+ calc_len = 0; curva = 0; end = 0;
+ for ( i = part; i < Points->n_points; i++ ) {
+ G_debug (2, "i = %d", i);
+
+ part_len = part_length (Points, i);
+ cur = calc_curv (Points, i);
+ if (abs_flag->answer && (cur < 0) ) cur = -cur;
+
+ rest_len = seg_len - calc_len;
+
+ /* length of used part of part */
+ if ( part_len >= (rest_len + dist) ) { /* end of segment reached */
+ len = rest_len;
+ end = 1;
+ } else {
+ len = part_len - dist;
+ }
+ G_debug (2, "part_len = %f len = %f", part_len, len);
+
+
+ /* cumulate curvature */
+ curva += cur * len;
+ G_debug (2, "curva = %f", curva );
+
+ calc_len += len;
+
+ if ( end ) break;
+
+ dist = 0; /* start of segment from the beginnig of part for next parts */
+ }
+
+ curva /= seg_len;
+ rad = 1 / curva;
+
+ fprintf (stdout, "%d %f %f\n", id, curva, rad);
+ fflush (stdout);
+ }
+ } else if ( OPTION_LINES && cinlines > 0 ) {
+ Vect_rewind ( &Map );
+ while ( (type = Vect_read_next_line (&Map, Points, Cats)) > 0) {
+ if ( !(type & ctype) ) continue;
+
+ /* TODO: more cats int the same layer */
+ cat = 0;
+ if( Vect_cat_get(Cats, field, &cat) == 0 ) {
+ continue;
+ }
+
+ G_debug (2, "n_points = %d", Points->n_points );
+ if ( Points->n_points < 2 ) {
+ G_warning ( _("Degenerated line with category %d"), ccat );
+ continue;
+ }
+
+ for ( part = 1; part < Points->n_points; part++ ) {
+ G_debug (2, "part = %d", part);
+
+ part_len = part_length (Points, part);
+ cur = calc_curv (Points, part);
+ if (abs_flag->answer && (cur < 0) ) cur = -cur;
+
+ rad = 1 / cur;
+
+ fprintf (stdout, "%d %f %f %f\n", cat, part_len, cur, rad);
+ fflush (stdout);
+ }
+ }
+ }
+
+ Vect_close (&Map);
+
+ exit(EXIT_SUCCESS) ;
+}
+
+/* Calculate curvature of segment */
+double calc_curv (struct line_pnts *Points, int part)
+{
+ double part_len;
+ double dx, dy;
+ double ang, ang1, ang2, part_ang, cur;
+
+ /* segment angle */
+ dx = Points->x[part] - Points->x[part-1];
+ dy = Points->y[part] - Points->y[part-1];
+ part_ang = atan2 ( dy, dx );
+ G_debug (2, "part: dx = %f dy = %f part_ang = %f", dx, dy, part_ang);
+
+ /* angle 1 */
+ if ( part == 1 ) { /* first segment */
+ ang1 = 0;
+ G_debug (2, "1: first seg ang1 = 0");
+ } else {
+ dx = Points->x[part-1] - Points->x[part-2];
+ dy = Points->y[part-1] - Points->y[part-2];
+ ang = atan2 ( dy, dx );
+ ang1 = part_ang - ang;
+ G_debug (2, "1: %d->%d: %f, %f -> %f, %f",part-2,part-1,
+ Points->x[part-2], Points->y[part-2], Points->x[part-1], Points->y[part-1] );
+ G_debug (2, "1: dx = %f dy = %.10f ang = %f, ang1 = %f", dx, dy, ang, ang1);
+ if ( ang1 < -M_PI ) ang1 += 2 * M_PI;
+ if ( ang1 > M_PI ) ang1 -= 2 * M_PI;
+ G_debug (2, "1: -> ang1 = %f", ang1);
+ }
+ /* angle 2 */
+ if ( part == Points->n_points - 1 ) { /* last segment */
+ ang2 = 0;
+ G_debug (2, "2: last seg ang2 = 0");
+ } else {
+ dx = Points->x[part+1] - Points->x[part];
+ dy = Points->y[part+1] - Points->y[part];
+ ang = atan2 ( dy, dx );
+ ang2 = ang - part_ang;
+ G_debug (2, "2: %d->%d: %f, %f -> %f, %f",part,part+1,
+ Points->x[part+1], Points->y[part+1], Points->x[part], Points->y[part] );
+ G_debug (2, "2: dx = %f dy = %.10f ang = %f ang2 = %f", dx, dy, ang, ang2);
+ if ( ang2 < -M_PI ) ang2 += 2 * M_PI;
+ if ( ang2 > M_PI ) ang2 -= 2 * M_PI;
+ G_debug (2, "2: -> ang2 = %f", ang2);
+ }
+
+ /* curvature */
+ part_len = part_length (Points, part);
+ cur = 2 * sin ( (ang1 + ang2) / 4 ) / part_len ;
+
+ G_debug (2, "cur = %f R = %f", cur, 1/cur );
+
+ return cur;
+}
+
+double part_length (struct line_pnts *Points, int part) {
+ double dx, dy, dz, len;
+
+ /* length of segment */
+ dx = Points->x[part] - Points->x[part-1];
+ dy = Points->y[part] - Points->y[part-1];
+ dz = Points->z[part] - Points->z[part-1];
+ len = hypot (dx, dy);
+ len = hypot (len, dz);
+
+ return len;
+}
+
From cepicky at grass.itc.it Wed Apr 4 16:47:57 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Wed Apr 4 16:47:59 2007
Subject: [grass-addons] r432 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704041447.l34Elvln014805@grass.itc.it>
Author: cepicky
Date: 2007-04-04 16:47:57 +0200 (Wed, 04 Apr 2007)
New Revision: 432
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/wxgui.py
Log:
* displaing tables from different mapsets possible
* images for sorting added
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 07:51:03 UTC (rev 431)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 14:47:57 UTC (rev 432)
@@ -25,7 +25,7 @@
import wx
import wx.lib.mixins.listctrl as listmix
-import sys,os
+import sys,os,locale
#----------------------------------------------------------------------
class Log:
@@ -43,20 +43,25 @@
#----------------------------------------------------------------------
class TestVirtualList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
- def __init__(self, parent,log,tablename,mapset=None,pointdata=None):
+ def __init__(self, parent,log,vectmap,pointdata=None):
wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
self.log=log
- self.tablename = tablename
- self.mapset = mapset
+
+ self.vectmap = vectmap
+ self.mapname, self.mapset = self.vectmap.split("@")
+ self.layer,self.tablename, self.column, self.database, self.driver =\
+ os.popen("v.db.connect -g map=%s" %\
+ (self.vectmap)).readlines()[0].strip().split()
+
self.icon = ''
self.pointsize = ''
- self.icon = pointdata[0]
- self.pointsize = pointdata[1]
+ if pointdata:
+ self.icon = pointdata[0]
+ self.pointsize = pointdata[1]
self.columns = []
- self.columnNumber = 0
self.parent = parent
self.qlayer = None
@@ -65,13 +70,17 @@
self.attr1.SetBackgroundColour("light blue")
self.attr2 = wx.ListItemAttr()
self.attr2.SetBackgroundColour("white")
+ self.il = wx.ImageList(16, 16)
+ self.sm_up = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_UP,wx.ART_TOOLBAR,(16,16)))
+ self.sm_dn = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_DOWN,wx.ART_TOOLBAR,(16,16)))
+ self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
#building the columns
i = 0
# FIXME: subprocess.Popen should be used
# FIXME: Maximal number of columns, when the GUI is still usable
- for line in os.popen("db.describe -c table=%s" %
- (self.tablename)).readlines()[1:]:
+ for line in os.popen("db.describe -c table=%s driver=%s database=%s" %\
+ (self.tablename, self.driver, self.database)).readlines()[1:]:
x,column,type = line.strip().split(":")
# FIXME: here will be more types
@@ -98,7 +107,8 @@
# FIXME: subprocess.Popen should be used
# FIXME: Max. number of rows, while the GUI is still usable
i = 0
- for line in os.popen("""db.select -c sql="SELECT * FROM %s" """ % self.tablename):
+ for line in os.popen("""db.select -c table=%s database=%s driver=%s """ %\
+ (self.tablename,self.database,self.driver)):
attributes = line.strip().split("|")
self.itemDataMap[i] = []
for attribute in attributes:
@@ -113,7 +123,7 @@
#mixins
listmix.ListCtrlAutoWidthMixin.__init__(self)
- listmix.ColumnSorterMixin.__init__(self, 3)
+ listmix.ColumnSorterMixin.__init__(self, len(self.columns))
#sort by genre (column 2), A->Z ascending order (1)
self.SortListItems(0, 1)
@@ -129,7 +139,7 @@
if self.qlayer: map.delLayer(item='qlayer')
def OnColClick(self,event):
- self.columnNumber = event.GetColumn()
+ self._col = event.GetColumn()
event.Skip()
def OnItemSelected(self, event):
@@ -222,8 +232,14 @@
col = self._col
ascending = self._colSortFlag[col]
# convert, because the it is allways string
- item1 = self.columns[col]["type"](self.itemDataMap[key1][col])
- item2 = self.columns[col]["type"](self.itemDataMap[key2][col])
+ try:
+ item1 = self.columns[col]["type"](self.itemDataMap[key1][col])
+ except:
+ item1 = ''
+ try:
+ item2 = self.columns[col]["type"](self.itemDataMap[key2][col])
+ except:
+ item2 = ''
#--- Internationalization of string sorting with locale module
if type(item1) == type('') or type(item2) == type(''):
@@ -245,8 +261,8 @@
# self.columns[self.columnNumber]["type"](b))
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
- #def GetSortImages(self):
- # return (self.sm_dn, self.sm_up)
+ def GetSortImages(self):
+ return (self.sm_dn, self.sm_up)
#XXX Looks okay to remove this one (was present in the original demo)
#def getColumnText(self, index, col):
@@ -266,7 +282,7 @@
class AttributeManager(wx.Frame):
def __init__(self, parent, id, title, size, style = wx.DEFAULT_FRAME_STYLE,
- table=None,mapset=None,pointdata=None):
+ vectmap=None,pointdata=None):
wx.Frame.__init__(self, parent, id, title, size=size, style=style)
@@ -277,7 +293,7 @@
# probably
self.gismanager = parent
- self.win = TestVirtualList(self, log,tablename=table,mapset=mapset,pointdata=pointdata)
+ self.win = TestVirtualList(self, log,vectmap=vectmap,pointdata=pointdata)
self.Show()
def main(argv=None):
@@ -297,7 +313,7 @@
#wx.InitAllImageHandlers()
app = wx.PySimpleApp()
- f = AttributeManager(None, -1, "GRASS Attribute Table Manager",wx.Size(500,300),table=argv[1])
+ f = AttributeManager(None, -1, "GRASS Attribute Table Manager",wx.Size(500,300),vectmap=argv[1])
app.MainLoop()
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-04 07:51:03 UTC (rev 431)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-04 14:47:57 UTC (rev 432)
@@ -334,11 +334,6 @@
for item in dcmd.split(' '):
if 'map=' in item:
mapname = item.split('=')[1]
- if '@' in mapname:
- map = mapname.split('@')[0]
- mapset = mapname.split('@')[1]
- else:
- map = mapname
elif 'size=' in item:
size = item.split('=')[1]
elif 'icon=' in item:
@@ -346,12 +341,11 @@
pointdata = (icon,size)
- if mapset == grassenv.env["MAPSET"]:
- from gui_modules import dbm
- self.dbmanager = gui_modules.dbm.AttributeManager(self,
- -1,"GRASS Attribute Table Manager: %s" % map,
- size=wx.Size(500,300),table=map,mapset=mapset,
- pointdata=pointdata)
+ from gui_modules import dbm
+ self.dbmanager = gui_modules.dbm.AttributeManager(self,
+ -1,"GRASS Attribute Table Manager: %s" % map,
+ size=wx.Size(500,300),vectmap=mapname,
+ pointdata=pointdata)
def newDisplay(self, event=None):
From cepicky at grass.itc.it Wed Apr 4 16:53:46 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Wed Apr 4 16:53:48 2007
Subject: [grass-addons] r433 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704041453.l34ErkKT015701@grass.itc.it>
Author: cepicky
Date: 2007-04-04 16:53:46 +0200 (Wed, 04 Apr 2007)
New Revision: 433
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
debuging stuff
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-04 14:47:57 UTC (rev 432)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-04 14:53:46 UTC (rev 433)
@@ -594,6 +594,8 @@
# render map layers
for layer in self.layers:
+ if DEBUG:
+ print "rendering", layer.name
# skip if hidden or not active
if layer.active == False or layer.hidden == True:
continue
@@ -611,6 +613,8 @@
maps.append(layer.mapfile)
masks.append(layer.maskfile)
opacities.append(str(layer.opacity))
+ if DEBUG:
+ print "rendered", layer.name
# make arrays to strings
mapstr = ",".join(maps)
From barton at grass.itc.it Wed Apr 4 16:59:59 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Apr 4 17:00:01 2007
Subject: [grass-addons] r434 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704041459.l34Exx6q015737@grass.itc.it>
Author: barton
Date: 2007-04-04 16:59:50 +0200 (Wed, 04 Apr 2007)
New Revision: 434
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
Attribute table can now grab map display coordinates when clicked with
a mouse. Moving toward implementing v.what to select attribute when
vector object is selected.
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 14:53:46 UTC (rev 433)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 14:59:50 UTC (rev 434)
@@ -27,6 +27,12 @@
import sys,os,locale
+try:
+ from subprocess import *
+except:
+ from compat import subprocess
+ from compat.subprocess import *
+
#----------------------------------------------------------------------
class Log:
r"""\brief Needed by the wxdemos.
@@ -75,6 +81,17 @@
self.sm_dn = self.il.Add(wx.ArtProvider_GetBitmap(wx.ART_GO_DOWN,wx.ART_TOOLBAR,(16,16)))
self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
+ # show us the result in map display
+ if self.parent.gismanager:
+
+ self.gism = self.parent.gismanager
+ curr_pg = self.gism.gm_cb.GetCurrentPage()
+ disp_idx = self.gism.track.Track().GetDisp_idx(curr_pg)
+
+ self.mapdisp = self.parent.gismanager.mapdisplays[disp_idx]
+ self.map = self.gism.maptree.Map
+
+
#building the columns
i = 0
# FIXME: subprocess.Popen should be used
@@ -134,9 +151,11 @@
self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected)
self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+ self.mapdisp.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.onMapClick)
+
def OnCloseWindow(self, event):
- if self.qlayer: map.delLayer(item='qlayer')
+ if self.qlayer: self.map.delLayer(item='qlayer')
def OnColClick(self,event):
self._col = event.GetColumn()
@@ -151,23 +170,23 @@
# show us the result in map display
if self.parent.gismanager:
- gism = self.parent.gismanager
- curr_pg = gism.gm_cb.GetCurrentPage()
- disp_idx = gism.track.Track().GetDisp_idx(curr_pg)
+# gism = self.parent.gismanager
+# curr_pg = gism.gm_cb.GetCurrentPage()
+# disp_idx = gism.track.Track().GetDisp_idx(curr_pg)
- mapdisp = self.parent.gismanager.mapdisplays[disp_idx]
- map = gism.maptree.Map
- if self.qlayer: map.delLayer(item='qlayer')
+# mapdisp = self.parent.gismanager.mapdisplays[disp_idx]
+# map = gism.maptree.Map
+ if self.qlayer: self.map.delLayer(item='qlayer')
cat = self.GetItemText(self.currentItem)
- cmd = "d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=3" % (self.tablename, self.mapset, cat)
+ cmd = "d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=3" % (self.tablename, self.self.mapset, cat)
if self.icon: cmd = cmd +" icon=%s" % (self.icon)
if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize)
- self.qlayer = map.addLayer(item='qlayer', command=cmd, l_active=True,
+ self.qlayer = self.map.addLayer(item='qlayer', command=cmd, l_active=True,
l_hidden=False, l_opacity=1, l_render=False)
- mapdisp.ReDraw(None)
+ self.mapdisp.ReDraw(None)
def OnItemActivated(self, event):
self.currentItem = event.m_itemIndex
@@ -269,6 +288,64 @@
# item = self.GetItem(index, col)
# return item.GetText()
+ def onMapClick(self, event):
+ """
+ Gets coordinates from mouse clicking on display window
+ """
+ # screen coordinates
+ posx, posy = event.GetPositionTuple()
+
+ # map coordinates
+ x, y = self.mapdisp.MapWindow.Pixel2Cell(posx, posy)
+ print 'coordinates =',x,y
+
+
+# try:
+# os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
+# cmd = "v.what -a east_north=%d,%d distance=%d map=%@%" % (x,y,100,self.tablename, self.self.mapset)
+## self.cmd_output.write(cmd+"\n----------\n")
+# p = Popen(cmd +" --verbose", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
+#
+# oline = p.stderr.readline()
+# while oline:
+# oline = oline.strip()
+# oline = p.stderr.readline()
+# if oline.find("GRASS_INFO_MESSAGE")>-1:
+# self.cmd_output.write(string.split(oline,maxsplit=1)[1]+"\n")
+# elif oline.find("GRASS_INFO_WARNING")>-1:
+# self.cmd_output.write("WARNING: "+string.split(oline,maxsplit=1)[1]+"\n")
+# elif oline.find("GRASS_INFO_ERROR")>-1:
+# self.cmd_output.write("ERROR: "+string.split(oline,maxsplit=1)[1]+"\n")
+#
+# oline = p.stdout.readline()
+# while oline:
+# oline = oline.strip()
+## self.cmd_output.write(oline+"\n")
+# print oline+"\n"
+# print >> sys.stderr, oline
+# oline = p.stdout.readline()
+#
+# if p.stdout < 0:
+# print >> sys.stderr, "Child was terminated by signal", p.stdout
+# elif p.stdout > 0:
+# print >> sys.stderr, p.stdout
+# pass
+# except OSError, e:
+# print >> sys.stderr, "Execution failed:", e
+
+
+
+ event.Skip()
+
+
+
+
+
+
+
+
+
+
#----------------------------------------------------------------------
# The main window
#----------------------------------------------------------------------
From cepicky at grass.itc.it Wed Apr 4 17:07:05 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Wed Apr 4 17:07:06 2007
Subject: [grass-addons] r435 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704041507.l34F75Ve015822@grass.itc.it>
Author: cepicky
Date: 2007-04-04 17:07:05 +0200 (Wed, 04 Apr 2007)
New Revision: 435
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
bug in PNG driver? elusion
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 14:59:50 UTC (rev 434)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 15:07:05 UTC (rev 435)
@@ -180,7 +180,9 @@
cat = self.GetItemText(self.currentItem)
- cmd = "d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=3" % (self.tablename, self.self.mapset, cat)
+ # FIXME: width=1, because of maybe bug in PNG driver elusion
+ # should be width=3 or something like this
+ cmd = "d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=1" % (self.tablename, self.self.mapset, cat)
if self.icon: cmd = cmd +" icon=%s" % (self.icon)
if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize)
From cepicky at grass.itc.it Wed Apr 4 17:10:09 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Wed Apr 4 17:10:10 2007
Subject: [grass-addons] r436 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704041510.l34FA9cU015868@grass.itc.it>
Author: cepicky
Date: 2007-04-04 17:10:09 +0200 (Wed, 04 Apr 2007)
New Revision: 436
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
shorter map name
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 15:07:05 UTC (rev 435)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 15:10:09 UTC (rev 436)
@@ -182,7 +182,7 @@
# FIXME: width=1, because of maybe bug in PNG driver elusion
# should be width=3 or something like this
- cmd = "d.vect map=%s@%s color=yellow fcolor=yellow cats=%s width=1" % (self.tablename, self.self.mapset, cat)
+ cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=1" % (self.vectmap, cat)
if self.icon: cmd = cmd +" icon=%s" % (self.icon)
if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize)
From cepicky at grass.itc.it Wed Apr 4 17:52:43 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Wed Apr 4 17:52:43 2007
Subject: [grass-addons] r437 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704041552.l34FqhmM016133@grass.itc.it>
Author: cepicky
Date: 2007-04-04 17:52:43 +0200 (Wed, 04 Apr 2007)
New Revision: 437
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
displaing mouse selection in attribute table possible
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 15:10:09 UTC (rev 436)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-04 15:52:43 UTC (rev 437)
@@ -151,9 +151,11 @@
self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected)
self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
- self.mapdisp.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.onMapClick)
+ if self.parent.gismanager:
+ self.mapdisp.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.onMapClick)
+
def OnCloseWindow(self, event):
if self.qlayer: self.map.delLayer(item='qlayer')
@@ -162,12 +164,14 @@
event.Skip()
def OnItemSelected(self, event):
+ print "Selecting"
self.currentItem = event.m_itemIndex
self.log.write('OnItemSelected: "%s", "%s"\n' %
(self.currentItem,
self.GetItemText(self.currentItem)))
# show us the result in map display
+ #print self.par
if self.parent.gismanager:
# gism = self.parent.gismanager
@@ -299,9 +303,25 @@
# map coordinates
x, y = self.mapdisp.MapWindow.Pixel2Cell(posx, posy)
- print 'coordinates =',x,y
+ #print 'coordinates =',x,y
+ category = ""
+ for line in os.popen("v.what east_north=%f,%f map=%s" %\
+ (x,y,self.vectmap)).readlines():
+ if "Category:" in line:
+ category = line.strip().split(" ")[1]
+ #print category
+
+ for idx in range(self.GetItemCount()):
+ item = self.GetItem(idx, 0)
+ if item.GetText() == category:
+ #print idx
+ self.Select(idx,True)
+ else:
+ self.Select(idx,False)
+
+
# try:
# os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
# cmd = "v.what -a east_north=%d,%d distance=%d map=%@%" % (x,y,100,self.tablename, self.self.mapset)
@@ -341,13 +361,52 @@
+# try:
+# os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
+# cmd = "v.what -a east_north=%d,%d distance=%d map=%@%" % (x,y,100,self.tablename, self.self.mapset)
+## self.cmd_output.write(cmd+"\n----------\n")
+# p = Popen(cmd +" --verbose", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
+#
+# oline = p.stderr.readline()
+# while oline:
+# oline = oline.strip()
+# oline = p.stderr.readline()
+# if oline.find("GRASS_INFO_MESSAGE")>-1:
+# self.cmd_output.write(string.split(oline,maxsplit=1)[1]+"\n")
+# elif oline.find("GRASS_INFO_WARNING")>-1:
+# self.cmd_output.write("WARNING: "+string.split(oline,maxsplit=1)[1]+"\n")
+# elif oline.find("GRASS_INFO_ERROR")>-1:
+# self.cmd_output.write("ERROR: "+string.split(oline,maxsplit=1)[1]+"\n")
+#
+# oline = p.stdout.readline()
+# while oline:
+# oline = oline.strip()
+## self.cmd_output.write(oline+"\n")
+# print oline+"\n"
+# print >> sys.stderr, oline
+# oline = p.stdout.readline()
+#
+# if p.stdout < 0:
+# print >> sys.stderr, "Child was terminated by signal", p.stdout
+# elif p.stdout > 0:
+# print >> sys.stderr, p.stdout
+# pass
+# except OSError, e:
+# print >> sys.stderr, "Execution failed:", e
+ event.Skip()
+
+
+
+
+
+
#----------------------------------------------------------------------
# The main window
#----------------------------------------------------------------------
From chemin at grass.itc.it Wed Apr 4 21:43:22 2007
From: chemin at grass.itc.it (chemin@grass.itc.it)
Date: Wed Apr 4 21:43:23 2007
Subject: [grass-addons] r438 - trunk/grassaddons/gipe/script_generator
Message-ID: <200704041943.l34JhMho018594@grass.itc.it>
Author: chemin
Date: 2007-04-04 21:43:18 +0200 (Wed, 04 Apr 2007)
New Revision: 438
Modified:
trunk/grassaddons/gipe/script_generator/l7_in_read.c
Log:
Updated script generator to ET Prestley-Taylor
Modified: trunk/grassaddons/gipe/script_generator/l7_in_read.c
===================================================================
--- trunk/grassaddons/gipe/script_generator/l7_in_read.c 2007-04-04 15:52:43 UTC (rev 437)
+++ trunk/grassaddons/gipe/script_generator/l7_in_read.c 2007-04-04 19:43:18 UTC (rev 438)
@@ -83,8 +83,9 @@
char sys_9[1000],sys_10[1000],sys_100[1000];
char sys_11[1000],sys_12[1000],sys_13[1000],sys_14[1000];
char sys_15[1000],sys_16[1000],sys_17[1000],sys_18[1000];
+ char sys_19[1000],sys_20[1000],sys_21[1000],sys_22[1000];
+ char sys_23[1000];
-
if(argc < 1){
usage();
}
@@ -624,6 +625,17 @@
system(sys_17);
sprintf(sys_10,"echo \"r.evapo.TSA RNET=%s.rnetd FV=%s.ndvi TEMPK=%s.61 TEMPKA=%s.tempka ALB=%s.albedo NDVI=%s.ndvi UZ=u2 Z=2.0 Z0=%s.z0h Z0S=z0s W=%s.w TIME=%s.sath SUNH=%s.sunh output=%s.ETA_TSA --overwrite\" >> temp.txt",basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate);
system(sys_10);
+ sprintf(sys_19,"echo \"r.mapcalc %s.patm=1010.0\" >> temp.txt",basedate);
+ system(sys_19);
+ sprintf(sys_20,"echo \"r.emissivity ndvi=%s.ndvi emissivity=%s.e0 --overwrite\" >> temp.txt",basedate,basedate);
+ system(sys_20);
+ sprintf(sys_21,"echo \"r.eb.netrad albedo=%s.albedo ndvi=%s.ndvi tempk=%s.61 time=%s.time dtair=%s.delta emissivity=%s.e0 tsw=%s.tsw doy=%s.doy sunzangle=%s.sunza rnet=%s.rnet --overwrite\" >> temp.txt",basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate,basedate);
+ system(sys_21);
+ sprintf(sys_22,"echo \"r.eb.g0 albedo=%s.albedo ndvi=%s.ndvi tempk=%s.61 rnet=%s.rnet time=%s.time g0=%s.g0 --overwrite\"",basedate,basedate,basedate,basedate,basedate,basedate);
+ system(sys_22);
+ sprintf(sys_23,"echo \"r.evapo.PT -z RNET=%s.rnetd G0=%s.g0 TEMPKA=%s.tempka PATM=%s.patm PT=1.26 output=%s.ETA_PT --overwrite\"",basedate,basedate,basedate,basedate,basedate);
+ system(sys_23);
+
//clean maps
// system("chmod +x temp.txt; cat temp.txt; echo \"Start GRASS Processing\n\" ; ./temp.txt");
From neteler at grass.itc.it Thu Apr 5 08:15:20 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Thu Apr 5 08:15:22 2007
Subject: [grass-addons] r439 - trunk/grassaddons
Message-ID: <200704050615.l356FKM1025736@grass.itc.it>
Author: neteler
Date: 2007-04-05 08:15:20 +0200 (Thu, 05 Apr 2007)
New Revision: 439
Added:
trunk/grassaddons/SUBMITTING
trunk/grassaddons/SUBMITTING_SCRIPTS
trunk/grassaddons/SUBMITTING_TCLTK
Log:
GRASS submission rules also apply here
Added: trunk/grassaddons/SUBMITTING
===================================================================
--- trunk/grassaddons/SUBMITTING (rev 0)
+++ trunk/grassaddons/SUBMITTING 2007-04-05 06:15:20 UTC (rev 439)
@@ -0,0 +1,391 @@
+$Id: SUBMITTING,v 1.22 2006/08/09 09:27:57 markus Exp $
+
+NOTE: Please improve this list!
+
+Dear (new) GRASS Developer,
+
+When submitting C code to GRASS Addons-SVN repository, please take
+care of following rules:
+
+[ see SUBMITTING_SCRIPTS for shell script hints ]
+[ see SUBMITTING_TCLTK for tcl and tk hints ]
+
+
+1. Get and read the GRASS 6 Programmer's Manual here:
+ http://grass.itc.it/devel/index.php#prog
+
+ or generate it from this source code (the programmer's manual is
+ integrated in the source code in doxygen style):
+ make htmldocs
+ make pdfdocs
+
+
+2. Use the directory structure to place your module appropriately into
+ the source tree
+ - libes go into lib/
+ - raster goes into raster/
+ - vector goes into vector/
+ - ...
+
+ Consider to take a look at "GNU Coding Standards"
+ http://www.gnu.org/prep/standards.html
+
+ In future, there will be a centralized contribution directory.
+
+3. Add a header section to each file you submit and make sure you include
+ the copyright. The purpose section is meant to contain a general
+ overview of the code in the file to assist other programmers that will
+ need to make changes to your code.
+
+ Example (ficticious header for a file called color.c) :
+
+/****************************************************************************
+ *
+ * MODULE: d.rast (or new higher level module name (eg GRASS core)
+ * for 6.1)
+ * AUTHOR(S): Original author unknown - probably CERL
+ * John Doe - jdoe@some.where.org
+ * PURPOSE: To provide storage and manipulation of colors used for
+ * rendering the raster. The colors are stored in a doubly linked
+ * list which must be initialized with InitColors() before it can
+ * be used. Note that most linked list functionality (add,
+ * remove, get) is supported, but their is no sorting
+ * functionality.
+ * COPYRIGHT: (C) 2005 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.
+ *
+ *****************************************************************************/
+
+ The copyright protects your rights according to GNU General Public
+ License (www.gnu.org).
+
+
+4. - deleted.
+ We don't want the $ ID $ in source code any more as it causes problems
+ for the CVS branches.
+
+
+5. To ensure that the software system continues to work, please include
+
+ #include
+
+ in your files and make use of the various system dependencies
+ contained therein. As one example of this, see
+ lib/gmath/fft.c . Please refrain from declaring
+ system functions within the software; include the proper header files
+ (conditionally dependent on config.h macros if necessary) instead.
+
+
+6. Order of include headers
+
+ In general, headers should be included in the order:
+
+ 1. Core system headers (stdio.h, ctype.h, ...)
+ 2. Headers for non-core system components (X11, libraries).
+ 3. Headers for core systems of the package being compiled (grass/gis.h, grass/glocale.h ...)
+ 4. Headers for the specific library/program being compiled (geodesic.h, ...)
+
+ Each class of header has an obligation to be compatible with those
+ above it in the list, but not those below it.
+
+
+7. Always specify the return type for ALL functions including those that
+ return type "void", and insert return statements for ALL functions.
+ Also, use ANSI C prototypes to declare your functions.
+ For module return values, see "Exit status" below.
+
+ Examples:
+
+ void G_something(void);
+ int G_something_else(int, int);
+
+ void G_something(void)
+ {
+ /* Snipped out code */
+
+ return;
+ }
+
+ int G_something_else(int x, int y)
+ {
+ /* Snipped out code */
+
+ return(0);
+ }
+
+
+8. Exit status is defined as EXIT_SUCCESS or EXIT_FAILURE, e.g.
+
+ {
+ ...
+ if (G_parser (argc, argv))
+ exit (EXIT_FAILURE);
+
+ ...
+ exit (EXIT_SUCCESS)
+ }
+
+
+9. Use fprintf instead of printf. But:
+
+ For errors and warnings please use the G_fatal_error() and
+ G_warning() functions. General messages for the user should use
+ G_message() while debug messages should use G_debug() whenever
+ possible.
+
+ G_message() output is not expected to be sent to pipe or file.
+
+ Always use the gettext macros with _("") for user messages,
+ example:
+ G_fatal_error ( _("Vector file [%s] not available"), name);
+
+
+ Pipe/file data output:
+ For data output redirected to pipe or file, please use fprintf() and
+ specify the stdout stream as follows:
+
+ fprintf(stdout, ...);
+ fflush(stdout);
+
+ fflush(stdout) always required when using fprintf(stdout, ...).
+
+
+10. Use the GRASS library function G_asprintf() instead of the
+ standard C functions asprintf(), vsnprintf() and snprintf(). These
+ functions are not portable or have other issues. Example:
+
+ char *msg;
+
+ G_asprintf(&msg, "%s", parameters);
+ do_something_with_msg();
+ G_free(msg);
+
+ Note that you should free memory when G_asprintf() is used.
+
+
+11. Use the following GRASS library functions instead of the standard C
+ functions. The reason for this is that the following functions ensure
+ good programming practice (eg always checking if memory was allocated)
+ and/or improves portability. PLEASE refer to the programmers manual
+ for the proper use (eg determining if any casts are needed for arguments
+ or return values) of these library functions. They may perform a task
+ slightly different from their corresponding C library function, and thus,
+ their use may not be the same.
+
+ G_malloc() instead of malloc()
+ G_calloc() instead of calloc()
+ G_realloc() instead of realloc()
+ G_free() instead of free()
+ G_getenv() instead of getenv()
+ G_setenv() instead of setenv()
+ G_unsetenv() instead of unsetenv()
+ G_sleep() instead of sleep()
+
+ Could somebody please add others (please verify that they are
+ useful and safe first)
+
+12. Use function names which fulfil the official GNU naming convention.
+ http://www.gnu.org/prep/standards/html_node/Names.html#Names
+
+ Instead of naming a function like: MyNewFunction() use underscores
+ for seperation and lower case letters: my_new_function().
+
+13. Don't use the C++ comment style! This confuses several compilers.
+ Use instead:
+ /* C-comments */
+
+ If you want to comment code portions, use
+ #ifdef notdef
+ portion_to_be_commented;
+ #endif
+ This is safe comparing to nested /* comments */
+
+ Functions in the library must be documented in doxygen style to
+ get them into the programmer's manual (generate with
+ make pdfdocs or
+ make htmldocs
+ ). See lib/gis/*.c for examples.
+
+
+14. PLEASE take the time to add comments throughout your code explaining what
+ the code is doing. It will save a HUGE amount of time and frustration for
+ other programmers that may have to change your code in the future.
+
+
+15. To promote a consistent coding style, please use the "indent" program
+ on all new C modules using the following switches:
+
+ $ indent -nbad -bap -bbb -nbbo -nbc -br -bli1 -bls -cbi0 -ncdb -nce \
+ -ci4 -cli0 -ncs -d0 -di0 -fc1 -nfca -hnl -i4 -ip4 -l80 -lc80 -lp \
+ -npcs -pi4 -nprs -npsl -sbi0 -sc -nsob -ss -ts8 main.c
+
+ Existing code should not be re-indented except in extreme cases, as this
+ will make "diff" comparisons with older versions impossible. If indent is
+ needed, do not check in any changes other than the indentation in the same
+ commit! Do add the indent switches and any indent warning messages to the
+ CVS log. Any change or fix mixed in with an indent is very hard to track
+ making it hard for others to follow the change or fix any new bugs.
+
+
+16. Platform dependent code:
+ Do not remove #ifdef __CYGWIN__ and/or #ifndef __CYGWIN__ lines and
+ their encapsulated lines from source code (one example was that someone
+ removed drand48 definition.)
+
+17. Suggested compiler flags:
+ We suggest to use very strict compiler flags to capture errors
+ at the very beginning. Here our list of flags, please use them
+ to configure you development version of GRASS:
+
+ GNU/Linux:
+
+ MYCFLAGS="-g -Wall -Werror-implicit-function-declaration -fno-common"
+ MYCXXFLAGS="-g -Wall"
+
+ CFLAGS="$MYCFLAGS" CXXFLAGS="$MYCXXFLAGS" ./configure ...
+
+ MacOSX: [to be suggested]
+
+ MS-Windows: [to be suggested]
+
+18. Make sure a new line is at the end of each file.
+
+
+19. When writing Makefiles, use the current standard.
+
+ If you have to use commands, please check for:
+
+ avoid | use instead
+ ------------------+---------------
+ make target | $(MAKE) target
+ mkdir target | $(MKDIR) target
+ cp (executable) | $(INSTALL) -m 755 file target
+ cp (normal file) | $(INSTALL) -m 644 file target
+ ar | $(AR)
+
+ rm: be VERY careful with recursive remove.
+
+ Examples: see below examples or others
+ raster/r.info/Makefile
+ vector/v.digit/Makefile
+
+ If you are unsure, please ask on the GRASS Developers list.
+
+20. Have a look at ./INSTALL
+
+
+21. Have a function included in your module which writes to the history
+ file of the map (e.g. command line, parameters etc.). See eg
+ raster/r.patch/main.c
+
+ (the same applies to vector and g3d modules!)
+
+
+22. Standard parser options: use G_define_standard_option() whenever possible
+ to define standard module command line options. This will save you time,
+ create fewer bugs, and make things easier on the translators.
+ See lib/gis/parser.c for details of the function definition.
+
+
+23. Module manual page:
+ Place the documentation in HTML format into 'description.html'.
+ The easiest way to do this is to study an existing HTML page
+ (to get the page style, e.g. vector/v.to.db/description.html).
+ With a few exceptions header and footer are NOT allowed.
+ You can add figures (PNG format), the figure name prefix should be the
+ module name. See raster/r.terraflow/description.html for an example.
+
+ Note that the parameter information is auto-generated upon
+ compilation. This is done by running module in a virtual session
+ after compilation (see the output of 'make'). To subsequently
+ verify the final HTML page, check the resulting HTML pages which
+ will be stored with the name of the module.
+
+ Examples (please add some) should be coded like this:
+
+
+
+ The online WWW man pages will be updated every Saturday by CVS.
+
+
+24. Add/update, if required the related GUI menus:
+ gui/tcltk/menus/menu.tcl
+
+
+25. For consistency, use README rather than README.txt for any README files.
+
+
+26. GRASS/Environment variables:
+ If you add a new variable, please follow the naming convention.
+ All variables are described in
+ lib/init/variables.html
+
+
+27. Be sure to develop on top of the LATEST GRASS code (which is in CVS).
+ You can re-check before submission with 'cvs diff':
+
+ Be sure to create unified ("diff -u") format. "Plain" diffs (the default
+ format) are risky, because they will apply without warning to code which
+ has been substantially changed; they are also harder to read than unified.
+
+ Such diffs should be made from the top-level directory, e.g.
+ "cvs diff -u display/d.vect/main.c"; that way, the diff will
+ include the pathname rather than just "main.c".
+
+28. Try to use module names which describe shortly the intended purpose of the module.
+
+ The first letters for module name should be:
+ d. - display commands
+ db. - database commands
+ g. - general commands
+ i. - imagery commands
+ p. - paint commands
+ ps. - postscript commands
+ r. - raster commands
+ r3. - raster3D commands
+ v. - vector commands
+
+ Some additional naming conventions
+ * export modules: (type).out.(format) eg: r.out.arc, v.out.ascii
+ * import module: (type).in.(format) eg: r.in.arc, v.in.ascii
+ * conversion modules: (type).to.(type) eg: r.to.vect, v.to.rast, r3.to.rast
+
+ Avoid module names with more than two dots in the name.
+ Example:
+ instead of r.to.rast3.elev use r.to.rast3elev
+
+28. Use the grass test suite to test your modules.
+
+ http://www-pool.math.tu-berlin.de/~soeren/grass/GRASS_TestSuite
+
+ You can easily write specific tests for your modules.
+
+ If your module is part of grass and you created some standard test cases,
+ please contact the developers to add your tests to the default test suite.
+ This will automatize complex test scenarios and assure to find bugs much
+ faster, if changes were made to your modules or to the grass library.
+
+ Consider to subscribe to the GRASS Quality Assessment System to
+ get immediate notification about the code quality:
+
+ http://grass.itc.it/mailman/listinfo/grass-qa
+
+29. Tell the other developers about the new code using the following e-mail:
+ grass-dev@grass.itc.it
+
+ To subscribe to this mailing list, see
+ http://grass.itc.it/devel/index.php
+
+
+30. In case of questions feel free to contact the developers at the above
+ mailing list.
+ http://grass.itc.it/devel/index.php#submission
+
+...
+[please add further hints if required]
+
Added: trunk/grassaddons/SUBMITTING_SCRIPTS
===================================================================
--- trunk/grassaddons/SUBMITTING_SCRIPTS (rev 0)
+++ trunk/grassaddons/SUBMITTING_SCRIPTS 2007-04-05 06:15:20 UTC (rev 439)
@@ -0,0 +1,188 @@
+$Id: SUBMITTING_SCRIPTS,v 1.9 2007/03/23 13:10:45 jachym Exp $
+
+NOTE: Please improve this list!
+
+Dear (new) GRASS Developer,
+
+When submitting SHELL SCRIPTS to GRASS Addons-SVN repositiory,
+please take care of following rules:
+
+[ see SUBMITTING for C code hints ]
+[ see SUBMITTING_TCLTK for tcl and tk hints ]
+
+0. Instructions for the GRASS script parser can be found in the g.parser
+ module's help page.
+ http://grass.ibiblio.org/grass63/manuals/html63_user/g.parser.html
+
+1. Use the directory structure to place your script appropriately into
+ the source tree
+ - scripts go into scripts/
+
+ Consider to take a look at [please suggest Shell tutorial]
+
+2. Add a header section to the script you submit and make sure you include
+ the copyright. The purpose section is meant to contain a general
+ overview of the code in the file to assist other programmers that will
+ need to make changes to your code.
+
+ Example (ficticious header for a script called r.myscript) :
+
+#!/bin/sh
+
+############################################################################
+#
+# MODULE: r.myscript
+# AUTHOR(S): Me
+# PURPOSE: Calculates univariate statistics from a GRASS raster map
+# COPYRIGHT: (C) 2005 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.
+#
+#############################################################################
+
+ The copyright protects your rights according to GNU General Public
+ License (www.gnu.org).
+
+3. - deleted.
+ We don't want the $ ID $ in scripts any more as it
+ causes problems for the CVS branches.
+
+4. As a general principle, shell variables should almost always be quoted.
+ Use only secure temp files, see g.tempfile and scripts/* for examples.
+
+5. [This rule is currently under review] If you search for a command in $PATH, do NOT
+ use the "which" command or the "type -p" command. Both commands are not
+ supported on all platforms, thus causing problems for some people. As an
+ alternative, please use code similar to the following shell script snippet
+ which will perform the same function. In this case, the path of the grass60
+ command is saved if grass60 is found in $PATH. This won't recognize aliased
+ command name.
+
+ # Search for grass5 command in user's path
+ for i in `echo $PATH | sed 's/^:/.:/
+ s/::/:.:/g
+ s/:$/:./
+ s/:/ /g'`
+ do
+ if [ -f $i/grass5 ] ; then
+
+ # Save the path of the grass60 command
+ GRASS_PATH=$i/grass60
+ # Use the first one in user's path
+ break
+ fi
+ done
+
+>
+ If you must use "which", use as follows:
+
+ # check if we have awk
+ if [ ! -x "`which awk`" ] ; then
+ g.message -e "awk required, please install awk or gawk first"
+ exit 1
+ fi
+?>
+
+6. Add a test to check if the user is in GRASS before starting main part
+ of script. Result of running the script is unpredicable otherwise.
+
+ if [ -z "$GISBASE" ] ; then
+ echo "You must be in GRASS GIS to run this program." 1>&2
+ exit 1
+ fi
+
+ This is the only case, where g.message module (see below) can not be used.
+ In all other cases, you should prefer it's usage over the 'echo' command.
+
+7. Create and use secure temporary files and directories. Use the g.tempfile
+ module to do this. e.g.
+
+ # setup temporary file
+ TMP="`g.tempfile pid=$$`"
+ if [ $? -ne 0 ] || [ -z "$TMP" ] ; then
+ g.message -e "unable to create temporary files"
+ exit 1
+ fi
+
+ For temportary directories remove the newly created file and mkdir using
+ the same name. Beware of commands like "rm -f ${TMP}*" as this becomes
+ "rm -f *" if $TMP is unset (hence the test above).
+
+8. Testing the existence of variables. For portability, use
+ if [ -z "$VARIABLE" ] ; then
+ instead of
+ if [ "$VARIABLE" == "" ] ; then
+
+ and
+
+ if [ -n "$VARIABLE" ] ; then
+ instead of
+ if [ "$VARIABLE" != "" ] ; then
+
+
+9. Internationalization proofing Awk: In some areas (e.g. some European
+ countries) the decimal place is held with a comma instead of a dot.
+ When scanning variables awk doesn't understand this, so scripts need to
+ temporarily discard locale settings before calling awk.
+
+ # set environment so that awk works properly in all languages
+ unset LC_ALL
+ export LC_NUMERIC=C
+
+ awk '{print $1}'
+
+
+10. Use g.findfile when there is a need to test if a map exists.
+
+ # test for input raster map
+ g.findfile element=cell file="$INPUT" > /dev/null
+ if [ $? -eq 0 ] ; then
+ g.message -e "Input map not found"
+ exit 1
+ fi
+
+11. For any informational output, use the g.message modul. This module should
+ be also used for error messages and warnings. You can also use it for
+ debugging purposes.
+
+ g.message "Done."
+ g.message -w "No input values found, using default values"
+ g.message -e "No map found, exiting."
+ g.message -d "Our calculated value is: $value"
+
+ Try to omit any usage of the 'echo' command for informational output.
+
+12. For consistency, use README rather than README.txt for any README files.
+
+13. Be sure to develop on top of the LATEST GRASS code (which is in CVS).
+ You can re-check before submission with 'cvs diff':
+
+ Be sure to create unified ("diff -u") format. "Plain"
+ diffs (the default format) are risky, because they will apply without
+ warning to code which has been substantially changed; they are also
+ harder to read than unified.
+
+ Such diffs should be made from the top-level directory, e.g.
+ "cvs diff -u display/d.vect/main.c"; that way, the diff will
+ include the pathname rather than just "main.c".
+
+14. Tell the other developers about the new code using the following e-mail:
+ grass-dev@grass.itc.it
+
+ To subscribe to this mailing list, see
+ http://grass.itc.it/devel/index.php
+
+15. In case of questions feel free to contact the developers at the above
+ mailing list.
+ http://grass.itc.it/devel/index.php#submission
+
+
+16. For portability, scripts must work on any POSIX compliant shell, and
+ therefore may not include any Bashisms. Test with ash for errors:
+
+ ash -n scriptname
+
+...
+[please add further hints if required]
Added: trunk/grassaddons/SUBMITTING_TCLTK
===================================================================
--- trunk/grassaddons/SUBMITTING_TCLTK (rev 0)
+++ trunk/grassaddons/SUBMITTING_TCLTK 2007-04-05 06:15:20 UTC (rev 439)
@@ -0,0 +1,245 @@
+NOTE: Please improve this list!
+
+Dear (new) GRASS Developer,
+
+When submitting TCL and TK SCRIPTS and C code to GRASS Addons-SVN repository,
+please take care of following rules:
+
+[ see SUBMITTING for C code hints ]
+[ see SUBMITTING_SCRIPTS for shell script hints ]
+
+1. Use the directory structure to place your program appropriately into
+ the source tree
+ - general grass tcl/tk libraries and reusable code go into lib/gtcltk
+ - user interfaces go in gui/tcltk
+ - scripts go in scripts/
+ Programs here must have a proper Makefile and description.html
+
+2. Add a header section to the script you submit and make sure you include
+ the copyright. The purpose section is meant to contain a general
+ overview of the code in the file to assist other programmers that will
+ need to make changes to your code.
+
+ Example (fictitious header for a script called r.myscript) :
+
+############################################################################
+#
+# MODULE: r.myscript
+# AUTHOR(S): Me
+# PURPOSE: Calculates univariate statistics from a GRASS raster map
+# COPYRIGHT: (C) 2005 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.
+#
+#############################################################################
+
+ The copyright protects your rights according to GNU General Public
+ License (www.gnu.org).
+
+3. PLEASE take the time to add comments throughout your code explaining what
+ the code is doing. It will save a HUGE amount of time and frustration for
+ other programmers that need to change or understand your code in the future.
+ Many of the programmers working on grass are not heavily invested in tcl
+ and tk, so extra documentation and explanation are greatly appreciated.
+
+4. Test your program with both tcl/tk 8.3 and tcl/tk 8.4.
+
+5. Always use the gettext macros with [G_msg "..."] for user messages.
+ The string must be quoted using quotation marks, not braces, for
+ xgettext to find it. The string cannot include variable ($) or
+ command ([...]) substitutions. If you need substitutions use
+ [format ...].
+
+ Examples:
+ button .ok -text [G_msg "Ok"]
+
+ set statusbartext [format [G_msg "Monitor %d running"] $monitor_number]]
+
+ Use positional parameters if substitutions might be rearranged in another language:
+
+ format [G_msg "We produced %1\$d units in location %2\$s"] $num $city
+ format [G_msg "In location %2\$s we produced %1\$d units"] $num $city
+
+6. Use "GRASS_TCLSH" and "GRASS_WISH" environment variables instead of
+ "tclsh" and "wish" at the start of Tcl/Tk scripts. This allows users to
+ override the default names, so that developers don't need worry about the
+ shell names.
+
+ Tcl script:
+
+ #!/bin/sh
+ # the next line restarts using tclsh. Note the backslash: \
+ exec $GRASS_TCLSH "$0" "$@"
+
+
+ Tk script:
+
+ #!/bin/sh
+ # the next line restarts using wish. Note the backslash: \
+ exec $GRASS_WISH "$0" "$@"
+
+7. Do not source files that have already been sourced.
+
+ gui.tcl sources:
+ options.tcl
+ select.tcl
+ gronsole.tcl
+
+ If your code requires something to be sourced before it note so
+ in a comment at the top of the file.
+
+8. Set tabstops in your editor to 8 spaces.
+ When modifying files use the indentation style that is already present.
+ Please use consistent indentation style in your new code. Whether you use
+ tabs or spaces to indent please be consistent. Where tabs and spaces are
+ mixed please remember that a tab is 8 spaces.
+
+9. Use the tk options database to control the appearance of your user interface.
+ In general do not set options on tk widgets unless that option is truly
+ specific to that widget. It makes them harder to customize.
+
+ Example: Don't set options like -foreground or -background or -font
+ when creating widgets, unless there's a really _really_ specific reason to
+ have it that color (like it's demonstrating that color).
+
+ If you want something like a label to look different than everything else
+ of that class (other labels) give it a distinctive name, like
+ .moduletitlelabel . If you have a bunch of them give them all the same
+ distinctive name. This allows them to have their options controlled by the
+ options database.
+
+ You can put your options at the start of your script (before creating any
+ widgets) like this:
+ option add *modultitlelabel.background red
+ More examples are in lib/gtcltk/options.tcl
+
+ Many common options, like font, background and foreground colors,
+ highlighting, scrollbar colors, and help bubble appearance are controlled
+ by options.tcl. You can include it at the start of your script with:
+ source $env(GISBASE)/etc/gtcltk/options.tcl
+
+10. Avoid using global variables. Thay are a frequent source of bugs, make code
+ harder to understand, and make your program difficult to reuse. Additionally,
+ putting code into procs usually makes it run faster (it gets compiled).
+
+11. For consistency, use README rather than README.txt for any README files.
+
+12. Use of GRASS commands in shell wrapper.
+
+ Any GRASS program run in an xterm (those which do interactive query) needs
+ to use grass-run.sh, e.g.:
+
+ exec -- $env(GISBASE)/etc/grass-xterm-wrapper -e $env(GISBASE)/etc/grass-run.sh g.proj ...
+
+ You should probably also use "-T g.proj -n g.proj" to set the title
+ back (otherwise it will be "grass-run.sh", which isn't particularly
+ informative).
+
+ The xterm will close as soon as the command completes (whether it
+ succeeds or fails). You can use the -hold switch to retain the xterm
+ window after the command completes, but you should only do that for
+ debugging; having to manually close the xterm window each time would
+ be annoying in normal use. Alternatively, redirect stdout/stderr to a
+ file, to catch any error messages.
+
+13. Be sure to develop on top of the LATEST GRASS code (which is in CVS).
+ You can re-check before submission with 'cvs diff':
+
+ Be sure to create unified ("diff -u") format. "Plain"
+ diffs (the default format) are risky, because they will apply without
+ warning to code which has been substantially changed; they are also
+ harder to read than unified.
+
+ Such diffs should be made from the top-level directory, e.g.
+ "cvs diff -u display/d.vect/main.c"; that way, the diff will
+ include the pathname rather than just "main.c".
+
+14. Tell the other developers about the new code using the following e-mail:
+ grass-dev@grass.itc.it
+
+ To subscribe to this mailing list, see
+ http://grass.itc.it/devel/index.php
+
+15. In case of questions feel free to contact the developers at the above
+ mailing list.
+ http://grass.itc.it/devel/index.php#submission
+
+16. Try to evaluate things only once. Tcl compiles the program to bytecode which
+ can be interpreted fairly quickly. If there are strings that must still be
+ evaluated tcl must parse and either compile or interpret them
+ each time they are encountered. In general this means put braces around
+ expressions and especially regular expressions (Tcl also compiles regular
+ expressions). Multiple evaluation can also lead to bugs.
+
+ Expressions via expr command:
+ Slow:
+ set y [expr $a * $x + $b]
+ Fast:
+ set y [expr {$a * $x + $b}]
+
+ Expressions in conditions:
+ Slow:
+ if [...] {...
+ Fast:
+ if {[...]} {...
+
+ Regular expressions:
+ Very slow:
+ regex "x(\[0-9\]+).*not" $string trash number
+ Fast:
+ regex {x([0-9]+).*not} $string trash number
+
+ If you really want speed:
+ If a regular expression needs to be constructed from variables but used
+ multiple times store it in a variable that will not be destroyed or
+ changed between reuse. Tcl stores the compiled regex with the variable.
+
+17. You might want to decompose lists in a somewhat easy way:
+
+ Difficult and slow:
+ # Make x1 y1 x2 y2 the first four things in the list
+ set list [commandMakesList]
+ set x1 [lindex $list 0]
+ set y1 [lindex $list 1]
+ set x2 [lindex $list 2]
+ set y2 [lindex $list 3]
+
+ Easier and faster:
+ # Make x1 y1 x2 y2 the first four things in the list
+ foreach {x1 y1 x2 y2} [commandMakesList] {break}
+
+ Be sure to include a comment as to what you are doing.
+
+18. Use the Tcl list functions (list, lappend etc) for manipulating lists.
+
+ For example, use:
+
+ set vals [list $foo $bar]
+
+ rather than:
+
+ set vals "$foo $bar"
+
+ The former will always create a list with two elements, adding braces
+ if necessary, while the latter will split $foo and $bar into multiple
+ elements if they contain spaces. Additionally the first is faster
+ because tcl is not internally converting between strings and lists.
+
+ A related issue is to remember that command lines (as used by exec and
+ open "|...") are lists. exec behaves like execl(), spawnl() etc, and
+ not like system().
+
+ Overlooking either of these points is likely to result in code which
+ fails when a command argument contains a space.
+
+19. Tcl C library:
+ Memory allocated with Tcl_Alloc (such as the result of Tcl_Merge)
+ must be freed with Tcl_Free. This means that the ->freeProc of
+ an interpreter when returning a string using Tcl_Merge should be
+ TCL_DYNAMIC. Incorrectly freeing memory with glibc free will
+ cause segfaults in Tcl 8.4 and later.
+
+...
+[please add further hints if required]
From cepicky at grass.itc.it Thu Apr 5 08:42:36 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Thu Apr 5 08:42:37 2007
Subject: [grass-addons] r440 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704050642.l356gaCl025815@grass.itc.it>
Author: cepicky
Date: 2007-04-05 08:42:36 +0200 (Thu, 05 Apr 2007)
New Revision: 440
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
multiple selection event now works, but the whole table is slower (wx.VIRTUAL removed)
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 06:15:20 UTC (rev 439)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 06:42:36 UTC (rev 440)
@@ -50,7 +50,7 @@
class TestVirtualList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
def __init__(self, parent,log,vectmap,pointdata=None):
- wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_HRULES|wx.LC_VRULES)
+ wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_HRULES|wx.LC_VRULES) #wx.VIRTUAL
self.log=log
@@ -124,19 +124,35 @@
# FIXME: subprocess.Popen should be used
# FIXME: Max. number of rows, while the GUI is still usable
i = 0
+ # read data
for line in os.popen("""db.select -c table=%s database=%s driver=%s """ %\
(self.tablename,self.database,self.driver)):
attributes = line.strip().split("|")
self.itemDataMap[i] = []
- for attribute in attributes:
- self.itemDataMap[i].append(attribute)
- self.itemIndexMap.append(i)
+
+ # convert to appropriate type
+ for j in range(len(attributes)):
+ try:
+ attributes[j] = self.columns[j]["type"](attributes[j])
+ except:
+ pass
+
+ # insert to table
+ index = self.InsertStringItem(sys.maxint, str(attributes[0]))
+ self.itemDataMap[i].append(attributes[0])
+ for j in range(len(attributes[1:])):
+ self.SetStringItem(index, j+1, str(attributes[j+1]))
+ self.itemDataMap[i].append(attributes[j+1])
+
+ self.SetItemData(index, i)
+ self.itemIndexMap.append(i)
+
i += 1
if i >= 32000:
self.log.write("Can display only 32000 lines")
break
- self.SetItemCount(len(self.itemDataMap))
+ #self.SetItemCount(len(self.itemDataMap))
#mixins
listmix.ListCtrlAutoWidthMixin.__init__(self)
@@ -146,12 +162,20 @@
self.SortListItems(0, 1)
#events
- self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected)
- self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
- self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected)
- self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
- self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+ self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self)
+ self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemDeselected, self)
+ self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, self)
+ #self.Bind(wx.EVT_LIST_DELETE_ITEM, self.OnItemDelete, self.list)
+ self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self)
+ #self.Bind(wx.EVT_LIST_COL_RIGHT_CLICK, self.OnColRightClick, self.list)
+ #self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.OnColBeginDrag, self.list)
+ #self.Bind(wx.EVT_LIST_COL_DRAGGING, self.OnColDragging, self.list)
+ #self.Bind(wx.EVT_LIST_COL_END_DRAG, self.OnColEndDrag, self.list)
+ #self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.list)
+ #self.list.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)
+ #self.list.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
+
if self.parent.gismanager:
self.mapdisp.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.onMapClick)
@@ -193,28 +217,31 @@
self.qlayer = self.map.addLayer(item='qlayer', command=cmd, l_active=True,
l_hidden=False, l_opacity=1, l_render=False)
self.mapdisp.ReDraw(None)
+ event.Skip()
def OnItemActivated(self, event):
self.currentItem = event.m_itemIndex
self.log.write("OnItemActivated: %s\nTopItem: %s\n" %
(self.GetItemText(self.currentItem), self.GetTopItem()))
+ event.Skip()
def getColumnText(self, index, col):
item = self.GetItem(index, col)
return item.GetText()
- def OnItemDeselected(self, evt):
+ def OnItemDeselected(self, event):
self.log.write("OnItemDeselected: %s" % evt.m_itemIndex)
+ event.Skip()
#---------------------------------------------------
# These methods are callbacks for implementing the
# "virtualness" of the list...
- def OnGetItemText(self, item, col):
- index=self.itemIndexMap[item]
- s = self.itemDataMap[index][col]
- return s
+ # def OnGetItemText(self, item, col):
+ # index=self.itemIndexMap[item]
+ # s = self.itemDataMap[index][col]
+ # return s
# def OnGetItemImage(self, item):
# index=self.itemIndexMap[item]
@@ -235,55 +262,55 @@
# the ColumnSorterMixin.__ColumnSorter() method already handles the ascending/descending,
# and it knows to sort on another column if the chosen columns have the same value.
- def SortItems(self,sorter=cmp):
- items = list(self.itemDataMap.keys())
- # for i in range(len(items)):
- # items[i] = self.columns[self.columnNumber]["type"](items[i])
- items.sort(self.Sorter)
- #items.sort(sorter)
- # for i in range(len(items)):
- # items[i] = str(items[i])
- self.itemIndexMap = items
+ # def SortItems(self,sorter=cmp):
+ # items = list(self.itemDataMap.keys())
+ # # for i in range(len(items)):
+ # # items[i] = self.columns[self.columnNumber]["type"](items[i])
+ # items.sort(self.Sorter)
+ # #items.sort(sorter)
+ # # for i in range(len(items)):
+ # # items[i] = str(items[i])
+ # self.itemIndexMap = items
- # redraw the list
- self.Refresh()
+ # # redraw the list
+ # self.Refresh()
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
def GetListCtrl(self):
return self
- # stolen from python2.4/site-packages/wx-2.8-gtk2-unicode/wx/lib/mixins/listctrl.py
- def Sorter(self, key1,key2):
- col = self._col
- ascending = self._colSortFlag[col]
- # convert, because the it is allways string
- try:
- item1 = self.columns[col]["type"](self.itemDataMap[key1][col])
- except:
- item1 = ''
- try:
- item2 = self.columns[col]["type"](self.itemDataMap[key2][col])
- except:
- item2 = ''
+ # # stolen from python2.4/site-packages/wx-2.8-gtk2-unicode/wx/lib/mixins/listctrl.py
+ # def Sorter(self, key1,key2):
+ # col = self._col
+ # ascending = self._colSortFlag[col]
+ # # convert, because the it is allways string
+ # try:
+ # item1 = self.columns[col]["type"](self.itemDataMap[key1][col])
+ # except:
+ # item1 = ''
+ # try:
+ # item2 = self.columns[col]["type"](self.itemDataMap[key2][col])
+ # except:
+ # item2 = ''
- #--- Internationalization of string sorting with locale module
- if type(item1) == type('') or type(item2) == type(''):
- cmpVal = locale.strcoll(str(item1), str(item2))
- else:
- cmpVal = cmp(item1, item2)
- #---
+ # #--- Internationalization of string sorting with locale module
+ # if type(item1) == type('') or type(item2) == type(''):
+ # cmpVal = locale.strcoll(str(item1), str(item2))
+ # else:
+ # cmpVal = cmp(item1, item2)
+ # #---
- # If the items are equal then pick something else to make the sort v ->alue unique
- if cmpVal == 0:
- cmpVal = apply(cmp, self.GetSecondarySortValues(col, key1, key2))
+ # # If the items are equal then pick something else to make the sort v ->alue unique
+ # if cmpVal == 0:
+ # cmpVal = apply(cmp, self.GetSecondarySortValues(col, key1, key2))
- if ascending:
- return cmpVal
- else:
- return -cmpVal
+ # if ascending:
+ # return cmpVal
+ # else:
+ # return -cmpVal
- #return cmp(self.columns[self.columnNumber]["type"](a),
- # self.columns[self.columnNumber]["type"](b))
+ #return cmp(self.columns[self.columnNumber]["type"](a),
+ # self.columns[self.columnNumber]["type"](b))
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
def GetSortImages(self):
From cepicky at grass.itc.it Thu Apr 5 09:12:43 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Thu Apr 5 09:12:44 2007
Subject: [grass-addons] r441 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704050712.l357ChfG025885@grass.itc.it>
Author: cepicky
Date: 2007-04-05 09:12:43 +0200 (Thu, 05 Apr 2007)
New Revision: 441
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
displaing multiple selection now possible and usable
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 06:42:36 UTC (rev 440)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 07:12:43 UTC (rev 441)
@@ -25,7 +25,7 @@
import wx
import wx.lib.mixins.listctrl as listmix
-import sys,os,locale
+import sys,os,locale,string
try:
from subprocess import *
@@ -33,7 +33,6 @@
from compat import subprocess
from compat.subprocess import *
-#----------------------------------------------------------------------
class Log:
r"""\brief Needed by the wxdemos.
The log output is redirected to the status bar of the containing frame.
@@ -68,6 +67,8 @@
self.pointsize = pointdata[1]
self.columns = []
+ self.selectedCats = []
+ self.lastTurnSelectedCats = []
self.parent = parent
self.qlayer = None
@@ -179,6 +180,9 @@
if self.parent.gismanager:
self.mapdisp.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.onMapClick)
+ self.timer = wx.PyTimer(self.RedrawMap)
+ # check each 0.1s
+ self.timer.Start(100)
def OnCloseWindow(self, event):
if self.qlayer: self.map.delLayer(item='qlayer')
@@ -188,36 +192,36 @@
event.Skip()
def OnItemSelected(self, event):
- print "Selecting"
self.currentItem = event.m_itemIndex
self.log.write('OnItemSelected: "%s", "%s"\n' %
(self.currentItem,
self.GetItemText(self.currentItem)))
+ self.selectedCats.append(self.GetItemText(self.currentItem))
- # show us the result in map display
- #print self.par
- if self.parent.gismanager:
+ event.Skip()
+ def RedrawMap(self):
+
# gism = self.parent.gismanager
# curr_pg = gism.gm_cb.GetCurrentPage()
# disp_idx = gism.track.Track().GetDisp_idx(curr_pg)
# mapdisp = self.parent.gismanager.mapdisplays[disp_idx]
# map = gism.maptree.Map
+
+ if self.lastTurnSelectedCats[:] != self.selectedCats[:]:
if self.qlayer: self.map.delLayer(item='qlayer')
- cat = self.GetItemText(self.currentItem)
-
# FIXME: width=1, because of maybe bug in PNG driver elusion
# should be width=3 or something like this
- cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=1" % (self.vectmap, cat)
+ cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=1" % (self.vectmap, string.join(self.selectedCats,sep=","))
if self.icon: cmd = cmd +" icon=%s" % (self.icon)
if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize)
self.qlayer = self.map.addLayer(item='qlayer', command=cmd, l_active=True,
- l_hidden=False, l_opacity=1, l_render=False)
+ l_hidden=False, l_opacity=1, l_render=False)
self.mapdisp.ReDraw(None)
- event.Skip()
+ self.lastTurnSelectedCats = self.selectedCats[:]
def OnItemActivated(self, event):
self.currentItem = event.m_itemIndex
@@ -230,7 +234,8 @@
return item.GetText()
def OnItemDeselected(self, event):
- self.log.write("OnItemDeselected: %s" % evt.m_itemIndex)
+ self.log.write("OnItemDeselected: %s" % event.m_itemIndex)
+ self.selectedCats.remove(self.GetItemText(event.m_itemIndex))
event.Skip()
From cepicky at grass.itc.it Thu Apr 5 10:06:47 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Thu Apr 5 10:06:48 2007
Subject: [grass-addons] r442 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704050806.l3586lIG026001@grass.itc.it>
Author: cepicky
Date: 2007-04-05 10:06:47 +0200 (Thu, 05 Apr 2007)
New Revision: 442
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
selection and map display usable now
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 07:12:43 UTC (rev 441)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 08:06:47 UTC (rev 442)
@@ -68,7 +68,7 @@
self.columns = []
self.selectedCats = []
- self.lastTurnSelectedCats = []
+ self.lastTurnSelectedCats = [] # just temporary, for comparation
self.parent = parent
self.qlayer = None
@@ -193,11 +193,16 @@
def OnItemSelected(self, event):
self.currentItem = event.m_itemIndex
- self.log.write('OnItemSelected: "%s", "%s"\n' %
- (self.currentItem,
- self.GetItemText(self.currentItem)))
- self.selectedCats.append(self.GetItemText(self.currentItem))
+ #self.log.write('OnItemSelected: "%s", "%s"\n' %
+ # (self.currentItem,
+ # self.GetItemText(self.currentItem)))
+ # now the funny part:
+ # make 1,2,3,4 to 1-4
+
+ self.selectedCats.append(int(self.GetItemText(self.currentItem)))
+ self.selectedCats.sort()
+
event.Skip()
def RedrawMap(self):
@@ -212,9 +217,42 @@
if self.lastTurnSelectedCats[:] != self.selectedCats[:]:
if self.qlayer: self.map.delLayer(item='qlayer')
+ cats = self.selectedCats
+ catstr = ""
+ i = 0
+ while 1:
+ next = 0
+ j = 0
+ while 1:
+ try:
+ if cats[i+j]+1 == cats[i+j+1]:
+ next +=1
+ else:
+ break
+ except IndexError:
+ next = 0
+ if j+i >= len(cats)-2:
+ break
+ else:
+ j += 1
+ if next > 1:
+ catstr += "%d-%d," % (cats[i], cats[i+next])
+ i += next
+ else:
+ catstr += "%d," % (cats[i])
+
+ i += 1
+ if i >= len(cats):
+ break
+
+ if catstr[-1] == ",":
+ catstr = string.join(catstr[:-1],"")
+
+
# FIXME: width=1, because of maybe bug in PNG driver elusion
# should be width=3 or something like this
- cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=1" % (self.vectmap, string.join(self.selectedCats,sep=","))
+ cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=1" % (self.vectmap, catstr)
+ print cmd
if self.icon: cmd = cmd +" icon=%s" % (self.icon)
if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize)
@@ -234,8 +272,9 @@
return item.GetText()
def OnItemDeselected(self, event):
- self.log.write("OnItemDeselected: %s" % event.m_itemIndex)
- self.selectedCats.remove(self.GetItemText(event.m_itemIndex))
+ #self.log.write("OnItemDeselected: %s" % event.m_itemIndex)
+ self.selectedCats.remove(int(self.GetItemText(event.m_itemIndex)))
+ self.selectedCats.sort()
event.Skip()
From cepicky at grass.itc.it Thu Apr 5 11:42:40 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Thu Apr 5 11:42:41 2007
Subject: [grass-addons] r443 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704050942.l359ge2A027854@grass.itc.it>
Author: cepicky
Date: 2007-04-05 11:42:40 +0200 (Thu, 05 Apr 2007)
New Revision: 443
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
scrolling to selection works
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 08:06:47 UTC (rev 442)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 09:42:40 UTC (rev 443)
@@ -26,6 +26,7 @@
import wx.lib.mixins.listctrl as listmix
import sys,os,locale,string
+import grassenv
try:
from subprocess import *
@@ -54,6 +55,8 @@
self.log=log
self.vectmap = vectmap
+ if not "@" in self.vectmap:
+ self.vectmap = self.vectmap+"@"+grassenv.env["MAPSET"]
self.mapname, self.mapset = self.vectmap.split("@")
self.layer,self.tablename, self.column, self.database, self.driver =\
os.popen("v.db.connect -g map=%s" %\
@@ -252,7 +255,7 @@
# FIXME: width=1, because of maybe bug in PNG driver elusion
# should be width=3 or something like this
cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=1" % (self.vectmap, catstr)
- print cmd
+ #print cmd
if self.icon: cmd = cmd +" icon=%s" % (self.icon)
if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize)
@@ -388,8 +391,11 @@
item = self.GetItem(idx, 0)
if item.GetText() == category:
#print idx
- self.Select(idx,True)
+ #self.Select(idx,True)
+ self.EnsureVisible( idx )
+ self.SetItemState(idx, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
else:
+ #self.SetItemState(idx, wx.LIST_STATE_DESELECTED, wx.LIST_STATE_DESELECTED)
self.Select(idx,False)
From landa at grass.itc.it Thu Apr 5 12:29:47 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Thu Apr 5 12:29:48 2007
Subject: [grass-addons] r444 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704051029.l35ATlNj028361@grass.itc.it>
Author: landa
Date: 2007-04-05 12:29:47 +0200 (Thu, 05 Apr 2007)
New Revision: 444
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
__main__ test fixed
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-05 09:42:40 UTC (rev 443)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-05 10:29:47 UTC (rev 444)
@@ -682,6 +682,7 @@
layer = MapLayer(type="raster", name=name, mapset=mapset,
active=l_active, hidden=l_hidden, opacity=l_opacity,
dispcmd=dispcmd)
+
layer.id = len(self.layers)-1
# add maplayer to the list of layers
@@ -1069,7 +1070,7 @@
Go trough all layers and remove them from layer list
Removes also l_mapfile and l_maskfile
- Returns 1 if failed or None if ok"
+ Returns 1 if failed or None if ok
"""
try:
for layer in self.layers:
@@ -1109,15 +1110,15 @@
map.width = 300
map.height = 400
- map.AddRasterLayer("elevation.dem", mapset="PERMANENT", catlist="1000-1500", invertCats=True)
+ map.AddRasterLayer(name="elevation.dem", mapset="PERMANENT", dispcmd = {"catlist" : "1000-1500", "i" : None},
+ l_opacity=.7)
- map.AddVectorLayer("roads", color="red", width=3, mapset="PERMANENT",
- l_opacity=50)
+ map.AddVectorLayer(name="streams", mapset="PERMANENT", dispcmd = {"color" : "red", "width" : 3, "type" : "line"})
image = map.Render(force=True)
if image:
- os.system("display %s" % image)
+ os.system("display %s" % image[0])
#image = map.Render()
#os.system("display %s" % image)
From cepicky at grass.itc.it Thu Apr 5 13:50:30 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Thu Apr 5 13:50:31 2007
Subject: [grass-addons] r445 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704051150.l35BoU8C029453@grass.itc.it>
Author: cepicky
Date: 2007-04-05 13:50:30 +0200 (Thu, 05 Apr 2007)
New Revision: 445
Modified:
trunk/grassaddons/gui/gui_modules/select.py
Log:
fixed (coomented out) Expand of map layer tree, which causes Exception in gis manager
Modified: trunk/grassaddons/gui/gui_modules/select.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/select.py 2007-04-05 10:29:47 UTC (rev 444)
+++ trunk/grassaddons/gui/gui_modules/select.py 2007-04-05 11:50:30 UTC (rev 445)
@@ -84,7 +84,7 @@
pass
#mapsets in current location
- mapsets = os.popen('g.mapsets -p', "r").read().lstrip().rstrip().split(' ')
+ mapsets = os.popen('g.mapsets -p').read().strip().split(' ')
elementlist = ['cell',
'grid3d',
@@ -106,7 +106,6 @@
#Get directory tree nodes
for dir in mapsets:
if dir == curr_mapset:
- #TODO: make current mapset node expanded
dir_node = self.AddItem('Mapset: '+dir)
self.tree.SetItemTextColour(dir_node,wx.Colour(50,50,200))
try:
@@ -115,7 +114,15 @@
self.AddItem(elem+'@'+dir, parent=dir_node)
except:
continue
- self.tree.Expand(dir_node)
+ # FIXME: This introduces error and so it is commented out
+ # -------- ERROR BEGIN --------------
+ # Traceback (most recent call last):
+ # File "/hardmnt/moll0/ssi/cepicky/src/gis/grass/grass6/dist.x86_64-unknown-linux-gnu/etc/wx/gui_modules/wxgui_utils.py", line 348, in onExpandNode
+ # if self.layertype[self.layer_selected] == 'group':
+ # KeyError: >
+ # -------- ERROR END --------------
+ #self.tree.Expand(dir_node)
+
else:
dir_node = self.AddItem('Mapset: '+dir)
self.tree.SetItemTextColour(dir_node,wx.Colour(50,50,200))
From neteler at grass.itc.it Thu Apr 5 14:40:46 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Thu Apr 5 14:40:47 2007
Subject: [grass-addons] r446 - trunk/grassaddons/gui
Message-ID: <200704051240.l35Cekxb029711@grass.itc.it>
Author: neteler
Date: 2007-04-05 14:40:45 +0200 (Thu, 05 Apr 2007)
New Revision: 446
Modified:
trunk/grassaddons/gui/README
Log:
Mandriva 2007 wxPython RPMs available
Modified: trunk/grassaddons/gui/README
===================================================================
--- trunk/grassaddons/gui/README 2007-04-05 11:50:30 UTC (rev 445)
+++ trunk/grassaddons/gui/README 2007-04-05 12:40:45 UTC (rev 446)
@@ -7,6 +7,14 @@
---------------------------------------------------------------------
Requirements:
Python >=2.4 and wxPython 2.8.1.1
+
+ Get wxPython 2.8.x packages from:
+ * Debian:
+ * Fedora:
+ * Mandriva 2007: http://mpa.itc.it/markus/wxpython_rpms/
+ * MS-Windows:
+ * SuSe:
+ * Ubuntu:
---------------------------------------------------------------------
How to start:
From cepicky at grass.itc.it Thu Apr 5 15:45:57 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Thu Apr 5 15:45:59 2007
Subject: [grass-addons] r447 - trunk/grassaddons/gui
Message-ID: <200704051345.l35DjvLj030059@grass.itc.it>
Author: cepicky
Date: 2007-04-05 15:45:57 +0200 (Thu, 05 Apr 2007)
New Revision: 447
Modified:
trunk/grassaddons/gui/README
Log:
updated sources
Modified: trunk/grassaddons/gui/README
===================================================================
--- trunk/grassaddons/gui/README 2007-04-05 12:40:45 UTC (rev 446)
+++ trunk/grassaddons/gui/README 2007-04-05 13:45:57 UTC (rev 447)
@@ -9,12 +9,13 @@
Python >=2.4 and wxPython 2.8.1.1
Get wxPython 2.8.x packages from:
- * Debian:
+ * Debian: http://www.bitpim.org/developer.html -> "Install wxPython"
* Fedora:
* Mandriva 2007: http://mpa.itc.it/markus/wxpython_rpms/
* MS-Windows:
* SuSe:
- * Ubuntu:
+ * Ubuntu: deb http://wxpython.wxcommunity.com/apt/ubuntu/dapper /
+ deb http://wxpython.wxcommunity.com/apt/ubuntu/feisty /
---------------------------------------------------------------------
How to start:
From barton at grass.itc.it Fri Apr 6 02:15:45 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Fri Apr 6 02:15:46 2007
Subject: [grass-addons] r448 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704060015.l360Fjli002530@grass.itc.it>
Author: barton
Date: 2007-04-06 02:15:36 +0200 (Fri, 06 Apr 2007)
New Revision: 448
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
Log:
set column size to width of header
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-05 13:45:57 UTC (rev 447)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-06 00:15:36 UTC (rev 448)
@@ -115,7 +115,7 @@
self.columns.append({"name":column,"type":str})
self.InsertColumn(i, column)
- self.SetColumnWidth(i, 50)
+ self.SetColumnWidth(i, wx.LIST_AUTOSIZE_USEHEADER)
i += 1
if i >= 256:
self.log.write("Can display only 256 columns")
@@ -206,7 +206,7 @@
self.selectedCats.append(int(self.GetItemText(self.currentItem)))
self.selectedCats.sort()
- event.Skip()
+ event.Skip()
def RedrawMap(self):
@@ -250,8 +250,8 @@
if catstr[-1] == ",":
catstr = string.join(catstr[:-1],"")
-
+
# FIXME: width=1, because of maybe bug in PNG driver elusion
# should be width=3 or something like this
cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=1" % (self.vectmap, catstr)
@@ -268,7 +268,7 @@
self.currentItem = event.m_itemIndex
self.log.write("OnItemActivated: %s\nTopItem: %s\n" %
(self.GetItemText(self.currentItem), self.GetTopItem()))
- event.Skip()
+ event.Skip()
def getColumnText(self, index, col):
item = self.GetItem(index, col)
@@ -278,7 +278,7 @@
#self.log.write("OnItemDeselected: %s" % event.m_itemIndex)
self.selectedCats.remove(int(self.GetItemText(event.m_itemIndex)))
self.selectedCats.sort()
- event.Skip()
+ event.Skip()
#---------------------------------------------------
@@ -386,7 +386,7 @@
category = line.strip().split(" ")[1]
#print category
-
+
for idx in range(self.GetItemCount()):
item = self.GetItem(idx, 0)
if item.GetText() == category:
@@ -434,7 +434,6 @@
- event.Skip()
@@ -473,7 +472,6 @@
- event.Skip()
@@ -483,7 +481,6 @@
-
#----------------------------------------------------------------------
# The main window
#----------------------------------------------------------------------
From barton at grass.itc.it Fri Apr 6 07:25:12 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Fri Apr 6 07:25:14 2007
Subject: [grass-addons] r449 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704060525.l365PCSV005594@grass.itc.it>
Author: barton
Date: 2007-04-06 07:25:01 +0200 (Fri, 06 Apr 2007)
New Revision: 449
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Fixed bug in mapdisplay query. Made nicer raster query output.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-06 00:15:36 UTC (rev 448)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-06 05:25:01 UTC (rev 449)
@@ -584,7 +584,7 @@
# digitizing
elif self.parent.digittoolbar:
if self.parent.digittoolbar.digitize == "point":
- east,north= self.Pixel2Cell(self.mouse['end'][0],self.mouse['end'][1])
+ east,north= self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1])
self.parent.digittoolbar.AddPoint(east,north)
# redraw map
self.render=True
@@ -592,12 +592,17 @@
# quering
elif self.mouse["box"] == "query":
- east,north = self.Pixel2Cell(self.mouse['end'][0],self.mouse['end'][1])
+ east,north = self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1])
if self.parent.gismanager:
layer = self.parent.gismanager.maptree.GetSelection()
type = self.parent.gismanager.maptree.layertype[layer]
- map,mapset = layer.GetText().split("@")
- self.parent.QueryMap(map,mapset,type,east,north)
+ dcmd = self.parent.gismanager.maptree.GetPyData(layer)[0]
+ mapname = None
+ for item in dcmd.split(' '):
+ if 'map=' in item:
+ mapname = item.split('=')[1]
+
+ self.parent.QueryMap(mapname,type,east,north)
else:
print "Quering without gis manager not implemented yet"
@@ -661,7 +666,6 @@
newy = self.Map.region['n'] - y * self.Map.region["nsres"]
return newx, newy
-
def Zoom(self, begin, end, zoomtype):
"""
Calculates new region while (un)zoom/pan-ing
@@ -817,7 +821,6 @@
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"], cb=None, idx=-1):
-# style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"]):
"""
Main map display window with toolbars, statusbar and
@@ -1137,17 +1140,20 @@
# change the cursor
self.MapWindow.SetCursor (self.cursors["cross"])
- def QueryMap(self,name,mapset,type,x,y):
+ def QueryMap(self,mapname,type,x,y):
"""
Run *.what command in gis manager output window
"""
+ #set query snap distance for v.what at mapunit equivalent of 10 pixels
+ qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w'])/self.Map.width)
+
if type == "raster":
- cmd = "r.what input=%s east_north=%f,%f" %\
- (name+"@"+mapset, float(x), float(y))
+ cmd = "r.what -f input=%s east_north=%f,%f" %\
+ (mapname, float(x), float(y))
elif type == "vector":
- cmd = "v.what map=%s east_north=%f,%f"%\
- (name+"@"+mapset, float(x), float(y))
+ cmd = "v.what -a map=%s east_north=%f,%f distance=%f" %\
+ (mapname, float(x), float(y), qdist)
if self.gismanager:
self.gismanager.goutput.runCmd(cmd)
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-06 00:15:36 UTC (rev 448)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-06 05:25:01 UTC (rev 449)
@@ -813,10 +813,18 @@
oline = p.stdout.readline()
while oline:
oline = oline.strip()
- self.cmd_output.write(oline+"\n")
+ if cmd.split(' ')[0] == 'r.what':
+ rastqlist = oline.split('|')
+ self.cmd_output.write('East: '+rastqlist[0]+"\n")
+ self.cmd_output.write('North: '+rastqlist[1]+"\n")
+ self.cmd_output.write(rastqlist[2]+"\n")
+ self.cmd_output.write('Category: '+rastqlist[3]+"\n")
+ self.cmd_output.write('Label: '+rastqlist[4]+"\n")
+ else:
+ self.cmd_output.write(oline+"\n")
print >> sys.stderr, oline
oline = p.stdout.readline()
-
+ self.cmd_output.write("\n==========\n")
if p.stdout < 0:
print >> sys.stderr, "Child was terminated by signal", p.stdout
elif p.stdout > 0:
From barton at grass.itc.it Fri Apr 6 09:34:01 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Fri Apr 6 09:34:03 2007
Subject: [grass-addons] r450 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704060734.l367Y1xH007679@grass.itc.it>
Author: barton
Date: 2007-04-06 09:33:52 +0200 (Fri, 06 Apr 2007)
New Revision: 450
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Adding text overlay. Everything working except that there is no text drawn???
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-06 05:25:01 UTC (rev 449)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-06 07:33:52 UTC (rev 450)
@@ -319,11 +319,12 @@
self.ovlcoords[drawid] = coords
elif pdctype == 'text': # draw text on top of map
- text = img
+ print 'in draw: font info, id, pdctype = ',img,drawid,pdctype
+ text = img[0]
w,h = self.GetFullTextExtent(text)[0:2]
- pdc.SetFont(self.GetFont())
- pdc.SetTextForeground(self.RandomColor())
- pdc.SetTextBackground(self.RandomColor())
+ pdc.SetFont(img[1])
+ pdc.SetTextForeground(img[2])
+# pdc.SetTextBackground(self.RandomColor())
pdc.DrawText(text, coords[0], coords[1])
pdc.SetIdBounds(drawid, (coords[0], coords[1], coords[2], coords[3]))
self.ovlcoords[drawid] = coords
@@ -1184,6 +1185,14 @@
decmenu.AppendItem(addlegend)
self.Bind(wx.EVT_MENU, self.addLegend, addlegend)
+ addtext = wx.MenuItem(decmenu, -1,'Text')
+ bmp = wx.Image(os.path.join(icons,'gui-font.gif'), wx.BITMAP_TYPE_GIF)
+ bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addtext.SetBitmap(bmp)
+ decmenu.AppendItem(addtext)
+ self.Bind(wx.EVT_MENU, self.addText, addtext)
+
# Popup the menu. If an item is selected then its handler
# will be called before PopupMenu returns.
self.PopupMenu(decmenu)
@@ -1269,6 +1278,35 @@
self.MapWindow.UpdateMap()
dlg.Destroy()
+ def addText(self, event):
+ """
+ Handler for text decoration menu selection.
+ """
+ ovltype = 2 # index for overlay layer in render
+
+ id = wx.NewId()+100
+ print 'in addText'
+
+ dlg = TextDialog(self, wx.ID_ANY, 'Text', size=(350, 200),
+ style=wx.DEFAULT_DIALOG_STYLE,
+ ovltype=ovltype,
+ drawid=id)
+
+ dlg.CenterOnScreen()
+
+ # If OK button pressed in decoration control dialog
+ val = dlg.ShowModal()
+ if val == wx.ID_OK:
+ print 'OK'
+ maptext = dlg.currText
+ textfont = dlg.currFont
+ textcolor = dlg.currClr
+ print 'text, font, color =', maptext,textfont,textcolor
+
+ self.MapWindow.Draw(self.MapWindow.pdc, img=(maptext,textfont,textcolor), drawid=id, pdctype='text')
+
+
+
def getOptData(self, dcmd, type, params):
"""
Callback method for decoration overlay command generated by
@@ -1352,6 +1390,121 @@
completed=(self.Parent.getOptData,self.ovltype,self.params),
parentframe=None)
+class TextDialog(wx.Dialog):
+ def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
+ style=wx.DEFAULT_DIALOG_STYLE,
+ ovltype=2,drawid=None,currText='',
+ currClr=wx.BLACK,
+ currFont=''):
+ wx.Dialog.__init__(self, parent, id, title, pos, size, style)
+ """
+ Controls setting options and displaying/hiding map overlay decorations
+ """
+ print 'in textdialog'
+
+ self.ovltype = ovltype
+ self.drawid = drawid
+ self.currClr = currClr
+ self.currText = currText
+ self.currFont = currFont
+# self.ovlcmd = cmd
+# self.ovlchk = self.Parent.MapWindow.ovlchk
+# self.params = params #previously set decoration options to pass back to options dialog
+
+ sizer = wx.BoxSizer(wx.VERTICAL)
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
+
+ label = wx.StaticText(self, -1, "Enter text:")
+ box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+
+ self.textentry = wx.TextCtrl(self, -1, "", size=(80,-1))
+ self.currFont = self.textentry.GetFont()
+ box.Add(self.textentry, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ fontbtn = wx.Button(self, wx.ID_ANY, "Set font")
+ box.Add(fontbtn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ label = wx.StaticText(self, -1, ("Double-click text with mouse in\npointer mode and drag to position.\nDouble-click again to set"))
+ box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
+ sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
+
+ btnsizer = wx.StdDialogButtonSizer()
+
+ btn = wx.Button(self, wx.ID_OK)
+ btn.SetDefault()
+ btnsizer.AddButton(btn)
+
+ btn = wx.Button(self, wx.ID_CANCEL)
+ btnsizer.AddButton(btn)
+ btnsizer.Realize()
+
+ sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ self.SetSizer(sizer)
+ sizer.Fit(self)
+
+# self.Bind(wx.EVT_CHECKBOX, self.onCheck, self.chkbox)
+ self.Bind(wx.EVT_BUTTON, self.onSelectFont, fontbtn)
+ self.textentry.Bind(wx.EVT_TEXT, self.onText)
+
+
+# def onCheck(self, event):
+# """
+# Handler for checkbox for displaying/hiding decoration
+# """
+# check = event.IsChecked()
+# self.ovlchk[self.drawid] = check
+
+ def onText(self, event):
+ self.currText = event.GetString()
+
+ def onSelectFont(self, event):
+ data = wx.FontData()
+ data.EnableEffects(True)
+ data.SetColour(self.currClr) # set colour
+ data.SetInitialFont(self.currFont)
+
+ dlg = wx.FontDialog(self, data)
+
+ if dlg.ShowModal() == wx.ID_OK:
+ data = dlg.GetFontData()
+ font = data.GetChosenFont()
+ face = font.GetFaceName()
+ ptsize = font.GetPointSize()
+ colour = data.GetColour()
+
+ print ('You selected: "%s", %d points, color %s\n' %
+ (font.GetFaceName(), font.GetPointSize(),
+ colour.Get()))
+
+ self.currFont = font
+ self.currClr = colour
+ self.UpdateUI()
+
+ # Don't destroy the dialog until you get everything you need from the
+ # dialog!
+ dlg.Destroy()
+
+ def UpdateUI(self):
+ self.textentry.SetFont(self.currFont)
+ self.textentry.SetForegroundColour(self.currClr)
+# self.ps.SetLabel(str(self.currFont.GetPointSize()))
+# self.family.SetLabel(self.currFont.GetFamilyString())
+# self.style.SetLabel(self.currFont.GetStyleString())
+# self.weight.SetLabel(self.currFont.GetWeightString())
+# self.face.SetLabel(self.currFont.GetFaceName())
+# self.nfi.SetLabel(self.currFont.GetNativeFontInfo().ToString())
+ self.Layout()
+
+
class MapApp(wx.App):
"""
MapApp class
From barton at grass.itc.it Fri Apr 6 09:34:37 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Fri Apr 6 09:34:38 2007
Subject: [grass-addons] r451 - trunk/grassaddons/gui
Message-ID: <200704060734.l367YbLC007701@grass.itc.it>
Author: barton
Date: 2007-04-06 09:34:28 +0200 (Fri, 06 Apr 2007)
New Revision: 451
Modified:
trunk/grassaddons/gui/wxgui.py
Log:
Legend is overlay, not layer
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-06 07:33:52 UTC (rev 450)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-06 07:34:28 UTC (rev 451)
@@ -423,14 +423,6 @@
rastmenu.AppendItem(addhis)
self.Bind(wx.EVT_MENU, self.addHIS, addhis)
- addrleg = wx.MenuItem(rastmenu, -1,'Add raster legend layer')
- bmp = wx.Image(os.path.join(wxgui_utils.icons,'module-d.legend.gif'), wx.BITMAP_TYPE_GIF)
- bmp.Rescale(16, 16)
- bmp = bmp.ConvertToBitmap()
- addrleg.SetBitmap(bmp)
- rastmenu.AppendItem(addrleg)
- self.Bind(wx.EVT_MENU, self.addRastLeg, addrleg)
-
# Popup the menu. If an item is selected then its handler
# will be called before PopupMenu returns.
self.PopupMenu(rastmenu)
From landa at grass.itc.it Fri Apr 6 14:05:55 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 6 14:05:57 2007
Subject: [grass-addons] r452 - trunk/grassaddons/gui
Message-ID: <200704061205.l36C5tF7011620@grass.itc.it>
Author: landa
Date: 2007-04-06 14:05:55 +0200 (Fri, 06 Apr 2007)
New Revision: 452
Modified:
trunk/grassaddons/gui/README
Log:
cosmetics; p.cmd note
Modified: trunk/grassaddons/gui/README
===================================================================
--- trunk/grassaddons/gui/README 2007-04-06 07:34:28 UTC (rev 451)
+++ trunk/grassaddons/gui/README 2007-04-06 12:05:55 UTC (rev 452)
@@ -1,8 +1,8 @@
GRASS graphical user interface
==============================
-AUTHORS: Jachym, Michael
-LAST CHANGE: 2007-3-25
+AUTHORS: Jachym, Michael, MartinL
+LAST CHANGE: 2007-04-06
---------------------------------------------------------------------
Requirements:
@@ -20,9 +20,7 @@
How to start:
-Before you start
-----------------
-Download fresh source from subversion:
+Download fresh source code from subversion:
$~ svn co https://grasssvn.itc.it/svn/grassaddons/trunk/grassaddons/gui grassaddons/gui
Or update your local repository
@@ -33,16 +31,19 @@
$~ cd grassaddons/gui
+
1 - INSTALLATION
-Put everthing from gui into a new directory $GISBASE/etc/wx.
+Put everything from gui into a new directory $GISBASE/etc/wx.
Move the script "wxgrass" into $GISBASE/scripts
2 - STARTUP WITH GRASS INITIALIZATION
-If you want to start the wxgrass GUI automatically when you start GRASS, replace your $GRASS/etc/init.sh with the one that accompanies wxgrass. Rename your original init.sh to avoid overwriting it.
+If you want to start the wxgrass GUI automatically when you start
+GRASS, replace your $GRASS/etc/init.sh with the one that accompanies
+wxgrass. Rename your original init.sh to avoid overwriting it.
Edit your .grassrc6 file to replace...
@@ -58,25 +59,27 @@
3 - STARTUP FROM GRASS TERMINAL
-Do not use the wxgrass init.sh. Simply type wxgrass& from the GRASS terminal to start the GUI using the wxgrass script.
+Do not use the wxgrass init.sh. Simply type wxgrass& from the GRASS
+terminal to start the GUI using the wxgrass script.
-4 - CLI MapDisplay scripts
-------------------
-This is going to be replacement for command line tools like d.rast and d.vect
+4 - CLI Display scripts
-Now add directory "scripts" in gui directory to your $PATH. This small
-programms should later go to GRASS Scripts directory or became Python
-scripts or C programs. Now they are small bash wrappers, which can be
-easily and fast costumized.
+This is going to be replacement for command line tools like d.rast and
+d.vect.
+Now add directory "scripts" in gui directory to your $PATH. These
+little programs should later go to GRASS Scripts directory or became
+Python scripts or C programs. Now they are only small BASH wrappers
+which can be easily and fast customized.
+
$~ export PATH=scripts/:$PATH
-Lounch GRASS, if you didn't it yet
+Start GRASS:
$~ grass63 ~/grassdata/spearfish60/user1
-Use command p.mon (shell script in gui/scripts direcotory) to start map
+Use command p.mon (shell script in gui/scripts directory) to start map
display:
GRASS> p.mon anything
@@ -95,10 +98,13 @@
GRASS> p.vect roads
NOTE: only map name is currently supported. No other option will influence
- the map apperience
+ the map layout
+Alternatively you can use more universal p.cmd:
-You should be abple to zoom && pan through the map, ones the layers are
+GRASS> p.cmd "d.rast map=elevation.dem@PERMANENT catlist=1300-1400 -i"
+
+You should be able to zoom && pan through the map, once the layers are
displayed. You should be also able to store the display content as well as
clear the display and start from scratch.
From chemin at grass.itc.it Fri Apr 6 17:22:00 2007
From: chemin at grass.itc.it (chemin@grass.itc.it)
Date: Fri Apr 6 17:22:02 2007
Subject: [grass-addons] r453 - in trunk/grassaddons/gipe: . r.evapo.MH
Message-ID: <200704061522.l36FM03R013048@grass.itc.it>
Author: chemin
Date: 2007-04-06 17:21:52 +0200 (Fri, 06 Apr 2007)
New Revision: 453
Added:
trunk/grassaddons/gipe/r.evapo.MH/
trunk/grassaddons/gipe/r.evapo.MH/Makefile
trunk/grassaddons/gipe/r.evapo.MH/description.html
trunk/grassaddons/gipe/r.evapo.MH/main.c
trunk/grassaddons/gipe/r.evapo.MH/mh_eto.c
trunk/grassaddons/gipe/r.evapo.MH/mh_original.c
Modified:
trunk/grassaddons/gipe/Makefile
Log:
Added r.evapo.MH: ET reference by Modified Hargreaves (+ Flag for original Hargreaves)
Modified: trunk/grassaddons/gipe/Makefile
===================================================================
--- trunk/grassaddons/gipe/Makefile 2007-04-06 12:05:55 UTC (rev 452)
+++ trunk/grassaddons/gipe/Makefile 2007-04-06 15:21:52 UTC (rev 453)
@@ -45,6 +45,7 @@
r.eb.ustar \
r.eb.z0m \
r.emissivity \
+ r.evapo.MH \
r.evapo.potrad \
r.evapo.PM \
r.evapo.PT \
Added: trunk/grassaddons/gipe/r.evapo.MH/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.evapo.MH/Makefile (rev 0)
+++ trunk/grassaddons/gipe/r.evapo.MH/Makefile 2007-04-06 15:21:52 UTC (rev 453)
@@ -0,0 +1,12 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.evapo.MH
+
+LIBES = $(VECTLIB) $(RASTERLIB) $(GISLIB)
+DEPENDENCIES= $(VECTDEP) $(GISDEP) $(DISPLAYDEP) $(RASTERDEP)
+EXTRA_INC = $(VECT_INC)
+EXTRA_CFLAGS = $(VECT_CFLAGS)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd
Added: trunk/grassaddons/gipe/r.evapo.MH/description.html
===================================================================
--- trunk/grassaddons/gipe/r.evapo.MH/description.html (rev 0)
+++ trunk/grassaddons/gipe/r.evapo.MH/description.html 2007-04-06 15:21:52 UTC (rev 453)
@@ -0,0 +1,31 @@
+
DESCRIPTION
+
+r.evapo.MH Calculates the reference ET after Hargreaves (1985) and Modified Hargreaves (2001).
+
+
NOTES
+Hargreaves GL, Hargreaves GH, Riley JP, 1985. Agricultural benefits for Senegal River Basin. Journal of Irrigation and Drainange Engineering, ASCE, 111(2):113-124.
+
+Droogers P, Allen RG, 2001. Towards a simplified global reference evapotranspiration equation. Irrigation Science.
+
+
+
+Yann Chemin, GRASS Development team, 2007
+
+
+
+Last changed: $Date: 2007/04/10 11:58:15 $
Added: trunk/grassaddons/gipe/r.evapo.MH/main.c
===================================================================
--- trunk/grassaddons/gipe/r.evapo.MH/main.c (rev 0)
+++ trunk/grassaddons/gipe/r.evapo.MH/main.c 2007-04-06 15:21:52 UTC (rev 453)
@@ -0,0 +1,367 @@
+/*****************************************************************************
+*
+* MODULE: r.evapo.MH
+* AUTHOR: Yann Chemin (2007)
+* yann.chemin_AT_gmail.com
+*
+* PURPOSE: To estimate the reference evapotranspiration by means
+* of Modified Hargreaves method (2001).
+* Also has a switch for original Hargreaves (1985).
+*
+* COPYRIGHT: (C) 2007 by the GRASS Development Team
+*
+* This program is free software under the GNU General Public
+* Licence (>=2). Read the file COPYING that comes with GRASS
+* for details.
+*
+***************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+//proto ET
+double mh_original(double ra,double tavg,double tmax,double tmin,double p);
+double mh_eto(double ra,double tavg,double tmax,double tmin,double p);
+
+
+int main(int argc, char *argv[])
+{
+ /* buffer for input-output rasters */
+ void *inrast_TEMPKAVG,*inrast_TEMPKMIN, *inrast_TEMPKMAX, *inrast_RNET,*inrast_P;
+
+ unsigned char *outrast;
+
+ /* pointers to input-output raster files */
+ int infd_TEMPKAVG,infd_TEMPKMIN,infd_TEMPKMAX,infd_RNET,infd_P;
+
+ int outfd;
+
+ /* mapsets for input raster files */
+ char *mapset_TEMPKAVG,*mapset_TEMPKMIN,*mapset_TEMPKMAX,*mapset_RNET,*mapset_P;
+
+ /* names of input-output raster files */
+ char *RNET, *TEMPKAVG, *TEMPKMIN, *TEMPKMAX, *P;
+
+ char *ETa;
+
+ /* input-output cell values */
+ DCELL d_tempkavg, d_tempkmin, d_tempkmax, d_rnet, d_p;
+ DCELL d_daily_et;
+
+
+ /* region informations and handler */
+ struct Cell_head cellhd;
+ int nrows, ncols;
+ int row, col;
+
+ /* parser stuctures definition */
+ struct GModule *module;
+ struct Option *input_RNET,*input_TEMPKAVG, *input_TEMPKMIN;
+ struct Option *input_TEMPKMAX, *input_P;
+ struct Option *output;
+ struct Flag *flag1, *zero, *original;
+ struct Colors color;
+ struct History history;
+
+ RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
+ RASTER_MAP_TYPE data_type_tempkavg;
+ RASTER_MAP_TYPE data_type_tempkmin;
+ RASTER_MAP_TYPE data_type_tempkmax;
+ RASTER_MAP_TYPE data_type_rnet;
+ RASTER_MAP_TYPE data_type_p;
+ RASTER_MAP_TYPE data_type_eta;
+
+ /* Initialize the GIS calls */
+ G_gisinit(argv[0]);
+
+ module = G_define_module();
+ module->description =
+ _("Evapotranspiration Calculation "
+ "Modified Hargreaves formulation, 2001."
+ "Flag for Original Hargreaves (1985).");
+
+ /* Define different options */
+ input_RNET = G_define_option();
+ input_RNET->key = "RNETD";
+ input_RNET->key_desc = "[W/m2/d]";
+ input_RNET->type = TYPE_STRING;
+ input_RNET->required = YES;
+ input_RNET->gisprompt = "old,cell,raster";
+ input_RNET->description = _("Name of Diurnal Net Radiation raster map");
+
+ input_TEMPKAVG = G_define_option();
+ input_TEMPKAVG->key = "TEMPKAVG";
+ input_TEMPKAVG->key_desc = "[C]";
+ input_TEMPKAVG->type = TYPE_STRING;
+ input_TEMPKAVG->required = YES;
+ input_TEMPKAVG->gisprompt = "old,cell,raster";
+ input_TEMPKAVG->description = _("Name of avg air temperature raster map");
+
+ input_TEMPKMIN = G_define_option();
+ input_TEMPKMIN->key = "TEMPKMIN";
+ input_TEMPKMIN->key_desc = "[C]";
+ input_TEMPKMIN->type = TYPE_STRING;
+ input_TEMPKMIN->required = YES;
+ input_TEMPKMIN->gisprompt = "old,cell,raster";
+ input_TEMPKMIN->description = _("Name of min air temperature raster map");
+
+ input_TEMPKMAX = G_define_option();
+ input_TEMPKMAX->key = "TEMPKMAX";
+ input_TEMPKMAX->key_desc = "[C]";
+ input_TEMPKMAX->type = TYPE_STRING;
+ input_TEMPKMAX->required = YES;
+ input_TEMPKMAX->gisprompt = "old,cell,raster";
+ input_TEMPKMAX->description = _("Name of max air temperature raster map");
+
+ input_P = G_define_option();
+ input_P->key = "P";
+ input_P->key_desc = "[mm/month]";
+ input_P->type = TYPE_STRING;
+ input_P->required = NO;
+ input_P->gisprompt = "old,cell,raster";
+ input_P->description = _("Name of precipitation raster map, disabled if original Hargreaves (1985) is enabled.");
+
+ output = G_define_option() ;
+ output->key = "output";
+ output->key_desc = "[mm/d]";
+ output->type = TYPE_STRING;
+ output->required = YES;
+ output->gisprompt = "new,cell,raster" ;
+ output->description = _("Name of output Ref Evapotranspiration layer");
+
+ /* Define the different flags */
+ flag1 = G_define_flag() ;
+ flag1->key = 'q' ;
+ flag1->description = _("quiet");
+
+ zero = G_define_flag() ;
+ zero->key = 'z' ;
+ zero->description = _("set negative ETa to zero");
+
+ original = G_define_flag() ;
+ original->key = 'h' ;
+ original->description = _("set to original Hargreaves (1985)");
+
+ if (G_parser(argc, argv))
+ exit(EXIT_FAILURE);
+
+ /* get entered parameters */
+ RNET = input_RNET->answer;
+ TEMPKAVG = input_TEMPKAVG->answer;
+ TEMPKMIN = input_TEMPKMIN->answer;
+ TEMPKMAX = input_TEMPKMAX->answer;
+ P = input_P->answer;
+
+ ETa = output->answer;
+
+ /* find maps in mapset */
+ mapset_RNET = G_find_cell2 (RNET, "");
+ if (mapset_RNET == NULL)
+ G_fatal_error (_("cell file [%s] not found"), RNET);
+ mapset_TEMPKAVG = G_find_cell2 (TEMPKAVG, "");
+ if (mapset_TEMPKAVG == NULL)
+ G_fatal_error (_("cell file [%s] not found"), TEMPKAVG);
+ mapset_TEMPKMIN = G_find_cell2 (TEMPKMIN, "");
+ if (mapset_TEMPKMIN == NULL)
+ G_fatal_error (_("cell file [%s] not found"), TEMPKMIN);
+ mapset_TEMPKMAX = G_find_cell2 (TEMPKMAX, "");
+ if (mapset_TEMPKMAX == NULL)
+ G_fatal_error (_("cell file [%s] not found"), TEMPKMAX);
+ if(!original->answer){
+ mapset_P = G_find_cell2 (P, "");
+ if (mapset_P == NULL)
+ G_fatal_error (_("cell file [%s] not found"), P);
+ }
+ /* check legal output name */
+ if (G_legal_filename (ETa) < 0)
+ G_fatal_error (_("[%s] is an illegal name"), ETa);
+
+ /* determine the input map type (CELL/FCELL/DCELL) */
+ data_type_rnet = G_raster_map_type(RNET,mapset_RNET);
+ data_type_tempkavg = G_raster_map_type(TEMPKAVG,mapset_TEMPKAVG);
+ data_type_tempkmin = G_raster_map_type(TEMPKMIN,mapset_TEMPKMIN);
+ data_type_tempkmax = G_raster_map_type(TEMPKMAX,mapset_TEMPKMAX);
+ if(!original->answer){
+ data_type_p = G_raster_map_type(P,mapset_P);
+ }
+ /* open pointers to input raster files */
+ if ( (infd_RNET = G_open_cell_old (RNET, mapset_RNET)) < 0)
+ G_fatal_error (_("Cannot open cell file [%s]"), RNET);
+ if ( (infd_TEMPKAVG = G_open_cell_old (TEMPKAVG, mapset_TEMPKAVG)) < 0)
+ G_fatal_error (_("Cannot open cell file [%s]"), TEMPKAVG);
+ if ( (infd_TEMPKMIN = G_open_cell_old (TEMPKMIN, mapset_TEMPKMIN)) < 0)
+ G_fatal_error (_("Cannot open cell file [%s]"), TEMPKMIN);
+ if ( (infd_TEMPKMAX = G_open_cell_old (TEMPKMAX, mapset_TEMPKMAX)) < 0)
+ G_fatal_error (_("Cannot open cell file [%s]"), TEMPKMAX);
+ if(!original->answer){
+ if ( (infd_P = G_open_cell_old (P, mapset_P)) < 0)
+ G_fatal_error (_("Cannot open cell file [%s]"), P);
+ }
+ /* read headers of raster files */
+ if (G_get_cellhd (RNET, mapset_RNET, &cellhd) < 0)
+ G_fatal_error (_("Cannot read file header of [%s]"), RNET);
+ if (G_get_cellhd (TEMPKAVG, mapset_TEMPKAVG, &cellhd) < 0)
+ G_fatal_error (_("Cannot read file header of [%s]"), TEMPKAVG);
+ if (G_get_cellhd (TEMPKMIN, mapset_TEMPKMIN, &cellhd) < 0)
+ G_fatal_error (_("Cannot read file header of [%s]"), TEMPKMIN);
+ if (G_get_cellhd (TEMPKMAX, mapset_TEMPKMAX, &cellhd) < 0)
+ G_fatal_error (_("Cannot read file header of [%s]"), TEMPKMAX);
+ if(!original->answer){
+ if (G_get_cellhd (P, mapset_P, &cellhd) < 0)
+ G_fatal_error (_("Cannot read file header of [%s]"), P);
+ }
+ /* Allocate input buffer */
+ inrast_RNET = G_allocate_raster_buf(data_type_rnet);
+ inrast_TEMPKAVG = G_allocate_raster_buf(data_type_tempkavg);
+ inrast_TEMPKMIN = G_allocate_raster_buf(data_type_tempkmin);
+ inrast_TEMPKMAX = G_allocate_raster_buf(data_type_tempkmax);
+ if(!original->answer){
+ inrast_P = G_allocate_raster_buf(data_type_p);
+ }
+ /* get rows and columns number of the current region */
+ nrows = G_window_rows();
+ ncols = G_window_cols();
+
+ /* allocate output buffer */
+ outrast = G_allocate_raster_buf(data_type_output);
+
+ /* open pointers to output raster files */
+ if ( (outfd = G_open_raster_new (ETa,data_type_output)) < 0)
+ G_fatal_error (_("Could not open <%s>"),ETa);
+
+
+ /* start the loop through cells */
+ for (row = 0; row < nrows; row++)
+ {
+
+ /* read input raster row into line buffer*/
+ if (G_get_raster_row (infd_RNET, inrast_RNET, row,data_type_rnet) < 0)
+ G_fatal_error (_("Could not read from <%s>"),RNET);
+ if (G_get_raster_row (infd_TEMPKAVG, inrast_TEMPKAVG, row,data_type_tempkavg) < 0)
+ G_fatal_error (_("Could not read from <%s>"),TEMPKAVG);
+ if (G_get_raster_row (infd_TEMPKMIN, inrast_TEMPKMIN, row,data_type_tempkmin) < 0)
+ G_fatal_error (_("Could not read from <%s>"),TEMPKMIN);
+ if (G_get_raster_row (infd_TEMPKMAX, inrast_TEMPKMAX, row,data_type_tempkmax) < 0)
+ G_fatal_error (_("Could not read from <%s>"),TEMPKMAX);
+ if(!original->answer){
+ if (G_get_raster_row (infd_P, inrast_P, row,data_type_p) < 0)
+ G_fatal_error (_("Could not read from <%s>"),P);
+ }
+ for (col=0; col < ncols; col++)
+ {
+ /* read current cell from line buffer */
+ switch(data_type_rnet){
+ case CELL_TYPE:
+ d_rnet = (double) ((CELL *) inrast_RNET)[col];
+ break;
+ case FCELL_TYPE:
+ d_rnet = (double) ((FCELL *) inrast_RNET)[col];
+ break;
+ case DCELL_TYPE:
+ d_rnet = ((DCELL *) inrast_RNET)[col];
+ break;
+ }
+ switch(data_type_tempkavg){
+ case CELL_TYPE:
+ d_tempkavg = (double) ((CELL *) inrast_TEMPKAVG)[col];
+ break;
+ case FCELL_TYPE:
+ d_tempkavg = (double) ((FCELL *) inrast_TEMPKAVG)[col];
+ break;
+ case DCELL_TYPE:
+ d_tempkavg = ((DCELL *) inrast_TEMPKAVG)[col];
+ break;
+ }
+ switch(data_type_tempkmin){
+ case CELL_TYPE:
+ d_tempkmin = (double) ((CELL *) inrast_TEMPKMIN)[col];
+ break;
+ case FCELL_TYPE:
+ d_tempkmin = (double) ((FCELL *) inrast_TEMPKMIN)[col];
+ break;
+ case DCELL_TYPE:
+ d_tempkmin = ((DCELL *) inrast_TEMPKMIN)[col];
+ break;
+ }
+ switch(data_type_tempkmax){
+ case CELL_TYPE:
+ d_tempkmax = (double) ((CELL *) inrast_TEMPKMAX)[col];
+ break;
+ case FCELL_TYPE:
+ d_tempkmax = (double) ((FCELL *) inrast_TEMPKMAX)[col];
+ break;
+ case DCELL_TYPE:
+ d_tempkmax = ((DCELL *) inrast_TEMPKMAX)[col];
+ break;
+ }
+ if(!original->answer){
+ switch(data_type_p){
+ case CELL_TYPE:
+ d_p = (double) ((CELL *) inrast_P)[col];
+ break;
+ case FCELL_TYPE:
+ d_p = (double) ((FCELL *) inrast_P)[col];
+ break;
+ case DCELL_TYPE:
+ d_p = ((DCELL *) inrast_P)[col];
+ break;
+ }
+ }
+
+ //Calculate ET
+ if(original->answer){
+ d_daily_et = mh_original( d_rnet, d_tempkavg, d_tempkmax, d_tempkmin, d_p );
+ } else {
+ d_daily_et = mh_eto( d_rnet, d_tempkavg, d_tempkmax, d_tempkmin, d_p );
+ }
+ if (zero->answer && d_daily_et<0)
+ d_daily_et=0.0;
+
+ /* write calculated ETP to output line buffer */
+ ((DCELL *) outrast)[col] = d_daily_et;
+ }
+
+ if (!flag1->answer) G_percent(row, nrows, 2);
+
+ /* write output line buffer to output raster file */
+ if (G_put_raster_row (outfd, outrast, data_type_output) < 0)
+ G_fatal_error (_("Cannot write to <%s>"), ETa);
+
+ }
+ /* free buffers and close input maps */
+
+ G_free(inrast_RNET);
+ G_free(inrast_TEMPKAVG);
+ G_free(inrast_TEMPKMIN);
+ G_free(inrast_TEMPKMAX);
+ if(!original->answer){
+ G_free(inrast_P);
+ }
+ G_close_cell (infd_RNET);
+ G_close_cell (infd_TEMPKAVG);
+ G_close_cell (infd_TEMPKMIN);
+ G_close_cell (infd_TEMPKMAX);
+ if(!original->answer){
+ G_close_cell (infd_P);
+ }
+ /* generate color table between -20 and 20 */
+ G_make_rainbow_colors(&color, -20, 20);
+ G_write_colors(ETa,G_mapset(),&color);
+
+ G_short_history(ETa,"raster", &history);
+ G_command_history(&history);
+ G_write_history(ETa, &history);
+
+ /* free buffers and close output map */
+ G_free(outrast);
+ G_close_cell (outfd);
+
+ return (0);
+}
+
Added: trunk/grassaddons/gipe/r.evapo.MH/mh_eto.c
===================================================================
--- trunk/grassaddons/gipe/r.evapo.MH/mh_eto.c (rev 0)
+++ trunk/grassaddons/gipe/r.evapo.MH/mh_eto.c 2007-04-06 15:21:52 UTC (rev 453)
@@ -0,0 +1,24 @@
+#include
+#include
+#include
+
+//Droogers and Allen, 2001.
+//p is [mm/month]
+
+double mh_eto(double ra,double tavg,double tmax,double tmin,double p)
+{
+ double td, result;
+
+ td = tmax - tmin;
+
+ if (tavg > 100.0){
+ tavg=tavg-273.15;//in case temperature is in Kelvin
+ }
+
+ ra = ra * (84600.0 * 1000.0); // convert W -> MJ/d
+
+ result = 0.0013 * 0.408 * ra * ( tavg + 17.0 ) * pow((td - 0.0123*p),0.76) ;
+
+ return result;
+}
+
Added: trunk/grassaddons/gipe/r.evapo.MH/mh_original.c
===================================================================
--- trunk/grassaddons/gipe/r.evapo.MH/mh_original.c (rev 0)
+++ trunk/grassaddons/gipe/r.evapo.MH/mh_original.c 2007-04-06 15:21:52 UTC (rev 453)
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+
+//Hargreaves et al, 1985.
+
+double mh_original(double ra,double tavg,double tmax,double tmin,double p)
+{
+ double td, result;
+
+ td = tmax - tmin;
+
+ if (tavg > 100.0){
+ tavg=tavg-273.15;// in case Temperature is in Kelvin
+ }
+
+ ra = ra * (84600.0 * 1000.0); // convert W -> MJ/d
+
+ result = 0.0023 * 0.408 * ra * ( tavg + 17.8 ) * pow(td,0.5) ;
+
+ return result;
+}
+
From cepicky at grass.itc.it Fri Apr 6 19:53:10 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Fri Apr 6 19:53:12 2007
Subject: [grass-addons] r454 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704061753.l36HrAS2015086@grass.itc.it>
Author: cepicky
Date: 2007-04-06 19:53:10 +0200 (Fri, 06 Apr 2007)
New Revision: 454
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/gui_modules/sqlbuilder.py
Log:
database query builder nearly works, better table design
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-06 15:21:52 UTC (rev 453)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-06 17:53:10 UTC (rev 454)
@@ -125,37 +125,8 @@
#setting the numbers of items = number of elements in the dictionary
self.itemDataMap = {}
self.itemIndexMap = []
- # FIXME: subprocess.Popen should be used
- # FIXME: Max. number of rows, while the GUI is still usable
- i = 0
- # read data
- for line in os.popen("""db.select -c table=%s database=%s driver=%s """ %\
- (self.tablename,self.database,self.driver)):
- attributes = line.strip().split("|")
- self.itemDataMap[i] = []
- # convert to appropriate type
- for j in range(len(attributes)):
- try:
- attributes[j] = self.columns[j]["type"](attributes[j])
- except:
- pass
-
- # insert to table
- index = self.InsertStringItem(sys.maxint, str(attributes[0]))
- self.itemDataMap[i].append(attributes[0])
- for j in range(len(attributes[1:])):
- self.SetStringItem(index, j+1, str(attributes[j+1]))
- self.itemDataMap[i].append(attributes[j+1])
-
- self.SetItemData(index, i)
- self.itemIndexMap.append(i)
-
- i += 1
- if i >= 32000:
- self.log.write("Can display only 32000 lines")
- break
-
+ self.LoadData()
#self.SetItemCount(len(self.itemDataMap))
#mixins
@@ -187,6 +158,47 @@
# check each 0.1s
self.timer.Start(100)
+ def LoadData(self,where=None):
+
+ cmd = """db.select -c table=%s database=%s driver=%s """ %\
+ (self.tablename,self.database,self.driver)
+
+ if where:
+ self.ClearAll()
+ cmd = """db.select -c sql="SELECT * FROM %s WHERE %s" database=%s driver=%s """ %\
+ (self.tablename,where,self.database,self.driver)
+
+
+ # FIXME: subprocess.Popen should be used
+ # FIXME: Max. number of rows, while the GUI is still usable
+ i = 0
+ # read data
+ for line in os.popen(cmd):
+ attributes = line.strip().split("|")
+ self.itemDataMap[i] = []
+
+ # convert to appropriate type
+ for j in range(len(attributes)):
+ try:
+ attributes[j] = self.columns[j]["type"](attributes[j])
+ except:
+ pass
+
+ # insert to table
+ index = self.InsertStringItem(sys.maxint, str(attributes[0]))
+ self.itemDataMap[i].append(attributes[0])
+ for j in range(len(attributes[1:])):
+ self.SetStringItem(index, j+1, str(attributes[j+1]))
+ self.itemDataMap[i].append(attributes[j+1])
+
+ self.SetItemData(index, i)
+ self.itemIndexMap.append(i)
+
+ i += 1
+ if i >= 32000:
+ self.log.write("Can display only 32000 lines")
+ break
+
def OnCloseWindow(self, event):
if self.qlayer: self.map.delLayer(item='qlayer')
@@ -254,7 +266,7 @@
# FIXME: width=1, because of maybe bug in PNG driver elusion
# should be width=3 or something like this
- cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=1" % (self.vectmap, catstr)
+ cmd = "d.vect map=%s color=yellow fcolor=yellow cats=%s width=3" % (self.vectmap, catstr)
#print cmd
if self.icon: cmd = cmd +" icon=%s" % (self.icon)
if self.pointsize: cmd = cmd + " size=%s" % (self.pointsize)
@@ -499,15 +511,81 @@
wx.Frame.__init__(self, parent, id, title, size=size, style=style)
self.CreateStatusBar(1)
+ self.vectmap=vectmap
log=Log(self)
# probably
self.gismanager = parent
+
+ # most importand part
+ self.win = TestVirtualList(self, log,vectmap=vectmap,pointdata=pointdata)
- self.win = TestVirtualList(self, log,vectmap=vectmap,pointdata=pointdata)
+ # buttons
+ self.btn_apply = wx.Button(self, -1, "Apply")
+ #self.btn_unselect = wx.Button(self, -1, "Unselect")
+ self.btn_sqlbuilder = wx.Button(self, -1, "SQL Builder")
+
+ # check
+ #self.check_add_to_selection = wx.CheckBox(self, -1, "Add to selection")
+ # textarea
+ self.text_query = wx.TextCtrl(self,-1,"")
+ # label
+ self.sqlabel=wx.StaticText(self,-1,"SELECT * FROM %s WHERE " % self.win.tablename)
+ self.label_query = wx.StaticText(self,-1,"")
+
+ # box
+ self.sqlbox = wx.StaticBox(self, -1, "SQL Query:")
+
+
+ self.btn_sqlbuilder.Bind(wx.EVT_BUTTON, self.OnBuilder)
+
+ self.__layout()
self.Show()
+ def OnBuilder(self,event):
+ import sqlbuilder
+ self.builder = sqlbuilder.SQLFrame(self,-1,"SQL Builder",self.vectmap)
+
+
+ def OnApply(self,event):
+ self.win.LoadData(where=self.text_query.GetValue().strip())
+
+
+ def OnTextEnter(self, event):
+ pass
+
+ def OnSQLBuilder(self, event):
+ pass
+
+ def __layout(self):
+ #self.panel = wx.Panel(self,-1, style=wx.SUNKEN_BORDER)
+
+ self.label_query.SetMinSize((500,50))
+ self.text_query.SetMinSize((500,-1))
+
+ bsizer = wx.StaticBoxSizer(self.sqlbox, wx.VERTICAL)
+ bsizer.Add(self.label_query, flag=wx.EXPAND)
+
+
+ pagesizer= wx.BoxSizer(wx.VERTICAL)
+ toolsizer1 = wx.BoxSizer(wx.HORIZONTAL)
+ #toolsizer2 = wx.BoxSizer(wx.HORIZONTAL)
+
+ toolsizer1.Add(self.sqlabel, flag=wx.ALIGN_CENTER_VERTICAL,
+ proportion=1)
+ toolsizer1.Add(self.text_query,flag=wx.SHAPED|wx.GROW, proportion=2,)
+ toolsizer1.Add(self.btn_sqlbuilder,flag=wx.ALIGN_RIGHT,proportion=0)
+ toolsizer1.Add(self.btn_apply,flag=wx.ALIGN_RIGHT,proportion=0)
+
+ pagesizer.Add(bsizer,flag=wx.EXPAND)
+ pagesizer.Add(self.win, proportion=1, flag=wx.EXPAND, border=1)
+ pagesizer.Add(toolsizer1)
+
+ self.SetSizer(pagesizer)
+ pagesizer.Fit(self)
+ self.Layout()
+
def main(argv=None):
if argv is None:
argv = sys.argv
@@ -525,7 +603,7 @@
#wx.InitAllImageHandlers()
app = wx.PySimpleApp()
- f = AttributeManager(None, -1, "GRASS Attribute Table Manager",wx.Size(500,300),vectmap=argv[1])
+ f = AttributeManager(None, -1, "GRASS Attribute Table Manager",wx.Size(700,600),vectmap=argv[1])
app.MainLoop()
Modified: trunk/grassaddons/gui/gui_modules/sqlbuilder.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/sqlbuilder.py 2007-04-06 15:21:52 UTC (rev 453)
+++ trunk/grassaddons/gui/gui_modules/sqlbuilder.py 2007-04-06 17:53:10 UTC (rev 454)
@@ -16,7 +16,7 @@
class SQLFrame(wx.Frame):
- def __init__(self, parent, id, title, table, qtype="select"):
+ def __init__(self, parent, id, title, vectmap, qtype="select"):
wx.Frame.__init__(self, parent, -1, title)
self.SetTitle("SQL Builder for GRASS GIS - %s " % (qtype.upper()))
@@ -25,12 +25,25 @@
#
# variables
#
- self.tablename = table # name of the table "select * from #self.tablename# "
+ self.vectmap = vectmap
+ if not "@" in self.vectmap:
+ self.vectmap = self.vectmap+"@"+grassenv.env["MAPSET"]
+ self.mapname, self.mapset = self.vectmap.split("@")
+ self.layer,self.tablename, self.column, self.database, self.driver =\
+ os.popen("v.db.connect -g map=%s" %\
+ (self.vectmap)).readlines()[0].strip().split()
+
self.qtype = qtype # type of the uqery: SELECT, UPDATE, DELETE, ...
self.column_names = [] # array with column names
self.columns = {} # array with colum properties
self.colvalues = [] # arrya with uniqe values in selected column
+ self.heading = ""
+ self.parent = parent
+ if self.qtype.lower()=="select":
+ self.heading = "SELECT * FROM %s WHERE" % self.tablename
+
+
# Init
self.GetColumns()
@@ -40,12 +53,13 @@
#
self.btn_clear = wx.Button(self, -1, "Clear")
self.btn_verify = wx.Button(self, -1, "Verify")
- self.btn_help = wx.Button(self, -1, "Help")
- self.btn_load = wx.Button(self, -1, "Load")
- self.btn_save = wx.Button(self, -1, "Save")
+ #self.btn_help = wx.Button(self, -1, "Help")
+ # self.btn_load = wx.Button(self, -1, "Load")
+ # self.btn_save = wx.Button(self, -1, "Save")
self.btn_apply = wx.Button(self, -1, "Apply")
self.btn_close = wx.Button(self, -1, "Close")
- self.btn_uniqe = wx.Button(self, -1, "Get unique values")
+ self.btn_uniqe = wx.Button(self, -1, "Get all values")
+ self.btn_uniqesample = wx.Button(self, -1, "Get sample")
self.btn_is = wx.Button(self, -1, "=")
self.btn_isnot = wx.Button(self, -1, "!=")
@@ -68,18 +82,19 @@
#
# Textareas
#
- self.text_sql = wx.TextCtrl(self, -1, '', size=(-1,50),style=wx.TE_MULTILINE)
+ self.text_sql = wx.TextCtrl(self, -1, '', size=(-1,75),style=wx.TE_MULTILINE)
#
# List Boxes
#
- self.list_columns = wx.ListBox(self, -1, wx.DefaultPosition, (130, 130), self.column_names, wx.LB_MULTIPLE|wx.LB_SORT)
- self.list_values = wx.ListBox(self, -1, wx.DefaultPosition, (130, 130), self.colvalues, wx.LB_MULTIPLE|wx.LB_SORT)
+ self.list_columns = wx.ListBox(self, -1, wx.DefaultPosition, (-1, -1), self.column_names, wx.LB_MULTIPLE|wx.LB_SORT)
+ self.list_values = wx.ListBox(self, -1, wx.DefaultPosition, (-1, -1), self.colvalues, wx.LB_MULTIPLE|wx.LB_SORT)
#
# Bindings
#
self.btn_uniqe.Bind(wx.EVT_BUTTON, self.GetUniqueValues)
+ self.btn_uniqesample.Bind(wx.EVT_BUTTON, self.GetSampleValues)
self.btn_is.Bind(wx.EVT_BUTTON, self.AddMark)
self.btn_isnot.Bind(wx.EVT_BUTTON, self.AddMark)
self.btn_like.Bind(wx.EVT_BUTTON, self.AddMark)
@@ -92,22 +107,38 @@
self.btn_brackets.Bind(wx.EVT_BUTTON, self.AddMark)
self.btn_prc.Bind(wx.EVT_BUTTON, self.AddMark)
self.btn_and.Bind(wx.EVT_BUTTON, self.AddMark)
+ self.btn_close.Bind(wx.EVT_BUTTON, self.OnClose)
+ self.btn_clear.Bind(wx.EVT_BUTTON, self.OnClear)
+ self.btn_verify.Bind(wx.EVT_BUTTON, self.OnVerify)
+ self.btn_apply.Bind(wx.EVT_BUTTON, self.OnApply)
self.list_columns.Bind(wx.EVT_LISTBOX, self.AddColumnName)
self.list_values.Bind(wx.EVT_LISTBOX, self.AddValue)
+
+ self.__doLayout()
- #
- # Layout
- #
+ def __doLayout(self):
+ databasebox = wx.StaticBox(self, -1, "Database connection")
+ databaseboxsizer = wx.StaticBoxSizer(databasebox,wx.VERTICAL)
+ dbstr = "Database: %s\n" % (self.database)
+ dbstr += "Driver: %s\n" % (self.driver)
+ dbstr += "Table: %s" % (self.tablename)
+ databaseboxsizer.Add(wx.StaticText(self,-1,dbstr), flag=wx.EXPAND)
+
+ sqlbox = wx.StaticBox(self, -1, "%s" % self.heading)
+ sqlboxsizer = wx.StaticBoxSizer(sqlbox,wx.VERTICAL)
+ sqlboxsizer.Add(self.text_sql, flag=wx.EXPAND)
+
+
pagesizer = wx.BoxSizer(wx.VERTICAL)
- buttonsizer1 = wx.BoxSizer(wx.HORIZONTAL)
- buttonsizer1.Add(self.btn_clear, 0, wx.LEFT|wx.RIGHT, 5)
- buttonsizer1.Add(self.btn_verify, 0, wx.LEFT|wx.RIGHT, 5 )
- buttonsizer1.Add(self.btn_help, 0, wx.LEFT|wx.RIGHT, 5, )
- buttonsizer1.Add(self.btn_load, 0, wx.LEFT|wx.RIGHT, 5,)
- buttonsizer1.Add(self.btn_save, 0, wx.LEFT|wx.RIGHT, 5, )
- buttonsizer1.Add(self.btn_apply, 0, wx.LEFT|wx.RIGHT, 5, )
+ buttonsizer1 = wx.GridBagSizer(2,2)
+ buttonsizer1.Add(self.btn_clear, (0,0))
+ buttonsizer1.Add(self.btn_verify, (0,1))
+ #buttonsizer1.Add(self.btn_help, (0,2))
+ #buttonsizer1.Add(self.btn_load, (0,2))
+ # buttonsizer1.Add(self.btn_save, (0,3))
+ buttonsizer1.Add(self.btn_apply, (0,2))
buttonsizer2 = wx.GridBagSizer(2, 2)
buttonsizer2.Add(self.btn_is, (0,0))
@@ -130,18 +161,33 @@
buttonsizer3.Add(self.btn_apply,0,wx.RIGHT,5)
buttonsizer3.Add(self.btn_close,0,wx.RIGHT,5)
- hsizer1 = wx.GridSizer(2, 2, 0, 0)
- hsizer1.Add((wx.StaticText(self,-1,"Columns: ",size=(-1,22))), proportion=0,border=0)
- hsizer1.Add((wx.StaticText(self,-1,"Unique values: ", size=(-1,22))), proportion=0,border=0)
- hsizer1.Add(self.list_columns, 1, wx.EXPAND)
- hsizer1.Add(self.list_values, 1, wx.EXPAND)
+ buttonsizer4 = wx.BoxSizer(wx.HORIZONTAL)
+ buttonsizer4.Add(self.btn_uniqesample,0,flag=wx.ALIGN_CENTER_HORIZONTAL,border=5)
+ buttonsizer4.Add(self.btn_uniqe,0,flag=wx.ALIGN_CENTER_HORIZONTAL,border=5)
- pagesizer.Add((wx.StaticText(self,-1,self.qtype,size=(-1,22))), 0, 0)
- pagesizer.Add(hsizer1, 1, wx.EXPAND, 0)
- pagesizer.Add(self.btn_uniqe,0,wx.ALIGN_LEFT|wx.TOP,border=5)
+ hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
+ #hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
+
+ columnsbox = wx.StaticBox(self,-1,"Columns: ")
+ valuesbox = wx.StaticBox(self,-1,"Values: ")
+ #hsizer1.Add(wx.StaticText(self,-1, "Unique values: "), border=0, proportion=1)
+ columnsizer = wx.StaticBoxSizer(columnsbox,wx.VERTICAL)
+ valuesizer = wx.StaticBoxSizer(valuesbox,wx.VERTICAL)
+ columnsizer.Add(self.list_columns, flag=wx.EXPAND,)
+ valuesizer.Add(self.list_values, flag=wx.EXPAND)
+ self.list_columns.SetMinSize((-1,130))
+ self.list_values.SetMinSize((-1,100))
+ valuesizer.Add(buttonsizer4)
+ hsizer1.Add(columnsizer,border=0, proportion=1)
+ hsizer1.Add(valuesizer,border=0, proportion=1)
+
+ pagesizer.Add(databaseboxsizer,flag=wx.EXPAND,border=5)
+ pagesizer.Add(hsizer1, 1,flag=wx.EXPAND,border=5)
+ #pagesizer.Add(self.btn_uniqe,0,wx.ALIGN_LEFT|wx.TOP,border=5)
+ #pagesizer.Add(self.btn_uniqesample,0,wx.ALIGN_LEFT|wx.TOP,border=5)
pagesizer.Add(buttonsizer2, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.TOP, border=5)
- pagesizer.Add(self.text_sql, proportion=1, flag=wx.EXPAND|wx.TOP, border=5)
- pagesizer.Add(buttonsizer1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.TOP, 5)
+ pagesizer.Add(sqlboxsizer, flag=wx.EXPAND,border=5)
+ pagesizer.Add(buttonsizer1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.TOP, border=5)
pagesizer.Add(buttonsizer3, proportion=0, flag=wx.TOP, border=5)
self.SetAutoLayout(True)
self.SetSizer(pagesizer)
@@ -158,7 +204,7 @@
self.columns[name] = {'type':ctype}
return
- def GetUniqueValues(self,event):
+ def GetUniqueValues(self,event,justsample=False):
vals = []
try:
idx = self.list_columns.GetSelections()[0]
@@ -166,9 +212,18 @@
return
self.list_values.Clear()
column = self.list_columns.GetString(idx)
- for line in os.popen("""db.select -c sql="SELECT %s FROM %s" """ %\
- (column,self.tablename)):
- self.list_values.Insert(line.strip(),0)
+ i = 0
+ for line in os.popen("""db.select -c database=%s driver=%s sql="SELECT %s FROM %s" """ %\
+ (self.database,self.driver,column,self.tablename)):
+ if justsample and i < 256 or \
+ not justsample:
+ self.list_values.Insert(line.strip(),0)
+ else:
+ break
+ i += 1
+
+ def GetSampleValues(self,event):
+ self.GetUniqueValues(None,True)
def AddColumnName(self,event):
idx = self.list_columns.GetSelections()[0]
@@ -206,7 +261,7 @@
def __addSomething(self,what):
sqlstr = self.text_sql.GetValue()
newsqlstr = ''
- position = self.text_sql.GetLastPosition()
+ position = self.text_sql.GetPosition()[0]
selection = self.text_sql.GetSelection()
newsqlstr = sqlstr[:position]
@@ -221,7 +276,25 @@
self.text_sql.SetValue(newsqlstr)
self.text_sql.SetInsertionPoint(position)
+ def OnApply(self,event):
+ if self.parent:
+ try:
+ self.parent.text_query.SetValue= self.text_sql.GetValue().strip().replace("\n"," ")
+ except:
+ pass
+ def OnVerify(self,event):
+ if self.text_sql.GetValue():
+ if os.system("""db.select -t driver=%s database=%s sql="SELECT * FROM %s WHERE %s" """ % \
+ (self.driver, self.database,self.tablename,
+ self.text_sql.GetValue().strip().replace("\n"," "))):
+ # FIXME: LOG
+ print self.text_sql.GetValue().strip().replace("\n"," "), "not correct!"
+ def OnClear(self, event):
+ self.text_sql.SetValue("")
+ def OnClose(self,event):
+ self.Destroy()
+
if __name__ == "__main__":
if len(sys.argv) != 2:
@@ -229,7 +302,7 @@
sys.exit()
app = wx.App(0)
- sqlb = SQLFrame(None, -1, 'SQL Buiilder',sys.argv[1])
+ sqlb = SQLFrame(None, -1, 'SQL Builder',sys.argv[1])
app.MainLoop()
From calvelo at grass.itc.it Sun Apr 8 00:21:39 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Sun Apr 8 00:21:40 2007
Subject: [grass-addons] r455 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704072221.l37MLdCp015550@grass.itc.it>
Author: calvelo
Date: 2007-04-08 00:21:29 +0200 (Sun, 08 Apr 2007)
New Revision: 455
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
Fixed bugs in
- sys.path setting,
- pre-filled parameter handling from wxgui and
- SO-dependent line-breaks
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-06 17:53:10 UTC (rev 454)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-07 22:21:29 UTC (rev 455)
@@ -52,10 +52,10 @@
import os
from os import system
+sys.path.append(os.path.join(os.getenv("GISBASE"),"etc","wx"))
try:
import subprocess
except:
- sys.path.append(os.path.join(os.getenv("GISBASE"),"etc","wx"))
from compat import subprocess
import re
@@ -122,7 +122,7 @@
"Make really long texts shorter"
# TODO: remove magic number (calculate a correct value from
# pixelSize of text and the magic number for maximum size
- return escape_ampersand( "\n".join( textwrap.wrap( normalize_whitespace(someString), 72 ) ) )
+ return escape_ampersand( os.linesep.join( textwrap.wrap( normalize_whitespace(someString), 72 ) ) )
def escape_ampersand(text):
"Escapes ampersands with additional ampersand for GUI"
@@ -853,8 +853,9 @@
xml.sax.parseString( getInterfaceDescription( cmd ) , handler )
# if layer parameters previously set, re-insert them into dialog
- if 'params' in dcmd_params: self.grass_task.params = dcmd_params['params']
- if 'flags' in dcmd_params: self.grass_task.flags = dcmd_params['flags']
+ if completed is not None:
+ if 'params' in dcmd_params: self.grass_task.params = dcmd_params['params']
+ if 'flags' in dcmd_params: self.grass_task.flags = dcmd_params['flags']
self.mf = mainFrame(self.parent ,-1, self.grass_task, get_dcmd, layer)
self.mf.Show(True)
From barton at grass.itc.it Sun Apr 8 06:56:47 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sun Apr 8 06:56:48 2007
Subject: [grass-addons] r456 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704080456.l384ul1L013521@grass.itc.it>
Author: barton
Date: 2007-04-08 06:56:36 +0200 (Sun, 08 Apr 2007)
New Revision: 456
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/gui_modules/sqlbuilder.py
Log:
Fixed bug in parsing of db.describe output
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-07 22:21:29 UTC (rev 455)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-08 04:56:36 UTC (rev 456)
@@ -103,7 +103,7 @@
for line in os.popen("db.describe -c table=%s driver=%s database=%s" %\
(self.tablename, self.driver, self.database)).readlines()[1:]:
- x,column,type = line.strip().split(":")
+ x,column,type,length = line.strip().split(":")
# FIXME: here will be more types
if type.lower().find("integer") > -1:
self.columns.append({"name":column,"type":int})
@@ -159,7 +159,7 @@
self.timer.Start(100)
def LoadData(self,where=None):
-
+
cmd = """db.select -c table=%s database=%s driver=%s """ %\
(self.tablename,self.database,self.driver)
@@ -517,7 +517,7 @@
# probably
self.gismanager = parent
-
+
# most importand part
self.win = TestVirtualList(self, log,vectmap=vectmap,pointdata=pointdata)
@@ -525,7 +525,7 @@
self.btn_apply = wx.Button(self, -1, "Apply")
#self.btn_unselect = wx.Button(self, -1, "Unselect")
self.btn_sqlbuilder = wx.Button(self, -1, "SQL Builder")
-
+
# check
#self.check_add_to_selection = wx.CheckBox(self, -1, "Add to selection")
# textarea
@@ -533,7 +533,7 @@
# label
self.sqlabel=wx.StaticText(self,-1,"SELECT * FROM %s WHERE " % self.win.tablename)
self.label_query = wx.StaticText(self,-1,"")
-
+
# box
self.sqlbox = wx.StaticBox(self, -1, "SQL Query:")
Modified: trunk/grassaddons/gui/gui_modules/sqlbuilder.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/sqlbuilder.py 2007-04-07 22:21:29 UTC (rev 455)
+++ trunk/grassaddons/gui/gui_modules/sqlbuilder.py 2007-04-08 04:56:36 UTC (rev 456)
@@ -22,7 +22,7 @@
self.SetTitle("SQL Builder for GRASS GIS - %s " % (qtype.upper()))
self.SetIcon(wx.Icon(os.path.join(imagepath,'grass_sql.png'), wx.BITMAP_TYPE_ANY))
- #
+ #
# variables
#
self.vectmap = vectmap
@@ -73,26 +73,26 @@
self.btn_and = wx.Button(self, -1, "AND")
self.btn_brackets = wx.Button(self, -1, "()")
self.btn_prc = wx.Button(self, -1, "%")
-
- #
+
+ #
# Text labels
#
#self.label_headding = wx.StaticText(self, -1, '')
#
# Textareas
- #
+ #
self.text_sql = wx.TextCtrl(self, -1, '', size=(-1,75),style=wx.TE_MULTILINE)
- #
+ #
# List Boxes
#
self.list_columns = wx.ListBox(self, -1, wx.DefaultPosition, (-1, -1), self.column_names, wx.LB_MULTIPLE|wx.LB_SORT)
self.list_values = wx.ListBox(self, -1, wx.DefaultPosition, (-1, -1), self.colvalues, wx.LB_MULTIPLE|wx.LB_SORT)
-
+
#
# Bindings
- #
+ #
self.btn_uniqe.Bind(wx.EVT_BUTTON, self.GetUniqueValues)
self.btn_uniqesample.Bind(wx.EVT_BUTTON, self.GetSampleValues)
self.btn_is.Bind(wx.EVT_BUTTON, self.AddMark)
@@ -114,7 +114,7 @@
self.list_columns.Bind(wx.EVT_LISTBOX, self.AddColumnName)
self.list_values.Bind(wx.EVT_LISTBOX, self.AddValue)
-
+
self.__doLayout()
def __doLayout(self):
@@ -167,7 +167,7 @@
hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
#hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
-
+
columnsbox = wx.StaticBox(self,-1,"Columns: ")
valuesbox = wx.StaticBox(self,-1,"Values: ")
#hsizer1.Add(wx.StaticText(self,-1, "Unique values: "), border=0, proportion=1)
@@ -200,7 +200,7 @@
for line in os.popen("db.columns table=%s" % (self.tablename)):
self.column_names.append(line.strip())
for line in os.popen("db.describe -c table=%s" % (self.tablename)).readlines()[1:]:
- x,name,ctype = line.strip().split(":")
+ x,name,ctype,length = line.strip().split(":")
self.columns[name] = {'type':ctype}
return
@@ -221,7 +221,7 @@
else:
break
i += 1
-
+
def GetSampleValues(self,event):
self.GetUniqueValues(None,True)
@@ -257,7 +257,7 @@
elif event.GetId() == self.btn_prc.GetId(): mark = "%"
self.__addSomething(mark)
-
+
def __addSomething(self,what):
sqlstr = self.text_sql.GetValue()
newsqlstr = ''
From barton at grass.itc.it Sun Apr 8 18:43:35 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sun Apr 8 18:43:36 2007
Subject: [grass-addons] r457 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704081643.l38GhZUK022747@grass.itc.it>
Author: barton
Date: 2007-04-08 18:43:26 +0200 (Sun, 08 Apr 2007)
New Revision: 457
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Fixed overlay transparency.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-08 04:56:36 UTC (rev 456)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-08 16:43:26 UTC (rev 457)
@@ -158,11 +158,11 @@
def __init__(self, parent, id,
pos = wx.DefaultPosition,
size = wx.DefaultSize,
- style=wx.NO_FULL_REPAINT_ON_RESIZE,map=Map):
+ style=wx.NO_FULL_REPAINT_ON_RESIZE):
wx.Window.__init__(self, parent, id, pos, size, style)
self.parent = parent
- self.Map = map
+ self.Map = Map
#
# Flags
@@ -275,15 +275,18 @@
drawid == None
else:
drawid = wx.NewId()
-
- if drawid:
+ else:
self.ovlcoords[drawid] = coords
self.ovlchk[drawid] = True
pdc.SetId(drawid)
self.select[drawid] = False
pdc.BeginDrawing()
- pdc.SetBackground(wx.Brush(self.GetBackgroundColour()))
+ if drawid != 99:
+ bg = wx.TRANSPARENT_BRUSH
+ else:
+ bg = wx.Brush(self.GetBackgroundColour())
+ pdc.SetBackground(bg)
pdc.Clear()
self.Refresh()
@@ -292,6 +295,7 @@
return
if pdctype == 'image':
+ mask = None
bitmap = wx.BitmapFromImage(img)
w,h = bitmap.GetSize()
pdc.DrawBitmap(bitmap, coords[0], coords[1], True) # draw the composite map
@@ -315,17 +319,21 @@
pen = self.RandomPen()
pdc.SetPen(pen)
pdc.DrawPoint(coords[0], coords[1])
+ coords[0] = coords[0] - 5
+ coords[1] = coords[1] - 5
+ coords[2] = coords[0] + 5
+ coords[3] = coords[1] + 5
pdc.SetIdBounds(drawid,(coords[0], coords[1], coords[2], coords[3]))
self.ovlcoords[drawid] = coords
elif pdctype == 'text': # draw text on top of map
- print 'in draw: font info, id, pdctype = ',img,drawid,pdctype
+
text = img[0]
- w,h = self.GetFullTextExtent(text)[0:2]
+ w,h = self.GetFullTextExtent(img[0])[0:2]
+ coords[2], coords[3] = coords[0] + w, coords[1] + h
pdc.SetFont(img[1])
pdc.SetTextForeground(img[2])
-# pdc.SetTextBackground(self.RandomColor())
- pdc.DrawText(text, coords[0], coords[1])
+ pdc.DrawText(img[0], coords[0], coords[1])
pdc.SetIdBounds(drawid, (coords[0], coords[1], coords[2], coords[3]))
self.ovlcoords[drawid] = coords
@@ -341,7 +349,6 @@
# use PrepateDC to set position correctly
self.PrepareDC(dc)
# we need to clear the dc BEFORE calling PrepareDC
-# bg = wx.TRANSPARENT_BRUSH
bg = wx.Brush(self.GetBackgroundColour())
dc.SetBackground(bg)
dc.Clear()
@@ -408,6 +415,7 @@
for ovlfile in self.Map.ovlist:
if os.path.isfile(ovlfile) and os.path.getsize(ovlfile):
img = wx.Image(ovlfile, wx.BITMAP_TYPE_ANY)
+# img.ConvertAlphaToMask()
ovlist.append(img)
self.imagedict[img] = ovlist.index(img) # set image PeudoDC ID
return ovlist
@@ -890,7 +898,7 @@
#
self.InitDisplay() # initialize region values
# self.MapWindow = DrawWindow(self) # initialize buffered DC
- self.MapWindow = BufferedWindow(self, id = wx.ID_ANY,map=self.Map) # initialize buffered DC
+ self.MapWindow = BufferedWindow(self, id = wx.ID_ANY) # initialize buffered DC
self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
# decoration overlays
@@ -1133,7 +1141,6 @@
"""
Query currrent or last map
"""
- print "Quering"
self.MapWindow.mouse['box'] = "query"
self.MapWindow.zoomtype = 0
#event.Skip()
@@ -1283,9 +1290,11 @@
Handler for text decoration menu selection.
"""
ovltype = 2 # index for overlay layer in render
+ maptext = ''
+ textfont = self.GetFont()
+ textcolor = wx.BLACK
id = wx.NewId()+100
- print 'in addText'
dlg = TextDialog(self, wx.ID_ANY, 'Text', size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE,
@@ -1297,11 +1306,9 @@
# If OK button pressed in decoration control dialog
val = dlg.ShowModal()
if val == wx.ID_OK:
- print 'OK'
maptext = dlg.currText
textfont = dlg.currFont
textcolor = dlg.currClr
- print 'text, font, color =', maptext,textfont,textcolor
self.MapWindow.Draw(self.MapWindow.pdc, img=(maptext,textfont,textcolor), drawid=id, pdctype='text')
@@ -1400,7 +1407,6 @@
"""
Controls setting options and displaying/hiding map overlay decorations
"""
- print 'in textdialog'
self.ovltype = ovltype
self.drawid = drawid
@@ -1481,10 +1487,6 @@
ptsize = font.GetPointSize()
colour = data.GetColour()
- print ('You selected: "%s", %d points, color %s\n' %
- (font.GetFaceName(), font.GetPointSize(),
- colour.Get()))
-
self.currFont = font
self.currClr = colour
self.UpdateUI()
From barton at grass.itc.it Mon Apr 9 00:19:10 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 9 00:19:12 2007
Subject: [grass-addons] r458 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704082219.l38MJAl4027125@grass.itc.it>
Author: barton
Date: 2007-04-09 00:19:02 +0200 (Mon, 09 Apr 2007)
New Revision: 458
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Overlay text partly working
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-08 16:43:26 UTC (rev 457)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-08 22:19:02 UTC (rev 458)
@@ -191,6 +191,8 @@
self.imagedict = {} # images and their ID's for painting and dragging
self.select = {} # selecting/unselecting decorations for dragging
self.ovlchk = {} # showing/hiding decorations
+ self.textdict = {} # text, font, and color indexed by id
+ self.currtxtid = None # PseudoDC id for currently selected text
#
# mouse attributes like currently pressed buttons, position on
@@ -222,47 +224,6 @@
self.dragid = -1
self.lastpos = (0,0)
-
-# def Draw(self, dc, img=None, pdctype='image', coords='0,0'):
-# """
-# Just here as a place holder.
-# This method should be over-ridden when sub-classed
-# """
-# pass
-#
-# def DrawOvl(self, pdc, type, data, pdctype='image', coords=wx.Rect(0,0,0,0)):
-# """
-# Draws map decorations on top of map
-# Just here as a place holder.
-# This method should be over-ridden when sub-classed
-# """
-# pass
-
-# def Draw(self, dc, img=None, pdctype='image', coords=[0, 0]):
-# """
-# Draws image, box and line in the background
-# """
-# dc.BeginDrawing()
-# dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
-# dc.Clear() # make sure you clear the bitmap!
-#
-# if dctype == 'clear': # erase the display
-# dc.EndDrawing()
-# return
-# bitmap = wx.BitmapFromImage(img)
-# dc.DrawBitmap(bitmap, 0, 0, True) # draw the composite map
-#
-# if dctype == 'box': # draw a box on top of the map
-# dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
-# dc.SetPen(self.pen)
-# dc.DrawRectangle(coords[0], coords[1], coords[2], coords[3])
-# elif dctype == 'line': # draw a line on top of the map
-# dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
-# dc.SetPen(self.pen)
-# dc.DrawLine(coords[0], coords[1], coords[2], coords[3])
-#
-# dc.EndDrawing()
-
def Draw(self, pdc, img=None, drawid=None, pdctype='image', coords=[0,0,0,0]):
"""
Draws map decorations on top of map
@@ -466,7 +427,7 @@
self.pdc.RemoveAll()
self.Draw(self.pdc, self.img, drawid=id) # draw map image background
self.ovlist = self.GetOverlay() # list of decoration overlay images
- if self.ovlist != []:
+ if self.ovlist != []: # draw scale and legend overlays
for img in self.ovlist:
id = self.imagedict[img]
if id not in self.ovlcoords: self.ovlcoords[id] = wx.Rect(0,0,0,0)
@@ -474,8 +435,13 @@
if id not in self.ovlchk: self.ovlchk[id] = False
if self.ovlchk[id] == True: # draw any active and defined overlays
self.Draw(self.pdc, img=img, drawid=id,
- pdctype='image', coords=self.ovlcoords[id])
+ pdctype='image', coords=self.ovlcoords[id])
+ if self.textdict != None: # draw text overlays
+ for id in self.textdict:
+ self.Draw(self.pdc, img=self.textdict[id], drawid=id,
+ pdctype='text', coords=self.ovlcoords[id])
+
self.resize = False
# update statusbar
@@ -571,9 +537,11 @@
self.select[id] = not self.select[id]
if self.select[id] == True:
self.dragid = id
+ if id > 100: self.currtxtid = id
else:
self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
self.dragid = None
+ self.currtxtid = None
self.UpdateMap()
id = None
@@ -719,107 +687,6 @@
self.Map.region['e'] = newreg['e']
self.Map.region['w'] = newreg['w']
-
-#class DrawWindow(BufferedWindow):
-# """
-# Drawing routine for double buffered drawing. Overwrites Draw method
-# in the BufferedWindow class
-# """
-# def __init__(self, parent, id = wx.ID_ANY):
-# """
-# """
-# ## Any data the Draw() function needs must be initialized before
-# ## calling BufferedWindow.__init__, as it will call the Draw
-# ## function.
-# self.dcmd_list = [] # list of display commands to process
-# BufferedWindow.__init__(self, parent, id)
-#
-# def Draw(self, dc, img=None, pdctype='image', coords=[0, 0]):
-# """
-# Draws image, box and line in the background
-# """
-# dc.BeginDrawing()
-# dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
-# dc.Clear() # make sure you clear the bitmap!
-#
-# if dctype == 'clear': # erase the display
-# dc.EndDrawing()
-# return
-# bitmap = wx.BitmapFromImage(img)
-# dc.DrawBitmap(bitmap, 0, 0, True) # draw the composite map
-#
-# if dctype == 'box': # draw a box on top of the map
-# dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
-# dc.SetPen(self.pen)
-# dc.DrawRectangle(coords[0], coords[1], coords[2], coords[3])
-# elif dctype == 'line': # draw a line on top of the map
-# dc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
-# dc.SetPen(self.pen)
-# dc.DrawLine(coords[0], coords[1], coords[2], coords[3])
-#
-# dc.EndDrawing()
-#
-# def DrawOvl(self, pdc, img=None, id=None, pdctype='image', coords=[0,0,0,0]):
-# """
-# Draws map decorations on top of map
-# """
-# pdc.BeginDrawing()
-#
-# if id == None:
-# if pdctype == 'image' :
-# id = imagedict[img]
-# else:
-# id = wx.NewId()
-# pdc.SetId(id)
-# self.select[id] = False
-#
-# if pdctype == 'clear': # erase the display
-## if type > -1:
-## pdc.RemoveId(id)
-# pdc.EndDrawing()
-# return
-#
-# elif pdctype == 'image':
-# bitmap = wx.BitmapFromImage(img)
-# w,h = bitmap.GetSize()
-# pdc.DrawBitmap(bitmap, coords[0], coords[1], True) # draw the composite map
-# pdc.SetIdBounds(id, (coords[0],coords[1],w,h))
-#
-# elif pdctype == 'box': # draw a box on top of the map
-# pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
-# pdc.SetPen(self.pen)
-# pdc.DrawRectangle(coords[0], coords[1], coords[2], coords[3])
-# rect.Inflate(pen.GetWidth(),pen.GetWidth())
-# pdc.SetIdBounds(id,(coords[0], coords[1], coords[2], coords[3]))
-#
-# elif pdctype == 'line': # draw a line on top of the map
-# pdc.SetBrush(wx.Brush(wx.CYAN, wx.TRANSPARENT))
-# pdc.SetPen(self.pen)
-# dc.DrawLine(rect)
-# rect.Inflate(pen.GetWidth(),pen.GetWidth())
-# pdc.SetIdBounds(id,(coords[0], coords[1], coords[2], coords[3]))
-#
-# elif pdctype == 'point': #draw point
-# pen = self.RandomPen()
-# pdc.SetPen(pen)
-# pdc.DrawPoint(coords[0], coords[1])
-# rect.Inflate(pen.GetWidth(),pen.GetWidth())
-# pdc.SetIdBounds(id,(coords[0], coords[1], coords[2], coords[3]))
-#
-# elif pdctype == 'text': # draw text on top of map
-# text = img
-# w,h = self.GetFullTextExtent(text)[0:2]
-# pdc.SetFont(self.GetFont())
-# pdc.SetTextForeground(self.RandomColor())
-# pdc.SetTextBackground(self.RandomColor())
-# pdc.DrawText(text, coords[0], coords[1])
-# rect.Inflate(2,2)
-# pdc.SetIdBounds(id, (coords[0], coords[1], coords[2], coords[3]))
-#
-# pdc.EndDrawing()
-# self.Refresh()
-
-
class MapFrame(wx.Frame):
"""
Main frame for map display window. Drawing takes place in child double buffered
@@ -844,6 +711,8 @@
style -- window style
toolbars-- array of default toolbars, which should appear
map, digit
+ cb -- control book ID in GIS Manager
+ idx -- index of display
"""
wx.Frame.__init__(self, parent, id, title, pos, size, style)
@@ -905,6 +774,7 @@
self.ovlchk = self.MapWindow.ovlchk
self.ovlcoords = self.MapWindow.ovlcoords
self.params = {} # previously set decoration options parameters to insert into options dialog
+
#
# Bind various events
# ONLY if we are running from GIS manager
@@ -1293,10 +1163,15 @@
maptext = ''
textfont = self.GetFont()
textcolor = wx.BLACK
+ textcoords = [0,0,0,0]
- id = wx.NewId()+100
+ if self.MapWindow.currtxtid == None: # text doesn't already exist
+ id = wx.NewId()+100
+ else: # text already exists
+ id = self.MapWindow.currtxtid
+ textcoords=self.ovlcoords[id]
- dlg = TextDialog(self, wx.ID_ANY, 'Text', size=(350, 200),
+ dlg = TextDialog(self, wx.ID_ANY, 'Text', size=(400, 200),
style=wx.DEFAULT_DIALOG_STYLE,
ovltype=ovltype,
drawid=id)
@@ -1310,10 +1185,12 @@
textfont = dlg.currFont
textcolor = dlg.currClr
- self.MapWindow.Draw(self.MapWindow.pdc, img=(maptext,textfont,textcolor), drawid=id, pdctype='text')
+ self.MapWindow.textdict[id] = (maptext,textfont,textcolor)
+ self.MapWindow.Draw(self.MapWindow.pdc, img=self.MapWindow.textdict[id],
+ drawid=id, pdctype='text', coords=textcoords)
+ self.MapWindow.Update()
-
def getOptData(self, dcmd, type, params):
"""
Callback method for decoration overlay command generated by
@@ -1400,9 +1277,7 @@
class TextDialog(wx.Dialog):
def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_DIALOG_STYLE,
- ovltype=2,drawid=None,currText='',
- currClr=wx.BLACK,
- currFont=''):
+ ovltype=2,drawid=None):
wx.Dialog.__init__(self, parent, id, title, pos, size, style)
"""
Controls setting options and displaying/hiding map overlay decorations
@@ -1410,13 +1285,14 @@
self.ovltype = ovltype
self.drawid = drawid
- self.currClr = currClr
- self.currText = currText
- self.currFont = currFont
-# self.ovlcmd = cmd
-# self.ovlchk = self.Parent.MapWindow.ovlchk
-# self.params = params #previously set decoration options to pass back to options dialog
+ if drawid in self.Parent.MapWindow.textdict:
+ self.currText,self.currFont,self.currClr = self.Parent.MapWindow.textdict[drawid]
+ else:
+ self.currClr = wx.BLACK
+ self.currText = ''
+ self.currFont = self.GetFont()
+
sizer = wx.BoxSizer(wx.VERTICAL)
box = wx.BoxSizer(wx.HORIZONTAL)
@@ -1424,8 +1300,10 @@
label = wx.StaticText(self, -1, "Enter text:")
box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
- self.textentry = wx.TextCtrl(self, -1, "", size=(80,-1))
- self.currFont = self.textentry.GetFont()
+ self.textentry = wx.TextCtrl(self, -1, "", size=(200,-1))
+ self.textentry.SetFont(self.currFont)
+ self.textentry.SetForegroundColour(self.currClr)
+ self.textentry.SetValue(self.currText)
box.Add(self.textentry, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
@@ -1435,7 +1313,10 @@
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
- label = wx.StaticText(self, -1, ("Double-click text with mouse in\npointer mode and drag to position.\nDouble-click again to set"))
+ label = wx.StaticText(self, -1, ("Double-click text with mouse in\
+ \npointer mode and drag to position.\
+ \nEdit by selecting text from overlay menu.\
+ \nDouble-click again to set"))
box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
@@ -1482,31 +1363,16 @@
if dlg.ShowModal() == wx.ID_OK:
data = dlg.GetFontData()
- font = data.GetChosenFont()
- face = font.GetFaceName()
- ptsize = font.GetPointSize()
- colour = data.GetColour()
+ self.currFont = data.GetChosenFont()
+ self.currClr = data.GetColour()
- self.currFont = font
- self.currClr = colour
- self.UpdateUI()
+ self.textentry.SetFont(self.currFont)
+ self.textentry.SetForegroundColour(self.currClr)
- # Don't destroy the dialog until you get everything you need from the
- # dialog!
+ self.Layout()
+
dlg.Destroy()
- def UpdateUI(self):
- self.textentry.SetFont(self.currFont)
- self.textentry.SetForegroundColour(self.currClr)
-# self.ps.SetLabel(str(self.currFont.GetPointSize()))
-# self.family.SetLabel(self.currFont.GetFamilyString())
-# self.style.SetLabel(self.currFont.GetStyleString())
-# self.weight.SetLabel(self.currFont.GetWeightString())
-# self.face.SetLabel(self.currFont.GetFaceName())
-# self.nfi.SetLabel(self.currFont.GetNativeFontInfo().ToString())
- self.Layout()
-
-
class MapApp(wx.App):
"""
MapApp class
From barton at grass.itc.it Mon Apr 9 08:24:34 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 9 08:24:36 2007
Subject: [grass-addons] r459 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704090624.l396OYC6031705@grass.itc.it>
Author: barton
Date: 2007-04-09 08:24:25 +0200 (Mon, 09 Apr 2007)
New Revision: 459
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Multiple text overlays work now. Scale and legend overlays improved.
Double click to change options. Drag with mouse to reposition.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-08 22:19:02 UTC (rev 458)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-09 06:24:25 UTC (rev 459)
@@ -186,9 +186,10 @@
#
self.mapfile = None # image file to be rendered
self.img = "" # wx.Image object (self.mapfile)
- self.ovlist = [] # list of images for overlays
+ self.ovldict = {} # list of images for overlays
self.ovlcoords = {} # positioning coordinates for decoration overlay
- self.imagedict = {} # images and their ID's for painting and dragging
+ self.imagedict = {} # images and their PseudoDC ID's for painting and dragging
+ self.crop = {} # coordinates to crop overlays to their data, indexed by image ID
self.select = {} # selecting/unselecting decorations for dragging
self.ovlchk = {} # showing/hiding decorations
self.textdict = {} # text, font, and color indexed by id
@@ -258,6 +259,9 @@
if pdctype == 'image':
mask = None
bitmap = wx.BitmapFromImage(img)
+# if drawid in self.ovldict:
+# w,h = self.ovldict[drawid][1]
+# else:
w,h = bitmap.GetSize()
pdc.DrawBitmap(bitmap, coords[0], coords[1], True) # draw the composite map
pdc.SetIdBounds(drawid, (coords[0],coords[1],w,h))
@@ -371,17 +375,61 @@
"""
Converts overlay files to wx.Image
"""
- ovlist = []
+ self.ovldict = {}
if self.Map.ovlist:
for ovlfile in self.Map.ovlist:
if os.path.isfile(ovlfile) and os.path.getsize(ovlfile):
img = wx.Image(ovlfile, wx.BITMAP_TYPE_ANY)
-# img.ConvertAlphaToMask()
- ovlist.append(img)
- self.imagedict[img] = ovlist.index(img) # set image PeudoDC ID
- return ovlist
+ left = right = top = bottom = 0
+ breakout = False
+# # auto-crop scales and legends
+# for w in range(img.GetWidth()): # set left edge
+# for h in range(img.GetHeight()-1):
+# if img.IsTransparent(w,h) == False:
+# left = w
+# breakout = True
+# break
+# if breakout:
+# breakout = False
+# break
+# for w in range(img.GetWidth()-1, 0, -1): # set right edge
+# for h in range(img.GetHeight()-1):
+# if img.IsTransparent(w,h) == False:
+# right = w
+# breakout = True
+# break
+# if breakout:
+# breakout = False
+# break
+# for h in range(img.GetHeight()): # set top edge
+# for w in range(left,right):
+# if img.IsTransparent(w,h) == False:
+# top = h
+# breakout = True
+# break
+# if breakout:
+# breakout = False
+# break
+# for h in range(img.GetHeight()-1, 0, - 1): # set top edge
+# for w in range(left,right):
+# if img.IsTransparent(w,h) == False:
+# bottom = h
+# breakout = True
+# break
+# if breakout:
+# breakout = False
+# break
+# cropwidth = right - left
+# cropheight = bottom - top
+ pdc_id = self.Map.ovlist.index(ovlfile)
+# self.ovldict[pdc_id] = img,(cropwidth,cropheight) # image and cropping information for each overlay image
+ self.ovldict[pdc_id] = img # image information for each overlay image
+ self.imagedict[img] = pdc_id # set image PeudoDC ID
+ return self.ovldict
+
+
def GetImage(self):
"""
Converts files to wx.Image
@@ -426,12 +474,11 @@
self.pdc.Clear()
self.pdc.RemoveAll()
self.Draw(self.pdc, self.img, drawid=id) # draw map image background
- self.ovlist = self.GetOverlay() # list of decoration overlay images
- if self.ovlist != []: # draw scale and legend overlays
- for img in self.ovlist:
- id = self.imagedict[img]
+ self.ovldict = self.GetOverlay() # list of decoration overlay images
+ if self.ovldict != {}: # draw scale and legend overlays
+ for id in self.ovldict:
+ img = self.ovldict[id]
if id not in self.ovlcoords: self.ovlcoords[id] = wx.Rect(0,0,0,0)
- if id == None: return # ID has not yet been assigned (image not painted)
if id not in self.ovlchk: self.ovlchk[id] = False
if self.ovlchk[id] == True: # draw any active and defined overlays
self.Draw(self.pdc, img=img, drawid=id,
@@ -480,10 +527,9 @@
self.pdc.SetBackground(wx.Brush(self.GetBackgroundColour()))
r = self.pdc.GetIdBounds(id)
self.pdc.TranslateId(id, dx, dy)
- if id != 99:
- r2 = self.pdc.GetIdBounds(id)
- r = r.Union(r2)
- r.Inflate(4,4)
+ r2 = self.pdc.GetIdBounds(id)
+ r = r.Union(r2)
+ r.Inflate(4,4)
self.RefreshRect(r, False)
self.lastpos = (event.GetX(),event.GetY())
@@ -520,31 +566,33 @@
wheel = event.GetWheelRotation() # +- int
hitradius = 5 # distance for selecting map decorations
- # left mouse button pressed
+ # left mouse button pressed; get decoration ID
if event.LeftDown():
- self.mouse['begin'] = event.GetPositionTuple()[:]
+ self.lastpos = self.mouse['begin'] = event.GetPositionTuple()[:]
+ idlist = self.pdc.FindObjects(self.mouse['begin'][0], self.mouse['begin'][1], hitradius)
+ if idlist != []:
+ self.dragid = idlist[0]
- # double click to select decoration for dragging
+ # double click to select overlay decoration options dialog
elif event.ButtonDClick():
# start point of drag
- self.lastpos = event.GetPositionTuple()[:]
+ clickposition = event.GetPositionTuple()[:]
- # select decoration and get its ID
+ # get decoration ID
# l = self.pdc.FindObjectsByBBox(self.mouse['begin'][0], self.mouse['begin'][1])
- idlist = self.pdc.FindObjects(self.lastpos[0], self.lastpos[1], hitradius)
+ idlist = self.pdc.FindObjects(clickposition[0], clickposition[1], hitradius)
if idlist == []: return
- id = idlist[0]
- self.select[id] = not self.select[id]
- if self.select[id] == True:
- self.dragid = id
- if id > 100: self.currtxtid = id
- else:
- self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
- self.dragid = None
- self.currtxtid = None
- self.UpdateMap()
- id = None
+ self.dragid = idlist[0]
+ self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
+ if self.dragid > 100:
+ self.currtxtid = self.dragid
+ self.Parent.addText(None)
+ elif self.dragid == 0:
+ self.Parent.addBarscale(None)
+ elif self.dragid == 1:
+ self.Parent.addLegend(None)
+
# left mouse button released and not just a pointer
elif event.LeftUp():
@@ -558,7 +606,7 @@
self.render=True
self.UpdateMap()
- # digitizing
+ # digitizing
elif self.parent.digittoolbar:
if self.parent.digittoolbar.digitize == "point":
east,north= self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1])
@@ -567,7 +615,7 @@
self.render=True
self.UpdateMap()
- # quering
+ # querying
elif self.mouse["box"] == "query":
east,north = self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1])
if self.parent.gismanager:
@@ -583,15 +631,19 @@
else:
print "Quering without gis manager not implemented yet"
-
+ # end drag of overlay decoration
elif self.dragid:
- self.Refresh()
+ self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
+ self.dragid = None
+ self.currtxtid = None
+ id = None
self.Update()
elif event.Dragging():
currpos = event.GetPositionTuple()[:]
end = (currpos[0]-self.mouse['begin'][0], \
currpos[1]-self.mouse['begin'][1])
+
# dragging or drawing box with left button
if self.mouse['box'] == 'pan':
self.DragMap(end)
@@ -618,16 +670,15 @@
x,y = event.GetPositionTuple()[:]
#l = self.pdc.FindObjectsByBBox(x, y)
l = self.pdc.FindObjects(x, y, hitradius)
- if l:
- id = l[0]
- self.pdc.SetId(id)
- if self.pdc.GetIdGreyedOut(id) == True:
- self.pdc.SetIdGreyedOut(id, False)
- else:
- self.pdc.SetIdGreyedOut(id, True)
- r = self.pdc.GetIdBounds(id)
- r.Inflate(4,4)
- self.RefreshRect(r, False)
+ if not l: return
+ id = l[0]
+ if self.pdc.GetIdGreyedOut(id) == True:
+ self.pdc.SetIdGreyedOut(id, False)
+ else:
+ self.pdc.SetIdGreyedOut(id, True)
+ r = self.pdc.GetIdBounds(id)
+ r.Inflate(4,4)
+ self.RefreshRect(r, False)
# store current mouse position
self.mouse['pos'] = event.GetPositionTuple()[:]
@@ -858,11 +909,6 @@
self.ctrlbk.SetSelection(pgnum)
event.Skip()
-# def SetDcommandList(self, clst):
-# self.MapWindow.dcmd_list = clst
-# self.MapWindow.ProcessDcommand()
-# self.MapWindow.UpdateMap()
-
def OnMotion(self, event):
"""
Mouse moved
@@ -884,12 +930,6 @@
"""
self.MapWindow.UpdateMap()
-# def ReDrawCommand(self):
-# """
-# d.* command on command line and enter pressed.
-# """
-# self.MapWindow.UpdateMap()
-
def Pointer(self, event):
"""Pointer button clicled"""
self.MapWindow.mouse['box'] = "point"
@@ -952,7 +992,6 @@
self.Map.getRegion()
self.Map.getResolution()
self.UpdateMap()
-# self.draw(dc)
event.Skip()
def OnAlignRegion(self, event):
@@ -1079,17 +1118,16 @@
"""
Handler for scale/arrow map decoration menu selection.
"""
- ovltype = 0 # index for overlay layer in render
+ ovltype = id = 0 # index for overlay layer in render
if ovltype in self.params:
params = self.params[ovltype]
else:
params = ''
- ovlist = self.MapWindow.GetOverlay()
- if ovlist == []: return
- img = ovlist[0]
- id = self.MapWindow.imagedict[img]
- if id == None: return
+ ovldict = self.MapWindow.GetOverlay()
+ if id not in ovldict: return
+ img = ovldict[id]
+
if id not in self.ovlcoords: self.ovlcoords[id] = wx.Rect(0,0,0,0)
# Decoration overlay control dialog
@@ -1119,18 +1157,15 @@
"""
Handler for legend map decoration menu selection.
"""
- ovltype = 1 # index for overlay layer in render
+ ovltype = id = 1 # index for overlay layer in render
if ovltype in self.params:
params = self.params[ovltype]
else:
params = ''
- ovlist = self.MapWindow.GetOverlay()
- if ovlist == []: return
- img = ovlist[1]
- id = self.MapWindow.imagedict[img]
- if id == None: return
- if id not in self.ovlcoords: self.ovlcoords[id] = wx.Rect(0,0,0,0)
+ ovldict = self.MapWindow.GetOverlay()
+ if id not in ovldict: return
+ img = ovldict[id]
# Decoration overlay control dialog
dlg = DecDialog(self, wx.ID_ANY, 'Legend', size=(350, 200),
@@ -1185,6 +1220,8 @@
textfont = dlg.currFont
textcolor = dlg.currClr
+ self.MapWindow.pdc.ClearId(id)
+ self.MapWindow.pdc.SetId(id)
self.MapWindow.textdict[id] = (maptext,textfont,textcolor)
self.MapWindow.Draw(self.MapWindow.pdc, img=self.MapWindow.textdict[id],
drawid=id, pdctype='text', coords=textcoords)
@@ -1233,7 +1270,7 @@
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
- label = wx.StaticText(self, -1, ("Double-click %s with mouse in\npointer mode and drag to position.\nDouble-click again to set" % ctrltxt))
+ label = wx.StaticText(self, -1, ("Drag %s with mouse in pointer mode\nto position. Double-click to change options" % ctrltxt))
box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
@@ -1313,10 +1350,7 @@
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
- label = wx.StaticText(self, -1, ("Double-click text with mouse in\
- \npointer mode and drag to position.\
- \nEdit by selecting text from overlay menu.\
- \nDouble-click again to set"))
+ label = wx.StaticText(self, -1, ("Drag text with mouse in pointer mode\nto position. Double-click to change options"))
box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
@@ -1338,18 +1372,9 @@
self.SetSizer(sizer)
sizer.Fit(self)
-# self.Bind(wx.EVT_CHECKBOX, self.onCheck, self.chkbox)
self.Bind(wx.EVT_BUTTON, self.onSelectFont, fontbtn)
self.textentry.Bind(wx.EVT_TEXT, self.onText)
-
-# def onCheck(self, event):
-# """
-# Handler for checkbox for displaying/hiding decoration
-# """
-# check = event.IsChecked()
-# self.ovlchk[self.drawid] = check
-
def onText(self, event):
self.currText = event.GetString()
From barton at grass.itc.it Mon Apr 9 15:58:43 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 9 15:58:44 2007
Subject: [grass-addons] r460 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704091358.l39Dwh0W002257@grass.itc.it>
Author: barton
Date: 2007-04-09 15:58:34 +0200 (Mon, 09 Apr 2007)
New Revision: 460
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Fix to keep overlay decoration in place with a map update.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-09 06:24:25 UTC (rev 459)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-09 13:58:34 UTC (rev 460)
@@ -632,7 +632,7 @@
print "Quering without gis manager not implemented yet"
# end drag of overlay decoration
- elif self.dragid:
+ elif self.dragid != None:
self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
self.dragid = None
self.currtxtid = None
From barton at grass.itc.it Mon Apr 9 21:16:22 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 9 21:16:24 2007
Subject: [grass-addons] r461 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704091916.l39JGMnW006136@grass.itc.it>
Author: barton
Date: 2007-04-09 21:16:16 +0200 (Mon, 09 Apr 2007)
New Revision: 461
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Text rotation added for overlay decorations.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-09 13:58:34 UTC (rev 460)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-09 19:16:16 UTC (rev 461)
@@ -22,7 +22,7 @@
import wx
import wx.aui
-import os, sys, time, glob
+import os, sys, time, glob, math
import render
import toolbars
@@ -292,19 +292,38 @@
self.ovlcoords[drawid] = coords
elif pdctype == 'text': # draw text on top of map
-
text = img[0]
+ rotation = float(img[3])
w,h = self.GetFullTextExtent(img[0])[0:2]
- coords[2], coords[3] = coords[0] + w, coords[1] + h
pdc.SetFont(img[1])
pdc.SetTextForeground(img[2])
- pdc.DrawText(img[0], coords[0], coords[1])
- pdc.SetIdBounds(drawid, (coords[0], coords[1], coords[2], coords[3]))
+ coords,w,h = self.textBounds(img,coords)
+ if rotation == 0:
+ pdc.DrawText(img[0], coords[0], coords[1])
+ else:
+ pdc.DrawRotatedText(img[0], coords[0], coords[1], rotation)
+ pdc.SetIdBounds(drawid, (coords[0], coords[1], w, h))
self.ovlcoords[drawid] = coords
pdc.EndDrawing()
self.Refresh()
+ def textBounds(self, textinfo, coords):
+ rotation = float(textinfo[3])
+ self.Update()
+ self.Refresh()
+ self.SetFont(textinfo[1])
+ w,h = self.GetTextExtent(textinfo[0])
+ if rotation == 0:
+ coords[2], coords[3] = coords[0] + w, coords[1] + h
+ return coords,w,h
+ else:
+ boxh = math.fabs(math.sin(math.radians(rotation)) * w) + h
+ boxw = math.fabs(math.cos(math.radians(rotation)) * w) + h
+ coords[2] = coords[0] + boxw
+ coords[3] = coords[1] + boxh
+ return coords,boxw,boxh
+
def OnPaint(self, event):
"""
All that is needed here is to draw the buffer to screen
@@ -526,10 +545,16 @@
dy = event.GetY() - y
self.pdc.SetBackground(wx.Brush(self.GetBackgroundColour()))
r = self.pdc.GetIdBounds(id)
+ if self.dragid > 100: # text dragging
+ rtop = (r[0],r[1]-r[3],r[2],r[3])
+ r = r.Union(rtop)
+ rleft = (r[0]-r[2],r[1],r[2],r[3])
+ r = r.Union(rleft)
self.pdc.TranslateId(id, dx, dy)
r2 = self.pdc.GetIdBounds(id)
r = r.Union(r2)
r.Inflate(4,4)
+ self.Update()
self.RefreshRect(r, False)
self.lastpos = (event.GetX(),event.GetY())
@@ -564,12 +589,13 @@
Mouse motion and button click notifier
"""
wheel = event.GetWheelRotation() # +- int
- hitradius = 5 # distance for selecting map decorations
+ hitradius = 10 # distance for selecting map decorations
# left mouse button pressed; get decoration ID
if event.LeftDown():
self.lastpos = self.mouse['begin'] = event.GetPositionTuple()[:]
- idlist = self.pdc.FindObjects(self.mouse['begin'][0], self.mouse['begin'][1], hitradius)
+# idlist = self.pdc.FindObjectsByBBox(self.lastpos[0],self.lastpos[1])
+ idlist = self.pdc.FindObjects(self.lastpos[0],self.lastpos[1], hitradius)
if idlist != []:
self.dragid = idlist[0]
@@ -579,7 +605,7 @@
clickposition = event.GetPositionTuple()[:]
# get decoration ID
-# l = self.pdc.FindObjectsByBBox(self.mouse['begin'][0], self.mouse['begin'][1])
+# idlist = self.pdc.FindObjectsByBBox(clickposition[0], clickposition[1])
idlist = self.pdc.FindObjects(clickposition[0], clickposition[1], hitradius)
if idlist == []: return
self.dragid = idlist[0]
@@ -1128,7 +1154,7 @@
if id not in ovldict: return
img = ovldict[id]
- if id not in self.ovlcoords: self.ovlcoords[id] = wx.Rect(0,0,0,0)
+ if id not in self.ovlcoords: self.ovlcoords[id] = [10,10]
# Decoration overlay control dialog
dlg = DecDialog(self, wx.ID_ANY, 'Scale and North arrow', size=(350, 200),
@@ -1167,6 +1193,8 @@
if id not in ovldict: return
img = ovldict[id]
+ if id not in self.ovlcoords: self.ovlcoords[id] = [10,10]
+
# Decoration overlay control dialog
dlg = DecDialog(self, wx.ID_ANY, 'Legend', size=(350, 200),
style=wx.DEFAULT_DIALOG_STYLE,
@@ -1198,7 +1226,8 @@
maptext = ''
textfont = self.GetFont()
textcolor = wx.BLACK
- textcoords = [0,0,0,0]
+ textcoords = [10,10,10,10]
+ rotation = 0
if self.MapWindow.currtxtid == None: # text doesn't already exist
id = wx.NewId()+100
@@ -1219,10 +1248,20 @@
maptext = dlg.currText
textfont = dlg.currFont
textcolor = dlg.currClr
+ rotation = dlg.currRot
+ coords,w,h = self.MapWindow.textBounds((maptext,textfont,textcolor,rotation),textcoords)
+ # delete object if if it has no text
+ if maptext == '':
+ self.MapWindow.pdc.ClearId(id)
+ self.MapWindow.pdc.RemoveId(id)
+ del self.MapWindow.textdict[id]
+ del self.ovlcoords[id]
+ return
+
self.MapWindow.pdc.ClearId(id)
self.MapWindow.pdc.SetId(id)
- self.MapWindow.textdict[id] = (maptext,textfont,textcolor)
+ self.MapWindow.textdict[id] = (maptext,textfont,textcolor,rotation)
self.MapWindow.Draw(self.MapWindow.pdc, img=self.MapWindow.textdict[id],
drawid=id, pdctype='text', coords=textcoords)
self.MapWindow.Update()
@@ -1324,19 +1363,18 @@
self.drawid = drawid
if drawid in self.Parent.MapWindow.textdict:
- self.currText,self.currFont,self.currClr = self.Parent.MapWindow.textdict[drawid]
+ self.currText,self.currFont,self.currClr,self.currRot = self.Parent.MapWindow.textdict[drawid]
else:
self.currClr = wx.BLACK
self.currText = ''
self.currFont = self.GetFont()
+ self.currRot = 0
sizer = wx.BoxSizer(wx.VERTICAL)
box = wx.BoxSizer(wx.HORIZONTAL)
-
label = wx.StaticText(self, -1, "Enter text:")
box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
-
self.textentry = wx.TextCtrl(self, -1, "", size=(200,-1))
self.textentry.SetFont(self.currFont)
self.textentry.SetForegroundColour(self.currClr)
@@ -1345,6 +1383,16 @@
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
box = wx.BoxSizer(wx.HORIZONTAL)
+ label = wx.StaticText(self, -1, "Rotation:")
+ box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ self.rotation = wx.SpinCtrl(self, id=wx.ID_ANY, value="", pos=(30, 50),
+ size=(75,-1), style=wx.SP_ARROW_KEYS)
+ self.rotation.SetRange(-360,360)
+ self.rotation.SetValue(int(self.currRot))
+ box.Add(self.rotation, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
+ sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+
+ box = wx.BoxSizer(wx.HORIZONTAL)
fontbtn = wx.Button(self, wx.ID_ANY, "Set font")
box.Add(fontbtn, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
@@ -1374,10 +1422,14 @@
self.Bind(wx.EVT_BUTTON, self.onSelectFont, fontbtn)
self.textentry.Bind(wx.EVT_TEXT, self.onText)
+ self.rotation.Bind(wx.EVT_TEXT, self.onRotation)
def onText(self, event):
self.currText = event.GetString()
+ def onRotation(self, event):
+ self.currRot = event.GetString()
+
def onSelectFont(self, event):
data = wx.FontData()
data.EnableEffects(True)
From barton at grass.itc.it Tue Apr 10 05:18:51 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 10 05:18:52 2007
Subject: [grass-addons] r462 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704100318.l3A3IpTO012338@grass.itc.it>
Author: barton
Date: 2007-04-10 05:18:42 +0200 (Tue, 10 Apr 2007)
New Revision: 462
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Clicking query button in map display tool bar will switch GIS Manager
display to output console to display query results.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-09 19:16:16 UTC (rev 461)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-10 03:18:42 UTC (rev 462)
@@ -1076,6 +1076,10 @@
"""
Query currrent or last map
"""
+ # switch GIS Manager to output console to show query results
+
+ self.Parent.notebook.SetSelection(1)
+
self.MapWindow.mouse['box'] = "query"
self.MapWindow.zoomtype = 0
#event.Skip()
From barton at grass.itc.it Tue Apr 10 06:44:46 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 10 06:44:47 2007
Subject: [grass-addons] r463 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704100444.l3A4ikNG013463@grass.itc.it>
Author: barton
Date: 2007-04-10 06:44:37 +0200 (Tue, 10 Apr 2007)
New Revision: 463
Modified:
trunk/grassaddons/gui/gui_modules/select.py
Log:
Attempt to fix bug where expanding selection tree in select control
causes expand event to propagate to GIS Manager layer tree. Try this
with line 131 active again and see what happens.
Modified: trunk/grassaddons/gui/gui_modules/select.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/select.py 2007-04-10 03:18:42 UTC (rev 462)
+++ trunk/grassaddons/gui/gui_modules/select.py 2007-04-10 04:44:37 UTC (rev 463)
@@ -28,40 +28,47 @@
def Create(self, parent):
- self.tree = wx.TreeCtrl(parent, style=wx.TR_HIDE_ROOT
+ self.seltree = wx.TreeCtrl(parent, style=wx.TR_HIDE_ROOT
|wx.TR_HAS_BUTTONS
|wx.TR_SINGLE
|wx.TR_LINES_AT_ROOT
|wx.SIMPLE_BORDER
|wx.TR_FULL_ROW_HIGHLIGHT)
- self.tree.Bind(wx.EVT_MOTION, self.OnMotion)
- self.tree.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
+ self.seltree.Bind(wx.EVT_MOTION, self.OnMotion)
+ self.seltree.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
+ self.seltree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.mapsetExpanded)
+ self.seltree.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.mapsetCollapsed)
+ def mapsetExpanded(self, event):
+ pass
+ def mapsetCollapsed(self, event):
+ pass
+
def GetControl(self):
- return self.tree
+ return self.seltree
def GetStringValue(self):
if self.value:
- return self.tree.GetItemText(self.value)
+ return self.seltree.GetItemText(self.value)
return ""
def OnPopup(self):
if self.value:
- self.tree.EnsureVisible(self.value)
- self.tree.SelectItem(self.value)
+ self.seltree.EnsureVisible(self.value)
+ self.seltree.SelectItem(self.value)
def SetStringValue(self, value):
# this assumes that item strings are unique...
- root = self.tree.GetRootItem()
+ root = self.seltree.GetRootItem()
if not root:
return
found = self.FindItem(root, value)
if found:
self.value = found
- self.tree.SelectItem(found)
+ self.seltree.SelectItem(found)
def GetAdjustedSize(self, minWidth, prefHeight, maxHeight):
return wx.Size(minWidth, min(200, maxHeight))
@@ -107,7 +114,7 @@
for dir in mapsets:
if dir == curr_mapset:
dir_node = self.AddItem('Mapset: '+dir)
- self.tree.SetItemTextColour(dir_node,wx.Colour(50,50,200))
+ self.seltree.SetItemTextColour(dir_node,wx.Colour(50,50,200))
try:
elem_list = os.listdir(os.path.join (location_path, dir, element))
for elem in elem_list:
@@ -121,11 +128,11 @@
# if self.layertype[self.layer_selected] == 'group':
# KeyError: >
# -------- ERROR END --------------
- #self.tree.Expand(dir_node)
-
+ #self.seltree.Expand(dir_node)
+
else:
dir_node = self.AddItem('Mapset: '+dir)
- self.tree.SetItemTextColour(dir_node,wx.Colour(50,50,200))
+ self.seltree.SetItemTextColour(dir_node,wx.Colour(50,50,200))
try:
elem_list = os.listdir(os.path.join (location_path, dir, element))
for elem in elem_list:
@@ -135,37 +142,37 @@
# helpers
def FindItem(self, parentItem, text):
- item, cookie = self.tree.GetFirstChild(parentItem)
+ item, cookie = self.seltree.GetFirstChild(parentItem)
while item:
- if self.tree.GetItemText(item) == text:
+ if self.seltree.GetItemText(item) == text:
return item
- if self.tree.ItemHasChildren(item):
+ if self.seltree.ItemHasChildren(item):
item = self.FindItem(item, text)
- item, cookie = self.tree.GetNextChild(parentItem, cookie)
+ item, cookie = self.seltree.GetNextChild(parentItem, cookie)
return wx.TreeItemId();
def AddItem(self, value, parent=None):
if not parent:
- root = self.tree.GetRootItem()
+ root = self.seltree.GetRootItem()
if not root:
- root = self.tree.AddRoot("")
+ root = self.seltree.AddRoot("")
parent = root
- item = self.tree.AppendItem(parent, value)
+ item = self.seltree.AppendItem(parent, value)
return item
def OnMotion(self, evt):
# have the selection follow the mouse, like in a real combobox
- item, flags = self.tree.HitTest(evt.GetPosition())
+ item, flags = self.seltree.HitTest(evt.GetPosition())
if item and flags & wx.TREE_HITTEST_ONITEMLABEL:
- self.tree.SelectItem(item)
+ self.seltree.SelectItem(item)
self.curitem = item
evt.Skip()
def OnLeftDown(self, evt):
# do the combobox selection
- item, flags = self.tree.HitTest(evt.GetPosition())
+ item, flags = self.seltree.HitTest(evt.GetPosition())
if item and flags & wx.TREE_HITTEST_ONITEMLABEL:
self.curitem = item
self.value = item
From barton at grass.itc.it Tue Apr 10 07:33:55 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 10 07:33:57 2007
Subject: [grass-addons] r464 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704100533.l3A5XtLv013560@grass.itc.it>
Author: barton
Date: 2007-04-10 07:33:47 +0200 (Tue, 10 Apr 2007)
New Revision: 464
Modified:
trunk/grassaddons/gui/gui_modules/select.py
Log:
Improve appearance select control.
Modified: trunk/grassaddons/gui/gui_modules/select.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/select.py 2007-04-10 04:44:37 UTC (rev 463)
+++ trunk/grassaddons/gui/gui_modules/select.py 2007-04-10 05:33:47 UTC (rev 464)
@@ -12,6 +12,7 @@
wx.combo.ComboCtrl.__init__(self, parent=parent, id=id, size=size)
tcp = TreeCtrlComboPopup()
self.SetPopupControl(tcp)
+ self.SetPopupExtents(0,100)
tcp.getElementList(type)
class TreeCtrlComboPopup(wx.combo.ComboPopup):
@@ -128,7 +129,7 @@
# if self.layertype[self.layer_selected] == 'group':
# KeyError: >
# -------- ERROR END --------------
- #self.seltree.Expand(dir_node)
+# self.seltree.Expand(dir_node)
else:
dir_node = self.AddItem('Mapset: '+dir)
From barton at grass.itc.it Tue Apr 10 16:42:22 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 10 16:42:24 2007
Subject: [grass-addons] r465 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704101442.l3AEgMCY019851@grass.itc.it>
Author: barton
Date: 2007-04-10 16:42:14 +0200 (Tue, 10 Apr 2007)
New Revision: 465
Modified:
trunk/grassaddons/gui/gui_modules/select.py
Log:
Additional dummy handler added to selection tree to stop bogus event
propagation up to GIS Manager layer tree.
Modified: trunk/grassaddons/gui/gui_modules/select.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/select.py 2007-04-10 05:33:47 UTC (rev 464)
+++ trunk/grassaddons/gui/gui_modules/select.py 2007-04-10 14:42:14 UTC (rev 465)
@@ -39,13 +39,24 @@
self.seltree.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.seltree.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.mapsetExpanded)
self.seltree.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.mapsetCollapsed)
+ self.seltree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.mapsetActivated)
+ self.seltree.Bind(wx.EVT_TREE_SEL_CHANGED, self.mapsetSelected)
+ # the following dummy handler are needed to keep tree events from propagating up to
+ # the parent GIS Manager layer tree
def mapsetExpanded(self, event):
pass
def mapsetCollapsed(self, event):
pass
+ def mapsetActivated(self, event):
+ pass
+
+ def mapsetSelected(self, event):
+ pass
+ # end of dummy events
+
def GetControl(self):
return self.seltree
From barton at grass.itc.it Tue Apr 10 16:54:58 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Tue Apr 10 16:55:00 2007
Subject: [grass-addons] r466 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704101454.l3AEswXR020750@grass.itc.it>
Author: barton
Date: 2007-04-10 16:54:47 +0200 (Tue, 10 Apr 2007)
New Revision: 466
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/toolbars.py
Log:
Button and dialog added for printing. Printing not enabled yet.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-10 14:42:14 UTC (rev 465)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-10 14:54:47 UTC (rev 466)
@@ -1043,6 +1043,29 @@
self.MapWindow.SaveToFile(dlg.GetPath(), wx.BITMAP_TYPE_PNG)
dlg.Destroy()
+ def PrintMap(self, event):
+ """
+ Print map display
+ """
+
+ pdata = wx.PrintDialogData()
+
+ pdata.EnableSelection(True)
+ pdata.EnablePrintToFile(True)
+ pdata.EnablePageNumbers(True)
+ pdata.SetMinPage(1)
+ pdata.SetMaxPage(5)
+ pdata.SetAllPages(True)
+
+ dlg = wx.PrintDialog(self, pdata)
+
+ if dlg.ShowModal() == wx.ID_OK:
+# data = dlg.GetPrintDialogData()
+ print 'printing not yet enabled'
+# self.log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
+
+ dlg.Destroy()
+
def OnCloseWindow(self, event):
"""
Window closed
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-10 14:42:14 UTC (rev 465)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-10 14:54:47 UTC (rev 466)
@@ -91,6 +91,14 @@
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
shortHelp="Save display to PNG file", longHelp="")
+ self.printmap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="printmap",
+ #bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"file-save.gif"),
+ #wx.BITMAP_TYPE_ANY),
+ # just testing wx.ArtProvider
+ bitmap=wx.ArtProvider.GetBitmap(id=wx.ART_PRINT, client=wx.ART_BUTTON),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Print display", longHelp="")
+
self.toolbar.AddSeparator()
#
@@ -111,6 +119,7 @@
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnQuery, self.query)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnErase, self.erase)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.SaveToFile, self.savefile)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.PrintMap, self.printmap)
self.mapdisplay.Bind(wx.EVT_COMBOBOX, self.OnSelect, self.combo)
def OnSelect(self,event):
From barton at grass.itc.it Wed Apr 11 08:29:51 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Wed Apr 11 08:29:56 2007
Subject: [grass-addons] r467 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704110629.l3B6TpAU031661@grass.itc.it>
Author: barton
Date: 2007-04-11 08:29:37 +0200 (Wed, 11 Apr 2007)
New Revision: 467
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
Added checkbox for potentially transparent colors, indicated by keyword
"none". But am not sure how to parse it in the color section. Commented
out at line 660.
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-10 14:54:47 UTC (rev 466)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-11 06:29:37 UTC (rev 467)
@@ -618,7 +618,7 @@
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
# element selection tree combobox (maps, icons, regions, etc.)
if p['prompt'] != 'color':
- self.selection = select.Select(which_panel, id=wx.ID_ANY, size=(250,-1),
+ self.selection = select.Select(which_panel, id=wx.ID_ANY, size=(300,-1),
type=p['element'])
if p['value'] != '': self.selection.SetValue(p['value']) # parameter previously set
which_sizer.Add(self.selection, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
@@ -657,6 +657,16 @@
which_sizer.Add(btn_colour, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
self.paramdict[btn_colour] = ID_PARAM_START + p_count
self.Bind(csel.EVT_COLOURSELECT, self.OnColorButton, btn_colour)
+# if "none" in title:
+# none_check = wx.CheckBox(which_panel, wx.ID_ANY, "Transparent")
+# if p['value'] != '' and p['value'][0] == "none":
+# none_check.SetValue(True)
+# else:
+# none_check.SetValue(False)
+# none_check.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
+# which_sizer.Add(none_check, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
+# self.paramdict[none_check] = ID_PARAM_START + p_count
+# self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, none_check)
if txt is not None:
txt.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
From cepicky at grass.itc.it Wed Apr 11 12:05:40 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Wed Apr 11 12:05:47 2007
Subject: [grass-addons] r468 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704111005.l3BA5eHi002938@grass.itc.it>
Author: cepicky
Date: 2007-04-11 12:05:39 +0200 (Wed, 11 Apr 2007)
New Revision: 468
Modified:
trunk/grassaddons/gui/gui_modules/sqlbuilder.py
Log:
sql query working better
Modified: trunk/grassaddons/gui/gui_modules/sqlbuilder.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/sqlbuilder.py 2007-04-11 06:29:37 UTC (rev 467)
+++ trunk/grassaddons/gui/gui_modules/sqlbuilder.py 2007-04-11 10:05:39 UTC (rev 468)
@@ -26,6 +26,7 @@
# variables
#
self.vectmap = vectmap
+ print self.vectmap
if not "@" in self.vectmap:
self.vectmap = self.vectmap+"@"+grassenv.env["MAPSET"]
self.mapname, self.mapset = self.vectmap.split("@")
From cepicky at grass.itc.it Wed Apr 11 18:07:56 2007
From: cepicky at grass.itc.it (cepicky@grass.itc.it)
Date: Wed Apr 11 18:07:57 2007
Subject: [grass-addons] r469 - in trunk/grassaddons/gui: . images
Message-ID: <200704111607.l3BG7uvh006810@grass.itc.it>
Author: cepicky
Date: 2007-04-11 18:07:55 +0200 (Wed, 11 Apr 2007)
New Revision: 469
Added:
trunk/grassaddons/gui/images/wizard.png
Modified:
trunk/grassaddons/gui/location_wizard.py
trunk/grassaddons/gui/wxgui.py
Log:
reorderd wizard
Added: trunk/grassaddons/gui/images/wizard.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/images/wizard.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/grassaddons/gui/location_wizard.py
===================================================================
--- trunk/grassaddons/gui/location_wizard.py 2007-04-11 10:05:39 UTC (rev 468)
+++ trunk/grassaddons/gui/location_wizard.py 2007-04-11 16:07:55 UTC (rev 469)
@@ -177,10 +177,11 @@
self.datumlist.SetColumnWidth(3, wx.LIST_AUTOSIZE)
def onPageChange(self,event):
- global datum
- datum = self.tdatum.GetValue()
- global transform
- transform = self.ttrans.GetValue()
+ self.GetNext().SetPrev(self)
+ global datum
+ datum = self.tdatum.GetValue()
+ global transform
+ transform = self.ttrans.GetValue()
def OnDoSearch(self,event):
str = self.searchb.GetValue()
@@ -343,20 +344,33 @@
global west
global resolution
+ if not coordsys:
+ coordsys = 0
+ if not north:
+ north = 0
+ if not south:
+ south = 0
+ if not east:
+ east = 0
+ if not west:
+ west = 0
+ if not resolution:
+ resolution = 1
+
#if projection != "latlong":
rows = int(round((float(north)-float(south))/float(resolution)))
cols = int(round((float(east)-float(west))/float(resolution)))
cells = int(rows*cols)
- self.ldatabase.SetLabel(database)
- self.llocation.SetLabel(location)
- self.lprojection.SetLabel(coordsys)
- self.lnorth.SetLabel(north)
- self.lsouth.SetLabel(south)
- self.least.SetLabel(east)
- self.lwest.SetLabel(west)
- self.lres.SetLabel(resolution)
+ self.ldatabase.SetLabel(str(database))
+ self.llocation.SetLabel(str(location))
+ self.lprojection.SetLabel(str(coordsys))
+ self.lnorth.SetLabel(str(north))
+ self.lsouth.SetLabel(str(south))
+ self.least.SetLabel(str(east))
+ self.lwest.SetLabel(str(west))
+ self.lres.SetLabel(str(resolution))
self.lrows.SetLabel(str(rows))
self.lcols.SetLabel(str(cols))
self.lcells.SetLabel(str(cells))
@@ -684,6 +698,7 @@
def onPageChange(self, event):
self.GetNext().FillVars()
+ self.GetNext().SetPrev(self)
global north
north = self.ttop.GetValue()
@@ -888,7 +903,8 @@
class EPSGPage(TitledPage):
def __init__(self, wizard, parent):
TitledPage.__init__(self, wizard, "Choose EPSG Code")
- wx.MessageBox("in epsgpage")
+ #wx.MessageBox("in epsgpage")
+ self.parent = parent
# labels
self.lfile= wx.StaticText(self, -1, "Path to the EPSG-codes file: ",
@@ -963,8 +979,9 @@
def onPageChange(self, event):
global epsgcode
- epsgcode = self.tcode
- wx.MessageBox("setting epsgcode to %" % (epsgcode))
+ epsgcode = self.tcode.GetValue()
+ self.parent.datumpage.SetPrev(self)
+ #wx.MessageBox("setting epsgcode to %s" % (epsgcode))
def OnDoSearch(self,event):
str = self.searchb.GetValue()
@@ -1038,7 +1055,7 @@
dlg.Destroy()
def OnChange(self,event):
- self.item = event.GetItem()
+ self.item = event.GetItem()
def OnDoubleClick(self, event):
print self.epsgs.GetValue()
@@ -1090,13 +1107,13 @@
self.parent.bboxpage.SetPrev(self.parent.datumpage)
elif event.GetId() == self.radio3.GetId():
coordsys = "utm"
- self.SetNext(self.parent.datumpage)
- self.parent.datumpage.SetPrev(self.parent.csystemspage)
- self.parent.bboxpage.SetPrev(self.parent.datumpage)
+ self.SetNext(self.parent.utmpage)
+ self.parent.datumpage.SetPrev(self.parent.utmpage)
elif event.GetId() == self.radio4.GetId():
coordsys = "custom"
self.SetNext(self.parent.projpage)
- self.parent.bboxpage.SetPrev(self.parent.projpage)
+ self.parent.datumpage.SetPrev(self.parent.projpage)
+ self.parent.bboxpage.SetPrev(self.parent.datumpage)
elif event.GetId() == self.radio5.GetId():
coordsys = "epsg"
self.SetNext(self.parent.epsgpage)
@@ -1112,7 +1129,24 @@
self.parent.bboxpage.cstate.Enable(False)
else:
self.parent.bboxpage.cstate.Enable(True)
+
+class UTMPage(TitledPage):
+ def __init__(self, wizard, parent):
+ TitledPage.__init__(self, wizard, "Choose zone for UTM coordinate system")
+ self.parent = parent
+ self.text_utm = self.MakeTextCtrl(size=(300,-1))
+ self.label_utm= self.MakeLabel("Set your UTM zone: ")
+
+ self.sizer.Add(self.label_utm, 0, wx.ALIGN_LEFT, 5, row=1,col=1)
+ self.sizer.Add(self.text_utm, 0, wx.ALIGN_LEFT, 5, row=1,col=2)
+
+
+ def GetUtm(self):
+ return int(self.text_utm.GetValue())
+
+
+
class DatabasePage(TitledPage):
def __init__(self, wizard, parent, grassdatabase):
TitledPage.__init__(self, wizard, "Define GRASS database and new Location Name")
@@ -1189,8 +1223,8 @@
class GWizard:
def __init__(self, parent, grassdatabase):
- wizbmp = wx.Image(os.path.join(os.getenv("GISBASE"),"etc","wx","images","grasslogo_small.gif"), wx.BITMAP_TYPE_GIF)
- wizbmp.Rescale(50,60)
+ wizbmp = wx.Image(os.path.join(os.getenv("GISBASE"),"etc","wx","images","wizard.png"), wx.BITMAP_TYPE_PNG)
+ wizbmp.Rescale(250,600)
wizbmp = wizbmp.ConvertToBitmap()
wizard = wiz.Wizard(parent, -1, "Define new Location",
bitmap=wizbmp)
@@ -1202,15 +1236,17 @@
self.projpage = ProjectionsPage(wizard, self)
self.sumpage = SummaryPage(wizard, self)
self.datumpage = DatumPage(wizard, self)
+ self.utmpage = UTMPage(wizard,self)
# Set the initial order of the pages
+ # it should follow the epsg line
self.startpage.SetNext(self.csystemspage)
self.csystemspage.SetPrev(self.startpage)
self.csystemspage.SetNext(self.bboxpage)
self.epsgpage.SetPrev(self.csystemspage)
- self.epsgpage.SetNext(self.sumpage)
+ self.epsgpage.SetNext(self.datumpage)
self.projpage.SetPrev(self.csystemspage)
self.projpage.SetNext(self.datumpage)
@@ -1225,6 +1261,9 @@
self.sumpage.SetPrev(self.bboxpage)
+ self.utmpage.SetPrev(self.csystemspage)
+ self.utmpage.SetNext(self.datumpage)
+
wizard.FitToPage(self.bboxpage)
if wizard.RunWizard(self.startpage):
self.onWizFinished()
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-11 10:05:39 UTC (rev 468)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-11 16:07:55 UTC (rev 469)
@@ -343,7 +343,7 @@
from gui_modules import dbm
self.dbmanager = gui_modules.dbm.AttributeManager(self,
- -1,"GRASS Attribute Table Manager: %s" % map,
+ -1,"GRASS Attribute Table Manager: %s" % mapname,
size=wx.Size(500,300),vectmap=mapname,
pointdata=pointdata)
From barton at grass.itc.it Thu Apr 12 00:18:45 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Apr 12 00:18:46 2007
Subject: [grass-addons] r470 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704112218.l3BMIj2c010415@grass.itc.it>
Author: barton
Date: 2007-04-12 00:18:34 +0200 (Thu, 12 Apr 2007)
New Revision: 470
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/toolbars.py
Log:
Added zoom back button and methods.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-11 16:07:55 UTC (rev 469)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-11 22:18:34 UTC (rev 470)
@@ -196,6 +196,13 @@
self.currtxtid = None # PseudoDC id for currently selected text
#
+ # Zoom objects
+ #
+ self.zoomhistory = [] # list of past zoom extents
+ self.currzoom = 0 # current set of extents in zoom history being used
+
+
+ #
# mouse attributes like currently pressed buttons, position on
# the screen, begin and end of dragging, and type of drawing
#
@@ -253,11 +260,14 @@
self.Refresh()
if pdctype == 'clear': # erase the display
+ bg = wx.Brush(self.GetBackgroundColour())
+ pdc.SetBackground(bg)
+ pdc.Clear()
+ self.Refresh()
pdc.EndDrawing()
return
if pdctype == 'image':
- mask = None
bitmap = wx.BitmapFromImage(img)
# if drawid in self.ovldict:
# w,h = self.ovldict[drawid][1]
@@ -400,8 +410,8 @@
if os.path.isfile(ovlfile) and os.path.getsize(ovlfile):
img = wx.Image(ovlfile, wx.BITMAP_TYPE_ANY)
- left = right = top = bottom = 0
- breakout = False
+# left = right = top = bottom = 0
+# breakout = False
# # auto-crop scales and legends
# for w in range(img.GetWidth()): # set left edge
# for h in range(img.GetHeight()-1):
@@ -511,9 +521,9 @@
self.resize = False
# update statusbar
- self.parent.statusbar.SetStatusText("Extent: %d,%d : %d,%d" %
- (self.Map.region["w"], self.Map.region["e"],
- self.Map.region["n"], self.Map.region["s"]), 0)
+ self.parent.statusbar.SetStatusText("Extents: %d(W)-%d(E), %d(N)-%d(S)" %
+ (self.Map.region["w"], self.Map.region["e"],
+ self.Map.region["n"], self.Map.region["s"]), 0)
def EraseMap(self):
"""
@@ -764,6 +774,30 @@
self.Map.region['e'] = newreg['e']
self.Map.region['w'] = newreg['w']
+ self.ZoomHistory(newreg['n'],newreg['s'],newreg['e'],newreg['w'])
+
+ def ZoomBack(self):
+
+ if len(self.zoomhistory) > 0:
+ self.zoomhistory.pop()
+ zoom = self.zoomhistory[len(self.zoomhistory)-1]
+
+ if zoom:
+ self.Map.region['n'] = zoom[0]
+ self.Map.region['s'] = zoom[1]
+ self.Map.region['e'] = zoom[2]
+ self.Map.region['w'] = zoom[3]
+ self.render=True
+ self.UpdateMap()
+
+ def ZoomHistory(self, n,s,e,w):
+ """
+ Manages a list of last 10 zoom extents
+ """
+ self.zoomhistory.append((n,s,e,w))
+ if len(self.zoomhistory) > 10:
+ self.zoomhistory.pop(0)
+
class MapFrame(wx.Frame):
"""
Main frame for map display window. Drawing takes place in child double buffered
@@ -826,7 +860,7 @@
#
self.statusbar = self.CreateStatusBar(number=2, style=0)
self.statusbar.SetStatusWidths([-2, -1])
- map_frame_statusbar_fields = ["Extent: %d,%d : %d,%d" %
+ map_frame_statusbar_fields = ["Extents: %d(W)-%d(E), %d(N)-%d(S)" %
(self.Map.region["w"], self.Map.region["e"],
self.Map.region["n"], self.Map.region["s"]),
"%s,%s" %(None, None)]
@@ -847,6 +881,11 @@
self.MapWindow = BufferedWindow(self, id = wx.ID_ANY) # initialize buffered DC
self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
+ #
+ # Init zoomhistory
+ #
+ self.MapWindow.ZoomHistory(self.Map.region['n'],self.Map.region['s'],self.Map.region['e'],self.Map.region['w'])
+
# decoration overlays
self.ovlchk = self.MapWindow.ovlchk
self.ovlcoords = self.MapWindow.ovlcoords
@@ -905,9 +944,6 @@
self.width, self.height = self.GetClientSize()
self.Map.geom = self.width, self.height
self.Map.GetRegion()
- #FIXME
- #This was Map.getResolution().
- #I'm guessing at the moment that this is replaced by Map.SetRegion()
self.Map.SetRegion()
def OnFocus(self, event):
@@ -991,8 +1027,7 @@
"""
Zoom last (previously stored position)
"""
- # FIXME
- pass
+ self.MapWindow.ZoomBack()
def OnPan(self, event):
"""
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-11 16:07:55 UTC (rev 469)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-11 22:18:34 UTC (rev 470)
@@ -69,6 +69,11 @@
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
shortHelp="Query", longHelp="Query selected map")
+ self.zoomback = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_back",
+ bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_back.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Zoom back", longHelp="Zoom to previous display region")
self.toolbar.AddSeparator()
@@ -115,6 +120,7 @@
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomIn, self.zoomin)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomOut, self.zoomout)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnPan, self.pan)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomBack, self.zoomback)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onDecoration, self.dec)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnQuery, self.query)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnErase, self.erase)
From barton at grass.itc.it Thu Apr 12 00:19:19 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Apr 12 00:19:20 2007
Subject: [grass-addons] r471 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704112219.l3BMJJPw010435@grass.itc.it>
Author: barton
Date: 2007-04-12 00:19:08 +0200 (Thu, 12 Apr 2007)
New Revision: 471
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
very minor code cleanup
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-11 22:18:34 UTC (rev 470)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-11 22:19:08 UTC (rev 471)
@@ -379,7 +379,7 @@
def __adjustRegion(self):
"""
Adjust region according to monitor size
- """
+ """
# adjusting region to monitor size
if self.width > self.height and \
@@ -682,7 +682,7 @@
layer = MapLayer(type="raster", name=name, mapset=mapset,
active=l_active, hidden=l_hidden, opacity=l_opacity,
dispcmd=dispcmd)
-
+
layer.id = len(self.layers)-1
# add maplayer to the list of layers
From barton at grass.itc.it Thu Apr 12 00:21:33 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Apr 12 00:21:34 2007
Subject: [grass-addons] r472 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704112221.l3BMLXNc010456@grass.itc.it>
Author: barton
Date: 2007-04-12 00:21:24 +0200 (Thu, 12 Apr 2007)
New Revision: 472
Modified:
trunk/grassaddons/gui/gui_modules/toolbars.py
Log:
moved zoomback button
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-11 22:19:08 UTC (rev 471)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-11 22:21:24 UTC (rev 472)
@@ -59,6 +59,11 @@
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
shortHelp="Zoom out", longHelp="Drag or click mouse to unzoom")
+ self.zoomback = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_back",
+ bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_back.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Zoom back", longHelp="Zoom to previous display region")
self.pan = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="pan",
bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-pan.gif"),
wx.BITMAP_TYPE_ANY),
@@ -69,11 +74,6 @@
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
shortHelp="Query", longHelp="Query selected map")
- self.zoomback = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_back",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_back.gif"),
- wx.BITMAP_TYPE_ANY),
- bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
- shortHelp="Zoom back", longHelp="Zoom to previous display region")
self.toolbar.AddSeparator()
From calvelo at grass.itc.it Thu Apr 12 00:24:32 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Thu Apr 12 00:24:33 2007
Subject: [grass-addons] r473 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704112224.l3BMOWQM010491@grass.itc.it>
Author: calvelo
Date: 2007-04-12 00:24:26 +0200 (Thu, 12 Apr 2007)
New Revision: 473
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- transparent color now works
- internal structures changed to manage the widget-parameter relation
- simplified event callbacks: each special callback sets the 'value' field and calls updateStatus now
- statusline report and copy button both work
- commenting and cosmetics
- some better error handling
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-11 22:21:24 UTC (rev 472)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-11 22:24:26 UTC (rev 473)
@@ -51,6 +51,9 @@
import os
from os import system
+import gettext
+#from gettext import _
+gettext.install("wxgrass")
sys.path.append(os.path.join(os.getenv("GISBASE"),"etc","wx"))
try:
@@ -107,13 +110,27 @@
(128, 0,128)
)
t_color = t_colors.split(',')
-color_str2rgb = {}
-color_rgb2str = {}
+str2rgb = {}
+rgb2str = {}
for c in range(0,len(t_rgb)):
- color_str2rgb[ t_color[c] ] = t_rgb[ c ]
- color_rgb2str[ t_rgb[ c ] ] = t_color[ c ]
+ str2rgb[ t_color[c] ] = t_rgb[ c ]
+ rgb2str[ t_rgb[ c ] ] = t_color[ c ]
+def color_resolve(color):
+ if color[0] in "0123456789":
+ rgb = tuple(map(int,color.split( ':' )))
+ label = color
+ else:
+ # Convert color names to RGB
+ try:
+ rgb = str2rgb[ color ]
+ label = color
+ except KeyError:
+ rgb = (200,200,200)
+ label = 'Select Color'
+ return (rgb, label)
+
def normalize_whitespace(text):
"Remove redundant whitespace from a string"
return string.join( string.split(text), ' ')
@@ -152,6 +169,10 @@
self.description = ''
self.flags = []
+ def buildCmd(self): # TODO: It should be this class' responsibility to build the command, not the gui's.
+ pass
+
+
class processTask(HandlerBase):
"""A SAX handler for the --interface-description output, as
defined in grass-interface.dtd. Extend or modify this and the
@@ -308,8 +329,8 @@
self.SetPage( "".join( contents ) )
self.Ok = True
except:
- raise
self.Ok = False
+ raise
class mainFrame(wx.Frame):
@@ -413,11 +434,11 @@
self.OnCancel(event)
def OnApply(self, event):
- cmd,params = self.createCmd()
+ cmd = self.createCmd()
if cmd is not None and self.get_dcmd is not None:
# return d.* command to layer tree for rendering
- self.get_dcmd(cmd, self.layer,params)
+ self.get_dcmd(cmd, self.layer, {"params":self.task.params,"flags":self.task.flags} )
# echo d.* command to output console
# self.parent.writeDCommand(cmd)
return cmd
@@ -492,11 +513,10 @@
self.task = task
self.selection = '' #selection from GIS element selector
- self.paramdict = {} # dictionary of controls and their parameter values
+ # Determine tab layout
sections = ['Main']
is_section = {}
-
for task in self.task.params + self.task.flags:
if not task.has_key('guisection') or task['guisection']=='':
task['guisection'] = 'Options'
@@ -513,20 +533,18 @@
sections = sections[1:]
self.panelsizer = wx.BoxSizer(wx.VERTICAL)
-
+ # Build notebook
nbStyle=FN.FNB_NO_X_BUTTON|FN.FNB_NO_NAV_BUTTONS|FN.FNB_VC8|FN.FNB_BACKGROUND_GRADIENT
self.notebook = FN.FlatNotebook( self, id=wx.ID_ANY, style=nbStyle)
self.notebook.SetTabAreaColour(wx.Colour(125,200,175))
self.notebook.Bind( FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChange )
self.tab = {}
self.tabsizer = {}
- is_first = True
for section in sections:
self.tab[section] = wx.ScrolledWindow(self.notebook, id = wx.ID_ANY )
self.tab[section].SetScrollRate(10,10)
self.tabsizer[section] = wx.BoxSizer(wx.VERTICAL)
- self.notebook.AddPage( self.tab[section], text = section, select = is_first )
- is_first = False
+ self.notebook.AddPage( self.tab[section], text = section )
# are we running from command line?
if standalone:
@@ -542,9 +560,8 @@
self.notebook.SetSelection(0)
self.panelsizer.Add( self.notebook, 1, flag=wx.EXPAND )
- p_count = -1
+
for p in self.task.params:
- p_count += 1 # Needed for checkboxes hack
which_sizer = self.tabsizer[ p['guisection'] ]
which_panel = self.tab[ p['guisection'] ]
title = text_beautify(p['description'])
@@ -562,18 +579,18 @@
if p['multiple'] == 'yes':
txt = wx.StaticBox(which_panel,0,title+":")
hSizer=wx.StaticBoxSizer( txt, wx.VERTICAL )
- v_count = 0
isDefault = {}
for defval in p['value'].split(','):
isDefault[ defval ] = 'yes'
+ # for multi checkboxes, this is an array of all wx IDs
+ # for each individual checkbox
+ p[ 'wxId' ]=[]
for val in valuelist:
- # This is the checkboxes hack
- idForWX = ID_MULTI_START + p_count*20 + v_count
- chkbox = wx.CheckBox( which_panel, idForWX, text_beautify(val) )
+ chkbox = wx.CheckBox( which_panel, label = text_beautify(val) )
+ p[ 'wxId' ].append( chkbox.GetId() )
if isDefault.has_key(val): chkbox.SetValue( True )
hSizer.Add( chkbox,0,wx.ADJUST_MINSIZE,5 )
- self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBoxMulti)
- v_count += 1
+ self.Bind(wx.EVT_CHECKBOX, self.OnCheckBoxMulti)
which_sizer.Add( hSizer, 0, wx.ADJUST_MINSIZE, 5)
elif len(valuelist) == 1:
txt = wx.StaticText(which_panel, label = title +
@@ -584,8 +601,8 @@
if p['value'] != '': self.txt2.SetValue(p['value']) # parameter previously set
which_sizer.Add(self.txt2, 0, wx.ADJUST_MINSIZE, 5)
- self.paramdict[self.txt2] = ID_PARAM_START + p_count
- self.txt2.Bind(wx.EVT_TEXT, self.EvtText)
+ p['wxId'] = self.txt2.GetId()
+ self.txt2.Bind(wx.EVT_TEXT, self.OnSetValue)
else:
txt = wx.StaticText(which_panel, label = title + ':' )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
@@ -594,8 +611,8 @@
valuelist, wx.CB_DROPDOWN)
if p['value'] != '': self.cb.SetValue(p['value']) # parameter previously set
which_sizer.Add(self.cb, 0, wx.ADJUST_MINSIZE, 5)
- self.paramdict[self.cb] = ID_PARAM_START + p_count
- self.cb.Bind( wx.EVT_COMBOBOX, self.EvtComboBox)
+ p['wxId'] = self.cb.GetId()
+ self.cb.Bind( wx.EVT_COMBOBOX, self.OnSetValue)
# text entry
if (p['type'] in ('string','integer','float')
@@ -610,8 +627,8 @@
size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
if p['value'] != '': self.txt3.SetValue(p['value']) # parameter previously set
which_sizer.Add(self.txt3, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
- self.paramdict[self.txt3] = ID_PARAM_START + p_count
- self.txt3.Bind(wx.EVT_TEXT, self.EvtText)
+ p['wxId'] = self.txt3.GetId()
+ self.txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
if p['type'] == 'string' and p['gisprompt'] == True:
txt = wx.StaticText(which_panel, label = title + ':')
@@ -622,57 +639,41 @@
type=p['element'])
if p['value'] != '': self.selection.SetValue(p['value']) # parameter previously set
which_sizer.Add(self.selection, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
- self.paramdict[self.selection] = ID_PARAM_START + p_count
- self.selection.Bind(wx.EVT_TEXT, self.EvtText)
+ p['wxId'] = self.selection.GetId()
+ self.selection.Bind(wx.EVT_TEXT, self.OnSetValue)
# color entry
elif p['prompt'] == 'color':
if p['default'] != '':
- if p['default'][0] in "0123456789":
- default_color = tuple(map(int,p['default'].split( ':' )))
- label_color = p['default']
- else:
- # Convert color names to RGB
- try:
- default_color = color_str2rgb[ p['default'] ]
- label_color = p['default']
- except KeyError:
- default_color = (200,200,200)
- label_color = 'Select Color'
- else:
- default_color = (200,200,200)
- label_color = 'Select Color'
+ default_color, label_color = color_resolve( p['default'] )
if p['value'] != '': # parameter previously set
- if p['value'][0] in "0123456789":
- default_color = tuple(map(int,p['value'].split( ':' )))
- label_color = p['value']
+ default_color, label_color = color_resolve( p['value'] )
+ if "none" in title:
+ this_sizer = wx.BoxSizer( wx.HORIZONTAL )
+ else:
+ this_sizer = which_sizer
+ btn_colour = csel.ColourSelect(which_panel, wx.ID_ANY, label_color, default_color, wx.DefaultPosition, (150,-1) )
+ this_sizer.Add(btn_colour, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
+ # For color selectors, this is a two-member array, holding the IDs of
+ # the selector proper and either a "transparent" button or None
+ p['wxId'] = [btn_colour.GetId(),]
+ btn_colour.Bind(csel.EVT_COLOURSELECT, self.OnColorChange )
+ if "none" in title:
+ none_check = wx.CheckBox(which_panel, wx.ID_ANY, "Transparent")
+ if p['value'] != '' and p['value'][0] == "none":
+ none_check.SetValue(True)
else:
- # Convert color names to RGB
- try:
- default_color = color_str2rgb[ p['value'] ]
- label_color = p['value']
- except KeyError:
- default_color = (200,200,200)
- label_color = 'Select Color'
- btn_colour = csel.ColourSelect(which_panel, -1, label_color, default_color, wx.DefaultPosition, (150,-1) )
- which_sizer.Add(btn_colour, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
- self.paramdict[btn_colour] = ID_PARAM_START + p_count
- self.Bind(csel.EVT_COLOURSELECT, self.OnColorButton, btn_colour)
-# if "none" in title:
-# none_check = wx.CheckBox(which_panel, wx.ID_ANY, "Transparent")
-# if p['value'] != '' and p['value'][0] == "none":
-# none_check.SetValue(True)
-# else:
-# none_check.SetValue(False)
-# none_check.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
-# which_sizer.Add(none_check, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
-# self.paramdict[none_check] = ID_PARAM_START + p_count
-# self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, none_check)
+ none_check.SetValue(False)
+ none_check.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
+ this_sizer.Add(none_check, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
+ which_sizer.Add( this_sizer )
+ none_check.Bind(wx.EVT_CHECKBOX, self.OnColorChange)
+ p['wxId'].append( none_check.GetId() )
+ else:
+ p['wxId'].append(None)
if txt is not None:
txt.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
- f_count = -1
for f in self.task.flags:
- f_count += 1
which_sizer = self.tabsizer[ f['guisection'] ]
which_panel = self.tab[ f['guisection'] ]
title = text_beautify(f['description'])
@@ -680,8 +681,8 @@
if 'value' in f: self.chk.SetValue(f['value'])
self.chk.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
which_sizer.Add(self.chk, 0, wx.EXPAND| wx.ALL, 5)
- self.paramdict[self.chk] = ID_FLAG_START + f_count
- self.chk.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox)
+ f['wxId'] = self.chk.GetId()
+ self.chk.Bind(wx.EVT_CHECKBOX, self.OnSetValue)
maxsizes = (0,0)
for section in sections:
@@ -704,16 +705,24 @@
def OnPageChange(self, event):
self.Layout()
- def OnColorButton(self, event):
- colorchooser = wx.FindWindowById( event.GetId() )
- new_color = colorchooser.GetValue()[:]
- # This is weird: new_color is a 4-tuple and new_color[:] is a 3-tuple
- # under wx2.8.1
- new_label = color_rgb2str.get( new_color, ':'.join(map(str,new_color)) )
- colorchooser.SetLabel( new_label )
- colorchooser.SetColour( new_color )
- colorchooser.Refresh()
- self.getValues()
+ def OnColorChange( self, event ):
+ myId = event.GetId()
+ for p in self.task.params:
+ if type( p['wxId'] ) == type( [] ) and myId in p['wxId']:
+ has_button = p['wxId'][1] is not None
+ if has_button and wx.FindWindowById( p['wxId'][1] ).GetValue() == True:
+ p[ 'value' ] = 'none'
+ else:
+ colorchooser = wx.FindWindowById( p['wxId'][0] )
+ new_color = colorchooser.GetValue()[:]
+ # This is weird: new_color is a 4-tuple and new_color[:] is a 3-tuple
+ # under wx2.8.1
+ new_label = rgb2str.get( new_color, ':'.join(map(str,new_color)) )
+ colorchooser.SetLabel( new_label )
+ colorchooser.SetColour( new_color )
+ colorchooser.Refresh()
+ p[ 'value' ] = colorchooser.GetLabel()
+ self.updateStatusLine()
def updateStatusLine(self):
"""If we were part of a richer interface, report back the current command being built."""
@@ -723,56 +732,39 @@
except:
pass
- def getValues(self):
- for (gui_object,param_num) in self.paramdict.items():
- if 'CheckBox' in str( gui_object ):
- tasktype = self.task.flags
- num = param_num-ID_FLAG_START
- param_val = gui_object.GetValue()
- else:
- tasktype = self.task.params
- num = param_num-ID_PARAM_START
- if 'ColourSelect' in str( gui_object ):
- if 'Select' in gui_object.GetLabel():
- param_val = ''
- else:
- data = gui_object.GetValue()[:]
- param_val = color_rgb2str.get( data , ':'.join( map(str, data) ) )
- else:
- param_val = gui_object.GetValue()
- tasktype[num]['value'] = param_val
- self.updateStatusLine()
-
- def EvtText(self, event):
- self.getValues()
-
- def EvtCheckBox(self, event):
- self.getValues()
-
- def EvtComboBox(self, event):
- self.getValues()
-
- def EvtCheckBoxMulti(self, event):
+ def OnCheckBoxMulti(self, event):
"""Fill the values ,-separated string according to current status of the checkboxes."""
- theParamId = (event.GetId()-ID_MULTI_START ) / 20
- theCheckedId = (event.GetId()-ID_MULTI_START ) % 20
+ me = event.GetId()
+ theParam = None
+ for p in self.task.params:
+ if type( p['wxId'] ) == type( [] ) and me in p['wxId']:
+ theParam = p
+ myIndex = p['wxId'].index( me )
# Unpack current value list
currentValues={}
- for isThere in self.task.params[theParamId]['value'].split(','):
+ for isThere in theParam['value'].split(','):
currentValues[isThere] = 1
- theValue = self.task.params[theParamId]['values'][theCheckedId]
+ theValue = theParam['values'][myIndex]
if event.Checked():
currentValues[ theValue ] = 1
else:
del currentValues[ theValue ]
currentValueList=[] # Keep the original order, so that some defaults may be recovered
- for v in self.task.params[theParamId]['values']:
+ for v in theParam['values']:
if currentValues.has_key(v):
currentValueList.append( v )
# Pack it back
- self.task.params[theParamId]['value'] = ','.join( currentValueList )
+ theParam['value'] = ','.join( currentValueList )
self.updateStatusLine()
+ def OnSetValue(self, event):
+ myId = event.GetId()
+ me = wx.FindWindowById( myId )
+ for porf in self.task.params + self.task.flags:
+ if type( porf[ 'wxId' ] ) == type( 1 ) and porf['wxId'] == myId:
+ porf[ 'value' ] = me.GetValue()
+ self.updateStatusLine()
+
def createCmd(self, ignoreErrors = False):
"""Produce a command line string for feeding into GRASS.
@@ -798,13 +790,8 @@
self.OnError(errStr)
return None
- # create paramater dictionary to return to layer tree
- dcmd_params['flags'] = self.task.flags
- dcmd_params['params'] = self.task.params
+ return cmd
-
- return cmd,dcmd_params
-
def getInterfaceDescription( cmd ):
"""Returns the XML description for the GRASS cmd.
@@ -855,7 +842,7 @@
self.parent = parentframe
if len(cmdlst) > 1:
- print "usage: %s " % cmdlst[0]
+ raise ValueError, "usage: %s " % cmdlst[0]
else:
# parse the interface decription
self.grass_task = grassTask()
From calvelo at grass.itc.it Thu Apr 12 01:44:11 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Thu Apr 12 01:44:13 2007
Subject: [grass-addons] r474 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704112344.l3BNiBl6011021@grass.itc.it>
Author: calvelo
Date: 2007-04-12 01:44:03 +0200 (Thu, 12 Apr 2007)
New Revision: 474
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- silly bugs solved
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-11 22:24:26 UTC (rev 473)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-11 23:44:03 UTC (rev 474)
@@ -444,7 +444,7 @@
return cmd
def OnRun(self, event):
- cmd = self.createCmd()[0]
+ cmd = self.createCmd()
if cmd != None and cmd[0:2] != "d.":
# Send any non-display command to parent window (probably wxgui.py)
@@ -475,11 +475,6 @@
self.SetStatusText("'%s' copied to clipboard" %\
(self.createCmd(ignoreErrors=True)))
- def OnError(self, errMsg):
- dlg = wx.MessageDialog(self, errMsg, "Error", wx.OK | wx.ICON_ERROR)
- dlg.ShowModal()
- dlg.Destroy()
-
def OnCancel(self, event):
self.Destroy()
@@ -792,6 +787,12 @@
return cmd
+ def OnError(self, errMsg):
+ dlg = wx.MessageDialog(self, errMsg, "Error", wx.OK | wx.ICON_ERROR)
+ dlg.ShowModal()
+ dlg.Destroy()
+
+
def getInterfaceDescription( cmd ):
"""Returns the XML description for the GRASS cmd.
From calvelo at grass.itc.it Thu Apr 12 03:28:30 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Thu Apr 12 03:28:31 2007
Subject: [grass-addons] r475 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704120128.l3C1SU3W012049@grass.itc.it>
Author: calvelo
Date: 2007-04-12 03:28:24 +0200 (Thu, 12 Apr 2007)
New Revision: 475
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- clean up: do not bind to self what doesn't need to
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-11 23:44:03 UTC (rev 474)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-12 01:28:24 UTC (rev 475)
@@ -52,7 +52,6 @@
import os
from os import system
import gettext
-#from gettext import _
gettext.install("wxgrass")
sys.path.append(os.path.join(os.getenv("GISBASE"),"etc","wx"))
@@ -139,7 +138,7 @@
"Make really long texts shorter"
# TODO: remove magic number (calculate a correct value from
# pixelSize of text and the magic number for maximum size
- return escape_ampersand( os.linesep.join( textwrap.wrap( normalize_whitespace(someString), 72 ) ) )
+ return escape_ampersand( os.linesep.join( textwrap.wrap( normalize_whitespace(someString), 70 ) ) )
def escape_ampersand(text):
"Escapes ampersands with additional ampersand for GUI"
@@ -305,8 +304,8 @@
GISBASE must be set in the environment to find the html docs dir.
The SYNOPSIS section is skipped, since this Panel is supposed to
be integrated into the cmdPanel."""
- def __init__(self, parent, id, grass_command = "index"):
- wx.html.HtmlWindow.__init__(self, parent, id)
+ def __init__(self, grass_command = "index", *args, **kwargs):
+ wx.html.HtmlWindow.__init__(self, *args, **kwargs)
self.fspath = os.getenv( "GISBASE" ) + "/docs/html/"
self.SetStandardFonts( size = 11 )
self.fillContentsFromFile( self.fspath + grass_command + ".html" )
@@ -370,7 +369,7 @@
menuBar.Append(menu, "&File");
self.SetMenuBar(menuBar)
- self.guisizer = wx.BoxSizer(wx.VERTICAL)
+ guisizer = wx.BoxSizer(wx.VERTICAL)
# set apropriate output window
# if self.parent:
@@ -378,53 +377,52 @@
# self.goutput = self.parent.goutput
# else:
standalone=True
- self.notebookpanel = cmdPanel( self, self.task, standalone)
+ self.notebookpanel = cmdPanel( parent=self, task=self.task, standalone=standalone )
if standalone:
self.goutput = self.notebookpanel.goutput
- self.guisizer.Add( self.notebookpanel, 1, flag = wx.EXPAND )
+ guisizer.Add( self.notebookpanel, 1, flag = wx.EXPAND )
- status_text = "Enter parameters for " + self.task.name
- if self.notebookpanel.tab.has_key('Main'):
+ status_text = _("Enter parameters for ") + self.task.name
+ if self.notebookpanel.hasMain:
# We have to wait for the notebookpanel to be filled in order
# to know if there actually is a Main tab
- status_text += " (those of Main in bold typeface are required)"
+ status_text += _(" (those of Main in bold typeface are required)")
self.SetStatusText( status_text )
btnsizer = wx.BoxSizer(wx.HORIZONTAL)
- self.btn_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
- btnsizer.Add(self.btn_cancel, 0, wx.ALL| wx.ALIGN_CENTER, 10)
+ btn_cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel") )
+ btnsizer.Add( btn_cancel, 0, wx.ALL| wx.ALIGN_CENTER, 10)
if self.get_dcmd is not None: # A callback has been set up
- self.btn_apply = wx.Button(self, wx.ID_APPLY, "Apply")
- btnsizer.Add(self.btn_apply, 0, wx.ALL| wx.ALIGN_CENTER, 10)
- self.btn_ok = wx.Button(self, wx.ID_OK, "OK")
- btnsizer.Add(self.btn_ok, 0, wx.ALL| wx.ALIGN_CENTER, 10)
- self.btn_ok.SetDefault()
- self.btn_apply.Bind(wx.EVT_BUTTON, self.OnApply)
- self.btn_ok.Bind(wx.EVT_BUTTON, self.OnOK)
+ btn_apply = wx.Button(self, wx.ID_APPLY, _("Apply") )
+ btnsizer.Add( btn_apply, 0, wx.ALL| wx.ALIGN_CENTER, 10)
+ btn_ok = wx.Button(self, wx.ID_OK, _("OK") )
+ btnsizer.Add( btn_ok, 0, wx.ALL| wx.ALIGN_CENTER, 10)
+ btn_ok.SetDefault()
+ btn_apply.Bind(wx.EVT_BUTTON, self.OnApply)
+ btn_ok.Bind(wx.EVT_BUTTON, self.OnOK)
else: # We're standalone
- self.btn_run = wx.Button(self, wx.ID_OK, "Run")
- btnsizer.Add(self.btn_run, 0, wx.ALL| wx.ALIGN_CENTER, 10)
- self.btn_run.SetDefault()
- self.btn_run.Bind(wx.EVT_BUTTON, self.OnRun)
- self.btn_clipboard = wx.Button(self, wx.ID_OK, "Copy")
- btnsizer.Add(self.btn_clipboard, 0, wx.ALL| wx.ALIGN_CENTER, 10)
- self.btn_clipboard.Bind(wx.EVT_BUTTON, self.OnCopy)
- self.guisizer.Add(btnsizer, 0, wx.ALIGN_BOTTOM)
+ btn_run = wx.Button(self, wx.ID_OK, _("Run") )
+ btnsizer.Add( btn_run, 0, wx.ALL| wx.ALIGN_CENTER, 10)
+ btn_run.SetDefault()
+ btn_run.Bind(wx.EVT_BUTTON, self.OnRun)
+ btn_clipboard = wx.Button(self, wx.ID_OK, _("Copy") )
+ btnsizer.Add(btn_clipboard, 0, wx.ALL| wx.ALIGN_CENTER, 10)
+ btn_clipboard.Bind(wx.EVT_BUTTON, self.OnCopy)
+ guisizer.Add(btnsizer, 0, wx.ALIGN_BOTTOM)
wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout)
wx.EVT_MENU(self, ID_ABOUT_COMMAND, self.OnAboutCommand)
wx.EVT_MENU(self, wx.ID_EXIT, self.OnCancel)
- self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
+ btn_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
constrained_size = self.notebookpanel.GetSize()
self.notebookpanel.SetSize( (constrained_size[0],constrained_size[1]+80) ) # 80 takes the tabbar into account
- self.notebookpanel.SetSizer( self.notebookpanel.panelsizer )
self.notebookpanel.Layout()
- self.guisizer.SetSizeHints(self)
+ guisizer.SetSizeHints(self)
self.SetAutoLayout(True)
- self.SetSizer(self.guisizer)
+ self.SetSizer(guisizer)
self.Layout()
@@ -507,7 +505,6 @@
wx.Panel.__init__( self, parent, *args, **kwargs )
self.task = task
- self.selection = '' #selection from GIS element selector
# Determine tab layout
sections = ['Main']
@@ -527,45 +524,45 @@
if not there_is_main:
sections = sections[1:]
- self.panelsizer = wx.BoxSizer(wx.VERTICAL)
+ panelsizer = wx.BoxSizer(wx.VERTICAL)
# Build notebook
nbStyle=FN.FNB_NO_X_BUTTON|FN.FNB_NO_NAV_BUTTONS|FN.FNB_VC8|FN.FNB_BACKGROUND_GRADIENT
- self.notebook = FN.FlatNotebook( self, id=wx.ID_ANY, style=nbStyle)
- self.notebook.SetTabAreaColour(wx.Colour(125,200,175))
- self.notebook.Bind( FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChange )
- self.tab = {}
- self.tabsizer = {}
+ notebook = FN.FlatNotebook( self, id=wx.ID_ANY, style=nbStyle)
+ notebook.SetTabAreaColour(wx.Colour(125,200,175))
+ notebook.Bind( FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChange )
+ tab = {}
+ tabsizer = {}
for section in sections:
- self.tab[section] = wx.ScrolledWindow(self.notebook, id = wx.ID_ANY )
- self.tab[section].SetScrollRate(10,10)
- self.tabsizer[section] = wx.BoxSizer(wx.VERTICAL)
- self.notebook.AddPage( self.tab[section], text = section )
+ tab[section] = wx.ScrolledWindow( notebook )
+ tab[section].SetScrollRate(10,10)
+ tabsizer[section] = wx.BoxSizer(wx.VERTICAL)
+ notebook.AddPage( tab[section], text = section )
# are we running from command line?
if standalone:
from gui_modules import wxgui_utils
self.goutput = wxgui_utils.GMConsole(self)
- self.outpage = self.notebook.AddPage(self.goutput, text="Command output")
+ self.outpage = notebook.AddPage(self.goutput, text=_("Command output") )
- manual_tab = helpPanel( self.notebook, id = wx.ID_ANY, grass_command = self.task.name)
+ manual_tab = helpPanel( parent = notebook, grass_command = self.task.name)
if manual_tab.Ok:
manual_tabsizer = wx.BoxSizer(wx.VERTICAL)
- self.notebook.AddPage( manual_tab, text = "Manual" , select = False )
+ notebook.AddPage( manual_tab, text = _("Manual") )
- self.notebook.SetSelection(0)
- self.panelsizer.Add( self.notebook, 1, flag=wx.EXPAND )
+ notebook.SetSelection(0)
+ panelsizer.Add( notebook, 1, flag=wx.EXPAND )
for p in self.task.params:
- which_sizer = self.tabsizer[ p['guisection'] ]
- which_panel = self.tab[ p['guisection'] ]
+ which_sizer = tabsizer[ p['guisection'] ]
+ which_panel = tab[ p['guisection'] ]
title = text_beautify(p['description'])
text_style = wx.FONTWEIGHT_BOLD
txt = None
if p['required'] == 'no':
text_style = wx.FONTWEIGHT_NORMAL
if p['multiple'] == 'yes' and len( p['values'] ) == 0:
- title = "[multiple] " + title
+ title = _("[multiple]") + " " + title
if p[ 'value'] == '' :
p['value'] = p['default']
if (len(p['values']) > 0):
@@ -585,29 +582,29 @@
p[ 'wxId' ].append( chkbox.GetId() )
if isDefault.has_key(val): chkbox.SetValue( True )
hSizer.Add( chkbox,0,wx.ADJUST_MINSIZE,5 )
- self.Bind(wx.EVT_CHECKBOX, self.OnCheckBoxMulti)
+ chkbox.Bind(wx.EVT_CHECKBOX, self.OnCheckBoxMulti)
which_sizer.Add( hSizer, 0, wx.ADJUST_MINSIZE, 5)
elif len(valuelist) == 1:
txt = wx.StaticText(which_panel, label = title +
'. Valid range=' + str(valuelist).strip("[]'") + ':' )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
- self.txt2 = wx.TextCtrl(which_panel, value = p['default'],
+ txt2 = wx.TextCtrl(which_panel, value = p['default'],
size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
- if p['value'] != '': self.txt2.SetValue(p['value']) # parameter previously set
+ if p['value'] != '': txt2.SetValue(p['value']) # parameter previously set
- which_sizer.Add(self.txt2, 0, wx.ADJUST_MINSIZE, 5)
- p['wxId'] = self.txt2.GetId()
- self.txt2.Bind(wx.EVT_TEXT, self.OnSetValue)
+ which_sizer.Add( txt2, 0, wx.ADJUST_MINSIZE, 5)
+ p['wxId'] = txt2.GetId()
+ txt2.Bind(wx.EVT_TEXT, self.OnSetValue)
else:
txt = wx.StaticText(which_panel, label = title + ':' )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
- self.cb = wx.ComboBox(which_panel, -1, p['default'],
+ cb = wx.ComboBox(which_panel, -1, p['default'],
wx.Point(-1, -1), wx.Size(STRING_ENTRY_WIDTH, -1),
valuelist, wx.CB_DROPDOWN)
- if p['value'] != '': self.cb.SetValue(p['value']) # parameter previously set
- which_sizer.Add(self.cb, 0, wx.ADJUST_MINSIZE, 5)
- p['wxId'] = self.cb.GetId()
- self.cb.Bind( wx.EVT_COMBOBOX, self.OnSetValue)
+ if p['value'] != '': cb.SetValue(p['value']) # parameter previously set
+ which_sizer.Add( cb, 0, wx.ADJUST_MINSIZE, 5)
+ p['wxId'] = cb.GetId()
+ cb.Bind( wx.EVT_COMBOBOX, self.OnSetValue)
# text entry
if (p['type'] in ('string','integer','float')
@@ -618,24 +615,24 @@
txt = wx.StaticText(which_panel, label = title + ':' )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
- self.txt3 = wx.TextCtrl(which_panel, value = p['default'],
+ txt3 = wx.TextCtrl(which_panel, value = p['default'],
size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
- if p['value'] != '': self.txt3.SetValue(p['value']) # parameter previously set
- which_sizer.Add(self.txt3, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
- p['wxId'] = self.txt3.GetId()
- self.txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
+ if p['value'] != '': txt3.SetValue(p['value']) # parameter previously set
+ which_sizer.Add( txt3, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
+ p['wxId'] = txt3.GetId()
+ txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
if p['type'] == 'string' and p['gisprompt'] == True:
txt = wx.StaticText(which_panel, label = title + ':')
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
# element selection tree combobox (maps, icons, regions, etc.)
if p['prompt'] != 'color':
- self.selection = select.Select(which_panel, id=wx.ID_ANY, size=(300,-1),
+ selection = select.Select(which_panel, id=wx.ID_ANY, size=(300,-1),
type=p['element'])
- if p['value'] != '': self.selection.SetValue(p['value']) # parameter previously set
- which_sizer.Add(self.selection, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
- p['wxId'] = self.selection.GetId()
- self.selection.Bind(wx.EVT_TEXT, self.OnSetValue)
+ if p['value'] != '': selection.SetValue(p['value']) # parameter previously set
+ which_sizer.Add( selection, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
+ p['wxId'] = selection.GetId()
+ selection.Bind(wx.EVT_TEXT, self.OnSetValue)
# color entry
elif p['prompt'] == 'color':
if p['default'] != '':
@@ -669,34 +666,37 @@
txt.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
for f in self.task.flags:
- which_sizer = self.tabsizer[ f['guisection'] ]
- which_panel = self.tab[ f['guisection'] ]
+ which_sizer = tabsizer[ f['guisection'] ]
+ which_panel = tab[ f['guisection'] ]
title = text_beautify(f['description'])
- self.chk = wx.CheckBox(which_panel,-1, label = title, style = wx.NO_BORDER)
- if 'value' in f: self.chk.SetValue(f['value'])
- self.chk.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
- which_sizer.Add(self.chk, 0, wx.EXPAND| wx.ALL, 5)
- f['wxId'] = self.chk.GetId()
- self.chk.Bind(wx.EVT_CHECKBOX, self.OnSetValue)
+ chk = wx.CheckBox(which_panel,-1, label = title, style = wx.NO_BORDER)
+ if 'value' in f: chk.SetValue(f['value'])
+ chk.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
+ which_sizer.Add( chk, 0, wx.EXPAND| wx.ALL, 5)
+ f['wxId'] = chk.GetId()
+ chk.Bind(wx.EVT_CHECKBOX, self.OnSetValue)
maxsizes = (0,0)
for section in sections:
- self.tabsizer[section].SetSizeHints( self.tab[section] )
- self.tabsizer[section].Fit( self.tab[section] )
- self.tab[section].SetAutoLayout(True)
- self.tab[section].SetSizer( self.tabsizer[section] )
- self.tab[section].Layout()
- minsecsizes = self.tabsizer[section].GetMinSize()
+ tabsizer[section].SetSizeHints( tab[section] )
+ tabsizer[section].Fit( tab[section] )
+ tab[section].SetAutoLayout(True)
+ tab[section].SetSizer( tabsizer[section] )
+ tab[section].Layout()
+ minsecsizes = tabsizer[section].GetMinSize()
maxsizes = map( lambda x: max( maxsizes[x], minsecsizes[x] ), (0,1) )
# TODO: be less arbitrary with these 600
constrained_size = (min(600, maxsizes[0]), min(600, maxsizes[1]) )
for section in sections:
- self.tab[section].SetMinSize( constrained_size )
+ tab[section].SetMinSize( constrained_size )
if manual_tab.Ok:
manual_tab.SetMinSize( constrained_size )
+ self.SetSizer( panelsizer )
+ self.hasMain = tab.has_key( 'Main' ) # publish, to enclosing Frame for instance
+
def OnPageChange(self, event):
self.Layout()
From calvelo at grass.itc.it Thu Apr 12 07:06:04 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Thu Apr 12 07:06:06 2007
Subject: [grass-addons] r476 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704120506.l3C564kY015030@grass.itc.it>
Author: calvelo
Date: 2007-04-12 07:05:55 +0200 (Thu, 12 Apr 2007)
New Revision: 476
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- fixed GetId() for select.Select
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-12 01:28:24 UTC (rev 475)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-12 05:05:55 UTC (rev 476)
@@ -74,10 +74,6 @@
reexec_with_pythonw()
-ID_PARAM_START = 800
-ID_FLAG_START = 900
-ID_MULTI_START = 1000
-
ID_ABOUT_COMMAND = 102
VSPACE = 4
@@ -631,7 +627,9 @@
type=p['element'])
if p['value'] != '': selection.SetValue(p['value']) # parameter previously set
which_sizer.Add( selection, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
- p['wxId'] = selection.GetId()
+ # A select.Select is a combobox with two children: a textctl and a popupwindow;
+ # we target the textctl here
+ p['wxId'] = selection.GetChildren()[0].GetId()
selection.Bind(wx.EVT_TEXT, self.OnSetValue)
# color entry
elif p['prompt'] == 'color':
From calvelo at grass.itc.it Thu Apr 12 07:10:30 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Thu Apr 12 07:10:31 2007
Subject: [grass-addons] r477 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704120510.l3C5AUhg015050@grass.itc.it>
Author: calvelo
Date: 2007-04-12 07:10:22 +0200 (Thu, 12 Apr 2007)
New Revision: 477
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- added navigation for tabs
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-12 05:05:55 UTC (rev 476)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-12 05:10:22 UTC (rev 477)
@@ -522,7 +522,7 @@
panelsizer = wx.BoxSizer(wx.VERTICAL)
# Build notebook
- nbStyle=FN.FNB_NO_X_BUTTON|FN.FNB_NO_NAV_BUTTONS|FN.FNB_VC8|FN.FNB_BACKGROUND_GRADIENT
+ nbStyle=FN.FNB_NO_X_BUTTON|FN.FNB_VC8|FN.FNB_BACKGROUND_GRADIENT
notebook = FN.FlatNotebook( self, id=wx.ID_ANY, style=nbStyle)
notebook.SetTabAreaColour(wx.Colour(125,200,175))
notebook.Bind( FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChange )
From barton at grass.itc.it Thu Apr 12 08:59:40 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Apr 12 08:59:41 2007
Subject: [grass-addons] r478 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704120659.l3C6xeMs016087@grass.itc.it>
Author: barton
Date: 2007-04-12 08:59:31 +0200 (Thu, 12 Apr 2007)
New Revision: 478
Modified:
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Non-display commands operate within computational region set by g.region
rather than display region.
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-12 05:10:22 UTC (rev 477)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-12 06:59:31 UTC (rev 478)
@@ -792,8 +792,18 @@
try:
os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
self.cmd_output.write(cmd+"\n----------\n")
+
+ # activate compuational region (set with g.region) for all non-display commands.
+ tmpreg = os.getenv("GRASS_REGION")
+ os.unsetenv("GRASS_REGION")
+
p = Popen(cmd +" --verbose", shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
+ # deactivate computational region and return to display settings
+ if tmpreg:
+ os.environ["GRASS_REGION"] = tmpreg
+
+
oline = p.stderr.readline()
while oline:
oline = oline.strip()
@@ -869,8 +879,7 @@
Path to file name (string) or None
"""
- tempfile = os.popen("g.tempfile pid=%d" %
- os.getpid()).readlines()[0].strip()
+ tempfile = os.popen("g.tempfile pid=%d" % os.getpid()).readlines()[0].strip()
if not tempfile:
return None
From barton at grass.itc.it Thu Apr 12 09:00:30 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Apr 12 09:00:31 2007
Subject: [grass-addons] r479 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704120700.l3C70Uoi016108@grass.itc.it>
Author: barton
Date: 2007-04-12 09:00:18 +0200 (Thu, 12 Apr 2007)
New Revision: 479
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/toolbars.py
Log:
Added zoom options menu.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-12 06:59:31 UTC (rev 478)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-12 07:00:18 UTC (rev 479)
@@ -36,6 +36,12 @@
from threading import Thread
+try:
+ from subprocess import *
+except:
+ from compat import subprocess
+ from compat.subprocess import *
+
gmpath = os.getenv("GISBASE") + "/etc/wx/gui_modules/"
sys.path.append(gmpath)
@@ -777,8 +783,12 @@
self.ZoomHistory(newreg['n'],newreg['s'],newreg['e'],newreg['w'])
def ZoomBack(self):
+ """
+ Zoom to previous extents in zoomhistory list
+ """
- if len(self.zoomhistory) > 0:
+ zoom = []
+ if len(self.zoomhistory) > 1:
self.zoomhistory.pop()
zoom = self.zoomhistory[len(self.zoomhistory)-1]
@@ -798,6 +808,135 @@
if len(self.zoomhistory) > 10:
self.zoomhistory.pop(0)
+ def ZoomToMap(self, event):
+ """
+ Set display extents to match selected raster
+ or vector map.
+ """
+
+ if not self.parent.gismanager: return
+ if not self.parent.gismanager.maptree.GetSelection(): return
+ layer = self.parent.gismanager.maptree.GetSelection()
+ type = self.parent.gismanager.maptree.layertype[layer]
+ dcmd = self.parent.gismanager.maptree.GetPyData(layer)[0]
+ mapname = None
+ for item in dcmd.split(' '):
+ if 'map=' in item:
+ mapname = item.split('=')[1]
+
+ # selected layer must be a valid map
+ if type in ('raster', 'rgb', 'his'):
+ cmd = "r.info -g map=%s" % mapname
+ elif type in ('vector', 'thememap', 'themechart'):
+ cmd = "v.info -g map=%s" % mapname
+ else:
+ return
+ try:
+ p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
+
+ output = p.stdout.read().split('\n')
+ for oline in output:
+ extent = oline.split('=')
+ if extent[0] == 'north':
+ self.Map.region['n'] = float(extent[1])
+ elif extent[0] == 'south':
+ self.Map.region['s'] = float(extent[1])
+ elif extent[0] == 'east':
+ self.Map.region['e'] = float(extent[1])
+ elif extent[0] == 'west':
+ self.Map.region['w'] = float(extent[1])
+
+ self.ZoomHistory(self.Map.region['n'],self.Map.region['s'],self.Map.region['e'],self.Map.region['w'])
+ self.UpdateMap()
+
+ if p.stdout < 0:
+ print >> sys.stderr, "Child was terminated by signal", p.stdout
+ elif p.stdout > 0:
+ #print >> sys.stderr, p.stdout
+ pass
+ except OSError, e:
+ print >> sys.stderr, "Execution failed:", e
+
+ def ZoomToWind(self, event):
+ """
+ Set display geometry to match computational
+ region extents (set with g.region)
+ """
+
+ self.Map.region = self.Map.GetRegion()
+ self.Map.SetRegion()
+ self.ZoomHistory(self.Map.region['n'],self.Map.region['s'],self.Map.region['e'],self.Map.region['w'])
+ self.UpdateMap()
+
+ def DisplayToWind(self, event):
+ """
+ Set computational region (WIND file) to
+ match display extents
+ """
+ tmpreg = os.getenv("GRASS_REGION")
+ os.unsetenv("GRASS_REGION")
+
+ # get current resolution
+ grass_region = self.Map.GetRegion()
+ ewres = grass_region['ewres']
+ nsres = grass_region['nsres']
+
+ # set extents to even increments of resolution
+ self.Map.region['n'] = round(self.Map.region['n']/nsres) * nsres
+ self.Map.region['s'] = round(self.Map.region['s']/nsres) * nsres
+ self.Map.region['e'] = round(self.Map.region['e']/nsres) * ewres
+ self.Map.region['w'] = round(self.Map.region['w']/nsres) * ewres
+
+ cols = math.fabs(round(self.Map.region['n'] - self.Map.region['s']))
+ rows = math.fabs(round(self.Map.region['e'] - self.Map.region['w']))
+
+ os.popen("g.region n=%d s=%d e=%d w=%d nsres=30.0 ewres=30.0" % (
+ self.Map.region['n'],
+ self.Map.region['s'],
+ self.Map.region['e'],
+ self.Map.region['w']) )
+
+ if tmpreg:
+ os.environ["GRASS_REGION"] = tmpreg
+
+ self.ZoomHistory(self.Map.region['n'],self.Map.region['s'],self.Map.region['e'],self.Map.region['w'])
+ self.UpdateMap()
+
+ def ZoomToSaved(self, event):
+ """
+ Set display geometry to match extents in
+ saved region file
+ """
+
+ print 'not yet functional'
+ pass
+
+ def SaveDisplayRegion(self, event):
+ """
+ Save display extents to named region file.
+ """
+
+ print 'not yet functional'
+ pass
+
+# tmpreg = os.getenv("GRASS_REGION")
+# os.unsetenv("GRASS_REGION")
+#
+# # set extents to even increments of resolution
+# self.Map.region['n'] = round(self.Map.region['n']/self.Map.region['nsres']) * self.Map.region['nsres']
+# self.Map.region['s'] = round(self.Map.region['s']/self.Map.region['nsres']) * self.Map.region['nsres']
+# self.Map.region['e'] = round(self.Map.region['e']/self.Map.region['ewres']) * self.Map.region['ewres']
+# self.Map.region['w'] = round(self.Map.region['w']/self.Map.region['ewres']) * self.Map.region['ewres']
+#
+# os.popen("g.region n=%d s=%d e=%d w=%d" % (
+# self.Map.region['n'],
+# self.Map.region['s'],
+# self.Map.region['e'],
+# self.Map.region['w']) )
+#
+# if tmpreg:
+# os.environ["GRASS_REGION"] = tmpreg
+
class MapFrame(wx.Frame):
"""
Main frame for map display window. Drawing takes place in child double buffered
@@ -1340,6 +1479,59 @@
self.Map.changeOverlay(type=type, command=dcmd, l_active=True, l_render=False)
self.params[type] = params
+ def onZoomMenu(self, event):
+ """
+ Decorations overlay menu"
+ """
+ point = wx.GetMousePosition()
+ zoommenu = wx.Menu()
+ # Add items to the menu
+ zoommap = wx.MenuItem(zoommenu, -1,'Zoom to selected map')
+# bmp = wx.Image(os.path.join(icons,'module-d.barscale.gif'), wx.BITMAP_TYPE_GIF)
+# bmp.Rescale(16, 16)
+# bmp = bmp.ConvertToBitmap()
+# zoommap.SetBitmap(bmp)
+ zoommenu.AppendItem(zoommap)
+ self.Bind(wx.EVT_MENU, self.MapWindow.ZoomToMap, zoommap)
+
+ zoomwind = wx.MenuItem(zoommenu, -1,'Zoom to computational region (set with g.region)')
+# bmp = wx.Image(os.path.join(icons,'module-d.barscale.gif'), wx.BITMAP_TYPE_GIF)
+# bmp.Rescale(16, 16)
+# bmp = bmp.ConvertToBitmap()
+# zoomwind.SetBitmap(bmp)
+ zoommenu.AppendItem(zoomwind)
+ self.Bind(wx.EVT_MENU, self.MapWindow.ZoomToWind, zoomwind)
+
+ savewind = wx.MenuItem(zoommenu, -1,'Set computational region from display')
+# bmp = wx.Image(os.path.join(icons,'module-d.legend.gif'), wx.BITMAP_TYPE_GIF)
+# bmp.Rescale(16, 16)
+# bmp = bmp.ConvertToBitmap()
+# savewind.SetBitmap(bmp)
+ zoommenu.AppendItem(savewind)
+ self.Bind(wx.EVT_MENU, self.MapWindow.DisplayToWind, savewind)
+
+ zoomsaved = wx.MenuItem(zoommenu, -1,'Zoom to saved region')
+# bmp = wx.Image(os.path.join(icons,'gui-font.gif'), wx.BITMAP_TYPE_GIF)
+# bmp.Rescale(16, 16)
+# bmp = bmp.ConvertToBitmap()
+# zoomsaved.SetBitmap(bmp)
+ zoommenu.AppendItem(zoomsaved)
+ self.Bind(wx.EVT_MENU, self.MapWindow.ZoomToSaved, zoomsaved)
+
+ savezoom = wx.MenuItem(zoommenu, -1,'Save display geometry to named region')
+# bmp = wx.Image(os.path.join(icons,'gui-font.gif'), wx.BITMAP_TYPE_GIF)
+# bmp.Rescale(16, 16)
+# bmp = bmp.ConvertToBitmap()
+# savezoom.SetBitmap(bmp)
+ zoommenu.AppendItem(savezoom)
+ self.Bind(wx.EVT_MENU, self.MapWindow.SaveDisplayRegion, savezoom)
+
+ # Popup the menu. If an item is selected then its handler
+ # will be called before PopupMenu returns.
+ self.PopupMenu(zoommenu)
+ zoommenu.Destroy()
+
+
# end of class MapFrame
class DecDialog(wx.Dialog):
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-12 06:59:31 UTC (rev 478)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-12 07:00:18 UTC (rev 479)
@@ -59,11 +59,6 @@
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
shortHelp="Zoom out", longHelp="Drag or click mouse to unzoom")
- self.zoomback = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_back",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_back.gif"),
- wx.BITMAP_TYPE_ANY),
- bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
- shortHelp="Zoom back", longHelp="Zoom to previous display region")
self.pan = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="pan",
bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-pan.gif"),
wx.BITMAP_TYPE_ANY),
@@ -77,6 +72,19 @@
self.toolbar.AddSeparator()
+ self.zoomback = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_back",
+ bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_back.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Zoom options", longHelp="Display zoom management")
+ self.zoommenu = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoommenu",
+ bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-mapzoom.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ shortHelp="Decoration", longHelp="Add graphic overlays to map")
+ self.toolbar.AddSeparator()
+
+
self.dec = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="dec",
bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"module-d.barscale.gif"),
wx.BITMAP_TYPE_ANY),
@@ -122,6 +130,7 @@
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnPan, self.pan)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomBack, self.zoomback)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onDecoration, self.dec)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onZoomMenu, self.zoommenu)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnQuery, self.query)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnErase, self.erase)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.SaveToFile, self.savefile)
From barton at grass.itc.it Thu Apr 12 09:01:52 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Thu Apr 12 09:01:53 2007
Subject: [grass-addons] r480 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704120701.l3C71qSp016138@grass.itc.it>
Author: barton
Date: 2007-04-12 09:01:42 +0200 (Thu, 12 Apr 2007)
New Revision: 480
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
Code cleanup
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-12 07:00:18 UTC (rev 479)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-12 07:01:42 UTC (rev 480)
@@ -437,9 +437,9 @@
reg = reg.strip()
key, val = reg.split("=",1)
try:
- region[key] = float(val)
- except ValueError:
- region[key] = val
+ region[key] = float(val)
+ except ValueError:
+ region[key] = val
if tmpreg:
os.environ["GRASS_REGION"] = tmpreg
From chemin at grass.itc.it Thu Apr 12 18:30:54 2007
From: chemin at grass.itc.it (chemin@grass.itc.it)
Date: Thu Apr 12 18:30:55 2007
Subject: [grass-addons] r481 - in trunk/grassaddons/gipe: r.albedo r.biomass
r.dn2full.l7 r.dn2potrad.l7 r.dn2ref.ast r.dn2ref.l7
r.eb.deltat r.eb.disp r.eb.eta r.eb.evapfr r.eb.g0 r.eb.h0
r.eb.h_iter r.eb.molength r.eb.netrad r.eb.psi r.eb.rah
r.eb.ublend r.eb.ustar r.eb.z0m r.emissivity r.evapo.PM
r.evapo.PT r.evapo.TSA r.evapo.potrad r.latitude r.sattime
r.sunhours r.vi r.vi.mpi
Message-ID: <200704121630.l3CGUsG5023880@grass.itc.it>
Author: chemin
Date: 2007-04-12 18:29:55 +0200 (Thu, 12 Apr 2007)
New Revision: 481
Modified:
trunk/grassaddons/gipe/r.albedo/Makefile
trunk/grassaddons/gipe/r.biomass/Makefile
trunk/grassaddons/gipe/r.dn2full.l7/Makefile
trunk/grassaddons/gipe/r.dn2potrad.l7/Makefile
trunk/grassaddons/gipe/r.dn2ref.ast/Makefile
trunk/grassaddons/gipe/r.dn2ref.l7/Makefile
trunk/grassaddons/gipe/r.eb.deltat/Makefile
trunk/grassaddons/gipe/r.eb.disp/Makefile
trunk/grassaddons/gipe/r.eb.eta/Makefile
trunk/grassaddons/gipe/r.eb.evapfr/Makefile
trunk/grassaddons/gipe/r.eb.g0/Makefile
trunk/grassaddons/gipe/r.eb.h0/Makefile
trunk/grassaddons/gipe/r.eb.h_iter/Makefile
trunk/grassaddons/gipe/r.eb.molength/Makefile
trunk/grassaddons/gipe/r.eb.netrad/Makefile
trunk/grassaddons/gipe/r.eb.psi/Makefile
trunk/grassaddons/gipe/r.eb.rah/Makefile
trunk/grassaddons/gipe/r.eb.ublend/Makefile
trunk/grassaddons/gipe/r.eb.ustar/Makefile
trunk/grassaddons/gipe/r.eb.z0m/Makefile
trunk/grassaddons/gipe/r.emissivity/Makefile
trunk/grassaddons/gipe/r.evapo.PM/Makefile
trunk/grassaddons/gipe/r.evapo.PT/Makefile
trunk/grassaddons/gipe/r.evapo.TSA/Makefile
trunk/grassaddons/gipe/r.evapo.potrad/Makefile
trunk/grassaddons/gipe/r.latitude/Makefile
trunk/grassaddons/gipe/r.sattime/Makefile
trunk/grassaddons/gipe/r.sunhours/Makefile
trunk/grassaddons/gipe/r.vi.mpi/Makefile
trunk/grassaddons/gipe/r.vi/Makefile
Log:
Added Large file support in Makefile to all modules but i.atcorr
Modified: trunk/grassaddons/gipe/r.albedo/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.albedo/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.albedo/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.biomass/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.biomass/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.biomass/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.dn2full.l7/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.dn2full.l7/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.dn2full.l7/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.dn2potrad.l7/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.dn2potrad.l7/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.dn2potrad.l7/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -8,4 +8,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.dn2ref.ast/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.dn2ref.ast/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.dn2ref.ast/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.dn2ref.l7/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.dn2ref.l7/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.dn2ref.l7/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.deltat/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.deltat/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.deltat/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.disp/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.disp/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.disp/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.eta/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.eta/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.eta/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.evapfr/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.evapfr/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.evapfr/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.g0/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.g0/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.g0/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.h0/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.h0/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.h0/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.h_iter/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.h_iter/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.h_iter/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.molength/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.molength/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.molength/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.netrad/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.netrad/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.netrad/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.psi/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.psi/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.psi/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.rah/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.rah/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.rah/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.ublend/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.ublend/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.ublend/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.ustar/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.ustar/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.ustar/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.eb.z0m/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.eb.z0m/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.eb.z0m/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.emissivity/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.emissivity/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.emissivity/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.evapo.PM/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.evapo.PM/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.evapo.PM/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -9,4 +9,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.evapo.PT/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.evapo.PT/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.evapo.PT/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -9,4 +9,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.evapo.TSA/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.evapo.TSA/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.evapo.TSA/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -9,4 +9,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.evapo.potrad/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.evapo.potrad/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.evapo.potrad/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.latitude/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.latitude/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.latitude/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -8,4 +8,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.sattime/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.sattime/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.sattime/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -8,4 +8,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.sunhours/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.sunhours/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.sunhours/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -8,4 +8,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.vi/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.vi/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.vi/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,4 +7,8 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
Modified: trunk/grassaddons/gipe/r.vi.mpi/Makefile
===================================================================
--- trunk/grassaddons/gipe/r.vi.mpi/Makefile 2007-04-12 07:01:42 UTC (rev 480)
+++ trunk/grassaddons/gipe/r.vi.mpi/Makefile 2007-04-12 16:29:55 UTC (rev 481)
@@ -7,5 +7,9 @@
include $(MODULE_TOPDIR)/include/Make/Module.make
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
default: cmd
CC=mpicc
From chemin at grass.itc.it Thu Apr 12 18:33:40 2007
From: chemin at grass.itc.it (chemin@grass.itc.it)
Date: Thu Apr 12 18:33:41 2007
Subject: [grass-addons] r482 - in trunk/grassaddons/gipe: . screenshots
Message-ID: <200704121633.l3CGXeNq023902@grass.itc.it>
Author: chemin
Date: 2007-04-12 18:33:26 +0200 (Thu, 12 Apr 2007)
New Revision: 482
Added:
trunk/grassaddons/gipe/screenshots/
trunk/grassaddons/gipe/screenshots/gipe01.png
trunk/grassaddons/gipe/screenshots/gipe02.png
trunk/grassaddons/gipe/screenshots/gipe03.png
trunk/grassaddons/gipe/screenshots/gipe04.png
trunk/grassaddons/gipe/screenshots/gipe05.png
trunk/grassaddons/gipe/screenshots/gipe06.png
trunk/grassaddons/gipe/screenshots/gipe07.png
Log:
Added screenshots of the main GUI and main modules GUI
Added: trunk/grassaddons/gipe/screenshots/gipe01.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gipe/screenshots/gipe01.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gipe/screenshots/gipe02.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gipe/screenshots/gipe02.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gipe/screenshots/gipe03.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gipe/screenshots/gipe03.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gipe/screenshots/gipe04.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gipe/screenshots/gipe04.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gipe/screenshots/gipe05.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gipe/screenshots/gipe05.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gipe/screenshots/gipe06.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gipe/screenshots/gipe06.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gipe/screenshots/gipe07.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gipe/screenshots/gipe07.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
From landa at grass.itc.it Fri Apr 13 11:15:05 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 13 11:15:07 2007
Subject: [grass-addons] r483 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704130915.l3D9F53W004371@grass.itc.it>
Author: landa
Date: 2007-04-13 11:15:05 +0200 (Fri, 13 Apr 2007)
New Revision: 483
Modified:
trunk/grassaddons/gui/gui_modules/cmd.py
Log:
* Popen class used instead of popen3 fn
* header added
* Command class rearranged
Modified: trunk/grassaddons/gui/gui_modules/cmd.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/cmd.py 2007-04-12 16:33:26 UTC (rev 482)
+++ trunk/grassaddons/gui/gui_modules/cmd.py 2007-04-13 09:15:05 UTC (rev 483)
@@ -1,101 +1,172 @@
+"""
+PACKAGE: digit
+
+CLASSES:
+ * EndOfCommand
+ * Command
+
+PURPOSE: Command interface
+
+AUTHORS: The GRASS Development Team
+ Jachym Cepicky, Martin Landa
+
+COPYRIGHT: (C) 2007 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.
+"""
+
+import os
+try:
+ import subprocess
+except:
+ import combat.subprocess as subprocess
+
import grassenv
-import os
+
class EndOfCommand(Exception):
+ """
+ End of command indicator
+ """
def __str__(self):
return "End of command"
class Command:
- def __init__ (self,cmd,stdin=None,verbose=False):
- self.module_stdout = None
+ """
+ Run command on the background
+
+ Usage:
+ cmd = Command(cmd="d.rast elevation.dem", verbose=True, wait=True)
+
+ if cmd.returncode == None:
+ print "RUNNING"
+ elif cmd.returncode == 0:
+ print "SUCCESS"
+ else:
+ print "FAILURE (%d)" % cmd.returncode
+
+ for msg in cmd.module_msg:
+ if msg[0] == "GRASS_INFO_PERCENT":
+ print "Percent done: %d" % (int(msg[1]))
+ else:
+ print "General message:", msg[1]
+ """
+ def __init__ (self, cmd, stdin=None, verbose=False, wait=True):
+ # input
self.module_stdin = None
- self.cmd = cmd
- self.line = None
+ self.cmd = cmd
+ self.module = None
+
+ # output
+ self.module_stderr = None
+ self.module_msg = [] # list of messages (msgtype, content)
os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
- (self.module_stdin, self.module_stdout, self.module_stderr) = os.popen3(self.cmd)
+ # run command
+ if 0:
+ (self.module_stdin, self.module_stdout, self.module_stderr) = \
+ os.popen3(self.cmd)
+ else:
+ self.module = subprocess.Popen(self.cmd, shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ close_fds=True)
+
os.environ["GRASS_MESSAGE_FORMAT"] = "text"
-
+
+ if self.module:
+ self.module_stdin = self.module.stdin
+ self.module_stderr = self.module.stderr
+
if stdin:
self.module_stdin.write(stdin)
self.module_stdin.close()
- if not verbose:
- self.RunS()
+
+ try:
+ self.Run(verbose)
+ except EndOfCommand:
+ pass
- def Run(self):
- """
- run command verbosely
-
- Returns: (msgtype, content)
+ if self.module:
+ if wait:
+ self.module.wait()
+ self.returncode = self.module.returncode
+ else:
+ self.returncode = None
- Usage:
- cmd = Command("d.rast elevation.dem")
- try:
- (msgtype,content) = cmd.RunV()
- while 1:
- if msgtype == "GRASS_INFO_PERCENT":
- print "Percent done: %d" % (int(content))
- else:
- print "General message:", content
- (msgtype,content) = cmd.RunV()
- except EndOfCommand:
- print "end"
+
+ def Run(self, verbose=False):
"""
+ Process messages read from stderr
+ """
msgtype = None
- cont = None
- line = None
+ content = None
+ line = None
- line = self.module_stderr.readline()
while 1:
- if not line:
- raise EndOfCommand()
+ line = self.module_stderr.readline()
+ if not line or line.find("GRASS_INFO_END") > -1:
+ raise EndOfCommand
if line.find(':') > -1:
- break
- line = self.module_stderr.readline()
- msgtype, cont = line.split(":")
+ msgtype, content = line.split(":", 1)
+ if verbose:
+ self.module_msg.append((msgtype, content.strip()))
+ else: # write only fatal errors and warnigs
+ if msgtype.find("GRASS_INFO_ERROR") > -1 or \
+ msgtype.find("GRASS_INFO_WARNING") > -1:
+ self.module_msg.append((msgtype, content.strip()))
- cont=cont.strip()
- return (msgtype,cont.strip())
+ return
- def RunS(self):
- """
- run command silently
+# testing ...
+if __name__ == "__main__":
+ #print __doc__
+
+ # d.rast verbosely, wait for process termination
+ print "Running d.rast..."
+
+ cmd = Command(cmd="d.rast elevation.dem", verbose=True, wait=True)
+
+ if cmd.returncode == None:
+ print "RUNNING"
+ elif cmd.returncode == 0:
+ print "SUCCESS"
+ else:
+ print "FAILURE (%d)" % cmd.returncode
- Returns:
- None if OK
- Usage:
- cmd = Command("d.rast elevation.dem")
- if cmd.RunS():
- print "ERRRROR"
+ for msg in cmd.module_msg:
+ if msg[0] == "GRASS_INFO_PERCENT":
+ print "Percent done: %d" % (int(msg[1]))
+ else:
+ print "General message:", msg[1]
+
+ # v.net.path silently, wait for process termination
+ print "Running v.net.path for 0 593527.6875 4925297.0625 602083.875 4917545.8125..."
- FIXME: maybe use os.system instead?
- """
+ cmd = Command(cmd="v.net.path in=roads@PERMANENT out=tmp --o",
+ stdin="0 593527.6875 4925297.0625 602083.875 4917545.8125",
+ verbose=False,
+ wait=True)
- line = self.module_stderr.readline()
- while 1:
- if not line:
- break
- line =self.module_stderr.readline()
- return
+ if cmd.returncode == None:
+ print "RUNNING"
+ elif cmd.returncode == 0:
+ print "SUCCESS"
+ else:
+ print "FAILURE (%d)" % cmd.returncode
-if __name__ == "__main__":
- print "Running d.rast"
- cmd=Command("d.rast elevation.dem")
- try:
- (msgtype,content) = cmd.RunV()
- while 1:
- if msgtype == "GRASS_INFO_PERCENT":
- print "Percent done: %d" % (int(content))
- else:
- print "General message:", content
- (msgtype,content) = cmd.RunV()
- except EndOfCommand:
- print "konec"
+ # d.vect silently, do not wait for process termination
+ # returncode will be None
+ print "Running d.vect tmp..."
- print "Running v.net.path for 0 593527.6875 4925297.0625 602083.875 4917545.8125"
- cmd=Command("v.net.path in=roads out=tmp --o", "0 593527.6875 4925297.0625 602083.875 4917545.8125")
- cmd.RunS()
- print "Running d.vect tmp"
- cmd = Command("d.vect tmp")
- cmd.RunS()
+ cmd = Command("d.vect tmp", verbose=False, wait=False)
+
+ if cmd.returncode == None:
+ print "RUNNING"
+ elif cmd.returncode == 0:
+ print "SUCCESS"
+ else:
+ print "FAILURE (%d)" % cmd.returncode
From landa at grass.itc.it Fri Apr 13 11:16:15 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 13 11:16:17 2007
Subject: [grass-addons] r484 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704130916.l3D9GFoW004398@grass.itc.it>
Author: landa
Date: 2007-04-13 11:16:15 +0200 (Fri, 13 Apr 2007)
New Revision: 484
Added:
trunk/grassaddons/gui/gui_modules/digit.py
Modified:
trunk/grassaddons/gui/gui_modules/__init__.py
Log:
digit package added
Modified: trunk/grassaddons/gui/gui_modules/__init__.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/__init__.py 2007-04-13 09:15:05 UTC (rev 483)
+++ trunk/grassaddons/gui/gui_modules/__init__.py 2007-04-13 09:16:15 UTC (rev 484)
@@ -4,4 +4,5 @@
"menudata",
"menuform",
"select",
+ "digit",
]
Added: trunk/grassaddons/gui/gui_modules/digit.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/digit.py (rev 0)
+++ trunk/grassaddons/gui/gui_modules/digit.py 2007-04-13 09:16:15 UTC (rev 484)
@@ -0,0 +1,72 @@
+"""
+PACKAGE: digit
+
+CLASSES:
+ * VEdit
+ * VDigit
+
+PURPOSE: Digitization tool wxPython GUI prototype
+
+ Note: Initial version under development
+
+ Progress:
+ (1) v.edit called on the background (class VEdit)
+ (2) Reimplentation of v.digit (VDigit)
+
+AUTHORS: The GRASS Development Team
+ Martin Landa
+
+COPYRIGHT: (C) 2007 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.
+"""
+
+import cmd
+
+#
+class Digit:
+ """
+ Abstract digitization class
+ """
+ pass
+
+#
+class VEdit(Digit):
+ """
+ Prototype of digitization class based on v.edit command
+ """
+ def AddPoint (self, map, x, y):
+ """
+ Add point to the vector map
+ """
+ addstring="""P 1
+ %f %f""" % (x,y)
+ command = """v.edit -n map=%s tool=add""" % (map)
+
+ # run the command
+ vedit = cmd.Command(cmd=command, stdin=addstring)
+
+ # result?
+ if vedit.returncode == 0:
+ pass
+ else:
+ print "FAILURE"
+ for msg in vedit.msg:
+ print msg[1]
+
+#
+class VDigit(Digit):
+ """
+ Prototype of digitization class based on v.digit reimplementation
+
+ Under development (wxWidgets C/C++ background)
+ """
+ pass
+
+
+##############################
+# digitization class instance
+##############################
+
+Digit = VEdit()
From landa at grass.itc.it Fri Apr 13 11:20:07 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 13 11:20:08 2007
Subject: [grass-addons] r485 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704130920.l3D9K7tO004446@grass.itc.it>
Author: landa
Date: 2007-04-13 11:20:07 +0200 (Fri, 13 Apr 2007)
New Revision: 485
Modified:
trunk/grassaddons/gui/gui_modules/render.py
Log:
GetListofLayers(): return always 'selected' list
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-13 09:16:15 UTC (rev 484)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-13 09:20:07 UTC (rev 485)
@@ -546,11 +546,8 @@
else:
selected.append(layer)
- if len(selected) > 0:
- return selected
- else:
- return None
-
+ return selected
+
def Render(self, force=False):
"""
Creates final image composite
From landa at grass.itc.it Fri Apr 13 11:29:29 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 13 11:29:31 2007
Subject: [grass-addons] r486 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704130929.l3D9TTn9004509@grass.itc.it>
Author: landa
Date: 2007-04-13 11:29:29 +0200 (Fri, 13 Apr 2007)
New Revision: 486
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/toolbars.py
Log:
various minor (older) changes (almost digit stuff)
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 09:20:07 UTC (rev 485)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 09:29:29 UTC (rev 486)
@@ -29,6 +29,7 @@
import grassenv
import track
import menuform
+from digit import Digit as Digit
import images
imagepath = images.__path__[0]
@@ -650,9 +651,11 @@
# digitizing
elif self.parent.digittoolbar:
- if self.parent.digittoolbar.digitize == "point":
+ if self.parent.digittoolbar.action == "addpoint":
+ #self.SetCursor (self.parent.cursors["cross"])
east,north= self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1])
- self.parent.digittoolbar.AddPoint(east,north)
+ Digit.AddPoint(self.parent.digittoolbar.layers[self.parent.digittoolbar.layerID],
+ east,north)
# redraw map
self.render=True
self.UpdateMap()
@@ -1016,7 +1019,9 @@
# Init map display
#
self.InitDisplay() # initialize region values
-# self.MapWindow = DrawWindow(self) # initialize buffered DC
+
+ # initialize buffered DC
+ # self.MapWindow = DrawWindow(self)
self.MapWindow = BufferedWindow(self, id = wx.ID_ANY) # initialize buffered DC
self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
@@ -1063,19 +1068,42 @@
"""
if name == "map":
self.maptoolbar = toolbars.MapToolbar(self, self.Map)
- self._mgr.AddPane(self.maptoolbar.toolbar, wx.aui.AuiPaneInfo().
- Name("maptoolbar").Caption("Map Toolbar").
- ToolbarPane().Top().LeftDockable(False).RightDockable(False).
- BottomDockable(True).CloseButton(False))
- if name == "digit":
- self.digittoolbar = toolbars.DigitToolbar(self,self.Map)
+ self._mgr.AddPane(self.maptoolbar.toolbar,
+ wx.aui.AuiPaneInfo().
+ Name("maptoolbar").Caption("Map Toolbar").
+ ToolbarPane().Top().LeftDockable(True).RightDockable(False).
+ BottomDockable(False).TopDockable(False).CloseButton(False))
+
+ elif name == "digit":
+ self.digittoolbar = toolbars.DigitToolbar(self, self.Map)
+
self._mgr.AddPane(self.digittoolbar.toolbar, wx.aui.AuiPaneInfo().
- Name("digittoolbar").Caption("Digit Toolbar").
- ToolbarPane().Top().LeftDockable(False).RightDockable(False).
- BottomDockable(True).CloseButton(False))
+ Name("digittoolbar").Caption("Digit Toolbar").
+ ToolbarPane().Top().Row(1).LeftDockable(False).RightDockable(True).
+ BottomDockable(False).TopDockable(False).CloseButton(False))
+
self._mgr.Update()
+ def RemoveToolbar (self, name):
+ """
+ Removes toolbar from the window
+
+ TODO: Only hide, activate by calling AddToolbar()
+ """
+
+ # cannot hide main toolbar
+ if name == "map":
+ return
+ elif name == "digit":
+ # TODO: not destroy only hide
+ self._mgr.DetachPane (self.digittoolbar.toolbar)
+ self.digittoolbar.toolbar.Destroy()
+ self.digittoolbar = None
+
+ self.maptoolbar.combo.SetValue ("");
+ self._mgr.Update()
+
def InitDisplay(self):
"""
Initialize map display, set dimensions and map region
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-13 09:20:07 UTC (rev 485)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-13 09:29:29 UTC (rev 486)
@@ -3,7 +3,9 @@
class:
* MapToolbar
+* DigitToolbar
"""
+
import wx
import os
import wxgui_utils
@@ -19,22 +21,29 @@
"""
Main Map Display toolbar
"""
+
def __init__(self, mapdisplay, map):
+
global icons
+
self.mapcontent = map
self.mapdisplay = mapdisplay
- self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY, size=(5,100))
+ self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
+
#self.SetToolBar(self.toolbar)
- self.toolbar.SetToolBitmapSize(wx.Size(24,24))
+ tsize = (24, 24)
+ self.toolbar.SetToolBitmapSize(tsize)
+
#
# Draw
#
- self.displaymap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="displaymap",
- bitmap=wx.Bitmap(name=os.path.join(wxgui_utils.icons,"gui-display.gif"),
- type=wx.BITMAP_TYPE_ANY),
- bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
- shortHelp="Display map", longHelp="")
+ self.displaymap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="displaymap",
+ bitmap=wx.Bitmap(name=os.path.join(wxgui_utils.icons, "gui-display.gif")),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_NORMAL,
+ shortHelp="Display map",
+ longHelp="")
self.erase = self.toolbar.AddLabelTool(wx.ID_ANY, "erase",
wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-erase.gif"),
wx.BITMAP_TYPE_ANY),
@@ -47,7 +56,8 @@
self.pointer = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="pointer",
bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-pointer.gif"),
wx.BITMAP_TYPE_ANY),
- bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
shortHelp="Pointer", longHelp="")
self.zoomin = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_in",
bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_in.gif"),
@@ -57,18 +67,21 @@
self.zoomout = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_out",
bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_out.gif"),
wx.BITMAP_TYPE_ANY),
- bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
shortHelp="Zoom out", longHelp="Drag or click mouse to unzoom")
self.pan = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="pan",
bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-pan.gif"),
wx.BITMAP_TYPE_ANY),
- bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
shortHelp="Pan", longHelp="Drag with mouse to pan")
self.query = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="query",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-query.gif"),
+ bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-query.gif"),
wx.BITMAP_TYPE_ANY),
- bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
- shortHelp="Query", longHelp="Query selected map")
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Query", longHelp="Query selected map")
self.toolbar.AddSeparator()
@@ -89,7 +102,8 @@
bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"module-d.barscale.gif"),
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap,
- shortHelp="Decoration", longHelp="Add graphic overlays to map")
+ shortHelp="Decoration",
+ longHelp="Add graphic overlays to map")
self.toolbar.AddSeparator()
@@ -100,9 +114,11 @@
#bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"file-save.gif"),
#wx.BITMAP_TYPE_ANY),
# just testing wx.ArtProvider
- bitmap=wx.ArtProvider.GetBitmap(id=wx.ART_FILE_SAVE, client=wx.ART_BUTTON),
- bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
- shortHelp="Save display to PNG file", longHelp="")
+ bitmap=wx.ArtProvider.GetBitmap(id=wx.ART_FILE_SAVE, client=wx.ART_BUTTON, size=tsize),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_NORMAL,
+ shortHelp="Save display to PNG file",
+ longHelp="")
self.printmap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="printmap",
#bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"file-save.gif"),
@@ -117,25 +133,26 @@
#
# Optional toolbars
#
- cb = wx.ComboBox(self.toolbar, id=wx.ID_ANY, value='',
+ self.combo = wx.ComboBox(self.toolbar, id=wx.ID_ANY, value='',
choices=['Digitize'], size=(-1, -1), style=wx.CB_READONLY , name='Tools')
- self.combo = self.toolbar.AddControl(cb)
+ self.comboid = self.toolbar.AddControl(self.combo)
+
self.toolbar.Realize()
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.ReDraw, self.displaymap)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.Pointer, self.pointer)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomIn, self.zoomin)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomOut, self.zoomout)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnPan, self.pan)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomBack, self.zoomback)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.ReDraw, self.displaymap)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.Pointer, self.pointer)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomIn, self.zoomin)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomOut, self.zoomout)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnPan, self.pan)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomBack, self.zoomback)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onDecoration, self.dec)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onZoomMenu, self.zoommenu)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnQuery, self.query)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnErase, self.erase)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.SaveToFile, self.savefile)
- self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.PrintMap, self.printmap)
- self.mapdisplay.Bind(wx.EVT_COMBOBOX, self.OnSelect, self.combo)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onZoomMenu, self.zoommenu)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnQuery, self.query)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnErase, self.erase)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.SaveToFile, self.savefile)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.PrintMap, self.printmap)
+ self.mapdisplay.Bind(wx.EVT_COMBOBOX, self.OnSelect, self.comboid)
def OnSelect(self,event):
tool = event.GetString()
@@ -144,89 +161,114 @@
self.mapdisplay.AddToolbar("digit")
class DigitToolbar:
- def __init__(self,parent,map):
+ """
+ Toolbar for digitization
+ """
- global icons
+ def __init__(self, parent, map):
self.mapcontent = map
- self.digitize=None
- self.parent=parent
- self.toolbar = wx.ToolBar(self.parent, wx.ID_ANY)
- icons = os.path.join(icons,"v.digit")
+ self.parent = parent
+ self.icons = os.path.join (icons, "v.digit")
- self.addString = ""
+ # selected map to digitize
+ self.layerID = -1
+ # action (digitize new point, line, etc.
+ self.action = None
+ # list of available vector maps
+ self.layers = self._getListOfLayers()
- self.layers = self._getListOfLayers()
+ self.addString = ""
+ # create toolbar
+ self.toolbar = wx.ToolBar(parent=self.parent, id=wx.ID_ANY)
+ self.toolbar.SetToolBitmapSize(wx.Size(24,24))
+
self.initToolbar()
def initToolbar(self):
- self.combo = wx.ComboBox(self.toolbar, 4, 'Select vector map',
- choices=self.layers, size=(120, 10))
+ self.combo = wx.ComboBox(self.toolbar, id=4, value='Select vector map',
+ choices=self.layers, size=(-1, -1))
self.comboid = self.toolbar.AddControl(self.combo)
+
+ self.toolbar.AddSeparator()
+
+ self.point = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="point",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"new.point.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Digitize new point",
+ longHelp="")
+ self.line = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="line",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"new.line.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Digitize new line",
+ longHelp="")
+
+ self.boundary = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="boundary",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"new.boundary.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Digitize new boundary",
+ longHelp="")
+
+ self.centroid = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="centroid",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"new.centroid.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Digitize new centroid",
+ longHelp="")
+
self.toolbar.AddSeparator()
- self.point = self.toolbar.AddLabelTool(wx.ID_ANY, "point",
- wx.Bitmap(os.path.join(icons,"new.point.gif"),
- wx.BITMAP_TYPE_ANY),
- wx.NullBitmap, wx.ITEM_RADIO, "Digitize new point", "")
- self.line = self.toolbar.AddLabelTool(wx.ID_ANY, "line",
- wx.Bitmap(os.path.join(icons,"new.line.gif"),
- wx.BITMAP_TYPE_ANY),
- wx.NullBitmap, wx.ITEM_RADIO, "Digitize new line",
- "")
- self.boundary = self.toolbar.AddLabelTool(wx.ID_ANY, "boundary",
- wx.Bitmap(os.path.join(icons,"new.boundary.gif"),
- wx.BITMAP_TYPE_ANY),
- wx.NullBitmap, wx.ITEM_RADIO, "Digitize new boundary", "")
- self.centroid = self.toolbar.AddLabelTool(wx.ID_ANY, "centroid",
- wx.Bitmap(os.path.join(icons,"new.centroid.gif"),
- wx.BITMAP_TYPE_ANY),
- wx.NullBitmap, wx.ITEM_RADIO, "Digitize new centroid", "")
+ self.exit = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="exit",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"exit.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_NORMAL,
+ shortHelp="Quit digitization tool",
+ longHelp="")
- self.parent.Bind(wx.EVT_TOOL, self.OnPoint, self.point)
+ # Bindings
+ self.parent.Bind(wx.EVT_TOOL, self.OnAddPoint, self.point)
+ self.parent.Bind(wx.EVT_TOOL, self.OnExit, self.exit)
+ self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid)
+
+ def OnAddPoint(self,event):
- def OnPoint(self,event):
-
- self.digitize="point"
+ self.action="addpoint"
#self.parent.MapWindow.mouse['box'] = "point"
- def AddPoint(self,x,y):
- #east,north = self.parent.Pixel2Cell(x,y)
- selectedmap=self.combo.GetCurrentSelection()
- if selectedmap < 1:
- print "you have to select map"
- return
+ def OnExit (self, event):
+ """
+ Quit digitization tool
+ """
+
+ self.parent.RemoveToolbar ("digit")
- addstring="""P 1
- %f %f
- """ % (x,y)
- command = """v.edit -n map="%s" tool=add""" % (self.combo.GetValue())
- #print addstring, command
- vedit=cmd.Command(command,stdin=addstring)
- #try:
- # kye,val = vedit.RunV()
- # while 1:
- # print key,val
- # key,val = vedit.RunV()
- #except:
- # pass
+ def OnSelectMap (self, event):
+ """
+ Select vector map to digitize
+ If any vector map is activated for digitization this action
+ is firstly terminated
+ """
+ self.layerID = self.combo.GetCurrentSelection()
+
+ # digitize (self.layers[self.layerID], mapset)
+
def _getListOfLayers(self):
- layers =[""]
+ layers = []
+
for layer in self.mapcontent.GetListOfLayers(l_type="vector"):
- layers.append( layer.name)
+ layers.append (layer.name)
+
return layers
-
-#class pokus:
-# def __init__(self):
-# global icons
-# print icons
-#
-#if __name__=="__main__":
-# p = pokus()
-
-
From landa at grass.itc.it Fri Apr 13 11:50:19 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 13 11:50:20 2007
Subject: [grass-addons] r487 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704130950.l3D9oJsB004598@grass.itc.it>
Author: landa
Date: 2007-04-13 11:50:19 +0200 (Fri, 13 Apr 2007)
New Revision: 487
Modified:
trunk/grassaddons/gui/gui_modules/cmd.py
Log:
bugfix (compat issue), usePopenClass added
Modified: trunk/grassaddons/gui/gui_modules/cmd.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/cmd.py 2007-04-13 09:29:29 UTC (rev 486)
+++ trunk/grassaddons/gui/gui_modules/cmd.py 2007-04-13 09:50:19 UTC (rev 487)
@@ -16,11 +16,16 @@
for details.
"""
-import os
+import os, sys
+
+usePopenClass = True
+
try:
import subprocess
except:
- import combat.subprocess as subprocess
+ CombatPath = os.getenv("GISBASE") + "/etc/wx"
+ sys.path.append(CombatPath)
+ from compat import subprocess
import grassenv
@@ -64,26 +69,23 @@
os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
# run command
- if 0:
- (self.module_stdin, self.module_stdout, self.module_stderr) = \
- os.popen3(self.cmd)
+ if not usePopenClass:
+ (self.module_stdin, self.module_stdout, self.module_stderr) = \
+ os.popen3(self.cmd)
else:
- self.module = subprocess.Popen(self.cmd, shell=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- close_fds=True)
+ self.module = subprocess.Popen(self.cmd, shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ close_fds=True)
+ self.module_stdin = self.module.stdin
+ self.module_stderr = self.module.stderr
- os.environ["GRASS_MESSAGE_FORMAT"] = "text"
-
- if self.module:
- self.module_stdin = self.module.stdin
- self.module_stderr = self.module.stderr
-
if stdin:
- self.module_stdin.write(stdin)
- self.module_stdin.close()
+ self.module_stdin.write(stdin)
+ self.module_stdin.close()
+ os.environ["GRASS_MESSAGE_FORMAT"] = "text"
try:
self.Run(verbose)
@@ -146,7 +148,7 @@
# v.net.path silently, wait for process termination
print "Running v.net.path for 0 593527.6875 4925297.0625 602083.875 4917545.8125..."
- cmd = Command(cmd="v.net.path in=roads@PERMANENT out=tmp --o",
+ cmd = Command(cmd="v.net.path in=roads@PERMANENT out=tmp dmax=100000 --o",
stdin="0 593527.6875 4925297.0625 602083.875 4917545.8125",
verbose=False,
wait=True)
From landa at grass.itc.it Fri Apr 13 11:56:51 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 13 11:56:52 2007
Subject: [grass-addons] r488 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704130956.l3D9up4m004626@grass.itc.it>
Author: landa
Date: 2007-04-13 11:56:50 +0200 (Fri, 13 Apr 2007)
New Revision: 488
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
cosmetics: redundant " removed
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 09:50:19 UTC (rev 487)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 09:56:50 UTC (rev 488)
@@ -1335,7 +1335,7 @@
# toolBar button handlers
def onDecoration(self, event):
"""
- Decorations overlay menu"
+ Decorations overlay menu
"""
point = wx.GetMousePosition()
decmenu = wx.Menu()
@@ -1509,7 +1509,7 @@
def onZoomMenu(self, event):
"""
- Decorations overlay menu"
+ Decorations overlay menu
"""
point = wx.GetMousePosition()
zoommenu = wx.Menu()
From landa at grass.itc.it Fri Apr 13 12:11:23 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 13 12:11:24 2007
Subject: [grass-addons] r489 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704131011.l3DABNbt004673@grass.itc.it>
Author: landa
Date: 2007-04-13 12:11:23 +0200 (Fri, 13 Apr 2007)
New Revision: 489
Modified:
trunk/grassaddons/gui/gui_modules/toolbars.py
Log:
set size of comboboxes
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-13 09:56:50 UTC (rev 488)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-13 10:11:23 UTC (rev 489)
@@ -133,8 +133,8 @@
#
# Optional toolbars
#
- self.combo = wx.ComboBox(self.toolbar, id=wx.ID_ANY, value='',
- choices=['Digitize'], size=(-1, -1), style=wx.CB_READONLY , name='Tools')
+ self.combo = wx.ComboBox(parent=self.toolbar, id=wx.ID_ANY, value='Tools',
+ choices=['Digitize'], style=wx.CB_READONLY, size=(110, -1))
self.comboid = self.toolbar.AddControl(self.combo)
@@ -187,8 +187,8 @@
self.initToolbar()
def initToolbar(self):
- self.combo = wx.ComboBox(self.toolbar, id=4, value='Select vector map',
- choices=self.layers, size=(-1, -1))
+ self.combo = wx.ComboBox(self.toolbar, id=wx.ID_ANY, value='Select vector map',
+ choices=self.layers, size=(150, -1))
self.comboid = self.toolbar.AddControl(self.combo)
From landa at grass.itc.it Fri Apr 13 12:17:15 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Fri Apr 13 12:17:16 2007
Subject: [grass-addons] r490 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704131017.l3DAHFOe004693@grass.itc.it>
Author: landa
Date: 2007-04-13 12:17:15 +0200 (Fri, 13 Apr 2007)
New Revision: 490
Modified:
trunk/grassaddons/gui/gui_modules/digit.py
Log:
typo
Modified: trunk/grassaddons/gui/gui_modules/digit.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/digit.py 2007-04-13 10:11:23 UTC (rev 489)
+++ trunk/grassaddons/gui/gui_modules/digit.py 2007-04-13 10:17:15 UTC (rev 490)
@@ -52,7 +52,7 @@
pass
else:
print "FAILURE"
- for msg in vedit.msg:
+ for msg in vedit.module_msg:
print msg[1]
#
From barton at grass.itc.it Fri Apr 13 22:05:43 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Fri Apr 13 22:05:44 2007
Subject: [grass-addons] r491 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704132005.l3DK5hTv013356@grass.itc.it>
Author: barton
Date: 2007-04-13 22:05:32 +0200 (Fri, 13 Apr 2007)
New Revision: 491
Modified:
trunk/grassaddons/gui/gui_modules/dbm.py
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/toolbars.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Map displays made a child of layer tree. Makes for much more robust
joint management of linked display and layer tree. Fixed a number of
hidden bugs. Some refactoring.
Modified: trunk/grassaddons/gui/gui_modules/dbm.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-13 10:17:15 UTC (rev 490)
+++ trunk/grassaddons/gui/gui_modules/dbm.py 2007-04-13 20:05:32 UTC (rev 491)
@@ -45,10 +45,10 @@
self.parent.SetStatusText(text_string.strip())
#----------------------------------------------------------------------
-# The panel you want to test (TestVirtualList)
+# The panel you want to test (VirtualAttributeList)
#----------------------------------------------------------------------
-class TestVirtualList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
+class VirtualAttributeList(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.ColumnSorterMixin):
def __init__(self, parent,log,vectmap,pointdata=None):
wx.ListCtrl.__init__( self, parent, -1, style=wx.LC_REPORT|wx.LC_HRULES|wx.LC_VRULES) #wx.VIRTUAL
@@ -86,16 +86,12 @@
self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
# show us the result in map display
- if self.parent.gismanager:
+ if self.Parent.gismanager:
- self.gism = self.parent.gismanager
- curr_pg = self.gism.gm_cb.GetCurrentPage()
- disp_idx = self.gism.track.Track().GetDisp_idx(curr_pg)
+ self.mapdisp = self.Parent.gismanager.curr_page.maptree.mapdisplay
+ self.map = self.Parent.gismanager.curr_page.maptree.Map
- self.mapdisp = self.parent.gismanager.mapdisplays[disp_idx]
- self.map = self.gism.maptree.Map
-
#building the columns
i = 0
# FIXME: subprocess.Popen should be used
@@ -151,7 +147,7 @@
#self.list.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)
#self.list.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
- if self.parent.gismanager:
+ if self.Parent.gismanager:
self.mapdisp.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.onMapClick)
self.timer = wx.PyTimer(self.RedrawMap)
@@ -519,7 +515,7 @@
self.gismanager = parent
# most importand part
- self.win = TestVirtualList(self, log,vectmap=vectmap,pointdata=pointdata)
+ self.win = VirtualAttributeList(self, log,vectmap=vectmap,pointdata=pointdata)
# buttons
self.btn_apply = wx.Button(self, -1, "Apply")
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 10:17:15 UTC (rev 490)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 20:05:32 UTC (rev 491)
@@ -53,7 +53,7 @@
else:
icons = os.environ["GRASS_ICONPATH"]
-Map = render.Map() # instance of Map class to render GRASS display output to PPM file
+#Map = render.Map() # instance of Map class to render GRASS display output to PPM file
# for cmdlinef
cmdfilename = None
@@ -69,7 +69,7 @@
global cmdfilename
self.parent = parent
- self.map = Map #
+ self.map = render.Map() # instance of Map class to render GRASS display output to PPM file
self.cmdfile = open(cmdfilename,"r")
def run(self):
@@ -165,11 +165,13 @@
def __init__(self, parent, id,
pos = wx.DefaultPosition,
size = wx.DefaultSize,
- style=wx.NO_FULL_REPAINT_ON_RESIZE):
+ style=wx.NO_FULL_REPAINT_ON_RESIZE,
+ Map=None, tree=None):
wx.Window.__init__(self, parent, id, pos, size, style)
self.parent = parent
self.Map = Map
+ self.tree = tree
#
# Flags
@@ -345,7 +347,7 @@
"""
All that is needed here is to draw the buffer to screen
"""
- dc = wx.BufferedPaintDC(self, self._Buffer)
+ dc = wx.BufferedPaintDC(self)
# use PrepateDC to set position correctly
self.PrepareDC(dc)
@@ -630,11 +632,11 @@
self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
if self.dragid > 100:
self.currtxtid = self.dragid
- self.Parent.addText(None)
+ self.parent.addText(None)
elif self.dragid == 0:
- self.Parent.addBarscale(None)
+ self.parent.addBarscale(None)
elif self.dragid == 1:
- self.Parent.addLegend(None)
+ self.parent.addLegend(None)
# left mouse button released and not just a pointer
elif event.LeftUp():
@@ -663,10 +665,10 @@
# querying
elif self.mouse["box"] == "query":
east,north = self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1])
- if self.parent.gismanager:
- layer = self.parent.gismanager.maptree.GetSelection()
- type = self.parent.gismanager.maptree.layertype[layer]
- dcmd = self.parent.gismanager.maptree.GetPyData(layer)[0]
+ if self.tree.GetSelection():
+ layer = self.tree.GetSelection()
+ type = self.tree.layertype[layer]
+ dcmd = self.tree.GetPyData(layer)[0]
mapname = None
for item in dcmd.split(' '):
if 'map=' in item:
@@ -817,11 +819,10 @@
or vector map.
"""
- if not self.parent.gismanager: return
- if not self.parent.gismanager.maptree.GetSelection(): return
- layer = self.parent.gismanager.maptree.GetSelection()
- type = self.parent.gismanager.maptree.layertype[layer]
- dcmd = self.parent.gismanager.maptree.GetPyData(layer)[0]
+ if not self.tree.GetSelection(): return
+ layer = self.tree.GetSelection()
+ type = self.tree.layertype[layer]
+ dcmd = self.tree.GetPyData(layer)[0]
mapname = None
for item in dcmd.split(' '):
if 'map=' in item:
@@ -948,7 +949,8 @@
def __init__(self, parent=None, id = wx.ID_ANY, title="Map display",
pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"], cb=None, idx=-1):
+ style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"],
+ cb=None, gismgr=None, Map=None):
"""
@@ -971,8 +973,9 @@
wx.Frame.__init__(self, parent, id, title, pos, size, style)
# most of the thime, this will be the gis manager
- self.gismanager = parent
+ self.gismanager = gismgr
self.Map = Map
+ self.tree = parent
#
# Set the size
@@ -1022,7 +1025,7 @@
# initialize buffered DC
# self.MapWindow = DrawWindow(self)
- self.MapWindow = BufferedWindow(self, id = wx.ID_ANY) # initialize buffered DC
+ self.MapWindow = BufferedWindow(self, id = wx.ID_ANY, Map=self.Map, tree=self.tree) # initialize buffered DC
self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
#
@@ -1303,7 +1306,7 @@
"""
# switch GIS Manager to output console to show query results
- self.Parent.notebook.SetSelection(1)
+ self.gismanager.notebook.SetSelection(1)
self.MapWindow.mouse['box'] = "query"
self.MapWindow.zoomtype = 0
@@ -1629,7 +1632,7 @@
"""
menuform.GUI().parseCommand(self.ovlcmd, gmpath,
- completed=(self.Parent.getOptData,self.ovltype,self.params),
+ completed=(self.parent.getOptData,self.ovltype,self.params),
parentframe=None)
class TextDialog(wx.Dialog):
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-13 10:17:15 UTC (rev 490)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-13 20:05:32 UTC (rev 491)
@@ -8,15 +8,21 @@
import wx
import os
-import wxgui_utils
+#import wxgui_utils
import cmd
-icons= os.path.split(wxgui_utils.icons)[0]
-icons= os.path.split(icons)[0]
-icons= os.path.split(icons)[0]
+#icons= os.path.split(icons)[0]
+#icons= os.path.split(icons)[0]
+#icons= os.path.split(icons)[0]
#print icons
+if not os.getenv("GRASS_ICONPATH"):
+ icons = os.getenv("GISBASE") + "/etc/gui/icons/"
+else:
+ icons = os.environ["GRASS_ICONPATH"]
+
+
class MapToolbar:
"""
Main Map Display toolbar
@@ -30,7 +36,7 @@
self.mapdisplay = mapdisplay
self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
-
+
#self.SetToolBar(self.toolbar)
tsize = (24, 24)
self.toolbar.SetToolBitmapSize(tsize)
@@ -38,14 +44,14 @@
#
# Draw
#
- self.displaymap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="displaymap",
- bitmap=wx.Bitmap(name=os.path.join(wxgui_utils.icons, "gui-display.gif")),
- bmpDisabled=wx.NullBitmap,
- kind=wx.ITEM_NORMAL,
- shortHelp="Display map",
- longHelp="")
+
+ self.displaymap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="displaymap",
+ bitmap=wx.Bitmap(name=os.path.join(icons,"gui-display.gif"),
+ type=wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Display map", longHelp="")
self.erase = self.toolbar.AddLabelTool(wx.ID_ANY, "erase",
- wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-erase.gif"),
+ wx.Bitmap(os.path.join(icons,"gui-erase.gif"),
wx.BITMAP_TYPE_ANY),
wx.NullBitmap, wx.ITEM_NORMAL, "Erase display", "")
self.toolbar.AddSeparator()
@@ -54,44 +60,44 @@
# Zooming, etc.
#
self.pointer = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="pointer",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-pointer.gif"),
+ bitmap=wx.Bitmap(os.path.join(icons,"gui-pointer.gif"),
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap,
kind=wx.ITEM_RADIO,
shortHelp="Pointer", longHelp="")
self.zoomin = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_in",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_in.gif"),
+ bitmap=wx.Bitmap(os.path.join(icons,"gui-zoom_in.gif"),
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
shortHelp="Zoom in", longHelp="Drag or click mouse to zoom")
self.zoomout = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_out",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_out.gif"),
+ bitmap=wx.Bitmap(os.path.join(icons,"gui-zoom_out.gif"),
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap,
kind=wx.ITEM_RADIO,
shortHelp="Zoom out", longHelp="Drag or click mouse to unzoom")
self.pan = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="pan",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-pan.gif"),
+ bitmap=wx.Bitmap(os.path.join(icons,"gui-pan.gif"),
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap,
kind=wx.ITEM_RADIO,
shortHelp="Pan", longHelp="Drag with mouse to pan")
self.query = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="query",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-query.gif"),
- wx.BITMAP_TYPE_ANY),
- bmpDisabled=wx.NullBitmap,
- kind=wx.ITEM_RADIO,
- shortHelp="Query", longHelp="Query selected map")
+ bitmap=wx.Bitmap(os.path.join(icons,"gui-query.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Query", longHelp="Query selected map")
self.toolbar.AddSeparator()
self.zoomback = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_back",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-zoom_back.gif"),
+ bitmap=wx.Bitmap(os.path.join(icons,"gui-zoom_back.gif"),
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
shortHelp="Zoom options", longHelp="Display zoom management")
self.zoommenu = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoommenu",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"gui-mapzoom.gif"),
+ bitmap=wx.Bitmap(os.path.join(icons,"gui-mapzoom.gif"),
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap,
shortHelp="Decoration", longHelp="Add graphic overlays to map")
@@ -99,10 +105,10 @@
self.dec = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="dec",
- bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"module-d.barscale.gif"),
+ bitmap=wx.Bitmap(os.path.join(icons,"module-d.barscale.gif"),
wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap,
- shortHelp="Decoration",
+ shortHelp="Decoration",
longHelp="Add graphic overlays to map")
self.toolbar.AddSeparator()
@@ -111,7 +117,7 @@
# Misc
#
self.savefile = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="savefile",
- #bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"file-save.gif"),
+ #bitmap=wx.Bitmap(os.path.join(icons,"file-save.gif"),
#wx.BITMAP_TYPE_ANY),
# just testing wx.ArtProvider
bitmap=wx.ArtProvider.GetBitmap(id=wx.ART_FILE_SAVE, client=wx.ART_BUTTON, size=tsize),
@@ -121,7 +127,7 @@
longHelp="")
self.printmap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="printmap",
- #bitmap=wx.Bitmap(os.path.join(wxgui_utils.icons,"file-save.gif"),
+ #bitmap=wx.Bitmap(os.path.join(icons,"file-save.gif"),
#wx.BITMAP_TYPE_ANY),
# just testing wx.ArtProvider
bitmap=wx.ArtProvider.GetBitmap(id=wx.ART_PRINT, client=wx.ART_BUTTON),
@@ -183,7 +189,7 @@
# create toolbar
self.toolbar = wx.ToolBar(parent=self.parent, id=wx.ID_ANY)
self.toolbar.SetToolBitmapSize(wx.Size(24,24))
-
+
self.initToolbar()
def initToolbar(self):
@@ -191,9 +197,9 @@
choices=self.layers, size=(150, -1))
self.comboid = self.toolbar.AddControl(self.combo)
-
+
self.toolbar.AddSeparator()
-
+
self.point = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="point",
bitmap=wx.Bitmap(os.path.join(self.icons,"new.point.gif"),
wx.BITMAP_TYPE_ANY),
@@ -240,7 +246,7 @@
self.parent.Bind(wx.EVT_TOOL, self.OnAddPoint, self.point)
self.parent.Bind(wx.EVT_TOOL, self.OnExit, self.exit)
self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid)
-
+
def OnAddPoint(self,event):
self.action="addpoint"
@@ -250,7 +256,7 @@
"""
Quit digitization tool
"""
-
+
self.parent.RemoveToolbar ("digit")
def OnSelectMap (self, event):
@@ -258,11 +264,11 @@
Select vector map to digitize
If any vector map is activated for digitization this action
- is firstly terminated
+ is firstly terminated
"""
self.layerID = self.combo.GetCurrentSelection()
-
+
# digitize (self.layers[self.layerID], mapset)
def _getListOfLayers(self):
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-13 10:17:15 UTC (rev 490)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-13 20:05:32 UTC (rev 491)
@@ -7,7 +7,11 @@
import track
import select
import menuform
+import mapdisp
+import render
+
+
#FIXME??
try:
from subprocess import *
@@ -35,7 +39,7 @@
size=wx.DefaultSize, style=wx.SUNKEN_BORDER,
ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT|
- CT.TR_EDIT_LABELS, disp=None, log=None):
+ CT.TR_EDIT_LABELS, idx=None, gismgr=None, gm_cb=None):
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style,ctstyle)
self.SetAutoLayout(True)
@@ -43,7 +47,7 @@
self.EnableSelectionGradient(True)
self.SetFirstGradientColour(wx.Colour(150, 150, 150))
- self.Map = "" # instance of render.Map associated with display
+ self.Map = render.Map() # instance of render.Map to be associated with display
self.root = "" # ID of layer tree root node
self.groupnode = 0 # index value for layers
self.optpage = {} # dictionary of notebook option pages for each map layer
@@ -53,9 +57,34 @@
self.saveitem = {} # dictionary to preserve layer attributes for drag and drop
self.first = True # indicates if a layer is just added or not
self.drag = False # flag to indicate a drag event is in process
+ self.disp_idx = idx
+ self.gismgr = gismgr
+ self.gm_cb = gm_cb # GIS Manager notebook for layer tree
+ self.treepg = parent # notebook page holding layer tree
- self.Map = disp.getRender()
+ # init associated map display
+ self.mapdisplay = mapdisp.MapFrame(self,
+ id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
+ style=wx.DEFAULT_FRAME_STYLE,
+ cb=self.gm_cb, gismgr=self.gismgr, Map=self.Map)
+
+ # title
+ self.mapdisplay.SetTitle(_("Map Display " + str(self.disp_idx)))
+ #self.maptree[self.disp_idx] = self.mapdisplays[self.disp_idx].getTree()
+
+ # store information about display and associated controls in a dictionary in track.py
+ track.Track().SetDisp(self.disp_idx,self.mapdisplay)
+ track.Track().SetCtrlDict(self.disp_idx, self.mapdisplay, self.treepg, self)
+
+ #show new display
+ self.mapdisplay.Show()
+ self.mapdisplay.Refresh()
+ self.mapdisplay.Update()
+
+
+ self.Map = self.mapdisplay.getRender()
+
self.root = self.AddRoot("Map Layers")
self.SetPyData(self.root, (None,None))
@@ -134,7 +163,7 @@
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.onBeginDrag)
self.Bind(wx.EVT_TREE_END_DRAG, self.onEndDrag)
- def AddLayer(self, idx, type):
+ def AddLayer(self, type):
self.first = True
params = {} # no initial options parameters
@@ -507,6 +536,9 @@
self.Map.changeLayer(item=layer, command=cmd, l_active=chk,
l_hidden=hidden, l_opacity=opac, l_render=False)
+ def setNotebookPage(self,pg):
+ self.Parent.notebook.SetSelection(pg)
+
class TreeCtrlComboPopup(wx.combo.ComboPopup):
"""
Create a tree ComboBox for selecting maps and other GIS elements
@@ -729,10 +761,11 @@
# cmd = self.console_command.GetLineText(0)
cmdlst = cmd.split(' ')
try:
- disp_idx = int(track.Track().GetDisp()[0])
- curr_disp = track.Track().GetDisp()[1]
+# disp_idx = int(track.Track().GetDisp()[0])
+# curr_disp = track.Track().GetDisp()[1]
+ curr_disp = self.Parent.Parent.curr_page.maptree.mapdisplay
except:
- disp_idx = None
+# disp_idx = None
curr_disp = None
if len(cmdlst) == 1 and cmd in gcmdlst:
@@ -762,11 +795,11 @@
print 'Command type not yet implemented'
return
- if disp_idx != None:
- # get layer tree for active display
- layertree = track.Track().GetCtrls(disp_idx, 2)
+# if disp_idx != None:
+# # get layer tree for active display
+# layertree = track.Track().GetCtrls(disp_idx, 2)
# add layer
- layertree.AddLayer(disp_idx, layertype)
+ self.Parent.Parent.curr_page.maptree.AddLayer(layertype)
else:
menuform.GUI().parseCommand(cmd, gmpath, parentframe=None)
From barton at grass.itc.it Fri Apr 13 22:13:32 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Fri Apr 13 22:13:32 2007
Subject: [grass-addons] r492 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704132013.l3DKDWL9013802@grass.itc.it>
Author: barton
Date: 2007-04-13 22:13:25 +0200 (Fri, 13 Apr 2007)
New Revision: 492
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
small bug fix
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 20:05:32 UTC (rev 491)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 20:13:25 UTC (rev 492)
@@ -950,7 +950,7 @@
def __init__(self, parent=None, id = wx.ID_ANY, title="Map display",
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"],
- cb=None, gismgr=None, Map=None):
+ cb=None, gismgr=None, idx=None, Map=None):
"""
@@ -1103,7 +1103,7 @@
self._mgr.DetachPane (self.digittoolbar.toolbar)
self.digittoolbar.toolbar.Destroy()
self.digittoolbar = None
-
+
self.maptoolbar.combo.SetValue ("");
self._mgr.Update()
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-13 20:05:32 UTC (rev 491)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-13 20:13:25 UTC (rev 492)
@@ -66,7 +66,7 @@
self.mapdisplay = mapdisp.MapFrame(self,
id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE,
- cb=self.gm_cb, gismgr=self.gismgr, Map=self.Map)
+ cb=self.gm_cb, gismgr=self.gismgr, idx=self.disp_idx, Map=self.Map)
# title
From barton at grass.itc.it Sat Apr 14 02:16:29 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sat Apr 14 02:16:30 2007
Subject: [grass-addons] r493 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704140016.l3E0GTpA017753@grass.itc.it>
Author: barton
Date: 2007-04-14 02:16:18 +0200 (Sat, 14 Apr 2007)
New Revision: 493
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
trunk/grassaddons/gui/wxgui.py
Log:
Further cleanup after making map displays children of layer tree. Probably
don't need track.py anymore. Check for operation of cmd.py
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-13 20:13:25 UTC (rev 492)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-14 00:16:18 UTC (rev 493)
@@ -950,7 +950,7 @@
def __init__(self, parent=None, id = wx.ID_ANY, title="Map display",
pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE, toolbars=["map"],
- cb=None, gismgr=None, idx=None, Map=None):
+ tree=None, notebook=None, gismgr=None, page=None, Map=None):
"""
@@ -966,16 +966,21 @@
style -- window style
toolbars-- array of default toolbars, which should appear
map, digit
- cb -- control book ID in GIS Manager
- idx -- index of display
+ notebook-- control book ID in GIS Manager
+ tree -- associated layer tree
+ gismgr -- GIS Manager panel
+ page -- notebook page with layer tree
+ Map -- instance of render.Map
"""
wx.Frame.__init__(self, parent, id, title, pos, size, style)
# most of the thime, this will be the gis manager
- self.gismanager = gismgr
- self.Map = Map
- self.tree = parent
+ self.gismanager = gismgr # GIS Manager object
+ self.Map = Map # instance of render.Map
+ self.tree = tree # GIS Manager layer tree object
+ self.page = page # Notebook page holding the layer tree
+ self.layerbook = notebook #GIS Manager layer tree notebook
#
# Set the size
@@ -983,7 +988,6 @@
self.SetClientSize((600, 475))
# Set variables to associate display with GIS Manager page
- self.ctrlbk = cb
self.disp_idx = idx
#
@@ -1040,11 +1044,9 @@
#
# Bind various events
- # ONLY if we are running from GIS manager
#
- if self.disp_idx > -1:
- self.Bind(wx.EVT_ACTIVATE, self.OnFocus)
- self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+ self.Bind(wx.EVT_ACTIVATE, self.OnFocus)
+ self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
#
# Update fancy gui style
@@ -1118,27 +1120,13 @@
def OnFocus(self, event):
"""
- Store information about active display
- in tracking variables and change choicebook
+ Change choicebook
page to match display
"""
- #get index number of active display
- self.disp_idx = int(track.Track().GetDisp_idx(self))
- #set active display tuple in track
- track.Track().SetDisp(self.disp_idx, self)
-
- # change bookcontrol page to page associted with display if > 1 display
- pg = track.Track().GetCtrls(self.disp_idx, 1)
- pg_count = self.ctrlbk.GetPageCount()
- pgnum = '0'
- if pg_count > 0:
- for x in range(0,pg_count):
- if self.ctrlbk.GetPage(x) == pg:
- pgnum = x
- break
-
- self.ctrlbk.SetSelection(pgnum)
+ # change bookcontrol page to page associted with display
+ pgnum = self.layerbook.GetPageIndex(self.page)
+ if pgnum > -1: self.layerbook.SetSelection(pgnum)
event.Skip()
def OnMotion(self, event):
@@ -1274,26 +1262,15 @@
def OnCloseWindow(self, event):
"""
Window closed
+ Also close associated layer tree page
"""
+ pgnum = None
self.Map.Clean()
+ pgnum = self.layerbook.GetPageIndex(self.page)
self.Destroy()
- #close associated controls book page
- #get index number of active display
- self.disp_idx = track.Track().GetDisp_idx(self)
+ if pgnum > -1: self.layerbook.DeletePage(pgnum)
- # delete associated bookcontrol page if it exists
- if self.disp_idx != None:
- pg = track.Track().GetCtrls(self.disp_idx, 1)
- pg_count = self.ctrlbk.GetPageCount()
- pgnum = '0'
- if pg_count > 0:
- for x in range(0,pg_count):
- if self.ctrlbk.GetPage(x) == pg:
- pgnum = x
- track.Track().popCtrl(self.disp_idx)
- self.ctrlbk.DeletePage(pgnum)
-
def getRender(self):
"""
returns the current instance of render.Map()
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-13 20:13:25 UTC (rev 492)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-14 00:16:18 UTC (rev 493)
@@ -39,7 +39,7 @@
size=wx.DefaultSize, style=wx.SUNKEN_BORDER,
ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT|
- CT.TR_EDIT_LABELS, idx=None, gismgr=None, gm_cb=None):
+ CT.TR_EDIT_LABELS, idx=None, gismgr=None, notebook=None):
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style,ctstyle)
self.SetAutoLayout(True)
@@ -59,14 +59,16 @@
self.drag = False # flag to indicate a drag event is in process
self.disp_idx = idx
self.gismgr = gismgr
- self.gm_cb = gm_cb # GIS Manager notebook for layer tree
+ self.notebook = notebook # GIS Manager notebook for layer tree
self.treepg = parent # notebook page holding layer tree
+
# init associated map display
self.mapdisplay = mapdisp.MapFrame(self,
id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
style=wx.DEFAULT_FRAME_STYLE,
- cb=self.gm_cb, gismgr=self.gismgr, idx=self.disp_idx, Map=self.Map)
+ tree=self, notebook=self.notebook, gismgr=self.gismgr, page=self.treepg,
+ Map=self.Map)
# title
@@ -83,6 +85,7 @@
self.mapdisplay.Update()
+
self.Map = self.mapdisplay.getRender()
self.root = self.AddRoot("Map Layers")
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-13 20:13:25 UTC (rev 492)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-14 00:16:18 UTC (rev 493)
@@ -137,6 +137,8 @@
self.disp_idx = 0 #index value for map displays and layer trees
self.maptree = {} #dictionary to index a layer tree to accompanying a map display
self.mapfocus = 0 #track which display currently has focus
+ self.curr_page = '' # currently selected page for layer tree notebook
+ self.curr_pagenum = '' # currently selected page number for layer tree notebook
self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
self.Bind(wx.EVT_LEFT_DOWN, self.addRaster)
@@ -246,32 +248,28 @@
old_pgnum = event.GetOldSelection()
new_pgnum = event.GetSelection()
- curr_pg = self.gm_cb.GetCurrentPage()
- sel_pgnum = self.gm_cb.GetSelection()
+ self.curr_page = self.gm_cb.GetCurrentPage()
+ self.curr_pagenum = self.gm_cb.GetSelection()
+ try:
+ self.curr_page.maptree.mapdisplay.SetFocus()
+ self.curr_page.maptree.mapdisplay.Raise()
+ except:
+ pass
- # get ID of associated display if more than one
- disp_idx = track.Track().GetDisp_idx(curr_pg)
- if disp_idx != None:
- #get associated display and make it active
- newdisp = track.Track().GetCtrls(disp_idx, 0)
- newdisp.SetFocus()
- newdisp.Raise()
event.Skip()
def onCBPageClosed(self, event):
- """Page of notebook closed"""
+ """
+ Page of notebook closed
+ Also close associated map display
+ """
+ closepage = event.GetSelection()
- curr_pg = self.gm_cb.GetCurrentPage()
- disp_idx = track.Track().GetDisp_idx(curr_pg)
- if disp_idx != None:
- #get associated display and make it active
- disp = track.Track().GetCtrls(disp_idx, 0)
- try:
- if self.mapdisplays.has_key(disp_idx):
- if self.mapdisplays[disp_idx].Close(False):
- self.mapdisplays[disp_idx].Close(True)
- except:
- pass
+ try:
+ if self.closepage.maptree.mapdisplay.Close(False):
+ self.closepage.maptree.mapdisplay.Close(True)
+ except:
+ pass
def runCmd(self,event):
"""Run command"""
@@ -323,13 +321,15 @@
)
def ShowAttributeTable(self,event):
-
- maptype = self.maptree.layertype[self.maptree.GetSelection()]
+ if self.curr_page.maptree.GetSelection() not in self.curr_page.maptree.layertype: return
+ maptype = self.curr_page.maptree.layertype[self.curr_page.maptree.GetSelection()]
if maptype != 'vector':
print 'Attribute management only available for vector files'
return
- dcmd = self.maptree.GetPyData(self.maptree.GetSelection())[0]
+ if not self.curr_page.maptree.GetPyData(self.curr_page.maptree.GetSelection()): return
+ dcmd = self.curr_page.maptree.GetPyData(self.curr_page.maptree.GetSelection())[0]
+ if not dcmd: return
mapname = map = mapset = size = icon = None
for item in dcmd.split(' '):
if 'map=' in item:
@@ -351,46 +351,26 @@
def newDisplay(self, event=None):
"""Create new map display frame"""
- newdisp = self.mapdisplays[self.disp_idx] = mapdisp.MapFrame(self,
- id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=wx.DEFAULT_FRAME_STYLE,
- cb=self.gm_cb, idx=self.disp_idx)
- # title
- newdisp.SetTitle(_("Map Display " + str(self.disp_idx)))
- #self.maptree[self.disp_idx] = self.mapdisplays[self.disp_idx].getTree()
-
- #add notebook page to GIS Manager
-
# make a new page in the bookcontrol for the layer tree (on page 0 of the notebook)
self.pg_panel = wx.Panel(self.gm_cb, id=wx.ID_ANY, style= wx.EXPAND)
self.gm_cb.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx), select = True)
- self.cb_page = self.gm_cb.GetCurrentPage()
+ self.curr_page = self.gm_cb.GetCurrentPage()
# create layer tree (tree control for managing GIS layers) and put on new notebook page
- self.maptree = wxgui_utils.LayerTree(self.cb_page, id=wx.ID_ANY, pos=wx.DefaultPosition,
+ self.curr_page.maptree = wxgui_utils.LayerTree(self.curr_page, id=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS
|wx.TR_LINES_AT_ROOT|wx.TR_EDIT_LABELS|wx.TR_HIDE_ROOT
|wx.TR_DEFAULT_STYLE|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE,
- disp=newdisp)
+ idx=self.disp_idx, gismgr=self, notebook=self.gm_cb)
# layout for controls
cb_boxsizer = wx.BoxSizer(wx.VERTICAL)
- cb_boxsizer.Add(self.maptree, proportion=1, flag=wx.EXPAND, border=1)
- self.cb_page.SetSizer(cb_boxsizer)
- cb_boxsizer.Fit(self.cb_page)
- self.cb_page.Layout()
- #self.cb_page.SetAutoLayout(True)
- #self.Centre()
+ cb_boxsizer.Add(self.curr_page.maptree, proportion=1, flag=wx.EXPAND, border=1)
+ self.curr_page.SetSizer(cb_boxsizer)
+ cb_boxsizer.Fit(self.curr_page.maptree)
+ self.curr_page.Layout()
+ self.curr_page.maptree.Layout()
- # store information about display and associated controls in a dictionary in track.py
- track.Track().SetDisp(self.disp_idx,self)
- track.Track().SetCtrlDict(self.disp_idx, newdisp, self.cb_page, self.maptree)
-
- #show new display
- self.mapdisplays[self.disp_idx].Show()
- self.mapdisplays[self.disp_idx].Refresh()
- self.mapdisplays[self.disp_idx].Update()
-
self.disp_idx += 1
# toolBar button handlers
@@ -489,75 +469,62 @@
def addRaster(self, event):
- self.SetTree('raster')
+ self.curr_page.maptree.AddLayer('raster')
def addRGB(self, event):
"""Add RGB layer"""
- self.SetTree('rgb')
+ self.curr_page.maptree.AddLayer('rgb')
def addHIS(self, event):
"""Add HIS layer"""
- self.SetTree('his')
+ self.curr_page.maptree.AddLayer('his')
def addRastLeg(self, event):
"""Add raster legend"""
- self.SetTree('rastleg')
+ self.curr_page.maptree.AddLayer('rastleg')
def addVector(self, event):
"""Add vector layer"""
- self.SetTree('vector')
+ self.curr_page.maptree.AddLayer('vector')
def addThemeMap(self, event):
"""Add thematic map layer"""
- self.SetTree('thememap')
+ self.curr_page.maptree.AddLayer('thememap')
def addThemeChart(self, event):
"""Add thematic chart layer"""
- self.SetTree('themechart')
+ self.curr_page.maptree.AddLayer('themechart')
def addCommand(self, event):
"""Add command line layer"""
- self.SetTree('command')
+ self.curr_page.maptree.AddLayer('command')
def addGroup(self, event):
"""Add layer group"""
- self.SetTree('group')
+ self.curr_page.maptree.AddLayer('group')
def addGrid(self, event):
"""Add layer grid"""
- self.SetTree('grid')
+ self.curr_page.maptree.AddLayer('grid')
def addLabels(self, event):
"""Add layer vector labels"""
- print 'labels 1', event
- self.SetTree('labels')
+ self.curr_page.maptree.AddLayer('labels')
def GetSelectedDisplay(self):
return self.notebook.GetSelection()
- def SetTree(self, layertype):
- """
- Add map display layer in GIS Manager tree widget
- """
- disp_idx = track.Track().GetDisp_idx(self.maptree)
- if disp_idx != None:
- self.maptree.AddLayer(disp_idx, layertype)
-
def deleteLayer(self, event):
"""
Delete selected map display layer in GIS Manager tree widget
"""
- self.maptree.Delete(self.maptree.GetSelection())
+ self.curr_page.maptree.Delete(self.curr_page.maptree.GetSelection())
#Misc methods
def onCloseWindow(self, event):
'''Cleanup when wxgui.py is quit'''
- mdlist = range(0, self.disp_idx+1)
try:
- for md in mdlist:
- if self.mapdisplays.has_key(md):
- if self.mapdisplays[md].Close(False):
- self.mapdisplays[md].Close(True)
+ self.DeleteAllPages()
except:
self.DestroyChildren()
self.Destroy()
From barton at grass.itc.it Sat Apr 14 03:36:19 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sat Apr 14 03:36:20 2007
Subject: [grass-addons] r494 - trunk/grassaddons/gui
Message-ID: <200704140136.l3E1aJ4w018305@grass.itc.it>
Author: barton
Date: 2007-04-14 03:36:11 +0200 (Sat, 14 Apr 2007)
New Revision: 494
Modified:
trunk/grassaddons/gui/wxgui.py
Log:
Adding a layer to the layer tree automatically switches to layer tree view.
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-14 00:16:18 UTC (rev 493)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-14 01:36:11 UTC (rev 494)
@@ -469,46 +469,57 @@
def addRaster(self, event):
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('raster')
def addRGB(self, event):
"""Add RGB layer"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('rgb')
def addHIS(self, event):
"""Add HIS layer"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('his')
def addRastLeg(self, event):
"""Add raster legend"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('rastleg')
def addVector(self, event):
"""Add vector layer"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('vector')
def addThemeMap(self, event):
"""Add thematic map layer"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('thememap')
def addThemeChart(self, event):
"""Add thematic chart layer"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('themechart')
def addCommand(self, event):
"""Add command line layer"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('command')
def addGroup(self, event):
"""Add layer group"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('group')
def addGrid(self, event):
"""Add layer grid"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('grid')
def addLabels(self, event):
"""Add layer vector labels"""
+ self.notebook.SetSelection(0)
self.curr_page.maptree.AddLayer('labels')
def GetSelectedDisplay(self):
From barton at grass.itc.it Sat Apr 14 07:09:28 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sat Apr 14 07:09:30 2007
Subject: [grass-addons] r495 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704140509.l3E59SW2000814@grass.itc.it>
Author: barton
Date: 2007-04-14 07:09:19 +0200 (Sat, 14 Apr 2007)
New Revision: 495
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
Error trapping improved.
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-14 01:36:11 UTC (rev 494)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-14 05:09:19 UTC (rev 495)
@@ -757,7 +757,7 @@
if type( porf[ 'wxId' ] ) == type( 1 ) and porf['wxId'] == myId:
porf[ 'value' ] = me.GetValue()
self.updateStatusLine()
-
+
def createCmd(self, ignoreErrors = False):
"""Produce a command line string for feeding into GRASS.
@@ -834,7 +834,7 @@
else:
get_dcmd = completed[0]
layer = completed[1]
- dcmd_params.update(completed[2])
+ if completed[2]: dcmd_params.update(completed[2])
cmdlst = cmd.split(' ')
if parentframe != -1:
From barton at grass.itc.it Sat Apr 14 07:10:24 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sat Apr 14 07:10:26 2007
Subject: [grass-addons] r496 - trunk/grassaddons/gui
Message-ID: <200704140510.l3E5AOHD000835@grass.itc.it>
Author: barton
Date: 2007-04-14 07:10:16 +0200 (Sat, 14 Apr 2007)
New Revision: 496
Modified:
trunk/grassaddons/gui/wxgui.py
Log:
Select multiple layers to delete
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-14 05:09:19 UTC (rev 495)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-14 05:10:16 UTC (rev 496)
@@ -529,7 +529,10 @@
"""
Delete selected map display layer in GIS Manager tree widget
"""
- self.curr_page.maptree.Delete(self.curr_page.maptree.GetSelection())
+ for layer in self.curr_page.maptree.GetSelections():
+ if self.curr_page.maptree.layertype[layer] == 'group':
+ self.curr_page.maptree.DeleteChildren(layer)
+ self.curr_page.maptree.Delete(layer)
#Misc methods
def onCloseWindow(self, event):
From barton at grass.itc.it Sat Apr 14 07:27:34 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sat Apr 14 07:27:36 2007
Subject: [grass-addons] r497 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704140527.l3E5RYFw001150@grass.itc.it>
Author: barton
Date: 2007-04-14 07:27:26 +0200 (Sat, 14 Apr 2007)
New Revision: 497
Modified:
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Improved management of selected/unselected items.
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-14 05:10:16 UTC (rev 496)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-14 05:27:26 UTC (rev 497)
@@ -39,7 +39,7 @@
size=wx.DefaultSize, style=wx.SUNKEN_BORDER,
ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT|
- CT.TR_EDIT_LABELS, idx=None, gismgr=None, notebook=None):
+ CT.TR_EDIT_LABELS|CT.TR_MULTIPLE, idx=None, gismgr=None, notebook=None):
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style,ctstyle)
self.SetAutoLayout(True)
@@ -170,6 +170,8 @@
self.first = True
params = {} # no initial options parameters
+ if self.layer_selected: self.SelectItem(self.layer_selected, select=False)
+
if type == 'command':
# generic command layer
self.ctrl = wx.TextCtrl(self, id=wx.ID_ANY, value='',
@@ -314,6 +316,8 @@
self.Map.delLayer(item=layer)
self.layertype.pop(layer)
+ self.Unselect()
+ self.layer_selected = None
def onLayerChecked(self, event):
layer = event.GetItem()
@@ -372,10 +376,12 @@
def onBeginDrag(self, event):
""" Drag and drop of single tree nodes
"""
- self.drag = True
+
# node cannot be a parent
if self.GetChildrenCount(event.GetItem()) == 0:
event.Allow()
+ self.drag = True
+ self.DoSelectItem(event.GetItem(), unselect_others=True)
# save everthing associated with item to drag
self.dragItem = event.GetItem()
From neteler at grass.itc.it Sat Apr 14 07:35:34 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Sat Apr 14 07:35:38 2007
Subject: [grass-addons] r498 - in trunk/grassaddons: . grassflyer
grassflyer/flyer1 grassflyer/flyer1/pix
Message-ID: <200704140535.l3E5ZY8x001209@grass.itc.it>
Author: neteler
Date: 2007-04-14 07:35:33 +0200 (Sat, 14 Apr 2007)
New Revision: 498
Added:
trunk/grassaddons/grassflyer/
trunk/grassaddons/grassflyer/README
trunk/grassaddons/grassflyer/flyer1/
trunk/grassaddons/grassflyer/flyer1/Makefile
trunk/grassaddons/grassflyer/flyer1/grassflyer.tex
trunk/grassaddons/grassflyer/flyer1/leaflet.cls
trunk/grassaddons/grassflyer/flyer1/pix/
trunk/grassaddons/grassflyer/flyer1/pix/OSGeo_CMYK.pdf
trunk/grassaddons/grassflyer/flyer1/pix/grasslogo_vector.pdf
trunk/grassaddons/grassflyer/flyer1/pix/isodist.png
trunk/grassaddons/grassflyer/flyer1/pix/ndvi.png
trunk/grassaddons/grassflyer/flyer1/pix/trento3d.pdf
trunk/grassaddons/grassflyer/flyer1/pix/visibility.png
Log:
GRASS Flyer 1
Added: trunk/grassaddons/grassflyer/README
===================================================================
--- trunk/grassaddons/grassflyer/README (rev 0)
+++ trunk/grassaddons/grassflyer/README 2007-04-14 05:35:33 UTC (rev 498)
@@ -0,0 +1,6 @@
+GRASS Flyer
+
+Contact:
+Malte Halbey-Martin (GRASS Promotion Manager)
+
+
Added: trunk/grassaddons/grassflyer/flyer1/Makefile
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/Makefile (rev 0)
+++ trunk/grassaddons/grassflyer/flyer1/Makefile 2007-04-14 05:35:33 UTC (rev 498)
@@ -0,0 +1,19 @@
+vectoreps := $(wildcard *.eps)
+vectorfinal := $(patsubst %.eps,%.pdf,$(vectoreps))
+
+default: grassflyer.pdf
+
+$(vectorfinal): $(vectoreps)
+ eps2eps -sOutputFile=- $< | epstopdf -f
+
+%.pdf: %.tex
+ pdflatex $<
+ pdflatex $<
+
+clean:
+ rm -f *.aux *.log *.out
+
+distclean: clean
+ rm -f *.pdf
+
+.PHONY: clean distclean default
Added: trunk/grassaddons/grassflyer/flyer1/grassflyer.tex
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/grassflyer.tex (rev 0)
+++ trunk/grassaddons/grassflyer/flyer1/grassflyer.tex 2007-04-14 05:35:33 UTC (rev 498)
@@ -0,0 +1,198 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%GRASS PROMOTION FLYER %
+%(c) 2007 GRASS PROMOTION TEAM %
+%GNU Free Documentation License %
+%Version 1.2 %
+%Needs leaflet.cls %
+%www.ctan.org/tex-archive/macros/latex/contrib/leaflet/%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%Sometimes printing engines need the 2nd side upside down
+%in this case, use tumble (which is default) instead of notumble
+%If this causes problems, use notumble
+%If you need a foldmark, delete nofoldmark
+\documentclass[notumble,a4paper,10pt,nofoldmark]{leaflet}
+\usepackage{helvet,courier,xcolor}
+
+% Set Helvetica as the default font
+\renewcommand*\familydefault\sfdefault
+% Let LaTeX knows that pictures are found in ./pix
+\graphicspath{{pix/}}
+
+% Setting up things for the captions
+\usepackage{caption}[2004/07/16]
+\captionsetup{%
+ font={small,it},%
+ labelformat=empty,% Leaves out label: ``Figure 1''
+ labelsep=none,%
+ aboveskip=0pt%
+}
+% Defining a new 'figure' environment for the document
+\newenvironment{myfig}[1][0pt plus 1.5ex minus .5ex]{\par\vspace*{#1}\begin{minipage}{\textwidth}\centering}{\end{minipage}}
+
+% Defining the GRASS homepage
+\newcommand{\GRASSurl}{\url{http://grass.itc.it}}
+
+% Define a color for the URIs
+\definecolor{darkblue}{RGB}{0,0,88}
+
+\usepackage{hyperref}
+% Setting up some document info
+\hypersetup{%
+ colorlinks=true,%
+ urlcolor=darkblue,% Redefine this color to change URIs color
+ pdfauthor={The GRASS Community},%
+ pdftitle={GRASS GIS: Efficiency through Freedom \& Transparency},%
+ pdfsubject={GRASS Promotion Flyer},%
+ breaklinks=true,%
+ plainpages=false%
+}
+
+% Title page stuff
+\title{\textbf{\huge GRASS GIS}\\%
+\textsl{Efficiency through Freedom \& Transparency}}
+\author{The GRASS Community}
+\date{\includegraphics[width=\textwidth]{grasslogo_vector}\\[2ex]
+\large\GRASSurl}
+
+\begin{document}
+
+\maketitle
+\thispagestyle{empty}% Necessary to leave out the page number on the first page
+
+\newpage
+
+\section{What is GRASS}
+
+GRASS (Geographic Resources Analysis Support System) is a free and Open Source Software for performing spatial analysis. It consists of more than 350 modules for processing vector (2D/3D), raster and voxel data. Many interfaces to other programs in related domains like geostatistics, databases, mapserver and even other GIS software exist. It is the largest Open Source GIS. It can serve as a Desktop GIS and as the backbone of a complete GIS Infrastructure.
+
+\section{Where is GRASS used}
+
+GRASS is used in scientific applications, commercial settings and by public authorities all over the world. GRASS has shown strong potential for solving geospatial problems in numerous situations world-wide.
+
+\section{History}
+
+GRASS was originally developed in the beginning of the 1980's by the US Army Construction Engineering Research Laboratories (USA-CERL) and was published as public domain software. When the USA-CERL withdrew from GRASS development, an international developer team took over this work. Since 1999, GRASS has been published as free software under the terms of the GNU General Public Licence.
+\begin{myfig}[1.5ex]
+\includegraphics[width=0.7\textwidth]{visibility}
+\captionof{figure}{Viewshed analysis performed with GRASS}
+\end{myfig}
+
+\section{Open Source Philosophy}
+
+The Open Source philosophy provides the user the ability to see the source code and structure of the program which offers a great transparency. Users can extend the program for their own needs. Immediate souce code peer review increases the quality. With the help of the extension manager new modules can be created without GRASS package source code.
+
+\section{Technical Data Sheet}
+
+\subsection{License}
+
+GNU General Public License (Free Software Foundation)
+
+\subsection{Supported platforms}
+
+GRASS runs on nearly all platforms. It supports GNU/Linux, Posix compliant Unix Systems, MS-Windows and MacOS X.
+
+\subsection{Design}
+
+\begin{itemize}
+\item Modular
+\item Consists of more than 350 modules
+\end{itemize}
+
+\subsection{Programming Languages}
+
+\begin{itemize}
+\item ANSI C
+\item GRASS- SWIG interface
+\item Python for WebGIS applications
+\item Java Version: JGRASS
+\end{itemize}
+
+\subsection{Data Management Capabilities}
+
+\begin{itemize}
+\item Raster / Vector / Voxel data processing
+\item 2D / 3D Raster / Vector modelling
+\item Image manipulation
+\item Vector topology / Network analysis
+\item Geostatistics (Interface to R)
+\end{itemize}
+
+\begin{myfig}[1ex]
+\includegraphics[width=0.7\textwidth]{trento3d}
+\captionof{figure}{A flyby of the city of Trento, Italy}
+\end{myfig}
+
+\section{Supported File Formats}
+
+GRASS supports nearly all common GIS file formats through the use of the GDAL/OGR library. In addition it supports the Open GIS Consortium's Simple Features.
+
+\subsection{Vector File formats}
+ASCII, ARC/INFO ungenerate, ARC/INFO E00, Arc\-View SHAPE, BIL, DLG (U.S.), DXF, DXF3D, GMT, GPS-ASCII USGS-DEM, IDRISI, MOSS, MapInfo MIF, TIGER, VRML, \dots
+
+\subsection{Raster File Formats}
+ASCII, ARC/GRID, E00, GIF, GMT, TIF, PNG, Vis5D, SURFER (.grd),\dots
+\begin{myfig}
+\includegraphics[width=0.7\textwidth]{isodist}
+\captionof{figure}{Default GUI configuration showing GRASS network analysis capabilites}
+\end{myfig}
+
+\subsection{Image File Formats}
+
+CEOS (SAR, SRTM, LANDSAT7 etc.), ERDAS LAN / IMG, HDF, LANDSAT TM/MSS, NHAP aerial photos, SAR, SPOT, \dots
+\begin{myfig}[1.5ex]
+\includegraphics[width=0.7\textwidth]{ndvi}
+\captionof{figure}{Image processing capabilities of GRASS}
+\end{myfig}
+
+\subsection{Database support}
+
+\begin{itemize}
+\item PostgreSQL / PostGIS
+\item MySQL
+\item SQLite
+\item ODBC
+\item DBF
+\end{itemize}
+
+\subsection{Output}
+
+\begin{itemize}
+\item Modules for creating maps
+\item NVIZ for visualization of 2.5D and 3D data (creation of animations \& flybys)
+%\item{GMT export}
+%item{VRML}
+\item VTK, POVray
+\item WebGIS via Mapserver, Python, etc.
+\end{itemize}
+
+\subsection{Interoperability to other GIS- related Software}
+
+\begin{itemize}
+\item Quantum GIS (Free Geodata Viewer and more)
+\item R- Language (Statistics)
+\item Gstat (Geostatistics)
+\item UMN Mapserver (Webmapping)
+\end{itemize}
+
+\section{Where to find more information}
+
+\begin{itemize}
+%\begin{flushleft}
+\item{Project Website: \\\GRASSurl}
+\item{GRASS Wiki: \\\url{http://grass.gdf.hannover.de/wiki}}
+\item{GRASS Promotion Team: \\\url{malte@perlomat.de}}
+\item{GRASS mailing lists: \\\url{http://grass.itc.it/community/support.php}}
+%\end{flushleft}
+\end{itemize}
+
+\vfill
+\section{OSGeo}
+
+GRASS is a founding project of the Open Source Geospatial Foundation which has the aim to create high quality open source geospatial software. For further information visit the OSGeo homepage:
+\begin{center}
+\includegraphics[width=0.8\textwidth]{OSGeo_CMYK}\\
+\url{http://www.osgeo.org}
+\end{center}
+
+\end{document}
Added: trunk/grassaddons/grassflyer/flyer1/leaflet.cls
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/leaflet.cls (rev 0)
+++ trunk/grassaddons/grassflyer/flyer1/leaflet.cls 2007-04-14 05:35:33 UTC (rev 498)
@@ -0,0 +1,503 @@
+%%
+%% This is file `leaflet.cls',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% leaflet.dtx (with options: `class')
+%%
+%% Copyright (C) 2003, 2004
+%% Rolf Niepraschk, Rolf.Niepraschk@ptb.de
+%% Hubert Gaesslein, HubertJG@open.mind.de
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "author-maintained".
+%%
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesClass{leaflet}
+ [2004/12/22 v1.0d LaTeX document class (JS,WaS,RN,HjG)]
+\let\LL@shipout\shipout \let\LL@outputpage\@outputpage
+\let\LL@begindvi\@begindvi \let\LL@@end\@@end
+\@ifundefined{iflandscape}{\newif\iflandscape}{}%
+\@ifundefined{iftumble}{\newif\iftumble}{}%
+\newcommand\LL@debug@info[1]{}%
+\DeclareOption{dvips}{\PassOptionsToPackage{\CurrentOption}{graphics}}
+\DeclareOption{pdftex}{\PassOptionsToPackage{\CurrentOption}{graphics}}
+\DeclareOption{vtex}{\PassOptionsToPackage{\CurrentOption}{graphics}}
+\DeclareOption{dvipdfm}{\PassOptionsToPackage{\CurrentOption}{graphics}}
+\DeclareOption{twoside}{\OptionNotUsed}
+\DeclareOption{twocolumn}{\OptionNotUsed}
+\DeclareOption{landscape}{\landscapetrue}
+\DeclareOption{portrait}{\landscapefalse}
+\DeclareOption{debug}{\let\LL@debug@info\typeout}
+\DeclareOption{nospecialtricks}{%
+ \AtEndOfClass{%
+ \ifLL@combine
+ \let\immediate\@@@immediate\let\write\@@@write
+ \let\openout\@@@openout\let\closeout\@@@closeout
+ \let\special\@@@special\let\@@@exec@outs\relax
+ \fi}}
+\newcommand*\LL@setPaperSize{}
+\DeclareOption{a3paper}{\def\LL@setPaperSize{%
+ \paperwidth=420mm\paperheight=297mm\relax}}%
+\@ifdefinable\ifLL@combine{\newif\ifLL@combine}
+\DeclareOption{combine}{\LL@combinetrue}
+\DeclareOption{nocombine}{\LL@combinefalse}
+\newcommand*\LL@selectOutput{}
+\DeclareOption{frontside}{\def\LL@selectOutput#1#2{#1}}
+\DeclareOption{backside}{\def\LL@selectOutput#1#2{#2}}
+\DeclareOption{bothsides}{\def\LL@selectOutput#1#2{#1#2}}
+\DeclareOption{tumble}{\tumbletrue}
+\DeclareOption{notumble}{\tumblefalse}
+\newcommand*\LL@foldmark{}
+\DeclareOption{foldmark}{%
+ \def\LL@foldmark{%
+ \begingroup
+ \linethickness{\LenToUnit{\foldmarkrule}}%
+ \setlength\@tempdima{\paperheight-\LL@tmargin}%
+ \put(0,\LenToUnit{\@tempdima}){%
+ \line(0,-1){\LenToUnit{\foldmarklength}}}%
+ \endgroup}%
+}
+\DeclareOption{nofoldmark}{\def\LL@foldmark{}}%
+\newcommand*\LL@toomanypages[2]{}
+\DeclareOption{draft}{\PassOptionsToClass{\CurrentOption}{article}%
+ \AtEndOfClass{%
+ \def\LL@toomanypages#1#2{%
+ \ClassWarningNoLine{leaflet}{#1.\MessageBreak#2}}%
+ }%
+}
+\DeclareOption{final}{\PassOptionsToClass{\CurrentOption}{article}%
+ \AtEndOfClass{%
+ \ifLL@combine
+ \def\LL@toomanypages#1#2{%
+ \ClassError{leaflet}{#1}{#2.}}%
+ \else
+ \def\LL@toomanypages#1#2{%
+ \ClassWarningNoLine{leaflet}{#1.\MessageBreak#2}}%
+ \fi
+ }%
+}
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
+\PassOptionsToClass{landscape,a4paper}{article}
+\ExecuteOptions{tumble,foldmark,bothsides,combine,landscape,final}
+\ProcessOptions\relax
+\ifLL@combine
+ \newcommand*\LL@rotate@I{}\newcommand*\LL@rotate@II{}%
+ \iflandscape
+ \def\LL@rotate@I#1{#1}%
+ \iftumble
+ \def\LL@rotate@II#1{\rotatebox[origin=c]{180}{#1}}%
+ \else
+ \def\LL@rotate@II#1{#1}%
+ \fi
+ \else
+ \def\LL@rotate@I#1{\rotatebox[origin=c]{90}{#1}}%
+ \iftumble
+ \def\LL@rotate@II#1{\rotatebox[origin=c]{270}{#1}}%
+ \else
+ \def\LL@rotate@II#1{\rotatebox[origin=c]{90}{#1}}%
+ \fi
+ \fi
+ \def\@@@pending@outs{}\let\@@@immediate\immediate
+ \let\@@@write\write \let\@@@special\special
+ \let\@@@openout\openout \let\@@@closeout\closeout
+ \def\immediate{%
+ \let\write\immediate@write%
+ \let\openout\immediate@openout%
+ \let\closeout\immediate@closeout%
+ \let\special\immediate@special}%
+ \def\reset@immediate{%
+ \let\write\pending@write%
+ \let\openout\pending@openout%
+ \let\closeout\pending@closeout%
+ \let\special\@@@special}%
+ \long\def\pending@write#1#{\pending@@write{#1}}
+ \def\immediate@write{%
+ \reset@immediate\@@@immediate\@@@write}%
+ \def\immediate@openout{%
+ \reset@immediate\@@@immediate\@@@openout}%
+ \def\immediate@closeout{%
+ \reset@immediate\@@@immediate\@@@closeout}%
+ \def\immediate@special{%
+ \reset@immediate\@@@immediate\@@@special}%
+ \let\write\pending@write
+ \let\openout\pending@openout
+ \let\closeout\pending@closeout
+ \def\@dummy@whatsit{\special{}}
+ \begingroup\@ifundefined{pdfoutput}%
+ {\endgroup}
+ {\endgroup
+ \ifnum\pdfoutput>\z@\def\@dummy@whatsit{\pdfliteral{}}\fi}
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname eTeXversion\endcsname\relax
+ %%% Test is from Markus Kohm (d.c.t.t, 29 Jun 2004)
+ \ClassWarningNoLine{leaflet}{%
+ *************************************\MessageBreak
+ * It's very recommended to use eTeX \MessageBreak
+ * with this package! \MessageBreak
+ *************************************}%
+ \long\def\pending@@write#1#2{%
+ \@dummy@whatsit
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@write\number#1{#2},}}%
+ \def\pending@openout#1 {%
+ \@dummy@whatsit
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@openout\number#1,}}%
+ \def\pending@closeout#1{%
+ \@dummy@whatsit
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@closeout\number#1,}}%
+ \newcommand*\@@@exec@outs{%
+ \@@@pending@outs\gdef\@@@pending@outs{}%
+ \LL@debug@info{%
+ >>> execute the output commands of the current page <<<}}%
+ \else
+ \RequirePackage{etex}
+ \globmarks\@@@out@mark
+ \newcounter{@@total@outs}\setcounter{@@total@outs}{0}
+ \newcounter{@@last@exec}\setcounter{@@last@exec}{0}
+ \long\def\pending@@write#1#2{%
+ \global\advance\c@@@total@outs\@ne%
+ \marks\@@@out@mark{\the\c@@@total@outs}%
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@write\number#1{#2},}}%
+\def\pending@openout#1 {%
+ \global\advance\c@@@total@outs\@ne%
+ \marks\@@@out@mark{\the\c@@@total@outs}%
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@openout\number#1,}}%
+\def\pending@closeout#1{%
+ \global\advance\c@@@total@outs\@ne%
+ \marks\@@@out@mark{\the\c@@@total@outs}%
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@closeout\number#1,}}%
+ \newcommand*\@@@exec@outs{%
+ \begingroup
+ \@tempcntb\c@@@total@outs\advance\@tempcntb-\c@@@last@exec%
+ \edef\reserved@a{\botmarks\@@@out@mark}%
+ \ifx\reserved@a\@empty\@tempcnta\z@\else\@tempcnta\reserved@a\fi%
+ \LL@debug@info{PENDING-OUTS:\the\@tempcntb\space\space
+ TOTAL-OUTS:\the\c@@@total@outs\space\space
+ LAST-EXEC:\the\c@@@last@exec\space\space
+ TOPMARK:\topmarks\@@@out@mark\space\space
+ FIRSTMARK:\firstmarks\@@@out@mark\space\space
+ BOTMARK:\botmarks\@@@out@mark}%
+ \advance\@tempcnta-\c@@@total@outs \advance\@tempcntb\@tempcnta
+ \@tempcnta-\@tempcnta%
+ \ifnum\@tempcnta>\z@
+ \LL@debug@info{%
+ >>> resave \the\@tempcnta\space output command(s).
+ Too early to execute! <<<}%
+ \fi
+ \@tempcnta\z@ \def\reserved@b{}%
+ \@for\reserved@a :=\@@@pending@outs\do{%
+ \ifx\reserved@a\@empty\else
+ \ifnum\@tempcnta<\@tempcntb%
+ \reserved@a% execute output's related to the current page box.
+ \global\advance\c@@@last@exec\@ne
+ \LL@debug@info{>>> execute output command number
+ \the\c@@@last@exec\space<<<}%
+ \else
+ \expandafter\g@addto@macro\expandafter\reserved@b\expandafter{%
+ \reserved@a,}%
+ \fi
+ \advance\@tempcnta\@ne%
+ \fi}%
+ \expandafter\@temptokena\expandafter{\reserved@b}%
+ \xdef\@@@pending@outs{\the\@temptokena}%
+ \endgroup}%
+ \fi% end of eTeX test.
+ \long\def\protected@write#1#2#3{%
+ \begingroup
+ \let\thepage\relax
+ #2%
+ \let\protect\@unexpandable@protect
+ \edef\reserved@a{\noexpand\write#1{#3}}%
+ \reserved@a%
+ \endgroup
+ \if@nobreak\ifvmode\nobreak\fi\fi}%
+ \def\shipout{\deadcycles\z@\setbox\@tempboxa=}
+ \let\@begindvi\@empty
+\fi% end of \ifLL@combine
+\LoadClass{article}
+\RequirePackage{everyshi,calc,graphicx}
+\newcommand*\LL@pagesize@specials[2]{}
+\@ifundefined{Gin@driver}{}%
+{%
+ \ifx\Gin@driver\@empty\else%
+ \filename@parse{\Gin@driver}\@tempswafalse%
+ \def\reserved@a{dvips}%
+ \ifx\filename@base\reserved@a\@tempswatrue\fi%
+ \def\reserved@a{dvipdfm}%
+ \ifx\filename@base\reserved@a\@tempswatrue\fi%
+ \if@tempswa%
+ \ClassInfo{leaflet}{Generating code for dvips}%
+ \def\LL@pagesize@specials#1#2{%
+ \@tempdima=#1\@tempdimb=#2%
+ \AtBeginDvi{\special{papersize=\the\@tempdima,\the\@tempdimb}}}%
+ \fi%
+ \def\reserved@a{pdftex}%
+ \ifx\filename@base\reserved@a
+ \ClassInfo{leaflet}{Generating code for pdfTeX}%
+ \def\LL@pagesize@specials#1#2{%
+ \@tempdima=#1\@tempdimb=#2%
+ \pdfpagewidth\@tempdima\pdfpageheight\@tempdimb}%
+ \fi%
+ \def\reserved@a{vtex}%
+ \ifx\filename@base\reserved@a
+ \ClassInfo{leaflet}{Generating code for VTeX}%
+ \def\LL@pagesize@specials#1#2{%
+ \@tempdima=#1\@tempdimb=#2%
+ \mediawidth\@tempdima\mediaheight\@tempdimb}%
+ \fi%
+ \fi
+}
+\newcommand*\LL@CmdIgnored[1]{%
+ \ClassWarning{leaflet}{%
+ `\string#1' ignored}}
+\setlength{\parskip}{1ex plus 2pt}
+\@listi%
+\setlength{\labelwidth}{\leftmargin}
+\addtolength{\labelwidth}{-\labelsep}
+\pagestyle{empty}
+\headheight\z@
+\headsep\z@
+\footskip\z@
+\marginparwidth\z@
+\marginparsep\z@
+\sloppy
+\setcounter{secnumdepth}{0}
+\renewcommand\twocolumn[1][]{\LL@CmdIgnored{\twocolumn}}
+\renewcommand\onecolumn{\LL@CmdIgnored{\onecolumn}}
+\renewcommand\topfraction{0.7}
+\renewcommand\bottomfraction{0.7}
+\setlength{\textfloatsep}{10pt plus 4pt minus 3pt}
+\setlength{\parindent}{\z@}
+\setlength{\leftmargini}{1.5em}
+\setlength{\leftmarginii}{1.5em}
+\setlength{\leftmarginiii}{1.5em}
+\setlength{\leftmarginiv}{1.5em}
+\setlength{\leftmarginv}{1.5em}
+\setlength{\leftmarginvi}{1.5em}
+\setlength{\labelsep}{.5em}
+\setlength \labelwidth{\leftmargini}
+\addtolength\labelwidth{-\labelsep}
+\def\noparskip{\par\vspace{-\parskip}}
+\let\old@small\small
+\renewcommand{\small}{\old@small\let\@listi\@listI}
+\let\old@footnotesize\footnotesize
+\renewcommand{\footnotesize}{\old@footnotesize\let\@listi\@listI}
+\newcommand{\sectfont}{\bfseries}
+\renewcommand\section{\@startsection{section}{1}{\z@}%
+ {-3.5ex \@plus -.75ex}%
+ {1ex} %{1.5ex}%
+ {\normalfont\large\sectfont}}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+ {-2.5ex plus -.5ex}%
+ {1\p@} %{1ex}%
+ {\normalfont\normalsize\sectfont}}
+\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
+ {-2.5ex plus -.5ex}%
+ {-1em}%
+ {\normalfont\normalsize\sectfont}}
+\def\part{\LL@CmdIgnored{\part}\secdef\@part\@spart}
+\def\@part[#1]#2{}
+\def\@spart#1{}
+
+\renewcommand*\descriptionlabel[1]{%
+ \hspace\labelsep\normalfont\descfont #1}
+\newcommand*\descfont{\bfseries}
+\iffalse
+\g@addto@macro\enumerate{\parsep2\p@\@plus2\p@\@minus\z@}
+\g@addto@macro\itemize{\parsep2\p@\@plus2\p@\@minus\z@}
+\g@addto@macro\description{\parsep2\p@\@plus2\p@\@minus\z@}
+\else
+\newcommand*\LL@listsetup{%
+ \parsep1ex\@plus.5ex\@minus.25ex%
+ \LL@debug@info{***parsep=\the\parsep}%
+ \itemsep\z@
+ \LL@debug@info{***itemsep=\the\itemsep}%
+ \topsep\z@
+ \LL@debug@info{***topsep=\the\topsep}%
+ \LL@debug@info{***partopsep=\the\partopsep}%
+}
+\def\enumerate{%
+ \ifnum \@enumdepth >\thr@@\@toodeep\else
+ \advance\@enumdepth\@ne
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
+ \expandafter
+ \list
+ \csname label\@enumctr\endcsname
+ {\usecounter\@enumctr
+ \def\makelabel##1{\hss\llap{##1}}%
+ %\def\makelabel##1{##1\hfill}%
+ %\def\makelabel##1{\hss##1}%
+ \LL@listsetup
+ }%
+ \fi}
+\def\itemize{%
+ \ifnum \@itemdepth >\thr@@\@toodeep\else
+ \advance\@itemdepth\@ne
+ \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
+ \expandafter
+ \list
+ \csname\@itemitem\endcsname
+ {%
+ \def\makelabel##1{\hss\llap{##1}}%
+ %\def\makelabel##1{##1\hfill}%
+ %\def\makelabel##1{\hss##1}%
+ \LL@listsetup
+ }%
+ \fi}
+\renewenvironment{description}
+ {\list{}{\labelwidth\z@ \itemindent-\leftmargin
+ \let\makelabel\descriptionlabel
+ \LL@listsetup}}
+ {\endlist}
+\fi
+\newcommand*\setmargins[4]{%
+ \setlength\topmargin{#1}%
+ \edef\LL@tmargin{\the\topmargin}%
+ \setlength\evensidemargin{#2}%
+ \setlength\textheight{%
+ \paperheight-\topmargin-\evensidemargin%
+ -\headheight-\headsep-\footskip}%
+ \setlength\oddsidemargin{#3}%
+ \setlength\evensidemargin{#4}%
+ \setlength\textwidth{%
+ \paperwidth-\oddsidemargin-\evensidemargin-\marginparwidth-\marginparsep}%
+ \addtolength\topmargin{-1in}%
+ \addtolength\oddsidemargin{-1in}%
+ \evensidemargin\oddsidemargin%
+}
+\LL@setPaperSize
+\paperwidth=0.333333334\paperwidth
+\setmargins{11mm}{11mm}{8mm}{8mm}
+\newcommand*\foldmarkrule{0.4pt}
+\newcommand*\foldmarklength{2mm}
+\newcommand\AddToBackground{%
+ \@ifstar{\@tempswatrue\LL@AddToBackground}
+ {\@tempswafalse\LL@AddToBackground}}
+\@onlypreamble\AddToBackground
+\newcommand\LL@AddToBackground[2]{%
+ \if@tempswa\def\@tempa{LL@largePic}\else\def\@tempa{LL@smallPic}\fi
+ \expandafter\providecommand\csname\@tempa\@Roman{#1}\endcsname{}%
+ \expandafter\g@addto@macro\csname\@tempa\@Roman{#1}\endcsname{#2}}
+\newcommand\LenToUnit[1]{#1\@gobble}
+\newcommand*\CutLine{%
+ \@ifstar{\@tempswatrue\LL@CutLine}{\@tempswafalse\LL@CutLine}}
+\@onlypreamble\CutLine
+\newcommand*\LL@CutLine[1]{%
+ \ifLL@combine
+ \ifx\Scissors\@empty\@tempswatrue\fi
+ \if@tempswa
+ \AddToBackground{#1}{%
+ \put(0,0){%
+ \rotatebox{90}{\makebox(\LenToUnit{\paperheight},0){%
+ \normalsize
+ \dotfill}}}}%
+ \else
+ \AddToBackground{#1}{%
+ \put(0,0){%
+ \rotatebox{90}{\makebox(\LenToUnit{\paperheight},0){%
+ \normalsize
+ \dotfill\Scissors\dotfill\dotfill\Scissors\dotfill}}}}%
+ \fi
+ \fi}
+\IfFileExists{pifont.sty}
+ {\RequirePackage{pifont}%
+ \newcommand*\Scissors{\raisebox{-0.85ex}{\large\ding{34}}}}%
+ {\newcommand*\Scissors{}}
+\AddToBackground{3}{\LL@foldmark}
+\providecommand*\vb@xt@{\vbox to}
+\AtBeginDocument{\EveryShipout{\LL@savePage}}
+\newcounter{LL@page}\setcounter{LL@page}{1}
+\newcommand\LL@tempa{}
+\newcommand*\LL@savePage{%
+ \ifnum\c@LL@page<7\relax
+ \setbox\@cclv\vbox{%
+ \vbox{\@tempdima=1in\relax
+ \@tempdimb=\paperheight\advance\@tempdimb-\@tempdima
+ \pictur@(0,0)(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimb})%
+ \begingroup
+ \set@typeset@protect
+ \@nameuse{LL@smallPic\Roman{LL@page}}%
+ %\set@display@protect
+ \endgroup
+ \endpicture}%
+ \nointerlineskip\box\@cclv}%
+ \ifLL@combine
+ \@@@exec@outs
+ \expandafter\newsavebox\csname LL@box\Roman{LL@page}\endcsname%
+ \setbox\@cclv=\vbox{\vskip1in\unvbox\@cclv}%
+ \setbox\@cclv=\vbox{\moveright1in\box\@cclv}%
+ \setbox\@cclv=\hb@xt@\paperwidth{\box\@cclv\hss}%
+ \setbox\@cclv=\vb@xt@\paperheight{\box\@cclv\vss}%
+ \global\expandafter\setbox%
+ \csname LL@box\Roman{LL@page}\endcsname=\box\@cclv%
+ \typeout{\@spaces[\the\c@LL@page] ==> [\Roman{LL@page}]}%
+ \fi
+ \fi
+ \ifnum\c@LL@page=7\relax
+ \begingroup
+ \set@typeset@protect
+ \LL@toomanypages{%
+ The text you supplied fills more than six pages\MessageBreak
+ and will therefore not fit onto a single flyer}{%
+ Try using smaller fonts or reducing vertical space}%
+ \endgroup
+ \fi
+ \stepcounter{LL@page}}
+\ifLL@combine
+ \def\@@end{%
+ \clearpage\pagestyle{empty}%
+ \let\@outputpage\LL@outputpage
+ \def\@EveryShipout@Hook{}%
+ \def\@EveryShipout@AtNextHook{}%
+ \EveryShipout{\LL@savePage}%
+ \loop\ifnum\c@LL@page<7\relax
+ \ClassInfo{leaflet}{Generating empty page \the\c@page}%
+ \null\newpage
+ \repeat
+ \let\shipout\LL@shipout \let\@begindvi\LL@begindvi
+ \paperwidth=3\paperwidth
+ \iflandscape
+ \LL@pagesize@specials{\paperwidth}{\paperheight}%
+ \else
+ \LL@pagesize@specials{\paperheight}{\paperwidth}%
+ \fi
+ \newcommand*\LL@shipoutPage[1]{%
+ \let \protect \noexpand
+ \shipout\vb@xt@\paperheight{%
+ \set@typeset@protect
+ \vskip-1in%
+ \@begindvi\hb@xt@\paperwidth{\hskip-1in##1\hss}\vss}}%
+ \newcommand*\LL@preparePages[3]{%
+ \typeout{[\@Roman{##1}\space\@Roman{##2}\space\@Roman{##3}] ==>}%
+ \pictur@(0,0)\@nameuse{LL@largePic\Roman{page}}\endpicture%
+ \LL@preparePage{##1}\LL@preparePage{##2}\LL@preparePage{##3}}%
+ \newcommand*\LL@preparePage[1]{%
+ \expandafter\box\csname LL@box\@Roman{##1}\endcsname}%
+ \LL@selectOutput
+ {\setcounter{page}{1}%
+ \LL@shipoutPage{\LL@rotate@I{\LL@preparePages{5}{6}{1}}}}%
+ {\setcounter{page}{2}%
+ \LL@shipoutPage{\LL@rotate@II{\LL@preparePages{2}{3}{4}}}}%
+ \LL@@end
+ }%
+\else
+ \LL@pagesize@specials{\paperwidth}{\paperheight}%
+ \AtEndDocument{%
+ \clearpage\pagestyle{empty}%
+ \loop\ifnum\c@LL@page<7\relax
+ \ClassInfo{leaflet}{Generating empty page \the\c@page}%
+ \null\newpage
+ \repeat
+ }
+\fi
+\endinput
+%%
+%% End of file `leaflet.cls'.
Added: trunk/grassaddons/grassflyer/flyer1/pix/OSGeo_CMYK.pdf
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/grassflyer/flyer1/pix/OSGeo_CMYK.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/grassflyer/flyer1/pix/grasslogo_vector.pdf
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/grassflyer/flyer1/pix/grasslogo_vector.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/grassflyer/flyer1/pix/isodist.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/grassflyer/flyer1/pix/isodist.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/grassflyer/flyer1/pix/ndvi.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/grassflyer/flyer1/pix/ndvi.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/grassflyer/flyer1/pix/trento3d.pdf
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/grassflyer/flyer1/pix/trento3d.pdf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/grassflyer/flyer1/pix/visibility.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/grassflyer/flyer1/pix/visibility.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
From calvelo at grass.itc.it Sat Apr 14 08:02:03 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Sat Apr 14 08:02:05 2007
Subject: [grass-addons] r499 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704140602.l3E623Vv002399@grass.itc.it>
Author: calvelo
Date: 2007-04-14 08:01:34 +0200 (Sat, 14 Apr 2007)
New Revision: 499
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
Added self-testing in standalone: call with 'test' as command. Still far from complete.
Started refactoring so that menuform becomes usable from something like a qgisgrass-style toolbox:
- added hidden fields, for preset values
- factored out xml parsing from task description, so as to feed arbitrary task descritions
- added error handling for missing fields in the params and flags structure: only name and description are now compulsory
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-14 05:35:33 UTC (rev 498)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-14 06:01:34 UTC (rev 499)
@@ -36,6 +36,7 @@
import wx
import sys
+import re
import string
import textwrap
import select
@@ -55,17 +56,15 @@
gettext.install("wxgrass")
sys.path.append(os.path.join(os.getenv("GISBASE"),"etc","wx"))
+imagepath = os.path.join(os.getenv("GISBASE"),"etc","wx","images")
+sys.path.append(imagepath)
+
try:
import subprocess
except:
from compat import subprocess
-import re
-imagepath = os.getenv("GISBASE") + "/etc/wx/images/"
-#imagepath = os.sep.join( os.getcwd().split(os.sep) [:-1] + ['images'] )
-sys.path.append(imagepath)
-
def reexec_with_pythonw():
if sys.platform == 'darwin' and\
not sys.executable.endswith('MacOS/Python'):
@@ -110,9 +109,12 @@
for c in range(0,len(t_rgb)):
str2rgb[ t_color[c] ] = t_rgb[ c ]
rgb2str[ t_rgb[ c ] ] = t_color[ c ]
+del t_colors
+del t_color
+del t_rgb
def color_resolve(color):
- if color[0] in "0123456789":
+ if len(color)>0 and color[0] in "0123456789":
rgb = tuple(map(int,color.split( ':' )))
label = color
else:
@@ -122,7 +124,7 @@
label = color
except KeyError:
rgb = (200,200,200)
- label = 'Select Color'
+ label = _('Select Color')
return (rgb, label)
@@ -159,7 +161,7 @@
"""This class holds the structures needed for both filling by the parser and
use by the interface constructor."""
def __init__(self):
- self.name = 'unknown'
+ self.name = _('unknown')
self.params = []
self.description = ''
self.flags = []
@@ -323,9 +325,8 @@
contents.append( l )
self.SetPage( "".join( contents ) )
self.Ok = True
- except:
+ except: # The Manual file was not found
self.Ok = False
- raise
class mainFrame(wx.Frame):
@@ -354,12 +355,12 @@
self.SetIcon(wx.Icon(os.path.join(imagepath,'grass.form.gif'), wx.BITMAP_TYPE_ANY))
menu = wx.Menu()
- menu.Append(wx.ID_ABOUT, "&About GrassGUI",
- "Information about GrassGUI")
- menu.Append(ID_ABOUT_COMMAND, "&About " + self.task.name,
- "Short descripton of GRASS command " + self.task.name)
+ menu.Append(wx.ID_ABOUT, _("&About GrassGUI"),
+ _("Information about GrassGUI") )
+ menu.Append(ID_ABOUT_COMMAND, _("&About %s") % self.task.name,
+ _("Short descripton of GRASS command %s") % self.task.name)
menu.AppendSeparator()
- menu.Append(wx.ID_EXIT, "E&xit", "Terminate the program")
+ menu.Append(wx.ID_EXIT, _("E&xit"), _("Terminate the program") )
menuBar = wx.MenuBar()
menuBar.Append(menu, "&File");
@@ -466,7 +467,7 @@
wx.TheClipboard.UsePrimarySelection(True)
wx.TheClipboard.SetData(cmddata)
wx.TheClipboard.Close()
- self.SetStatusText("'%s' copied to clipboard" %\
+ self.SetStatusText( _("'%s' copied to clipboard") %\
(self.createCmd(ignoreErrors=True)))
def OnCancel(self, event):
@@ -476,10 +477,10 @@
self.Destroy()
def OnAbout(self, event):
- dlg = wx.MessageDialog(self, "This is a sample program for\n"
+ dlg = wx.MessageDialog(self, _("This is a sample program for\n"
"GRASS command interface parsing\n"
- "and automatic GUI building. \n%s" %(__version__),
- "About GrassGUI", wx.OK | wx.ICON_INFORMATION)
+ "and automatic GUI building. \n%s") %(__version__),
+ _("About GrassGUI"), wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
@@ -503,19 +504,19 @@
self.task = task
# Determine tab layout
- sections = ['Main']
+ sections = [ _('Main') ]
is_section = {}
for task in self.task.params + self.task.flags:
if not task.has_key('guisection') or task['guisection']=='':
task['guisection'] = 'Options'
if not is_section.has_key(task['guisection']):
is_section[task['guisection']] = 1
- if task['guisection'] != 'Main': # check for pre-existing parameters passed from layer tree
+ if task['guisection'] != _('Main'): # check for pre-existing parameters passed from layer tree
sections.append( task['guisection'] )
there_is_main = False
for i in self.task.params+self.task.flags:
if i.has_key('required') and i['required'] == 'yes':
- i['guisection'] = 'Main'
+ i['guisection'] = _('Main')
there_is_main = True
if not there_is_main:
sections = sections[1:]
@@ -548,23 +549,23 @@
notebook.SetSelection(0)
panelsizer.Add( notebook, 1, flag=wx.EXPAND )
-
- for p in self.task.params:
+ visible_params = [ p for p in self.task.params if not p.get( 'hidden', 'no' ) == 'yes' ]
+ for p in visible_params:
which_sizer = tabsizer[ p['guisection'] ]
which_panel = tab[ p['guisection'] ]
- title = text_beautify(p['description'])
+ title = text_beautify( p['description'] )
text_style = wx.FONTWEIGHT_BOLD
txt = None
- if p['required'] == 'no':
+ if p.get('required','no') == 'no':
text_style = wx.FONTWEIGHT_NORMAL
- if p['multiple'] == 'yes' and len( p['values'] ) == 0:
+ if p.get('multiple','no') == 'yes' and len( p.get('values','') ) == 0:
title = _("[multiple]") + " " + title
- if p[ 'value'] == '' :
- p['value'] = p['default']
- if (len(p['values']) > 0):
+ if p.get('value','') == '' :
+ p['value'] = p.get('default','')
+ if ( len(p.get('values',[]) ) > 0):
- valuelist=map(str,p['values'])
- if p['multiple'] == 'yes':
+ valuelist=map(str,p.get('values',[]))
+ if p.get('multiple','no') == 'yes':
txt = wx.StaticBox(which_panel,0,title+":")
hSizer=wx.StaticBoxSizer( txt, wx.VERTICAL )
isDefault = {}
@@ -581,12 +582,12 @@
chkbox.Bind(wx.EVT_CHECKBOX, self.OnCheckBoxMulti)
which_sizer.Add( hSizer, 0, wx.ADJUST_MINSIZE, 5)
elif len(valuelist) == 1:
- txt = wx.StaticText(which_panel, label = title +
- '. Valid range=' + str(valuelist).strip("[]'") + ':' )
+ txt = wx.StaticText(which_panel,
+ label = _('%s. Valid range=%s') % (title, str(valuelist).strip("[]'") + ':' ) )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
- txt2 = wx.TextCtrl(which_panel, value = p['default'],
+ txt2 = wx.TextCtrl(which_panel, value = p.get('default',''),
size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
- if p['value'] != '': txt2.SetValue(p['value']) # parameter previously set
+ if p.get('value','') != '': txt2.SetValue(p['value']) # parameter previously set
which_sizer.Add( txt2, 0, wx.ADJUST_MINSIZE, 5)
p['wxId'] = txt2.GetId()
@@ -594,48 +595,50 @@
else:
txt = wx.StaticText(which_panel, label = title + ':' )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
- cb = wx.ComboBox(which_panel, -1, p['default'],
+ cb = wx.ComboBox(which_panel, -1, p.get('default',''),
wx.Point(-1, -1), wx.Size(STRING_ENTRY_WIDTH, -1),
valuelist, wx.CB_DROPDOWN)
- if p['value'] != '': cb.SetValue(p['value']) # parameter previously set
+ if p.get('value','') != '': cb.SetValue(p['value']) # parameter previously set
which_sizer.Add( cb, 0, wx.ADJUST_MINSIZE, 5)
p['wxId'] = cb.GetId()
cb.Bind( wx.EVT_COMBOBOX, self.OnSetValue)
# text entry
- if (p['type'] in ('string','integer','float')
- and len(p['values']) == 0
- and p['gisprompt'] == False
- and p['prompt'] != 'color'):
+ if (p.get('type','string') in ('string','integer','float')
+ and len(p.get('values',[])) == 0
+ and p.get('gisprompt',False) == False
+ and p.get('prompt','') != 'color'):
txt = wx.StaticText(which_panel, label = title + ':' )
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
- txt3 = wx.TextCtrl(which_panel, value = p['default'],
+ txt3 = wx.TextCtrl(which_panel, value = p.get('default',''),
size = (STRING_ENTRY_WIDTH, ENTRY_HEIGHT))
- if p['value'] != '': txt3.SetValue(p['value']) # parameter previously set
+ if p.get('value','') != '': txt3.SetValue(p['value']) # parameter previously set
which_sizer.Add( txt3, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
p['wxId'] = txt3.GetId()
txt3.Bind(wx.EVT_TEXT, self.OnSetValue)
- if p['type'] == 'string' and p['gisprompt'] == True:
+ if p.get('type','string') == 'string' and p.get('gisprompt',False) == True:
txt = wx.StaticText(which_panel, label = title + ':')
which_sizer.Add(txt, 0, wx.ADJUST_MINSIZE | wx.ALL, 5)
# element selection tree combobox (maps, icons, regions, etc.)
- if p['prompt'] != 'color':
+ if p.get('prompt','') != 'color':
selection = select.Select(which_panel, id=wx.ID_ANY, size=(300,-1),
- type=p['element'])
- if p['value'] != '': selection.SetValue(p['value']) # parameter previously set
+ type=p.get('element','') )
+ if p.get('value','') != '': selection.SetValue(p['value']) # parameter previously set
which_sizer.Add( selection, 0, wx.ADJUST_MINSIZE| wx.ALL, 5)
# A select.Select is a combobox with two children: a textctl and a popupwindow;
# we target the textctl here
p['wxId'] = selection.GetChildren()[0].GetId()
selection.Bind(wx.EVT_TEXT, self.OnSetValue)
# color entry
- elif p['prompt'] == 'color':
- if p['default'] != '':
+ elif p.get('prompt','') == 'color':
+ default_color = (200,200,200)
+ label_color = _("Select Color")
+ if p.get('default','') != '':
default_color, label_color = color_resolve( p['default'] )
- if p['value'] != '': # parameter previously set
+ if p.get('value','') != '': # parameter previously set
default_color, label_color = color_resolve( p['value'] )
if "none" in title:
this_sizer = wx.BoxSizer( wx.HORIZONTAL )
@@ -648,8 +651,8 @@
p['wxId'] = [btn_colour.GetId(),]
btn_colour.Bind(csel.EVT_COLOURSELECT, self.OnColorChange )
if "none" in title:
- none_check = wx.CheckBox(which_panel, wx.ID_ANY, "Transparent")
- if p['value'] != '' and p['value'][0] == "none":
+ none_check = wx.CheckBox(which_panel, wx.ID_ANY, _("Transparent") )
+ if p.get('value','') != '' and p.get('value',[''])[0] == "none":
none_check.SetValue(True)
else:
none_check.SetValue(False)
@@ -663,12 +666,13 @@
if txt is not None:
txt.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
- for f in self.task.flags:
+ visible_flags = [ f for f in self.task.flags if not f.get( 'hidden', 'no' ) == 'yes' ]
+ for f in visible_flags:
which_sizer = tabsizer[ f['guisection'] ]
which_panel = tab[ f['guisection'] ]
- title = text_beautify(f['description'])
+ title = text_beautify( f['description'] )
chk = wx.CheckBox(which_panel,-1, label = title, style = wx.NO_BORDER)
- if 'value' in f: chk.SetValue(f['value'])
+ if 'value' in f: chk.SetValue( f['value'] )
chk.SetFont( wx.Font( 12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, text_style, 0, ''))
which_sizer.Add( chk, 0, wx.EXPAND| wx.ALL, 5)
f['wxId'] = chk.GetId()
@@ -692,7 +696,7 @@
manual_tab.SetMinSize( constrained_size )
self.SetSizer( panelsizer )
- self.hasMain = tab.has_key( 'Main' ) # publish, to enclosing Frame for instance
+ self.hasMain = tab.has_key( _('Main') ) # publish, to enclosing Frame for instance
def OnPageChange(self, event):
@@ -701,7 +705,7 @@
def OnColorChange( self, event ):
myId = event.GetId()
for p in self.task.params:
- if type( p['wxId'] ) == type( [] ) and myId in p['wxId']:
+ if 'wxId' in p and type( p['wxId'] ) == type( [] ) and myId in p['wxId']:
has_button = p['wxId'][1] is not None
if has_button and wx.FindWindowById( p['wxId'][1] ).GetValue() == True:
p[ 'value' ] = 'none'
@@ -730,7 +734,7 @@
me = event.GetId()
theParam = None
for p in self.task.params:
- if type( p['wxId'] ) == type( [] ) and me in p['wxId']:
+ if 'wxId' in p and type( p['wxId'] ) == type( [] ) and me in p['wxId']:
theParam = p
myIndex = p['wxId'].index( me )
# Unpack current value list
@@ -754,7 +758,7 @@
myId = event.GetId()
me = wx.FindWindowById( myId )
for porf in self.task.params + self.task.flags:
- if type( porf[ 'wxId' ] ) == type( 1 ) and porf['wxId'] == myId:
+ if 'wxId' in porf and type( porf[ 'wxId' ] ) == type( 1 ) and porf['wxId'] == myId:
porf[ 'value' ] = me.GetValue()
self.updateStatusLine()
@@ -773,11 +777,11 @@
if 'value' in flag and flag['value']:
cmd += ' -' + flag['name']
for p in self.task.params:
- if p['value'] == '' and p['required'] != 'no':
- cmd += ' ' + p['name'] + '=' + ''
- errStr += "Parameter " + p['name'] + "(" + p['description'] + ") is missing\n"
+ if p.get('value','') == '' and p.get('required','no') != 'no':
+ cmd += ' ' + p['name'] + '=' + _('')
+ errStr += _("Parameter %s (%s) is missing\n") % ( p['name'], p['description'] )
errors += 1
- if p['value'] != '' and p['value'] != p['default'] :
+ if p.get('value','') != '' and p['value'] != p.get('default','') :
cmd += ' ' + p['name'] + '=' + p['value']
if errors and not ignoreErrors:
self.OnError(errStr)
@@ -786,7 +790,7 @@
return cmd
def OnError(self, errMsg):
- dlg = wx.MessageDialog(self, errMsg, "Error", wx.OK | wx.ICON_ERROR)
+ dlg = wx.MessageDialog(self, errMsg, _("Error"), wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
@@ -796,7 +800,7 @@
The DTD must be located in $GISBASE/etx/wx/gui_modules/grass-interface.dtd,
otherwise the parser will not succeed."""
- gmpath = os.getenv("GISBASE") + "/etc/wx/gui_modules"
+ gmpath = os.getenv("GISBASE") + "/etc/wx/gui_modules"
cmd = cmd + r' --interface-description'
cmdout = os.popen(cmd, "r").read()
p = re.compile( '(grass-interface.dtd)')
@@ -806,10 +810,11 @@
class GrassGUIApp(wx.App):
"""Stand-alone GRASS command GUI"""
- def __init__(self, cmd):
- self.grass_task = grassTask()
- handler = processTask(self.grass_task)
- xml.sax.parseString( getInterfaceDescription( cmd ) , handler )
+ def __init__(self, grass_task):
+ self.grass_task = grass_task
+#XXX from pprint import pprint
+# pprint( self.grass_task.params )
+
wx.App.__init__(self)
def OnInit(self):
@@ -841,7 +846,7 @@
self.parent = parentframe
if len(cmdlst) > 1:
- raise ValueError, "usage: %s " % cmdlst[0]
+ raise ValueError, _("usage: %s ") % cmdlst[0]
else:
# parse the interface decription
self.grass_task = grassTask()
@@ -856,11 +861,79 @@
self.mf = mainFrame(self.parent ,-1, self.grass_task, get_dcmd, layer)
self.mf.Show(True)
+
if __name__ == "__main__":
if len(sys.argv) == 1:
- print "Usage: %s " % sys.argv[0]
+ print _("usage: %s ") % sys.argv[0]
sys.exit()
- app = GrassGUIApp(sys.argv[1])
- app.MainLoop()
-
+ if sys.argv[1] != 'test':
+ grass_task = grassTask()
+ handler = processTask(grass_task)
+ xml.sax.parseString( getInterfaceDescription( sys.argv[1] ) , handler )
+ app = GrassGUIApp( grass_task )
+ app.MainLoop()
+ else: #Test
+ task = grassTask()
+ task.name = "TestTask"
+ task.description = "This is a artificial grassTask() object intended for testing purposes"
+ task.params = [
+ {
+ "name" : "text",
+ "description" : "Enter some text"
+ },{
+ "name" : "hidden_text",
+ "description" : "This text should not appear in the form",
+ "hidden" : "yes"
+ },{
+ "name" : "text_default",
+ "description" : "Enter text to override the default",
+ "default" : "default text"
+ },{
+ "name" : "text_prefilled",
+ "description" : "You should see a friendly welcome message here",
+ "value" : "hello, world"
+ },{
+ "name" : "plain_color",
+ "description" : "This is a plain color, and it is a compulsory parameter",
+ "required" : "yes",
+ "gisprompt" : True,
+ "prompt" : "color"
+ },{
+ "name" : "transparent_color",
+ "description" : "This color becomes transparent when set to none",
+ "guisection" : "tab",
+ "prompt" : "color"
+ },{
+ "name" : "multi",
+ "description" : "A multiple selection",
+ 'default': u'red,green,blue',
+ 'gisprompt': False,
+ 'guisection': 'tab',
+ 'multiple': u'yes',
+ 'type': u'string',
+ 'value': '',
+ 'values': ['red', 'green', u'yellow', u'blue', u'purple', u'other']
+ },{
+ "name" : "single",
+ "description" : "A single multiple-choice selection",
+ 'values': ['red', 'green', u'yellow', u'blue', u'purple', u'other'],
+ "guisection" : "tab"
+ }
+ ]
+ task.flags = [
+ {
+ "name" : "a",
+ "description" : "Some flag",
+ "required" : "yes"
+ },{
+ "name" : "b",
+ "description" : "pre-filled flag",
+ "value" : True
+ },{
+ "name" : "h",
+ "description" : "hidden flag",
+ "hidden" : "yes"
+ }
+ ]
+ GrassGUIApp( task ).MainLoop()
From barton at grass.itc.it Sat Apr 14 09:21:36 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sat Apr 14 09:21:39 2007
Subject: [grass-addons] r500 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704140721.l3E7LaRA017394@grass.itc.it>
Author: barton
Date: 2007-04-14 09:21:25 +0200 (Sat, 14 Apr 2007)
New Revision: 500
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
Log:
Querying of multiple raster and vector files enabled.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-14 06:01:34 UTC (rev 499)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-14 07:21:25 UTC (rev 500)
@@ -665,19 +665,20 @@
# querying
elif self.mouse["box"] == "query":
east,north = self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1])
- if self.tree.GetSelection():
- layer = self.tree.GetSelection()
- type = self.tree.layertype[layer]
- dcmd = self.tree.GetPyData(layer)[0]
- mapname = None
- for item in dcmd.split(' '):
- if 'map=' in item:
- mapname = item.split('=')[1]
+ self.Parent.QueryMap(east,north)
+# if self.tree.GetSelection():
+# layer = self.tree.GetSelection()
+# type = self.tree.layertype[layer]
+# dcmd = self.tree.GetPyData(layer)[0]
+# mapname = None
+# for item in dcmd.split(' '):
+# if 'map=' in item:
+# mapname = item.split('=')[1]
+#
+# self.parent.QueryMap(mapname,type,east,north)
+# else:
+# print "Quering without gis manager not implemented yet"
- self.parent.QueryMap(mapname,type,east,north)
- else:
- print "Quering without gis manager not implemented yet"
-
# end drag of overlay decoration
elif self.dragid != None:
self.ovlcoords[self.dragid] = self.pdc.GetIdBounds(self.dragid)
@@ -911,17 +912,20 @@
Set display geometry to match extents in
saved region file
"""
+ dlg = wx.MessageDialog(self, 'This is not yet functional',
+ 'Zoom to saved region extents', wx.OK | wx.ICON_INFORMATION)
+ dlg.ShowModal()
+ dlg.Destroy()
- print 'not yet functional'
- pass
-
def SaveDisplayRegion(self, event):
"""
Save display extents to named region file.
"""
- print 'not yet functional'
- pass
+ dlg = wx.MessageDialog(self, 'This is not yet functional',
+ 'Save display extents to named region', wx.OK | wx.ICON_INFORMATION)
+ dlg.ShowModal()
+ dlg.Destroy()
# tmpreg = os.getenv("GRASS_REGION")
# os.unsetenv("GRASS_REGION")
@@ -987,8 +991,6 @@
#
self.SetClientSize((600, 475))
- # Set variables to associate display with GIS Manager page
- self.disp_idx = idx
#
# Fancy gui
@@ -1254,7 +1256,10 @@
if dlg.ShowModal() == wx.ID_OK:
# data = dlg.GetPrintDialogData()
- print 'printing not yet enabled'
+ dlg = wx.MessageDialog(self, 'This is not yet functional',
+ 'Map printing', wx.OK | wx.ICON_INFORMATION)
+ dlg.ShowModal()
+ dlg.Destroy()
# self.log.WriteText('GetAllPages: %d\n' % data.GetAllPages())
dlg.Destroy()
@@ -1292,25 +1297,58 @@
# change the cursor
self.MapWindow.SetCursor (self.cursors["cross"])
- def QueryMap(self,mapname,type,x,y):
+ def QueryMap(self,x,y):
"""
Run *.what command in gis manager output window
"""
#set query snap distance for v.what at mapunit equivalent of 10 pixels
qdist = 10.0 * ((self.Map.region['e'] - self.Map.region['w'])/self.Map.width)
- if type == "raster":
- cmd = "r.what -f input=%s east_north=%f,%f" %\
- (mapname, float(x), float(y))
+ if self.tree.GetSelections():
+ mapname = None
+ raststr = ''
+ vectstr = ''
+ rcmd = ''
+ vcmd = ''
+ for layer in self.tree.GetSelections():
+ type = self.tree.layertype[layer]
+ dcmd = self.tree.GetPyData(layer)[0]
+ if type in ('raster', 'rgb', 'his'):
+ for item in dcmd.split(' '):
+ if 'map=' in item:
+ raststr += "%s," % item.split('=')[1]
+ elif 'red=' in item:
+ raststr += "%s," % item.split('=')[1]
+ elif 'h_map=' in item:
+ raststr += "%s," % item.split('=')[1]
+ elif type in ('vector', 'thememap', 'themechart'):
+ for item in dcmd.split(' '):
+ if 'map=' in item:
+ vectstr += "%s," % item.split('=')[1]
- elif type == "vector":
- cmd = "v.what -a map=%s east_north=%f,%f distance=%f" %\
- (mapname, float(x), float(y), qdist)
+ # build query commands for any selected rasters and vectors
+ if raststr != '':
+ raststr = raststr.rstrip(',')
+ rcmd = "r.what -f input=%s east_north=%f,%f" %\
+ (raststr, float(x), float(y))
+ if vectstr != '':
+ vectstr = vectstr.rstrip(',')
+ vcmd = "v.what -a map=%s east_north=%f,%f distance=%f" %\
+ (vectstr, float(x), float(y), qdist)
+ else:
+ dlg = wx.MessageDialog(self, 'You must select a map in the GIS Manager to query',
+ 'Nothing to query', wx.OK | wx.ICON_INFORMATION)
+ dlg.ShowModal()
+ dlg.Destroy()
+ return
+ # parse query command(s)
if self.gismanager:
- self.gismanager.goutput.runCmd(cmd)
+ if rcmd != '': self.gismanager.goutput.runCmd(rcmd)
+ if vcmd != '': self.gismanager.goutput.runCmd(vcmd)
else:
- os.system(cmd)
+ os.system(rcmd)
+ os.system(vcmd)
# toolBar button handlers
def onDecoration(self, event):
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-14 06:01:34 UTC (rev 499)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-14 07:21:25 UTC (rev 500)
@@ -165,6 +165,7 @@
self.Bind(wx.EVT_TREE_DELETE_ITEM, self.onDeleteLayer)
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.onBeginDrag)
self.Bind(wx.EVT_TREE_END_DRAG, self.onEndDrag)
+ self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
def AddLayer(self, type):
self.first = True
@@ -548,6 +549,9 @@
def setNotebookPage(self,pg):
self.Parent.notebook.SetSelection(pg)
+ def onCloseWindow(self, event):
+ self.Map.Clean()
+
class TreeCtrlComboPopup(wx.combo.ComboPopup):
"""
Create a tree ComboBox for selecting maps and other GIS elements
@@ -685,7 +689,6 @@
evt.Skip()
-
class GMConsole(wx.Panel):
"""
Create and manage output console for commands entered on the
@@ -870,8 +873,11 @@
self.cmd_output.write('East: '+rastqlist[0]+"\n")
self.cmd_output.write('North: '+rastqlist[1]+"\n")
self.cmd_output.write(rastqlist[2]+"\n")
- self.cmd_output.write('Category: '+rastqlist[3]+"\n")
- self.cmd_output.write('Label: '+rastqlist[4]+"\n")
+ data = rastqlist[3:]
+ print 'data=',data
+ for x in range(0,len(data),2):
+ self.cmd_output.write('Category: '+data[x]+"\n")
+ self.cmd_output.write('Label: '+data[x+1]+"\n")
else:
self.cmd_output.write(oline+"\n")
print >> sys.stderr, oline
From barton at grass.itc.it Sat Apr 14 10:34:34 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sat Apr 14 10:34:36 2007
Subject: [grass-addons] r501 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704140834.l3E8YY6n017490@grass.itc.it>
Author: barton
Date: 2007-04-14 10:34:20 +0200 (Sat, 14 Apr 2007)
New Revision: 501
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/wxgui_utils.py
trunk/grassaddons/gui/wxgui.py
Log:
Better trash collection
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-14 07:21:25 UTC (rev 500)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-14 08:34:20 UTC (rev 501)
@@ -666,18 +666,6 @@
elif self.mouse["box"] == "query":
east,north = self.Pixel2Cell(self.mouse['begin'][0],self.mouse['begin'][1])
self.Parent.QueryMap(east,north)
-# if self.tree.GetSelection():
-# layer = self.tree.GetSelection()
-# type = self.tree.layertype[layer]
-# dcmd = self.tree.GetPyData(layer)[0]
-# mapname = None
-# for item in dcmd.split(' '):
-# if 'map=' in item:
-# mapname = item.split('=')[1]
-#
-# self.parent.QueryMap(mapname,type,east,north)
-# else:
-# print "Quering without gis manager not implemented yet"
# end drag of overlay decoration
elif self.dragid != None:
Modified: trunk/grassaddons/gui/gui_modules/wxgui_utils.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-14 07:21:25 UTC (rev 500)
+++ trunk/grassaddons/gui/gui_modules/wxgui_utils.py 2007-04-14 08:34:20 UTC (rev 501)
@@ -165,7 +165,7 @@
self.Bind(wx.EVT_TREE_DELETE_ITEM, self.onDeleteLayer)
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.onBeginDrag)
self.Bind(wx.EVT_TREE_END_DRAG, self.onEndDrag)
- self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
+# self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
def AddLayer(self, type):
self.first = True
@@ -550,7 +550,8 @@
self.Parent.notebook.SetSelection(pg)
def onCloseWindow(self, event):
- self.Map.Clean()
+ pass
+# self.Map.Clean()
class TreeCtrlComboPopup(wx.combo.ComboPopup):
"""
Modified: trunk/grassaddons/gui/wxgui.py
===================================================================
--- trunk/grassaddons/gui/wxgui.py 2007-04-14 07:21:25 UTC (rev 500)
+++ trunk/grassaddons/gui/wxgui.py 2007-04-14 08:34:20 UTC (rev 501)
@@ -263,13 +263,10 @@
Page of notebook closed
Also close associated map display
"""
- closepage = event.GetSelection()
- try:
- if self.closepage.maptree.mapdisplay.Close(False):
- self.closepage.maptree.mapdisplay.Close(True)
- except:
- pass
+ self.gm_cb.GetPage(event.GetSelection()).maptree.Map.Clean()
+ self.gm_cb.GetPage(event.GetSelection()).maptree.Close(True)
+ event.Skip()
def runCmd(self,event):
"""Run command"""
@@ -538,6 +535,8 @@
def onCloseWindow(self, event):
'''Cleanup when wxgui.py is quit'''
try:
+ for page in range(self.gm_cb.GetPageCount()):
+ self.gm_cb.GetPage(page).maptree.Map.Clean()
self.DeleteAllPages()
except:
self.DestroyChildren()
From neteler at grass.itc.it Sat Apr 14 10:51:32 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Sat Apr 14 10:51:34 2007
Subject: [grass-addons] r502 - in trunk/grassaddons/grassflyer/flyer1: . en
en/pix
Message-ID: <200704140851.l3E8pW3h018353@grass.itc.it>
Author: neteler
Date: 2007-04-14 10:51:32 +0200 (Sat, 14 Apr 2007)
New Revision: 502
Added:
trunk/grassaddons/grassflyer/flyer1/README
trunk/grassaddons/grassflyer/flyer1/en/
trunk/grassaddons/grassflyer/flyer1/en/Makefile
trunk/grassaddons/grassflyer/flyer1/en/grassflyer.tex
trunk/grassaddons/grassflyer/flyer1/en/leaflet.cls
trunk/grassaddons/grassflyer/flyer1/en/pix/
trunk/grassaddons/grassflyer/flyer1/en/pix/OSGeo_CMYK.pdf
trunk/grassaddons/grassflyer/flyer1/en/pix/grasslogo_vector.pdf
trunk/grassaddons/grassflyer/flyer1/en/pix/isodist.png
trunk/grassaddons/grassflyer/flyer1/en/pix/ndvi.png
trunk/grassaddons/grassflyer/flyer1/en/pix/trento3d.pdf
trunk/grassaddons/grassflyer/flyer1/en/pix/visibility.png
Removed:
trunk/grassaddons/grassflyer/flyer1/Makefile
trunk/grassaddons/grassflyer/flyer1/en/pix/OSGeo_CMYK.pdf
trunk/grassaddons/grassflyer/flyer1/en/pix/grasslogo_vector.pdf
trunk/grassaddons/grassflyer/flyer1/en/pix/isodist.png
trunk/grassaddons/grassflyer/flyer1/en/pix/ndvi.png
trunk/grassaddons/grassflyer/flyer1/en/pix/trento3d.pdf
trunk/grassaddons/grassflyer/flyer1/en/pix/visibility.png
trunk/grassaddons/grassflyer/flyer1/grassflyer.tex
trunk/grassaddons/grassflyer/flyer1/leaflet.cls
trunk/grassaddons/grassflyer/flyer1/pix/
Log:
moved into en for english
Deleted: trunk/grassaddons/grassflyer/flyer1/Makefile
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/Makefile 2007-04-14 08:34:20 UTC (rev 501)
+++ trunk/grassaddons/grassflyer/flyer1/Makefile 2007-04-14 08:51:32 UTC (rev 502)
@@ -1,19 +0,0 @@
-vectoreps := $(wildcard *.eps)
-vectorfinal := $(patsubst %.eps,%.pdf,$(vectoreps))
-
-default: grassflyer.pdf
-
-$(vectorfinal): $(vectoreps)
- eps2eps -sOutputFile=- $< | epstopdf -f
-
-%.pdf: %.tex
- pdflatex $<
- pdflatex $<
-
-clean:
- rm -f *.aux *.log *.out
-
-distclean: clean
- rm -f *.pdf
-
-.PHONY: clean distclean default
Added: trunk/grassaddons/grassflyer/flyer1/README
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/README (rev 0)
+++ trunk/grassaddons/grassflyer/flyer1/README 2007-04-14 08:51:32 UTC (rev 502)
@@ -0,0 +1,3 @@
+GRASS Flyer 1
+
+en/ English version
Copied: trunk/grassaddons/grassflyer/flyer1/en/Makefile (from rev 501, trunk/grassaddons/grassflyer/flyer1/Makefile)
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/en/Makefile (rev 0)
+++ trunk/grassaddons/grassflyer/flyer1/en/Makefile 2007-04-14 08:51:32 UTC (rev 502)
@@ -0,0 +1,19 @@
+vectoreps := $(wildcard *.eps)
+vectorfinal := $(patsubst %.eps,%.pdf,$(vectoreps))
+
+default: grassflyer.pdf
+
+$(vectorfinal): $(vectoreps)
+ eps2eps -sOutputFile=- $< | epstopdf -f
+
+%.pdf: %.tex
+ pdflatex $<
+ pdflatex $<
+
+clean:
+ rm -f *.aux *.log *.out
+
+distclean: clean
+ rm -f *.pdf
+
+.PHONY: clean distclean default
Copied: trunk/grassaddons/grassflyer/flyer1/en/grassflyer.tex (from rev 501, trunk/grassaddons/grassflyer/flyer1/grassflyer.tex)
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/en/grassflyer.tex (rev 0)
+++ trunk/grassaddons/grassflyer/flyer1/en/grassflyer.tex 2007-04-14 08:51:32 UTC (rev 502)
@@ -0,0 +1,198 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%GRASS PROMOTION FLYER %
+%(c) 2007 GRASS PROMOTION TEAM %
+%GNU Free Documentation License %
+%Version 1.2 %
+%Needs leaflet.cls %
+%www.ctan.org/tex-archive/macros/latex/contrib/leaflet/%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%Sometimes printing engines need the 2nd side upside down
+%in this case, use tumble (which is default) instead of notumble
+%If this causes problems, use notumble
+%If you need a foldmark, delete nofoldmark
+\documentclass[notumble,a4paper,10pt,nofoldmark]{leaflet}
+\usepackage{helvet,courier,xcolor}
+
+% Set Helvetica as the default font
+\renewcommand*\familydefault\sfdefault
+% Let LaTeX knows that pictures are found in ./pix
+\graphicspath{{pix/}}
+
+% Setting up things for the captions
+\usepackage{caption}[2004/07/16]
+\captionsetup{%
+ font={small,it},%
+ labelformat=empty,% Leaves out label: ``Figure 1''
+ labelsep=none,%
+ aboveskip=0pt%
+}
+% Defining a new 'figure' environment for the document
+\newenvironment{myfig}[1][0pt plus 1.5ex minus .5ex]{\par\vspace*{#1}\begin{minipage}{\textwidth}\centering}{\end{minipage}}
+
+% Defining the GRASS homepage
+\newcommand{\GRASSurl}{\url{http://grass.itc.it}}
+
+% Define a color for the URIs
+\definecolor{darkblue}{RGB}{0,0,88}
+
+\usepackage{hyperref}
+% Setting up some document info
+\hypersetup{%
+ colorlinks=true,%
+ urlcolor=darkblue,% Redefine this color to change URIs color
+ pdfauthor={The GRASS Community},%
+ pdftitle={GRASS GIS: Efficiency through Freedom \& Transparency},%
+ pdfsubject={GRASS Promotion Flyer},%
+ breaklinks=true,%
+ plainpages=false%
+}
+
+% Title page stuff
+\title{\textbf{\huge GRASS GIS}\\%
+\textsl{Efficiency through Freedom \& Transparency}}
+\author{The GRASS Community}
+\date{\includegraphics[width=\textwidth]{grasslogo_vector}\\[2ex]
+\large\GRASSurl}
+
+\begin{document}
+
+\maketitle
+\thispagestyle{empty}% Necessary to leave out the page number on the first page
+
+\newpage
+
+\section{What is GRASS}
+
+GRASS (Geographic Resources Analysis Support System) is a free and Open Source Software for performing spatial analysis. It consists of more than 350 modules for processing vector (2D/3D), raster and voxel data. Many interfaces to other programs in related domains like geostatistics, databases, mapserver and even other GIS software exist. It is the largest Open Source GIS. It can serve as a Desktop GIS and as the backbone of a complete GIS Infrastructure.
+
+\section{Where is GRASS used}
+
+GRASS is used in scientific applications, commercial settings and by public authorities all over the world. GRASS has shown strong potential for solving geospatial problems in numerous situations world-wide.
+
+\section{History}
+
+GRASS was originally developed in the beginning of the 1980's by the US Army Construction Engineering Research Laboratories (USA-CERL) and was published as public domain software. When the USA-CERL withdrew from GRASS development, an international developer team took over this work. Since 1999, GRASS has been published as free software under the terms of the GNU General Public Licence.
+\begin{myfig}[1.5ex]
+\includegraphics[width=0.7\textwidth]{visibility}
+\captionof{figure}{Viewshed analysis performed with GRASS}
+\end{myfig}
+
+\section{Open Source Philosophy}
+
+The Open Source philosophy provides the user the ability to see the source code and structure of the program which offers a great transparency. Users can extend the program for their own needs. Immediate souce code peer review increases the quality. With the help of the extension manager new modules can be created without GRASS package source code.
+
+\section{Technical Data Sheet}
+
+\subsection{License}
+
+GNU General Public License (Free Software Foundation)
+
+\subsection{Supported platforms}
+
+GRASS runs on nearly all platforms. It supports GNU/Linux, Posix compliant Unix Systems, MS-Windows and MacOS X.
+
+\subsection{Design}
+
+\begin{itemize}
+\item Modular
+\item Consists of more than 350 modules
+\end{itemize}
+
+\subsection{Programming Languages}
+
+\begin{itemize}
+\item ANSI C
+\item GRASS- SWIG interface
+\item Python for WebGIS applications
+\item Java Version: JGRASS
+\end{itemize}
+
+\subsection{Data Management Capabilities}
+
+\begin{itemize}
+\item Raster / Vector / Voxel data processing
+\item 2D / 3D Raster / Vector modelling
+\item Image manipulation
+\item Vector topology / Network analysis
+\item Geostatistics (Interface to R)
+\end{itemize}
+
+\begin{myfig}[1ex]
+\includegraphics[width=0.7\textwidth]{trento3d}
+\captionof{figure}{A flyby of the city of Trento, Italy}
+\end{myfig}
+
+\section{Supported File Formats}
+
+GRASS supports nearly all common GIS file formats through the use of the GDAL/OGR library. In addition it supports the Open GIS Consortium's Simple Features.
+
+\subsection{Vector File formats}
+ASCII, ARC/INFO ungenerate, ARC/INFO E00, Arc\-View SHAPE, BIL, DLG (U.S.), DXF, DXF3D, GMT, GPS-ASCII USGS-DEM, IDRISI, MOSS, MapInfo MIF, TIGER, VRML, \dots
+
+\subsection{Raster File Formats}
+ASCII, ARC/GRID, E00, GIF, GMT, TIF, PNG, Vis5D, SURFER (.grd),\dots
+\begin{myfig}
+\includegraphics[width=0.7\textwidth]{isodist}
+\captionof{figure}{Default GUI configuration showing GRASS network analysis capabilites}
+\end{myfig}
+
+\subsection{Image File Formats}
+
+CEOS (SAR, SRTM, LANDSAT7 etc.), ERDAS LAN / IMG, HDF, LANDSAT TM/MSS, NHAP aerial photos, SAR, SPOT, \dots
+\begin{myfig}[1.5ex]
+\includegraphics[width=0.7\textwidth]{ndvi}
+\captionof{figure}{Image processing capabilities of GRASS}
+\end{myfig}
+
+\subsection{Database support}
+
+\begin{itemize}
+\item PostgreSQL / PostGIS
+\item MySQL
+\item SQLite
+\item ODBC
+\item DBF
+\end{itemize}
+
+\subsection{Output}
+
+\begin{itemize}
+\item Modules for creating maps
+\item NVIZ for visualization of 2.5D and 3D data (creation of animations \& flybys)
+%\item{GMT export}
+%item{VRML}
+\item VTK, POVray
+\item WebGIS via Mapserver, Python, etc.
+\end{itemize}
+
+\subsection{Interoperability to other GIS- related Software}
+
+\begin{itemize}
+\item Quantum GIS (Free Geodata Viewer and more)
+\item R- Language (Statistics)
+\item Gstat (Geostatistics)
+\item UMN Mapserver (Webmapping)
+\end{itemize}
+
+\section{Where to find more information}
+
+\begin{itemize}
+%\begin{flushleft}
+\item{Project Website: \\\GRASSurl}
+\item{GRASS Wiki: \\\url{http://grass.gdf.hannover.de/wiki}}
+\item{GRASS Promotion Team: \\\url{malte@perlomat.de}}
+\item{GRASS mailing lists: \\\url{http://grass.itc.it/community/support.php}}
+%\end{flushleft}
+\end{itemize}
+
+\vfill
+\section{OSGeo}
+
+GRASS is a founding project of the Open Source Geospatial Foundation which has the aim to create high quality open source geospatial software. For further information visit the OSGeo homepage:
+\begin{center}
+\includegraphics[width=0.8\textwidth]{OSGeo_CMYK}\\
+\url{http://www.osgeo.org}
+\end{center}
+
+\end{document}
Copied: trunk/grassaddons/grassflyer/flyer1/en/leaflet.cls (from rev 501, trunk/grassaddons/grassflyer/flyer1/leaflet.cls)
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/en/leaflet.cls (rev 0)
+++ trunk/grassaddons/grassflyer/flyer1/en/leaflet.cls 2007-04-14 08:51:32 UTC (rev 502)
@@ -0,0 +1,503 @@
+%%
+%% This is file `leaflet.cls',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% leaflet.dtx (with options: `class')
+%%
+%% Copyright (C) 2003, 2004
+%% Rolf Niepraschk, Rolf.Niepraschk@ptb.de
+%% Hubert Gaesslein, HubertJG@open.mind.de
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "author-maintained".
+%%
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesClass{leaflet}
+ [2004/12/22 v1.0d LaTeX document class (JS,WaS,RN,HjG)]
+\let\LL@shipout\shipout \let\LL@outputpage\@outputpage
+\let\LL@begindvi\@begindvi \let\LL@@end\@@end
+\@ifundefined{iflandscape}{\newif\iflandscape}{}%
+\@ifundefined{iftumble}{\newif\iftumble}{}%
+\newcommand\LL@debug@info[1]{}%
+\DeclareOption{dvips}{\PassOptionsToPackage{\CurrentOption}{graphics}}
+\DeclareOption{pdftex}{\PassOptionsToPackage{\CurrentOption}{graphics}}
+\DeclareOption{vtex}{\PassOptionsToPackage{\CurrentOption}{graphics}}
+\DeclareOption{dvipdfm}{\PassOptionsToPackage{\CurrentOption}{graphics}}
+\DeclareOption{twoside}{\OptionNotUsed}
+\DeclareOption{twocolumn}{\OptionNotUsed}
+\DeclareOption{landscape}{\landscapetrue}
+\DeclareOption{portrait}{\landscapefalse}
+\DeclareOption{debug}{\let\LL@debug@info\typeout}
+\DeclareOption{nospecialtricks}{%
+ \AtEndOfClass{%
+ \ifLL@combine
+ \let\immediate\@@@immediate\let\write\@@@write
+ \let\openout\@@@openout\let\closeout\@@@closeout
+ \let\special\@@@special\let\@@@exec@outs\relax
+ \fi}}
+\newcommand*\LL@setPaperSize{}
+\DeclareOption{a3paper}{\def\LL@setPaperSize{%
+ \paperwidth=420mm\paperheight=297mm\relax}}%
+\@ifdefinable\ifLL@combine{\newif\ifLL@combine}
+\DeclareOption{combine}{\LL@combinetrue}
+\DeclareOption{nocombine}{\LL@combinefalse}
+\newcommand*\LL@selectOutput{}
+\DeclareOption{frontside}{\def\LL@selectOutput#1#2{#1}}
+\DeclareOption{backside}{\def\LL@selectOutput#1#2{#2}}
+\DeclareOption{bothsides}{\def\LL@selectOutput#1#2{#1#2}}
+\DeclareOption{tumble}{\tumbletrue}
+\DeclareOption{notumble}{\tumblefalse}
+\newcommand*\LL@foldmark{}
+\DeclareOption{foldmark}{%
+ \def\LL@foldmark{%
+ \begingroup
+ \linethickness{\LenToUnit{\foldmarkrule}}%
+ \setlength\@tempdima{\paperheight-\LL@tmargin}%
+ \put(0,\LenToUnit{\@tempdima}){%
+ \line(0,-1){\LenToUnit{\foldmarklength}}}%
+ \endgroup}%
+}
+\DeclareOption{nofoldmark}{\def\LL@foldmark{}}%
+\newcommand*\LL@toomanypages[2]{}
+\DeclareOption{draft}{\PassOptionsToClass{\CurrentOption}{article}%
+ \AtEndOfClass{%
+ \def\LL@toomanypages#1#2{%
+ \ClassWarningNoLine{leaflet}{#1.\MessageBreak#2}}%
+ }%
+}
+\DeclareOption{final}{\PassOptionsToClass{\CurrentOption}{article}%
+ \AtEndOfClass{%
+ \ifLL@combine
+ \def\LL@toomanypages#1#2{%
+ \ClassError{leaflet}{#1}{#2.}}%
+ \else
+ \def\LL@toomanypages#1#2{%
+ \ClassWarningNoLine{leaflet}{#1.\MessageBreak#2}}%
+ \fi
+ }%
+}
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
+\PassOptionsToClass{landscape,a4paper}{article}
+\ExecuteOptions{tumble,foldmark,bothsides,combine,landscape,final}
+\ProcessOptions\relax
+\ifLL@combine
+ \newcommand*\LL@rotate@I{}\newcommand*\LL@rotate@II{}%
+ \iflandscape
+ \def\LL@rotate@I#1{#1}%
+ \iftumble
+ \def\LL@rotate@II#1{\rotatebox[origin=c]{180}{#1}}%
+ \else
+ \def\LL@rotate@II#1{#1}%
+ \fi
+ \else
+ \def\LL@rotate@I#1{\rotatebox[origin=c]{90}{#1}}%
+ \iftumble
+ \def\LL@rotate@II#1{\rotatebox[origin=c]{270}{#1}}%
+ \else
+ \def\LL@rotate@II#1{\rotatebox[origin=c]{90}{#1}}%
+ \fi
+ \fi
+ \def\@@@pending@outs{}\let\@@@immediate\immediate
+ \let\@@@write\write \let\@@@special\special
+ \let\@@@openout\openout \let\@@@closeout\closeout
+ \def\immediate{%
+ \let\write\immediate@write%
+ \let\openout\immediate@openout%
+ \let\closeout\immediate@closeout%
+ \let\special\immediate@special}%
+ \def\reset@immediate{%
+ \let\write\pending@write%
+ \let\openout\pending@openout%
+ \let\closeout\pending@closeout%
+ \let\special\@@@special}%
+ \long\def\pending@write#1#{\pending@@write{#1}}
+ \def\immediate@write{%
+ \reset@immediate\@@@immediate\@@@write}%
+ \def\immediate@openout{%
+ \reset@immediate\@@@immediate\@@@openout}%
+ \def\immediate@closeout{%
+ \reset@immediate\@@@immediate\@@@closeout}%
+ \def\immediate@special{%
+ \reset@immediate\@@@immediate\@@@special}%
+ \let\write\pending@write
+ \let\openout\pending@openout
+ \let\closeout\pending@closeout
+ \def\@dummy@whatsit{\special{}}
+ \begingroup\@ifundefined{pdfoutput}%
+ {\endgroup}
+ {\endgroup
+ \ifnum\pdfoutput>\z@\def\@dummy@whatsit{\pdfliteral{}}\fi}
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname eTeXversion\endcsname\relax
+ %%% Test is from Markus Kohm (d.c.t.t, 29 Jun 2004)
+ \ClassWarningNoLine{leaflet}{%
+ *************************************\MessageBreak
+ * It's very recommended to use eTeX \MessageBreak
+ * with this package! \MessageBreak
+ *************************************}%
+ \long\def\pending@@write#1#2{%
+ \@dummy@whatsit
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@write\number#1{#2},}}%
+ \def\pending@openout#1 {%
+ \@dummy@whatsit
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@openout\number#1,}}%
+ \def\pending@closeout#1{%
+ \@dummy@whatsit
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@closeout\number#1,}}%
+ \newcommand*\@@@exec@outs{%
+ \@@@pending@outs\gdef\@@@pending@outs{}%
+ \LL@debug@info{%
+ >>> execute the output commands of the current page <<<}}%
+ \else
+ \RequirePackage{etex}
+ \globmarks\@@@out@mark
+ \newcounter{@@total@outs}\setcounter{@@total@outs}{0}
+ \newcounter{@@last@exec}\setcounter{@@last@exec}{0}
+ \long\def\pending@@write#1#2{%
+ \global\advance\c@@@total@outs\@ne%
+ \marks\@@@out@mark{\the\c@@@total@outs}%
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@write\number#1{#2},}}%
+\def\pending@openout#1 {%
+ \global\advance\c@@@total@outs\@ne%
+ \marks\@@@out@mark{\the\c@@@total@outs}%
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@openout\number#1,}}%
+\def\pending@closeout#1{%
+ \global\advance\c@@@total@outs\@ne%
+ \marks\@@@out@mark{\the\c@@@total@outs}%
+ \g@addto@macro\@@@pending@outs{\@@@immediate\@@@closeout\number#1,}}%
+ \newcommand*\@@@exec@outs{%
+ \begingroup
+ \@tempcntb\c@@@total@outs\advance\@tempcntb-\c@@@last@exec%
+ \edef\reserved@a{\botmarks\@@@out@mark}%
+ \ifx\reserved@a\@empty\@tempcnta\z@\else\@tempcnta\reserved@a\fi%
+ \LL@debug@info{PENDING-OUTS:\the\@tempcntb\space\space
+ TOTAL-OUTS:\the\c@@@total@outs\space\space
+ LAST-EXEC:\the\c@@@last@exec\space\space
+ TOPMARK:\topmarks\@@@out@mark\space\space
+ FIRSTMARK:\firstmarks\@@@out@mark\space\space
+ BOTMARK:\botmarks\@@@out@mark}%
+ \advance\@tempcnta-\c@@@total@outs \advance\@tempcntb\@tempcnta
+ \@tempcnta-\@tempcnta%
+ \ifnum\@tempcnta>\z@
+ \LL@debug@info{%
+ >>> resave \the\@tempcnta\space output command(s).
+ Too early to execute! <<<}%
+ \fi
+ \@tempcnta\z@ \def\reserved@b{}%
+ \@for\reserved@a :=\@@@pending@outs\do{%
+ \ifx\reserved@a\@empty\else
+ \ifnum\@tempcnta<\@tempcntb%
+ \reserved@a% execute output's related to the current page box.
+ \global\advance\c@@@last@exec\@ne
+ \LL@debug@info{>>> execute output command number
+ \the\c@@@last@exec\space<<<}%
+ \else
+ \expandafter\g@addto@macro\expandafter\reserved@b\expandafter{%
+ \reserved@a,}%
+ \fi
+ \advance\@tempcnta\@ne%
+ \fi}%
+ \expandafter\@temptokena\expandafter{\reserved@b}%
+ \xdef\@@@pending@outs{\the\@temptokena}%
+ \endgroup}%
+ \fi% end of eTeX test.
+ \long\def\protected@write#1#2#3{%
+ \begingroup
+ \let\thepage\relax
+ #2%
+ \let\protect\@unexpandable@protect
+ \edef\reserved@a{\noexpand\write#1{#3}}%
+ \reserved@a%
+ \endgroup
+ \if@nobreak\ifvmode\nobreak\fi\fi}%
+ \def\shipout{\deadcycles\z@\setbox\@tempboxa=}
+ \let\@begindvi\@empty
+\fi% end of \ifLL@combine
+\LoadClass{article}
+\RequirePackage{everyshi,calc,graphicx}
+\newcommand*\LL@pagesize@specials[2]{}
+\@ifundefined{Gin@driver}{}%
+{%
+ \ifx\Gin@driver\@empty\else%
+ \filename@parse{\Gin@driver}\@tempswafalse%
+ \def\reserved@a{dvips}%
+ \ifx\filename@base\reserved@a\@tempswatrue\fi%
+ \def\reserved@a{dvipdfm}%
+ \ifx\filename@base\reserved@a\@tempswatrue\fi%
+ \if@tempswa%
+ \ClassInfo{leaflet}{Generating code for dvips}%
+ \def\LL@pagesize@specials#1#2{%
+ \@tempdima=#1\@tempdimb=#2%
+ \AtBeginDvi{\special{papersize=\the\@tempdima,\the\@tempdimb}}}%
+ \fi%
+ \def\reserved@a{pdftex}%
+ \ifx\filename@base\reserved@a
+ \ClassInfo{leaflet}{Generating code for pdfTeX}%
+ \def\LL@pagesize@specials#1#2{%
+ \@tempdima=#1\@tempdimb=#2%
+ \pdfpagewidth\@tempdima\pdfpageheight\@tempdimb}%
+ \fi%
+ \def\reserved@a{vtex}%
+ \ifx\filename@base\reserved@a
+ \ClassInfo{leaflet}{Generating code for VTeX}%
+ \def\LL@pagesize@specials#1#2{%
+ \@tempdima=#1\@tempdimb=#2%
+ \mediawidth\@tempdima\mediaheight\@tempdimb}%
+ \fi%
+ \fi
+}
+\newcommand*\LL@CmdIgnored[1]{%
+ \ClassWarning{leaflet}{%
+ `\string#1' ignored}}
+\setlength{\parskip}{1ex plus 2pt}
+\@listi%
+\setlength{\labelwidth}{\leftmargin}
+\addtolength{\labelwidth}{-\labelsep}
+\pagestyle{empty}
+\headheight\z@
+\headsep\z@
+\footskip\z@
+\marginparwidth\z@
+\marginparsep\z@
+\sloppy
+\setcounter{secnumdepth}{0}
+\renewcommand\twocolumn[1][]{\LL@CmdIgnored{\twocolumn}}
+\renewcommand\onecolumn{\LL@CmdIgnored{\onecolumn}}
+\renewcommand\topfraction{0.7}
+\renewcommand\bottomfraction{0.7}
+\setlength{\textfloatsep}{10pt plus 4pt minus 3pt}
+\setlength{\parindent}{\z@}
+\setlength{\leftmargini}{1.5em}
+\setlength{\leftmarginii}{1.5em}
+\setlength{\leftmarginiii}{1.5em}
+\setlength{\leftmarginiv}{1.5em}
+\setlength{\leftmarginv}{1.5em}
+\setlength{\leftmarginvi}{1.5em}
+\setlength{\labelsep}{.5em}
+\setlength \labelwidth{\leftmargini}
+\addtolength\labelwidth{-\labelsep}
+\def\noparskip{\par\vspace{-\parskip}}
+\let\old@small\small
+\renewcommand{\small}{\old@small\let\@listi\@listI}
+\let\old@footnotesize\footnotesize
+\renewcommand{\footnotesize}{\old@footnotesize\let\@listi\@listI}
+\newcommand{\sectfont}{\bfseries}
+\renewcommand\section{\@startsection{section}{1}{\z@}%
+ {-3.5ex \@plus -.75ex}%
+ {1ex} %{1.5ex}%
+ {\normalfont\large\sectfont}}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+ {-2.5ex plus -.5ex}%
+ {1\p@} %{1ex}%
+ {\normalfont\normalsize\sectfont}}
+\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
+ {-2.5ex plus -.5ex}%
+ {-1em}%
+ {\normalfont\normalsize\sectfont}}
+\def\part{\LL@CmdIgnored{\part}\secdef\@part\@spart}
+\def\@part[#1]#2{}
+\def\@spart#1{}
+
+\renewcommand*\descriptionlabel[1]{%
+ \hspace\labelsep\normalfont\descfont #1}
+\newcommand*\descfont{\bfseries}
+\iffalse
+\g@addto@macro\enumerate{\parsep2\p@\@plus2\p@\@minus\z@}
+\g@addto@macro\itemize{\parsep2\p@\@plus2\p@\@minus\z@}
+\g@addto@macro\description{\parsep2\p@\@plus2\p@\@minus\z@}
+\else
+\newcommand*\LL@listsetup{%
+ \parsep1ex\@plus.5ex\@minus.25ex%
+ \LL@debug@info{***parsep=\the\parsep}%
+ \itemsep\z@
+ \LL@debug@info{***itemsep=\the\itemsep}%
+ \topsep\z@
+ \LL@debug@info{***topsep=\the\topsep}%
+ \LL@debug@info{***partopsep=\the\partopsep}%
+}
+\def\enumerate{%
+ \ifnum \@enumdepth >\thr@@\@toodeep\else
+ \advance\@enumdepth\@ne
+ \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
+ \expandafter
+ \list
+ \csname label\@enumctr\endcsname
+ {\usecounter\@enumctr
+ \def\makelabel##1{\hss\llap{##1}}%
+ %\def\makelabel##1{##1\hfill}%
+ %\def\makelabel##1{\hss##1}%
+ \LL@listsetup
+ }%
+ \fi}
+\def\itemize{%
+ \ifnum \@itemdepth >\thr@@\@toodeep\else
+ \advance\@itemdepth\@ne
+ \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
+ \expandafter
+ \list
+ \csname\@itemitem\endcsname
+ {%
+ \def\makelabel##1{\hss\llap{##1}}%
+ %\def\makelabel##1{##1\hfill}%
+ %\def\makelabel##1{\hss##1}%
+ \LL@listsetup
+ }%
+ \fi}
+\renewenvironment{description}
+ {\list{}{\labelwidth\z@ \itemindent-\leftmargin
+ \let\makelabel\descriptionlabel
+ \LL@listsetup}}
+ {\endlist}
+\fi
+\newcommand*\setmargins[4]{%
+ \setlength\topmargin{#1}%
+ \edef\LL@tmargin{\the\topmargin}%
+ \setlength\evensidemargin{#2}%
+ \setlength\textheight{%
+ \paperheight-\topmargin-\evensidemargin%
+ -\headheight-\headsep-\footskip}%
+ \setlength\oddsidemargin{#3}%
+ \setlength\evensidemargin{#4}%
+ \setlength\textwidth{%
+ \paperwidth-\oddsidemargin-\evensidemargin-\marginparwidth-\marginparsep}%
+ \addtolength\topmargin{-1in}%
+ \addtolength\oddsidemargin{-1in}%
+ \evensidemargin\oddsidemargin%
+}
+\LL@setPaperSize
+\paperwidth=0.333333334\paperwidth
+\setmargins{11mm}{11mm}{8mm}{8mm}
+\newcommand*\foldmarkrule{0.4pt}
+\newcommand*\foldmarklength{2mm}
+\newcommand\AddToBackground{%
+ \@ifstar{\@tempswatrue\LL@AddToBackground}
+ {\@tempswafalse\LL@AddToBackground}}
+\@onlypreamble\AddToBackground
+\newcommand\LL@AddToBackground[2]{%
+ \if@tempswa\def\@tempa{LL@largePic}\else\def\@tempa{LL@smallPic}\fi
+ \expandafter\providecommand\csname\@tempa\@Roman{#1}\endcsname{}%
+ \expandafter\g@addto@macro\csname\@tempa\@Roman{#1}\endcsname{#2}}
+\newcommand\LenToUnit[1]{#1\@gobble}
+\newcommand*\CutLine{%
+ \@ifstar{\@tempswatrue\LL@CutLine}{\@tempswafalse\LL@CutLine}}
+\@onlypreamble\CutLine
+\newcommand*\LL@CutLine[1]{%
+ \ifLL@combine
+ \ifx\Scissors\@empty\@tempswatrue\fi
+ \if@tempswa
+ \AddToBackground{#1}{%
+ \put(0,0){%
+ \rotatebox{90}{\makebox(\LenToUnit{\paperheight},0){%
+ \normalsize
+ \dotfill}}}}%
+ \else
+ \AddToBackground{#1}{%
+ \put(0,0){%
+ \rotatebox{90}{\makebox(\LenToUnit{\paperheight},0){%
+ \normalsize
+ \dotfill\Scissors\dotfill\dotfill\Scissors\dotfill}}}}%
+ \fi
+ \fi}
+\IfFileExists{pifont.sty}
+ {\RequirePackage{pifont}%
+ \newcommand*\Scissors{\raisebox{-0.85ex}{\large\ding{34}}}}%
+ {\newcommand*\Scissors{}}
+\AddToBackground{3}{\LL@foldmark}
+\providecommand*\vb@xt@{\vbox to}
+\AtBeginDocument{\EveryShipout{\LL@savePage}}
+\newcounter{LL@page}\setcounter{LL@page}{1}
+\newcommand\LL@tempa{}
+\newcommand*\LL@savePage{%
+ \ifnum\c@LL@page<7\relax
+ \setbox\@cclv\vbox{%
+ \vbox{\@tempdima=1in\relax
+ \@tempdimb=\paperheight\advance\@tempdimb-\@tempdima
+ \pictur@(0,0)(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimb})%
+ \begingroup
+ \set@typeset@protect
+ \@nameuse{LL@smallPic\Roman{LL@page}}%
+ %\set@display@protect
+ \endgroup
+ \endpicture}%
+ \nointerlineskip\box\@cclv}%
+ \ifLL@combine
+ \@@@exec@outs
+ \expandafter\newsavebox\csname LL@box\Roman{LL@page}\endcsname%
+ \setbox\@cclv=\vbox{\vskip1in\unvbox\@cclv}%
+ \setbox\@cclv=\vbox{\moveright1in\box\@cclv}%
+ \setbox\@cclv=\hb@xt@\paperwidth{\box\@cclv\hss}%
+ \setbox\@cclv=\vb@xt@\paperheight{\box\@cclv\vss}%
+ \global\expandafter\setbox%
+ \csname LL@box\Roman{LL@page}\endcsname=\box\@cclv%
+ \typeout{\@spaces[\the\c@LL@page] ==> [\Roman{LL@page}]}%
+ \fi
+ \fi
+ \ifnum\c@LL@page=7\relax
+ \begingroup
+ \set@typeset@protect
+ \LL@toomanypages{%
+ The text you supplied fills more than six pages\MessageBreak
+ and will therefore not fit onto a single flyer}{%
+ Try using smaller fonts or reducing vertical space}%
+ \endgroup
+ \fi
+ \stepcounter{LL@page}}
+\ifLL@combine
+ \def\@@end{%
+ \clearpage\pagestyle{empty}%
+ \let\@outputpage\LL@outputpage
+ \def\@EveryShipout@Hook{}%
+ \def\@EveryShipout@AtNextHook{}%
+ \EveryShipout{\LL@savePage}%
+ \loop\ifnum\c@LL@page<7\relax
+ \ClassInfo{leaflet}{Generating empty page \the\c@page}%
+ \null\newpage
+ \repeat
+ \let\shipout\LL@shipout \let\@begindvi\LL@begindvi
+ \paperwidth=3\paperwidth
+ \iflandscape
+ \LL@pagesize@specials{\paperwidth}{\paperheight}%
+ \else
+ \LL@pagesize@specials{\paperheight}{\paperwidth}%
+ \fi
+ \newcommand*\LL@shipoutPage[1]{%
+ \let \protect \noexpand
+ \shipout\vb@xt@\paperheight{%
+ \set@typeset@protect
+ \vskip-1in%
+ \@begindvi\hb@xt@\paperwidth{\hskip-1in##1\hss}\vss}}%
+ \newcommand*\LL@preparePages[3]{%
+ \typeout{[\@Roman{##1}\space\@Roman{##2}\space\@Roman{##3}] ==>}%
+ \pictur@(0,0)\@nameuse{LL@largePic\Roman{page}}\endpicture%
+ \LL@preparePage{##1}\LL@preparePage{##2}\LL@preparePage{##3}}%
+ \newcommand*\LL@preparePage[1]{%
+ \expandafter\box\csname LL@box\@Roman{##1}\endcsname}%
+ \LL@selectOutput
+ {\setcounter{page}{1}%
+ \LL@shipoutPage{\LL@rotate@I{\LL@preparePages{5}{6}{1}}}}%
+ {\setcounter{page}{2}%
+ \LL@shipoutPage{\LL@rotate@II{\LL@preparePages{2}{3}{4}}}}%
+ \LL@@end
+ }%
+\else
+ \LL@pagesize@specials{\paperwidth}{\paperheight}%
+ \AtEndDocument{%
+ \clearpage\pagestyle{empty}%
+ \loop\ifnum\c@LL@page<7\relax
+ \ClassInfo{leaflet}{Generating empty page \the\c@page}%
+ \null\newpage
+ \repeat
+ }
+\fi
+\endinput
+%%
+%% End of file `leaflet.cls'.
Copied: trunk/grassaddons/grassflyer/flyer1/en/pix (from rev 498, trunk/grassaddons/grassflyer/flyer1/pix)
Deleted: trunk/grassaddons/grassflyer/flyer1/en/pix/OSGeo_CMYK.pdf
===================================================================
(Binary files differ)
Copied: trunk/grassaddons/grassflyer/flyer1/en/pix/OSGeo_CMYK.pdf (from rev 501, trunk/grassaddons/grassflyer/flyer1/pix/OSGeo_CMYK.pdf)
===================================================================
(Binary files differ)
Deleted: trunk/grassaddons/grassflyer/flyer1/en/pix/grasslogo_vector.pdf
===================================================================
(Binary files differ)
Copied: trunk/grassaddons/grassflyer/flyer1/en/pix/grasslogo_vector.pdf (from rev 501, trunk/grassaddons/grassflyer/flyer1/pix/grasslogo_vector.pdf)
===================================================================
(Binary files differ)
Deleted: trunk/grassaddons/grassflyer/flyer1/en/pix/isodist.png
===================================================================
(Binary files differ)
Copied: trunk/grassaddons/grassflyer/flyer1/en/pix/isodist.png (from rev 501, trunk/grassaddons/grassflyer/flyer1/pix/isodist.png)
===================================================================
(Binary files differ)
Deleted: trunk/grassaddons/grassflyer/flyer1/en/pix/ndvi.png
===================================================================
(Binary files differ)
Copied: trunk/grassaddons/grassflyer/flyer1/en/pix/ndvi.png (from rev 501, trunk/grassaddons/grassflyer/flyer1/pix/ndvi.png)
===================================================================
(Binary files differ)
Deleted: trunk/grassaddons/grassflyer/flyer1/en/pix/trento3d.pdf
===================================================================
(Binary files differ)
Copied: trunk/grassaddons/grassflyer/flyer1/en/pix/trento3d.pdf (from rev 501, trunk/grassaddons/grassflyer/flyer1/pix/trento3d.pdf)
===================================================================
(Binary files differ)
Deleted: trunk/grassaddons/grassflyer/flyer1/en/pix/visibility.png
===================================================================
(Binary files differ)
Copied: trunk/grassaddons/grassflyer/flyer1/en/pix/visibility.png (from rev 501, trunk/grassaddons/grassflyer/flyer1/pix/visibility.png)
===================================================================
(Binary files differ)
Deleted: trunk/grassaddons/grassflyer/flyer1/grassflyer.tex
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/grassflyer.tex 2007-04-14 08:34:20 UTC (rev 501)
+++ trunk/grassaddons/grassflyer/flyer1/grassflyer.tex 2007-04-14 08:51:32 UTC (rev 502)
@@ -1,198 +0,0 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%GRASS PROMOTION FLYER %
-%(c) 2007 GRASS PROMOTION TEAM %
-%GNU Free Documentation License %
-%Version 1.2 %
-%Needs leaflet.cls %
-%www.ctan.org/tex-archive/macros/latex/contrib/leaflet/%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%Sometimes printing engines need the 2nd side upside down
-%in this case, use tumble (which is default) instead of notumble
-%If this causes problems, use notumble
-%If you need a foldmark, delete nofoldmark
-\documentclass[notumble,a4paper,10pt,nofoldmark]{leaflet}
-\usepackage{helvet,courier,xcolor}
-
-% Set Helvetica as the default font
-\renewcommand*\familydefault\sfdefault
-% Let LaTeX knows that pictures are found in ./pix
-\graphicspath{{pix/}}
-
-% Setting up things for the captions
-\usepackage{caption}[2004/07/16]
-\captionsetup{%
- font={small,it},%
- labelformat=empty,% Leaves out label: ``Figure 1''
- labelsep=none,%
- aboveskip=0pt%
-}
-% Defining a new 'figure' environment for the document
-\newenvironment{myfig}[1][0pt plus 1.5ex minus .5ex]{\par\vspace*{#1}\begin{minipage}{\textwidth}\centering}{\end{minipage}}
-
-% Defining the GRASS homepage
-\newcommand{\GRASSurl}{\url{http://grass.itc.it}}
-
-% Define a color for the URIs
-\definecolor{darkblue}{RGB}{0,0,88}
-
-\usepackage{hyperref}
-% Setting up some document info
-\hypersetup{%
- colorlinks=true,%
- urlcolor=darkblue,% Redefine this color to change URIs color
- pdfauthor={The GRASS Community},%
- pdftitle={GRASS GIS: Efficiency through Freedom \& Transparency},%
- pdfsubject={GRASS Promotion Flyer},%
- breaklinks=true,%
- plainpages=false%
-}
-
-% Title page stuff
-\title{\textbf{\huge GRASS GIS}\\%
-\textsl{Efficiency through Freedom \& Transparency}}
-\author{The GRASS Community}
-\date{\includegraphics[width=\textwidth]{grasslogo_vector}\\[2ex]
-\large\GRASSurl}
-
-\begin{document}
-
-\maketitle
-\thispagestyle{empty}% Necessary to leave out the page number on the first page
-
-\newpage
-
-\section{What is GRASS}
-
-GRASS (Geographic Resources Analysis Support System) is a free and Open Source Software for performing spatial analysis. It consists of more than 350 modules for processing vector (2D/3D), raster and voxel data. Many interfaces to other programs in related domains like geostatistics, databases, mapserver and even other GIS software exist. It is the largest Open Source GIS. It can serve as a Desktop GIS and as the backbone of a complete GIS Infrastructure.
-
-\section{Where is GRASS used}
-
-GRASS is used in scientific applications, commercial settings and by public authorities all over the world. GRASS has shown strong potential for solving geospatial problems in numerous situations world-wide.
-
-\section{History}
-
-GRASS was originally developed in the beginning of the 1980's by the US Army Construction Engineering Research Laboratories (USA-CERL) and was published as public domain software. When the USA-CERL withdrew from GRASS development, an international developer team took over this work. Since 1999, GRASS has been published as free software under the terms of the GNU General Public Licence.
-\begin{myfig}[1.5ex]
-\includegraphics[width=0.7\textwidth]{visibility}
-\captionof{figure}{Viewshed analysis performed with GRASS}
-\end{myfig}
-
-\section{Open Source Philosophy}
-
-The Open Source philosophy provides the user the ability to see the source code and structure of the program which offers a great transparency. Users can extend the program for their own needs. Immediate souce code peer review increases the quality. With the help of the extension manager new modules can be created without GRASS package source code.
-
-\section{Technical Data Sheet}
-
-\subsection{License}
-
-GNU General Public License (Free Software Foundation)
-
-\subsection{Supported platforms}
-
-GRASS runs on nearly all platforms. It supports GNU/Linux, Posix compliant Unix Systems, MS-Windows and MacOS X.
-
-\subsection{Design}
-
-\begin{itemize}
-\item Modular
-\item Consists of more than 350 modules
-\end{itemize}
-
-\subsection{Programming Languages}
-
-\begin{itemize}
-\item ANSI C
-\item GRASS- SWIG interface
-\item Python for WebGIS applications
-\item Java Version: JGRASS
-\end{itemize}
-
-\subsection{Data Management Capabilities}
-
-\begin{itemize}
-\item Raster / Vector / Voxel data processing
-\item 2D / 3D Raster / Vector modelling
-\item Image manipulation
-\item Vector topology / Network analysis
-\item Geostatistics (Interface to R)
-\end{itemize}
-
-\begin{myfig}[1ex]
-\includegraphics[width=0.7\textwidth]{trento3d}
-\captionof{figure}{A flyby of the city of Trento, Italy}
-\end{myfig}
-
-\section{Supported File Formats}
-
-GRASS supports nearly all common GIS file formats through the use of the GDAL/OGR library. In addition it supports the Open GIS Consortium's Simple Features.
-
-\subsection{Vector File formats}
-ASCII, ARC/INFO ungenerate, ARC/INFO E00, Arc\-View SHAPE, BIL, DLG (U.S.), DXF, DXF3D, GMT, GPS-ASCII USGS-DEM, IDRISI, MOSS, MapInfo MIF, TIGER, VRML, \dots
-
-\subsection{Raster File Formats}
-ASCII, ARC/GRID, E00, GIF, GMT, TIF, PNG, Vis5D, SURFER (.grd),\dots
-\begin{myfig}
-\includegraphics[width=0.7\textwidth]{isodist}
-\captionof{figure}{Default GUI configuration showing GRASS network analysis capabilites}
-\end{myfig}
-
-\subsection{Image File Formats}
-
-CEOS (SAR, SRTM, LANDSAT7 etc.), ERDAS LAN / IMG, HDF, LANDSAT TM/MSS, NHAP aerial photos, SAR, SPOT, \dots
-\begin{myfig}[1.5ex]
-\includegraphics[width=0.7\textwidth]{ndvi}
-\captionof{figure}{Image processing capabilities of GRASS}
-\end{myfig}
-
-\subsection{Database support}
-
-\begin{itemize}
-\item PostgreSQL / PostGIS
-\item MySQL
-\item SQLite
-\item ODBC
-\item DBF
-\end{itemize}
-
-\subsection{Output}
-
-\begin{itemize}
-\item Modules for creating maps
-\item NVIZ for visualization of 2.5D and 3D data (creation of animations \& flybys)
-%\item{GMT export}
-%item{VRML}
-\item VTK, POVray
-\item WebGIS via Mapserver, Python, etc.
-\end{itemize}
-
-\subsection{Interoperability to other GIS- related Software}
-
-\begin{itemize}
-\item Quantum GIS (Free Geodata Viewer and more)
-\item R- Language (Statistics)
-\item Gstat (Geostatistics)
-\item UMN Mapserver (Webmapping)
-\end{itemize}
-
-\section{Where to find more information}
-
-\begin{itemize}
-%\begin{flushleft}
-\item{Project Website: \\\GRASSurl}
-\item{GRASS Wiki: \\\url{http://grass.gdf.hannover.de/wiki}}
-\item{GRASS Promotion Team: \\\url{malte@perlomat.de}}
-\item{GRASS mailing lists: \\\url{http://grass.itc.it/community/support.php}}
-%\end{flushleft}
-\end{itemize}
-
-\vfill
-\section{OSGeo}
-
-GRASS is a founding project of the Open Source Geospatial Foundation which has the aim to create high quality open source geospatial software. For further information visit the OSGeo homepage:
-\begin{center}
-\includegraphics[width=0.8\textwidth]{OSGeo_CMYK}\\
-\url{http://www.osgeo.org}
-\end{center}
-
-\end{document}
Deleted: trunk/grassaddons/grassflyer/flyer1/leaflet.cls
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/leaflet.cls 2007-04-14 08:34:20 UTC (rev 501)
+++ trunk/grassaddons/grassflyer/flyer1/leaflet.cls 2007-04-14 08:51:32 UTC (rev 502)
@@ -1,503 +0,0 @@
-%%
-%% This is file `leaflet.cls',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% leaflet.dtx (with options: `class')
-%%
-%% Copyright (C) 2003, 2004
-%% Rolf Niepraschk, Rolf.Niepraschk@ptb.de
-%% Hubert Gaesslein, HubertJG@open.mind.de
-%%
-%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
-%% of this license or (at your option) any later version.
-%% The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2003/12/01 or later.
-%%
-%% This work has the LPPL maintenance status "author-maintained".
-%%
-\NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesClass{leaflet}
- [2004/12/22 v1.0d LaTeX document class (JS,WaS,RN,HjG)]
-\let\LL@shipout\shipout \let\LL@outputpage\@outputpage
-\let\LL@begindvi\@begindvi \let\LL@@end\@@end
-\@ifundefined{iflandscape}{\newif\iflandscape}{}%
-\@ifundefined{iftumble}{\newif\iftumble}{}%
-\newcommand\LL@debug@info[1]{}%
-\DeclareOption{dvips}{\PassOptionsToPackage{\CurrentOption}{graphics}}
-\DeclareOption{pdftex}{\PassOptionsToPackage{\CurrentOption}{graphics}}
-\DeclareOption{vtex}{\PassOptionsToPackage{\CurrentOption}{graphics}}
-\DeclareOption{dvipdfm}{\PassOptionsToPackage{\CurrentOption}{graphics}}
-\DeclareOption{twoside}{\OptionNotUsed}
-\DeclareOption{twocolumn}{\OptionNotUsed}
-\DeclareOption{landscape}{\landscapetrue}
-\DeclareOption{portrait}{\landscapefalse}
-\DeclareOption{debug}{\let\LL@debug@info\typeout}
-\DeclareOption{nospecialtricks}{%
- \AtEndOfClass{%
- \ifLL@combine
- \let\immediate\@@@immediate\let\write\@@@write
- \let\openout\@@@openout\let\closeout\@@@closeout
- \let\special\@@@special\let\@@@exec@outs\relax
- \fi}}
-\newcommand*\LL@setPaperSize{}
-\DeclareOption{a3paper}{\def\LL@setPaperSize{%
- \paperwidth=420mm\paperheight=297mm\relax}}%
-\@ifdefinable\ifLL@combine{\newif\ifLL@combine}
-\DeclareOption{combine}{\LL@combinetrue}
-\DeclareOption{nocombine}{\LL@combinefalse}
-\newcommand*\LL@selectOutput{}
-\DeclareOption{frontside}{\def\LL@selectOutput#1#2{#1}}
-\DeclareOption{backside}{\def\LL@selectOutput#1#2{#2}}
-\DeclareOption{bothsides}{\def\LL@selectOutput#1#2{#1#2}}
-\DeclareOption{tumble}{\tumbletrue}
-\DeclareOption{notumble}{\tumblefalse}
-\newcommand*\LL@foldmark{}
-\DeclareOption{foldmark}{%
- \def\LL@foldmark{%
- \begingroup
- \linethickness{\LenToUnit{\foldmarkrule}}%
- \setlength\@tempdima{\paperheight-\LL@tmargin}%
- \put(0,\LenToUnit{\@tempdima}){%
- \line(0,-1){\LenToUnit{\foldmarklength}}}%
- \endgroup}%
-}
-\DeclareOption{nofoldmark}{\def\LL@foldmark{}}%
-\newcommand*\LL@toomanypages[2]{}
-\DeclareOption{draft}{\PassOptionsToClass{\CurrentOption}{article}%
- \AtEndOfClass{%
- \def\LL@toomanypages#1#2{%
- \ClassWarningNoLine{leaflet}{#1.\MessageBreak#2}}%
- }%
-}
-\DeclareOption{final}{\PassOptionsToClass{\CurrentOption}{article}%
- \AtEndOfClass{%
- \ifLL@combine
- \def\LL@toomanypages#1#2{%
- \ClassError{leaflet}{#1}{#2.}}%
- \else
- \def\LL@toomanypages#1#2{%
- \ClassWarningNoLine{leaflet}{#1.\MessageBreak#2}}%
- \fi
- }%
-}
-\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
-\PassOptionsToClass{landscape,a4paper}{article}
-\ExecuteOptions{tumble,foldmark,bothsides,combine,landscape,final}
-\ProcessOptions\relax
-\ifLL@combine
- \newcommand*\LL@rotate@I{}\newcommand*\LL@rotate@II{}%
- \iflandscape
- \def\LL@rotate@I#1{#1}%
- \iftumble
- \def\LL@rotate@II#1{\rotatebox[origin=c]{180}{#1}}%
- \else
- \def\LL@rotate@II#1{#1}%
- \fi
- \else
- \def\LL@rotate@I#1{\rotatebox[origin=c]{90}{#1}}%
- \iftumble
- \def\LL@rotate@II#1{\rotatebox[origin=c]{270}{#1}}%
- \else
- \def\LL@rotate@II#1{\rotatebox[origin=c]{90}{#1}}%
- \fi
- \fi
- \def\@@@pending@outs{}\let\@@@immediate\immediate
- \let\@@@write\write \let\@@@special\special
- \let\@@@openout\openout \let\@@@closeout\closeout
- \def\immediate{%
- \let\write\immediate@write%
- \let\openout\immediate@openout%
- \let\closeout\immediate@closeout%
- \let\special\immediate@special}%
- \def\reset@immediate{%
- \let\write\pending@write%
- \let\openout\pending@openout%
- \let\closeout\pending@closeout%
- \let\special\@@@special}%
- \long\def\pending@write#1#{\pending@@write{#1}}
- \def\immediate@write{%
- \reset@immediate\@@@immediate\@@@write}%
- \def\immediate@openout{%
- \reset@immediate\@@@immediate\@@@openout}%
- \def\immediate@closeout{%
- \reset@immediate\@@@immediate\@@@closeout}%
- \def\immediate@special{%
- \reset@immediate\@@@immediate\@@@special}%
- \let\write\pending@write
- \let\openout\pending@openout
- \let\closeout\pending@closeout
- \def\@dummy@whatsit{\special{}}
- \begingroup\@ifundefined{pdfoutput}%
- {\endgroup}
- {\endgroup
- \ifnum\pdfoutput>\z@\def\@dummy@whatsit{\pdfliteral{}}\fi}
- \begingroup\expandafter\expandafter\expandafter\endgroup
- \expandafter\ifx\csname eTeXversion\endcsname\relax
- %%% Test is from Markus Kohm (d.c.t.t, 29 Jun 2004)
- \ClassWarningNoLine{leaflet}{%
- *************************************\MessageBreak
- * It's very recommended to use eTeX \MessageBreak
- * with this package! \MessageBreak
- *************************************}%
- \long\def\pending@@write#1#2{%
- \@dummy@whatsit
- \g@addto@macro\@@@pending@outs{\@@@immediate\@@@write\number#1{#2},}}%
- \def\pending@openout#1 {%
- \@dummy@whatsit
- \g@addto@macro\@@@pending@outs{\@@@immediate\@@@openout\number#1,}}%
- \def\pending@closeout#1{%
- \@dummy@whatsit
- \g@addto@macro\@@@pending@outs{\@@@immediate\@@@closeout\number#1,}}%
- \newcommand*\@@@exec@outs{%
- \@@@pending@outs\gdef\@@@pending@outs{}%
- \LL@debug@info{%
- >>> execute the output commands of the current page <<<}}%
- \else
- \RequirePackage{etex}
- \globmarks\@@@out@mark
- \newcounter{@@total@outs}\setcounter{@@total@outs}{0}
- \newcounter{@@last@exec}\setcounter{@@last@exec}{0}
- \long\def\pending@@write#1#2{%
- \global\advance\c@@@total@outs\@ne%
- \marks\@@@out@mark{\the\c@@@total@outs}%
- \g@addto@macro\@@@pending@outs{\@@@immediate\@@@write\number#1{#2},}}%
-\def\pending@openout#1 {%
- \global\advance\c@@@total@outs\@ne%
- \marks\@@@out@mark{\the\c@@@total@outs}%
- \g@addto@macro\@@@pending@outs{\@@@immediate\@@@openout\number#1,}}%
-\def\pending@closeout#1{%
- \global\advance\c@@@total@outs\@ne%
- \marks\@@@out@mark{\the\c@@@total@outs}%
- \g@addto@macro\@@@pending@outs{\@@@immediate\@@@closeout\number#1,}}%
- \newcommand*\@@@exec@outs{%
- \begingroup
- \@tempcntb\c@@@total@outs\advance\@tempcntb-\c@@@last@exec%
- \edef\reserved@a{\botmarks\@@@out@mark}%
- \ifx\reserved@a\@empty\@tempcnta\z@\else\@tempcnta\reserved@a\fi%
- \LL@debug@info{PENDING-OUTS:\the\@tempcntb\space\space
- TOTAL-OUTS:\the\c@@@total@outs\space\space
- LAST-EXEC:\the\c@@@last@exec\space\space
- TOPMARK:\topmarks\@@@out@mark\space\space
- FIRSTMARK:\firstmarks\@@@out@mark\space\space
- BOTMARK:\botmarks\@@@out@mark}%
- \advance\@tempcnta-\c@@@total@outs \advance\@tempcntb\@tempcnta
- \@tempcnta-\@tempcnta%
- \ifnum\@tempcnta>\z@
- \LL@debug@info{%
- >>> resave \the\@tempcnta\space output command(s).
- Too early to execute! <<<}%
- \fi
- \@tempcnta\z@ \def\reserved@b{}%
- \@for\reserved@a :=\@@@pending@outs\do{%
- \ifx\reserved@a\@empty\else
- \ifnum\@tempcnta<\@tempcntb%
- \reserved@a% execute output's related to the current page box.
- \global\advance\c@@@last@exec\@ne
- \LL@debug@info{>>> execute output command number
- \the\c@@@last@exec\space<<<}%
- \else
- \expandafter\g@addto@macro\expandafter\reserved@b\expandafter{%
- \reserved@a,}%
- \fi
- \advance\@tempcnta\@ne%
- \fi}%
- \expandafter\@temptokena\expandafter{\reserved@b}%
- \xdef\@@@pending@outs{\the\@temptokena}%
- \endgroup}%
- \fi% end of eTeX test.
- \long\def\protected@write#1#2#3{%
- \begingroup
- \let\thepage\relax
- #2%
- \let\protect\@unexpandable@protect
- \edef\reserved@a{\noexpand\write#1{#3}}%
- \reserved@a%
- \endgroup
- \if@nobreak\ifvmode\nobreak\fi\fi}%
- \def\shipout{\deadcycles\z@\setbox\@tempboxa=}
- \let\@begindvi\@empty
-\fi% end of \ifLL@combine
-\LoadClass{article}
-\RequirePackage{everyshi,calc,graphicx}
-\newcommand*\LL@pagesize@specials[2]{}
-\@ifundefined{Gin@driver}{}%
-{%
- \ifx\Gin@driver\@empty\else%
- \filename@parse{\Gin@driver}\@tempswafalse%
- \def\reserved@a{dvips}%
- \ifx\filename@base\reserved@a\@tempswatrue\fi%
- \def\reserved@a{dvipdfm}%
- \ifx\filename@base\reserved@a\@tempswatrue\fi%
- \if@tempswa%
- \ClassInfo{leaflet}{Generating code for dvips}%
- \def\LL@pagesize@specials#1#2{%
- \@tempdima=#1\@tempdimb=#2%
- \AtBeginDvi{\special{papersize=\the\@tempdima,\the\@tempdimb}}}%
- \fi%
- \def\reserved@a{pdftex}%
- \ifx\filename@base\reserved@a
- \ClassInfo{leaflet}{Generating code for pdfTeX}%
- \def\LL@pagesize@specials#1#2{%
- \@tempdima=#1\@tempdimb=#2%
- \pdfpagewidth\@tempdima\pdfpageheight\@tempdimb}%
- \fi%
- \def\reserved@a{vtex}%
- \ifx\filename@base\reserved@a
- \ClassInfo{leaflet}{Generating code for VTeX}%
- \def\LL@pagesize@specials#1#2{%
- \@tempdima=#1\@tempdimb=#2%
- \mediawidth\@tempdima\mediaheight\@tempdimb}%
- \fi%
- \fi
-}
-\newcommand*\LL@CmdIgnored[1]{%
- \ClassWarning{leaflet}{%
- `\string#1' ignored}}
-\setlength{\parskip}{1ex plus 2pt}
-\@listi%
-\setlength{\labelwidth}{\leftmargin}
-\addtolength{\labelwidth}{-\labelsep}
-\pagestyle{empty}
-\headheight\z@
-\headsep\z@
-\footskip\z@
-\marginparwidth\z@
-\marginparsep\z@
-\sloppy
-\setcounter{secnumdepth}{0}
-\renewcommand\twocolumn[1][]{\LL@CmdIgnored{\twocolumn}}
-\renewcommand\onecolumn{\LL@CmdIgnored{\onecolumn}}
-\renewcommand\topfraction{0.7}
-\renewcommand\bottomfraction{0.7}
-\setlength{\textfloatsep}{10pt plus 4pt minus 3pt}
-\setlength{\parindent}{\z@}
-\setlength{\leftmargini}{1.5em}
-\setlength{\leftmarginii}{1.5em}
-\setlength{\leftmarginiii}{1.5em}
-\setlength{\leftmarginiv}{1.5em}
-\setlength{\leftmarginv}{1.5em}
-\setlength{\leftmarginvi}{1.5em}
-\setlength{\labelsep}{.5em}
-\setlength \labelwidth{\leftmargini}
-\addtolength\labelwidth{-\labelsep}
-\def\noparskip{\par\vspace{-\parskip}}
-\let\old@small\small
-\renewcommand{\small}{\old@small\let\@listi\@listI}
-\let\old@footnotesize\footnotesize
-\renewcommand{\footnotesize}{\old@footnotesize\let\@listi\@listI}
-\newcommand{\sectfont}{\bfseries}
-\renewcommand\section{\@startsection{section}{1}{\z@}%
- {-3.5ex \@plus -.75ex}%
- {1ex} %{1.5ex}%
- {\normalfont\large\sectfont}}
-\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
- {-2.5ex plus -.5ex}%
- {1\p@} %{1ex}%
- {\normalfont\normalsize\sectfont}}
-\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
- {-2.5ex plus -.5ex}%
- {-1em}%
- {\normalfont\normalsize\sectfont}}
-\def\part{\LL@CmdIgnored{\part}\secdef\@part\@spart}
-\def\@part[#1]#2{}
-\def\@spart#1{}
-
-\renewcommand*\descriptionlabel[1]{%
- \hspace\labelsep\normalfont\descfont #1}
-\newcommand*\descfont{\bfseries}
-\iffalse
-\g@addto@macro\enumerate{\parsep2\p@\@plus2\p@\@minus\z@}
-\g@addto@macro\itemize{\parsep2\p@\@plus2\p@\@minus\z@}
-\g@addto@macro\description{\parsep2\p@\@plus2\p@\@minus\z@}
-\else
-\newcommand*\LL@listsetup{%
- \parsep1ex\@plus.5ex\@minus.25ex%
- \LL@debug@info{***parsep=\the\parsep}%
- \itemsep\z@
- \LL@debug@info{***itemsep=\the\itemsep}%
- \topsep\z@
- \LL@debug@info{***topsep=\the\topsep}%
- \LL@debug@info{***partopsep=\the\partopsep}%
-}
-\def\enumerate{%
- \ifnum \@enumdepth >\thr@@\@toodeep\else
- \advance\@enumdepth\@ne
- \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
- \expandafter
- \list
- \csname label\@enumctr\endcsname
- {\usecounter\@enumctr
- \def\makelabel##1{\hss\llap{##1}}%
- %\def\makelabel##1{##1\hfill}%
- %\def\makelabel##1{\hss##1}%
- \LL@listsetup
- }%
- \fi}
-\def\itemize{%
- \ifnum \@itemdepth >\thr@@\@toodeep\else
- \advance\@itemdepth\@ne
- \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
- \expandafter
- \list
- \csname\@itemitem\endcsname
- {%
- \def\makelabel##1{\hss\llap{##1}}%
- %\def\makelabel##1{##1\hfill}%
- %\def\makelabel##1{\hss##1}%
- \LL@listsetup
- }%
- \fi}
-\renewenvironment{description}
- {\list{}{\labelwidth\z@ \itemindent-\leftmargin
- \let\makelabel\descriptionlabel
- \LL@listsetup}}
- {\endlist}
-\fi
-\newcommand*\setmargins[4]{%
- \setlength\topmargin{#1}%
- \edef\LL@tmargin{\the\topmargin}%
- \setlength\evensidemargin{#2}%
- \setlength\textheight{%
- \paperheight-\topmargin-\evensidemargin%
- -\headheight-\headsep-\footskip}%
- \setlength\oddsidemargin{#3}%
- \setlength\evensidemargin{#4}%
- \setlength\textwidth{%
- \paperwidth-\oddsidemargin-\evensidemargin-\marginparwidth-\marginparsep}%
- \addtolength\topmargin{-1in}%
- \addtolength\oddsidemargin{-1in}%
- \evensidemargin\oddsidemargin%
-}
-\LL@setPaperSize
-\paperwidth=0.333333334\paperwidth
-\setmargins{11mm}{11mm}{8mm}{8mm}
-\newcommand*\foldmarkrule{0.4pt}
-\newcommand*\foldmarklength{2mm}
-\newcommand\AddToBackground{%
- \@ifstar{\@tempswatrue\LL@AddToBackground}
- {\@tempswafalse\LL@AddToBackground}}
-\@onlypreamble\AddToBackground
-\newcommand\LL@AddToBackground[2]{%
- \if@tempswa\def\@tempa{LL@largePic}\else\def\@tempa{LL@smallPic}\fi
- \expandafter\providecommand\csname\@tempa\@Roman{#1}\endcsname{}%
- \expandafter\g@addto@macro\csname\@tempa\@Roman{#1}\endcsname{#2}}
-\newcommand\LenToUnit[1]{#1\@gobble}
-\newcommand*\CutLine{%
- \@ifstar{\@tempswatrue\LL@CutLine}{\@tempswafalse\LL@CutLine}}
-\@onlypreamble\CutLine
-\newcommand*\LL@CutLine[1]{%
- \ifLL@combine
- \ifx\Scissors\@empty\@tempswatrue\fi
- \if@tempswa
- \AddToBackground{#1}{%
- \put(0,0){%
- \rotatebox{90}{\makebox(\LenToUnit{\paperheight},0){%
- \normalsize
- \dotfill}}}}%
- \else
- \AddToBackground{#1}{%
- \put(0,0){%
- \rotatebox{90}{\makebox(\LenToUnit{\paperheight},0){%
- \normalsize
- \dotfill\Scissors\dotfill\dotfill\Scissors\dotfill}}}}%
- \fi
- \fi}
-\IfFileExists{pifont.sty}
- {\RequirePackage{pifont}%
- \newcommand*\Scissors{\raisebox{-0.85ex}{\large\ding{34}}}}%
- {\newcommand*\Scissors{}}
-\AddToBackground{3}{\LL@foldmark}
-\providecommand*\vb@xt@{\vbox to}
-\AtBeginDocument{\EveryShipout{\LL@savePage}}
-\newcounter{LL@page}\setcounter{LL@page}{1}
-\newcommand\LL@tempa{}
-\newcommand*\LL@savePage{%
- \ifnum\c@LL@page<7\relax
- \setbox\@cclv\vbox{%
- \vbox{\@tempdima=1in\relax
- \@tempdimb=\paperheight\advance\@tempdimb-\@tempdima
- \pictur@(0,0)(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimb})%
- \begingroup
- \set@typeset@protect
- \@nameuse{LL@smallPic\Roman{LL@page}}%
- %\set@display@protect
- \endgroup
- \endpicture}%
- \nointerlineskip\box\@cclv}%
- \ifLL@combine
- \@@@exec@outs
- \expandafter\newsavebox\csname LL@box\Roman{LL@page}\endcsname%
- \setbox\@cclv=\vbox{\vskip1in\unvbox\@cclv}%
- \setbox\@cclv=\vbox{\moveright1in\box\@cclv}%
- \setbox\@cclv=\hb@xt@\paperwidth{\box\@cclv\hss}%
- \setbox\@cclv=\vb@xt@\paperheight{\box\@cclv\vss}%
- \global\expandafter\setbox%
- \csname LL@box\Roman{LL@page}\endcsname=\box\@cclv%
- \typeout{\@spaces[\the\c@LL@page] ==> [\Roman{LL@page}]}%
- \fi
- \fi
- \ifnum\c@LL@page=7\relax
- \begingroup
- \set@typeset@protect
- \LL@toomanypages{%
- The text you supplied fills more than six pages\MessageBreak
- and will therefore not fit onto a single flyer}{%
- Try using smaller fonts or reducing vertical space}%
- \endgroup
- \fi
- \stepcounter{LL@page}}
-\ifLL@combine
- \def\@@end{%
- \clearpage\pagestyle{empty}%
- \let\@outputpage\LL@outputpage
- \def\@EveryShipout@Hook{}%
- \def\@EveryShipout@AtNextHook{}%
- \EveryShipout{\LL@savePage}%
- \loop\ifnum\c@LL@page<7\relax
- \ClassInfo{leaflet}{Generating empty page \the\c@page}%
- \null\newpage
- \repeat
- \let\shipout\LL@shipout \let\@begindvi\LL@begindvi
- \paperwidth=3\paperwidth
- \iflandscape
- \LL@pagesize@specials{\paperwidth}{\paperheight}%
- \else
- \LL@pagesize@specials{\paperheight}{\paperwidth}%
- \fi
- \newcommand*\LL@shipoutPage[1]{%
- \let \protect \noexpand
- \shipout\vb@xt@\paperheight{%
- \set@typeset@protect
- \vskip-1in%
- \@begindvi\hb@xt@\paperwidth{\hskip-1in##1\hss}\vss}}%
- \newcommand*\LL@preparePages[3]{%
- \typeout{[\@Roman{##1}\space\@Roman{##2}\space\@Roman{##3}] ==>}%
- \pictur@(0,0)\@nameuse{LL@largePic\Roman{page}}\endpicture%
- \LL@preparePage{##1}\LL@preparePage{##2}\LL@preparePage{##3}}%
- \newcommand*\LL@preparePage[1]{%
- \expandafter\box\csname LL@box\@Roman{##1}\endcsname}%
- \LL@selectOutput
- {\setcounter{page}{1}%
- \LL@shipoutPage{\LL@rotate@I{\LL@preparePages{5}{6}{1}}}}%
- {\setcounter{page}{2}%
- \LL@shipoutPage{\LL@rotate@II{\LL@preparePages{2}{3}{4}}}}%
- \LL@@end
- }%
-\else
- \LL@pagesize@specials{\paperwidth}{\paperheight}%
- \AtEndDocument{%
- \clearpage\pagestyle{empty}%
- \loop\ifnum\c@LL@page<7\relax
- \ClassInfo{leaflet}{Generating empty page \the\c@page}%
- \null\newpage
- \repeat
- }
-\fi
-\endinput
-%%
-%% End of file `leaflet.cls'.
From barton at grass.itc.it Sun Apr 15 18:47:58 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sun Apr 15 18:48:00 2007
Subject: [grass-addons] r503 - trunk/grassaddons/gui
Message-ID: <200704151647.l3FGlwYk025342@grass.itc.it>
Author: barton
Date: 2007-04-15 18:47:49 +0200 (Sun, 15 Apr 2007)
New Revision: 503
Added:
trunk/grassaddons/gui/icons/
Log:
Test silk icons for wxgrass
From barton at grass.itc.it Sun Apr 15 18:55:50 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sun Apr 15 18:55:52 2007
Subject: [grass-addons] r504 - trunk/grassaddons/gui/icons
Message-ID: <200704151655.l3FGtoGe025362@grass.itc.it>
Author: barton
Date: 2007-04-15 18:54:33 +0200 (Sun, 15 Apr 2007)
New Revision: 504
Added:
trunk/grassaddons/gui/icons/__init__.py
trunk/grassaddons/gui/icons/application.png
trunk/grassaddons/gui/icons/application_add.png
trunk/grassaddons/gui/icons/application_delete.png
trunk/grassaddons/gui/icons/application_lightning.png
trunk/grassaddons/gui/icons/chart_bar.png
trunk/grassaddons/gui/icons/cog_add.png
trunk/grassaddons/gui/icons/cross.png
trunk/grassaddons/gui/icons/cursor.png
trunk/grassaddons/gui/icons/folder_add.png
trunk/grassaddons/gui/icons/grid.png
trunk/grassaddons/gui/icons/his.png
trunk/grassaddons/gui/icons/image_add.png
trunk/grassaddons/gui/icons/images.png
trunk/grassaddons/gui/icons/information.png
trunk/grassaddons/gui/icons/layout_content.png
trunk/grassaddons/gui/icons/map.png
trunk/grassaddons/gui/icons/map_add.png
trunk/grassaddons/gui/icons/map_magnify.png
trunk/grassaddons/gui/icons/map_magnify_menu.png
trunk/grassaddons/gui/icons/pan.png
trunk/grassaddons/gui/icons/picture_save.png
trunk/grassaddons/gui/icons/printer.png
trunk/grassaddons/gui/icons/rgb.png
trunk/grassaddons/gui/icons/table_add.png
trunk/grassaddons/gui/icons/tag_green.png
trunk/grassaddons/gui/icons/thematic.png
trunk/grassaddons/gui/icons/zoom.png
trunk/grassaddons/gui/icons/zoom_back.png
trunk/grassaddons/gui/icons/zoom_in.png
trunk/grassaddons/gui/icons/zoom_out.png
Log:
Test silk icons for wxgrass
Added: trunk/grassaddons/gui/icons/__init__.py
===================================================================
--- trunk/grassaddons/gui/icons/__init__.py (rev 0)
+++ trunk/grassaddons/gui/icons/__init__.py 2007-04-15 16:54:33 UTC (rev 504)
@@ -0,0 +1,7 @@
+"""
+Silk icon set, v1.3
+http://www.famfamfam.com/lab/icons/silk/
+
+"""
+__author__ = "Mark James"
+
Added: trunk/grassaddons/gui/icons/application.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/application.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/application_add.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/application_add.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/application_delete.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/application_delete.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/application_lightning.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/application_lightning.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/chart_bar.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/chart_bar.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/cog_add.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/cog_add.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/cross.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/cross.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/cursor.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/cursor.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/folder_add.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/folder_add.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/grid.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/grid.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/his.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/his.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/image_add.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/image_add.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/images.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/images.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/information.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/information.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/layout_content.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/layout_content.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/map.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/map.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/map_add.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/map_add.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/map_magnify.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/map_magnify.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/map_magnify_menu.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/map_magnify_menu.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/pan.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/pan.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/picture_save.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/picture_save.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/printer.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/printer.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/rgb.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/rgb.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/table_add.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/table_add.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/tag_green.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/tag_green.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/thematic.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/thematic.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/zoom.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/zoom.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/zoom_back.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/zoom_back.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/zoom_in.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/zoom_in.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/grassaddons/gui/icons/zoom_out.png
===================================================================
(Binary files differ)
Property changes on: trunk/grassaddons/gui/icons/zoom_out.png
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
From barton at grass.itc.it Sun Apr 15 18:57:58 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Sun Apr 15 18:58:02 2007
Subject: [grass-addons] r505 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704151657.l3FGvw7G025384@grass.itc.it>
Author: barton
Date: 2007-04-15 18:57:42 +0200 (Sun, 15 Apr 2007)
New Revision: 505
Added:
trunk/grassaddons/gui/gui_modules/toolbars_silk.py
trunk/grassaddons/gui/wxgui_silk.py
Log:
Test silk icon toolbars
Added: trunk/grassaddons/gui/gui_modules/toolbars_silk.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars_silk.py (rev 0)
+++ trunk/grassaddons/gui/gui_modules/toolbars_silk.py 2007-04-15 16:57:42 UTC (rev 505)
@@ -0,0 +1,280 @@
+"""
+toolbars package
+
+class:
+* MapToolbar
+* DigitToolbar
+"""
+
+import wx
+import os, sys
+#import wxgui_utils
+
+import cmd
+
+#icons= os.path.split(icons)[0]
+#icons= os.path.split(icons)[0]
+#icons= os.path.split(icons)[0]
+#print icons
+
+#if not os.getenv("GRASS_ICONPATH"):
+# icons = os.getenv("GISBASE") + "/etc/gui/icons/"
+#else:
+# icons = os.environ["GRASS_ICONPATH"]
+
+import icons
+iconpath = icons.__path__[0]
+sys.path.append(iconpath)
+
+class MapToolbar:
+ """
+ Main Map Display toolbar
+ """
+
+ def __init__(self, mapdisplay, map):
+
+ global icons
+
+ self.mapcontent = map
+ self.mapdisplay = mapdisplay
+
+ self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
+
+ #self.SetToolBar(self.toolbar)
+ tsize = (20,20)
+ self.toolbar.SetToolBitmapSize(tsize)
+
+ #
+ # Draw
+ #
+
+ self.displaymap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="displaymap",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'application_lightning.png'), wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Display map", longHelp="")
+ self.erase = self.toolbar.AddLabelTool(wx.ID_ANY, "erase",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'application_delete.png'), wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL, shortHelp="Erase display", longHelp="")
+ self.toolbar.AddSeparator()
+
+ #
+ # Zooming, etc.
+ #
+ self.pointer = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="pointer",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'cursor.png'), wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Pointer", longHelp="")
+ self.zoomin = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_in",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'zoom_in.png'),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_RADIO,
+ shortHelp="Zoom in", longHelp="Drag or click mouse to zoom")
+ self.zoomout = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_out",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'zoom_out.png'),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Zoom out", longHelp="Drag or click mouse to unzoom")
+ self.pan = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="pan",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'pan.png'),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Pan", longHelp="Drag with mouse to pan")
+ self.query = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="query",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'information.png'),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Query", longHelp="Query selected map")
+ self.toolbar.AddSeparator()
+
+
+ self.zoomback = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoom_back",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'zoom_back.png'),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Zoom options", longHelp="Display zoom management")
+ self.zoommenu = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="zoommenu",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'map_magnify_menu.png'),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ shortHelp="Decoration", longHelp="Add graphic overlays to map")
+ self.toolbar.AddSeparator()
+
+
+ self.dec = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="dec",
+ bitmap=wx.Bitmap(os.path.join(iconpath,'layout_content.png'),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ shortHelp="Decoration",
+ longHelp="Add graphic overlays to map")
+
+ self.toolbar.AddSeparator()
+
+ #
+ # Misc
+ #
+ self.savefile = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="savefile",
+ #bitmap=wx.Bitmap(os.path.join(icons,"file-save.gif"),
+ #wx.BITMAP_TYPE_ANY),
+ # just testing wx.ArtProvider
+ bitmap=wx.Bitmap(os.path.join(iconpath,'picture_save.png'), wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_NORMAL,
+ shortHelp="Save display to PNG file",
+ longHelp="")
+
+ self.printmap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="printmap",
+ #bitmap=wx.Bitmap(os.path.join(icons,"file-save.gif"),
+ #wx.BITMAP_TYPE_ANY),
+ # just testing wx.ArtProvider
+ bitmap=wx.Bitmap(os.path.join(iconpath,'printer.png'), wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Print display", longHelp="")
+
+ self.toolbar.AddSeparator()
+
+ #
+ # Optional toolbars
+ #
+ self.combo = wx.ComboBox(parent=self.toolbar, id=wx.ID_ANY, value='Tools',
+ choices=['Digitize'], style=wx.CB_READONLY, size=(110, -1))
+
+ self.comboid = self.toolbar.AddControl(self.combo)
+
+ self.toolbar.Realize()
+
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.ReDraw, self.displaymap)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.Pointer, self.pointer)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomIn, self.zoomin)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomOut, self.zoomout)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnPan, self.pan)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomBack, self.zoomback)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onDecoration, self.dec)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.onZoomMenu, self.zoommenu)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnQuery, self.query)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnErase, self.erase)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.SaveToFile, self.savefile)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.PrintMap, self.printmap)
+ self.mapdisplay.Bind(wx.EVT_COMBOBOX, self.OnSelect, self.comboid)
+
+ def OnSelect(self,event):
+ tool = event.GetString()
+
+ if tool == "Digitize" and not self.mapdisplay.digittoolbar:
+ self.mapdisplay.AddToolbar("digit")
+
+class DigitToolbar:
+ """
+ Toolbar for digitization
+ """
+
+ def __init__(self, parent, map):
+
+ self.mapcontent = map
+ self.parent = parent
+ self.icons = os.path.join (icons, "v.digit")
+
+ # selected map to digitize
+ self.layerID = -1
+ # action (digitize new point, line, etc.
+ self.action = None
+ # list of available vector maps
+ self.layers = self._getListOfLayers()
+
+ self.addString = ""
+
+ # create toolbar
+ self.toolbar = wx.ToolBar(parent=self.parent, id=wx.ID_ANY)
+ self.toolbar.SetToolBitmapSize(wx.Size(24,24))
+
+ self.initToolbar()
+
+ def initToolbar(self):
+ self.combo = wx.ComboBox(self.toolbar, id=wx.ID_ANY, value='Select vector map',
+ choices=self.layers, size=(150, -1))
+
+ self.comboid = self.toolbar.AddControl(self.combo)
+
+ self.toolbar.AddSeparator()
+
+ self.point = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="point",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"new.point.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Digitize new point",
+ longHelp="")
+
+ self.line = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="line",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"new.line.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Digitize new line",
+ longHelp="")
+
+ self.boundary = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="boundary",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"new.boundary.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Digitize new boundary",
+ longHelp="")
+
+ self.centroid = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="centroid",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"new.centroid.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_RADIO,
+ shortHelp="Digitize new centroid",
+ longHelp="")
+
+ self.toolbar.AddSeparator()
+
+ self.exit = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="exit",
+ bitmap=wx.Bitmap(os.path.join(self.icons,"exit.gif"),
+ wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap,
+ kind=wx.ITEM_NORMAL,
+ shortHelp="Quit digitization tool",
+ longHelp="")
+
+ # Bindings
+ self.parent.Bind(wx.EVT_TOOL, self.OnAddPoint, self.point)
+ self.parent.Bind(wx.EVT_TOOL, self.OnExit, self.exit)
+ self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid)
+
+ def OnAddPoint(self,event):
+
+ self.action="addpoint"
+ #self.parent.MapWindow.mouse['box'] = "point"
+
+ def OnExit (self, event):
+ """
+ Quit digitization tool
+ """
+
+ self.parent.RemoveToolbar ("digit")
+
+ def OnSelectMap (self, event):
+ """
+ Select vector map to digitize
+
+ If any vector map is activated for digitization this action
+ is firstly terminated
+ """
+
+ self.layerID = self.combo.GetCurrentSelection()
+
+ # digitize (self.layers[self.layerID], mapset)
+
+ def _getListOfLayers(self):
+ layers = []
+
+ for layer in self.mapcontent.GetListOfLayers(l_type="vector"):
+ layers.append (layer.name)
+
+ return layers
Added: trunk/grassaddons/gui/wxgui_silk.py
===================================================================
--- trunk/grassaddons/gui/wxgui_silk.py (rev 0)
+++ trunk/grassaddons/gui/wxgui_silk.py 2007-04-15 16:57:42 UTC (rev 505)
@@ -0,0 +1,587 @@
+#!/usr/bin/env python
+"""
+Classes:
+* GRasterDialog
+* GMFrame
+* SetVal
+* GMApp
+"""
+import sys
+import os
+import wx
+import wx.combo
+import wx.lib.customtreectrl as CT
+import wx.lib.flatnotebook as FN
+import wx.stc
+import wx.richtext
+
+import sys, os, time, traceback, types
+
+import wx # This module uses the new wx namespace
+import wx.html
+
+
+# try:
+# import subprocess
+#except:
+# from compat import subprocess
+
+import gui_modules
+gmpath = gui_modules.__path__[0]
+sys.path.append(gmpath)
+
+import images
+imagepath = images.__path__[0]
+sys.path.append(imagepath)
+
+import icons
+iconpath = icons.__path__[0]
+sys.path.append(iconpath)
+
+
+import gui_modules.track as track
+import gui_modules.wxgui_utils as wxgui_utils
+import gui_modules.mapdisp as mapdisp
+import gui_modules.render as render
+import gui_modules.menudata as menudata
+import gui_modules.menuform as menuform
+import gui_modules.grassenv as grassenv
+
+"""Main Python app to set up GIS Manager window and trap commands
+Only command console is working currently, but windows for
+panels and layer tree done and demo tree items appear"""
+
+##########################################################################
+#
+# wxgui.py - wxPython prototype GUI for GRASS 6+
+#
+# Authors: Michael Barton (Arizona State University) &
+# Jachym Cepicky (Mendel University of Agriculture)
+#
+# August 2006
+#
+# COPYRIGHT: (C) 1999 - 2006 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.
+#
+##########################################################################
+
+menucmd = {}
+
+class GRasterDialog(wx.Frame):
+ def __init__(self,parent,id=-1,title="Set raster layer"):
+ wx.Frame.__init__(self, parent, id , title, size=(50,600))
+
+ # sizers
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ buttsizer = wx.BoxSizer(wx.HORIZONTAL)
+
+ # labels
+ lmap = wx.StaticText(self,-1,"Map name")
+ lvalues = wx.StaticText(self,-1,"List of values to be displayed")
+ lopaque = wx.StaticText(self,-1,"Transparency")
+
+ # checkboxes
+ cboverlay = wx.CheckBox(self, -1, "Overlay (non-null values)")
+ cboverlay.SetValue(True)
+
+ # text entries
+ tmapname = wx.TextCtrl(self,-1,size=(-1,-1))
+ tvalues = wx.TextCtrl(self,-1,size=(-1,-1))
+
+ # buttons
+ bsize=(75,-1)
+ bok = wx.Button(self,-1, "OK",size=bsize)
+ bapply = wx.Button(self,-1, "Apply", size=bsize)
+ bcancel = wx.Button(self,-1, "Cancel", size=bsize)
+
+ buttsizer.Add(bok, 0, wx.ADJUST_MINSIZE, 1)
+ buttsizer.Add(bapply, 0, wx.ADJUST_MINSIZE, 1)
+ buttsizer.Add(bcancel, 0, wx.ADJUST_MINSIZE, 1)
+ sizer.Add(lopaque,1, wx.EXPAND, 1)
+ sizer.Add(lmap,0, wx.EXPAND, 1)
+ sizer.Add(tmapname,0, wx.EXPAND, 1)
+ sizer.Add(lvalues,0, wx.EXPAND, 1)
+ sizer.Add(tvalues,0, wx.EXPAND, 1)
+ sizer.Add(cboverlay,1, wx.EXPAND, 1)
+ sizer.Add(buttsizer,0, wx.ADJUST_MINSIZE, 1)
+ self.SetSizer(sizer)
+ sizer.Fit(self)
+ self.Layout()
+
+
+class GMFrame(wx.Frame):
+ '''GIS Manager frame with notebook widget for controlling
+ GRASS GIS. Includes command console page for typing GRASS
+ (and other) commands, tree widget page for managing GIS map layers.'''
+ def __init__(self, parent, id, title):
+ self.parent = parent
+ wx.Frame.__init__(self, parent=parent, id=-1, title=title, style=wx.DEFAULT_FRAME_STYLE)
+
+ # creating widgets
+ self.notebook = self.__createNoteBook()
+ self.cmdinput = self.__createCommandInput()
+ self.menubar = self.__createMenuBar()
+ toolbar = self.__createToolBar()
+ #self.panel = wx.Panel(self,-1, style= wx.EXPAND)
+ self.sizer= wx.BoxSizer(wx.VERTICAL)
+ self.cmdsizer = wx.BoxSizer(wx.HORIZONTAL)
+ self.track = track
+
+ # do layout
+ self.SetTitle(_("GRASS GIS Manager - wxPython Prototype"))
+ self.SetMinSize((450, 450))
+ self.SetIcon(wx.Icon(os.path.join(imagepath,'grass.smlogo.gif'), wx.BITMAP_TYPE_ANY))
+ # self.nb_panel = wx.Panel(self)
+
+ # initialize variables
+ self.mapdisplays = {} #dictionary to index open map displays
+ self.disp_idx = 0 #index value for map displays and layer trees
+ self.maptree = {} #dictionary to index a layer tree to accompanying a map display
+ self.mapfocus = 0 #track which display currently has focus
+ self.curr_page = '' # currently selected page for layer tree notebook
+ self.curr_pagenum = '' # currently selected page number for layer tree notebook
+
+ self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
+ self.Bind(wx.EVT_LEFT_DOWN, self.addRaster)
+
+ # item, proportion, flag, border, userData
+ self.sizer.Add(self.notebook, proportion=1, flag=wx.EXPAND, border=1)
+ self.sizer.Add(self.cmdinput, proportion=0, flag=wx.EXPAND, border=1)
+ self.SetSizer(self.sizer)
+ self.sizer.Fit(self)
+ self.Layout()
+ wx.CallAfter(self.notebook.SetSelection, 0)
+
+ # start default initial display
+ self.newDisplay()
+
+ def __createCommandInput(self):
+ """Creates command input area"""
+ #l = wx.StaticText(self, -1, "GRASS> ")
+
+ self.cmdinput = wx.TextCtrl(self, id=wx.ID_ANY, value="", style=wx.HSCROLL|wx.TE_LINEWRAP|
+ wx.TE_PROCESS_ENTER)
+
+ self.cmdinput.SetFont(wx.Font(10, wx.FONTFAMILY_MODERN, wx.NORMAL, wx.NORMAL, 0, ''))
+ wx.CallAfter(self.cmdinput.SetInsertionPoint, 0)
+
+ self.Bind(wx.EVT_TEXT_ENTER, self.runCmd, self.cmdinput)
+
+ return self.cmdinput
+
+ def __createMenuBar(self):
+ """Creates menubar"""
+
+ self.menubar = wx.MenuBar()
+ menud = menudata.Data()
+ for eachMenuData in menud.GetMenu():
+ for eachHeading in eachMenuData:
+ menuLabel = eachHeading[0]
+ menuItems = eachHeading[1]
+ self.menubar.Append(self.__createMenu(menuItems), menuLabel)
+ self.SetMenuBar(self.menubar)
+
+ return self.menubar
+
+ def __createMenu(self, menuData):
+ """Cretes menu"""
+
+ menu = wx.Menu()
+ for eachItem in menuData:
+ if len(eachItem) == 2:
+ label = eachItem[0]
+ subMenu = self.__createMenu(eachItem[1])
+ menu.AppendMenu(wx.NewId(), label, subMenu)
+ else:
+ self.__createMenuItem(menu, *eachItem)
+ return menu
+
+ def __createMenuItem(self, menu, label, help, handler, gcmd, kind=wx.ITEM_NORMAL):
+ """Creates menu items"""
+
+ if not label:
+ menu.AppendSeparator()
+ return
+ menuItem = menu.Append(-1, label, help, kind)
+ if label:
+ menucmd[label] = gcmd
+ rhandler = eval(handler)
+ self.Bind(wx.EVT_MENU, rhandler, menuItem)
+
+ def __createNoteBook(self):
+ """Creates notebook widgets"""
+
+ # create main notebook widget
+ #bookStyle=FN.FNB_DEFAULT_STYLE #| FN.FNB_FANCY_TABS
+ #bookStyle=FN.FNB_DEFAULT_STYLE|FN.FNB_BOTTOM|FN.FNB_NO_X_BUTTON|FN.FNB_NO_NAV_BUTTONS
+ nbStyle=FN.FNB_FANCY_TABS|FN.FNB_BOTTOM|FN.FNB_NO_X_BUTTON|FN.FNB_NO_NAV_BUTTONS
+ self.notebook = FN.FlatNotebook(self, id=wx.ID_ANY, style=nbStyle)
+
+ # create displays notebook widget and add it to main notebook page
+ cbStyle=FN.FNB_VC8|FN.FNB_BACKGROUND_GRADIENT|FN.FNB_X_ON_TAB|FN.FNB_TABS_BORDER_SIMPLE
+ #self.cb_panel = wx.Panel(self,-1, style = wx.EXPAND)
+ self.gm_cb = FN.FlatNotebook(self, id=wx.ID_ANY, style=cbStyle)
+ self.gm_cb.SetTabAreaColour(wx.Colour(125,200,175))
+ self.notebook.AddPage(self.gm_cb, text="Map layers for each display")
+
+ # create command output text area and add it to main notebook page
+ #self.outpanel = wx.Panel(self,-1, style = wx.EXPAND)
+ self.goutput = wxgui_utils.GMConsole(self)
+ #self.goutput = wx.richtext.RichTextCtrl(self,style=wx.VSCROLL|wx.HSCROLL|wx.NO_BORDER)
+ self.outpage = self.notebook.AddPage(self.goutput, text="Command output")
+
+ self.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.onCBPageChanged, self.gm_cb)
+ self.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.onCBPageClosed, self.gm_cb)
+
+ self.out_sizer = wx.BoxSizer(wx.VERTICAL)
+ self.out_sizer.Add(self.goutput, proportion=1, flag=wx.EXPAND, border=1)
+ self.SetSizer(self.out_sizer)
+ #self.out_sizer.Fit(self.outpage)
+ #self.outpage.Layout()
+
+ self.Centre()
+ return self.notebook
+
+
+ # choicebook methods
+ def onCBPageChanged(self, event):
+ """Page in notebook changed"""
+
+ old_pgnum = event.GetOldSelection()
+ new_pgnum = event.GetSelection()
+ self.curr_page = self.gm_cb.GetCurrentPage()
+ self.curr_pagenum = self.gm_cb.GetSelection()
+ try:
+ self.curr_page.maptree.mapdisplay.SetFocus()
+ self.curr_page.maptree.mapdisplay.Raise()
+ except:
+ pass
+
+ event.Skip()
+
+ def onCBPageClosed(self, event):
+ """
+ Page of notebook closed
+ Also close associated map display
+ """
+
+ self.gm_cb.GetPage(event.GetSelection()).maptree.Map.Clean()
+ self.gm_cb.GetPage(event.GetSelection()).maptree.Close(True)
+ event.Skip()
+
+ def runCmd(self,event):
+ """Run command"""
+
+ #global gmpath
+ cmd = self.cmdinput.GetValue()
+
+ self.goutput.runCmd(cmd)
+ #menuform.GUI().parseCommand(cmd, gmpath)
+
+ def runMenuCmd(self, event):
+ """Run menu command"""
+
+ menuitem = self.menubar.FindItemById(event.GetId())
+ itemtext = menuitem.GetText()
+ cmd = menucmd[itemtext]
+ global gmpath
+ menuform.GUI().parseCommand(cmd,gmpath, parentframe=self)
+
+ def __createToolBar(self):
+ """Creates toolbar"""
+
+ toolbar = self.CreateToolBar()
+
+
+ for each in self.toolbarData():
+ self.addToolbarButton(toolbar, *each)
+ tsize = (20, 20)
+ toolbar.SetToolBitmapSize(tsize)
+ toolbar.Realize()
+
+ def addToolbarButton(self, toolbar, label, icon, help, handler):
+ """Adds button to the given toolbar"""
+
+ if not label:
+ toolbar.AddSeparator()
+ return
+ tool = toolbar.AddLabelTool(id=wx.ID_ANY, label=label, bitmap=icon, shortHelp=help)
+ self.Bind(wx.EVT_TOOL, handler, tool)
+
+ def toolbarData(self):
+
+ return (
+ ('newdisplay', wx.Bitmap(os.path.join(iconpath,'application_add.png'), wx.BITMAP_TYPE_ANY), 'Start new display', self.newDisplay),
+ ('', '', '', ''),
+ ('addrast', wx.Bitmap(os.path.join(iconpath,'image_add.png'), wx.BITMAP_TYPE_ANY), 'Add raster layer', self.onRaster),
+ ('addvect', wx.Bitmap(os.path.join(iconpath,'map_add.png'), wx.BITMAP_TYPE_ANY), 'Add vector layer', self.onVector),
+ ('addcmd', wx.Bitmap(os.path.join(iconpath,'cog_add.png'), wx.BITMAP_TYPE_ANY), 'Add command layer', self.addCommand),
+ ('addgrp', wx.Bitmap(os.path.join(iconpath,'folder_add.png'), wx.BITMAP_TYPE_ANY), 'Add layer group', self.addGroup),
+ ('addovl', wx.Bitmap(os.path.join(iconpath,'images.png'), wx.BITMAP_TYPE_ANY), 'Add grid or vector labels overlay', self.onOverlay),
+ ('delcmd', wx.Bitmap(os.path.join(iconpath,'cross.png'), wx.BITMAP_TYPE_ANY), 'Delete selected layer', self.deleteLayer),
+ ('', '', '', ''),
+ ('attributetable',wx.Bitmap(os.path.join(iconpath,'table_add.png'),wx.BITMAP_TYPE_ANY), 'Show attribute table', self.ShowAttributeTable),
+ )
+
+ def ShowAttributeTable(self,event):
+ if self.curr_page.maptree.GetSelection() not in self.curr_page.maptree.layertype: return
+ maptype = self.curr_page.maptree.layertype[self.curr_page.maptree.GetSelection()]
+ if maptype != 'vector':
+ print 'Attribute management only available for vector files'
+ return
+
+ if not self.curr_page.maptree.GetPyData(self.curr_page.maptree.GetSelection()): return
+ dcmd = self.curr_page.maptree.GetPyData(self.curr_page.maptree.GetSelection())[0]
+ if not dcmd: return
+ mapname = map = mapset = size = icon = None
+ for item in dcmd.split(' '):
+ if 'map=' in item:
+ mapname = item.split('=')[1]
+ elif 'size=' in item:
+ size = item.split('=')[1]
+ elif 'icon=' in item:
+ icon = item.split('=')[1]
+
+ pointdata = (icon,size)
+
+ from gui_modules import dbm
+ self.dbmanager = gui_modules.dbm.AttributeManager(self,
+ -1,"GRASS Attribute Table Manager: %s" % mapname,
+ size=wx.Size(500,300),vectmap=mapname,
+ pointdata=pointdata)
+
+
+ def newDisplay(self, event=None):
+ """Create new map display frame"""
+
+ # make a new page in the bookcontrol for the layer tree (on page 0 of the notebook)
+ self.pg_panel = wx.Panel(self.gm_cb, id=wx.ID_ANY, style= wx.EXPAND)
+ self.gm_cb.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx), select = True)
+ self.curr_page = self.gm_cb.GetCurrentPage()
+
+ # create layer tree (tree control for managing GIS layers) and put on new notebook page
+ self.curr_page.maptree = wxgui_utils.LayerTree(self.curr_page, id=wx.ID_ANY, pos=wx.DefaultPosition,
+ size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS
+ |wx.TR_LINES_AT_ROOT|wx.TR_EDIT_LABELS|wx.TR_HIDE_ROOT
+ |wx.TR_DEFAULT_STYLE|wx.NO_BORDER|wx.FULL_REPAINT_ON_RESIZE,
+ idx=self.disp_idx, gismgr=self, notebook=self.gm_cb)
+
+ # layout for controls
+ cb_boxsizer = wx.BoxSizer(wx.VERTICAL)
+ cb_boxsizer.Add(self.curr_page.maptree, proportion=1, flag=wx.EXPAND, border=1)
+ self.curr_page.SetSizer(cb_boxsizer)
+ cb_boxsizer.Fit(self.curr_page.maptree)
+ self.curr_page.Layout()
+ self.curr_page.maptree.Layout()
+
+ self.disp_idx += 1
+
+ # toolBar button handlers
+ def onRaster(self, event):
+ """Add raster menu"""
+ point = wx.GetMousePosition()
+ rastmenu = wx.Menu()
+ # Add items to the menu
+ addrast = wx.MenuItem(rastmenu, -1,'Add raster map layer')
+ bmp = wx.Image(os.path.join(iconpath,'image_add.png'), wx.BITMAP_TYPE_ANY)
+# bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addrast.SetBitmap(bmp)
+ rastmenu.AppendItem(addrast)
+ self.Bind(wx.EVT_MENU, self.addRaster, addrast)
+
+ addrgb = wx.MenuItem(rastmenu, -1,'Add RGB layer')
+ bmp = wx.Image(os.path.join(iconpath,'rgb.png'), wx.BITMAP_TYPE_ANY)
+# bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addrgb.SetBitmap(bmp)
+ rastmenu.AppendItem(addrgb)
+ self.Bind(wx.EVT_MENU, self.addRGB, addrgb)
+
+ addhis = wx.MenuItem(rastmenu, -1,'Add HIS layer')
+ bmp = wx.Image(os.path.join(iconpath,'his.png'), wx.BITMAP_TYPE_ANY)
+# bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addhis.SetBitmap(bmp)
+ rastmenu.AppendItem(addhis)
+ self.Bind(wx.EVT_MENU, self.addHIS, addhis)
+
+ # Popup the menu. If an item is selected then its handler
+ # will be called before PopupMenu returns.
+ self.PopupMenu(rastmenu)
+ rastmenu.Destroy()
+
+ def onVector(self, event):
+ """Add vector menu"""
+ point = wx.GetMousePosition()
+ vectmenu = wx.Menu()
+
+ addvect = wx.MenuItem(vectmenu, -1,'Add vector map layer')
+ bmp = wx.Image(os.path.join(iconpath,'map.png'), wx.BITMAP_TYPE_ANY)
+# bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addvect.SetBitmap(bmp)
+ vectmenu.AppendItem(addvect)
+ self.Bind(wx.EVT_MENU, self.addVector, addvect)
+
+ addtheme = wx.MenuItem(vectmenu, -1,'Add thematic map layer')
+ bmp = wx.Image(os.path.join(iconpath,'thematic.png'), wx.BITMAP_TYPE_ANY)
+# bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addtheme.SetBitmap(bmp)
+ vectmenu.AppendItem(addtheme)
+ self.Bind(wx.EVT_MENU, self.addThemeMap, addtheme)
+
+ addchart = wx.MenuItem(vectmenu, -1,'Add thematic chart layer')
+ bmp = wx.Image(os.path.join(iconpath,'chart_bar.png'), wx.BITMAP_TYPE_ANY)
+# bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addchart.SetBitmap(bmp)
+ vectmenu.AppendItem(addchart)
+ self.Bind(wx.EVT_MENU, self.addThemeChart, addchart)
+ # Popup the menu. If an item is selected then its handler
+ # will be called before PopupMenu returns.
+ self.PopupMenu(vectmenu)
+ vectmenu.Destroy()
+
+ def onOverlay(self, event):
+ """Add overlay menu"""
+ point = wx.GetMousePosition()
+ ovlmenu = wx.Menu()
+
+ addgrid = wx.MenuItem(ovlmenu, -1,'Add grid overlay')
+ bmp = wx.Image(os.path.join(iconpath,'grid.png'), wx.BITMAP_TYPE_ANY)
+ bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addgrid.SetBitmap(bmp)
+ ovlmenu.AppendItem(addgrid)
+ self.Bind(wx.EVT_MENU, self.addGrid, addgrid)
+
+ addlbl = wx.MenuItem(ovlmenu, -1,'Add vector labels overlay (create with v.label)')
+ bmp = wx.Image(os.path.join(iconpath,'tag_green.png'), wx.BITMAP_TYPE_ANY)
+ bmp.Rescale(16, 16)
+ bmp = bmp.ConvertToBitmap()
+ addlbl.SetBitmap(bmp)
+ ovlmenu.AppendItem(addlbl)
+ self.Bind(wx.EVT_MENU, self.addLabels, addlbl)
+
+ # Popup the menu. If an item is selected then its handler
+ # will be called before PopupMenu returns.
+ self.PopupMenu(ovlmenu)
+ ovlmenu.Destroy()
+
+
+ def addRaster(self, event):
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('raster')
+
+ def addRGB(self, event):
+ """Add RGB layer"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('rgb')
+
+ def addHIS(self, event):
+ """Add HIS layer"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('his')
+
+ def addRastLeg(self, event):
+ """Add raster legend"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('rastleg')
+
+ def addVector(self, event):
+ """Add vector layer"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('vector')
+
+ def addThemeMap(self, event):
+ """Add thematic map layer"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('thememap')
+
+ def addThemeChart(self, event):
+ """Add thematic chart layer"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('themechart')
+
+ def addCommand(self, event):
+ """Add command line layer"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('command')
+
+ def addGroup(self, event):
+ """Add layer group"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('group')
+
+ def addGrid(self, event):
+ """Add layer grid"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('grid')
+
+ def addLabels(self, event):
+ """Add layer vector labels"""
+ self.notebook.SetSelection(0)
+ self.curr_page.maptree.AddLayer('labels')
+
+ def GetSelectedDisplay(self):
+ return self.notebook.GetSelection()
+
+ def deleteLayer(self, event):
+ """
+ Delete selected map display layer in GIS Manager tree widget
+ """
+ for layer in self.curr_page.maptree.GetSelections():
+ if self.curr_page.maptree.layertype[layer] == 'group':
+ self.curr_page.maptree.DeleteChildren(layer)
+ self.curr_page.maptree.Delete(layer)
+
+ #Misc methods
+ def onCloseWindow(self, event):
+ '''Cleanup when wxgui.py is quit'''
+ try:
+ for page in range(self.gm_cb.GetPageCount()):
+ self.gm_cb.GetPage(page).maptree.Map.Clean()
+ self.DeleteAllPages()
+ except:
+ self.DestroyChildren()
+ self.Destroy()
+
+ def Nomethod(self, event):
+ '''Stub for testing'''
+ pass
+ event.Skip()
+
+class GMApp(wx.App):
+ """
+ GMApp class
+ """
+ def OnInit(self):
+## reexec_with_pythonw()
+ # initialize all available image handlers
+ wx.InitAllImageHandlers()
+ # create and show main frame
+ mainframe = GMFrame(None, -1, "" )
+ self.SetTopWindow(mainframe)
+ mainframe.Show()
+ return 1
+
+def reexec_with_pythonw():
+ if sys.platform == 'darwin' and\
+ not sys.executable.endswith('MacOS/Python'):
+ print >>sys.stderr,'re-executing using pythonw'
+ os.execvp('pythonw',['pythonw',__file__] + sys.argv[1:])
+
+
+if __name__ == "__main__":
+
+ reexec_with_pythonw()
+
+ import gettext
+ gettext.install("GMApp") # replace with the appropriate catalog name
+ app = GMApp(0)
+ app.MainLoop()
Property changes on: trunk/grassaddons/gui/wxgui_silk.py
___________________________________________________________________
Name: svn:executable
+ *
From calvelo at grass.itc.it Mon Apr 16 05:14:01 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Mon Apr 16 05:14:02 2007
Subject: [grass-addons] r506 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704160314.l3G3E1Xq003133@grass.itc.it>
Author: calvelo
Date: 2007-04-16 05:13:46 +0200 (Mon, 16 Apr 2007)
New Revision: 506
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- cmdPanel is now totally independent. It can be used with a grassTask() structure to generate any grass-style command building interface, and it uses createCmd() and OnSetValues() as its main API
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-15 16:57:42 UTC (rev 505)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 03:13:46 UTC (rev 506)
@@ -377,6 +377,7 @@
self.notebookpanel = cmdPanel( parent=self, task=self.task, standalone=standalone )
if standalone:
self.goutput = self.notebookpanel.goutput
+ self.notebookpanel.OnUpdateValues = self.updateValuesHook
guisizer.Add( self.notebookpanel, 1, flag = wx.EXPAND )
@@ -422,6 +423,8 @@
self.SetSizer(guisizer)
self.Layout()
+ def updateValuesHook(self):
+ self.SetStatusText( self.notebookpanel.createCmd(ignoreErrors = True) )
def OnOK(self, event):
cmd = self.OnApply(event)
@@ -719,16 +722,15 @@
colorchooser.SetColour( new_color )
colorchooser.Refresh()
p[ 'value' ] = colorchooser.GetLabel()
- self.updateStatusLine()
+ self.OnUpdateValues()
- def updateStatusLine(self):
- """If we were part of a richer interface, report back the current command being built."""
- # TODO: don't tie this to a StatusLine
- try:
- self.GetParent().SetStatusText( self.createCmd(ignoreErrors = True) )
- except:
- pass
+ def OnUpdateValues(self):
+ """If we were part of a richer interface, report back the current command being built.
+ This method should be set by the parent of this panel if needed. It's a hook, actually.
+ Beware of what is "self" in the method def, though. It will be called with no arguments."""
+ pass
+
def OnCheckBoxMulti(self, event):
"""Fill the values ,-separated string according to current status of the checkboxes."""
me = event.GetId()
@@ -752,7 +754,7 @@
currentValueList.append( v )
# Pack it back
theParam['value'] = ','.join( currentValueList )
- self.updateStatusLine()
+ self.OnUpdateValues()
def OnSetValue(self, event):
myId = event.GetId()
@@ -760,7 +762,7 @@
for porf in self.task.params + self.task.flags:
if 'wxId' in porf and type( porf[ 'wxId' ] ) == type( 1 ) and porf['wxId'] == myId:
porf[ 'value' ] = me.GetValue()
- self.updateStatusLine()
+ self.OnUpdateValues()
def createCmd(self, ignoreErrors = False):
"""Produce a command line string for feeding into GRASS.
From barton at grass.itc.it Mon Apr 16 06:04:05 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 16 06:04:06 2007
Subject: [grass-addons] r507 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704160404.l3G445uO004389@grass.itc.it>
Author: barton
Date: 2007-04-16 06:03:57 +0200 (Mon, 16 Apr 2007)
New Revision: 507
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Fix bug keeping barscale and legend from opening options dialog.
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-16 03:13:46 UTC (rev 506)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-16 04:03:57 UTC (rev 507)
@@ -1635,7 +1635,7 @@
"""
menuform.GUI().parseCommand(self.ovlcmd, gmpath,
- completed=(self.parent.getOptData,self.ovltype,self.params),
+ completed=(self.Parent.getOptData,self.ovltype,self.params),
parentframe=None)
class TextDialog(wx.Dialog):
From calvelo at grass.itc.it Mon Apr 16 06:55:51 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Mon Apr 16 06:55:52 2007
Subject: [grass-addons] r508 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704160455.l3G4tpMC005030@grass.itc.it>
Author: calvelo
Date: 2007-04-16 06:55:38 +0200 (Mon, 16 Apr 2007)
New Revision: 508
Modified:
trunk/grassaddons/gui/gui_modules/grass-interface.dtd
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- value sets may have names and descriptions; slurp names only, so that selectors are not confused.
TODO: record descriptions also, so that they can be used for tooltips or other help.
Modified: trunk/grassaddons/gui/gui_modules/grass-interface.dtd
===================================================================
--- trunk/grassaddons/gui/gui_modules/grass-interface.dtd 2007-04-16 04:03:57 UTC (rev 507)
+++ trunk/grassaddons/gui/gui_modules/grass-interface.dtd 2007-04-16 04:55:38 UTC (rev 508)
@@ -115,18 +115,18 @@
-->
-
-
+
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 04:03:57 UTC (rev 507)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 04:55:38 UTC (rev 508)
@@ -244,7 +244,7 @@
self.description = self.description + ch
if self.inDefaultContent:
self.param_default = self.param_default + ch
- if self.inValueContent:
+ if self.inValueContent and not self.inDescriptionContent:
self.value_tmp = self.value_tmp + ch
if self.inGuisection:
self.param_guisection = self.param_guisection + ch
From calvelo at grass.itc.it Mon Apr 16 08:00:16 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Mon Apr 16 08:00:16 2007
Subject: [grass-addons] r509 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704160600.l3G60Gnv006005@grass.itc.it>
Author: calvelo
Date: 2007-04-16 08:00:03 +0200 (Mon, 16 Apr 2007)
New Revision: 509
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- better test task: use with 'test' as the grass command
- now cmdPanel may be queried by (i) buildCmd, which returns an array of arguments and (ii) createCmd, which is the usual cmdline string. This allows for both system-style use (with the usual quote madness), and a saner execve-style command launch.
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 04:55:38 UTC (rev 508)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 06:00:03 UTC (rev 509)
@@ -31,8 +31,9 @@
#
# - verify option value types
# - add tooltips
+# - use DOM instead of SAX !!!
"""
-__version__ ="$Date: 2006/08/06 21:21:01 $"
+__version__ ="$Revision $"
import wx
import sys
@@ -135,7 +136,7 @@
def text_beautify( someString ):
"Make really long texts shorter"
# TODO: remove magic number (calculate a correct value from
- # pixelSize of text and the magic number for maximum size
+ # pixelSize of text and the magic number for maximum size)
return escape_ampersand( os.linesep.join( textwrap.wrap( normalize_whitespace(someString), 70 ) ) )
def escape_ampersand(text):
@@ -245,6 +246,19 @@
if self.inDefaultContent:
self.param_default = self.param_default + ch
if self.inValueContent and not self.inDescriptionContent:
+ # Beware: value_tmp will get anything outside of a
+ # so in this snippet:
+ #
+ #
+ # a
+ # a desc
+ #
+ #
+ # 'a desc' will not be recorded anwhere; this unburdens further
+ # handling of value sets to distinguish between those that do define
+ # descriptions and those that do not.
+ #
+ # TODO: a set of flags to treat this case of a description sub-element
self.value_tmp = self.value_tmp + ch
if self.inGuisection:
self.param_guisection = self.param_guisection + ch
@@ -764,33 +778,42 @@
porf[ 'value' ] = me.GetValue()
self.OnUpdateValues()
- def createCmd(self, ignoreErrors = False):
- """Produce a command line string for feeding into GRASS.
+ def buildCmd(self, ignoreErrors = False):
+ """Produce an array of command ame and arguments for feeding
+ into some execve-like command processor.
If ignoreErrors==True then it will return whatever has been
built so far, even though it would not be a correct command
for GRASS."""
- cmd = self.task.name
+ cmd = [self.task.name]
errors = 0
errStr = ""
dcmd_params = {}
for flag in self.task.flags:
if 'value' in flag and flag['value']:
- cmd += ' -' + flag['name']
+ cmd += [ '-' + flag['name'] ]
for p in self.task.params:
if p.get('value','') == '' and p.get('required','no') != 'no':
- cmd += ' ' + p['name'] + '=' + _('')
+ cmd += [ p['name'] + '=' + _('')]
errStr += _("Parameter %s (%s) is missing\n") % ( p['name'], p['description'] )
errors += 1
if p.get('value','') != '' and p['value'] != p.get('default','') :
- cmd += ' ' + p['name'] + '=' + p['value']
+ cmd += [ p['name'] + '=' + p['value'] ]
if errors and not ignoreErrors:
self.OnError(errStr)
return None
return cmd
+ def createCmd( self, ignoreErrors = False ):
+ """Produce a command line string for feeding into GRASS.
+
+ If ignoreErrors==True then it will return whatever has been
+ built so far, even though it would not be a correct command
+ for GRASS."""
+ return ' '.join( self.buildCmd( ignoreErrors=ignoreErrors ) )
+
def OnError(self, errMsg):
dlg = wx.MessageDialog(self, errMsg, _("Error"), wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
@@ -905,6 +928,7 @@
"name" : "transparent_color",
"description" : "This color becomes transparent when set to none",
"guisection" : "tab",
+ "gisprompt" : True,
"prompt" : "color"
},{
"name" : "multi",
@@ -926,16 +950,17 @@
task.flags = [
{
"name" : "a",
- "description" : "Some flag",
+ "description" : "Some flag, will appear in Main since it is required",
"required" : "yes"
},{
"name" : "b",
- "description" : "pre-filled flag",
+ "description" : "pre-filled flag, will appear in options since it is not required",
"value" : True
},{
- "name" : "h",
- "description" : "hidden flag",
- "hidden" : "yes"
+ "name" : "hidden_flag",
+ "description" : "hidden flag, should not be changeable",
+ "hidden" : "yes",
+ "value" : True
}
]
GrassGUIApp( task ).MainLoop()
From barton at grass.itc.it Mon Apr 16 08:50:36 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 16 08:50:37 2007
Subject: [grass-addons] r510 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704160650.l3G6oahG006153@grass.itc.it>
Author: barton
Date: 2007-04-16 08:50:27 +0200 (Mon, 16 Apr 2007)
New Revision: 510
Modified:
trunk/grassaddons/gui/gui_modules/toolbars.py
Log:
Start of a force render option.
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-16 06:00:03 UTC (rev 509)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-16 06:50:27 UTC (rev 510)
@@ -50,6 +50,13 @@
type=wx.BITMAP_TYPE_ANY),
bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
shortHelp="Display map", longHelp="")
+
+ self.rendermap = self.toolbar.AddLabelTool(id=wx.ID_ANY, label="rendermap",
+ bitmap=wx.Bitmap(name=os.path.join(icons,"gui-redraw.gif"),
+ type=wx.BITMAP_TYPE_ANY),
+ bmpDisabled=wx.NullBitmap, kind=wx.ITEM_NORMAL,
+ shortHelp="Re-render map", longHelp="Force re-rendering of all layers")
+
self.erase = self.toolbar.AddLabelTool(wx.ID_ANY, "erase",
wx.Bitmap(os.path.join(icons,"gui-erase.gif"),
wx.BITMAP_TYPE_ANY),
@@ -147,6 +154,7 @@
self.toolbar.Realize()
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.ReDraw, self.displaymap)
+ self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.ReRender, self.rendermap)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.Pointer, self.pointer)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomIn, self.zoomin)
self.mapdisplay.Bind(wx.EVT_TOOL, self.mapdisplay.OnZoomOut, self.zoomout)
From barton at grass.itc.it Mon Apr 16 08:51:40 2007
From: barton at grass.itc.it (barton@grass.itc.it)
Date: Mon Apr 16 08:51:41 2007
Subject: [grass-addons] r511 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704160651.l3G6peRn006173@grass.itc.it>
Author: barton
Date: 2007-04-16 08:51:31 +0200 (Mon, 16 Apr 2007)
New Revision: 511
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
Log:
Start of a force render option. Improved save display to file. Only
overlay text not saving now. Why not???
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-16 06:50:27 UTC (rev 510)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-16 06:51:31 UTC (rev 511)
@@ -347,8 +347,10 @@
"""
All that is needed here is to draw the buffer to screen
"""
- dc = wx.BufferedPaintDC(self)
+ self._Buffer = wx.EmptyBitmap(self.Map.width, self.Map.height)
+ dc = wx.BufferedPaintDC(self, self._Buffer)
+
# use PrepateDC to set position correctly
self.PrepareDC(dc)
# we need to clear the dc BEFORE calling PrepareDC
@@ -683,7 +685,6 @@
# dragging or drawing box with left button
if self.mouse['box'] == 'pan':
self.DragMap(end)
- self.DragItem(99, event)
# dragging decoration overlay item
elif self.mouse['box'] == 'point' and self.dragid != None and self.dragid != 99:
@@ -1140,6 +1141,13 @@
"""
self.MapWindow.UpdateMap()
+ def ReRender(self, event):
+ """
+ Rerender button clicked
+ """
+ self.render = True
+ self.MapWindow.UpdateMap()
+
def Pointer(self, event):
"""Pointer button clicled"""
self.MapWindow.mouse['box'] = "point"
@@ -1217,13 +1225,29 @@
"""
Save to file
"""
+ filetype = "PNG file (*.png)|*.png|"\
+ "TIF file (*.tif)|*.tif|"\
+ "GIF file (*.gif)|*.gif"
+
dlg = wx.FileDialog(self, "Choose a file name to save the image as a PNG to",
defaultDir = "",
defaultFile = "",
- wildcard = "*.png",
- style=wx.SAVE)
+ wildcard = filetype,
+ style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
if dlg.ShowModal() == wx.ID_OK:
- self.MapWindow.SaveToFile(dlg.GetPath(), wx.BITMAP_TYPE_PNG)
+ base = os.path.splitext(dlg.GetPath())[0]
+ ext = os.path.splitext(dlg.GetPath())[1]
+ if dlg.GetFilterIndex() == 0:
+ type = wx.BITMAP_TYPE_PNG
+ path = dlg.GetPath()
+ if ext != '.png': path = base+'.png'
+ elif dlg.GetFilterIndex() == 1:
+ type = wx.BITMAP_TYPE_TIF
+ if ext != '.tif': path = base+'.tif'
+ elif dlg.GetFilterIndex() == 2:
+ type = wx.BITMAP_TYPE_TIF
+ if ext != '.gif': path = base+'.gif'
+ self.MapWindow.SaveToFile(path, type)
dlg.Destroy()
def PrintMap(self, event):
From landa at grass.itc.it Mon Apr 16 15:43:46 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Mon Apr 16 15:43:46 2007
Subject: [grass-addons] r512 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704161343.l3GDhkUr010945@grass.itc.it>
Author: landa
Date: 2007-04-16 15:43:45 +0200 (Mon, 16 Apr 2007)
New Revision: 512
Added:
trunk/grassaddons/gui/gui_modules/debug.py
Log:
debug module added
Added: trunk/grassaddons/gui/gui_modules/debug.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/debug.py (rev 0)
+++ trunk/grassaddons/gui/gui_modules/debug.py 2007-04-16 13:43:45 UTC (rev 512)
@@ -0,0 +1,64 @@
+"""
+MODULE: debug
+
+CLASSES:
+ * Debug
+
+PURPOSE: GRASS debugging
+
+AUTHORS: The GRASS Development Team
+ Martin Landa
+
+COPYRIGHT: (C) 2007 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.
+"""
+
+import grassenv
+
+class Debug:
+ """
+ GRASS Debugging
+
+ Usage:
+ import cmd
+
+ cmd.Command (cmd="g.gisenv set=DEBUG=3")
+
+ import grassenv # or reload (grassenv)
+
+ debug = Debug()
+ debug.msg (3, "message level=%d" % 3)
+ """
+ def __init__(self):
+ self.debuglevel = 0
+ self._update_level()
+
+ def _update_level(self):
+ if grassenv.env.has_key ("DEBUG"):
+ level = int (grassenv.env["DEBUG"])
+ if self.debuglevel != level:
+ self.debuglevel = level
+
+ def msg (self, level, message):
+ self._update_level()
+ if self.debuglevel > 0 and level >= self.debuglevel:
+ print "D%d/%d: %s" % (level, level, message)
+
+
+# testing
+if __name__ == "__main__":
+ import cmd
+ cmd.Command (cmd="g.gisenv set=DEBUG=3")
+
+ for unit in range (2):
+ if unit == 1:
+ cmd.Command (cmd="g.gisenv set=DEBUG=0")
+
+ reload (grassenv) # reload GRASS environments !
+ debug = Debug()
+
+ print "DEBUG=%d" % debug.debuglevel
+ for level in range (4):
+ debug.msg (level, "message level=%d" % level)
From neteler at grass.itc.it Mon Apr 16 16:41:50 2007
From: neteler at grass.itc.it (neteler@grass.itc.it)
Date: Mon Apr 16 16:41:52 2007
Subject: [grass-addons] r513 - trunk/grassaddons/grassflyer/flyer1/en
Message-ID: <200704161441.l3GEfok7011513@grass.itc.it>
Author: neteler
Date: 2007-04-16 16:41:50 +0200 (Mon, 16 Apr 2007)
New Revision: 513
Added:
trunk/grassaddons/grassflyer/flyer1/en/caption.sty
Log:
added (rather) new caption style which isn't available on older teTeXs
Added: trunk/grassaddons/grassflyer/flyer1/en/caption.sty
===================================================================
--- trunk/grassaddons/grassflyer/flyer1/en/caption.sty (rev 0)
+++ trunk/grassaddons/grassflyer/flyer1/en/caption.sty 2007-04-16 14:41:50 UTC (rev 513)
@@ -0,0 +1,688 @@
+%%
+%% This is file `caption.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% caption.dtx (with options: `package')
+%%
+%% Copyright (C) 1994-2004 Axel Sommerfeldt (caption@sommerfeldt.net)
+%%
+%% --------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% This Current Maintainer of this work is Axel Sommerfeldt.
+%%
+%% This work consists of the files caption.ins, caption.dtx,
+%% caption2.dtx, caption.xml, and anleitung.tex and the derived files
+%% caption.sty, caption2.sty, and manual.tex.
+%%
+\NeedsTeXFormat{LaTeX2e}[1994/12/01]
+\ProvidesPackage{caption}[2004/07/16 v3.0c Customising captions (AS)]
+\providecommand*\@nameundef[1]{%
+ \expandafter\let\csname #1\endcsname\@undefined}
+\providecommand\l@addto@macro[2]{%
+ \begingroup
+ \toks@\expandafter{#1#2}%
+ \edef\@tempa{\endgroup\def\noexpand#1{\the\toks@}}%
+ \@tempa}
+\def\bothIfFirst#1#2{%
+ \protected@edef\caption@tempa{#1}%
+ \ifx\caption@tempa\@empty\else
+ #1#2%
+ \fi}
+\def\bothIfSecond#1#2{%
+ \protected@edef\caption@tempa{#2}%
+ \ifx\caption@tempa\@empty\else
+ #1#2%
+ \fi}
+\def\caption@ifinlist#1#2{%
+ \let\next\@secondoftwo
+ \edef\caption@tempa{#1}%
+ \@for\caption@tempb:={#2}\do{%
+ \ifx\caption@tempa\caption@tempb
+ \let\next\@firstoftwo
+ \fi}%
+ \next}
+\def\caption@setbool#1#2{%
+ \caption@ifinlist{#2}{1,true,yes,on}{%
+ \expandafter\let\csname caption@if#1\endcsname\@firstoftwo
+ }{\caption@ifinlist{#2}{0,false,no,off}{%
+ \expandafter\let\csname caption@if#1\endcsname\@secondoftwo
+ }{%
+ \PackageError{caption}{Undefined boolean value `#2'}{\caption@eh}%
+ }}}
+\def\caption@ifbool#1{\@nameuse{caption@if#1}}
+\providecommand\captionsize{}% changed v3.0a+c
+\newdimen\captionmargin
+\newdimen\captionwidth
+\newif\ifcaption@width
+\newcommand\caption@setmargin{%
+ \caption@widthfalse
+ \setlength\captionmargin}
+\newcommand\caption@setwidth{%
+ \caption@widthtrue
+ \setlength\captionwidth}
+\newdimen\captionindent
+\newdimen\captionparindent
+\newdimen\captionhangindent
+\newif\ifcaption@star
+\@ifundefined{abovecaptionskip}{%
+ \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
+\@ifundefined{belowcaptionskip}{%
+ \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}
+\newcommand\caption@eh{%
+ If you do not understand this error, please take a closer look\MessageBreak
+ at the documentation of the `caption' package.\MessageBreak
+ \@ehc}
+\RequirePackage{keyval}[1997/11/10]
+\providecommand*\undefine@key[2]{%
+ \@nameundef{KV@#1@#2}\@nameundef{KV@#1@#2@default}}
+\newcommand\caption@setdefault{\captionsetup{%
+ format=default,labelformat=default,labelsep=default,justification=default,%
+ font=default,labelfont=default,textfont=default,%
+ margin=0pt,indention=0pt,parindent=0pt,hangindent=0pt,singlelinecheck}}
+\newcommand*\DeclareCaptionStyle[1]{%
+ \@ifnextchar[{\caption@declarestyle{#1}}{\caption@declarestyle{#1}[]}}
+\def\caption@declarestyle#1[#2]#3{% bugfixed v3.0a
+ \global\@namedef{caption@sls@#1}{#2}%
+ \global\@namedef{caption@sty@#1}{#3}}
+\@onlypreamble\DeclareCaptionStyle
+\@onlypreamble\caption@declarestyle
+\newcommand*\caption@setstyle[1]{%
+ \@ifundefined{caption@sty@#1}%
+ {\PackageError{caption}{Undefined caption style `#1'}{\caption@eh}}%
+ {\expandafter\let\expandafter\caption@sls\csname caption@sls@#1\endcsname
+ \caption@setdefault\caption@esetup{\csname caption@sty@#1\endcsname}}}
+\DeclareCaptionStyle{default}[justification=centering]{}
+\newcommand\DeclareCaptionFormat[2]{% bugfixed v3.0a
+ \global\long\expandafter\def\csname caption@fmt@#1\endcsname##1##2##3{#2}}
+\@onlypreamble\DeclareCaptionFormat
+\newcommand*\caption@setformat[1]{%
+ \@ifundefined{caption@fmt@#1}%
+ {\PackageError{caption}{Undefined caption format `#1'}{\caption@eh}}%
+ {\expandafter\let\expandafter\caption@fmt\csname caption@fmt@#1\endcsname}}
+\DeclareCaptionFormat{normal}{#1#2#3\par}
+\DeclareCaptionFormat{hang}{%
+ \@hangfrom{#1#2}%
+ \advance\captionparindent\hangindent
+ \advance\captionhangindent\hangindent
+ \caption@@par
+ #3\par}
+\def\caption@fmt@default{\caption@fmt@normal}
+\newcommand*\DeclareCaptionLabelFormat[2]{% bugfixed v3.0a
+ \global\expandafter\def\csname caption@lfmt@#1\endcsname##1##2{#2}}
+\@onlypreamble\DeclareCaptionLabelFormat
+\newcommand*\caption@setlabelformat[1]{%
+ \@ifundefined{caption@lfmt@#1}%
+ {\PackageError{caption}{Undefined caption label format `#1'}{\caption@eh}}%
+ {\expandafter\let\expandafter\caption@lfmt\csname caption@lfmt@#1\endcsname}}
+\DeclareCaptionLabelFormat{empty}{}
+\DeclareCaptionLabelFormat{simple}{\bothIfFirst{#1}{\nobreakspace}#2}
+\DeclareCaptionLabelFormat{parens}{\bothIfFirst{#1}{\nobreakspace}(#2)}
+\def\caption@lfmt@default{\caption@lfmt@simple}
+\newcommand\DeclareCaptionLabelSeparator[2]{% bugfixed v3.0a
+ \global\long\@namedef{caption@lsep@#1}{#2}}
+\@onlypreamble\DeclareCaptionLabelSeparator
+\newcommand*\caption@setlabelseparator[1]{%
+ \@ifundefined{caption@lsep@#1}%
+ {\PackageError{caption}{Undefined caption label separator `#1'}{\caption@eh}}%
+ {\expandafter\let\expandafter\caption@lsep\csname caption@lsep@#1\endcsname}}
+\DeclareCaptionLabelSeparator{none}{}
+\DeclareCaptionLabelSeparator{colon}{: }
+\DeclareCaptionLabelSeparator{period}{. }
+\DeclareCaptionLabelSeparator{space}{ }
+\DeclareCaptionLabelSeparator{quad}{\quad}
+\DeclareCaptionLabelSeparator{newline}{\newline}
+\DeclareCaptionLabelSeparator{widespace}{\hspace{1em plus .3em}}% obsolete, do not use!
+\def\caption@lsep@default{\caption@lsep@colon}
+\newcommand*\DeclareCaptionJustification[2]{% bugfixed v3.0a
+ \global\@namedef{caption@hj@#1}{#2}}
+\@onlypreamble\DeclareCaptionJustification
+\newcommand*\caption@setjustification[1]{%
+ \@ifundefined{caption@hj@#1}%
+ {\PackageError{caption}{Undefined caption justification `#1'}{\caption@eh}}%
+ {\expandafter\let\expandafter\caption@hj\csname caption@hj@#1\endcsname}}
+\newcommand\caption@centerfirst{%
+ \edef\caption@normaladjust{%
+ \leftskip\the\leftskip
+ \rightskip\the\rightskip
+ \parfillskip\the\parfillskip\relax}%
+ \leftskip\z@\@plus -1fil%
+ \rightskip\z@\@plus 1fil%
+ \parfillskip\z@skip
+ \noindent\hskip\z@\@plus 2fil%
+ \@setpar{\@@par\@restorepar\caption@normaladjust}}
+\newcommand\caption@centerlast{%
+ \leftskip\z@\@plus 1fil%
+ \rightskip\z@\@plus -1fil%
+ \parfillskip\z@\@plus 2fil\relax}
+\DeclareCaptionJustification{justified}{}
+\DeclareCaptionJustification{centering}{\centering}
+\DeclareCaptionJustification{centerfirst}{\caption@centerfirst}
+\DeclareCaptionJustification{centerlast}{\caption@centerlast}
+\DeclareCaptionJustification{raggedleft}{\raggedleft}
+\DeclareCaptionJustification{raggedright}{\raggedright}
+\def\caption@hj@default{\caption@hj@justified}
+\DeclareCaptionJustification{Centering}{%
+ \caption@ragged\Centering\centering}
+\DeclareCaptionJustification{RaggedLeft}{%
+ \caption@ragged\RaggedLeft\raggedleft}
+\DeclareCaptionJustification{RaggedRight}{%
+ \caption@ragged\RaggedRight\raggedright}
+\newcommand*\caption@ragged[2]{%
+ \@ifundefined{caption\string#1}{%
+ \PackageWarning{caption}{%
+ Cannot locate the `ragged2e' package, therefore\MessageBreak
+ substituting \string#2 for \string#1\MessageBreak}%
+ \global\@namedef{caption\string#1}}{}%
+ #2}
+\AtBeginDocument{\IfFileExists{ragged2e.sty}{%
+ \RequirePackage{ragged2e}\let\caption@ragged\@firstoftwo}{}}
+\newcommand\DeclareCaptionFont[2]{% bugfixed v3.0a
+ \define@key{caption@fnt}{#1}[]{\g@addto@macro\caption@tempa{#2}}}
+\@onlypreamble\DeclareCaptionFont
+\newcommand*\caption@setfont[2]{%
+ \let\caption@tempa\@empty
+ \begingroup
+ \setkeys{caption@fnt}{#2}%
+ \endgroup
+ \expandafter\let\csname caption#1\endcsname\caption@tempa}
+\DeclareCaptionFont{default}{}
+\DeclareCaptionFont{scriptsize}{\scriptsize}
+\DeclareCaptionFont{footnotesize}{\footnotesize}
+\DeclareCaptionFont{small}{\small}
+\DeclareCaptionFont{normalsize}{\normalsize}
+\DeclareCaptionFont{large}{\large}
+\DeclareCaptionFont{Large}{\Large}
+\DeclareCaptionFont{up}{\upshape}
+\DeclareCaptionFont{it}{\itshape}
+\DeclareCaptionFont{sl}{\slshape}
+\DeclareCaptionFont{sc}{\scshape}
+\DeclareCaptionFont{md}{\mdseries}
+\DeclareCaptionFont{bf}{\bfseries}
+\DeclareCaptionFont{rm}{\rmfamily}
+\DeclareCaptionFont{sf}{\sffamily}
+\DeclareCaptionFont{tt}{\ttfamily}
+\newcommand*\caption@setposition[1]{% improved v3.0a
+ \caption@ifinlist{#1}{t,top,above}{%
+ \let\caption@position\@firstoftwo
+ }{\caption@ifinlist{#1}{b,bottom,below,default}{%
+ \let\caption@position\@secondoftwo
+ }{\caption@ifinlist{#1}{a,auto}{%
+ \let\caption@position\@undefined
+ }{%
+ \PackageError{caption}{Undefined caption position `#1'}{\caption@eh}%
+ }}}}
+\def\captionsetup{\@ifnextchar[\caption@setuptype\caption@setup}
+\def\caption@setuptype[#1]#2{% bugfixed v3.0a
+ \@ifundefined{caption@typ@#1}%
+ {\@namedef{caption@typ@#1}{#2}}%
+ {\expandafter\l@addto@macro\csname caption@typ@#1\endcsname{,#2}}}
+\def\caption@setup{\setkeys{caption}}
+\def\caption@esetup#1{%
+ \edef\caption@tempa{\noexpand\caption@setup{#1}}%
+ \caption@tempa}
+\def\caption@settype#1{%
+ \@ifundefined{caption@typ@#1}{}{%
+ \caption@esetup{\csname caption@typ@#1\endcsname}}}%
+\let\caption@setfloattype\caption@settype% new v3.0a
+\newcommand*\clearcaptionsetup[1]{\@nameundef{caption@typ@#1}}
+\newcommand*\showcaptionsetup[2][]{%
+ \def\caption@tempa{#1}%
+ \ifx\caption@tempa\@empty
+ \def\caption@tempa{Caption\space}%
+ \else
+ \def\caption@tempa{#1 Caption\space}%
+ \fi
+ \GenericWarning{\caption@tempa}{%
+ \caption@tempa Info: KV list on `#2'\MessageBreak
+ Data: (%
+ \@ifundefined{caption@typ@#2}{%
+ % Empty -- print nothing.
+ }{%
+ \@nameuse{caption@typ@#2}%
+ }%
+ )}}
+\newcommand\caption@beginhook{}
+\newcommand\caption@endhook{}
+\newcommand\AtBeginCaption{\l@addto@macro\caption@beginhook}
+\newcommand\AtEndCaption{\l@addto@macro\caption@endhook}
+\newcommand\DeclareCaptionOption{%
+ \@ifstar{\caption@declareoption\AtEndOfPackage}{\caption@declareoption\@gobble}}
+\newcommand*\caption@declareoption[2]{%
+ #1{\undefine@key{caption}{#2}}\define@key{caption}{#2}}
+\@onlypreamble\DeclareCaptionOption
+\@onlypreamble\caption@declareoption
+\DeclareCaptionOption{default}[]{%
+ \caption@setup{style=default,position=default,aboveskip=10pt,belowskip=0pt}}
+\DeclareCaptionOption{style}{\caption@setstyle{#1}}
+\DeclareCaptionOption{format}{\caption@setformat{#1}}
+\DeclareCaptionOption{labelformat}{\caption@setlabelformat{#1}}
+\DeclareCaptionOption{labelsep}{\caption@setlabelseparator{#1}}
+\DeclareCaptionOption{labelseparator}{\caption@setlabelseparator{#1}}
+\DeclareCaptionOption{justification}{\caption@setjustification{#1}}
+\DeclareCaptionOption{size}{\caption@setfont{size}{#1}}% changed v3.0a
+\DeclareCaptionOption{font}{\caption@setfont{font}{#1}}
+\DeclareCaptionOption{labelfont}{\caption@setfont{labelfont}{#1}}
+\DeclareCaptionOption{textfont}{\caption@setfont{textfont}{#1}}
+\DeclareCaptionOption{margin}{\caption@setmargin{#1}}
+\DeclareCaptionOption{width}{\caption@setwidth{#1}}
+\DeclareCaptionOption{indent}[\leftmargini]{\setlength\captionindent{#1}}
+\DeclareCaptionOption{indention}[\leftmargini]{\setlength\captionindent{#1}}
+\DeclareCaptionOption{parindent}[\parindent]{\setlength\captionparindent{#1}}% changed v3.0b
+\DeclareCaptionOption{hangindent}[0pt]{\setlength\captionhangindent{#1}}% changed v3.0b
+\DeclareCaptionOption{parskip}[5pt]{\AtBeginCaption{\setlength\parskip{#1}}}
+\DeclareCaptionOption{singlelinecheck}[1]{\caption@setbool{slc}{#1}}
+\DeclareCaptionOption{aboveskip}{\setlength\abovecaptionskip{#1}}
+\DeclareCaptionOption{belowskip}{\setlength\belowcaptionskip{#1}}
+\DeclareCaptionOption{position}{\caption@setposition{#1}}
+\DeclareCaptionOption{listof}{\caption@setbool{lof}{#1}}% new v3.0b
+\DeclareCaptionOption{debug}{\def\caption@debug{#1}}
+\captionsetup{style=default,position=default,listof=1,debug=0}
+\newcommand\caption@fixposition{%
+ \ifx\caption@position\@undefined
+ \caption@autoposition
+ \fi}
+\newcommand\caption@autoposition{% bugfixed v3.0a
+ \ifvmode
+ \ifodd\caption@debug\relax
+ \edef\caption@tempa{\the\prevdepth}%
+ \PackageInfo{caption}{\protect\prevdepth=\caption@tempa}%
+ \fi
+ \ifdim\prevdepth>-\p@
+ \let\caption@position\@secondoftwo
+ \else
+ \let\caption@position\@firstoftwo
+ \fi
+ \else
+ \ifodd\caption@debug\relax
+ \PackageInfo{caption}{no \protect\prevdepth}%
+ \fi
+ \let\caption@position\@secondoftwo
+ \fi}
+\newcommand\caption@iftop{% bugfixed v3.0a
+ \ifx\caption@position\@firstoftwo
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi}
+\newcommand\caption@make[2]{%
+ \caption@@make{\caption@lfmt{#1}{#2}}}
+\newcommand\caption@@make[2]{%
+ \caption@beginhook
+ \caption@calcmargin
+ \advance\captionmargin by \captionindent
+ \advance\captionwidth by -\captionindent
+ \hskip\captionmargin
+ \vbox{\hsize=\captionwidth
+ \ifdim\captionindent=\z@\else
+ \hskip-\captionindent
+ \fi
+ \caption@ifslc{%
+ \ifx\caption@sls\@empty\else
+ \caption@beginslc
+ \sbox\@tempboxa{\caption@@@make{#1}{#2}}%
+ \ifdim\wd\@tempboxa >\hsize
+ \caption@endslc
+ \else
+ \caption@endslc
+ \caption@esetup\caption@sls
+ \fi
+ \fi}{}%
+ \captionsize\captionfont\strut
+ \caption@@@make{#1}{#2}}%
+ \caption@endhook
+ \global\caption@starfalse}
+\newcommand\caption@calcmargin{%
+ \ifcaption@width
+ \captionmargin\hsize
+ \advance\captionmargin by -\captionwidth
+ \divide\captionmargin by 2
+ \else
+ \captionwidth\hsize
+ \advance\captionwidth by -2\captionmargin
+ \fi
+ \ifodd\caption@debug\relax
+ \PackageInfo{caption}{\protect\hsize=\the\hsize,
+ \protect\margin=\the\captionmargin,
+ \protect\width=\the\captionwidth}%
+ \fi}
+\newcommand\caption@beginslc{%
+ \begingroup
+ \let\label\@gobble\let\@footnotetext\@gobble
+ \def\stepcounter##1{\advance\csname c@##1\endcsname\@ne\relax}}
+\newcommand\caption@endslc{%
+ \endgroup}
+\newcommand\caption@@@make[2]{%
+ \ifcaption@star
+ \let\caption@lfmt\@gobbletwo
+ \let\caption@lsep\relax
+ \fi
+ \def\caption@tempa{#2}%
+ \def\caption@tempb{\ignorespaces}%
+ \ifx\caption@tempa\caption@tempb
+ \let\caption@tempa\@empty
+ \fi
+ \ifx\caption@tempa\@empty
+ \let\caption@lsep\relax
+ \fi
+ \def\caption@@par{%
+ \parindent\captionparindent\hangindent\captionhangindent}%
+ \@setpar{\@@par\caption@@par}\caption@@par
+ \caption@hj\captionsize\captionfont
+ \caption@fmt{{\captionlabelfont#1}}%
+ {{\captionlabelfont\caption@lsep}}%
+ {{\captiontextfont\nobreak\hskip\z@skip#2\par}}}
+\DeclareCaptionOption{config}[caption]{%
+ \InputIfFileExists{#1.cfg}{\typeout{*** Local configuration file
+ #1.cfg used ***}}%
+ {\PackageWarning{caption}{Configuration
+ file #1.cfg not found}}}
+\DeclareCaptionOption*{figureposition}{\captionsetup[figure]{position=#1}}% new v3.0a
+\DeclareCaptionOption*{tableposition}{\captionsetup[table]{position=#1}}% new v3.0a
+\DeclareCaptionOption*{normal}[]{\caption@setformat{normal}}
+\DeclareCaptionOption*{isu}[]{\caption@setformat{hang}}
+\DeclareCaptionOption*{hang}[]{\caption@setformat{hang}}
+\DeclareCaptionOption*{center}[]{\caption@setjustification{centering}}
+\DeclareCaptionOption*{anne}[]{\caption@setjustification{centerlast}}
+\DeclareCaptionOption*{centerlast}[]{\caption@setjustification{centerlast}}
+\DeclareCaptionOption*{nooneline}[]{\caption@setbool{slc}{0}}
+\DeclareCaptionOption*{scriptsize}[]{\def\captionfont{\scriptsize}}
+\DeclareCaptionOption*{footnotesize}[]{\def\captionfont{\footnotesize}}
+\DeclareCaptionOption*{small}[]{\def\captionfont{\small}}
+\DeclareCaptionOption*{normalsize}[]{\def\captionfont{\normalsize}}
+\DeclareCaptionOption*{large}[]{\def\captionfont{\large}}
+\DeclareCaptionOption*{Large}[]{\def\captionfont{\Large}}
+\DeclareCaptionOption*{up}[]{\l@addto@macro\captionlabelfont\upshape}
+\DeclareCaptionOption*{it}[]{\l@addto@macro\captionlabelfont\itshape}
+\DeclareCaptionOption*{sl}[]{\l@addto@macro\captionlabelfont\slshape}
+\DeclareCaptionOption*{sc}[]{\l@addto@macro\captionlabelfont\scshape}
+\DeclareCaptionOption*{md}[]{\l@addto@macro\captionlabelfont\mdseries}
+\DeclareCaptionOption*{bf}[]{\l@addto@macro\captionlabelfont\bfseries}
+\DeclareCaptionOption*{rm}[]{\l@addto@macro\captionlabelfont\rmfamily}
+\DeclareCaptionOption*{sf}[]{\l@addto@macro\captionlabelfont\sffamily}
+\DeclareCaptionOption*{tt}[]{\l@addto@macro\captionlabelfont\ttfamily}
+\caption@setbool{ruled}{0}
+\DeclareCaptionOption*{ruled}[]{\caption@setbool{ruled}{1}}
+\newcommand*\DeclareCaptionPackage[1]{%
+ \caption@setbool{pkt@#1}{1}%
+ \DeclareCaptionOption*{#1}{\caption@setbool{pkt@#1}{##1}}}
+\DeclareCaptionPackage{caption}
+\DeclareCaptionPackage{float}
+\DeclareCaptionPackage{listings}
+\DeclareCaptionPackage{longtable}
+\DeclareCaptionPackage{rotating}
+\DeclareCaptionPackage{sidecap}
+\DeclareCaptionPackage{supertabular}
+\let\DeclareCaptionPackage\@undefined
+\def\ProcessOptionsWithKV#1{% bugfixed v3.0a
+ \let\@tempc\relax
+ \let\caption@tempa\@empty
+ \@for\CurrentOption:=\@classoptionslist\do{%
+ \@ifundefined{KV@#1@\CurrentOption}%
+ {}%
+ {%
+ \edef\caption@tempa{\caption@tempa,\CurrentOption,}%
+ \@expandtwoargs\@removeelement\CurrentOption
+ \@unusedoptionlist\@unusedoptionlist
+ }%
+ }%
+ \edef\caption@tempa{%
+ \noexpand\setkeys{#1}{%
+ \caption@tempa\@ptionlist{\@currname.\@currext}%
+ }%
+ }%
+ \caption@tempa
+ \let\CurrentOption\@empty
+ \AtEndOfPackage{\let\@unprocessedoptions\relax}}
+\ProcessOptionsWithKV{caption}
+\let\ProcessOptionsWithKV\@undefined
+\def\captionof{\@ifstar{\caption@of{\caption*}}{\caption@of\caption}}
+\newcommand*\caption@of[2]{\def\@captype{#2}#1}
+\providecommand\ContinuedFloat{%
+ \ifx\@captype\@undefined
+ \@latex@error{\noexpand\ContinuedFloat outside float}\@ehd
+ \else
+ \addtocounter{\@captype}{\m@ne}%
+ \fi}%
+\newcommand*\caption@floatname[1]{\@nameuse{#1name}}
+\newcommand*\caption@thefloat[1]{\@nameuse{the#1}}
+\def\caption@letfloattype#1{%
+ \def\caption@setfloattype##1{%
+ \caption@settype{##1}\caption@settype{#1}}}
+\newcommand*\caption@begin[1]{%
+ \begingroup
+ \caption@setfloattype{#1}%
+ \@namedef{fnum@#1}{%
+ \caption@lfmt{\caption@floatname{#1}}{\caption@thefloat{#1}}}%
+ \caption@fixposition
+ \global\let\caption@fixedposition\caption@position
+ \caption@@begin{#1}}
+\newcommand*\caption@beginex[1]{%
+ \caption@begin{#1}%
+ \caption@preparelof}
+\newcommand*\caption@end{%
+ \caption@@end
+ \endgroup
+ \let\caption@position\caption@fixedposition}
+\let\caption@@begin\@gobble% new v3.0a
+\let\caption@@end\@empty% new v3.0a
+\newcommand*\caption@preparelof[1]{% changed v3.0b
+ \caption@ifbool{lof}%
+ {\def\caption@tempa{#1}}%
+ {\let\caption@tempa\@empty}%
+ \ifx\caption@tempa\@empty
+ \def\addcontentsline##1##2##3{}%
+ \fi}
+\caption@ifpkt@caption{
+ \renewcommand\@makecaption[2]{%
+ \caption@iftop{\vskip\belowcaptionskip}{\vskip\abovecaptionskip}%
+ \ifnum\caption@debug>1 %
+ \llap{$\caption@iftop\downarrow\uparrow$ }%
+ \fi
+ \caption@@make{#1}{#2}%
+ \caption@iftop{\vskip\abovecaptionskip}{\vskip\belowcaptionskip}}
+ \AtBeginDocument{%
+ \@ifundefined{cc@caption}{%
+ \def\caption@caption#1{%
+ \@ifstar{\global\caption@startrue\@ifnextchar[{#1}{#1[]}}{#1}}%
+ \let\caption@old\caption
+ \def\caption{\caption@caption\caption@old}%
+ \let\caption@@old\@caption
+ \long\def\@caption#1[#2]#3{%
+ \caption@beginex{#1}{#2}%
+ \caption@@old{#1}[{#2}]{#3}%
+ \caption@end}%
+ }{%
+ \PackageInfo{caption}{captcont package v2.0 detected}%
+ \def\caption@caption#1{#1}% added v3.0c
+ }%
+ }}{}
+\AtEndOfPackage{\let\caption@ifpkt@caption\@undefined}% bugfixed v3.0a
+\newcommand*\caption@ifpackage[2]{%
+ \let\next\@gobble
+ \caption@ifpkt@caption{%
+ \caption@ifbool{pkt@#1}{%
+ \@ifundefined{#2}%
+ {\let\next\AtBeginDocument}%
+ {\let\next\@firstofone}}{}%
+ \ifodd\caption@debug\relax
+ \edef\caption@tempa{%
+ \caption@ifbool{pkt@#1}{%
+ \@ifundefined{#2}{AtBeginDocument}{firstofone}%
+ }{gobble}}%
+ \PackageInfo{caption}{#1 = \caption@ifbool{pkt@#1}{1}{0} %
+ (\@ifundefined{#2}{not }{}loaded -> \caption@tempa)}%
+ \fi
+ }{}%
+ \@nameundef{caption@ifpkt@#1}% bugfixed v3.0a
+ \next}
+\AtEndOfPackage{\let\caption@ifpackage\@undefined}
+\def\caption@setfloatposition{%
+ \caption@setposition{\@fs@iftopcapt t\else b\fi}}
+\caption@ifpackage{float}{float@caption}{%
+ \ifx\float@caption\relax
+ \else
+ \PackageInfo{caption}{float package v1.2 (or newer) detected}%
+ \let\caption@of@float\@gobble
+ \renewcommand*\caption@of[2]{%
+ \@ifundefined{fst@#2}{}{%
+ \let\caption@of@float\@firstofone
+ \@nameuse{fst@#2}\@float@setevery{#2}}%
+ \def\@captype{#2}#1}%
+ \renewcommand*\caption@floatname[1]{%
+ \@nameuse{\@ifundefined{fname@#1}{#1name}{fname@#1}}}%
+ \let\caption@@float\float@caption
+ \long\def\float@caption#1[#2]#3{%
+ \caption@beginex{#1}{#2}%
+ \let\@fs@capt\caption@@make
+ \caption@@float{#1}[{#2}]{#3}%
+ \caption@of@float{%
+ \def\caption@@make##1##2{\unvbox\@floatcapt}%
+ \@makecaption{}{}}%
+ \caption@end}%
+ \renewcommand*\caption@setfloattype[1]{% improved v3.0a
+ \caption@fixfloat@c{#1}%
+ \expandafter\ifx\csname @float@c@#1\endcsname\float@caption
+ \expandafter\let\expandafter\caption@fst\csname fst@#1\endcsname
+ \edef\caption@fst{\noexpand\string\expandafter\noexpand\caption@fst}%
+ \edef\caption@fst{\noexpand\@gobblefour\caption@fst}%
+ \@ifundefined{caption@sty@\caption@fst}{}{\caption@setstyle\caption@fst}%
+ \caption@setfloatposition% changed v3.0b
+ \fi
+ \caption@settype{#1}}%
+ \let\caption@float\caption
+ \def\caption{%
+ \ifx\@captype\@undefined
+ \@latex@error{\noexpand\caption outside float}\@ehd
+ \expandafter\@gobble
+ \else
+ \caption@fixfloat@c\@captype
+ \fi
+ \caption@float}%
+ \def\caption@fixfloat@c#1{%
+ \expandafter\let\expandafter\caption@tempa\csname @float@c@#1\endcsname
+ \ifx\caption@tempa\relax
+ \else\ifx\caption@tempa\float@caption
+ \else\ifx\caption@tempa\@caption
+ \else\ifx\caption@tempa\caption@@float
+ \ifodd\caption@debug\relax
+ \PackageInfo{caption}{\protect\@float@c@#1\space := \protect\float@caption}%
+ \fi
+ \expandafter\let\csname @float@c@#1\endcsname\float@caption
+ \else
+ \ifodd\caption@debug\relax
+ \PackageInfo{caption}{\protect\@float@c@#1\space := \protect\@caption}%
+ \fi
+ \expandafter\let\csname @float@c@#1\endcsname\@caption
+ \fi\fi\fi\fi}%
+ \fi}
+\caption@ifbool{ruled}{}{%
+ \DeclareCaptionStyle{ruled}{labelfont=bf,labelsep=space}}
+\let\caption@ifruled\@undefined
+\caption@ifpackage{listings}{lst@MakeCaption}{%
+ \ifx\lst@MakeCaption\relax
+ \else
+ \PackageInfo{caption}{listings package v1.2 (or newer) detected}%
+ \let\caption@lst@MakeCaption\lst@MakeCaption
+ \def\lst@MakeCaption#1{%
+ \let\caption@setfloattype\caption@settype
+ \def\caption@autoposition{\caption@setposition{#1}}%
+ \caption@begin{lstlisting}%
+ \caption@lst@MakeCaption{#1}%
+ \caption@end}%
+ \fi}
+\caption@ifpackage{longtable}{LT@makecaption}{%
+ \ifx\LT@makecaption\relax
+ \else
+ \PackageInfo{caption}{longtable package v3.15 (or newer) detected}%
+ \def\LT@makecaption#1#2#3{%
+ \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\linewidth{%
+ \caption@letfloattype{longtable}%
+ \caption@begin{table}%
+ \ifdim\LTcapwidth=4in \else
+ \caption@setwidth\LTcapwidth
+ \fi
+ \caption@startrue#1\caption@starfalse
+ \caption@@make{#2}{#3}%
+ \endgraf\vskip\baselineskip
+ \caption@end}%
+ \hss}}}%
+ \fi}
+\caption@ifpackage{rotating}{@rotcaption}{%
+ \ifx\@rotcaption\relax
+ \else
+ \PackageInfo{caption}{rotating package v2.0 (or newer) detected}%
+ \let\caption@rot\rotcaption
+ \def\rotcaption{\caption@caption\caption@rot}%
+ \let\caption@@rot\@rotcaption
+ \long\def\@rotcaption#1[#2]#3{%
+ \caption@beginex{#1}{#2}%
+ \caption@@rot{#1}[{#2}]{#3}%
+ \caption@end}%
+ \long\def\@makerotcaption#1#2{%
+ \rotatebox{90}{%
+ \begin{minipage}{.8\textheight}%
+ \caption@@make{#1}{#2}%
+ \end{minipage}%
+ }\par
+ \hspace{12pt}}%
+ \fi}
+\caption@ifpackage{sidecap}{endSC@FLOAT}{%
+ \ifx\endSC@FLOAT\relax
+ \else
+ \PackageInfo{caption}{sidecap package v1.4d (or newer) detected}%
+ \let\SC@caption=\caption
+ \let\caption@SC@zfloat\SC@zfloat
+ \def\SC@zfloat#1#2#3[#4]{%
+ \caption@SC@zfloat{#1}{#2}{#3}[#4]%
+ \global\let\SC@CAPsetup\@empty
+ \renewcommand\captionsetup[1]{\g@addto@macro\SC@CAPsetup{,##1}}%
+ \let\caption@old\caption
+ \def\caption{\caption@caption\caption@old}%
+ }%
+ \let\caption@endSC@FLOAT\endSC@FLOAT
+ \def\endSC@FLOAT{%
+ \caption@setmargin\z@
+ \@ifundefined{SC@justify}{}{%
+ \ifx\SC@justify\@empty\else
+ \let\caption@hj\SC@justify
+ \let\SC@justify\@empty
+ \fi}%
+ \caption@esetup\SC@CAPsetup
+ \caption@letfloattype{SC\@captype}%
+ \caption@endSC@FLOAT}%
+ \fi}
+\def\caption@setSTposition{%
+ \caption@setposition{\if@topcaption t\else b\fi}}
+\caption@ifpackage{supertabular}{ST@caption}{%
+ \ifx\ST@caption\relax
+ \else
+ \PackageInfo{caption}{supertabular package detected}%
+ \let\caption@ST\ST@caption
+ \long\def\ST@caption#1[#2]#3{\par% bugfixed v3.0a
+ \caption@letfloattype{supertabular}%
+ \let\caption@fixposition\caption@setSTposition
+ \caption@beginex{#1}{#2}%
+ \addcontentsline{\csname ext@#1\endcsname}{#1}%
+ {\protect\numberline{%
+ \csname the#1\endcsname}{\ignorespaces #2}}%
+ \@parboxrestore
+ \normalsize
+ \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
+ \caption@end}%
+ \fi}
+\AtBeginDocument{\let\scr@caption\caption}
+\endinput
+%%
+%% End of file `caption.sty'.
From landa at grass.itc.it Mon Apr 16 17:14:55 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Mon Apr 16 17:14:57 2007
Subject: [grass-addons] r514 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704161514.l3GFEtqd012439@grass.itc.it>
Author: landa
Date: 2007-04-16 17:14:55 +0200 (Mon, 16 Apr 2007)
New Revision: 514
Modified:
trunk/grassaddons/gui/gui_modules/debug.py
Log:
inor bugfix
Modified: trunk/grassaddons/gui/gui_modules/debug.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/debug.py 2007-04-16 14:41:50 UTC (rev 513)
+++ trunk/grassaddons/gui/gui_modules/debug.py 2007-04-16 15:14:55 UTC (rev 514)
@@ -43,22 +43,17 @@
def msg (self, level, message):
self._update_level()
- if self.debuglevel > 0 and level >= self.debuglevel:
- print "D%d/%d: %s" % (level, level, message)
+ if self.debuglevel > 0 and level > 0 and level <= self.debuglevel:
+ print "GUI D%d/%d: %s" % (level, level, message)
+# Debug instance
+Debug = Debug()
# testing
if __name__ == "__main__":
import cmd
cmd.Command (cmd="g.gisenv set=DEBUG=3")
-
- for unit in range (2):
- if unit == 1:
- cmd.Command (cmd="g.gisenv set=DEBUG=0")
-
- reload (grassenv) # reload GRASS environments !
- debug = Debug()
-
- print "DEBUG=%d" % debug.debuglevel
- for level in range (4):
- debug.msg (level, "message level=%d" % level)
+ reload (grassenv) # reload GRASS environments !
+
+ for level in range (4):
+ Debug.msg (level, "message level=%d" % level)
From landa at grass.itc.it Mon Apr 16 18:25:50 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Mon Apr 16 18:25:51 2007
Subject: [grass-addons] r515 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704161625.l3GGPoFq013063@grass.itc.it>
Author: landa
Date: 2007-04-16 18:25:50 +0200 (Mon, 16 Apr 2007)
New Revision: 515
Modified:
trunk/grassaddons/gui/gui_modules/mapdisp.py
trunk/grassaddons/gui/gui_modules/render.py
Log:
fixing broken scripts/p.mon
Modified: trunk/grassaddons/gui/gui_modules/mapdisp.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-16 15:14:55 UTC (rev 514)
+++ trunk/grassaddons/gui/gui_modules/mapdisp.py 2007-04-16 16:25:50 UTC (rev 515)
@@ -14,8 +14,6 @@
* MapApp
"""
-DEBUG = False
-
# Authors: Michael Barton and Jachym Cepicky
# COPYRIGHT: (C) 1999 - 2006 by the GRASS Development Team
# Double buffered drawing concepts from the wxPython Cookbook
@@ -30,6 +28,7 @@
import track
import menuform
from digit import Digit as Digit
+from debug import Debug as Debug
import images
imagepath = images.__path__[0]
@@ -53,8 +52,6 @@
else:
icons = os.environ["GRASS_ICONPATH"]
-#Map = render.Map() # instance of Map class to render GRASS display output to PPM file
-
# for cmdlinef
cmdfilename = None
@@ -69,7 +66,7 @@
global cmdfilename
self.parent = parent
- self.map = render.Map() # instance of Map class to render GRASS display output to PPM file
+ self.map = Map
self.cmdfile = open(cmdfilename,"r")
def run(self):
@@ -121,10 +118,7 @@
dispcmd[key] = value
- if DEBUG:
- print "Command.run(): ",
- print "opacity=%d name=%s mapset=%s" % (opacity, name, mapset),
- print dispcmd
+ Debug.msg (3, "Command.run(): opacity=%d name=%s mapset=%s, cmd=%s" % (opacity, name, mapset, dispcmd))
if action == "d.rast":
self.map.AddRasterLayer(name=name,
@@ -494,8 +488,7 @@
"""
- if DEBUG:
- print "Buffered Window.UpdateMap(%s): render=%s" % (img, self.render)
+ Debug.msg (3, "BufferedWindow.UpdateMap(%s): render=%s" % (img, self.render))
if self.render:
# render new map images
@@ -532,9 +525,10 @@
self.resize = False
# update statusbar
+ #Debug.msg (3, "BufferedWindow.UpdateMap(%s): region=%s" % self.Map.region)
self.parent.statusbar.SetStatusText("Extents: %d(W)-%d(E), %d(N)-%d(S)" %
- (self.Map.region["w"], self.Map.region["e"],
- self.Map.region["n"], self.Map.region["s"]), 0)
+ (self.Map.region["w"], self.Map.region["e"],
+ self.Map.region["n"], self.Map.region["s"]), 0)
def EraseMap(self):
"""
@@ -966,6 +960,8 @@
Map -- instance of render.Map
"""
+ Debug.msg (1, "MapFrame.__init__()")
+
wx.Frame.__init__(self, parent, id, title, pos, size, style)
# most of the thime, this will be the gis manager
@@ -1000,7 +996,7 @@
#
self.statusbar = self.CreateStatusBar(number=2, style=0)
self.statusbar.SetStatusWidths([-2, -1])
- map_frame_statusbar_fields = ["Extents: %d(W)-%d(E), %d(N)-%d(S)" %
+ map_frame_statusbar_fields = ["Extents: %d(W)-%d(E), %d(N)-%d(S)" %
(self.Map.region["w"], self.Map.region["e"],
self.Map.region["n"], self.Map.region["s"]),
"%s,%s" %(None, None)]
@@ -1116,8 +1112,10 @@
"""
# change bookcontrol page to page associted with display
- pgnum = self.layerbook.GetPageIndex(self.page)
- if pgnum > -1: self.layerbook.SetSelection(pgnum)
+ if self.page:
+ pgnum = self.layerbook.GetPageIndex(self.page)
+ if pgnum > -1:
+ self.layerbook.SetSelection(pgnum)
event.Skip()
def OnMotion(self, event):
@@ -1283,11 +1281,13 @@
"""
pgnum = None
self.Map.Clean()
- pgnum = self.layerbook.GetPageIndex(self.page)
+ if self.page:
+ pgnum = self.layerbook.GetPageIndex(self.page)
+ if pgnum > -1:
+ self.layerbook.DeletePage(pgnum)
+
self.Destroy()
- if pgnum > -1: self.layerbook.DeletePage(pgnum)
-
def getRender(self):
"""
returns the current instance of render.Map()
@@ -1769,7 +1769,12 @@
def OnInit(self):
wx.InitAllImageHandlers()
- self.mapFrm = MapFrame(parent=None, id=wx.ID_ANY)
+ if __name__ == "__main__":
+ Map = render.Map() # instance of Map class to render GRASS display output to PPM file
+ else:
+ Map = None
+
+ self.mapFrm = MapFrame(parent=None, id=wx.ID_ANY, Map=Map)
#self.SetTopWindow(Map)
self.mapFrm.Show()
Modified: trunk/grassaddons/gui/gui_modules/render.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/render.py 2007-04-16 15:14:55 UTC (rev 514)
+++ trunk/grassaddons/gui/gui_modules/render.py 2007-04-16 16:25:50 UTC (rev 515)
@@ -6,12 +6,12 @@
import os,sys,glob
import utils
+from debug import Debug as Debug
# Authors : Michael Barton, Jachym Cepicky, Martin Landa
#
# COPYRIGHT:(C) 1999 - 2007 by the GRASS Development Team
-DEBUG = False
class GRASSLayer:
"""
@@ -56,10 +56,8 @@
self.grassLayer = GRASSLayer(dispcmd)
- if DEBUG:
- print "MapLayer.__init__(): name=%s, mapset=%s, opacity=%d" % \
- (name, mapset, opacity),
- print dispcmd
+ Debug.msg (1, "MapLayer.__init__(): name=%s, mapset=%s, opacity=%d, %s" %
+ (name, mapset, opacity, dispcmd))
gtemp = utils.GetTempfile()
self.maskfile = gtemp + ".pgm"
@@ -81,9 +79,7 @@
else:
self.cmd += " -%s" % key
- if DEBUG:
- print "MapLayer.__renderRasterLayer():",
- print self.cmd
+ Debug.msg (3, "MapLayer.__renderRasterLayer(): %s" % self.cmd)
except StandardError, e:
sys.stderr.write("Could not render raster layer <%s>: %s\n" %\
@@ -105,9 +101,7 @@
else:
self.cmd += " -%s" % key
- if DEBUG:
- print "MapLayer.__renderVectorLayer():",
- print self.cmd
+ Debug.msg (3, "MapLayer.__renderVectorLayer(): %s" % self.cmd)
except StandardError, e:
sys.stderr.write("Could not render vector layer <%s>: %s\n" %\
@@ -206,7 +200,7 @@
#
if not self.cmd:
sys.stderr.write("Could not render layer <%s> with command: #%s#" %\
- (self.name, self.cmd))
+ (self.name, self.cmd))
return None
if os.system(self.cmd):
@@ -569,8 +563,7 @@
os.environ["GRASS_WIDTH"] = str(self.width)
os.environ["GRASS_HEIGHT"] = str(self.height)
- if DEBUG:
- print ("Map.Render() force=%s" % (force))
+ Debug.msg (3, "Map.Render() force=%s" % (force))
try:
# render overlays
@@ -591,8 +584,6 @@
# render map layers
for layer in self.layers:
- if DEBUG:
- print "rendering", layer.name
# skip if hidden or not active
if layer.active == False or layer.hidden == True:
continue
@@ -610,8 +601,7 @@
maps.append(layer.mapfile)
masks.append(layer.maskfile)
opacities.append(str(layer.opacity))
- if DEBUG:
- print "rendered", layer.name
+ Debug.msg (3, "Map.Render() layer=%s " % layer.name)
# make arrays to strings
mapstr = ",".join(maps)
@@ -626,7 +616,7 @@
" width=" + str(self.width) + \
" height=" + str(self.height) + \
" output=" + self.mapfile
-
+
# render overlays
os.unsetenv("GRASS_REGION")
@@ -639,6 +629,8 @@
sys.stderr.write("Could not run g.pnmcomp\n")
raise Exception (compcmd)
+ #Debug.msg (3, "Map.Render() file=%s,%s" % (self.mapfile, self.ovlist))
+
return self.mapfile, self.ovlist
except Exception, e:
From landa at grass.itc.it Mon Apr 16 18:40:23 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Mon Apr 16 18:40:24 2007
Subject: [grass-addons] r516 - in trunk/grassaddons/gui: . gui_modules
Message-ID: <200704161640.l3GGeNE4013091@grass.itc.it>
Author: landa
Date: 2007-04-16 18:40:22 +0200 (Mon, 16 Apr 2007)
New Revision: 516
Modified:
trunk/grassaddons/gui/gui_modules/toolbars.py
trunk/grassaddons/gui/wxgrass
Log:
enable DigitToolbar
Modified: trunk/grassaddons/gui/gui_modules/toolbars.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-16 16:25:50 UTC (rev 515)
+++ trunk/grassaddons/gui/gui_modules/toolbars.py 2007-04-16 16:40:22 UTC (rev 516)
@@ -183,7 +183,7 @@
self.mapcontent = map
self.parent = parent
- self.icons = os.path.join (icons, "v.digit")
+ self.icons = os.path.join (os.getenv("GISBASE"), "etc/v.digit")
# selected map to digitize
self.layerID = -1
Modified: trunk/grassaddons/gui/wxgrass
===================================================================
--- trunk/grassaddons/gui/wxgrass 2007-04-16 16:25:50 UTC (rev 515)
+++ trunk/grassaddons/gui/wxgrass 2007-04-16 16:40:22 UTC (rev 516)
@@ -10,7 +10,7 @@
if [ "$SYSTEM" = "Darwin" ] ; then
pythonw "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
else
- python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
+ python "$GISBASE/etc/wx/wxgui_silk.py" -name wxgui_py
fi
exit 0
From landa at grass.itc.it Mon Apr 16 18:42:07 2007
From: landa at grass.itc.it (landa@grass.itc.it)
Date: Mon Apr 16 18:42:09 2007
Subject: [grass-addons] r517 - trunk/grassaddons/gui
Message-ID: <200704161642.l3GGg710013111@grass.itc.it>
Author: landa
Date: 2007-04-16 18:42:07 +0200 (Mon, 16 Apr 2007)
New Revision: 517
Modified:
trunk/grassaddons/gui/wxgrass
Log:
revert change
Modified: trunk/grassaddons/gui/wxgrass
===================================================================
--- trunk/grassaddons/gui/wxgrass 2007-04-16 16:40:22 UTC (rev 516)
+++ trunk/grassaddons/gui/wxgrass 2007-04-16 16:42:07 UTC (rev 517)
@@ -10,7 +10,7 @@
if [ "$SYSTEM" = "Darwin" ] ; then
pythonw "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
else
- python "$GISBASE/etc/wx/wxgui_silk.py" -name wxgui_py
+ python "$GISBASE/etc/wx/wxgui.py" -name wxgui_py
fi
exit 0
From calvelo at grass.itc.it Mon Apr 16 20:12:37 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Mon Apr 16 20:12:38 2007
Subject: [grass-addons] r518 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704161812.l3GICbOK014460@grass.itc.it>
Author: calvelo
Date: 2007-04-16 20:12:28 +0200 (Mon, 16 Apr 2007)
New Revision: 518
Modified:
trunk/grassaddons/gui/gui_modules/grass-interface.dtd
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- fix for DTD
Modified: trunk/grassaddons/gui/gui_modules/grass-interface.dtd
===================================================================
--- trunk/grassaddons/gui/gui_modules/grass-interface.dtd 2007-04-16 16:42:07 UTC (rev 517)
+++ trunk/grassaddons/gui/gui_modules/grass-interface.dtd 2007-04-16 18:12:28 UTC (rev 518)
@@ -126,7 +126,7 @@
How to set up rules for that (same problem for
)?
-->
-
+
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 16:42:07 UTC (rev 517)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 18:12:28 UTC (rev 518)
@@ -31,9 +31,9 @@
#
# - verify option value types
# - add tooltips
-# - use DOM instead of SAX !!!
+# - use DOM instead of SAX
"""
-__version__ ="$Revision $"
+__version__ ="$Revision$"
import wx
import sys
@@ -779,7 +779,7 @@
self.OnUpdateValues()
def buildCmd(self, ignoreErrors = False):
- """Produce an array of command ame and arguments for feeding
+ """Produce an array of command name and arguments for feeding
into some execve-like command processor.
If ignoreErrors==True then it will return whatever has been
@@ -837,9 +837,6 @@
"""Stand-alone GRASS command GUI"""
def __init__(self, grass_task):
self.grass_task = grass_task
-#XXX from pprint import pprint
-# pprint( self.grass_task.params )
-
wx.App.__init__(self)
def OnInit(self):
From calvelo at grass.itc.it Mon Apr 16 22:38:05 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Mon Apr 16 22:38:07 2007
Subject: [grass-addons] r519 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704162038.l3GKc5GG015312@grass.itc.it>
Author: calvelo
Date: 2007-04-16 22:37:56 +0200 (Mon, 16 Apr 2007)
New Revision: 519
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
Isolated grassTask from GUI:
- need to define a nice API for it, though,
- it is currently used through get_param(), get_flag() and getCmd();
- it is initialized directly from a string containing a GRASS command, so the interface-description parser is now hidden beneath grassTask.
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 18:12:28 UTC (rev 518)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 20:37:56 UTC (rev 519)
@@ -160,17 +160,60 @@
class grassTask:
"""This class holds the structures needed for both filling by the parser and
- use by the interface constructor."""
- def __init__(self):
+ use by the interface constructor.
+
+ Use as either grassTask() for empty definition or grassTask( "grass.command" )
+ for parsed filling."""
+ def __init__(self, grassModule = None):
self.name = _('unknown')
self.params = []
self.description = ''
self.flags = []
+ if grassModule is not None:
+ xml.sax.parseString( getInterfaceDescription( grassModule ) , processTask( self ) )
- def buildCmd(self): # TODO: It should be this class' responsibility to build the command, not the gui's.
- pass
+ def get_param( self, aParam ):
+ """Find and return a param by name."""
+ for p in self.params:
+ if p['name'] == aParam:
+ return p
+ raise ValueError, "Parameter ot found"
+ def get_flag( self, aFlag ):
+ """Find and return a flag by name."""
+ for f in self.flags:
+ if f['name'] == aFlag:
+ return f
+ raise ValueError, "Falg not found"
+
+ def getCmd(self, ignoreErrors = False):
+ """Produce an array of command name and arguments for feeding
+ into some execve-like command processor.
+ If ignoreErrors==True then it will return whatever has been
+ built so far, even though it would not be a correct command
+ for GRASS."""
+ cmd = [self.name]
+ errors = 0
+ errStr = ""
+
+ for flag in self.flags:
+ if 'value' in flag and flag['value']:
+ cmd += [ '-' + flag['name'] ]
+ for p in self.params:
+ if p.get('value','') == '' and p.get('required','no') != 'no':
+ cmd += [ '%s=%s' % ( p['name'], _('') ) ]
+ errStr += _("Parameter %s (%s) is missing\n") % ( p['name'], p['description'] )
+ errors += 1
+ if p.get('value','') != '' and p['value'] != p.get('default','') :
+ cmd += [ '%s=%s' % ( p['name'], p['value'] ) ]
+ if errors and not ignoreErrors:
+ raise ValueError, errStr
+ return None
+
+ return cmd
+
+
class processTask(HandlerBase):
"""A SAX handler for the --interface-description output, as
defined in grass-interface.dtd. Extend or modify this and the
@@ -778,48 +821,23 @@
porf[ 'value' ] = me.GetValue()
self.OnUpdateValues()
- def buildCmd(self, ignoreErrors = False):
- """Produce an array of command name and arguments for feeding
- into some execve-like command processor.
- If ignoreErrors==True then it will return whatever has been
- built so far, even though it would not be a correct command
- for GRASS."""
- cmd = [self.task.name]
- errors = 0
- errStr = ""
- dcmd_params = {}
-
- for flag in self.task.flags:
- if 'value' in flag and flag['value']:
- cmd += [ '-' + flag['name'] ]
- for p in self.task.params:
- if p.get('value','') == '' and p.get('required','no') != 'no':
- cmd += [ p['name'] + '=' + _('')]
- errStr += _("Parameter %s (%s) is missing\n") % ( p['name'], p['description'] )
- errors += 1
- if p.get('value','') != '' and p['value'] != p.get('default','') :
- cmd += [ p['name'] + '=' + p['value'] ]
- if errors and not ignoreErrors:
- self.OnError(errStr)
- return None
-
- return cmd
-
def createCmd( self, ignoreErrors = False ):
"""Produce a command line string for feeding into GRASS.
If ignoreErrors==True then it will return whatever has been
built so far, even though it would not be a correct command
for GRASS."""
- return ' '.join( self.buildCmd( ignoreErrors=ignoreErrors ) )
+ try:
+ cmd = ' '.join( self.task.getCmd( ignoreErrors=ignoreErrors ) )
+ except ValueError, err:
+ dlg = wx.MessageDialog(self, str(err), _("Error"), wx.OK | wx.ICON_ERROR)
+ dlg.ShowModal()
+ dlg.Destroy()
+ cmd = ''
+ return cmd
- def OnError(self, errMsg):
- dlg = wx.MessageDialog(self, errMsg, _("Error"), wx.OK | wx.ICON_ERROR)
- dlg.ShowModal()
- dlg.Destroy()
-
def getInterfaceDescription( cmd ):
"""Returns the XML description for the GRASS cmd.
@@ -890,12 +908,17 @@
print _("usage: %s ") % sys.argv[0]
sys.exit()
if sys.argv[1] != 'test':
- grass_task = grassTask()
- handler = processTask(grass_task)
- xml.sax.parseString( getInterfaceDescription( sys.argv[1] ) , handler )
- app = GrassGUIApp( grass_task )
- app.MainLoop()
+ GrassGUIApp( grassTask( sys.argv[1] ) ).MainLoop()
else: #Test
+ # Test grassTask from within a GRASS session
+ if os.getenv("GISBASE") != '':
+ task = grassTask( "d.vect" )
+ task.get_param('map')['value'] = "map_name"
+ task.get_flag('v')['value'] = True
+ task.get_param('layer')['value'] = 12
+ task.get_param('bcolor')['value'] = "red"
+ assert ' '.join( task.getCmd() ) == "d.vect -v map=map_name layer=12 bcolor=red"
+ # Test interface building with handmade grassTask
task = grassTask()
task.name = "TestTask"
task.description = "This is a artificial grassTask() object intended for testing purposes"
From calvelo at grass.itc.it Tue Apr 17 01:57:53 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Tue Apr 17 01:57:56 2007
Subject: [grass-addons] r520 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704162357.l3GNvrCN017925@grass.itc.it>
Author: calvelo
Date: 2007-04-17 01:57:42 +0200 (Tue, 17 Apr 2007)
New Revision: 520
Added:
trunk/grassaddons/gui/gui_modules/toolbox.py
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
First shot at a simplified interface generator based on the QGIS GRASS plugin descriptions. Use with a .qgm file as argument. Lots TODO. This may have to wait for a stable qgm format in QGIS first...
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 20:37:56 UTC (rev 519)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 23:57:42 UTC (rev 520)
@@ -177,14 +177,14 @@
for p in self.params:
if p['name'] == aParam:
return p
- raise ValueError, "Parameter ot found"
+ raise ValueError, "Parameter not found : %s" % aParam
def get_flag( self, aFlag ):
"""Find and return a flag by name."""
for f in self.flags:
if f['name'] == aFlag:
return f
- raise ValueError, "Falg not found"
+ raise ValueError, "Flag not found : %s" % aFlag
def getCmd(self, ignoreErrors = False):
"""Produce an array of command name and arguments for feeding
@@ -209,7 +209,6 @@
cmd += [ '%s=%s' % ( p['name'], p['value'] ) ]
if errors and not ignoreErrors:
raise ValueError, errStr
- return None
return cmd
@@ -564,22 +563,28 @@
self.task = task
# Determine tab layout
- sections = [ _('Main') ]
+ sections = []
is_section = {}
- for task in self.task.params + self.task.flags:
- if not task.has_key('guisection') or task['guisection']=='':
- task['guisection'] = 'Options'
+ not_hidden = [ p for p in self.task.params + self.task.flags if not p.get( 'hidden','no' ) == 'yes' ]
+ for task in not_hidden:
+ if task.get( 'required','no' ) == 'yes':
+ # All required go into Main, even if they had defined another guisection
+ task['guisection'] = _( 'Main' )
+ if task.get( 'guisection','' ) == '':
+ # Undefined guisections end up into Options
+ task['guisection'] = _( 'Options' )
if not is_section.has_key(task['guisection']):
+ # We do it like this to keep the original order, except for Main which goes first
is_section[task['guisection']] = 1
- if task['guisection'] != _('Main'): # check for pre-existing parameters passed from layer tree
- sections.append( task['guisection'] )
- there_is_main = False
- for i in self.task.params+self.task.flags:
- if i.has_key('required') and i['required'] == 'yes':
- i['guisection'] = _('Main')
- there_is_main = True
- if not there_is_main:
- sections = sections[1:]
+ sections.append( task['guisection'] )
+ else:
+ is_section[ task['guisection'] ] += 1
+ # Main goes first, Options goes second
+ for (newidx,content) in [ (0,_( 'Main' )), (1,_('Options')) ]:
+ if content in sections:
+ idx = sections.index( content )
+ sections[idx:idx+1] = []
+ sections[newidx:newidx] = [content]
panelsizer = wx.BoxSizer(wx.VERTICAL)
# Build notebook
@@ -844,8 +849,9 @@
The DTD must be located in $GISBASE/etx/wx/gui_modules/grass-interface.dtd,
otherwise the parser will not succeed."""
gmpath = os.getenv("GISBASE") + "/etc/wx/gui_modules"
- cmd = cmd + r' --interface-description'
- cmdout = os.popen(cmd, "r").read()
+ cmdout = os.popen(cmd + r' --interface-description', "r").read()
+ if not len(cmdout) > 0 :
+ raise IOError, "Couldn't make command %s provide its interface description." % cmd
p = re.compile( '(grass-interface.dtd)')
p.search( cmdout )
cmdout = p.sub( gmpath+r'/grass-interface.dtd', cmdout)
Added: trunk/grassaddons/gui/gui_modules/toolbox.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/toolbox.py (rev 0)
+++ trunk/grassaddons/gui/gui_modules/toolbox.py 2007-04-16 23:57:42 UTC (rev 520)
@@ -0,0 +1,166 @@
+test_config = """
+
+
+
+
+
+
+
+
+
+
+
+
+
+"""
+test_modules = {"g.gisenv":"""
+
+
+""","r.to.vect.area":"""
+
+
+
+
+
+
+""","r.to.vect.line":"""
+
+
+
+
+
+
+"""}
+import xml.dom.minidom
+import menuform
+
+class handleQgisGrass:
+
+ def __init__(self, qgisgrass):
+ modules = qgisgrass.childNodes[0].getElementsByTagName('modules')[0]
+ for child in modules.childNodes:
+ if child.localName == 'grass':
+ self.handleGrass( child )
+ elif child.localName == 'section':
+ self.handleSection( child )
+
+ def handleSection( self,section ):
+ for child in section.getElementsByTagName('grass'):
+ self.handleGrass( child )
+
+ def handleGrass( self, grass ):
+ raise NotImplementedError
+
+class printQgisGrass( handleQgisGrass ):
+ def __init__(self, qgisgrass):
+ print "in qgisgrass"
+ handleQgisGrass.__init__( self, qgisgrass )
+
+ def handleSection( self,section ):
+ print "Section:",section.getAttribute('label')
+ handleQgisGrass.handleSection( self, section )
+
+ def handleGrass( self, grass ):
+ print "Command:",grass.getAttribute('name')
+
+
+class wxQgisGrass( handleQgisGrass ):
+ pass
+
+
+class handleQgisGrassModule:
+
+ def __init__( self, qgisgrassmodule):
+ qgisgrassm = qgisgrassmodule.getElementsByTagName( "qgisgrassmodule" )[0]
+ self.handleAttributes( qgisgrassm )
+ for inner in qgisgrassm.childNodes:
+ it = inner.localName
+ if it == 'option':
+ self.handleOption( inner )
+ elif it == 'flag':
+ self.handleFlag( inner )
+
+ def handleAttributes( self, node ):
+ for (l,a) in node.attributes.items():
+ self.handleAttribute( l, a, node )
+
+ def handleAttribute( self, label, value, parent ):
+ raise NotImplementedError
+
+ def handleOption( self, option ):
+ self.handleAttributes( option )
+
+ def handleFlag( self, flag ):
+ self.handleAttributes( flag )
+
+class printQgisGrassModule( handleQgisGrassModule ):
+
+ def __init__( self, qgisgrassmodule):
+ print "in qgisgrassmodule"
+ handleQgisGrassModule.__init__( self, qgisgrassmodule )
+
+ def handleOption( self, opt ):
+ print "Option"
+ handleQgisGrassModule.handleOption( self, opt )
+ print
+
+ def handleFlag( self, flag ):
+ print "Flag"
+ handleQgisGrassModule.handleFlag( self, flag )
+
+ def handleAttribute( self, label, value, option ):
+ print "%s:%s" % (label, value)
+
+class wxQgisGrassModule( handleQgisGrassModule ):
+ def __init__(self, qgisgrassmodule, label='' ):
+ """qgisGrassModule is a string containing the .qgm xml file"""
+ self.task = None
+ self.label = label
+ self.description = ''
+ handleQgisGrassModule.__init__( self, qgisgrassmodule )
+ self.task.description = self.description
+ menuform.GrassGUIApp( self.task ).MainLoop()
+
+ def handleOption( self, opt, getit = menuform.grassTask.get_param ):
+ a = dict(opt.attributes.items())
+ p = getit( self.task, a['key'] )
+ p['hidden'] = 'no' # unhide params
+ p['guisection'] = _( 'Main' ) # this should be the only tab present in the end
+ if a.get('hidden','no') == 'yes': p['hidden'] = 'yes' #except when explicitly hidden
+ if a.has_key( 'answer' ): p['value'] = a.get('answer')
+
+ def handleFlag( self, flag ):
+ self.handleOption( flag, getit = menuform.grassTask.get_flag )
+
+ def handleAttribute( self, label, value, option ):
+ if option.localName == 'qgisgrassmodule':
+ if label=='module':
+ self.task = menuform.grassTask( grassModule = value )
+ for pf in self.task.params + self.task.flags:
+ pf['hidden'] = 'yes'
+ if label=='label':
+ self.description = value
+
+from sys import argv
+
+if __name__ == '__main__':
+ if len( argv ) != 2:
+ print "Usage: %s " % sys.argv[0]
+ else:
+ the_module = argv[1]
+ if the_module != 'test':
+ qgm = open( the_module ).read()
+ x = wxQgisGrassModule( xml.dom.minidom.parseString( qgm ), label = the_module )
+ else:
+ # self test
+ config = xml.dom.minidom.parseString( test_config )
+ printQgisGrass( config )
+ print
+ for m in test_modules.keys():
+ print m
+ module = xml.dom.minidom.parseString( test_modules[m] )
+ printQgisGrassModule( module )
+ print "----------------"
+ m = "r.to.vect.area"
+ x = wxQgisGrassModule( xml.dom.minidom.parseString( test_modules[ m ] ), label = m )
+
From calvelo at grass.itc.it Tue Apr 17 02:10:17 2007
From: calvelo at grass.itc.it (calvelo@grass.itc.it)
Date: Tue Apr 17 02:10:18 2007
Subject: [grass-addons] r521 - trunk/grassaddons/gui/gui_modules
Message-ID: <200704170010.l3H0AHCc017969@grass.itc.it>
Author: calvelo
Date: 2007-04-17 02:10:09 +0200 (Tue, 17 Apr 2007)
New Revision: 521
Modified:
trunk/grassaddons/gui/gui_modules/menuform.py
Log:
- Properties for more useful $Revision $ thingie.
Modified: trunk/grassaddons/gui/gui_modules/menuform.py
===================================================================
--- trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-16 23:57:42 UTC (rev 520)
+++ trunk/grassaddons/gui/gui_modules/menuform.py 2007-04-17 00:10:09 UTC (rev 521)
@@ -33,7 +33,7 @@
# - add tooltips
# - use DOM instead of SAX
"""
-__version__ ="$Revision$"
+__version__ ="$Revision $"
import wx
import sys
Property changes on: trunk/grassaddons/gui/gui_modules/menuform.py
___________________________________________________________________
Name: svn:keywords
+ Date Author Revision Id
From chemin at grass.itc.it Wed Apr 18 08:55:06 2007
From: chemin at grass.itc.it (chemin@grass.itc.it)
Date: Wed Apr 18 08:55:09 2007
Subject: [grass-addons] r522 - trunk/grassaddons/gipe/r.evapo.MH
Message-ID: <200704180655.l3I6t6Pc008777@grass.itc.it>
Author: chemin
Date: 2007-04-18 08:53:58 +0200 (Wed, 18 Apr 2007)
New Revision: 522
Modified:
trunk/grassaddons/gipe/r.evapo.MH/description.html
Log:
Added reference in r.evapo.MH/description.html
Modified: trunk/grassaddons/gipe/r.evapo.MH/description.html
===================================================================
--- trunk/grassaddons/gipe/r.evapo.MH/description.html 2007-04-17 00:10:09 UTC (rev 521)
+++ trunk/grassaddons/gipe/r.evapo.MH/description.html 2007-04-18 06:53:58 UTC (rev 522)
@@ -5,8 +5,8 @@
NOTES
Hargreaves GL, Hargreaves GH, Riley JP, 1985. Agricultural benefits for Senegal River Basin. Journal of Irrigation and Drainange Engineering, ASCE, 111(2):113-124.
-Droogers P, Allen RG, 2001. Towards a simplified global reference evapotranspiration equation. Irrigation Science.
-
+Droogers P, Allen RG, 2002. Towards a simplified global reference evapotranspiration equation. Irrigation Science.
+Droogers, P., and R.G. Allen. 2002. Estimating reference evapotranspiration under inaccurate data conditions. Irrigation and Drainage Systems 16: 33-45.