~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to gui/wxpython/animation/g.gui.animation.py

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
22
#%module
 
23
#% description: Tool for animating a series of raster and vector maps or a space time raster or vector dataset.
 
24
#% keyword: general
 
25
#% keyword: GUI
 
26
#% keyword: display
 
27
#% keyword: animation
 
28
#%end
 
29
#%option G_OPT_R_INPUTS
 
30
#% key: raster
 
31
#% description: Raster maps to animate
 
32
#% required: no
 
33
#% guisection: Input
 
34
#%end
 
35
#%option G_OPT_V_INPUTS
 
36
#% key: vector
 
37
#% label: Vector maps to animate
 
38
#% required: no
 
39
#% guisection: Input
 
40
#%end
 
41
#%option G_OPT_STRDS_INPUT
 
42
#% key: strds
 
43
#% description: Space time raster dataset to animate
 
44
#% required: no
 
45
#% guisection: Input
 
46
#%end
 
47
#%option G_OPT_STVDS_INPUT
 
48
#% key: stvds
 
49
#% description: Space time vector dataset to animate
 
50
#% required: no
 
51
#% guisection: Input
 
52
#%end
 
53
 
 
54
import os
 
55
 
 
56
import wx
 
57
 
 
58
import grass.script as grass
 
59
import grass.temporal as tgis
 
60
 
 
61
from core.globalvar import CheckWxVersion
 
62
from core.utils import _, GuiModuleMain
 
63
from core.giface import StandaloneGrassInterface
 
64
from core.layerlist import LayerList
 
65
from animation.frame import AnimationFrame, MAX_COUNT
 
66
from animation.data import AnimLayer
 
67
 
 
68
 
 
69
def main():
 
70
    rast = options['raster']
 
71
    vect = options['vector']
 
72
    strds = options['strds']
 
73
    stvds = options['stvds']
 
74
 
 
75
    numInputs = 0
 
76
 
 
77
    if rast:
 
78
        numInputs += 1
 
79
    if vect:
 
80
        numInputs += 1
 
81
    if strds:
 
82
        numInputs += 1
 
83
    if stvds:
 
84
        numInputs += 1
 
85
        
 
86
 
 
87
    if numInputs > 1:
 
88
        grass.fatal(_("%s=, %s=, %s= and %s= are mutually exclusive.") %
 
89
                ("raster", "vector", "strds", "stvds"))
 
90
        
 
91
    if numInputs > 0:
 
92
        # We need to initialize the temporal framework in case
 
93
        # a space time dataset was set on the command line so that
 
94
        # the AnimLayer() class works correctly
 
95
        tgis.init()
 
96
 
 
97
    layerList = LayerList()
 
98
    if rast:
 
99
        layer = AnimLayer()
 
100
        layer.mapType = 'raster'
 
101
        layer.name = rast
 
102
        layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])]
 
103
        layerList.AddLayer(layer)
 
104
    if vect:
 
105
        layer = AnimLayer()
 
106
        layer.mapType = 'vector'
 
107
        layer.name = vect
 
108
        layer.cmd = ['d.vect', 'map={name=}'.format(name=vect.split(',')[0])]
 
109
        layerList.AddLayer(layer)
 
110
    if strds:
 
111
        layer = AnimLayer()
 
112
        layer.mapType = 'strds'
 
113
        layer.name = strds
 
114
        layer.cmd = ['d.rast', 'map=']
 
115
        layerList.AddLayer(layer)
 
116
    if stvds:
 
117
        layer = AnimLayer()
 
118
        layer.mapType = 'stvds'
 
119
        layer.name = stvds
 
120
        layer.cmd = ['d.vect', 'map=']
 
121
        layerList.AddLayer(layer)
 
122
 
 
123
    app = wx.App()
 
124
    if not CheckWxVersion([2, 9]):
 
125
        wx.InitAllImageHandlers()
 
126
 
 
127
    frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
 
128
    frame.CentreOnScreen()
 
129
    frame.Show()
 
130
    if len(layerList) >= 1:
 
131
        # CallAfter added since it was crashing with wxPython 3 gtk
 
132
        wx.CallAfter(frame.SetAnimations, [layerList] + [None] * (MAX_COUNT - 1))
 
133
    app.MainLoop()
 
134
 
 
135
if __name__ == '__main__':
 
136
    options, flags = grass.parser()
 
137
 
 
138
    GuiModuleMain(main)