[GRASS-SVN] r41869 - in grass/trunk/gui/wxpython: gui_modules xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Apr 14 18:45:06 EDT 2010
Author: martinl
Date: 2010-04-14 18:45:05 -0400 (Wed, 14 Apr 2010)
New Revision: 41869
Modified:
grass/trunk/gui/wxpython/gui_modules/gmodeler.py
grass/trunk/gui/wxpython/xml/grass-gxm.dtd
Log:
wxGUI/modeler: delete intermediate data
Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-04-14 21:44:35 UTC (rev 41868)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-04-14 22:45:05 UTC (rev 41869)
@@ -167,7 +167,60 @@
def OnDeleteData(self, event):
"""!Delete intermediate data"""
+ rast = list()
+ rast3d = list()
+ vect = list()
+ for data in self.data:
+ if not data.IsIntermediate():
+ continue
+ name = data.GetValue()
+ prompt = data.GetPrompt()
+ if prompt == 'raster':
+ rast.append(name)
+ elif prompt == 'vector':
+ vect.append(name)
+ elif prompt == 'rast3d':
+ rast3d.append(name)
+
+ if not rast and not vect and not rast3d:
+ GMessage(parent = self,
+ message = _('Nothing to delete.'),
+ msgType = 'info')
+ return
+
+ msg = ''
+ if rast:
+ msg += '\n\n%s: ' % _('Raster maps')
+ msg += ', '.join(rast)
+ if rast3d:
+ msg += '\n\n%s: ' % _('3D raster maps')
+ msg += ', '.join(rast3d)
+ if vect:
+ msg += '\n\n%s: ' % _('Vector maps')
+ msg += ', '.join(vect)
+ dlg = wx.MessageDialog(parent = self,
+ message= _("Do you want to permanently delete data?%s" % msg),
+ caption=_("Delete intermediate data?"),
+ style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
+
+ ret = dlg.ShowModal()
+ if ret == wx.ID_YES:
+ dlg.Destroy()
+
+ if rast:
+ self.goutput.RunCmd(['g.remove', 'rast=%s' %','.join(rast)])
+ if rast3d:
+ self.goutput.RunCmd(['g.remove', 'rast3d=%s' %','.join(rast3d)])
+ if vect:
+ self.goutput.RunCmd(['g.remove', 'vect=%s' %','.join(vect)])
+
+ self.SetStatusText(_("%d maps deleted from current mapset") % \
+ int(len(rast) + len(rast3d) + len(vect)))
+ return
+
+ dlg.Destroy()
+
def OnModelNew(self, event):
"""!Create new model"""
Debug.msg(4, "ModelFrame.OnModelNew():")
@@ -784,6 +837,8 @@
name = data['name'],
prompt = data['prompt'],
value = data['value'])
+ dataShape.SetIntermediate(data['intermediate'])
+
self.canvas.diagram.AddShape(dataShape)
dataShape.Show(True)
@@ -951,6 +1006,7 @@
self.name = name
self.value = value
self.prompt = prompt
+ self.intermediate = False
self.propWin = None
self.actions = { 'from' : list(), 'to' : list() }
@@ -979,6 +1035,24 @@
else:
self.AddText('\n')
+ def IsIntermediate(self):
+ """!Checks if data item is intermediate"""
+ return self.intermediate
+
+ def SetIntermediate(self, im):
+ """!Set intermediate flag"""
+ self.intermediate = im
+
+ def OnDraw(self, dc):
+ pen = self.GetPen()
+ if self.intermediate:
+ pen.SetStyle(wx.SHORT_DASH)
+ else:
+ pen.SetStyle(wx.SOLID)
+ self.SetPen(pen)
+
+ ogl.EllipseShape.OnDraw(self, dc)
+
def GetLog(self, string = True):
"""!Get logging info"""
if self.name:
@@ -1151,13 +1225,25 @@
if not hasattr (self, "popupID1"):
self.popupID1 = wx.NewId()
self.popupID2 = wx.NewId()
-
+ self.popupID3 = wx.NewId()
+
popupMenu = wx.Menu()
popupMenu.Append(self.popupID1, text=_('Remove'))
self.frame.Bind(wx.EVT_MENU, self.OnRemove, id = self.popupID1)
popupMenu.AppendSeparator()
+
+ shape = self.GetShape()
+ if isinstance(shape, ModelData) and '@' not in shape.GetValue():
+ popupMenu.Append(self.popupID3, text=_('Intermediate'),
+ kind = wx.ITEM_CHECK)
+ if self.GetShape().IsIntermediate():
+ popupMenu.Check(self.popupID3, True)
+
+ self.frame.Bind(wx.EVT_MENU, self.OnIntermediate, id = self.popupID3)
+
+ popupMenu.AppendSeparator()
popupMenu.Append(self.popupID2, text=_('Properties'))
self.frame.Bind(wx.EVT_MENU, self.OnProperties, id = self.popupID2)
@@ -1165,8 +1251,16 @@
self.frame.PopupMenu(popupMenu)
popupMenu.Destroy()
+ def OnIntermediate(self, event):
+ """!Mark data as intermediate"""
+ self.frame.ModelChanged()
+ shape = self.GetShape()
+ shape.SetIntermediate(event.IsChecked())
+ self.frame.canvas.Refresh()
+
def OnRemove(self, event):
"""!Remove shape"""
+ self.frame.ModelChanged()
shape = self.GetShape()
self.frame.canvas.GetDiagram().RemoveShape(shape)
self.frame.canvas.Refresh()
@@ -1420,7 +1514,12 @@
name = param.get('name', None)
prompt = param.get('prompt', None)
value = self._filterValue(self._getNodeText(param, 'value'))
-
+
+ if data.find('intermediate') is None:
+ intermediate = False
+ else:
+ intermediate = True
+
aId = list()
fromDir = list()
for action in data.findall('data-action'):
@@ -1435,6 +1534,7 @@
'name' : name,
'prompt' : prompt,
'value' : value,
+ 'intermediate' : intermediate,
'id' : aId,
'from' : fromDir })
@@ -1544,6 +1644,10 @@
(' ' * self.indent, self._filterValue(data.GetValue())))
self.indent -= 4
self.fd.write('%s</data-parameter>\n' % (' ' * self.indent))
+
+ if data.IsIntermediate():
+ self.fd.write('%s<intermediate />\n' % (' ' * self.indent))
+
for action in data.GetActions('from'):
id = action.GetId()
self.fd.write('%s<data-action id="%d" dir="from" />\n' % \
Modified: grass/trunk/gui/wxpython/xml/grass-gxm.dtd
===================================================================
--- grass/trunk/gui/wxpython/xml/grass-gxm.dtd 2010-04-14 21:44:35 UTC (rev 41868)
+++ grass/trunk/gui/wxpython/xml/grass-gxm.dtd 2010-04-14 22:45:05 UTC (rev 41869)
@@ -46,7 +46,7 @@
<!-- a data defines data properties (usually data layers)
-->
-<!ELEMENT data (data-parameter, data-action*)>
+<!ELEMENT data (data-parameter, intermediate?, data-action*)>
<!ATTLIST data pos CDATA #REQUIRED>
<!ATTLIST data size CDATA #REQUIRED>
@@ -56,6 +56,10 @@
<!ATTLIST data-parameter name CDATA #REQUIRED>
<!ATTLIST data-parameter prompt CDATA #REQUIRED>
+<!-- a data intermediate?
+-->
+<!ELEMENT intermediate EMPTY>
+
<!-- a data-action defines relation between data and actions
-->
<!ELEMENT data-action EMPTY>
More information about the grass-commit
mailing list