Exemple #1
0
    def __init__(self, parent, toolSwitcher):
        """Toolbar Cartographic Composer (psmap.py)

        :param parent: parent window
        """
        BaseToolbar.__init__(self, parent, toolSwitcher)

        # workaround for http://trac.wxwidgets.org/ticket/13888
        if sys.platform == 'darwin':
            parent.SetToolBar(self)

        self.InitToolbar(self._toolbarData())
        self._default = self.pointer

        for tool in (self.pointer, self.pan, self.zoomin, self.zoomout,
                     self.drawGraphics, self.addMap):
            self.toolSwitcher.AddToolToGroup(
                group='mouseUse', toolbar=self, tool=tool)

        # custom button for graphics mode selection
        # TODO: could this be somehow generalized?
        self.arrowButton = self.CreateSelectionButton()
        self.arrowButtonId = self.InsertControl(18, self.arrowButton)
        self.arrowButton.Bind(wx.EVT_BUTTON, self.OnDrawGraphicsMenu)

        self.drawGraphicsAction = None
        self.OnAddPoint(event=None)

        self.Realize()

        from psmap.frame import havePILImage
        if not havePILImage:
            self.EnableTool(self.preview, False)
Exemple #2
0
    def __init__(self, parent):
        """!
        GCP Display toolbar constructor
        """
        BaseToolbar.__init__(self, parent)
        
        self.InitToolbar(self._toolbarData())
        
        # add tool to toggle active map window
        self.togglemapid = wx.NewId()
        self.togglemap = wx.Choice(parent = self, id = self.togglemapid,
                                   choices = [_('source'), _('target')])

        self.InsertControl(10, self.togglemap)

        self.SetToolShortHelp(self.togglemapid, '%s %s %s' % (_('Set map canvas for '),
                                                              BaseIcons["zoomBack"].GetLabel(),
                                                              _(' / Zoom to map')))

        # realize the toolbar
        self.Realize()
        
        self.action = { 'id' : self.gcpset }
        self.defaultAction = { 'id' : self.gcpset,
                               'bind' : self.parent.OnPointer }
        
        self.OnTool(None)
        
        self.EnableTool(self.zoomback, False)
Exemple #3
0
    def __init__(self, parent, toolSwitcher):
        """RLiSetup toolbar constructor
        """

        BaseToolbar.__init__(self, parent, toolSwitcher,
                             style=wx.NO_BORDER | wx.TB_VERTICAL)

        self.InitToolbar(self._toolbarData())

        if self.parent.samplingtype == SamplingType.REGIONS:
            self._default = self.digitizeregion
        elif self.parent.samplingtype in [SamplingType.MUNITSR,
                                          SamplingType.MMVWINR]:
            self._default = self.digitizeunit
        elif self.parent.samplingtype in [SamplingType.MUNITSC,
                                          SamplingType.MMVWINC]:
            self._default = self.digitizeunitc
        elif self.parent.samplingtype == SamplingType.VECT:
            self._default = None
        else:
            self._default = self.draw

        for tool in (self._default, self.pan, self.zoomIn, self.zoomOut):
            if tool:
                self.toolSwitcher.AddToolToGroup(group='mouseUse',
                                                 toolbar=self, tool=tool)

        # realize the toolbar
        self.Realize()
Exemple #4
0
    def __init__(self, parent, toolSwitcher):
        """IClass Map toolbar constructor
        """
        BaseToolbar.__init__(self, parent, toolSwitcher)

        self.InitToolbar(self._toolbarData())
        self._default = self.pan

        # add tool to toggle active map window
        self.togglemapid = wx.NewId()
        self.togglemap = wx.Choice(parent=self, id=self.togglemapid,
                                   choices=[_('Training'), _('Preview')])

        self.InsertControl(9, self.togglemap)

        self.SetToolShortHelp(
            self.togglemapid, '%s %s %s' %
            (_('Set map canvas for '),
             BaseIcons["zoomBack"].GetLabel(),
             _('/ Zoom to map')))

        for tool in (self.pan, self.zoomIn, self.zoomOut):
            self.toolSwitcher.AddToolToGroup(
                group='mouseUse', toolbar=self, tool=tool)
        # realize the toolbar
        self.Realize()

        self.EnableTool(self.zoomBack, False)
Exemple #5
0
    def __init__(self, parent, stats_data):
        """IClass toolbar constructor
        """
        self.stats_data = stats_data

        BaseToolbar.__init__(self, parent)
        self.InitToolbar(self._toolbarData())

        self.choice = wx.Choice(parent=self, id=wx.ID_ANY, size=(110, -1))
        choiceid = self.InsertControl(3, self.choice)

        self.choice.Bind(wx.EVT_CHOICE, self.OnSelectCategory)

        # stupid workaround to insert small space between controls
        self.InsertControl(4, wx.StaticText(self, id=wx.ID_ANY, label=' '))

        self.combo = wx.ComboBox(self, id=wx.ID_ANY, size=(130, -1),
                                 style=wx.TE_PROCESS_ENTER)
        self.InitStddev()
        comboid = self.InsertControl(5, self.combo)

        self.EnableControls(False)

        self.combo.Bind(wx.EVT_COMBOBOX, self.OnStdChangeSelection)
        self.combo.Bind(wx.EVT_TEXT_ENTER, self.OnStdChangeText)

        self.stats_data.statisticsAdded.connect(self.Update)
        self.stats_data.statisticsDeleted.connect(self.Update)
        self.stats_data.allStatisticsDeleted.connect(self.Update)
        self.stats_data.statisticsSet.connect(self.Update)

        # realize the toolbar
        self.Realize()
Exemple #6
0
    def __init__(self, parent):
        """Toolbar constructor
        """
        BaseToolbar.__init__(self, parent)

        self.InitToolbar(self._toolbarData())

        # add tool to toggle active map window
        self.toggleModeId = wx.NewId()
        self.toggleMode = wx.Choice(parent=self, id=self.toggleModeId)
        for label, cdata in zip(
                [_('Swipe mode'),
                 _('Mirror mode')],
                ['swipe', 'mirror']):
            self.toggleMode.Append(label, cdata)
        self.toggleMode.SetSelection(0)
        self.toggleMode.SetSize(self.toggleMode.GetBestSize())
        self.toggleMode.Bind(
            wx.EVT_CHOICE,
            lambda event: self.parent.SetViewMode(
                self.toggleMode.GetClientData(
                    event.GetSelection())))
        self.InsertControl(3, self.toggleMode)

        help = _("Choose view mode")
        self.SetToolShortHelp(self.toggleModeId, help)
        # realize the toolbar
        self.Realize()
Exemple #7
0
    def __init__(self, parent, vnet_mgr):
        BaseToolbar.__init__(self, parent)
        
        self.vnet_mgr = vnet_mgr
        self.InitToolbar(self._toolbarData())

        choices = []

        for moduleName in self.vnet_mgr.GetAnalyses():
            choices.append(self.vnet_mgr.GetAnalysisProperties(moduleName)['label'])

        self.anChoice = wx.ComboBox(parent = self, id = wx.ID_ANY,
                                    choices = choices,
                                    style = wx.CB_READONLY, size = (350, 30))#FIXME
        self.anChoice.SetToolTipString(_('Availiable analyses'))
        self.anChoice.SetSelection(0)
               
        self.anChoiceId = self.AddControl(self.anChoice)
        self.parent.Bind(wx.EVT_COMBOBOX, self.parent.OnAnalysisChanged, self.anChoiceId)
                
        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
        self.anChoice.Hide()
        self.anChoice.Show()
        # realize the toolbar
        self.Realize()
Exemple #8
0
 def __init__(self, parent):
     BaseToolbar.__init__(self, parent)
     
     self.InitToolbar(self._toolbarData())
     
     # realize the toolbar
     self.Realize()
Exemple #9
0
    def __init__(self, parent):
        BaseToolbar.__init__(self, parent)

        self.icons = {
            'open': MetaIcon(img='open',
                             label=_('Open (Ctrl+O)')),
            'save': MetaIcon(img='save',
                             label=_('Save (Ctrl+S)')),
            'run': MetaIcon(img='execute',
                            label=_('Run (Ctrl+R)')),
            # TODO: better icons for overwrite modes
            'overwriteTrue': MetaIcon(img='locked',
                                      label=_('Activate overwrite')),
            'overwriteFalse': MetaIcon(img='unlocked',
                                       label=_('Deactive overwrite')),
        }

        # workaround for http://trac.wxwidgets.org/ticket/13888
        if sys.platform == 'darwin':
            parent.SetToolBar(self)

        self.InitToolbar(self._toolbarData())

        # realize the toolbar
        self.Realize()
Exemple #10
0
    def __init__(self, parent, toolSwitcher):
        """GCP Display toolbar constructor
        """
        BaseToolbar.__init__(self, parent, toolSwitcher)
        
        self.InitToolbar(self._toolbarData())
        self._default = self.gcpset
        
        # add tool to toggle active map window
        self.togglemapid = wx.NewId()
        self.togglemap = wx.Choice(parent = self, id = self.togglemapid,
                                   choices = [_('source'), _('target')])

        self.InsertControl(10, self.togglemap)

        self.SetToolShortHelp(self.togglemapid, '%s %s %s' % (_('Set map canvas for '),
                                                              BaseIcons["zoomBack"].GetLabel(),
                                                              _(' / Zoom to map')))

        for tool in (self.gcpset, self.pan, self.zoomin, self.zoomout):
            self.toolSwitcher.AddToolToGroup(group='mouseUse', toolbar=self, tool=tool)

        # realize the toolbar
        self.Realize()

        self.EnableTool(self.zoomback, False)
Exemple #11
0
    def __init__(self, parent):
        """IClass toolbar constructor
        """
        BaseToolbar.__init__(self, parent)

        self.InitToolbar(self._toolbarData())
        # realize the toolbar
        self.Realize()
Exemple #12
0
    def __init__(self, parent, scatt_mgr):
        BaseToolbar.__init__(self, parent)
        self.scatt_mgr = scatt_mgr

        self.InitToolbar(self._toolbarData())
        
        # realize the toolbar
        self.Realize()
        self.scatt_mgr.modeSet.connect(self.ModeSet)
Exemple #13
0
    def __init__(self, parent, vnet_mgr):
        BaseToolbar.__init__(self, parent)
        
        self.InitToolbar(self._toolbarData())

        self.vnet_mgr = vnet_mgr

        # realize the toolbar
        self.Realize()
