giface.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. """!
  2. @package lmgr.giface
  3. @brief Layer Manager GRASS interface
  4. Classes:
  5. - giface::LayerManagerGrassInterface
  6. (C) 2012 by the GRASS Development Team
  7. This program is free software under the GNU General Public License
  8. (>=v2). Read the file COPYING that comes with GRASS for details.
  9. @author Anna Kratochvilova <kratochanna gmail.com>
  10. @author Vaclav Petras <wenzeslaus gmail.com>
  11. """
  12. class LayerManagerGrassInterface:
  13. def __init__(self, lmgr):
  14. self.lmgr = lmgr
  15. def RunCmd(self, *args, **kwargs):
  16. self.lmgr._gconsole.RunCmd(*args, **kwargs)
  17. def Help(self, entry):
  18. cmdlist = ['g.manual', 'entry=%s' % entry]
  19. self.RunCmd(cmdlist, compReg = False, switchPage = False)
  20. def WriteLog(self, text, wrap = None,
  21. switchPage = False, priority = 1):
  22. self.lmgr._gconsole.WriteLog(text = text, wrap = wrap, switchPage = switchPage,
  23. priority = priority)
  24. def WriteCmdLog(self, line, pid = None, switchPage = True):
  25. self.lmgr._gconsole.WriteCmdLog(line = line, pid = pid, switchPage = switchPage)
  26. def WriteWarning(self, line):
  27. self.lmgr._gconsole.WriteWarning(line = line)
  28. def WriteError(self, line):
  29. self.lmgr._gconsole.WriteError(line = line)
  30. def GetLayerTree(self):
  31. return self.lmgr.GetLayerTree()
  32. def GetMapDisplay(self):
  33. """!Get current map display.
  34. @return MapFrame instance
  35. @return None no mapdisplay open
  36. """
  37. return self.lmgr.GetMapDisplay(onlyCurrent=True)
  38. def GetAllMapDisplays(self):
  39. """!Get list of all map displays.
  40. @return list of MapFrame instances
  41. """
  42. return self.lmgr.GetMapDisplay(onlyCurrent=False)
  43. def GetMapWindow(self):
  44. if self.lmgr.GetMapDisplay(onlyCurrent=True):
  45. return self.lmgr.GetMapDisplay(onlyCurrent=True).GetMapWindow()
  46. else:
  47. return None
  48. def GetProgress(self):
  49. return self.lmgr.goutput.GetProgressBar()