浏览代码

wxGUI/3D view: set point size relatively to region

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69732 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 8 年之前
父节点
当前提交
06a869bff2
共有 4 个文件被更改,包括 29 次插入16 次删除
  1. 1 0
      gui/wxpython/core/settings.py
  2. 3 7
      gui/wxpython/nviz/mapwindow.py
  3. 14 4
      gui/wxpython/nviz/preferences.py
  4. 11 5
      gui/wxpython/nviz/workspace.py

+ 1 - 0
gui/wxpython/core/settings.py

@@ -672,6 +672,7 @@ class Settings:
                     'points': {
                         'show': False,
                         'size': 100,
+                        'autosize': True,
                         'width': 2,
                         'marker': 2,
                         'color': (0, 0, 0, 255),

+ 3 - 7
gui/wxpython/nviz/mapwindow.py

@@ -1452,7 +1452,7 @@ class GLWindow(MapWindowBase, glcanvas.GLCanvas):
 
             elif mapType == 'vector':
                 # reset to default properties (lines/points)
-                data['vector'] = self.nvizDefault.SetVectorDefaultProp()
+                data['vector'] = self.nvizDefault.SetVectorDefaultProp(longDim=self._display.GetLongDim())
                 self.SetVectorFromCmd(item, data['vector'])
                 self.SetVectorSurface(data['vector']['points'])
                 self.SetVectorSurface(data['vector']['lines'])
@@ -1477,9 +1477,7 @@ class GLWindow(MapWindowBase, glcanvas.GLCanvas):
                         ['lines'])
                 if not data['vector']['points']:
                     self.nvizDefault.SetVectorPointsDefaultProp(
-                        data
-                        ['vector']
-                        ['points'])
+                        data['vector']['points'], self._display.GetLongDim())
             # set updates
             for sec in data.keys():
                 for sec1 in data[sec].keys():
@@ -2310,9 +2308,7 @@ class GLWindow(MapWindowBase, glcanvas.GLCanvas):
                 vInfo = grass.vector_info_topo(layer.GetName())
                 if (vInfo['points'] + vInfo['centroids']) > 0:
                     self.nvizDefault.SetVectorPointsDefaultProp(
-                        data
-                        ['vector']
-                        ['points'])
+                        data['vector']['points'], self._display.GetLongDim())
                 if (vInfo['lines'] + vInfo['boundaries']) > 0:
                     self.nvizDefault.SetVectorLinesDefaultProp(
                         data

+ 14 - 4
gui/wxpython/nviz/preferences.py

@@ -594,6 +594,14 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
 
         row = 0
         # icon size
+        autosize = wx.CheckBox(parent=panel, label=_("Automatic size"))
+        autosize.SetToolTipString(_("Icon size is set automatically based on landscape dimensions."))
+        gridSizer.Add(autosize, pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
+        self.winId['nviz:vector:points:autosize'] = autosize.GetId()
+        autosize.SetValue(UserSettings.Get(group='nviz', key='vector',
+                                           subkey=['points', 'autosize']))
+
+        row += 1
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Size:")),
                       pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
@@ -609,9 +617,10 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
         # icon symbol
+        row += 1
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Marker:")),
-                      pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL)
+                      pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
         isym = wx.Choice(
             parent=panel, id=wx.ID_ANY, size=(100, -1),
             choices=UserSettings.Get(
@@ -622,12 +631,13 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
         isym.SetSelection(UserSettings.Get(group='nviz', key='vector',
                                            subkey=['points', 'marker']))
         gridSizer.Add(item=isym, flag=wx.ALIGN_CENTER_VERTICAL,
-                      pos=(row, 3))
+                      pos=(row, 1))
 
         # icon color
+        row += 1
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Color:")),
-                      pos=(row, 4), flag=wx.ALIGN_CENTER_VERTICAL)
+                      pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
         icolor = csel.ColourSelect(panel, id=wx.ID_ANY,
                                    size=globalvar.DIALOG_COLOR_SIZE)
         icolor.SetName('GetColour')
@@ -635,7 +645,7 @@ class NvizPreferencesDialog(PreferencesBaseDialog):
         icolor.SetColour(UserSettings.Get(group='nviz', key='vector',
                                           subkey=['points', 'color']))
         gridSizer.Add(item=icolor, flag=wx.ALIGN_CENTER_VERTICAL,
-                      pos=(row, 5))
+                      pos=(row, 1))
 
         boxSizer.Add(item=gridSizer, proportion=1,
                      flag=wx.ALL | wx.EXPAND, border=5)

+ 11 - 5
gui/wxpython/nviz/workspace.py

@@ -194,7 +194,7 @@ class NvizSettings(object):
                 subkey='transp'))
         return data
 
-    def SetVectorDefaultProp(self, data=None):
+    def SetVectorDefaultProp(self, longDim, data=None):
         """Set default vector data properties"""
         if not data:
             data = dict()
@@ -202,7 +202,7 @@ class NvizSettings(object):
             data[sec] = {}
 
         self.SetVectorLinesDefaultProp(data['lines'])
-        self.SetVectorPointsDefaultProp(data['points'])
+        self.SetVectorPointsDefaultProp(data['points'], longDim)
 
         return data
 
@@ -250,11 +250,17 @@ class NvizSettings(object):
             for attrb in ('color', 'width', 'mode', 'height', 'thematic'):
                 data[attrb]['update'] = None
 
-    def SetVectorPointsDefaultProp(self, data):
+    def SetVectorPointsDefaultProp(self, data, longDim):
         """Set default vector properties -- points"""
+        size_fraction = 0.005
         # size
-        data['size'] = {'value': UserSettings.Get(group='nviz', key='vector',
-                                                  subkey=['points', 'size'])}
+        autosize = UserSettings.Get(group='nviz', key='vector',
+                                    subkey=['points', 'autosize'])
+        if autosize:
+            data['size'] = {'value': longDim * size_fraction}
+        else:
+            data['size'] = {'value': UserSettings.Get(group='nviz', key='vector',
+                                                      subkey=['points', 'size'])}
 
         # width
         data['width'] = {'value': UserSettings.Get(group='nviz', key='vector',