Exemple #14
0
    def __init__(self, parent, scatt_mgr, cats_list):
        BaseToolbar.__init__(self, parent)
        self.scatt_mgr = scatt_mgr
        self.cats_mgr = self.scatt_mgr.GetCategoriesManager()
        self.cats_list = cats_list

        self.InitToolbar(self._toolbarData())
        
        # realize the toolbar
        self.Realize()
Exemple #15
0
    def __init__(self, parent):
        BaseToolbar.__init__(self, parent)

        # workaround for http://trac.wxwidgets.org/ticket/13888
        if sys.platform == 'darwin':
            parent.SetToolBar(self)

        self.InitToolbar(self._toolbarData())
        
        # realize the toolbar
        self.Realize()
Exemple #16
0
    def __init__(self, parent, toolSwitcher, dialog, vnet_mgr):
        BaseToolbar.__init__(self, parent, toolSwitcher)
        self.vnet_mgr = vnet_mgr
        self.vnet_pts_mgr = self.vnet_mgr.GetPointsManager()

        self.dialog = dialog

        self.InitToolbar(self._toolbarData())
        self.toolSwitcher.AddToolToGroup('mouseUse', self, self.insertPoint)
        
        # realize the toolbar
        self.Realize()
Exemple #17
0
    def __init__(self, parent):
        """Animation toolbar constructor
        """
        BaseToolbar.__init__(self, parent)

        self.InitToolbar(self._toolbarData())

        # realize the toolbar
        self.Realize()

        self.isPlayingForward = True
        self.EnableAnimTools(False)
Exemple #18
0
    def __init__(self, parent, controller, toolSwitcher):
        """RDigit toolbar constructor
        """
        BaseToolbar.__init__(self, parent, toolSwitcher)
        self._controller = controller
        self.InitToolbar(self._toolbarData())

        self._mapSelectionComboId = wx.NewId()
        self._mapSelectionCombo = wx.ComboBox(self, id=self._mapSelectionComboId,
                                              value=_("Select raster map"),
                                              choices=[], size=(120, -1))
        self._mapSelectionCombo.Bind(wx.EVT_COMBOBOX, self.OnMapSelection)
        self._mapSelectionCombo.SetEditable(False)
        self.InsertControl(0, self._mapSelectionCombo)
        self._previousMap = self._mapSelectionCombo.GetValue()

        self._colorId = wx.NewId()
        self._color = csel.ColourSelect(parent=self, colour=wx.GREEN,
                                        size=(30, 30))
        self._color.Bind(csel.EVT_COLOURSELECT, lambda evt: self._changeDrawColor())
        self._color.SetToolTipString(_("Set drawing color (not raster cell color)"))
        self.InsertControl(4, self._color)

        self._cellValues = set(['1'])
        self._valueComboId = wx.NewId()
        # validator does not work with combobox, SetBackgroundColor is not working
        self._valueCombo = wx.ComboBox(self, id=self._valueComboId,
                                       choices=list(self._cellValues), size=(80, -1),
                                       validator=FloatValidator())
        self._valueCombo.Bind(wx.EVT_COMBOBOX, lambda evt: self._cellValueChanged())
        self._valueCombo.Bind(wx.EVT_TEXT, lambda evt: self._cellValueChanged())
        self._valueCombo.SetSelection(0)
        self._cellValueChanged()
        self.InsertControl(6, wx.StaticText(self, label=" %s" % _("Cell value:")))
        self.InsertControl(7, self._valueCombo)

        self._widthValueId = wx.NewId()
        # validator does not work with combobox, SetBackgroundColor is not working
        self._widthValue = wx.TextCtrl(self, id=self._widthValueId, value='0',
                                       size=(80, -1), validator=FloatValidator())
        self._widthValue.Bind(wx.EVT_TEXT, lambda evt: self._widthValueChanged())
        self._widthValueChanged()
        self._widthValue.SetToolTipString(
            _("Width of currently digitized line or diameter of a digitized point in map units."))
        self.InsertControl(8, wx.StaticText(self, label=" %s" % _("Width:")))
        self.InsertControl(9, self._widthValue)

        for tool in (self.area, self.line, self.point):
            self.toolSwitcher.AddToolToGroup(group='mouseUse', toolbar=self, tool=tool)
        self.toolSwitcher.toggleToolChanged.connect(self.CheckSelectedTool)
        self._default = self.area
        # realize the toolbar
        self.Realize()
Exemple #19
0
    def __init__(self, parent):
        self.lmgr = parent

        BaseToolbar.__init__(self, parent)

        # only one dialog can be open
        self.settingsDialog = None

        self.InitToolbar(self._toolbarData())

        # realize the toolbar
        self.Realize()
Exemple #20
0
    def __init__(self, parent, lmgrStyle):
        """Toolbar constructor
        """
        self._style = lmgrStyle
        if lmgrStyle & (SIMPLE_LMGR_TB_LEFT | SIMPLE_LMGR_TB_RIGHT):
            direction = wx.TB_VERTICAL
        else:
            direction = wx.TB_HORIZONTAL
        BaseToolbar.__init__(self, parent, style=wx.NO_BORDER | direction)

        self.InitToolbar(self._getToolbarData(self._toolbarData()))

        # realize the toolbar
        self.Realize()
Exemple #21
0
    def __init__(self, parent, mapManager):
        """IClass toolbar constructor
        """
        BaseToolbar.__init__(self, parent)

        self.InitToolbar(self._toolbarData())
        self.choice = wx.Choice(parent=self, id=wx.ID_ANY, size=(300, -1))

        self.choiceid = self.AddControl(self.choice)

        self.choice.Bind(wx.EVT_CHOICE, self.OnSelectLayer)

        self.mapManager = mapManager
        # realize the toolbar
        self.Realize()
Exemple #22
0
    def __init__(self, parent, toolSwitcher):
        """Map toolbar constructor
        """
        BaseToolbar.__init__(self, parent, toolSwitcher)

        self.InitToolbar(self._toolbarData())
        self._default = self.pan

        # realize the toolbar
        self.Realize()

        for tool in (self.pointer, self.query, self.pan, self.zoomIn, self.zoomOut):
            self.toolSwitcher.AddToolToGroup(group='mouseUse', toolbar=self, tool=tool)

        self.EnableTool(self.zoomBack, False)
Exemple #23
0
 def __init__(self, parent, mapcontent, layerTree = None, log = None):
     self.mapcontent    = mapcontent # Map class instance
     self.layerTree     = layerTree  # reference to layer tree associated to map display
     self.log           = log        # log area
     BaseToolbar.__init__(self, parent)
     self.digit         = None
     
     # currently selected map layer for editing (reference to MapLayer instance)
     self.mapLayer = None
     # list of vector layers from Layer Manager (only in the current mapset)
     self.layers   = [] 
     
     self.comboid    = None
     
     # only one dialog can be open
     self.settingsDialog   = None
     
     # create toolbars (two rows optionally)
     self.InitToolbar(self._toolbarData())
     self.Bind(wx.EVT_TOOL, self.OnTool)
     
     # default action (digitize new point, line, etc.)
     self.action = { 'desc' : '',
                     'type' : '',
                     'id'   : -1 }
     
     # list of available vector maps
     self.UpdateListOfLayers(updateTool = True)
     
     # realize toolbar
     self.Realize()
     # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
     self.combo.Hide()
     self.combo.Show()
     
     # disable undo/redo
     self.EnableTool(self.undo, False)
     ### hide undo - this tool is quite buggy in GRASS 6 
     self.RemoveTool(self.undo) 
     
     # toogle to pointer by default
     self.OnTool(None)
     
     self.FixSize(width = 105)
Exemple #24
0
 def __init__(self, parent):
     """!Toolbar Cartographic Composer (psmap.py)
     
     @param parent parent window
     """
     BaseToolbar.__init__(self, parent)
     
     self.InitToolbar(self._toolbarData())
     
     self.Realize()
     
     self.action = { 'id' : self.pointer }
     self.defaultAction = { 'id' : self.pointer,
                            'bind' : self.parent.OnPointer }
     self.OnTool(None)
     
     from psmap.frame import havePILImage
     if not havePILImage:
         self.EnableTool(self.preview, False)
Exemple #25
0
    def __init__(self, parent):
        """Main toolbar constructor
        """
        BaseToolbar.__init__(self, parent)

        self.InitToolbar(self._toolbarData())
        self.filterId = wx.NewId()
        self.filter = wx.TextCtrl(parent=self, id=self.filterId)
        self.filter.SetSize((120, self.filter.GetBestSize()[1]))
        self.filter.Bind(wx.EVT_TEXT,
                         lambda event: self.parent.Filter(
                         self.filter.GetValue()))
        self.AddControl(wx.StaticText(self, label=_("Search:")))
        self.AddControl(self.filter)
        help = _("Type to search database by map type or name. "
                 "Use prefix 'r:', 'v:' and 'r3:'"
                 "to show only raster, vector or 3D raster data, respectively. "
                 "Use Python regular expressions to refine your search.")
        self.SetToolShortHelp(self.filterId, help)
        # realize the toolbar
        self.Realize()
Exemple #26
0
    def __init__(self, parent):
        """Toolbar constructor
        """
        BaseToolbar.__init__(self, parent)

        self.InitToolbar(self._toolbarData())

        # add tool to toggle active map window
        self.toggleModeId = wx.NewId()
        self.toggleMode = wx.Choice(parent=self, id=self.toggleModeId)
        for label, cdata in zip(
            [_('Swipe mode'), _('Mirror mode')], ['swipe', 'mirror']):
            self.toggleMode.Append(label, cdata)
        self.toggleMode.SetSelection(0)
        self.toggleMode.SetSize(self.toggleMode.GetBestSize())
        self.toggleMode.Bind(
            wx.EVT_CHOICE, lambda event: self.parent.SetViewMode(
                self.toggleMode.GetClientData(event.GetSelection())))
        self.InsertControl(3, self.toggleMode)

        help = _("Choose view mode")
        self.SetToolShortHelp(self.toggleModeId, help)
        # realize the toolbar
        self.Realize()
