def __init__( self, parent=None, giface=None, title=_("Raster Digitizer"), toolbars=["digitMap", "rdigit"], size=(875, 600), name="RDigitWindow", **kwargs ): """! @param parent (no parent is expected) @param title window title @param toolbars dictionary of active toolbars (defalult value represents all toolbars) @param size default size """ SingleMapFrame.__init__( self, parent=parent, title=title, name=name, Map=Map(), **kwargs ) self._giface = giface self.MapWindow = RDigitWindow( parent=self, giface=self._giface, id=wx.ID_ANY, frame=self, Map=self.Map ) self.outMapName = None self.mapManager = MapManager(self, mapWindow=self.MapWindow, Map=self.GetMap()) self.SetSize(size) # MapWindowRDigit # Add toolbars toolbarsCopy = toolbars[:] if sys.platform == "win32": self.AddToolbar(toolbarsCopy.pop(1)) toolbarsCopy.reverse() else: self.AddToolbar(toolbarsCopy.pop(0)) for toolb in toolbarsCopy: self.AddToolbar(toolb) self.GetMapToolbar().Bind(wx.EVT_CHOICE, self.OnUpdateActive) # items for choice self.statusbarItems = [ sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, sb.SbShowRegion, sb.SbAlignExtent, sb.SbResolution, sb.SbDisplayGeometry, sb.SbMapScale, sb.SbGoTo, sb.SbProjection, ] # create statusbar and its manager statusbar = self.CreateStatusBar(number=4, style=0) statusbar.SetStatusWidths([-5, -2, -1, -1]) self.statusbarManager = sb.SbManager(mapframe=self, statusbar=statusbar) # fill statusbar manager self.statusbarManager.AddStatusbarItemsByClass( self.statusbarItems, mapframe=self, statusbar=statusbar ) self.statusbarManager.AddStatusbarItem( sb.SbMask(self, statusbar=statusbar, position=2) ) self.statusbarManager.AddStatusbarItem( sb.SbRender(self, statusbar=statusbar, position=3) ) self.statusbarManager.Update() self.changes = False self._addPanes() self._mgr.Update() self.mapManager.SetToolbar(self.toolbars["digitMap"]) # default action self.OnPan(event=None) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
class RDigitMapFrame(SingleMapFrame): """! RDigitMapFrame main frame This is the raster digitizer main window. It holds a minimal layer manager from wxIClass """ def __init__( self, parent=None, giface=None, title=_("Raster Digitizer"), toolbars=["digitMap", "rdigit"], size=(875, 600), name="RDigitWindow", **kwargs ): """! @param parent (no parent is expected) @param title window title @param toolbars dictionary of active toolbars (defalult value represents all toolbars) @param size default size """ SingleMapFrame.__init__( self, parent=parent, title=title, name=name, Map=Map(), **kwargs ) self._giface = giface self.MapWindow = RDigitWindow( parent=self, giface=self._giface, id=wx.ID_ANY, frame=self, Map=self.Map ) self.outMapName = None self.mapManager = MapManager(self, mapWindow=self.MapWindow, Map=self.GetMap()) self.SetSize(size) # MapWindowRDigit # Add toolbars toolbarsCopy = toolbars[:] if sys.platform == "win32": self.AddToolbar(toolbarsCopy.pop(1)) toolbarsCopy.reverse() else: self.AddToolbar(toolbarsCopy.pop(0)) for toolb in toolbarsCopy: self.AddToolbar(toolb) self.GetMapToolbar().Bind(wx.EVT_CHOICE, self.OnUpdateActive) # items for choice self.statusbarItems = [ sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, sb.SbShowRegion, sb.SbAlignExtent, sb.SbResolution, sb.SbDisplayGeometry, sb.SbMapScale, sb.SbGoTo, sb.SbProjection, ] # create statusbar and its manager statusbar = self.CreateStatusBar(number=4, style=0) statusbar.SetStatusWidths([-5, -2, -1, -1]) self.statusbarManager = sb.SbManager(mapframe=self, statusbar=statusbar) # fill statusbar manager self.statusbarManager.AddStatusbarItemsByClass( self.statusbarItems, mapframe=self, statusbar=statusbar ) self.statusbarManager.AddStatusbarItem( sb.SbMask(self, statusbar=statusbar, position=2) ) self.statusbarManager.AddStatusbarItem( sb.SbRender(self, statusbar=statusbar, position=3) ) self.statusbarManager.Update() self.changes = False self._addPanes() self._mgr.Update() self.mapManager.SetToolbar(self.toolbars["digitMap"]) # default action self.OnPan(event=None) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) def OnCloseWindow(self, event): self.Destroy() def GetWindow(self): return self.MapWindow def GetMap(self): return self.Map def OnHelp(self, event): """!Show help page""" helpInProgress = True def GetToolbar(self, name): if name in self.toolbars: return self.toolbars[name] return None def AddToolbar(self, name): """!Add toolbars to the frame""" if name == "digitMap": self.toolbars[name] = RDigitMapToolbar(self) self._mgr.AddPane( self.toolbars[name], wx.aui.AuiPaneInfo() .Name(name) .Caption(_("Map Toolbar")) .ToolbarPane() .Top() .LeftDockable(False) .RightDockable(False) .BottomDockable(False) .TopDockable(True) .CloseButton(False) .Layer(2) .Row(1) .BestSize((self.toolbars[name].GetBestSize())), ) elif name == "rdigit": self.toolbars[name] = RDigitToolbar( parent=self, MapWindow=self.MapWindow, digitClass=RDigit, layerTree=self.mapManager, ) self._mgr.AddPane( self.toolbars[name], wx.aui.AuiPaneInfo() .Name("rdigittoolbar") .Caption(_("Raster Digitizer Toolbar")) .ToolbarPane() .Top() .Row(1) .LeftDockable(False) .RightDockable(False) .BottomDockable(False) .TopDockable(True) .CloseButton(False) .Layer(0) .BestSize((self.toolbars["rdigit"].GetBestSize())), ) self.MapWindow.SetToolbar(self.toolbars[name]) # self._mgr.GetPane('rdigittoolbar').Hide() def _addPanes(self): """!Add mapwindows and toolbars to aui manager""" self._addPaneMapWindow() self._addPaneToolbar(name="digitMap") def _addPaneToolbar(self, name): self.toolbars[name] = RDigitMapManagerToolbar(self, self.mapManager) self._mgr.AddPane( self.toolbars[name], wx.aui.AuiPaneInfo() .ToolbarPane() .Movable() .Name(name) .CloseButton(False) .Center() .Layer(0) .BestSize((self.toolbars[name].GetBestSize())), ) def _addPaneMapWindow(self): self._mgr.AddPane( self.MapWindow, wx.aui.AuiPaneInfo() .CentrePane() .Dockable(False) .BestSize((-1, -1)) .Name("window") .CloseButton(False) .DestroyOnClose(True) .Layer(0), ) # self._mgr.AddPane(self.MapWindowRDigit, wx.aui.AuiPaneInfo().CentrePane(). # Dockable(True).BestSize((-1,-1)).Name('rdigit'). # CloseButton(False).DestroyOnClose(True). # Layer(0)) self._mgr.GetPane("window").Show() self._mgr.GetPane("rdigit").Hide() def IsStandalone(self): """!Check if Map display is standalone""" return True def OnUpdateActive(self, event): """! @todo move to DoubleMapFrame? """ self.StatusbarUpdate() def GetMapToolbar(self): """!Returns toolbar with zooming tools""" return self.toolbars["digitMap"] def AddRasterMap(self, name, firstMap=True, secondMap=True): """!Add raster map to Map""" cmdlist = ["d.rast", "map=%s" % name] if firstMap: self.GetFirstMap().AddLayer( type="raster", command=cmdlist, l_active=True, name=name, l_hidden=False, l_opacity=1.0, l_render=False, ) self.GetWindow().UpdateMap(render=True, renderVector=False) def OnZoomMenu(self, event): """!Popup Zoom menu""" zoommenu = wx.Menu() zoommenu.Destroy() def OnZoomIn(self, event): super(RDigitMapFrame, self).OnZoomIn(event) def OnZoomOut(self, event): super(RDigitMapFrame, self).OnZoomOut(event) def OnPan(self, event): super(RDigitMapFrame, self).OnPan(event) def GetOutputMap(self): return self.outMapName def RemoveToolbar(self, name): self.outMapName = self.toolbars["rdigit"].GetMapName() self.mapManager.AddLayer(name=self.outMapName) self._mgr.GetPane("window").Show() self._mgr.Update()