[GRASS-SVN] r42503 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 7 19:13:54 EDT 2010


Author: martinl
Date: 2010-06-07 19:13:54 -0400 (Mon, 07 Jun 2010)
New Revision: 42503

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
Log:
wxGUI/modeler: first steps towards variables
(merge r42501 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-06-07 23:10:53 UTC (rev 42502)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-06-07 23:13:54 UTC (rev 42503)
@@ -170,7 +170,8 @@
                     parameterized = True
                     break
             for p in task.get_options()['params']:
-                if p.get('value', '') == '' and \
+                if p.get('required', 'no') != 'no' and \
+                        p.get('value', '') == '' and \
                         p.get('default', '') == '':
                     valid = False
                 if p.get('parameterized', False):
@@ -473,6 +474,10 @@
         
         dlg.Destroy()
         
+    def OnModelVariables(self, event):
+        """!Manage (define) model variables"""
+        pass
+    
     def OnDeleteData(self, event):
         """!Delete intermediate data"""
         rast, vect, rast3d, msg = self.model.GetIntermediateData()
@@ -1087,7 +1092,8 @@
             # valid ?
             valid = True
             for p in params['params']:
-                if p.get('value', '') == '' and \
+                if p.get('required', 'no') != 'no' and \
+                        p.get('value', '') == '' and \
                         p.get('default', '') == '':
                     valid = False
                     break
@@ -1399,6 +1405,10 @@
         """!Set action parameterized"""
         self.isParameterized = isparameterized
         self._setPen()
+
+    def IsParameterized(self):
+        """!Check if action is parameterized"""
+        return self.isParameterized
     
     def AddData(self, item):
         """!Register new data item"""
@@ -1482,9 +1492,11 @@
         
     def GetLog(self, string = True):
         """!Get logging info"""
-        if self.rels['from']:
-            name = self.rels['from'].GetName()
-            return name + '=' + self.value + ' (' + self.prompt + ')'
+        name = list()
+        for rel in self.rels['from'] + self.rels['to']:
+            name.append(rel.GetName())
+        if name:
+            return '/'.join(name) + '=' + self.value + ' (' + self.prompt + ')'
         else:
             return _('unknown')
 
@@ -1569,8 +1581,25 @@
         
     def _setPen(self):
         """!Set pen"""
-        pen = wx.Pen("black")
-        pen.SetWidth(1)
+        isParameterized = False
+        for rel in self.rels['from']:
+            if rel.GetTo().IsParameterized():
+                isParameterized = True
+                break
+        if not isParameterized:
+            for rel in self.rels['to']:
+                if rel.GetFrom().IsParameterized():
+                    isParameterized = True
+                    break
+
+        if isParameterized:
+            width = int(UserSettings.Get(group='modeler', key='action',
+                                         subkey=('width', 'parameterized')))
+        else:
+            width = int(UserSettings.Get(group='modeler', key='action',
+                                         subkey=('width', 'default')))
+        pen = self.GetPen()
+        pen.SetWidth(width)
         self.SetPen(pen)
         
     def _setText(self):

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-06-07 23:10:53 UTC (rev 42502)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menuform.py	2010-06-07 23:13:54 UTC (rev 42503)
@@ -1452,6 +1452,11 @@
                     ifbb = wx.TextCtrl(parent = which_panel, id = wx.ID_ANY,
                                        style = wx.TE_MULTILINE,
                                        size = (-1, 75))
+                    if p.get('value', '') and os.path.isfile(p['value']):
+                        f = open(p['value'])
+                        ifbb.SetValue(''.join(f.readlines()))
+                        f.close()
+                    
                     ifbb.Bind(wx.EVT_TEXT, self.OnFileText)
                     which_sizer.Add(item = wx.StaticText(parent = which_panel, id = wx.ID_ANY,
                                                          label = _('or enter values interactively')),

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py	2010-06-07 23:10:53 UTC (rev 42502)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py	2010-06-07 23:13:54 UTC (rev 42503)
@@ -523,6 +523,13 @@
                     'lighting' : {
                         'color' : (255, 255, 255, 255), # white
                     },
+                'lighting' : {
+                    'pos' : {
+                        'x' : 0.68,
+                        'y' : 0.68,
+                        'z' : 0.80,
+                        },
+                    },
                 },
             'modeler' : {
                 'action' : {

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2010-06-07 23:10:53 UTC (rev 42502)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2010-06-07 23:13:54 UTC (rev 42503)
@@ -307,6 +307,7 @@
                      self.zoomout,
                      self.zoomback,
                      self.zoommenu,
+                     self.zoomextent,
                      self.analyze,
                      self.dec,
                      self.printmap):
@@ -1399,7 +1400,8 @@
         self.run = wx.NewId()
         self.validate = wx.NewId()
         self.settings = wx.NewId()
-        self.properties = wx.NewId()
+        # self.properties = wx.NewId()
+        self.variables = wx.NewId()
         self.quit = wx.NewId()
         
         # tool, label, bitmap, kind, shortHelp, longHelp, handler
@@ -1429,9 +1431,12 @@
             (self.relation, 'relation', Icons['modelRelation'].GetBitmap(),
              wx.ITEM_NORMAL, Icons['modelRelation'].GetLabel(), Icons['modelRelation'].GetDesc(),
              self.parent.OnDefineRelation),
-            (self.properties, "properties", Icons["modelProperties"].GetBitmap(),
-             wx.ITEM_NORMAL, Icons["modelProperties"].GetLabel(), Icons["modelProperties"].GetDesc(),
-             self.parent.OnModelProperties),
+            # (self.properties, "properties", Icons["modelProperties"].GetBitmap(),
+            #  wx.ITEM_NORMAL, Icons["modelProperties"].GetLabel(), Icons["modelProperties"].GetDesc(),
+            #  self.parent.OnModelProperties),
+            (self.variables, "variables", Icons["modelVariables"].GetBitmap(),
+             wx.ITEM_NORMAL, Icons["modelVariables"].GetLabel(), Icons["modelVariables"].GetDesc(),
+             self.parent.OnModelVariables),
             ('', '', '', '', '', '', ''),
             (self.run, 'run', Icons['modelRun'].GetBitmap(),
              wx.ITEM_NORMAL, Icons['modelRun'].GetLabel(), Icons['modelRun'].GetDesc(),



More information about the grass-commit mailing list