Exemple #27
0
    def __init__(self, parent, mapcontent):
        """!Map Display constructor

        @param parent reference to MapFrame
        @param mapcontent reference to render.Map (registred by MapFrame)
        """
        self.mapcontent = mapcontent # render.Map
        BaseToolbar.__init__(self, parent = parent) # MapFrame
        
        self.InitToolbar(self._toolbarData())
        
        # optional tools
        choices = [ _('2D view'), ]
        self.toolId = { '2d' : 0 }
        if self.parent.GetLayerManager():
            log = self.parent.GetLayerManager().GetLogWindow()
        
        if haveNviz:
            choices.append(_('3D view'))
            self.toolId['3d'] = 1
        else:
            from nviz.main import errorMsg
            log.WriteCmdLog(_('3D view mode not available'))
            log.WriteWarning(_('Reason: %s') % str(errorMsg))
            log.WriteLog(_('Note that the wxGUI\'s 3D view mode is currently disabled '
                           'on MS Windows (hopefully this will be fixed soon). '
                           'Please keep an eye out for updated versions of GRASS. '
                           'In the meantime you can use "NVIZ" from the File menu.'), wrap = 60)
            
            self.toolId['3d'] = -1

        if haveVDigit:
            choices.append(_('Digitize'))
            if self.toolId['3d'] > -1:
                self.toolId['vdigit'] = 2
            else:
                self.toolId['vdigit'] = 1
        else:
            from vdigit.main import errorMsg
            log.WriteCmdLog(_('Vector digitizer not available'))
            log.WriteWarning(_('Reason: %s') % errorMsg)
            log.WriteLog(_('Note that the wxGUI\'s vector digitizer is currently disabled '
                           '(hopefully this will be fixed soon). '
                           'Please keep an eye out for updated versions of GRASS. '
                           'In the meantime you can use "v.digit" from the Develop Vector menu.'), wrap = 60)
            
            self.toolId['vdigit'] = -1
        
        self.combo = wx.ComboBox(parent = self, id = wx.ID_ANY,
                                 choices = choices,
                                 style = wx.CB_READONLY, size = (110, -1))
        self.combo.SetSelection(0)
        
        self.comboid = self.AddControl(self.combo)
        self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)
        
        # realize the toolbar
        self.Realize()
        
        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
        self.combo.Hide()
        self.combo.Show()
        
        self.action = { 'id' : self.pointer }
        self.defaultAction = { 'id' : self.pointer,
                               'bind' : self.parent.OnPointer }
        
        self.OnTool(None)
        
        self.EnableTool(self.zoomBack, False)
        
        self.FixSize(width = 90)
Exemple #28
0
    def __init__(self, parent, toolSwitcher, MapWindow, digitClass, giface, tools=[]):
        self.MapWindow = MapWindow
        self.Map = MapWindow.GetMap()  # Map class instance
        self.tools = tools
        self.digitClass = digitClass
        BaseToolbar.__init__(self, parent, toolSwitcher)
        self.digit = None
        self._giface = giface
        self.fType = None  # feature type for simple features editing

        self.editingStarted = Signal("VDigitToolbar.editingStarted")
        self.editingStopped = Signal("VDigitToolbar.editingStopped")
        self.editingBgMap = Signal("VDigitToolbar.editingBgMap")
        self.quitDigitizer = Signal("VDigitToolbar.quitDigitizer")
        layerTree = self._giface.GetLayerTree()
        if layerTree:
            self.editingStarted.connect(layerTree.StartEditing)
            self.editingStopped.connect(layerTree.StopEditing)
            self.editingBgMap.connect(layerTree.SetBgMapForEditing)

        # bind events
        self.Bind(wx.EVT_SHOW, self.OnShow)

        # currently selected map layer for editing (reference to MapLayer
        # instance)
        self.mapLayer = None
        # list of vector layers from Layer Manager (only in the current mapset)
        self.layers = []

        self.comboid = self.combo = None
        self.undo = -1
        self.redo = -1

        # only one dialog can be open
        self.settingsDialog = None

        # create toolbars (two rows optionally)
        self.InitToolbar(self._toolbarData())

        self._default = -1
        # default action (digitize new point, line, etc.)
        self.action = {"desc": "", "type": "", "id": -1}
        self._currentAreaActionType = None

        # list of available vector maps
        self.UpdateListOfLayers(updateTool=True)

        for tool in (
            "addPoint",
            "addLine",
            "addBoundary",
            "addCentroid",
            "addArea",
            "addVertex",
            "deleteLine",
            "deleteArea",
            "displayAttr",
            "displayCats",
            "editLine",
            "moveLine",
            "moveVertex",
            "removeVertex",
            "additionalTools",
        ):
            if hasattr(self, tool):
                tool = getattr(self, tool)
                self.toolSwitcher.AddToolToGroup(
                    group="mouseUse", toolbar=self, tool=tool
                )
            else:
                Debug.msg(1, "%s skipped" % tool)

        # custom button for digitization of area/boundary/centroid
        # TODO: could this be somehow generalized?
        nAreaTools = 0
        if self.tools and "addBoundary" in self.tools:
            nAreaTools += 1
        if self.tools and "addCentroid" in self.tools:
            nAreaTools += 1
        if self.tools and "addArea" in self.tools:
            nAreaTools += 1
        if nAreaTools != 1:
            self.areaButton = self.CreateSelectionButton(
                _("Select area/boundary/centroid tool")
            )
            self.areaButtonId = self.InsertControl(5, self.areaButton)
            self.areaButton.Bind(wx.EVT_BUTTON, self.OnAddAreaMenu)

        # realize toolbar
        self.Realize()
        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
        if self.combo:
            self.combo.Hide()
            self.combo.Show()

        # disable undo/redo
        if self.undo > 0:
            self.EnableTool(self.undo, False)
        if self.redo > 0:
            self.EnableTool(self.redo, False)

        self.FixSize(width=105)
