4 @brief GIS map display canvas, with toolbar for various display
5 management functions, and additional toolbars (vector digitizer, 3d
8 Can be used either from Layer Manager or as p.mon backend.
15 python mapdisp.py monitor-identifier /path/to/command/file
17 (C) 2006-2011 by the GRASS Development Team
18 This program is free software under the GNU General Public
19 License (>=v2). Read the file COPYING that comes with GRASS
22 @author Michael Barton
23 @author Jachym Cepicky
24 @author Martin Landa <landa.martin gmail.com>
41 CompatPath = os.path.join(globalvar.ETCWXDIR)
42 sys.path.append(CompatPath)
43 from compat
import subprocess
45 gmpath = os.path.join(globalvar.ETCWXDIR,
"icons")
46 sys.path.append(gmpath)
48 grassPath = os.path.join(globalvar.ETCDIR,
"python")
49 sys.path.append(grassPath)
65 from debug
import Debug
66 from icon
import Icons
67 from preferences
import globalSettings
as UserSettings
69 from mapdisp_command
import Command
70 from mapdisp_window
import BufferedWindow
78 """!Main frame for map display window. Drawing takes place in
79 child double buffered drawing window.
81 def __init__(self, parent = None, id = wx.ID_ANY, title = _(
"GRASS GIS - Map display"),
82 style = wx.DEFAULT_FRAME_STYLE, toolbars = [
"map"],
83 tree =
None, notebook =
None, lmgr =
None, page =
None,
84 Map =
None, auimgr =
None, **kwargs):
85 """!Main map display window with toolbars, statusbar and
88 @param toolbars array of activated toolbars, e.g. ['map', 'digit']
89 @param tree reference to layer tree
90 @param notebook control book ID in Layer Manager
91 @param lmgr Layer Manager
92 @param page notebook page with layer tree
93 @param Map instance of render.Map
94 @param auimgs AUI manager
95 @param kwargs wx.Frame attribures
104 if 'name' not in kwargs:
105 kwargs[
'name'] =
'MapWindow'
106 wx.Frame.__init__(self, parent, id, title, style = style, **kwargs)
112 "default" : wx.StockCursor(wx.CURSOR_ARROW),
113 "cross" : wx.StockCursor(wx.CURSOR_CROSS),
114 "hand" : wx.StockCursor(wx.CURSOR_HAND),
115 "pencil" : wx.StockCursor(wx.CURSOR_PENCIL),
116 "sizenwse": wx.StockCursor(wx.CURSOR_SIZENWSE)
122 self.SetClientSize(self.GetSize())
125 self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR,
'grass_map.ico'), wx.BITMAP_TYPE_ICO))
130 self.
_mgr = wx.aui.AuiManager(self)
140 for toolb
in toolbars:
146 self.
statusbar = self.CreateStatusBar(number = 4, style = 0)
147 self.statusbar.SetStatusWidths([-5, -2, -1, -1])
150 choices = globalvar.MAP_DISPLAY_STATUSBAR_MODE)
151 self.
statusbarWin[
'toggle'].SetSelection(UserSettings.Get(group =
'display',
152 key =
'statusbarMode',
153 subkey =
'selection'))
159 self.
statusbarWin[
'render'].SetValue(UserSettings.Get(group =
'display',
160 key =
'autoRendering',
162 self.
statusbarWin[
'render'].SetToolTip(wx.ToolTip (_(
"Enable/disable auto-rendering")))
165 label = _(
"Show computational extent"))
170 self.
statusbarWin[
'region'].SetToolTip(wx.ToolTip (_(
"Show/hide computational "
171 "region extent (set with g.region). "
172 "Display region drawn as a blue box inside the "
173 "computational region, "
174 "computational region inside a display region "
178 label = _(
"Constrain display resolution to computational settings"))
180 self.
statusbarWin[
'resolution'].SetValue(UserSettings.Get(group =
'display', key =
'compResolution', subkey =
'enabled'))
182 self.
statusbarWin[
'resolution'].SetToolTip(wx.ToolTip (_(
"Constrain display resolution "
183 "to computational region settings. "
184 "Default value for new map displays can "
185 "be set up in 'User GUI settings' dialog.")))
188 style = wx.TE_PROCESS_ENTER,
203 value =
"", style = wx.TE_PROCESS_ENTER,
210 label = _(
"Use defined projection"))
213 self.
statusbarWin[
'projection'].SetMinSize((size[0] + 150, size[1]))
214 self.
statusbarWin[
'projection'].SetToolTip(wx.ToolTip (_(
"Reproject coordinates displayed "
215 "in the statusbar. Projection can be "
216 "defined in GUI preferences dialog "
223 self.
statusbarWin[
'mask'].SetForegroundColour(wx.Colour(255, 0, 0))
227 range = 0, style = wx.GA_HORIZONTAL)
239 self.MapWindow.SetCursor(self.
cursors[
"default"])
253 self.Bind(wx.EVT_ACTIVATE, self.
OnFocus)
260 self._mgr.AddPane(self.
MapWindow, wx.aui.AuiPaneInfo().CentrePane().
261 Dockable(
False).BestSize((-1,-1)).
262 CloseButton(
False).DestroyOnClose(
True).
274 self.MapWindow.ZoomHistory(self.Map.region[
'n'],
275 self.Map.region[
's'],
276 self.Map.region[
'e'],
277 self.Map.region[
'w'])
283 self.
dialogs[
'attributes'] =
None
284 self.
dialogs[
'category'] =
None
285 self.
dialogs[
'barscale'] =
None
290 def _addToolbarVDigit(self):
291 """!Add vector digitizer toolbar
293 from vdigit
import haveVDigit
296 from vdigit
import errorMsg
297 msg = _(
"Unable to start wxGUI vector digitizer.\nDo you want to start "
298 "TCL/TK digitizer (v.digit) instead?\n\n"
299 "Details: %s" % errorMsg)
301 self.
toolbars[
'map'].combo.SetValue(_(
"2D view"))
302 dlg = wx.MessageDialog(parent = self,
304 caption=_(
"Vector digitizer failed"),
305 style = wx.YES_NO | wx.CENTRE)
306 if dlg.ShowModal() == wx.ID_YES:
307 mapName = self.tree.GetPyData(self.tree.layer_selected)[0][
'maplayer'].GetName()
308 self._layerManager.goutput.RunCmd([
'v.digit',
'map=%s' % mapName],
312 self.
toolbars[
'map'].combo.SetValue(_(
"2D view"))
316 log = self._layerManager.goutput
321 from mapdisp_vdigit
import VDigitWindow
323 Map = self.
Map, tree = self.
tree,
325 self.MapWindowVDigit.Show()
330 self.MapWindow2D.Hide()
333 layerTree = self.
tree,
335 self.MapWindowVDigit.SetToolbar(self.
toolbars[
'vdigit'])
337 self._mgr.AddPane(self.
MapWindowVDigit, wx.aui.AuiPaneInfo().CentrePane().
338 Dockable(
False).BestSize((-1,-1)).
339 CloseButton(
False).DestroyOnClose(
True).
341 self._mgr.AddPane(self.
toolbars[
'vdigit'],
342 wx.aui.AuiPaneInfo().
343 Name(
"vdigittoolbar").Caption(_(
"Vector Digitizer Toolbar")).
344 ToolbarPane().Top().Row(1).
345 LeftDockable(
False).RightDockable(
False).
346 BottomDockable(
False).TopDockable(
True).
347 CloseButton(
False).Layer(2).
348 BestSize((self.
toolbars[
'vdigit'].GetBestSize())))
350 self.MapWindow.mouse[
'box'] =
"point"
351 self.MapWindow.zoomtype = 0
352 self.MapWindow.pen = wx.Pen(colour =
'red', width = 2, style = wx.SOLID)
353 self.MapWindow.polypen = wx.Pen(colour =
'green', width = 2, style = wx.SOLID)
355 def _addToolbarNviz(self):
356 """!Add 3D view mode toolbar
361 if not nviz.haveNviz:
362 self.
toolbars[
'map'].combo.SetValue (_(
"2D view"))
364 message = _(
"Unable to switch to 3D display mode.\nThe Nviz python extension "
365 "was not found or loaded properly.\n"
366 "Switching back to 2D display mode.\n\nDetails: %s" % nviz.errorMsg))
371 self.
toolbars[
'map'].Enable2D(
False)
377 self.MapWindow.EraseMap()
379 self._layerManager.goutput.WriteCmdLog(_(
"Starting 3D view mode..."))
380 self.statusbar.SetStatusText(_(
"Please wait, loading data..."), 0)
384 self.
MapWindow3D = nviz.GLWindow(self, id = wx.ID_ANY,
387 self.MapWindow.SetCursor(self.
cursors[
"default"])
390 self._layerManager.AddNviz()
392 self.MapWindow3D.OnPaint(
None)
393 self.MapWindow3D.Show()
394 self.MapWindow3D.UpdateView(
None)
398 self._layerManager.AddNviz()
399 self._layerManager.nviz.UpdatePage(
'view')
400 self._layerManager.nviz.UpdatePage(
'light')
405 self.MapWindow2D.Hide()
406 self._mgr.AddPane(self.
MapWindow3D, wx.aui.AuiPaneInfo().CentrePane().
407 Dockable(
False).BestSize((-1,-1)).
408 CloseButton(
False).DestroyOnClose(
True).
410 self._mgr.AddPane(self.
toolbars[
'nviz'],
411 wx.aui.AuiPaneInfo().
412 Name(
"nviztoolbar").Caption(_(
"3D View Toolbar")).
413 ToolbarPane().Top().Row(1).
414 LeftDockable(
False).RightDockable(
False).
415 BottomDockable(
False).TopDockable(
True).
416 CloseButton(
False).Layer(2).
417 BestSize((self.
toolbars[
'nviz'].GetBestSize())))
419 self.SetStatusText(
"", 0)
422 """!Add defined toolbar to the window
424 Currently known toolbars are:
425 - 'map' - basic map toolbar
426 - 'vdigit' - vector digitizer
427 - 'gcpdisp' - GCP Manager Display
428 - 'georect' - georectifier
429 - 'nviz' - 3D view mode
435 self._mgr.AddPane(self.
toolbars[
'map'],
436 wx.aui.AuiPaneInfo().
437 Name(
"maptoolbar").Caption(_(
"Map Toolbar")).
439 LeftDockable(
False).RightDockable(
False).
440 BottomDockable(
False).TopDockable(
True).
441 CloseButton(
False).Layer(2).
442 BestSize((self.
toolbars[
'map'].GetBestSize())))
445 elif name ==
"vdigit":
448 elif name ==
"georect":
449 self.
toolbars[
'georect'] = toolbars.GRToolbar(self, self.
Map)
451 self._mgr.AddPane(self.
toolbars[
'georect'],
452 wx.aui.AuiPaneInfo().
453 Name(
"georecttoolbar").Caption(_(
"Georectification Toolbar")).
455 LeftDockable(
False).RightDockable(
False).
456 BottomDockable(
False).TopDockable(
True).
457 CloseButton(
False).Layer(2).
458 BestSize((self.
toolbars[
'georect'].GetBestSize())))
466 """!Removes defined toolbar from the window
468 @todo Only hide, activate by calling AddToolbar()
474 self._mgr.DetachPane(self.
toolbars[name])
480 self.MapWindowVDigit.Hide()
481 self.MapWindow2D.Show()
482 self._mgr.AddPane(self.
MapWindow2D, wx.aui.AuiPaneInfo().CentrePane().
483 Dockable(
False).BestSize((-1,-1)).
484 CloseButton(
False).DestroyOnClose(
True).
493 self.MapWindow3D.Hide()
494 self.MapWindow2D.Show()
495 self._mgr.AddPane(self.
MapWindow2D, wx.aui.AuiPaneInfo().CentrePane().
496 Dockable(
False).BestSize((-1,-1)).
497 CloseButton(
False).DestroyOnClose(
True).
501 self._layerManager.RemoveNviz()
503 self.MapWindow.UpdateMap()
505 self.
toolbars[
'map'].combo.SetValue(_(
"2D view"))
511 def _initDisplay(self):
512 """!Initialize map display, set dimensions and map region
514 if not grass.find_program(
'g.region', [
'--help']):
515 sys.exit(_(
"GRASS module '%s' not found. Unable to start map "
516 "display window.") %
'g.region')
518 self.width, self.
height = self.GetClientSize()
520 Debug.msg(2,
"MapFrame._initDisplay():")
521 self.Map.ChangeMapSize(self.GetClientSize())
522 self.Map.region = self.Map.GetRegion()
526 """!Update progress bar info
534 Change choicebook page to match display.
535 Or set display for georectifying
538 self._layerManager.georectifying:
545 pgnum = self.layerbook.GetPageIndex(self.
page)
547 self.layerbook.SetSelection(pgnum)
552 """!Re-display current map composition
554 self.MapWindow.UpdateMap(render =
False)
557 """!Re-render map composition (each map layer)
560 qlayer = self.Map.GetListOfLayers(l_name = globalvar.QUERYLAYER)
562 self.Map.DeleteLayer(layer)
565 if self.MapWindow.mouse[
"use"]
in (
"measure",
567 self.MapWindow.polycoords = []
568 self.MapWindow.ClearLines()
572 if self.MapWindow.digit:
573 self.MapWindow.digit.GetDisplay().SetSelected([])
574 self.MapWindow.UpdateMap(render =
True, renderVector =
True)
576 self.MapWindow.UpdateMap(render =
True)
582 """!Pointer button clicked
587 self.
toolbars[
'map'].action[
'desc'] =
''
589 self.MapWindow.mouse[
'use'] =
"pointer"
590 self.MapWindow.mouse[
'box'] =
"point"
595 self.MapWindow.SetCursor(self.
cursors[
"cross"])
598 if self.
toolbars[
'vdigit'].GetAction()
in [
'addLine']:
599 if self.
toolbars[
'vdigit'].GetAction(
'type')
in [
'point',
'centroid']:
600 self.MapWindow.mouse[
'box'] =
'point'
602 self.MapWindow.mouse[
'box'] =
'line'
603 elif self.
toolbars[
'vdigit'].GetAction()
in [
'addVertex',
'removeVertex',
'splitLine',
604 'editLine',
'displayCats',
'queryMap',
606 self.MapWindow.mouse[
'box'] =
'point'
608 self.MapWindow.mouse[
'box'] =
'box'
610 elif self.
_layerManager and self._layerManager.georectifying:
611 self.MapWindow.SetCursor(self.
cursors[
"cross"])
614 self.MapWindow.SetCursor(self.
cursors[
"default"])
619 Set mouse cursor, zoombox attributes, and zoom direction
623 self.
toolbars[
'map'].action[
'desc'] =
''
625 self.MapWindow.mouse[
'use'] =
"zoom"
626 self.MapWindow.mouse[
'box'] =
"box"
627 self.MapWindow.zoomtype = 1
628 self.MapWindow.pen = wx.Pen(colour =
'Red', width = 2, style = wx.SHORT_DASH)
631 self.MapWindow.SetCursor(self.
cursors[
"cross"])
636 Set mouse cursor, zoombox attributes, and zoom direction
640 self.
toolbars[
'map'].action[
'desc'] =
''
642 self.MapWindow.mouse[
'use'] =
"zoom"
643 self.MapWindow.mouse[
'box'] =
"box"
644 self.MapWindow.zoomtype = -1
645 self.MapWindow.pen = wx.Pen(colour =
'Red', width = 2, style = wx.SHORT_DASH)
648 self.MapWindow.SetCursor(self.
cursors[
"cross"])
652 Zoom last (previously stored position)
654 self.MapWindow.ZoomBack()
658 Panning, set mouse to drag
662 self.
toolbars[
'map'].action[
'desc'] =
''
664 self.MapWindow.mouse[
'use'] =
"pan"
665 self.MapWindow.mouse[
'box'] =
"pan"
666 self.MapWindow.zoomtype = 0
669 self.MapWindow.SetCursor(self.
cursors[
"hand"])
675 self.MapWindow.EraseMap()
682 self.Map.getResolution()
690 if not self.Map.alignRegion:
691 self.Map.alignRegion =
True
693 self.Map.alignRegion =
False
697 """!Enable/disable auto-rendering
703 """!Check if auto-rendering is enabled"""
707 """!Show/Hide extent in map canvas
711 self.MapWindow.regionCoords = []
713 del self.MapWindow.regionCoords
721 Use resolution of computation region settings
722 for redering image instead of display resolution
736 Map scale changed by user
738 scale = event.GetString()
741 if scale[:2] !=
'1:':
743 value = int(scale[2:])
748 dEW = value * (self.Map.region[
'cols'] / self.
ppm[0])
749 dNS = value * (self.Map.region[
'rows'] / self.
ppm[1])
750 self.Map.region[
'n'] = self.Map.region[
'center_northing'] + dNS / 2.
751 self.Map.region[
's'] = self.Map.region[
'center_northing'] - dNS / 2.
752 self.Map.region[
'w'] = self.Map.region[
'center_easting'] - dEW / 2.
753 self.Map.region[
'e'] = self.Map.region[
'center_easting'] + dEW / 2.
756 self.MapWindow.ZoomHistory(self.Map.region[
'n'], self.Map.region[
's'],
757 self.Map.region[
'e'], self.Map.region[
'w'])
760 self.MapWindow.UpdateMap()
769 if not UserSettings.Get(group =
'projection', key =
'statusbar', subkey =
'proj4'):
770 self.statusbar.SetStatusText(_(
"Projection not defined (check the settings)"), 0)
773 projIn = UserSettings.Get(group =
'projection',
776 projOut = gcmd.RunCommand(
'g.proj',
779 proj = projIn.split(
' ')[0].
split(
'=')[1]
780 if proj
in (
'll',
'latlong',
'longlat'):
782 e, n = utils.DMS2Deg(e, n)
783 proj, coord1 = utils.ReprojectCoordinates(coord = (e, n),
785 projOut = projOut, flags =
'd')
789 proj, coord1 = utils.ReprojectCoordinates(coord = (e, n),
791 projOut = projOut, flags =
'd')
794 if self.Map.projinfo[
'proj'] ==
'll':
799 region = self.Map.GetCurrentRegion()
801 if not UserSettings.Get(group =
'projection', key =
'statusbar', subkey =
'proj4'):
802 self.statusbar.SetStatusText(_(
"Projection not defined (check the settings)"), 0)
804 region[
'center_easting'], region[
'center_northing'] = e, n
806 if self.Map.projinfo[
'proj'] ==
'll':
807 region[
'center_easting'], region[
'center_northing'] = utils.DMS2Deg(e, n)
809 region[
'center_easting'], region[
'center_northing'] = e, n
811 region = self.Map.GetCurrentRegion()
812 precision = int(UserSettings.Get(group =
'projection', key =
'format',
813 subkey =
'precision'))
814 format = UserSettings.Get(group =
'projection', key =
'format',
816 if self.Map.projinfo[
'proj'] ==
'll' and format ==
'DMS':
817 self.
statusbarWin[
'goto'].SetValue(
"%s" % utils.Deg2DMS(region[
'center_easting'],
818 region[
'center_northing'],
819 precision = precision))
822 (precision, region[
'center_easting'],
823 precision, region[
'center_northing']))
827 dn = (region[
'nsres'] * region[
'rows']) / 2.
828 region[
'n'] = region[
'center_northing'] + dn
829 region[
's'] = region[
'center_northing'] - dn
830 de = (region[
'ewres'] * region[
'cols']) / 2.
831 region[
'e'] = region[
'center_easting'] + de
832 region[
'w'] = region[
'center_easting'] - de
834 self.Map.AdjustRegion()
837 self.MapWindow.ZoomHistory(region[
'n'], region[
's'],
838 region[
'e'], region[
'w'])
841 self.MapWindow.UpdateMap()
845 """!Update statusbar content"""
855 self.statusbar.SetStatusText(
"", 0)
859 elif self.
statusbarWin[
'toggle'].GetSelection()
in (1, 2):
862 region = self.Map.region
864 region = self.Map.GetRegion()
866 precision = int(UserSettings.Get(group =
'projection', key =
'format',
867 subkey =
'precision'))
868 format = UserSettings.Get(group =
'projection', key =
'format',
872 if not UserSettings.Get(group =
'projection', key =
'statusbar', subkey =
'proj4'):
873 self.statusbar.SetStatusText(_(
"Projection not defined (check the settings)"), 0)
875 projOut = UserSettings.Get(group =
'projection',
878 proj, coord1 = utils.ReprojectCoordinates(coord = (region[
"w"], region[
"s"]),
879 projOut = projOut, flags =
'd')
880 proj, coord2 = utils.ReprojectCoordinates(coord = (region[
"e"], region[
"n"]),
881 projOut = projOut, flags =
'd')
883 proj, coord3 = utils.ReprojectCoordinates(coord = (0.0, 0.0),
884 projOut = projOut, flags =
'd')
885 proj, coord4 = utils.ReprojectCoordinates(coord = (region[
"ewres"], region[
"nsres"]),
886 projOut = projOut, flags =
'd')
887 if coord1
and coord2:
888 if proj
in (
'll',
'latlong',
'longlat')
and format ==
'DMS':
889 w, s = utils.Deg2DMS(coord1[0], coord1[1], string =
False,
890 precision = precision)
891 e, n = utils.Deg2DMS(coord2[0], coord2[1], string =
False,
892 precision = precision)
894 self.statusbar.SetStatusText(
"%s - %s, %s - %s" %
897 ewres, nsres = utils.Deg2DMS(abs(coord3[0]) - abs(coord4[0]),
898 abs(coord3[1]) - abs(coord4[1]),
899 string =
False, hemisphere =
False,
900 precision = precision)
901 self.statusbar.SetStatusText(
"%s - %s, %s - %s (%s, %s)" %
902 (w, e, s, n, ewres, nsres), 0)
907 self.statusbar.SetStatusText(
"%.*f - %.*f, %.*f - %.*f" %
908 (precision, w, precision, e,
909 precision, s, precision, n), 0)
911 ewres, nsres = coord3
912 self.statusbar.SetStatusText(
"%.*f - %.*f, %.*f - %.*f (%.*f, %.*f)" %
913 (precision, w, precision, e,
914 precision, s, precision, n,
915 precision, ewres, precision, nsres), 0)
917 self.statusbar.SetStatusText(_(
"Error in projection (check the settings)"), 0)
919 if self.Map.projinfo[
'proj'] ==
'll' and format ==
'DMS':
920 w, s = utils.Deg2DMS(region[
"w"], region[
"s"],
921 string =
False, precision = precision)
922 e, n = utils.Deg2DMS(region[
"e"], region[
"n"],
923 string =
False, precision = precision)
925 self.statusbar.SetStatusText(
"%s - %s, %s - %s" %
928 ewres, nsres = utils.Deg2DMS(region[
'ewres'], region[
'nsres'],
929 string =
False, precision = precision)
930 self.statusbar.SetStatusText(
"%s - %s, %s - %s (%s, %s)" %
931 (w, e, s, n, ewres, nsres), 0)
933 w, s = region[
"w"], region[
"s"]
934 e, n = region[
"e"], region[
"n"]
936 self.statusbar.SetStatusText(
"%.*f - %.*f, %.*f - %.*f" %
937 (precision, w, precision, e,
938 precision, s, precision, n), 0)
940 ewres, nsres = region[
'ewres'], region[
'nsres']
941 self.statusbar.SetStatusText(
"%.*f - %.*f, %.*f - %.*f (%.*f, %.*f)" %
942 (precision, w, precision, e,
943 precision, s, precision, n,
944 precision, ewres, precision, nsres), 0)
949 self.statusbar.SetStatusText(
"", 0)
955 self.statusbar.SetStatusText(
"", 0)
961 self.statusbar.SetStatusText(
"rows=%d; cols=%d; nsres=%.2f; ewres=%.2f" %
962 (self.Map.region[
"rows"], self.Map.region[
"cols"],
963 self.Map.region[
"nsres"], self.Map.region[
"ewres"]), 0)
972 dpSizePx = wx.DisplaySize()
973 dpSizeMM = wx.DisplaySizeMM()
974 dpSizeIn = (dpSizeMM[0] / 25.4, dpSizeMM[1] / 25.4)
976 comPpi = (dpSizePx[0] / dpSizeIn[0],
977 dpSizePx[1] / dpSizeIn[1])
980 self.
ppm = ((ppi[0] / 2.54) * 100,
981 (ppi[1] / 2.54) * 100)
983 Debug.msg(4,
"MapFrame.StatusbarUpdate(mapscale): size: px=%d,%d mm=%f,%f "
984 "in=%f,%f ppi: sys=%d,%d com=%d,%d; ppm=%f,%f" % \
985 (dpSizePx[0], dpSizePx[1], dpSizeMM[0], dpSizeMM[1],
986 dpSizeIn[0], dpSizeIn[1],
987 sysPpi[0], sysPpi[1], comPpi[0], comPpi[1],
988 self.
ppm[0], self.
ppm[1]))
990 region = self.Map.region
992 heightCm = region[
'rows'] / self.
ppm[1] * 100
993 widthCm = region[
'cols'] / self.
ppm[0] * 100
995 Debug.msg(4,
"MapFrame.StatusbarUpdate(mapscale): width_cm=%f, height_cm=%f" %
998 xscale = (region[
'e'] - region[
'w']) / (region[
'cols'] / self.
ppm[0])
999 yscale = (region[
'n'] - region[
's']) / (region[
'rows'] / self.
ppm[1])
1000 scale = (xscale + yscale) / 2.
1002 Debug.msg(3,
"MapFrame.StatusbarUpdate(mapscale): xscale=%f, yscale=%f -> scale=%f" % \
1003 (xscale, yscale, scale))
1005 self.statusbar.SetStatusText(
"")
1007 self.
statusbarWin[
'mapscale'].SetValue(
"1:%ld" % (scale + 0.5))
1017 self.statusbar.SetStatusText(
"")
1018 region = self.Map.GetCurrentRegion()
1019 precision = int(UserSettings.Get(group =
'projection', key =
'format',
1020 subkey =
'precision'))
1021 format = UserSettings.Get(group =
'projection', key =
'format',
1025 if not UserSettings.Get(group=
'projection', key=
'statusbar', subkey=
'proj4'):
1026 self.statusbar.SetStatusText(_(
"Projection not defined (check the settings)"), 0)
1028 proj, coord = utils.ReprojectCoordinates(coord = (region[
'center_easting'],
1029 region[
'center_northing']),
1030 projOut = UserSettings.Get(group =
'projection',
1035 if proj
in (
'll',
'latlong',
'longlat')
and format ==
'DMS':
1036 self.
statusbarWin[
'goto'].SetValue(
"%s" % utils.Deg2DMS(coord[0],
1038 precision = precision))
1040 self.
statusbarWin[
'goto'].SetValue(
"%.*f; %.*f" % (precision, coord[0],
1041 precision, coord[1]))
1043 self.statusbar.SetStatusText(_(
"Error in projection (check the settings)"), 0)
1045 if self.Map.projinfo[
'proj'] ==
'll' and format ==
'DMS':
1046 self.
statusbarWin[
'goto'].SetValue(
"%s" % utils.Deg2DMS(region[
'center_easting'],
1047 region[
'center_northing'],
1048 precision = precision))
1050 self.
statusbarWin[
'goto'].SetValue(
"%.*f; %.*f" % (precision, region[
'center_easting'],
1051 precision, region[
'center_northing']))
1058 self.statusbar.SetStatusText(
"")
1059 epsg = UserSettings.Get(group =
'projection', key =
'statusbar', subkey =
'epsg')
1061 label =
'%s (EPSG: %s)' % (_(
"Use defined projection"), epsg)
1064 self.
statusbarWin[
'projection'].SetLabel(_(
"Use defined projection"))
1071 self.statusbar.SetStatusText(
"", 1)
1074 """!Enable/disable toolbars long help"""
1075 for toolbar
in self.toolbars.itervalues():
1077 toolbar.EnableLongHelp(enable)
1080 """!Reposition checkbox in statusbar"""
1090 for idx, win
in widgets:
1091 rect = self.statusbar.GetFieldRect(idx)
1094 wWin, hWin = win.GetBestSize()
1096 wWin = rect.width - 6
1102 x, y = rect.x + 3, rect.y - 1
1103 w, h = wWin, rect.height + 2
1105 x, y = rect.x, rect.y - 1
1106 w, h = rect.width, rect.height + 2
1112 win.SetPosition((x, y))
1116 """!Save map to image
1119 filetype =
"PPM file (*.ppm)|*.ppm|TIF file (*.tif)|*.tif"
1120 ltype = [{
'ext' :
'ppm',
'type' : -1 },
1121 {
'ext' :
'tif',
'type' : wx.BITMAP_TYPE_TIF }]
1123 img = self.MapWindow.img
1126 message = _(
"Nothing to render (empty map). Operation canceled."))
1128 filetype, ltype = gdialogs.GetImageHandlers(img)
1132 dlg.CentreOnParent()
1133 if dlg.ShowModal() != wx.ID_OK:
1136 width, height = dlg.GetValues()
1140 dlg = wx.FileDialog(parent = self,
1141 message = _(
"Choose a file name to save the image "
1142 "(no need to add extension)"),
1143 wildcard = filetype,
1144 style = wx.SAVE | wx.FD_OVERWRITE_PROMPT)
1146 if dlg.ShowModal() == wx.ID_OK:
1147 path = dlg.GetPath()
1152 base, ext = os.path.splitext(path)
1153 fileType = ltype[dlg.GetFilterIndex()][
'type']
1154 extType = ltype[dlg.GetFilterIndex()][
'ext']
1156 path = base +
'.' + extType
1158 self.MapWindow.SaveToFile(path, fileType,
1165 Print options and output menu for map display
1167 point = wx.GetMousePosition()
1168 printmenu = wx.Menu()
1170 setup = wx.MenuItem(printmenu, wx.ID_ANY, _(
'Page setup'))
1171 printmenu.AppendItem(setup)
1172 self.Bind(wx.EVT_MENU, self.printopt.OnPageSetup, setup)
1174 preview = wx.MenuItem(printmenu, wx.ID_ANY, _(
'Print preview'))
1175 printmenu.AppendItem(preview)
1176 self.Bind(wx.EVT_MENU, self.printopt.OnPrintPreview, preview)
1178 doprint = wx.MenuItem(printmenu, wx.ID_ANY, _(
'Print display'))
1179 printmenu.AppendItem(doprint)
1180 self.Bind(wx.EVT_MENU, self.printopt.OnDoPrint, doprint)
1184 self.PopupMenu(printmenu)
1189 Also close associated layer tree page
1196 maplayer = self.
toolbars[
'vdigit'].GetLayer()
1206 pgnum = self.layerbook.GetPageIndex(self.
page)
1208 self.layerbook.DeletePage(pgnum)
1211 """!Returns current instance of render.Map()
1216 """!Get map window"""
1220 """!Query current surface in 3D view mode"""
1221 if self.
toolbars[
'map'].GetAction() ==
'nvizQuerySurface':
1222 self.
toolbars[
'map'].SelectDefault(event)
1225 self.
toolbars[
'map'].action[
'desc'] =
'nvizQuerySurface'
1227 self.MapWindow.mouse[
'use'] =
"nvizQuerySurface"
1231 """!Query current vector in 3D view mode"""
1232 if self.
toolbars[
'map'].GetAction() ==
'nvizQueryVector':
1233 self.
toolbars[
'map'].SelectDefault(event)
1236 self.
toolbars[
'map'].action[
'desc'] =
'nvizQueryVector'
1238 self.MapWindow.mouse[
'use'] =
"nvizQueryVector"
1242 """!Query raster or vector map layers by r/v.what
1244 @param x,y coordinates
1247 qdist = 10.0 * ((self.Map.region[
'e'] - self.Map.region[
'w']) / self.Map.width)
1248 east, north = self.MapWindow.Pixel2Cell((x, y))
1252 for layer
in self.tree.GetSelections():
1253 ltype = self.tree.GetPyData(layer)[0][
'maplayer'].GetType()
1254 if ltype
in (
'raster',
'rgb',
'his',
1255 'vector',
'thememap',
'themechart'):
1260 message = _(
'No raster or vector map layer selected for querying.'))
1265 rcmd = [
'r.what',
'--v']
1266 vcmd = [
'v.what',
'--v']
1271 for layer
in self.tree.GetSelections():
1272 ltype = self.tree.GetPyData(layer)[0][
'maplayer'].GetType()
1273 dcmd = self.tree.GetPyData(layer)[0][
'cmd']
1274 name, found = utils.GetLayerNameFromCmd(dcmd)
1278 if ltype ==
'raster':
1280 elif ltype
in (
'rgb',
'his'):
1281 for iname
in name.split(
'\n'):
1283 elif ltype
in (
'vector',
'thememap',
'themechart'):
1288 os.environ[
"GRASS_REGION"] = self.Map.SetRegion(windres =
False)
1294 rcmd.append(
'input=%s' %
','.join(rast))
1295 rcmd.append(
'east_north=%f,%f' % (float(east), float(north)))
1299 digitToolbar = self.
toolbars[
'vdigit']
1301 lmap = digitToolbar.GetLayer().GetName()
1304 self._layerManager.goutput.WriteWarning(_(
"Vector map <%s> "
1305 "opened for editing - skipped.") % map)
1309 self._layerManager.goutput.WriteCmdLog(_(
"Nothing to query."))
1313 vcmd.append(
'map=%s' %
','.join(vect))
1314 vcmd.append(
'east_north=%f,%f' % (float(east), float(north)))
1315 vcmd.append(
'distance=%f' % float(qdist))
1317 Debug.msg(1,
"QueryMap(): raster=%s vector=%s" % (
','.join(rast),
1322 self._layerManager.goutput.RunCmd(rcmd,
1326 self._layerManager.goutput.RunCmd(vcmd,
1330 gcmd.RunCommand(rcmd)
1332 gcmd.RunCommand(vcmd)
1334 def _QueryMapDone(self, cmd, returncode):
1335 """!Restore settings after querying (restore GRASS_REGION)
1337 @param returncode command return code
1339 if hasattr(self,
"tmpreg"):
1341 os.environ[
"GRASS_REGION"] = self.
tmpreg
1342 elif 'GRASS_REGION' in os.environ:
1343 del os.environ[
"GRASS_REGION"]
1344 elif 'GRASS_REGION' in os.environ:
1345 del os.environ[
"GRASS_REGION"]
1347 if hasattr(self,
"tmpreg"):
1351 """!Query vector map layer features
1353 Attribute data of selected vector object are displayed in GUI dialog.
1354 Data can be modified (On Submit)
1356 if not self.tree.layer_selected
or \
1357 self.tree.GetPyData(self.tree.layer_selected)[0][
'type'] !=
'vector':
1359 message = _(
"No map layer selected for querying."))
1362 posWindow = self.ClientToScreen((x + self.MapWindow.dialogOffset,
1363 y + self.MapWindow.dialogOffset))
1365 qdist = 10.0 * ((self.Map.region[
'e'] - self.Map.region[
'w']) /
1368 east, north = self.MapWindow.Pixel2Cell((x, y))
1370 mapName = self.tree.GetPyData(self.tree.layer_selected)[0][
'maplayer'].name
1372 if self.tree.GetPyData(self.tree.layer_selected)[0][
'maplayer'].GetMapset() != \
1373 grass.gisenv()[
'MAPSET']:
1378 if self.
dialogs[
'attributes']
is None:
1381 query = ((east, north), qdist),
1384 self.
dialogs[
'attributes'] = dlg
1388 if not self.
dialogs[
'attributes'].mapDBInfo
or \
1389 self.
dialogs[
'attributes'].mapDBInfo.map != mapName:
1395 if not self.
dialogs[
'attributes'].IsFound():
1396 self._layerManager.goutput.WriteLog(_(
'Nothing found.'))
1398 cats = self.
dialogs[
'attributes'].GetCats()
1401 qlayer = self.Map.GetListOfLayers(l_name = globalvar.QUERYLAYER)[0]
1405 if self.
dialogs[
'attributes'].mapDBInfo
and cats:
1415 opacity = self.tree.GetPyData(self.tree.layer_selected)[0][
'maplayer'].GetOpacity(float =
True)
1416 qlayer.SetOpacity(opacity)
1418 self.MapWindow.UpdateMap(render =
False, renderVector =
False)
1419 if not self.
dialogs[
'attributes'].IsShown():
1420 self.
dialogs[
'attributes'].Show()
1423 self.Map.DeleteLayer(qlayer)
1424 self.MapWindow.UpdateMap(render =
False, renderVector =
False)
1425 if self.
dialogs[
'attributes'].IsShown():
1426 self.
dialogs[
'attributes'].Hide()
1429 """!Query tools menu"""
1432 action = self.
toolbars[
'map'].GetAction()
1435 toolsmenu = wx.Menu()
1436 raster = wx.MenuItem(parentMenu = toolsmenu, id = wx.ID_ANY,
1437 text = _(
"Query surface (raster map)"),
1438 kind = wx.ITEM_CHECK)
1439 toolsmenu.AppendItem(raster)
1441 if action ==
"nvizQuerySurface":
1443 vector = wx.MenuItem(parentMenu = toolsmenu, id = wx.ID_ANY,
1444 text = _(
"Query vector map"),
1445 kind = wx.ITEM_CHECK)
1446 toolsmenu.AppendItem(vector)
1448 if action ==
"nvizQueryVector":
1451 self.PopupMenu(toolsmenu)
1454 self.
toolbars[
'map'].action[
'desc'] =
'queryMap'
1455 self.MapWindow.mouse[
'use'] =
"query"
1459 self._layerManager.notebook.SetSelectionByName(
'output')
1461 self.MapWindow.mouse[
'box'] =
"point"
1462 self.MapWindow.zoomtype = 0
1465 self.MapWindow.SetCursor(self.
cursors[
"cross"])
1468 """!Add temporal vector map layer to map composition
1470 @param name name of map layer
1471 @param useId use feature id instead of category
1474 color = UserSettings.Get(group =
'atm', key =
'highlight', subkey =
'color')
1475 colorStr = str(color[0]) +
":" + \
1476 str(color[1]) +
":" + \
1482 vparam = self.tree.GetPyData(self.tree.layer_selected)[0][
'cmd']
1485 parg,pval = p.split(
'=')
1486 if parg ==
'icon': icon = pval
1487 elif parg ==
'size': size = int(pval)
1489 pattern = [
"d.vect",
1491 "color=%s" % colorStr,
1492 "fcolor=%s" % colorStr,
1493 "width=%d" % UserSettings.Get(group =
'atm', key =
'highlight', subkey =
'width')]
1495 pattern.append(
'icon=%s' % icon)
1497 pattern.append(
'size=%i' % size)
1502 cmd.append(
'cats=%s' % str(cats))
1505 for layer
in cats.keys():
1506 cmd.append(copy.copy(pattern))
1508 cmd[-1].append(
"layer=%d" % layer)
1509 cmd[-1].append(
"cats=%s" % utils.ListOfCatsToRange(lcats))
1513 return self.Map.AddLayer(type =
'vector', name = globalvar.QUERYLAYER, command = cmd,
1514 l_active =
True, l_hidden =
True, l_opacity = 1.0)
1516 return self.Map.AddLayer(type =
'command', name = globalvar.QUERYLAYER, command = cmd,
1517 l_active =
True, l_hidden =
True, l_opacity = 1.0)
1522 """!Analysis tools menu
1524 point = wx.GetMousePosition()
1525 toolsmenu = wx.Menu()
1526 icons = Icons[
'displayWindow']
1529 measure = wx.MenuItem(toolsmenu, wx.ID_ANY, icons[
"measure"].GetLabel())
1530 measure.SetBitmap(icons[
"measure"].GetBitmap(self.
iconsize))
1531 toolsmenu.AppendItem(measure)
1532 self.Bind(wx.EVT_MENU, self.
OnMeasure, measure)
1534 profile = wx.MenuItem(toolsmenu, wx.ID_ANY, icons[
"profile"].GetLabel())
1535 profile.SetBitmap(icons[
"profile"].GetBitmap(self.
iconsize))
1536 toolsmenu.AppendItem(profile)
1537 self.Bind(wx.EVT_MENU, self.
Profile, profile)
1539 histogram = wx.MenuItem(toolsmenu, wx.ID_ANY, icons[
"histogram"].GetLabel())
1540 histogram.SetBitmap(icons[
"histogram"].GetBitmap(self.
iconsize))
1541 toolsmenu.AppendItem(histogram)
1542 self.Bind(wx.EVT_MENU, self.
Histogram, histogram)
1546 self.PopupMenu(toolsmenu)
1550 """!Init measurement routine that calculates map distance
1551 along transect drawn on map display
1556 self._layerManager.notebook.SetSelectionByName(
'output')
1559 self.MapWindow.mouse[
'use'] =
"measure"
1560 self.MapWindow.mouse[
'box'] =
"line"
1561 self.MapWindow.zoomtype = 0
1562 self.MapWindow.pen = wx.Pen(colour =
'red', width = 2, style = wx.SHORT_DASH)
1563 self.MapWindow.polypen = wx.Pen(colour =
'green', width = 2, style = wx.SHORT_DASH)
1566 self.MapWindow.SetCursor(self.
cursors[
"pencil"])
1569 style = self._layerManager.goutput.cmd_output.StyleWarning
1570 self._layerManager.goutput.WriteLog(_(
'Click and drag with left mouse button '
1572 'Double click with left button to clear.') % \
1573 (os.linesep), style)
1574 if self.Map.projinfo[
'proj'] !=
'xy':
1575 units = self.Map.projinfo[
'units']
1576 self._layerManager.goutput.WriteCmdLog(_(
'Measuring distance') +
' ('
1579 self._layerManager.goutput.WriteCmdLog(_(
'Measuring distance:'))
1581 if self.Map.projinfo[
'proj'] ==
'll':
1587 gislib.G_begin_distance_calculations()
1588 except ImportError, e:
1589 self._layerManager.goutput.WriteWarning(_(
'Geodesic distance is not yet '
1590 'supported by this tool.\n'
1594 """!Calculate map distance from screen distance
1595 and print to output window
1597 self._layerManager.notebook.SetSelectionByName(
'output')
1599 dist, (north, east) = self.MapWindow.Distance(beginpt, endpt)
1601 dist =
round(dist, 3)
1608 strtotdist = str(td)
1610 if self.Map.projinfo[
'proj'] ==
'xy' or 'degree' not in self.Map.projinfo[
'unit']:
1611 angle = int(math.degrees(math.atan2(north,east)) + 0.5)
1616 mstring =
'%s = %s %s\n%s = %s %s\n%s = %d %s\n%s' \
1617 % (_(
'segment'), strdist, dunits,
1618 _(
'total distance'), strtotdist, tdunits,
1619 _(
'bearing'), angle, _(
'deg'),
1622 mstring =
'%s = %s %s\n%s = %s %s\n%s' \
1623 % (_(
'segment'), strdist, dunits,
1624 _(
'total distance'), strtotdist, tdunits,
1627 self._layerManager.goutput.WriteLog(mstring)
1632 """!Init profile canvas and tools
1635 if self.tree.layer_selected
and \
1636 self.tree.GetPyData(self.tree.layer_selected)[0][
'type'] ==
'raster':
1637 raster.append(self.tree.GetPyData(self.tree.layer_selected)[0][
'maplayer'].name)
1640 id = wx.ID_ANY, pos = wx.DefaultPosition, size = (700,300),
1641 style = wx.DEFAULT_FRAME_STYLE, rasterList = raster)
1645 self.profile.OnSelectRaster(
None)
1648 """!Format length numbers and units in a nice way,
1649 as a function of length. From code by Hamish Bowman
1650 Grass Development Team 2006"""
1652 mapunits = self.Map.projinfo[
'units']
1653 if mapunits ==
'metres':
1660 if mapunits ==
'meters':
1664 else: outunits =
'm'
1665 elif mapunits ==
'feet':
1675 elif 'degree' in mapunits
and \
1686 if (dist/divisor) >= 2500.0:
1687 outdist =
round(dist/divisor)
1688 elif (dist/divisor) >= 1000.0:
1689 outdist =
round(dist/divisor,1)
1690 elif (dist/divisor) > 0.0:
1691 outdist =
round(dist/divisor,int(math.ceil(3-math.log10(dist/divisor))))
1693 outdist = float(dist/divisor)
1695 return (outdist, outunits)
1698 """!Init histogram display canvas and tools
1701 id = wx.ID_ANY, size = globalvar.HIST_WINDOW_SIZE,
1702 style = wx.DEFAULT_FRAME_STYLE)
1705 self.histogram.Show()
1706 self.histogram.Refresh()
1707 self.histogram.Update()
1711 """!Decorations overlay menu
1713 point = wx.GetMousePosition()
1715 icons = Icons[
'displayWindow']
1718 AddScale = wx.MenuItem(decmenu, wx.ID_ANY, icons[
"addBarscale"].GetLabel())
1719 AddScale.SetBitmap(icons[
"addBarscale"].GetBitmap(self.
iconsize))
1720 decmenu.AppendItem(AddScale)
1723 AddLegend = wx.MenuItem(decmenu, wx.ID_ANY, icons[
"addLegend"].GetLabel())
1724 AddLegend.SetBitmap(icons[
"addLegend"].GetBitmap(self.
iconsize))
1725 decmenu.AppendItem(AddLegend)
1726 self.Bind(wx.EVT_MENU, self.
OnAddLegend, AddLegend)
1728 AddText = wx.MenuItem(decmenu, wx.ID_ANY, icons[
"addText"].GetLabel())
1729 AddText.SetBitmap(icons[
"addText"].GetBitmap(self.
iconsize))
1730 decmenu.AppendItem(AddText)
1731 self.Bind(wx.EVT_MENU, self.
OnAddText, AddText)
1735 self.PopupMenu(decmenu)
1739 """!Handler for scale/arrow map decoration menu selection.
1757 style = wx.DEFAULT_DIALOG_STYLE | wx.CENTRE,
1758 cmd = [
'd.barscale',
'at=0,5'],
1761 checktxt = _(
"Show/hide scale and North arrow"),
1762 ctrltxt = _(
"scale object"))
1764 self.
dialogs[
'barscale'].CentreOnParent()
1767 self.
dialogs[
'barscale'].Show()
1768 self.MapWindow.mouse[
'use'] =
'pointer'
1771 """!Handler for legend map decoration menu selection.
1778 cmd = [
'd.legend',
'at=5,50,2,5']
1779 if self.tree.layer_selected
and \
1780 self.tree.GetPyData(self.tree.layer_selected)[0][
'type'] ==
'raster':
1781 cmd.append(
'map=%s' % self.tree.GetPyData(self.tree.layer_selected)[0][
'maplayer'].name)
1787 style = wx.DEFAULT_DIALOG_STYLE | wx.CENTRE,
1791 checktxt = _(
"Show/hide legend"),
1792 ctrltxt = _(
"legend object"))
1794 self.
dialogs[
'legend'].CentreOnParent()
1798 self.MapWindow.mouse[
'use'] =
'pointer'
1801 """!Handler for text decoration menu selection.
1803 if self.MapWindow.dragid > -1:
1804 id = self.MapWindow.dragid
1807 if len(self.MapWindow.textdict.keys()) > 0:
1808 id = self.MapWindow.textdict.keys()[-1] + 1
1813 title = _(
'Add text layer'),
1815 self.
dialogs[
'text'].CenterOnParent()
1818 if self.
dialogs[
'text'].ShowModal() == wx.ID_OK:
1819 text = self.
dialogs[
'text'].GetValues()[
'text']
1820 active = self.
dialogs[
'text'].GetValues()[
'active']
1821 coords, w, h = self.MapWindow.TextBounds(self.
dialogs[
'text'].GetValues())
1824 if text ==
'' or active ==
False:
1826 self.MapWindow.pdc.ClearId(id)
1827 self.MapWindow.pdc.RemoveId(id)
1828 del self.MapWindow.textdict[id]
1833 self.MapWindow.pdc.ClearId(id)
1834 self.MapWindow.pdc.SetId(id)
1835 self.MapWindow.textdict[id] = self.
dialogs[
'text'].GetValues()
1837 self.MapWindow.Draw(self.MapWindow.pdcDec, img = self.MapWindow.textdict[id],
1838 drawid = id, pdctype =
'text', coords = coords)
1840 self.MapWindow.UpdateMap(render =
False, renderVector =
False)
1842 self.MapWindow.mouse[
'use'] =
'pointer'
1845 """!Callback method for decoration overlay command generated by
1846 dialog created in menuform.py
1850 self.Map.ChangeOverlay(ovltype = type, type =
'overlay', name =
'', command = dcmd,
1851 l_active =
True, l_render =
False)
1852 self.params[type] = params
1853 self.propwin[type] = propwin
1856 """!Set display extents to match selected raster (including
1857 NULLs) or vector map.
1859 self.MapWindow.ZoomToMap()
1862 """!Set display extents to match selected raster map (ignore NULLs)
1864 self.MapWindow.ZoomToMap(ignoreNulls =
True)
1867 """!Set display geometry to match computational region
1868 settings (set with g.region)
1870 self.MapWindow.ZoomToWind()
1873 """!Set display geometry to match default region settings
1875 self.MapWindow.ZoomToDefault()
1878 """!Set display geometry to match extents in
1881 self.MapWindow.ZoomToSaved()
1884 """!Set computational region (WIND file) to match display
1887 self.MapWindow.DisplayToWind()
1890 """!Save display extents to named region file.
1892 self.MapWindow.SaveDisplayRegion()
1897 point = wx.GetMousePosition()
1898 zoommenu = wx.Menu()
1901 zoomwind = wx.MenuItem(zoommenu, wx.ID_ANY, _(
'Zoom to computational region (set with g.region)'))
1902 zoommenu.AppendItem(zoomwind)
1905 zoomdefault = wx.MenuItem(zoommenu, wx.ID_ANY, _(
'Zoom to default region'))
1906 zoommenu.AppendItem(zoomdefault)
1909 zoomsaved = wx.MenuItem(zoommenu, wx.ID_ANY, _(
'Zoom to saved region'))
1910 zoommenu.AppendItem(zoomsaved)
1913 savewind = wx.MenuItem(zoommenu, wx.ID_ANY, _(
'Set computational region from display extent'))
1914 zoommenu.AppendItem(savewind)
1917 savezoom = wx.MenuItem(zoommenu, wx.ID_ANY, _(
'Save display geometry to named region'))
1918 zoommenu.AppendItem(savezoom)
1923 self.PopupMenu(zoommenu)
1926 def SetProperties(self, render = False, mode = 0, showCompExtent = False,
1927 constrainRes =
False, projection =
False):
1928 """!Set properies of map display window"""
1936 self.MapWindow.regionCoords = []
1939 """!Check if Map display is standalone"""
1946 """!Get reference to Layer Manager
1948 @return window reference
1949 @return None (if standalone)
1957 wx.InitAllImageHandlers()
1958 if __name__ ==
"__main__":
1964 size = globalvar.MAP_WINDOW_SIZE)
1968 if __name__ ==
"__main__":
1971 status = Command(self, Map, cmdfilename)
1975 self.timer.Start(100)
1980 if __name__ ==
"__main__":
1984 os.system(
"""!echo "quit" >> %s""" % (cmdfilename))
1987 """!Redraw, if new layer appears"""
1989 self.mapFrm.OnDraw(
None)
1994 if __name__ ==
"__main__":
1997 if len(sys.argv) != 3:
2002 cmdfilename = sys.argv[2]
2005 gettext.install(
'grasswxpy', os.path.join(os.getenv(
"GISBASE"),
'locale'), unicode =
True)
2007 print >> sys.stderr,
"\nStarting monitor <%s>...\n" % (title)
2011 gm_map.mapFrm.SetTitle(_(
"GRASS GIS Map Display: " +
2013 " - Location: " + grass.gisenv()[
"LOCATION_NAME"]))
2017 if grass.gisenv().has_key(
"MONITOR"):
2018 os.system(
"d.mon sel=%s" % grass.gisenv()[
"MONITOR"])
2020 os.remove(cmdfilename)
2021 os.system(
"""!g.gisenv set="GRASS_PYCMDFILE" """)
2023 print >> sys.stderr,
"\nStoping monitor <%s>...\n" % (title)