g.gui.animation.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 raster maps or a space time raster dataset.
  23. #% keywords: general
  24. #% keywords: gui
  25. #% keywords: display
  26. #%end
  27. #%option G_OPT_R_INPUTS
  28. #% key: rast
  29. #% description: Raster maps to animate
  30. #% required: no
  31. #% guisection: Input
  32. #%end
  33. #%option G_OPT_STRDS_INPUT
  34. #% key: strds
  35. #% description: Space time raster dataset to animate
  36. #% required: no
  37. #% guisection: Input
  38. #%end
  39. import os
  40. import sys
  41. import wx
  42. import gettext
  43. import grass.script as grass
  44. if __name__ == '__main__':
  45. sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "gui", "wxpython"))
  46. from core.settings import UserSettings
  47. from core.giface import StandaloneGrassInterface
  48. from animation.frame import AnimationFrame, MAX_COUNT
  49. def main():
  50. gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
  51. options, flags = grass.parser()
  52. rast = options['rast']
  53. strds = options['strds']
  54. if rast and strds:
  55. grass.fatal(_("Options 'rast' and 'strds' are mutually exclusive."))
  56. if rast:
  57. rast = [rast.split(',')] + [None] * (MAX_COUNT - 1)
  58. else:
  59. rast = None
  60. if strds:
  61. strds = [strds] + [None] * (MAX_COUNT - 1)
  62. else:
  63. strds = None
  64. app = wx.PySimpleApp()
  65. wx.InitAllImageHandlers()
  66. frame = AnimationFrame(parent = None)
  67. frame.CentreOnScreen()
  68. frame.Show()
  69. frame.SetAnimations(raster = rast, strds = strds)
  70. app.MainLoop()
  71. if __name__ == '__main__':
  72. main()