Ver código fonte

wxGUI/d.mon: adding only layers which are new

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54894 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 12 anos atrás
pai
commit
57927bd48f
1 arquivos alterados com 17 adições e 1 exclusões
  1. 17 1
      gui/wxpython/mapdisp/main.py

+ 17 - 1
gui/wxpython/mapdisp/main.py

@@ -32,7 +32,7 @@ import wx
 from core          import utils
 from core.giface   import StandaloneGrassInterface
 from core.gcmd     import RunCommand
-from core.render   import Map
+from core.render   import Map, MapLayer
 from mapdisp.frame import MapFrame
 from grass.script  import core as grass
 from core.debug    import Debug
@@ -87,6 +87,7 @@ class DMonMap(Map):
         nlayers = 0
         try:
             fd = open(self.cmdfile, 'r')
+            existingLayers = self.GetListOfLayers()
             for line in fd.readlines():
                 cmd = utils.split(line.strip())
                 ltype = None
@@ -100,6 +101,21 @@ class DMonMap(Map):
                 name = utils.GetLayerNameFromCmd(cmd, fullyQualified = True,
                                                  layerType = ltype)[0]
 
+                # creating temporary layer object to compare commands
+                # neccessary to get the same format
+                # supposing that there are no side effects
+                tmpMapLayer = MapLayer(ltype = ltype, name = name,
+                                       cmd = cmd, Map = None,
+                                       active = False, hidden = True,
+                                       opacity = 0)
+                exists = False
+                for layer in existingLayers:
+                    if layer.GetCmd(string=True) == tmpMapLayer.GetCmd(string=True):
+                        exists = True
+                        break
+                if exists:
+                    continue
+
                 self.AddLayer(ltype = ltype, command = cmd, active = False, name = name)
                 nlayers += 1
         except IOError, e: