Пример #1
0
def main():
    """Sets the GRASS display driver

    .. todo::
        use command line options as an alternative to wizard
    """
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.globalvar import CheckWxVersion
    from core.giface import StandaloneGrassInterface
    from gcp.manager import GCPWizard

    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())

    app.MainLoop()
Пример #2
0
 def __init__(self, *args, **kwargs):
     Button.__init__(self, *args, **kwargs)
     self.SetId(wx.ID_CANCEL)
     if sys.platform == "darwin" and not CheckWxVersion([4, 1, 0]):
         self.SetLabel(_("Close"))
     else:
         self.SetLabel(_("&Close"))
Пример #3
0
def main():
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    first = options['first']
    second = options['second']
    mode = options['mode']

    for mapName in [first, second]:
        if mapName:
            gfile = grass.find_file(name=mapName)
            if not gfile['name']:
                grass.fatal(_("Raster map <%s> not found") % mapName)

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    frame = SwipeMapFrame(parent=None, giface=StandaloneGrassInterface())

    if first:
        frame.SetFirstRaster(first)
    if second:
        frame.SetSecondRaster(second)
    if first or second:
        frame.SetRasterNames()

    frame.SetViewMode(mode)
    frame.Show()

    app.MainLoop()
Пример #4
0
def main():
    options, flags = gcore.parser()
    if options['input']:
        map_name = gcore.find_file(name=options['input'], element='cell')['fullname']
        if not map_name:
            gcore.fatal(_("Raster map <{raster}> not found").format(raster=options['input']))

    # define display driver (avoid 'no graphics device selected' error at start up)
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    # launch application
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    # show main frame
    giface = StandaloneGrassInterface()
    frame = ExampleMapFrame(parent=None, giface=giface)
    if options['input']:
        giface.WriteLog(_("Loading raster map <{raster}>...").format(raster=map_name))
        frame.SetLayer(map_name)

    frame.Show()
    app.MainLoop()
Пример #5
0
def main():
    group_name = subgroup_name = map_name = trainingmap_name = None

    if options['group']:
        if not options['subgroup']:
            grass.fatal(_("Name of subgroup required"))
        group_name = grass.find_file(name=options['group'],
                                     element='group')['name']
        if not group_name:
            grass.fatal(_("Group <%s> not found") % options['group'])
        if options['subgroup'] not in grass.read_command(
                'i.group', group=group_name, flags='sg').splitlines():
            grass.fatal(_("Subgroup <%s> not found") % options['subgroup'])
        subgroup_name = options['subgroup']

    if options['map']:
        map_name = grass.find_file(name=options['map'],
                                   element='cell')['fullname']
        if not map_name:
            grass.fatal(_("Raster map <%s> not found") % options['map'])

    if options['trainingmap']:
        trainingmap_name = grass.find_file(name=options['trainingmap'],
                                           element='vector')['fullname']
        if not trainingmap_name:
            grass.fatal(
                _("Vector map <%s> not found") % options['trainingmap'])

    # define display driver
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    # launch application
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    # show main frame
    giface = StandaloneGrassInterface()
    frame = IClassMapFrame(parent=None, giface=giface)
    if not flags['m']:
        frame.CenterOnScreen()
    if group_name:
        frame.SetGroup(group_name, subgroup_name)
    if map_name:
        giface.WriteLog(_("Loading raster map <%s>...") % map_name)
        frame.trainingMapManager.AddLayer(map_name)
    if trainingmap_name:
        giface.WriteLog(_("Loading training map <%s>...") % trainingmap_name)
        frame.ImportAreas(trainingmap_name)

    frame.Show()
    if flags['m']:
        frame.Maximize()

    app.MainLoop()
Пример #6
0
def main():
    """Sets the GRASS display driver
    """
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    # TODO: message format should not be GUI
    # TODO: should messages here be translatable?
    # (for test its great, for translator not)

    options, flags = grass.parser()
    test = options['test']

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    map_ = Map()

    if options['raster']:
        names = options['raster']
        for name in names.split(','):
            cmdlist = ['d.rast', 'map=%s' % name]
            map_.AddLayer(ltype='raster', command=cmdlist, active=True,
                          name=name, hidden=False, opacity=1.0,
                          render=True)
    if options['vector']:
        names = options['vector']
        for name in names.split(','):
            cmdlist = ['d.vect', 'map=%s' % name]
            map_.AddLayer(ltype='vector', command=cmdlist, active=True,
                          name=name, hidden=False, opacity=1.0,
                          render=True)

    giface = MapdispGrassInterface(map_=map_)
    tester = Tester()

    if test == 'mapwindow':
        tester.testMapWindow(giface, map_)
    elif test == 'mapdisplay':
        tester.testMapDisplay(giface, map_)
    elif test == 'apitest':
        tester.testMapWindowApi(giface, map_)
    elif test == 'distance':
        tester.testMapWindowDistance(giface, map_)
    elif test == 'profile':
        tester.testMapWindowProfile(giface, map_)
    elif test == 'rlisetup':
        tester.testMapWindowRlisetup(map_)
    else:
        # TODO: this should not happen but happens
        import grass.script as sgrass
        sgrass.fatal(_("Unknown value %s of test parameter." % test))

    app.MainLoop()
Пример #7
0
def main():
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = RLiSetupFrame(parent=None, giface=StandaloneGrassInterface())
    frame.Show()
    frame.CenterOnScreen()

    app.MainLoop()
Пример #8
0
def main():
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = ModelFrame(parent=None, giface=StandaloneGrassInterface())
    if options['file']:
        frame.LoadModelFile(options['file'])
    frame.Show()

    app.MainLoop()
Пример #9
0
def main():
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = PsMapFrame(parent=None)
    frame.Show()

    if options['file']:
        frame.LoadFile(options['file'])

    app.MainLoop()
Пример #10
0
def main():
    """Sets the GRASS display driver
    """
    options, flags = gscript.parser()

    import wx
    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.globalvar import CheckWxVersion
    from core.giface import StandaloneGrassInterface
    from photo2image.ip2i_manager import GCPWizard

    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    if options['group']:
        group = options['group']
    else:
        gscript.fatal(_("Please provide a group name to process"))
    
    if options['raster']:
        raster = options['raster']
    else:
        gscript.fatal(_("Please provide a raster map name to process"))

    if options['camera']:
        camera = options['camera']
    else:
        gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)"))

    if options['order']:
        order = options['order']
    else:
        gscript.fatal(_("Please provive an order value (1 if 4 Fiducials, 2 if 8 Fiducials)"))

    if options['extension']:
        extension = options['extension']
    else:
        gscript.fatal(_("Please provive an output files extension (used by i.rectify)"))

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(), group=group, 
            raster=raster, raster1=raster, camera=camera, order=order, extension=extension)
    app.MainLoop()
Пример #11
0
    def __init__(self,
                 parent,
                 giface,
                 id=wx.ID_ANY,
                 simpleEditorHandler=None,
                 **kwargs):
        self.parent = parent
        self.giface = giface

        wx.Panel.__init__(self, parent=parent, id=id, **kwargs)

        self.intro = (
            _("Welcome to wxGUI Interactive Python Shell %s") % VERSION +
            "\n\n" +
            _("Type %s for more GRASS scripting related information.") %
            '"help(gs)"' + "\n" +
            _("Type %s to add raster or vector to the layer tree.") %
            "\"AddLayer('map_name')\"" + "\n\n")

        shellargs = dict(
            parent=self,
            id=wx.ID_ANY,
            introText=self.intro,
            locals={
                "gs": grass,
                "AddLayer": self.AddLayer,
                "help": self.Help
            },
        )
        # useStockId (available since wxPython 4.0.2) should be False on macOS
        if sys.platform == "darwin" and CheckWxVersion([4, 0, 2]):
            shellargs["useStockId"] = False
        self.shell = PyShell(**shellargs)
        if IsDark():
            SetDarkMode(self.shell)

        sys.displayhook = self._displayhook

        self.btnClear = ClearButton(self)
        self.btnClear.Bind(wx.EVT_BUTTON, self.OnClear)
        self.btnClear.SetToolTip(_("Delete all text from the shell"))

        self.simpleEditorHandler = simpleEditorHandler
        if simpleEditorHandler:
            self.btnSimpleEditor = Button(self,
                                          id=wx.ID_ANY,
                                          label=_("Simple &editor"))
            self.btnSimpleEditor.Bind(wx.EVT_BUTTON, simpleEditorHandler)
            self.btnSimpleEditor.SetToolTip(
                _("Open a simple Python code editor"))

        self._layout()
