Example #1
0
    def OnInit(self):
        if not globalvar.CheckWxVersion([2, 9]):
            wx.InitAllImageHandlers()
        if __name__ == "__main__":
            self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
            self.Map = Map(cmdfile=monFile['cmd'],
                           mapfile=monFile['map'],
                           envfile=monFile['env'],
                           monitor=monName)
        else:
            self.Map = None

        self.mapFrm = MapFrame(parent=None,
                               id=wx.ID_ANY,
                               Map=self.Map,
                               size=monSize)
        # self.SetTopWindow(Map)
        self.mapFrm.Show()

        if __name__ == "__main__":
            self.timer = wx.PyTimer(self.watcher)
            #check each 0.5s
            global mtime
            mtime = 500
            self.timer.Start(mtime)

        return True
Example #2
0
        def __init__(
                self, new_map=None, base_map=None, edit_map=None,
                map_type=None,
        ):
            MapFrame.__init__(
                self, parent=None, Map=Map(),
                giface=DMonGrassInterface(None),
                title=_("Raster Digitizer - GRASS GIS"),
                size=(850, 600),
            )
            # this giface issue not solved yet, we must set mapframe afterwards
            self._giface._mapframe = self
            self._giface.mapCreated.connect(self.OnMapCreated)
            self._mapObj = self.GetMap()

            # load raster map
            self._addLayer(name=new_map if new_map else edit_map)

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

            rdigit = self.toolbars['rdigit']
            if new_map:
                rdigit._mapSelectionCombo.Unbind(wx.EVT_COMBOBOX)
                self.rdigit.SelectNewMap(
                    standalone=True, mapName=new_map, bgMap=base_map,
                    mapType=map_type,
                )
                rdigit._mapSelectionCombo.Bind(
                    wx.EVT_COMBOBOX, rdigit.OnMapSelection,
                )
            else:
                rdigit._mapSelectionCombo.SetSelection(n=1)
                rdigit.OnMapSelection()
Example #3
0
        def __init__(self, vectorMap):
            MapFrame.__init__(
                self,
                parent=None,
                Map=Map(),
                giface=DMonGrassInterface(None),
                title=_("Vector Digitizer - GRASS GIS"),
                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)
Example #4
0
 def testMapDisplay(self, giface, map_):
     from mapdisp.frame import MapFrame
     # known issues (should be similar with d.mon):
     # * opening map in digitizer ends with: vdigit/toolbars.py:723: 'selection' referenced before assignment
     # * nviz start fails (closes window? segfaults?) after mapdisp/frame.py:306: 'NoneType' object has no attribute 'GetLayerNotebook'
     frame = MapFrame(parent=None, title=_("Map display test"),
                      giface=giface, Map=map_)
     # this is questionable: how complete the giface when creating objects
     # which are in giface
     giface.mapWindow = frame.GetMapWindow()
     frame.GetMapWindow().ZoomToMap()
     frame.Show()
Example #5
0
    def __init__(self, vectorMap):
        MapFrame.__init__(self, parent = None, giface = StandaloneGrassInterface(),
                          title = _("GRASS GIS Vector Digitizer"), size = (850, 600))

        # load vector map
        mapLayer = self.GetMap().AddLayer(ltype = 'vector',
                                          command = ['d.vect', 'map=%s' % vectorMap],
                                          active = True, name = vectorMap, hidden = False, opacity = 1.0,
                                          render = True)
        
        # switch toolbar
        self.AddToolbar('vdigit', fixed = True)
        
        # start editing
        self.toolbars['vdigit'].StartEditing(mapLayer)
Example #6
0
class MapApp(wx.App):
    def OnInit(self):
        if not globalvar.CheckWxVersion([2, 9]):
            wx.InitAllImageHandlers()
        if __name__ == "__main__":
            self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
            self.Map = Map(cmdfile=monFile['cmd'],
                           mapfile=monFile['map'],
                           envfile=monFile['env'],
                           monitor=monName)
        else:
            self.Map = None

        self.mapFrm = MapFrame(parent=None,
                               id=wx.ID_ANY,
                               Map=self.Map,
                               size=monSize)
        # self.SetTopWindow(Map)
        self.mapFrm.Show()

        if __name__ == "__main__":
            self.timer = wx.PyTimer(self.watcher)
            #check each 0.5s
            global mtime
            mtime = 500
            self.timer.Start(mtime)

        return True

    def OnExit(self):
        if __name__ == "__main__":
            # stop the timer
            # self.timer.Stop()
            # terminate thread
            for f in monFile.itervalues():
                grass.try_remove(f)

    def watcher(self):
        """!Redraw, if new layer appears (check's timestamp of
        cmdfile)
        """
        # todo: events
        if os.path.getmtime(monFile['cmd']) > self.cmdTimeStamp:
            self.timer.Stop()
            self.cmdTimeStamp = os.path.getmtime(monFile['cmd'])
            self.mapFrm.OnDraw(None)
            self.mapFrm.GetMap().GetLayersFromCmdFile()
            self.timer.Start(mtime)
Example #7
0
        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)
Example #8
0
    def __init__(self, vectorMap):
        MapFrame.__init__(self,
                          parent=None,
                          giface=StandaloneGrassInterface(),
                          title=_("GRASS GIS Vector Digitizer"),
                          size=(850, 600))

        # load vector map
        mapLayer = self.GetMap().AddLayer(
            ltype='vector',
            command=['d.vect', 'map=%s' % vectorMap],
            active=True,
            name=vectorMap,
            hidden=False,
            opacity=1.0,
            render=True)

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

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