g.gui.animation.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 and vector 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 and vector maps or a space time raster ot vector 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_V_INPUTS
  34. #% key: vect
  35. #% label: Vector maps to animate
  36. #% required: no
  37. #% guisection: Input
  38. #%end
  39. #%option G_OPT_STRDS_INPUT
  40. #% key: strds
  41. #% description: Space time raster dataset to animate
  42. #% required: no
  43. #% guisection: Input
  44. #%end
  45. #%option G_OPT_STVDS_INPUT
  46. #% key: stvds
  47. #% description: Space time vector dataset to animate
  48. #% required: no
  49. #% guisection: Input
  50. #%end
  51. import os
  52. import sys
  53. import wx
  54. import grass.script as grass
  55. if __name__ == '__main__':
  56. sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "gui", "wxpython"))
  57. from core.settings import UserSettings
  58. from core.globalvar import CheckWxVersion
  59. from core.giface import StandaloneGrassInterface
  60. from core.utils import _
  61. from animation.frame import AnimationFrame, MAX_COUNT
  62. def main():
  63. options, flags = grass.parser()
  64. rast = options['rast']
  65. vect = options['vect']
  66. strds = options['strds']
  67. stvds = options['stvds']
  68. dataType=None
  69. inputs=None
  70. numInputs=0
  71. if rast:
  72. numInputs += 1
  73. if vect:
  74. numInputs += 1
  75. if strds:
  76. numInputs += 1
  77. if stvds:
  78. numInputs += 1
  79. if numInputs > 1:
  80. grass.fatal(_("Options 'rast', 'vect', 'strds' and 'stvds' are mutually exclusive."))
  81. if rast:
  82. inputs = [rast.split(',')] + [None] * (MAX_COUNT - 1)
  83. dataType='rast'
  84. if vect:
  85. inputs = [vect.split(',')] + [None] * (MAX_COUNT - 1)
  86. dataType='vect'
  87. if strds:
  88. inputs = [strds] + [None] * (MAX_COUNT - 1)
  89. dataType='strds'
  90. if stvds:
  91. inputs = [stvds] + [None] * (MAX_COUNT - 1)
  92. dataType='stvds'
  93. app = wx.PySimpleApp()
  94. if not CheckWxVersion([2, 9]):
  95. wx.InitAllImageHandlers()
  96. frame = AnimationFrame(parent = None)
  97. frame.CentreOnScreen()
  98. frame.Show()
  99. frame.SetAnimations(inputs = inputs, dataType = dataType)
  100. app.MainLoop()
  101. if __name__ == '__main__':
  102. main()