Пример #12
0
def main():
    options, flags = gcore.parser()

    import wx

    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.globalvar import CheckWxVersion, MAP_WINDOW_SIZE
    from core.giface import StandaloneGrassInterface
    from core.settings import UserSettings
    from example.frame import ExampleMapDisplay

    if options["input"]:
        map_name = gcore.find_file(name=options["input"],
                                   element="cell")["fullname"]
        if not map_name:
            gcore.fatal(
                _("Raster map <{raster}> not found").format(
                    raster=options["input"]))

    # define display driver (avoid 'no graphics device selected' error at start up)
    driver = UserSettings.Get(group="display", key="driver", subkey="type")
    if driver == "png":
        os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
    else:
        os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"

    # launch application
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    # show main frame
    frame = wx.Frame(parent=None,
                     size=MAP_WINDOW_SIZE,
                     title=_("Example Tool - GRASSGIS"))
    frame = ExampleMapDisplay(
        parent=frame,
        giface=StandaloneGrassInterface(),
    )
    if options["input"]:
        frame.giface.WriteLog(
            _("Loading raster map <{raster}>...").format(raster=map_name))
        frame.SetLayer(map_name)

    frame.Show()
    app.MainLoop()
Пример #13
0
def main():
    # allow immediate rendering
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = VDigitMapFrame(options['map'])
    frame.Show()

    app.MainLoop()
Пример #14
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.globalvar import CheckWxVersion
    from core.giface import StandaloneGrassInterface
    from core.utils import _
    from mapswipe.frame import SwipeMapFrame

    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    first = options['first']
    second = options['second']
    mode = options['mode']

    for mapName in [first, second]:
        if mapName:
            gfile = gscript.find_file(name=mapName)
            if not gfile['name']:
                gscript.fatal(_("Raster map <%s> not found") % mapName)

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    frame = SwipeMapFrame(parent=None, giface=StandaloneGrassInterface())

    if first:
        frame.SetFirstRaster(first)
    if second:
        frame.SetSecondRaster(second)
    if first or second:
        frame.SetRasterNames()

    frame.SetViewMode(mode)
    frame.Show()

    app.MainLoop()
Пример #15
0
def main():
    gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    from core.globalvar import CheckWxVersion
    from rlisetup.frame import RLiSetupFrame

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = RLiSetupFrame(parent=None, giface=StandaloneGrassInterface())
    frame.Show()
    frame.CenterOnScreen()

    app.MainLoop()
Пример #16
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    from core.globalvar import CheckWxVersion
    from gmodeler.frame import ModelFrame

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = ModelFrame(parent=None, giface=StandaloneGrassInterface())
    if options['file']:
        frame.LoadModelFile(options['file'])
    frame.Show()

    app.MainLoop()
Пример #17
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.globalvar import CheckWxVersion
    from psmap.frame import PsMapFrame

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = PsMapFrame(parent=None)
    frame.Show()

    if options['file']:
        frame.LoadFile(options['file'])

    app.MainLoop()
Пример #18
0
    def SetStyle(self):
        """Set styles for styled text output windows with type face
        and point size selected by user (Courier New 10 is default)"""

        typeface = UserSettings.Get(group="appearance", key="outputfont", subkey="type")
        if typeface == "":
            typeface = "Courier New"

        typesize = UserSettings.Get(group="appearance", key="outputfont", subkey="size")
        if typesize is None or int(typesize) <= 0:
            typesize = 10
        typesize = int(float(typesize))

        fontInfo = wx.FontInfo(typesize)
        fontInfo.FaceName(typeface)
        fontInfo.Family(wx.FONTFAMILY_TELETYPE)
        defaultFont = wx.Font(fontInfo)

        self.StyleClearAll()

        isDarkMode = False
        if wxPythonPhoenix and CheckWxVersion([4, 1, 0]):
            isDarkMode = wx.SystemSettings.GetAppearance().IsDark()

        defaultBackgroundColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)
        defaultTextColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT)

        self.StyleDefault = 0
        self.StyleSetFont(stc.STC_STYLE_DEFAULT, defaultFont)
        self.StyleSetBackground(stc.STC_STYLE_DEFAULT, defaultBackgroundColour)
        self.StyleSetForeground(stc.STC_STYLE_DEFAULT, defaultTextColour)

        self.StyleCommand = 1
        self.StyleSetBackground(self.StyleCommand, wx.Colour(154, 154, 154, 255))
        self.StyleSetForeground(self.StyleCommand, defaultTextColour)

        self.StyleOutput = 2
        self.StyleSetBackground(self.StyleOutput, defaultBackgroundColour)
        self.StyleSetForeground(self.StyleOutput, defaultTextColour)

        # fatal error
        self.StyleError = 3
        errorColour = wx.Colour(127, 0, 0)
        if isDarkMode:
            errorColour = wx.Colour(230, 0, 0)
        self.StyleSetBackground(self.StyleError, defaultBackgroundColour)
        self.StyleSetForeground(self.StyleError, errorColour)

        # warning
        self.StyleWarning = 4
        warningColour = wx.Colour(0, 0, 255)
        if isDarkMode:
            warningColour = wx.Colour(0, 102, 255)
        self.StyleSetBackground(self.StyleWarning, defaultBackgroundColour)
        self.StyleSetForeground(self.StyleWarning, warningColour)

        # message
        self.StyleMessage = 5
        self.StyleSetBackground(self.StyleMessage, defaultBackgroundColour)
        self.StyleSetForeground(self.StyleMessage, defaultTextColour)

        # unknown
        self.StyleUnknown = 6
        self.StyleSetBackground(self.StyleUnknown, defaultBackgroundColour)
        self.StyleSetForeground(self.StyleUnknown, defaultTextColour)