Exemple #29
0
    def __init__(self, parent, giface, controller, toolSwitcher):
        """RDigit toolbar constructor
        """
        BaseToolbar.__init__(self, parent, toolSwitcher)
        self._controller = controller
        self._giface = giface
        self.InitToolbar(self._toolbarData())

        self._mapSelectionComboId = wx.NewId()
        self._mapSelectionCombo = wx.ComboBox(self,
                                              id=self._mapSelectionComboId,
                                              value=_("Select raster map"),
                                              choices=[],
                                              size=(120, -1))
        self._mapSelectionCombo.Bind(wx.EVT_COMBOBOX, self.OnMapSelection)
        self._mapSelectionCombo.SetEditable(False)
        self.InsertControl(0, self._mapSelectionCombo)
        self._previousMap = self._mapSelectionCombo.GetValue()

        self._colorId = wx.NewId()
        self._color = csel.ColourSelect(parent=self,
                                        colour=wx.GREEN,
                                        size=(30, 30))
        self._color.Bind(csel.EVT_COLOURSELECT,
                         lambda evt: self._changeDrawColor())
        self._color.SetToolTipString(
            _("Set drawing color (not raster cell color)"))
        self.InsertControl(4, self._color)

        self._cellValues = set(['1'])
        self._valueComboId = wx.NewId()
        # validator does not work with combobox, SetBackgroundColor is not
        # working
        self._valueCombo = wx.ComboBox(self,
                                       id=self._valueComboId,
                                       choices=list(self._cellValues),
                                       size=(80, -1),
                                       validator=FloatValidator())
        self._valueCombo.Bind(wx.EVT_COMBOBOX,
                              lambda evt: self._cellValueChanged())
        self._valueCombo.Bind(wx.EVT_TEXT,
                              lambda evt: self._cellValueChanged())
        self._valueCombo.SetSelection(0)
        self._cellValueChanged()
        self.InsertControl(6,
                           wx.StaticText(self, label=" %s" % _("Cell value:")))
        self.InsertControl(7, self._valueCombo)

        self._widthValueId = wx.NewId()
        # validator does not work with combobox, SetBackgroundColor is not
        # working
        self._widthValue = wx.TextCtrl(self,
                                       id=self._widthValueId,
                                       value='0',
                                       size=(80, -1),
                                       validator=FloatValidator())
        self._widthValue.Bind(wx.EVT_TEXT,
                              lambda evt: self._widthValueChanged())
        self._widthValueChanged()
        self._widthValue.SetToolTipString(
            _("Width of currently digitized line or diameter of a digitized point in map units."
              ))
        self.InsertControl(8, wx.StaticText(self, label=" %s" % _("Width:")))
        self.InsertControl(9, self._widthValue)

        for tool in (self.area, self.line, self.point):
            self.toolSwitcher.AddToolToGroup(group='mouseUse',
                                             toolbar=self,
                                             tool=tool)
        self.toolSwitcher.toggleToolChanged.connect(self.CheckSelectedTool)
        self._default = self.area
        # realize the toolbar
        self.Realize()
Exemple #30
0
    def __init__(self, parent, toolSwitcher):
        """Map Display constructor

        :param parent: reference to MapFrame
        """
        BaseToolbar.__init__(self, parent=parent, toolSwitcher=toolSwitcher) # MapFrame
        
        self.InitToolbar(self._toolbarData())
        self._default = self.pointer
        
        # optional tools
        toolNum = 0
        choices = [ _('2D view'), ]
        self.toolId = { '2d' : toolNum }
        toolNum += 1
        if self.parent.GetLayerManager():
            log = self.parent.GetLayerManager().GetLogWindow()
        
        if haveNviz:
            choices.append(_('3D view'))
            self.toolId['3d'] = toolNum
            toolNum += 1
        else:
            from nviz.main import errorMsg
            if self.parent.GetLayerManager():
                log.WriteCmdLog(_('3D view mode not available'))
                log.WriteWarning(_('Reason: %s') % str(errorMsg))
            
            self.toolId['3d'] = -1

        if haveVDigit:
            choices.append(_("Vector digitizer"))
            self.toolId['vdigit'] = toolNum
            toolNum += 1
        else:
            from vdigit.main import errorMsg
            if self.parent.GetLayerManager():
              log.WriteCmdLog(_('Vector digitizer not available'))
              log.WriteWarning(_('Reason: %s') % errorMsg)
              log.WriteLog(_('Note that the wxGUI\'s vector digitizer is currently disabled '
                             '(hopefully this will be fixed soon). '
                             'Please keep an eye out for updated versions of GRASS. '
                             'In the meantime you can use "v.digit" from the Develop Vector menu.'), wrap = 60)
            
            self.toolId['vdigit'] = -1
        choices.append(_("Raster digitizer"))
        self.toolId['rdigit'] = toolNum

        self.combo = wx.ComboBox(parent = self, id = wx.ID_ANY,
                                 choices = choices,
                                 style = wx.CB_READONLY, size = (110, -1))
        self.combo.SetSelection(0)
        
        self.comboid = self.AddControl(self.combo)
        self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)
        
        # realize the toolbar
        self.Realize()
        
        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
        self.combo.Hide()
        self.combo.Show()
        
        for tool in (self.pointer, self.select, self.query, self.pan, self.zoomIn, self.zoomOut):
            self.toolSwitcher.AddToolToGroup(group='mouseUse', toolbar=self, tool=tool)
        
        self.EnableTool(self.zoomBack, False)
        
        self.FixSize(width = 90)
