Ejemplo n.º 1
0
    def __init__(self, parent, giface, id=wx.ID_ANY,
                 title = _("GRASS GIS Histogramming Tool (d.histogram)"),
                 size = wx.Size(500, 350),
                 style = wx.DEFAULT_FRAME_STYLE, **kwargs):
        wx.Frame.__init__(self, parent, id, title, size = size, style = style, **kwargs)
        self.SetIcon(wx.Icon(os.path.join(globalvar.ICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))

        self._giface = giface
        self.Map   = Map()         # instance of render.Map to be associated with display
        self.layer = None          # reference to layer with histogram
        
        # Init variables
        self.params = {}  # previously set histogram parameters
        self.propwin = '' # ID of properties dialog
        
        self.font = ""
        self.encoding = 'ISO-8859-1' # default encoding for display fonts
        
        self.toolbar = HistogramToolbar(parent = self)
        # workaround for http://trac.wxwidgets.org/ticket/13888
        if sys.platform != 'darwin':
            self.SetToolBar(self.toolbar)

        # find selected map
        # might by moved outside this class
        # setting to None but honestly we do not handle no map case
        # TODO: when self.mapname is None content of map window is showed
        self.mapname = None
        layers = self._giface.GetLayerList().GetSelectedLayers(checkedOnly=False)
        if len(layers) > 0:
            self.mapname = layers[0].maplayer.name

        # Add statusbar
        self.statusbar = self.CreateStatusBar(number = 1, style = 0)
        # self.statusbar.SetStatusWidths([-2, -1])
        hist_frame_statusbar_fields = ["Histogramming %s" % self.mapname]
        for i in range(len(hist_frame_statusbar_fields)):
            self.statusbar.SetStatusText(hist_frame_statusbar_fields[i], i)
        
        # Init map display
        self.InitDisplay() # initialize region values
        
        # initialize buffered DC
        self.HistWindow = BufferedWindow(self, id = wx.ID_ANY, Map = self.Map) # initialize buffered DC
        
        # Bind various events
        self.Bind(wx.EVT_CLOSE,    self.OnCloseWindow)
        
        # Init print module and classes
        self.printopt = PrintOptions(self, self.HistWindow)
        
        # Add layer to the map
        self.layer = self.Map.AddLayer(ltype = "command", name = 'histogram', command = [['d.histogram']],
                                       active = False, hidden = False, opacity = 1, render = False)
        if self.mapname:
            self.SetHistLayer(self.mapname, None)
        else:
            self.OnErase(None)
            wx.CallAfter(self.OnOptions, None)
Ejemplo n.º 2
0
    def __init__(self,
                 parent=None,
                 title=_("GRASS GIS Manage Ground Control Points"),
                 toolbars=["gcpdisp"],
                 tree=None,
                 notebook=None,
                 lmgr=None,
                 page=None,
                 Map=None,
                 auimgr=None,
                 name='GCPMapWindow',
                 **kwargs):
        """!Main map display window with toolbars, statusbar and
        DrawWindow

        @param toolbars array of activated toolbars, e.g. ['map', 'digit']
        @param tree reference to layer tree
        @param notebook control book ID in Layer Manager
        @param lmgr Layer Manager
        @param page notebook page with layer tree
        @param Map instance of render.Map
        @param auimgs AUI manager
        @param kwargs wx.Frame attribures
        """

        MapFrameBase.__init__(self,
                              parent=parent,
                              title=title,
                              toolbars=toolbars,
                              Map=Map,
                              auimgr=auimgr,
                              name=name,
                              **kwargs)

        self._layerManager = lmgr  # Layer Manager object
        self.tree = tree  # Layer Manager layer tree object
        self.page = page  # Notebook page holding the layer tree
        self.layerbook = notebook  # Layer Manager layer tree notebook
        #
        # 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, sb.SbGoToGCP, sb.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
        self.statusbarManager.Update()

        #
        # Init map display (buffered DC & set default cursor)
        #
        self.grwiz.SwitchEnv('source')
        self.SrcMapWindow = BufferedWindow(self,
                                           id=wx.ID_ANY,
                                           Map=self.SrcMap,
                                           tree=self.tree,
                                           lmgr=self._layerManager)

        self.grwiz.SwitchEnv('target')
        self.TgtMapWindow = BufferedWindow(self,
                                           id=wx.ID_ANY,
                                           Map=self.TgtMap,
                                           tree=self.tree,
                                           lmgr=self._layerManager)
        self.MapWindow = self.SrcMapWindow
        self.Map = self.SrcMap
        self.SrcMapWindow.SetCursor(self.cursors["cross"])
        self.TgtMapWindow.SetCursor(self.cursors["cross"])

        #
        # initialize region values
        #
        self._initMap(map=self.SrcMap)
        self._initMap(map=self.TgtMap)

        #
        # Bind various events
        #
        self.Bind(wx.EVT_ACTIVATE, self.OnFocus)
        self.Bind(EVT_UPDATE_PRGBAR, self.OnUpdateProgress)
        self.Bind(wx.EVT_SIZE, self.OnDispResize)
        self.activemap.Bind(wx.EVT_CHOICE, self.OnUpdateActive)

        #
        # 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
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    def __init__(self,
                 parent=None,
                 id=wx.ID_ANY,
                 title=_("GRASS GIS Histogramming Tool (d.histogram)"),
                 size=wx.Size(500, 350),
                 style=wx.DEFAULT_FRAME_STYLE,
                 **kwargs):
        wx.Frame.__init__(self,
                          parent,
                          id,
                          title,
                          size=size,
                          style=style,
                          **kwargs)
        self.SetIcon(
            wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'),
                    wx.BITMAP_TYPE_ICO))

        self.Map = Map(
        )  # instance of render.Map to be associated with display
        self.layer = None  # reference to layer with histogram

        # Init variables
        self.params = {}  # previously set histogram parameters
        self.propwin = ''  # ID of properties dialog

        self.font = ""
        self.encoding = 'ISO-8859-1'  # default encoding for display fonts

        self.toolbar = HistogramToolbar(parent=self)
        self.SetToolBar(self.toolbar)

        # find selected map
        self.mapname = None
        if parent.GetName() == "MapWindow" and not parent.IsStandalone():
            tree = parent.GetLayerManager().GetLayerTree()

            if tree.layer_selected and tree.GetPyData(
                    tree.layer_selected)[0]['type'] == 'raster':
                self.mapname = tree.GetPyData(
                    tree.layer_selected)[0]['maplayer'].name

        # Add statusbar
        self.statusbar = self.CreateStatusBar(number=1, style=0)
        # self.statusbar.SetStatusWidths([-2, -1])
        hist_frame_statusbar_fields = ["Histogramming %s" % self.mapname]
        for i in range(len(hist_frame_statusbar_fields)):
            self.statusbar.SetStatusText(hist_frame_statusbar_fields[i], i)

        # Init map display
        self.InitDisplay()  # initialize region values

        # initialize buffered DC
        self.HistWindow = BufferedWindow(
            self, id=wx.ID_ANY, Map=self.Map)  # initialize buffered DC

        # Bind various events
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        # Init print module and classes
        self.printopt = PrintOptions(self, self.HistWindow)

        # Add layer to the map
        self.layer = self.Map.AddLayer(type="command",
                                       name='histogram',
                                       command=[['d.histogram']],
                                       l_active=False,
                                       l_hidden=False,
                                       l_opacity=1,
                                       l_render=False)
        if self.mapname:
            self.SetHistLayer(self.mapname, None)
        else:
            self.OnErase(None)