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