Пример #19
0
def main():
    rast = options['rast']
    vect = options['vect']
    strds = options['strds']
    stvds = options['stvds']

    numInputs = 0

    if rast:
        numInputs += 1
    if vect:
        numInputs += 1
    if strds:
        numInputs += 1
    if stvds:
        numInputs += 1

    if numInputs > 1:
        grass.fatal(
            _("%s=, %s=, %s= and %s= are mutually exclusive.") %
            ("rast", "vect", "strds", "stvds"))

    if numInputs > 0:
        # We need to initialize the temporal framework in case
        # a space time dataset was set on the command line so that
        # the AnimLayer() class works correctly
        tgis.init()

    layerList = LayerList()
    if rast:
        layer = AnimLayer()
        layer.mapType = 'rast'
        layer.name = rast
        layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])]
        layerList.AddLayer(layer)
    if vect:
        layer = AnimLayer()
        layer.mapType = 'vect'
        layer.name = vect
        layer.cmd = ['d.vect', 'map={name=}'.format(name=vect.split(',')[0])]
        layerList.AddLayer(layer)
    if strds:
        layer = AnimLayer()
        layer.mapType = 'strds'
        layer.name = strds
        layer.cmd = ['d.rast', 'map=']
        layerList.AddLayer(layer)
    if stvds:
        layer = AnimLayer()
        layer.mapType = 'stvds'
        layer.name = stvds
        layer.cmd = ['d.vect', 'map=']
        layerList.AddLayer(layer)

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
    frame.CentreOnScreen()
    frame.Show()
    if len(layerList) >= 1:
        frame.SetAnimations([layerList] + [None] * (MAX_COUNT - 1))
    app.MainLoop()
Пример #20
0
except ImportError:
    import wx.lib.customtreectrl as CT

from core.globalvar import gtk3, wxPythonPhoenix, CheckWxVersion
if wxPythonPhoenix:
    import wx.adv

if wxPythonPhoenix:
    ComboPopup = wx.ComboPopup
    wxComboCtrl = wx.ComboCtrl
else:
    import wx.combo
    ComboPopup = wx.combo.ComboPopup
    wxComboCtrl = wx.combo.ComboCtrl

if wxPythonPhoenix and CheckWxVersion([4, 0, 3, 0]):
    from wx import NewIdRef as NewId
else:
    from wx import NewId


def BitmapFromImage(image, depth=-1):
    if wxPythonPhoenix:
        return wx.Bitmap(img=image, depth=depth)
    else:
        return wx.BitmapFromImage(image, depth=depth)


def ImageFromBitmap(bitmap):
    if wxPythonPhoenix:
        return bitmap.ConvertToImage()
Пример #21
0
def main():
    grass.set_raise_on_error(False)

    options, flags = grass.parser()

    # import wx only after running parser
    # to avoid issues with complex imports when only interface is needed
    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.globalvar import CheckWxVersion
    from core.render import Map
    from mapdisp.frame import MapFrame
    from mapdisp.main import DMonGrassInterface
    from core.settings import UserSettings
    from vdigit.main import haveVDigit, errorMsg
    from grass.exceptions import CalledModuleError

    # define classes which needs imports as local
    # for longer definitions, a separate file would be a better option
    class VDigitMapFrame(MapFrame):

        def __init__(self, vectorMap):
            MapFrame.__init__(
                self, parent=None, Map=Map(), giface=DMonGrassInterface(None),
                title=_("GRASS GIS Vector Digitizer"), size=(850, 600))
            # this giface issue not solved yet, we must set mapframe aferwards
            self._giface._mapframe = self
            # load vector map
            mapLayer = self.GetMap().AddLayer(
                ltype='vector', name=vectorMap,
                command=['d.vect', 'map=%s' % vectorMap],
                active=True, hidden=False, opacity=1.0, render=True)

            # switch toolbar
            self.AddToolbar('vdigit', fixed=True)

            # start editing
            self.toolbars['vdigit'].StartEditing(mapLayer)

    if not haveVDigit:
        grass.fatal(_("Vector digitizer not available. %s") % errorMsg)

    if not grass.find_file(name=options['map'], element='vector',
                           mapset=grass.gisenv()['MAPSET'])['fullname']:
        if not flags['c']:
            grass.fatal(_("Vector map <%s> not found in current mapset. "
                          "New vector map can be created by providing '-c' flag.") %
                        options['map'])
        else:
            grass.verbose(_("New vector map <%s> created") % options['map'])
            try:
                grass.run_command(
                    'v.edit', map=options['map'],
                    tool='create', quiet=True)
            except CalledModuleError:
                grass.fatal(
                    _("Unable to create new vector map <%s>") %
                    options['map'])

    # allow immediate rendering
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = VDigitMapFrame(options['map'])
    frame.Show()

    app.MainLoop()
