def __init__( self, parent, giface, title=_("Example Tool"), toolbars=["MiscToolbar", "MapToolbar", "MainToolbar"], size=(800, 600), name="exampleWindow", **kwargs, ): """!Map Panel constructor @param parent (no parent is expected) @param title window title @param toolbars list of active toolbars (default value represents all toolbars) """ SingleMapPanel.__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, "ExampleMapPanel.__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 statusbarItems = [ sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, sb.SbDisplayGeometry, sb.SbMapScale, sb.SbGoTo, ] self.statusbar = self.CreateStatusbar(statusbarItems) # 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.SetSize(size)
def __init__( self, parent, giface, title=_("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 """ SingleMapPanel.__init__( self, parent=parent, giface=giface, title=title, Map=Map, auimgr=auimgr, name=name, **kwargs, ) self._giface = giface 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) # # Create statusbar # statusbarItems = [ sb.SbCoordinates, sb.SbRegionExtent, sb.SbCompRegionExtent, sb.SbDisplayGeometry, sb.SbMapScale, sbgcp.SbGoToGCP, sbgcp.SbRMSError, ] self.statusbar = self.CreateStatusbar(statusbarItems) # # 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() # set Go To GCP item as active in statusbar self.mapWindowProperties.sbItem = 5 # 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