1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
"""!
@package psmap.toolbars
@brief wxPsMap toolbars classes
Classes:
- toolbars::PsMapToolbar
(C) 2007-2011 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@author Anna Kratochvilova <kratochanna gmail.com>
"""
import os
import sys
import wx
from core import globalvar
from gui_core.toolbars import BaseToolbar, BaseIcons
from icons.icon import MetaIcon
class PsMapToolbar(BaseToolbar):
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)
def _toolbarData(self):
"""!Toolbar data
"""
icons = {
'scriptSave' : MetaIcon(img = 'script-save',
label = _('Generate text file with mapping instructions')),
'scriptLoad' : MetaIcon(img = 'script-load',
label = _('Load text file with mapping instructions')),
'psExport' : MetaIcon(img = 'ps-export',
label = _('Generate PostScript output')),
'pdfExport' : MetaIcon(img = 'pdf-export',
label = _('Generate PDF output')),
'pageSetup' : MetaIcon(img = 'page-settings',
label = _('Page setup'),
desc = _('Specify paper size, margins and orientation')),
'fullExtent' : MetaIcon(img = 'zoom-extent',
label = _("Full extent"),
desc = _("Zoom to full extent")),
'addMap' : MetaIcon(img = 'layer-add',
label = _("Map frame"),
desc = _("Click and drag to place map frame")),
'deleteObj' : MetaIcon(img = 'layer-remove',
label = _("Delete selected object")),
'preview' : MetaIcon(img = 'execute',
label = _("Show preview")),
'quit' : MetaIcon(img = 'quit',
label = _('Quit Cartographic Composer')),
'addText' : MetaIcon(img = 'text-add',
label = _('Text')),
'addMapinfo' : MetaIcon(img = 'map-info',
label = _('Map info')),
'addLegend' : MetaIcon(img = 'legend-add',
label = _('Legend')),
'addScalebar' : MetaIcon(img = 'scalebar-add',
label = _('Scale bar')),
'addImage' : MetaIcon(img = 'image-add',
label = _('Image')),
'addNorthArrow': MetaIcon(img = 'north-arrow-add',
label = _('North Arrow')),
'drawGraphics': MetaIcon(img = 'edit',
label = _('Add simple graphics')),
'pointAdd' : MetaIcon(img = 'point-add',
label = _('Point')),
'lineAdd' : MetaIcon(img = 'line-add',
label = _('Line')),
'rectangleAdd': MetaIcon(img = 'rectangle-add',
label = _('Rectangle')),
}
self.icons = icons
return self._getToolbarData((('loadFile', icons['scriptLoad'],
self.parent.OnLoadFile),
('instructionFile', icons['scriptSave'],
self.parent.OnInstructionFile),
(None, ),
('pagesetup', icons['pageSetup'],
self.parent.OnPageSetup),
(None, ),
("pointer", BaseIcons["pointer"],
self.parent.OnPointer, wx.ITEM_CHECK),
('pan', BaseIcons['pan'],
self.parent.OnPan, wx.ITEM_CHECK),
("zoomin", BaseIcons["zoomIn"],
self.parent.OnZoomIn, wx.ITEM_CHECK),
("zoomout", BaseIcons["zoomOut"],
self.parent.OnZoomOut, wx.ITEM_CHECK),
('zoomAll', icons['fullExtent'],
self.parent.OnZoomAll),
(None, ),
('addMap', icons['addMap'],
self.parent.OnAddMap, wx.ITEM_CHECK),
('addRaster', BaseIcons['addRast'],
self.parent.OnAddRaster),
('addVector', BaseIcons['addVect'],
self.parent.OnAddVect),
("dec", BaseIcons["overlay"],
self.OnDecoration),
("drawGraphics", icons["drawGraphics"],
self.OnDrawGraphics, wx.ITEM_CHECK),
("delete", icons["deleteObj"],
self.parent.OnDelete),
(None, ),
("preview", icons["preview"],
self.parent.OnPreview),
('generatePS', icons['psExport'],
self.parent.OnPSFile),
('generatePDF', icons['pdfExport'],
self.parent.OnPDFFile),
(None, ),
("help", BaseIcons['help'],
self.parent.OnHelp),
('quit', icons['quit'],
self.parent.OnCloseWindow))
)
def OnDecoration(self, event):
"""!Decorations overlay menu
"""
self._onMenu(((self.icons["addLegend"], self.parent.OnAddLegend),
(self.icons["addMapinfo"], self.parent.OnAddMapinfo),
(self.icons["addScalebar"], self.parent.OnAddScalebar),
(self.icons["addText"], self.parent.OnAddText),
(self.icons["addImage"], self.parent.OnAddImage),
(self.icons["addNorthArrow"], self.parent.OnAddNorthArrow)))
def OnDrawGraphics(self, event):
"""!Simple geometry features (point, line, rectangle) overlay menu
"""
# we need the previous id
self.actionOld = self.action['id']
self.OnTool(event)
self.action['id'] = self.actionOld
self._onMenu(((self.icons["pointAdd"], self.parent.OnAddPoint),
(self.icons["lineAdd"], self.parent.OnAddLine),
(self.icons["rectangleAdd"], self.parent.OnAddRectangle),
))
|