Jelajahi Sumber

wxGUI/animation: select number of processes in preferences

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65721 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 9 tahun lalu
induk
melakukan
4037133690
2 mengubah file dengan 19 tambahan dan 3 penghapusan
  1. 4 2
      gui/wxpython/animation/controller.py
  2. 15 1
      gui/wxpython/animation/dialogs.py

+ 4 - 2
gui/wxpython/animation/controller.py

@@ -371,7 +371,8 @@ class AnimationController(wx.EvtHandler):
                 self._load3DData(animData)
             self._loadLegend(animData)
         color = UserSettings.Get(group='animation', key='bgcolor', subkey='color')
-        self.bitmapProvider.Load(nprocs=getCpuCount(), bgcolor=color)
+        cpus = UserSettings.Get(group='animation', key='nprocs', subkey='value')
+        self.bitmapProvider.Load(nprocs=cpus, bgcolor=color)
         # clear pools
         self.bitmapPool.Clear()
         self.mapFilesPool.Clear()
@@ -449,7 +450,8 @@ class AnimationController(wx.EvtHandler):
         self.EndAnimation()
 
         color = UserSettings.Get(group='animation', key='bgcolor', subkey='color')
-        self.bitmapProvider.Load(nprocs=getCpuCount(), bgcolor=color, force=True)
+        cpus = UserSettings.Get(group='animation', key='nprocs', subkey='value')
+        self.bitmapProvider.Load(nprocs=cpus, bgcolor=color, force=True)
 
         self.EndAnimation()
 

+ 15 - 1
gui/wxpython/animation/dialogs.py

@@ -37,7 +37,7 @@ from core.utils import _
 from gui_core.gselect import Select
 from gui_core.widgets import FloatValidator
 
-from animation.utils import TemporalMode, getRegisteredMaps, getNameAndLayer
+from animation.utils import TemporalMode, getRegisteredMaps, getNameAndLayer, getCpuCount
 from animation.data import AnimationData, AnimLayer
 from animation.toolbars import AnimSimpleLmgrToolbar, SIMPLE_LMGR_STDS
 from gui_core.simplelmgr import SimpleLayerManager, \
@@ -1505,6 +1505,20 @@ class PreferencesDialog(PreferencesBaseDialog):
 
         gridSizer.Add(item=color, pos=(row, 1), flag=wx.ALIGN_RIGHT)
 
+        row += 1
+        gridSizer.Add(item=wx.StaticText(parent=panel,
+                                         label=_("Number of parallel processes:")),
+                      flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
+        # when running for the first time, set nprocs based on the number of processes
+        if UserSettings.Get(group='animation', key='nprocs', subkey='value') == -1:
+            UserSettings.Set(group='animation', key='nprocs', subkey='value', value=getCpuCount())
+        nprocs = wx.SpinCtrl(parent=panel,
+                             initial=UserSettings.Get(group='animation', key='nprocs', subkey='value'))
+        nprocs.SetName('GetValue')
+        self.winId['animation:nprocs:value'] = nprocs.GetId()
+
+        gridSizer.Add(item=nprocs, pos=(row, 1), flag=wx.ALIGN_RIGHT)
+
         gridSizer.AddGrowableCol(1)
         sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=3)
         border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)