Пример #22
0
def main():
    options, flags = gscript.parser()

    # import wx only after running parser
    # to avoid issues when only interface is needed
    import grass.temporal as tgis
    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.globalvar import CheckWxVersion
    from core.utils import _
    from core.giface import StandaloneGrassInterface
    from core.layerlist import LayerList
    from animation.frame import AnimationFrame, MAX_COUNT
    from animation.data import AnimLayer

    rast = options['raster']
    vect = options['vector']
    strds = options['strds']
    stvds = options['stvds']

    numInputs = 0

    if rast:
        numInputs += 1
    if vect:
        numInputs += 1
    if strds:
        numInputs += 1
    if stvds:
        numInputs += 1

    if numInputs > 1:
        gscript.fatal(
            _("%s=, %s=, %s= and %s= are mutually exclusive.") %
            ("raster", "vector", "strds", "stvds"))

    if numInputs > 0:
        # We need to initialize the temporal framework in case
        # a space time dataset was set on the command line so that
        # the AnimLayer() class works correctly
        tgis.init()

    layerList = LayerList()
    if rast:
        layer = AnimLayer()
        layer.mapType = 'raster'
        layer.name = rast
        layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])]
        layerList.AddLayer(layer)
    if vect:
        layer = AnimLayer()
        layer.mapType = 'vector'
        layer.name = vect
        layer.cmd = ['d.vect', 'map={name}'.format(name=vect.split(',')[0])]
        layerList.AddLayer(layer)
    if strds:
        layer = AnimLayer()
        layer.mapType = 'strds'
        layer.name = strds
        layer.cmd = ['d.rast', 'map=']
        layerList.AddLayer(layer)
    if stvds:
        layer = AnimLayer()
        layer.mapType = 'stvds'
        layer.name = stvds
        layer.cmd = ['d.vect', 'map=']
        layerList.AddLayer(layer)

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
    frame.CentreOnScreen()
    frame.Show()
    if len(layerList) >= 1:
        # CallAfter added since it was crashing with wxPython 3 gtk
        wx.CallAfter(frame.SetAnimations,
                     [layerList] + [None] * (MAX_COUNT - 1))
    app.MainLoop()
Пример #23
0
def main():
    """
    Sets the GRASS display driver
    """
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.globalvar import CheckWxVersion
    from core.giface import StandaloneGrassInterface
    from image2target.ii2t_manager import GCPWizard

    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

#    if options['source_location']:
#        src_loc = options['source_location']
#    else:
#        gscript.fatal(_("No georeferenced source location provided"))

#    if options['source_mapset']:
#        src_mpt = options['source_mapset']
#    else:
#        gscript.fatal(_("No georeferenced source mapset provided"))

#    if options['source_group']:
#        src_grp = options['source_group']
#    else:
#        gscript.fatal(_("Please provide a source group name to process"))

#    if options['source_image']:
#        src_ras = options['source_image']
#    else:
#        gscript.fatal(_("Please provide a source image map name to process"))

#    if options['target_image']:
#        tgt_ras = options['target_image']
#    else:
#        gscript.fatal(_("No georeferenced target map provided"))

#    if options['camera']:
#        camera = options['camera']
#    else:
#        gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)"))

#    if options['order']:
#        order = options['order']
#    else:
#        gscript.fatal(_("Please provive an order value"))

#    if options['extension']:
#        extension = options['extension']
#    else:
#        gscript.fatal(_("Please provide an output file extension"))

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()


#    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(),
#            srcloc=src_loc,srcmpt=src_mpt,srcgrp=src_grp,srcras=src_ras,
#            tgtras=tgt_ras,camera=camera, order=order, extension=extension)

    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())
    app.MainLoop()