g.gui.animation.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: Animation
  5. # AUTHOR(S): Anna Kratochvilova
  6. # PURPOSE: Tool for animating a series of GRASS raster maps
  7. # or a space time raster dataset
  8. # COPYRIGHT: (C) 2012 by Anna Kratochvilova, and the GRASS Development Team
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. ############################################################################
  21. #%module
  22. #% description: Tool for animating a series of GRASS raster maps or a space time raster dataset
  23. #%end
  24. #%option G_OPT_R_INPUTS
  25. #% key: rast
  26. #% description: Raster maps to animate
  27. #% required: no
  28. #% guisection: Input
  29. #%end
  30. #%option G_OPT_STRDS_INPUT
  31. #% key: strds
  32. #% description: Space time raster dataset to animate
  33. #% required: no
  34. #% guisection: Input
  35. #%end
  36. import os
  37. import sys
  38. import wx
  39. import gettext
  40. import grass.script as grass
  41. if __name__ == '__main__':
  42. sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "gui", "wxpython"))
  43. from core.settings import UserSettings
  44. from core.giface import StandaloneGrassInterface
  45. from animation.frame import AnimationFrame, MAX_COUNT
  46. def main():
  47. gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
  48. options, flags = grass.parser()
  49. rast = options['rast']
  50. strds = options['strds']
  51. if rast and strds:
  52. grass.fatal(_("Options 'rast' and 'strds' are mutually exclusive."))
  53. if rast:
  54. rast = [rast.split(',')] + [None] * (MAX_COUNT - 1)
  55. else:
  56. rast = None
  57. if strds:
  58. strds = [strds] + [None] * (MAX_COUNT - 1)
  59. else:
  60. strds = None
  61. app = wx.PySimpleApp()
  62. wx.InitAllImageHandlers()
  63. frame = AnimationFrame(parent = None)
  64. frame.CentreOnScreen()
  65. frame.Show()
  66. frame.SetAnimations(raster = rast, strds = strds)
  67. app.MainLoop()
  68. if __name__ == '__main__':
  69. main()