Exemple #31
0
    def __init__(self, parent, toolSwitcher, MapWindow, digitClass, giface,
                 tools=[]):
        self.MapWindow = MapWindow
        self.Map = MapWindow.GetMap()  # Map class instance
        self.tools = tools
        self.digitClass = digitClass
        BaseToolbar.__init__(self, parent, toolSwitcher)
        self.digit = None
        self._giface = giface
        self.fType = None     # feature type for simple features editing

        self.editingStarted = Signal("VDigitToolbar.editingStarted")
        self.editingStopped = Signal("VDigitToolbar.editingStopped")
        self.editingBgMap = Signal("VDigitToolbar.editingBgMap")
        layerTree = self._giface.GetLayerTree()
        if layerTree:
            self.editingStarted.connect(layerTree.StartEditing)
            self.editingStopped.connect(layerTree.StopEditing)
            self.editingBgMap.connect(layerTree.SetBgMapForEditing)

        # currently selected map layer for editing (reference to MapLayer
        # instance)
        self.mapLayer = None
        # list of vector layers from Layer Manager (only in the current mapset)
        self.layers = []

        self.comboid = self.combo = None
        self.undo = -1
        self.redo = -1

        # only one dialog can be open
        self.settingsDialog = None

        # create toolbars (two rows optionally)
        self.InitToolbar(self._toolbarData())

        self._default = -1
        # default action (digitize new point, line, etc.)
        self.action = {'desc': '',
                       'type': '',
                       'id': -1}
        self._currentAreaActionType = None

        # list of available vector maps
        self.UpdateListOfLayers(updateTool=True)

        for tool in (
                'addPoint', 'addLine', 'addBoundary', 'addCentroid', 'addArea',
                'addVertex', 'deleteLine', 'deleteArea', 'displayAttr',
                'displayCats', 'editLine', 'moveLine', 'moveVertex',
                'removeVertex', 'additionalTools'):
            if hasattr(self, tool):
                tool = getattr(self, tool)
                self.toolSwitcher.AddToolToGroup(
                    group='mouseUse', toolbar=self, tool=tool)
            else:
                Debug.msg(1, '%s skipped' % tool)

        # custom button for digitization of area/boundary/centroid
        # TODO: could this be somehow generalized?
        nAreaTools = 0
        if self.tools and 'addBoundary' in self.tools:
            nAreaTools += 1
        if self.tools and 'addCentroid' in self.tools:
            nAreaTools += 1
        if self.tools and 'addArea' in self.tools:
            nAreaTools += 1
        if nAreaTools != 1:
            self.areaButton = self.CreateSelectionButton(
                _("Select area/boundary/centroid tool"))
            self.areaButtonId = self.InsertControl(5, self.areaButton)
            self.areaButton.Bind(wx.EVT_BUTTON, self.OnAddAreaMenu)

        # realize toolbar
        self.Realize()
        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
        if self.combo:
            self.combo.Hide()
            self.combo.Show()

        # disable undo/redo
        if self.undo > 0:
            self.EnableTool(self.undo, False)
        if self.redo > 0:
            self.EnableTool(self.redo, False)

        self.FixSize(width=105)
Exemple #32
0
    def __init__(self,
                 parent,
                 MapWindow,
                 digitClass,
                 tools=[],
                 layerTree=None,
                 log=None):
        self.MapWindow = MapWindow
        self.Map = MapWindow.GetMap()  # Map class instance
        self.layerTree = layerTree  # reference to layer tree associated to map display
        self.log = log  # log area
        self.tools = tools
        self.digitClass = digitClass
        BaseToolbar.__init__(self, parent)
        self.digit = None

        # currently selected map layer for editing (reference to MapLayer instance)
        self.mapLayer = None
        self.mapName = None

        self.comboid = self.combo = None
        self.undo = -1
        self.redo = -1

        # only one dialog can be open
        self.settingsDialog = None

        # create toolbars (two rows optionally)
        self.InitToolbar(self._toolbarData())
        self.Bind(wx.EVT_TOOL, self._toolChosen)

        # default action (digitize new point, line, etc.)
        self.action = {"desc": "", "type": "", "id": -1}

        # list of available raster maps
        self.UpdateListOfLayers(updateTool=True)

        self.layerNameList = []
        layers = self.Map.GetListOfLayers(l_type="raster",
                                          l_mapset=grass.gisenv()["MAPSET"])

        for layer in layers:
            if layer.name not in self.layerNameList:  # do not duplicate layer
                self.layerNameList.append(layer.GetName())

        # realize toolbar
        self.Realize()
        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
        if self.combo:
            self.combo.Hide()
            self.combo.Show()

        # disable undo/redo
        if self.undo > 0:
            self.EnableTool(self.undo, False)
        if self.redo > 0:
            self.EnableTool(self.redo, False)

        # toogle to pointer by default
        self.OnTool(None)

        self.FixSize(width=105)
