def __init__( self, parent, giface, title=_( "GRASS GIS Manage Location of Tick Points on a Scanned Photo"), toolbars=["gcpdisp"], Map=None, auimgr=None, name='GCPMapWindow', **kwargs): """Main map display window with toolbars, statusbar and DrawWindow :param giface: GRASS interface instance :param title: window title :param toolbars: array of activated toolbars, e.g. ['map', 'digit'] :param map: instance of render.Map :param auimgs: AUI manager :param kwargs: wx.Frame attribures """ SingleMapFrame.__init__(self, parent=parent, giface=giface, title=title, Map=Map, auimgr=auimgr, name=name, **kwargs) self._giface = giface # properties are shared in other objects, so defining here self.mapWindowProperties = MapWindowProperties() self.mapWindowProperties.setValuesFromUserSettings() self.mapWindowProperties.alignExtent = True # # Add toolbars # for toolb in toolbars: self.AddToolbar(toolb) self.activemap = self.toolbars['gcpdisp'].togglemap self.activemap.SetSelection(0) self.SrcMap = self.grwiz.SrcMap # instance of render.Map self.TgtMap = self.grwiz.TgtMap # instance of render.Map self._mgr.SetDockSizeConstraint(0.5, 0.5) # # Add statusbar # # items for choice self.statusbarItems = [ sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, sb.SbShowRegion, sb.SbResolution, sb.SbDisplayGeometry, sb.SbMapScale, sb.SbProjection, sbgcp.SbGoToGCP, sbgcp.SbRMSError ] # 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.SetMode(8) # goto GCP # # Init map display (buffered DC & set default cursor) # self.grwiz.SwitchEnv('source') self.SrcMapWindow = BufferedMapWindow( parent=self, giface=self._giface, id=wx.ID_ANY, properties=self.mapWindowProperties, Map=self.SrcMap) self.grwiz.SwitchEnv('target') self.TgtMapWindow = BufferedMapWindow( parent=self, giface=self._giface, id=wx.ID_ANY, properties=self.mapWindowProperties, Map=self.TgtMap) self.MapWindow = self.SrcMapWindow self.Map = self.SrcMap self._setUpMapWindow(self.SrcMapWindow) self._setUpMapWindow(self.TgtMapWindow) self.SrcMapWindow.SetNamedCursor('cross') self.TgtMapWindow.SetNamedCursor('cross') # used to switch current map (combo box in toolbar) self.SrcMapWindow.mouseEntered.connect( lambda: self._setActiveMapWindow(self.SrcMapWindow)) self.TgtMapWindow.mouseEntered.connect( lambda: self._setActiveMapWindow(self.TgtMapWindow)) # # initialize region values # self._initMap(Map=self.SrcMap) self._initMap(Map=self.TgtMap) self.GetMapToolbar().SelectDefault() # # Bind various events # self.activemap.Bind(wx.EVT_CHOICE, self.OnUpdateActive) self.Bind(wx.EVT_SIZE, self.OnSize) # # Update fancy gui style # # AuiManager wants a CentrePane, workaround to get two equally sized # windows self.list = self.CreateGCPList() #self.SrcMapWindow.SetSize((300, 300)) #self.TgtMapWindow.SetSize((300, 300)) self.list.SetSize((100, 150)) self._mgr.AddPane( self.list, wx.aui.AuiPaneInfo().Name("gcplist").Caption( _("GCP List")).LeftDockable(False).RightDockable( False).PinButton().FloatingSize((600, 200)).CloseButton( False).DestroyOnClose(True).Top().Layer(1).MinSize( (200, 100))) self._mgr.AddPane( self.SrcMapWindow, wx.aui.AuiPaneInfo().Name("source").Caption( _("Source Display")).Dockable(False).CloseButton( False).DestroyOnClose(True).Floatable(False).Centre()) self._mgr.AddPane( self.TgtMapWindow, wx.aui.AuiPaneInfo().Name("target").Caption( _("Target Display")).Dockable(False).CloseButton(False). DestroyOnClose(True).Floatable(False).Right().Layer(0)) srcwidth, srcheight = self.SrcMapWindow.GetSize() tgtwidth, tgtheight = self.TgtMapWindow.GetSize() srcwidth = (srcwidth + tgtwidth) / 2 self._mgr.GetPane("target").Hide() self._mgr.Update() self._mgr.GetPane("source").BestSize((srcwidth, srcheight)) self._mgr.GetPane("target").BestSize((srcwidth, srcheight)) if self.show_target: self._mgr.GetPane("target").Show() else: self.activemap.Enable(False) # needed by Mac OS, does not harm on Linux, breaks display on Windows if platform.system() != 'Windows': self._mgr.Update() # # Init print module and classes # self.printopt = PrintOptions(self, self.MapWindow) # # Initialization of digitization tool # self.digit = None # set active map self.MapWindow = self.SrcMapWindow self.Map = self.SrcMap # do not init zoom history here, that happens when zooming to map(s) # # Re-use dialogs # self.dialogs = {} self.dialogs['attributes'] = None self.dialogs['category'] = None self.dialogs['barscale'] = None self.dialogs['legend'] = None self.decorationDialog = None # decoration/overlays # doing nice things in statusbar when other things are ready self.statusbarManager.Update()
def __init__( self, parent, giface, title=_("Example Tool"), toolbars=["MiscToolbar", "MapToolbar", "MainToolbar"], size=(800, 600), name="exampleWindow", **kwargs, ): """!Map Frame constructor @param parent (no parent is expected) @param title window title @param toolbars list of active toolbars (default value represents all toolbars) @param size default size """ SingleMapFrame.__init__( self, parent=parent, title=title, name=name, Map=Map(), **kwargs ) # Place debug message where appropriate # and set debug level from 1 to 5 (higher to lower level functions). # To enable debug mode write: # > g.gisenv set=WX_DEBUG=5 Debug.msg(1, "ExampleMapFrame.__init__()") # # Add toolbars to aui manager # toolbarsCopy = toolbars[:] # workaround to have the same toolbar order on all platforms if sys.platform == "win32": toolbarsCopy.reverse() for toolbar in toolbarsCopy: self.AddToolbar(toolbar) self.mapWindowProperties = MapWindowProperties() self.mapWindowProperties.setValuesFromUserSettings() self.mapWindowProperties.autoRenderChanged.connect( lambda value: self.OnRender(None) if value else None ) # # Add statusbar # # choose items in statusbar choice, which makes sense for your application 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() # create map window self.MapWindow = BufferedMapWindow( parent=self, Map=self.GetMap(), properties=self.mapWindowProperties, giface=self, ) self._setUpMapWindow(self.MapWindow) self.MapWindow.InitZoomHistory() # create whatever you want, here it is a widget for displaying raster info self.info = ExampleInfoTextManager(self) # add map window (and other widgets) to aui manager self._addPanes() self._mgr.Update() # initialize variables related to your application functionality self.InitVariables() # default action self.GetMapToolbar().SelectDefault() self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.SetSize(size)
def __init__( self, parent, giface, title=_("GRASS GIS Manage Ground Control Points"), toolbars=["gcpdisp"], Map=None, auimgr=None, name="GCPMapWindow", **kwargs, ): """Main map display window with toolbars, statusbar and DrawWindow :param giface: GRASS interface instance :param title: window title :param toolbars: array of activated toolbars, e.g. ['map', 'digit'] :param map: instance of render.Map :param auimgs: AUI manager :param kwargs: wx.Frame attribures """ SingleMapFrame.__init__( self, parent=parent, giface=giface, title=title, Map=Map, auimgr=auimgr, name=name, **kwargs, ) self._giface = giface # properties are shared in other objects, so defining here self.mapWindowProperties = MapWindowProperties() self.mapWindowProperties.setValuesFromUserSettings() self.mapWindowProperties.alignExtent = True # # Add toolbars # for toolb in toolbars: self.AddToolbar(toolb) self.activemap = self.toolbars["gcpdisp"].togglemap self.activemap.SetSelection(0) self.SrcMap = self.grwiz.SrcMap # instance of render.Map self.TgtMap = self.grwiz.TgtMap # instance of render.Map self._mgr.SetDockSizeConstraint(0.5, 0.5) # # Add statusbar # # items for choice statusbarItems = [ sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, sb.SbShowRegion, sb.SbResolution, sb.SbDisplayGeometry, sb.SbMapScale, sb.SbProjection, sbgcp.SbGoToGCP, sbgcp.SbRMSError, ] # create statusbar and its manager self.statusbar = self.CreateStatusbar(statusbarItems) self.statusbarManager.SetMode(8) # goto GCP # # Init map display (buffered DC & set default cursor) # self.grwiz.SwitchEnv("source") self.SrcMapWindow = BufferedMapWindow( parent=self, giface=self._giface, id=wx.ID_ANY, properties=self.mapWindowProperties, Map=self.SrcMap, ) self.grwiz.SwitchEnv("target") self.TgtMapWindow = BufferedMapWindow( parent=self, giface=self._giface, id=wx.ID_ANY, properties=self.mapWindowProperties, Map=self.TgtMap, ) self.MapWindow = self.SrcMapWindow self.Map = self.SrcMap self._setUpMapWindow(self.SrcMapWindow) self._setUpMapWindow(self.TgtMapWindow) self.SrcMapWindow.SetNamedCursor("cross") self.TgtMapWindow.SetNamedCursor("cross") # used to switch current map (combo box in toolbar) self.SrcMapWindow.mouseEntered.connect( lambda: self._setActiveMapWindow(self.SrcMapWindow)) self.TgtMapWindow.mouseEntered.connect( lambda: self._setActiveMapWindow(self.TgtMapWindow)) # # initialize region values # self._initMap(Map=self.SrcMap) self._initMap(Map=self.TgtMap) self.GetMapToolbar().SelectDefault() # # Bind various events # self.activemap.Bind(wx.EVT_CHOICE, self.OnUpdateActive) self.Bind(wx.EVT_SIZE, self.OnSize) # # Update fancy gui style # # AuiManager wants a CentrePane, workaround to get two equally sized # windows self.list = self.CreateGCPList() # self.SrcMapWindow.SetSize((300, 300)) # self.TgtMapWindow.SetSize((300, 300)) self.list.SetSize((100, 150)) self._addPanes() srcwidth, srcheight = self.SrcMapWindow.GetSize() tgtwidth, tgtheight = self.TgtMapWindow.GetSize() srcwidth = (srcwidth + tgtwidth) / 2 self._mgr.GetPane("target").Hide() self._mgr.Update() self._mgr.GetPane("source").BestSize((srcwidth, srcheight)) self._mgr.GetPane("target").BestSize((srcwidth, srcheight)) if self.show_target: self._mgr.GetPane("target").Show() else: self.activemap.Enable(False) # needed by Mac OS, does not harm on Linux, breaks display on Windows if platform.system() != "Windows": self._mgr.Update() # # Init print module and classes # self.printopt = PrintOptions(self, self.MapWindow) # # Initialization of digitization tool # self.digit = None # set active map self.MapWindow = self.SrcMapWindow self.Map = self.SrcMap # do not init zoom history here, that happens when zooming to map(s) # # Re-use dialogs # self.dialogs = {} self.dialogs["attributes"] = None self.dialogs["category"] = None self.dialogs["barscale"] = None self.dialogs["legend"] = None self.decorationDialog = None # decoration/overlays # doing nice things in statusbar when other things are ready self.statusbarManager.Update()
def __init__(self, parent, giface, title=_("Example Tool"), toolbars=["MiscToolbar", "MapToolbar", "MainToolbar"], size=(800, 600), name='exampleWindow', **kwargs): """!Map Frame constructor @param parent (no parent is expected) @param title window title @param toolbars list of active toolbars (default value represents all toolbars) @param size default size """ SingleMapFrame.__init__(self, parent=parent, title=title, name=name, Map=Map(), **kwargs) # Place debug message where appropriate # and set debug level from 1 to 5 (higher to lower level functions). # To enable debug mode write: # > g.gisenv set=WX_DEBUG=5 Debug.msg(1, "ExampleMapFrame.__init__()") # # Add toolbars to aui manager # toolbarsCopy = toolbars[:] # workaround to have the same toolbar order on all platforms if sys.platform == 'win32': toolbarsCopy.reverse() for toolbar in toolbarsCopy: self.AddToolbar(toolbar) self.mapWindowProperties = MapWindowProperties() self.mapWindowProperties.setValuesFromUserSettings() self.mapWindowProperties.autoRenderChanged.connect( lambda value: self.OnRender(None) if value else None) # # Add statusbar # # choose items in statusbar choice, which makes sense for your application 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() # create map window self.MapWindow = BufferedMapWindow(parent=self, Map=self.GetMap(), properties=self.mapWindowProperties, giface=self) self._setUpMapWindow(self.MapWindow) self.MapWindow.InitZoomHistory() # create whatever you want, here it is a widget for displaying raster info self.info = ExampleInfoTextManager(self) # add map window (and other widgets) to aui manager self._addPanes() self._mgr.Update() # initialize variables related to your application functionality self.InitVariables() # default action self.GetMapToolbar().SelectDefault() self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) self.SetSize(size)
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 __init__(self, parent, giface, title=_("GRASS GIS Manage Ground Control Points"), toolbars=["gcpdisp"], Map=None, auimgr=None, name='GCPMapWindow', **kwargs): """Main map display window with toolbars, statusbar and DrawWindow :param giface: GRASS interface instance :param title: window title :param toolbars: array of activated toolbars, e.g. ['map', 'digit'] :param map: instance of render.Map :param auimgs: AUI manager :param kwargs: wx.Frame attribures """ SingleMapFrame.__init__(self, parent = parent, giface = giface, title = title, Map = Map, auimgr = auimgr, name = name, **kwargs) self._giface = giface # properties are shared in other objects, so defining here self.mapWindowProperties = MapWindowProperties() self.mapWindowProperties.setValuesFromUserSettings() self.mapWindowProperties.alignExtent = True # # Add toolbars # for toolb in toolbars: self.AddToolbar(toolb) self.activemap = self.toolbars['gcpdisp'].togglemap self.activemap.SetSelection(0) self.SrcMap = self.grwiz.SrcMap # instance of render.Map self.TgtMap = self.grwiz.TgtMap # instance of render.Map self._mgr.SetDockSizeConstraint(0.5, 0.5) # # Add statusbar # # items for choice self.statusbarItems = [sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, sb.SbShowRegion, sb.SbResolution, sb.SbDisplayGeometry, sb.SbMapScale, sb.SbProjection, sbgcp.SbGoToGCP, sbgcp.SbRMSError] # 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.SetMode(8) # goto GCP # # Init map display (buffered DC & set default cursor) # self.grwiz.SwitchEnv('source') self.SrcMapWindow = BufferedMapWindow(parent=self, giface=self._giface, id=wx.ID_ANY, properties=self.mapWindowProperties, Map=self.SrcMap) self.grwiz.SwitchEnv('target') self.TgtMapWindow = BufferedMapWindow(parent=self, giface=self._giface, id=wx.ID_ANY, properties=self.mapWindowProperties, Map=self.TgtMap) self.MapWindow = self.SrcMapWindow self.Map = self.SrcMap self._setUpMapWindow(self.SrcMapWindow) self._setUpMapWindow(self.TgtMapWindow) self.SrcMapWindow.SetNamedCursor('cross') self.TgtMapWindow.SetNamedCursor('cross') # used to switch current map (combo box in toolbar) self.SrcMapWindow.mouseEntered.connect( lambda: self._setActiveMapWindow(self.SrcMapWindow)) self.TgtMapWindow.mouseEntered.connect( lambda: self._setActiveMapWindow(self.TgtMapWindow)) # # initialize region values # self._initMap(Map = self.SrcMap) self._initMap(Map = self.TgtMap) self.GetMapToolbar().SelectDefault() # # Bind various events # self.activemap.Bind(wx.EVT_CHOICE, self.OnUpdateActive) self.Bind(wx.EVT_SIZE, self.OnSize) # # Update fancy gui style # # AuiManager wants a CentrePane, workaround to get two equally sized windows self.list = self.CreateGCPList() #self.SrcMapWindow.SetSize((300, 300)) #self.TgtMapWindow.SetSize((300, 300)) self.list.SetSize((100, 150)) self._mgr.AddPane(self.list, wx.aui.AuiPaneInfo(). Name("gcplist").Caption(_("GCP List")).LeftDockable(False). RightDockable(False).PinButton().FloatingSize((600,200)). CloseButton(False).DestroyOnClose(True). Top().Layer(1).MinSize((200,100))) self._mgr.AddPane(self.SrcMapWindow, wx.aui.AuiPaneInfo(). Name("source").Caption(_("Source Display")).Dockable(False). CloseButton(False).DestroyOnClose(True).Floatable(False). Centre()) self._mgr.AddPane(self.TgtMapWindow, wx.aui.AuiPaneInfo(). Name("target").Caption(_("Target Display")).Dockable(False). CloseButton(False).DestroyOnClose(True).Floatable(False). Right().Layer(0)) srcwidth, srcheight = self.SrcMapWindow.GetSize() tgtwidth, tgtheight = self.TgtMapWindow.GetSize() srcwidth = (srcwidth + tgtwidth) / 2 self._mgr.GetPane("target").Hide() self._mgr.Update() self._mgr.GetPane("source").BestSize((srcwidth, srcheight)) self._mgr.GetPane("target").BestSize((srcwidth, srcheight)) if self.show_target: self._mgr.GetPane("target").Show() else: self.activemap.Enable(False) # needed by Mac OS, does not harm on Linux, breaks display on Windows if platform.system() != 'Windows': self._mgr.Update() # # Init print module and classes # self.printopt = PrintOptions(self, self.MapWindow) # # Initialization of digitization tool # self.digit = None # set active map self.MapWindow = self.SrcMapWindow self.Map = self.SrcMap # do not init zoom history here, that happens when zooming to map(s) # # Re-use dialogs # self.dialogs = {} self.dialogs['attributes'] = None self.dialogs['category'] = None self.dialogs['barscale'] = None self.dialogs['legend'] = None self.decorationDialog = None # decoration/overlays # doing nice things in statusbar when other things are ready self.statusbarManager.Update()