g.gui.animation.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.globalvar import CheckWxVersion
  48. from core.giface import StandaloneGrassInterface
  49. from animation.frame import AnimationFrame, MAX_COUNT
  50. def main():
  51. gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
  52. options, flags = grass.parser()
  53. rast = options['rast']
  54. strds = options['strds']
  55. if rast and strds:
  56. grass.fatal(_("Options 'rast' and 'strds' are mutually exclusive."))
  57. if rast:
  58. rast = [rast.split(',')] + [None] * (MAX_COUNT - 1)
  59. else:
  60. rast = None
  61. if strds:
  62. strds = [strds] + [None] * (MAX_COUNT - 1)
  63. else:
  64. strds = None
  65. app = wx.PySimpleApp()
  66. if not CheckWxVersion([2, 9]):
  67. wx.InitAllImageHandlers()
  68. frame = AnimationFrame(parent = None)
  69. frame.CentreOnScreen()
  70. frame.Show()
  71. frame.SetAnimations(raster = rast, strds = strds)
  72. app.MainLoop()
  73. if __name__ == '__main__':
  74. main()