Exemple #33
0
    def __init__(self, parent, mapcontent):
        """!Map Display constructor

        @param parent reference to MapFrame
        @param mapcontent reference to render.Map (registred by MapFrame)
        """
        self.mapcontent = mapcontent  # render.Map
        BaseToolbar.__init__(self, parent=parent)  # MapFrame

        self.InitToolbar(self._toolbarData())

        # optional tools
        choices = [
            _('2D view'),
        ]
        self.toolId = {'2d': 0}
        if self.parent.GetLayerManager():
            log = self.parent.GetLayerManager().GetLogWindow()

        if haveNviz:
            choices.append(_('3D view'))
            self.toolId['3d'] = 1
        else:
            from nviz.main import errorMsg
            log.WriteCmdLog(_('3D view mode not available'))
            log.WriteWarning(_('Reason: %s') % str(errorMsg))
            log.WriteLog(_(
                'Note that the wxGUI\'s 3D view mode is currently disabled '
                'on MS Windows (hopefully this will be fixed soon). '
                'Please keep an eye out for updated versions of GRASS. '
                'In the meantime you can use "NVIZ" from the File menu.'),
                         wrap=60)

            self.toolId['3d'] = -1

        if haveVDigit:
            choices.append(_('Digitize'))
            if self.toolId['3d'] > -1:
                self.toolId['vdigit'] = 2
            else:
                self.toolId['vdigit'] = 1
        else:
            from vdigit.main import errorMsg
            log.WriteCmdLog(_('Vector digitizer not available'))
            log.WriteWarning(_('Reason: %s') % errorMsg)
            log.WriteLog(_(
                'Note that the wxGUI\'s vector digitizer is currently disabled '
                '(hopefully this will be fixed soon). '
                'Please keep an eye out for updated versions of GRASS. '
                'In the meantime you can use "v.digit" from the Develop Vector menu.'
            ),
                         wrap=60)

            self.toolId['vdigit'] = -1

        self.combo = wx.ComboBox(parent=self,
                                 id=wx.ID_ANY,
                                 choices=choices,
                                 style=wx.CB_READONLY,
                                 size=(110, -1))
        self.combo.SetSelection(0)

        self.comboid = self.AddControl(self.combo)
        self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)

        # realize the toolbar
        self.Realize()

        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
        self.combo.Hide()
        self.combo.Show()

        self.action = {'id': self.pointer}
        self.defaultAction = {
            'id': self.pointer,
            'bind': self.parent.OnPointer
        }

        self.OnTool(None)

        self.EnableTool(self.zoomBack, False)

        self.FixSize(width=90)
Exemple #34
0
    def __init__(self, parent, toolSwitcher, giface):
        """Map Display constructor

        :param parent: reference to MapFrame
        """
        BaseToolbar.__init__(self, parent=parent, toolSwitcher=toolSwitcher)  # MapFrame

        self.InitToolbar(self._toolbarData())
        self._default = self.pointer
        self._giface = giface

        # optional tools
        toolNum = 0
        choices = [
            _("2D view"),
        ]
        self.toolId = {"2d": toolNum}
        toolNum += 1
        if haveNviz:
            choices.append(_("3D view"))
            self.toolId["3d"] = toolNum
            toolNum += 1
        else:
            from nviz.main import errorMsg

            self._giface.WriteCmdLog(_("3D view mode not available"))
            self._giface.WriteWarning(_("Reason: %s") % str(errorMsg))

            self.toolId["3d"] = -1

        if haveVDigit:
            choices.append(_("Vector digitizer"))
            self.toolId["vdigit"] = toolNum
            toolNum += 1
        else:
            from vdigit.main import errorMsg

            self._giface.WriteCmdLog(_("Vector digitizer not available"))
            self._giface.WriteWarning(_("Reason: %s") % errorMsg)
            self._giface.WriteLog(
                _(
                    "Note that the wxGUI's vector digitizer is disabled in this installation. "
                    "Please keep an eye out for updated versions of GRASS. "
                    'In the meantime you can use "v.edit" for non-interactive editing '
                    "from the Develop vector map menu."
                ),
                wrap=60,
            )

            self.toolId["vdigit"] = -1
        choices.append(_("Raster digitizer"))
        self.toolId["rdigit"] = toolNum

        self.combo = wx.ComboBox(
            parent=self,
            id=wx.ID_ANY,
            choices=choices,
            style=wx.CB_READONLY,
            size=(110, -1),
        )
        self.combo.SetSelection(0)

        self.comboid = self.AddControl(self.combo)
        self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)

        # realize the toolbar
        self.Realize()

        # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
        self.combo.Hide()
        self.combo.Show()

        for tool in (
            self.pointer,
            self.select,
            self.query,
            self.pan,
            self.zoomIn,
            self.zoomOut,
        ):
            self.toolSwitcher.AddToolToGroup(group="mouseUse", toolbar=self, tool=tool)

        self.EnableTool(self.zoomBack, False)

        self.FixSize(width=90)