Browse Source

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 years ago
parent
commit
57927bd48f
1 changed files with 17 additions and 1 deletions
  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          import utils
 from core.giface   import StandaloneGrassInterface
 from core.giface   import StandaloneGrassInterface
 from core.gcmd     import RunCommand
 from core.gcmd     import RunCommand
-from core.render   import Map
+from core.render   import Map, MapLayer
 from mapdisp.frame import MapFrame
 from mapdisp.frame import MapFrame
 from grass.script  import core as grass
 from grass.script  import core as grass
 from core.debug    import Debug
 from core.debug    import Debug
@@ -87,6 +87,7 @@ class DMonMap(Map):
         nlayers = 0
         nlayers = 0
         try:
         try:
             fd = open(self.cmdfile, 'r')
             fd = open(self.cmdfile, 'r')
+            existingLayers = self.GetListOfLayers()
             for line in fd.readlines():
             for line in fd.readlines():
                 cmd = utils.split(line.strip())
                 cmd = utils.split(line.strip())
                 ltype = None
                 ltype = None
@@ -100,6 +101,21 @@ class DMonMap(Map):
                 name = utils.GetLayerNameFromCmd(cmd, fullyQualified = True,
                 name = utils.GetLayerNameFromCmd(cmd, fullyQualified = True,
                                                  layerType = ltype)[0]
                                                  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)
                 self.AddLayer(ltype = ltype, command = cmd, active = False, name = name)
                 nlayers += 1
                 nlayers += 1
         except IOError, e:
         except IOError, e: