4 @brief wxGUI toolbar widgets
23 (C) 2007-2011 by the GRASS Development Team
24 This program is free software under the GNU General Public License
25 (>=v2). Read the file COPYING that comes with GRASS for details.
27 @author Michael Barton
28 @author Jachym Cepicky
29 @author Martin Landa <landa.martin gmail.com>
30 @author Anna Kratochvilova <anna.kratochvilova fsv.cvut.cz>
44 from vdigit
import VDigitSettingsDialog, haveVDigit, VDigit
45 from debug
import Debug
46 from preferences
import globalSettings
as UserSettings
47 from nviz
import haveNviz
48 from nviz_preferences
import NvizPreferencesDialog
50 sys.path.append(os.path.join(globalvar.ETCWXDIR,
"icons"))
51 from icon
import Icons
54 """!Abstract toolbar class"""
57 wx.ToolBar.__init__(self, parent = self.
parent, id = wx.ID_ANY)
61 self.Bind(wx.EVT_TOOL, self.
OnTool)
63 self.SetToolBitmapSize(globalvar.toolbarSize)
66 """!Initialize toolbar, add tools to the toolbar
73 def _toolbarData(self):
74 """!Toolbar data (virtual)"""
78 shortHelp, longHelp, handler):
79 """!Add tool to the toolbar
83 bmpDisabled = wx.NullBitmap
86 tool = vars(self)[label] = wx.NewId()
87 Debug.msg(3,
"CreateTool(): tool=%d, label=%s bitmap=%s" % \
88 (tool, label, bitmap))
90 toolWin = self.AddLabelTool(tool, label, bitmap,
93 self.Bind(wx.EVT_TOOL, handler, toolWin)
100 """!Enable/disable long help
102 @param enable True for enable otherwise disable
104 for tool
in self.
_data:
109 self.SetToolLongHelp(vars(self)[tool[0]], tool[4])
111 self.SetToolLongHelp(vars(self)[tool[0]],
"")
116 if self.parent.GetName() ==
"GCPFrame":
119 if hasattr(self.
parent,
'toolbars'):
120 if self.parent.toolbars[
'vdigit']:
122 id = self.parent.toolbars[
'vdigit'].
GetAction(type =
'id')
123 self.parent.toolbars[
'vdigit'].ToggleTool(id,
False)
127 id = self.action.get(
'id', -1)
128 if id != event.GetId():
129 self.ToggleTool(self.
action[
'id'],
False)
131 self.ToggleTool(self.
action[
'id'],
True)
133 self.
action[
'id'] = event.GetId()
138 self.ToggleTool(self.
action[
'id'],
True)
141 """!Get current action info"""
142 return self.action.get(type,
'')
145 """!Select default tool"""
146 self.ToggleTool(self.defaultAction[
'id'],
True)
147 self.defaultAction[
'bind'](event)
148 self.
action = {
'id' : self.defaultAction[
'id'],
149 'desc' : self.defaultAction.get(
'desc',
'') }
152 """!Fix toolbar width on Windows
154 @todo Determine why combobox causes problems here
156 if platform.system() ==
'Windows':
157 size = self.GetBestSize()
158 self.SetSize((size[0] + width, size[1]))
161 """!Enable defined tool
164 @param enable True to enable otherwise disable tool
167 id = getattr(self, tool)
168 except AttributeError:
171 self.EnableTool(id, enable)
173 def _getToolbarData(self, data):
182 def _defineTool(self, name = None, icon = None, handler = None, item = wx.ITEM_NORMAL):
186 return (name, icon.GetBitmap(),
187 item, icon.GetLabel(), icon.GetDesc(),
189 return (
"",
"",
"",
"",
"",
"")
192 """!Map Display toolbar
195 """!Map Display constructor
197 @param parent reference to MapFrame
198 @param mapcontent reference to render.Map (registred by MapFrame)
201 AbstractToolbar.__init__(self, parent = parent)
206 choices = [ _(
'2D view'), ]
208 if self.parent.GetLayerManager():
209 log = self.parent.GetLayerManager().GetLogWindow()
212 choices.append(_(
'3D view'))
215 from nviz
import errorMsg
226 choices.append(_(
'Digitize'))
227 if self.
toolId[
'3d'] > -1:
232 from vdigit
import errorMsg
233 log.WriteCmdLog(_(
'Vector digitizer not available'))
234 log.WriteWarning(_(
'Reason: %s') % errorMsg)
235 log.WriteLog(_(
'Note that the wxGUI\'s vector digitizer is currently disabled '
236 '(hopefully this will be fixed soon). '
237 'Please keep an eye out for updated versions of GRASS. '
238 'In the meantime you can use "v.digit" from the Develop Vector menu.'), wrap = 60)
240 self.
toolId[
'vdigit'] = -1
242 self.
combo = wx.ComboBox(parent = self, id = wx.ID_ANY,
244 style = wx.CB_READONLY, size = (110, -1))
245 self.combo.SetSelection(0)
259 'bind' : self.parent.OnPointer }
263 self.EnableTool(self.zoomback,
False)
267 def _toolbarData(self):
269 icons = Icons[
'displayWindow']
272 (
'rendermap', icons[
'render'],
273 self.parent.OnRender),
274 (
'erase', icons[
'erase'],
275 self.parent.OnErase),
277 (
'pointer', icons[
'pointer'],
278 self.parent.OnPointer,
280 (
'query', icons[
'query'],
283 (
'pan', icons[
'pan'],
286 (
'zoomin', icons[
'zoomIn'],
287 self.parent.OnZoomIn,
289 (
'zoomout', icons[
'zoomOut'],
290 self.parent.OnZoomOut,
292 (
'zoomextent', icons[
'zoomExtent'],
293 self.parent.OnZoomToMap),
294 (
'zoomback', icons[
'zoomBack'],
295 self.parent.OnZoomBack),
296 (
'zoommenu', icons[
'zoomMenu'],
297 self.parent.OnZoomMenu),
299 (
'analyze', icons[
'analyze'],
300 self.parent.OnAnalyze),
302 (
'dec', icons[
'overlay'],
303 self.parent.OnDecoration),
305 (
'savefile', icons[
'saveFile'],
306 self.parent.SaveToFile),
307 (
'printmap', icons[
'print'],
308 self.parent.PrintMenu),
313 """!Select / enable tool available in tools list
315 tool = event.GetSelection()
317 if tool == self.
toolId[
'2d']:
321 elif tool == self.
toolId[
'3d']
and \
322 not self.parent.toolbars[
'nviz']:
324 self.parent.AddToolbar(
"nviz")
326 elif tool == self.
toolId[
'vdigit']
and \
327 not self.parent.toolbars[
'vdigit']:
329 self.parent.AddToolbar(
"vdigit")
330 self.parent.MapWindow.SetFocus()
333 if self.parent.toolbars[
'vdigit']:
334 self.parent.toolbars[
'vdigit'].OnExit()
335 if self.parent.toolbars[
'nviz']:
336 self.parent.toolbars[
'nviz'].OnExit()
339 """!Enable/Disable 2D display mode specific tools"""
340 for tool
in (self.pointer,
349 self.EnableTool(tool, enabled)
352 """!Toolbar for managing ground control points
354 @param parent reference to GCP widget
357 AbstractToolbar.__init__(self, parent)
364 def _toolbarData(self):
365 icons = Icons[
'georectify']
367 self.parent.SaveGCPs),
368 (
'gcpReload', icons[
"gcpReload"],
369 self.parent.ReloadGCPs),
371 (
'gcpAdd', icons[
"gcpAdd"],
373 (
'gcpDelete', icons[
"gcpDelete"],
374 self.parent.DeleteGCP),
375 (
'gcpClear', icons[
"gcpClear"],
376 self.parent.ClearGCP),
378 (
'rms', icons[
"gcpRms"],
380 (
'georect', icons[
"georectify"],
381 self.parent.OnGeorect))
390 GCP Display toolbar constructor
392 AbstractToolbar.__init__(self, parent)
399 choices = [_(
'source'), _(
'target')],
400 style = wx.CB_READONLY)
404 self.SetToolShortHelp(self.
togglemapid,
'%s %s %s' % (_(
'Set map canvas for '),
405 Icons[
'displayWindow'][
"zoomBack"].GetLabel(),
406 _(
' / Zoom to map')))
413 'bind' : self.parent.OnPointer }
417 self.EnableTool(self.zoomback,
False)
419 def _toolbarData(self):
421 icons = Icons[
'displayWindow']
424 (
"rendermap", icons[
"render"],
425 self.parent.OnRender),
426 (
"erase", icons[
"erase"],
427 self.parent.OnErase),
429 (
"gcpset", Icons[
"georectify"][
"gcpSet"],
430 self.parent.OnPointer),
431 (
"pan", icons[
"pan"],
433 (
"zoomin", icons[
"zoomIn"],
434 self.parent.OnZoomIn),
435 (
"zoomout", icons[
"zoomOut"],
436 self.parent.OnZoomOut),
437 (
"zoommenu", icons[
"zoomMenu"],
438 self.parent.OnZoomMenuGCP),
440 (
"zoomback", icons[
"zoomBack"],
441 self.parent.OnZoomBack),
442 (
"zoomtomap", icons[
"zoomExtent"],
443 self.parent.OnZoomToMap),
445 (
'settings', Icons[
"georectify"][
"settings"],
446 self.parent.OnSettings),
447 (
'help', Icons[
"misc"][
"help"],
450 (
'quit', Icons[
"georectify"][
"quit"],
455 """!Zoom to selected map"""
456 self.parent.MapWindow.ZoomToMap(layers = self.mapcontent.GetListOfLayers())
461 """!Toolbar for digitization
463 def __init__(self, parent, mapcontent, layerTree = None, log = None):
467 AbstractToolbar.__init__(self, parent)
482 self.Bind(wx.EVT_TOOL, self.
OnTool)
499 self.EnableTool(self.undo,
False)
502 self.RemoveTool(self.undo)
509 def _toolbarData(self):
513 icons = Icons[
'vdigit']
515 (
"addPoint", icons[
"addPoint"],
518 (
"addLine", icons[
"addLine"],
521 (
"addBoundary", icons[
"addBoundary"],
524 (
"addCentroid", icons[
"addCentroid"],
527 (
"addArea", icons[
"addArea"],
530 (
"moveVertex", icons[
"moveVertex"],
533 (
"addVertex", icons[
"addVertex"],
536 (
"removeVertex", icons[
"removeVertex"],
539 (
"editLine", icons[
"editLine"],
542 (
"moveLine", icons[
"moveLine"],
545 (
"deleteLine", icons[
"deleteLine"],
548 (
"displayCats", icons[
"displayCats"],
551 (
"displayAttr", icons[
"displayAttr"],
554 (
"additionalTools", icons[
"additionalTools"],
558 (
"undo", icons[
"undo"],
560 (
"settings", icons[
"settings"],
562 (
"quit", icons[
"quit"],
567 """!Tool selected -> disable selected tool in map toolbar"""
568 aId = self.parent.toolbars[
'map'].
GetAction(type =
'id')
569 self.parent.toolbars[
'map'].ToggleTool(aId,
False)
572 cursor = self.parent.cursors[
"cross"]
573 self.parent.MapWindow.SetCursor(cursor)
576 self.parent.OnPointer(
None)
580 aId = self.action.get(
'id', -1)
581 if aId != event.GetId()
and \
583 self.ToggleTool(self.
action[
'id'],
False)
585 self.ToggleTool(self.
action[
'id'],
True)
587 self.
action[
'id'] = event.GetId()
591 if self.
action[
'id'] != -1:
592 self.ToggleTool(self.
action[
'id'],
True)
595 if self.
action[
'id'] != aId:
596 self.parent.MapWindow.ClearLines(pdc = self.parent.MapWindow.pdcTmp)
598 len(self.parent.MapWindow.digit.GetDisplay().GetSelected()) > 0:
600 self.parent.MapWindow.OnMiddleDown(
None)
603 self.parent.MapWindow.SetFocus()
606 """!Add point to the vector map Laier"""
607 Debug.msg (2,
"VDigitToolbar.OnAddPoint()")
608 self.
action = {
'desc' :
"addLine",
610 'id' : self.addPoint }
611 self.parent.MapWindow.mouse[
'box'] =
'point'
614 """!Add line to the vector map layer"""
615 Debug.msg (2,
"VDigitToolbar.OnAddLine()")
616 self.
action = {
'desc' :
"addLine",
618 'id' : self.addLine }
619 self.parent.MapWindow.mouse[
'box'] =
'line'
623 """!Add boundary to the vector map layer"""
624 Debug.msg (2,
"VDigitToolbar.OnAddBoundary()")
625 if self.
action[
'desc'] !=
'addLine' or \
626 self.
action[
'type'] !=
'boundary':
627 self.parent.MapWindow.polycoords = []
628 self.
action = {
'desc' :
"addLine",
630 'id' : self.addBoundary }
631 self.parent.MapWindow.mouse[
'box'] =
'line'
634 """!Add centroid to the vector map layer"""
635 Debug.msg (2,
"VDigitToolbar.OnAddCentroid()")
636 self.
action = {
'desc' :
"addLine",
638 'id' : self.addCentroid }
639 self.parent.MapWindow.mouse[
'box'] =
'point'
642 """!Add area to the vector map layer"""
643 Debug.msg (2,
"VDigitToolbar.OnAddCentroid()")
644 self.
action = {
'desc' :
"addLine",
646 'id' : self.addArea }
647 self.parent.MapWindow.mouse[
'box'] =
'line'
650 """!Quit digitization tool"""
657 self.settingsDialog.OnCancel(
None)
660 self.parent.MapWindow.mouse[
'use'] =
"pointer"
661 self.parent.MapWindow.mouse[
'box'] =
"point"
662 self.parent.MapWindow.polycoords = []
665 self.parent.RemoveToolbar(
"vdigit")
668 """!Move line vertex"""
669 Debug.msg(2,
"Digittoolbar.OnMoveVertex():")
670 self.
action = {
'desc' :
"moveVertex",
671 'id' : self.moveVertex }
672 self.parent.MapWindow.mouse[
'box'] =
'point'
675 """!Add line vertex"""
676 Debug.msg(2,
"Digittoolbar.OnAddVertex():")
677 self.
action = {
'desc' :
"addVertex",
678 'id' : self.addVertex }
679 self.parent.MapWindow.mouse[
'box'] =
'point'
682 """!Remove line vertex"""
683 Debug.msg(2,
"Digittoolbar.OnRemoveVertex():")
684 self.
action = {
'desc' :
"removeVertex",
685 'id' : self.removeVertex }
686 self.parent.MapWindow.mouse[
'box'] =
'point'
690 Debug.msg(2,
"Digittoolbar.OnEditLine():")
691 self.
action = {
'desc' :
"editLine",
692 'id' : self.editLine }
693 self.parent.MapWindow.mouse[
'box'] =
'line'
697 Debug.msg(2,
"Digittoolbar.OnMoveLine():")
698 self.
action = {
'desc' :
"moveLine",
699 'id' : self.moveLine }
700 self.parent.MapWindow.mouse[
'box'] =
'box'
704 Debug.msg(2,
"Digittoolbar.OnDeleteLine():")
705 self.
action = {
'desc' :
"deleteLine",
706 'id' : self.deleteLine }
707 self.parent.MapWindow.mouse[
'box'] =
'box'
710 """!Display/update categories"""
711 Debug.msg(2,
"Digittoolbar.OnDisplayCats():")
712 self.
action = {
'desc' :
"displayCats",
713 'id' : self.displayCats }
714 self.parent.MapWindow.mouse[
'box'] =
'point'
717 """!Display/update attributes"""
718 Debug.msg(2,
"Digittoolbar.OnDisplayAttr():")
719 self.
action = {
'desc' :
"displayAttrs",
720 'id' : self.displayAttr }
721 self.parent.MapWindow.mouse[
'box'] =
'point'
724 """!Undo previous changes"""
730 """!Enable 'Undo' in toolbar
732 @param enable False for disable
735 if self.GetToolEnabled(self.undo)
is False:
736 self.EnableTool(self.undo,
True)
738 if self.GetToolEnabled(self.undo)
is True:
739 self.EnableTool(self.undo,
False)
742 """!Show settings dialog"""
743 if self.
digit is None:
745 self.
digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
747 self.
digit = self.parent.MapWindow.digit =
None
750 self.
settingsDialog = VDigitSettingsDialog(parent = self.
parent, title = _(
"Digitization settings"),
751 style = wx.DEFAULT_DIALOG_STYLE)
752 self.settingsDialog.Show()
755 """!Menu for additional tools"""
756 point = wx.GetMousePosition()
759 for label, itype, handler, desc
in (
760 (_(
'Break selected lines/boundaries at intersection'),
761 wx.ITEM_CHECK, self.
OnBreak,
"breakLine"),
762 (_(
'Connect selected lines/boundaries'),
763 wx.ITEM_CHECK, self.
OnConnect,
"connectLine"),
764 (_(
'Copy categories'),
766 (_(
'Copy features from (background) vector map'),
767 wx.ITEM_CHECK, self.
OnCopy,
"copyLine"),
768 (_(
'Copy attributes'),
770 (_(
'Feature type conversion'),
772 (_(
'Flip selected lines/boundaries'),
773 wx.ITEM_CHECK, self.
OnFlip,
"flipLine"),
774 (_(
'Merge selected lines/boundaries'),
775 wx.ITEM_CHECK, self.
OnMerge,
"mergeLine"),
776 (_(
'Snap selected lines/boundaries (only to nodes)'),
777 wx.ITEM_CHECK, self.
OnSnap,
"snapLine"),
778 (_(
'Split line/boundary'),
780 (_(
'Query features'),
781 wx.ITEM_CHECK, self.
OnQuery,
"queryLine"),
782 (_(
'Z bulk-labeling of 3D lines'),
783 wx.ITEM_CHECK, self.
OnZBulk,
"zbulkLine")):
785 item = wx.MenuItem(parentMenu = toolMenu, id = wx.ID_ANY,
788 toolMenu.AppendItem(item)
789 self.parent.MapWindow.Bind(wx.EVT_MENU, handler, item)
790 if self.
action[
'desc'] == desc:
795 self.parent.MapWindow.PopupMenu(toolMenu)
798 if self.
action[
'desc'] ==
'addPoint':
799 self.ToggleTool(self.additionalTools,
False)
802 """!Copy selected features from (background) vector map"""
803 if self.
action[
'desc'] ==
'copyLine':
804 self.ToggleTool(self.addPoint,
True)
805 self.ToggleTool(self.additionalTools,
False)
809 Debug.msg(2,
"Digittoolbar.OnCopy():")
810 self.
action = {
'desc' :
"copyLine",
811 'id' : self.additionalTools }
812 self.parent.MapWindow.mouse[
'box'] =
'box'
816 if self.
action[
'desc'] ==
'splitLine':
817 self.ToggleTool(self.addPoint,
True)
818 self.ToggleTool(self.additionalTools,
False)
822 Debug.msg(2,
"Digittoolbar.OnSplitLine():")
823 self.
action = {
'desc' :
"splitLine",
824 'id' : self.additionalTools }
825 self.parent.MapWindow.mouse[
'box'] =
'point'
829 """!Copy categories"""
830 if self.
action[
'desc'] ==
'copyCats':
831 self.ToggleTool(self.addPoint,
True)
832 self.ToggleTool(self.copyCats,
False)
836 Debug.msg(2,
"Digittoolbar.OnCopyCats():")
837 self.
action = {
'desc' :
"copyCats",
838 'id' : self.additionalTools }
839 self.parent.MapWindow.mouse[
'box'] =
'point'
842 """!Copy attributes"""
843 if self.
action[
'desc'] ==
'copyAttrs':
844 self.ToggleTool(self.addPoint,
True)
845 self.ToggleTool(self.copyCats,
False)
849 Debug.msg(2,
"Digittoolbar.OnCopyAttrb():")
850 self.
action = {
'desc' :
"copyAttrs",
851 'id' : self.additionalTools }
852 self.parent.MapWindow.mouse[
'box'] =
'point'
856 """!Flip selected lines/boundaries"""
857 if self.
action[
'desc'] ==
'flipLine':
858 self.ToggleTool(self.addPoint,
True)
859 self.ToggleTool(self.additionalTools,
False)
863 Debug.msg(2,
"Digittoolbar.OnFlip():")
864 self.
action = {
'desc' :
"flipLine",
865 'id' : self.additionalTools }
866 self.parent.MapWindow.mouse[
'box'] =
'box'
869 """!Merge selected lines/boundaries"""
870 if self.
action[
'desc'] ==
'mergeLine':
871 self.ToggleTool(self.addPoint,
True)
872 self.ToggleTool(self.additionalTools,
False)
876 Debug.msg(2,
"Digittoolbar.OnMerge():")
877 self.
action = {
'desc' :
"mergeLine",
878 'id' : self.additionalTools }
879 self.parent.MapWindow.mouse[
'box'] =
'box'
882 """!Break selected lines/boundaries"""
883 if self.
action[
'desc'] ==
'breakLine':
884 self.ToggleTool(self.addPoint,
True)
885 self.ToggleTool(self.additionalTools,
False)
889 Debug.msg(2,
"Digittoolbar.OnBreak():")
890 self.
action = {
'desc' :
"breakLine",
891 'id' : self.additionalTools }
892 self.parent.MapWindow.mouse[
'box'] =
'box'
895 """!Snap selected features"""
896 if self.
action[
'desc'] ==
'snapLine':
897 self.ToggleTool(self.addPoint,
True)
898 self.ToggleTool(self.additionalTools,
False)
902 Debug.msg(2,
"Digittoolbar.OnSnap():")
903 self.
action = {
'desc' :
"snapLine",
904 'id' : self.additionalTools }
905 self.parent.MapWindow.mouse[
'box'] =
'box'
908 """!Connect selected lines/boundaries"""
909 if self.
action[
'desc'] ==
'connectLine':
910 self.ToggleTool(self.addPoint,
True)
911 self.ToggleTool(self.additionalTools,
False)
915 Debug.msg(2,
"Digittoolbar.OnConnect():")
916 self.
action = {
'desc' :
"connectLine",
917 'id' : self.additionalTools }
918 self.parent.MapWindow.mouse[
'box'] =
'box'
921 """!Query selected lines/boundaries"""
922 if self.
action[
'desc'] ==
'queryLine':
923 self.ToggleTool(self.addPoint,
True)
924 self.ToggleTool(self.additionalTools,
False)
928 Debug.msg(2,
"Digittoolbar.OnQuery(): %s" % \
929 UserSettings.Get(group =
'vdigit', key =
'query', subkey =
'selection'))
930 self.
action = {
'desc' :
"queryLine",
931 'id' : self.additionalTools }
932 self.parent.MapWindow.mouse[
'box'] =
'box'
935 """!Z bulk-labeling selected lines/boundaries"""
936 if not self.digit.IsVector3D():
938 message = _(
"Vector map is not 3D. Operation canceled."))
941 if self.
action[
'desc'] ==
'zbulkLine':
942 self.ToggleTool(self.addPoint,
True)
943 self.ToggleTool(self.additionalTools,
False)
947 Debug.msg(2,
"Digittoolbar.OnZBulk():")
948 self.
action = {
'desc' :
"zbulkLine",
949 'id' : self.additionalTools }
950 self.parent.MapWindow.mouse[
'box'] =
'line'
953 """!Feature type conversion
955 Supported conversions:
959 if self.
action[
'desc'] ==
'typeConv':
960 self.ToggleTool(self.addPoint,
True)
961 self.ToggleTool(self.additionalTools,
False)
965 Debug.msg(2,
"Digittoolbar.OnTypeConversion():")
966 self.
action = {
'desc' :
"typeConv",
967 'id' : self.additionalTools }
968 self.parent.MapWindow.mouse[
'box'] =
'box'
971 """!Select vector map layer for editing
973 If there is a vector map layer already edited, this action is
974 firstly terminated. The map layer is closed. After this the
975 selected map layer activated for editing.
977 if event.GetSelection() == 0:
979 openVectorMap = self.mapLayer.GetName(fullyQualified =
False)[
'name']
982 dlg = gdialogs.CreateNewVector(self.
parent,
983 exceptMap = openVectorMap, log = self.
log,
985 {
'tool' :
'create' },
989 if dlg
and dlg.GetName():
992 mapName = dlg.GetName() +
'@' + grass.gisenv()[
'MAPSET']
993 self.layerTree.AddLayer(ltype =
'vector',
995 lcmd = [
'd.vect',
'map=%s' % mapName])
998 selection = vectLayers.index(mapName)
1001 if dlg.IsChecked(
'table'):
1002 lmgr = self.parent.GetLayerManager()
1004 lmgr.OnShowAttributeTable(
None, selection = 1)
1007 self.combo.SetValue(_(
'Select vector map'))
1012 selection = event.GetSelection() - 1
1028 """!Start editing selected vector map layer.
1030 @param mapLayer MapLayer to be edited
1033 self.mapcontent.ChangeLayerActive(mapLayer,
False)
1036 self.parent.MapWindow.EraseMap()
1040 if UserSettings.Get(group =
'vdigit', key =
'bgmap',
1041 subkey =
'value', internal =
True) == mapLayer.GetName():
1042 UserSettings.Set(group =
'vdigit', key =
'bgmap',
1043 subkey =
'value', value =
'', internal =
True)
1045 self.parent.statusbar.SetStatusText(_(
"Please wait, "
1046 "opening vector map <%s> for editing...") % mapLayer.GetName(),
1049 self.parent.MapWindow.pdcVector = wx.PseudoDC()
1050 self.
digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
1055 if self.digit.OpenMap(mapLayer.GetName())
is None:
1061 self.combo.SetValue(mapLayer.GetName())
1062 self.parent.toolbars[
'map'].combo.SetValue (_(
'Digitize'))
1063 lmgr = self.parent.GetLayerManager()
1065 lmgr.toolbars[
'tools'].
Enable(
'vdigit', enable =
False)
1067 Debug.msg (4,
"VDigitToolbar.StartEditing(): layer=%s" % mapLayer.GetName())
1070 if self.parent.MapWindow.mouse[
'use'] ==
'pointer':
1071 self.parent.MapWindow.SetCursor(self.parent.cursors[
"cross"])
1073 if not self.parent.MapWindow.resize:
1074 self.parent.MapWindow.UpdateMap(render =
True)
1077 opacity = mapLayer.GetOpacity(float =
True)
1079 alpha = int(opacity * 255)
1080 self.digit.GetDisplay().UpdateSettings(alpha = alpha)
1085 """!Stop editing of selected vector map layer.
1087 @return True on success
1088 @return False on failure
1090 self.combo.SetValue (_(
'Select vector map'))
1094 Debug.msg (4,
"VDigitToolbar.StopEditing(): layer=%s" % self.mapLayer.GetName())
1095 if UserSettings.Get(group =
'vdigit', key =
'saveOnExit', subkey =
'enabled')
is False:
1096 if self.digit.GetUndoLevel() > -1:
1097 dlg = wx.MessageDialog(parent = self.
parent,
1098 message = _(
"Do you want to save changes "
1099 "in vector map <%s>?") % self.mapLayer.GetName(),
1100 caption = _(
"Save changes?"),
1101 style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
1102 if dlg.ShowModal() == wx.ID_NO:
1107 self.parent.statusbar.SetStatusText(_(
"Please wait, "
1108 "closing and rebuilding topology of "
1109 "vector map <%s>...") % self.mapLayer.GetName(),
1111 lmgr = self.parent.GetLayerManager()
1113 lmgr.toolbars[
'tools'].
Enable(
'vdigit', enable =
True)
1114 lmgr.notebook.SetSelectionByName(
'output')
1115 self.digit.CloseMap()
1117 lmgr.GetLogWindow().GetProgressBar().SetValue(0)
1118 lmgr.GetLogWindow().WriteCmdLog(_(
"Editing of vector map <%s> successfully finished") % \
1119 self.mapLayer.GetName())
1121 item = self.parent.tree.FindItemByData(
'maplayer', self.
mapLayer)
1122 if item
and self.parent.tree.IsItemChecked(item):
1123 self.mapcontent.ChangeLayerActive(self.
mapLayer,
True)
1126 self.parent.MapWindow.SetCursor(self.parent.cursors[
"default"])
1127 self.parent.MapWindow.pdcVector =
None
1130 for dialog
in (
'attributes',
'category'):
1131 if self.parent.dialogs[dialog]:
1132 self.parent.dialogs[dialog].Close()
1133 self.parent.dialogs[dialog] =
None
1136 del self.parent.MapWindow.digit
1140 self.parent.MapWindow.redrawAll =
True
1146 Update list of available vector map layers.
1147 This list consists only editable layers (in the current mapset)
1149 Optionally also update toolbar
1151 Debug.msg (4,
"VDigitToolbar.UpdateListOfLayers(): updateTool=%d" % \
1154 layerNameSelected =
None
1157 layerNameSelected = self.mapLayer.GetName()
1161 self.
layers = self.mapcontent.GetListOfLayers(l_type =
"vector",
1162 l_mapset = grass.gisenv()[
'MAPSET'])
1163 for layer
in self.
layers:
1164 if not layer.name
in layerNameList:
1165 layerNameList.append (layer.GetName())
1169 value = _(
'Select vector map')
1171 value = layerNameSelected
1174 self.
combo = wx.ComboBox(self, id = wx.ID_ANY, value = value,
1175 choices = [_(
'New vector map'), ] + layerNameList, size = (80, -1),
1176 style = wx.CB_READONLY)
1180 self.combo.SetItems([_(
'New vector map'), ] + layerNameList)
1184 return layerNameList
1187 """!Get selected layer for editing -- MapLayer instance"""
1191 """!Toolbar for profiling raster map
1194 AbstractToolbar.__init__(self, parent)
1201 def _toolbarData(self):
1203 icons = Icons[
'profile']
1204 return self.
_getToolbarData(((
'addraster', Icons[
'layerManager'][
"addRast"],
1205 self.parent.OnSelectRaster),
1206 (
'transect', icons[
"transect"],
1207 self.parent.OnDrawTransect),
1209 (
'draw', icons[
"draw"],
1210 self.parent.OnCreateProfile),
1211 (
'erase', Icons[
'displayWindow'][
"erase"],
1212 self.parent.OnErase),
1213 (
'drag', Icons[
'displayWindow'][
'pan'],
1214 self.parent.OnDrag),
1215 (
'zoom', Icons[
'displayWindow'][
'zoomIn'],
1216 self.parent.OnZoom),
1217 (
'unzoom', Icons[
'displayWindow'][
'zoomBack'],
1218 self.parent.OnRedraw),
1220 (
'datasave', icons[
"save"],
1221 self.parent.SaveProfileToFile),
1222 (
'image', Icons[
'displayWindow'][
"saveFile"],
1223 self.parent.SaveToFile),
1224 (
'print', Icons[
'displayWindow'][
"print"],
1225 self.parent.PrintMenu),
1227 (
'settings', icons[
"options"],
1228 self.parent.ProfileOptionsMenu),
1229 (
'quit', icons[
"quit"],
1230 self.parent.OnQuit),
1238 self.
lmgr = parent.GetLayerManager()
1240 AbstractToolbar.__init__(self, parent)
1250 def _toolbarData(self):
1252 icons = Icons[
'nviz']
1256 (
"surface", icons[
"surface"],
1258 (
"vector", icons[
"vector"],
1260 (
"volume", icons[
"volume"],
1263 (
"light", icons[
"light"],
1265 (
"fringe", icons[
"fringe"],
1268 (
"settings", icons[
"settings"],
1270 (
"help", Icons[
'misc'][
"help"],
1273 (
'quit', icons[
"quit"],
1278 """!Go to the selected page"""
1279 if not self.
lmgr or not hasattr(self.
lmgr,
"nviz"):
1283 self.lmgr.notebook.SetSelectionByName(
'nviz')
1285 if eId == self.view:
1286 self.lmgr.nviz.SetPage(
'view')
1287 elif eId == self.surface:
1288 self.lmgr.nviz.SetPage(
'surface')
1289 elif eId == self.surface:
1290 self.lmgr.nviz.SetPage(
'surface')
1291 elif eId == self.vector:
1292 self.lmgr.nviz.SetPage(
'vector')
1293 elif eId == self.volume:
1294 self.lmgr.nviz.SetPage(
'volume')
1295 elif eId == self.light:
1296 self.lmgr.nviz.SetPage(
'light')
1297 elif eId == self.fringe:
1298 self.lmgr.nviz.SetPage(
'fringe')
1303 """!Show 3D view mode help"""
1305 gcmd.RunCommand(
'g.manual',
1306 entry =
'wxGUI.Nviz')
1308 log = self.lmgr.GetLogWindow()
1309 log.RunCmd([
'g.manual',
1310 'entry=wxGUI.Nviz'])
1313 """!Show nviz notebook page"""
1316 self.settingsDialog.Show()
1319 """!Quit nviz tool (swith to 2D mode)"""
1321 self.parent.MapWindow.mouse[
'use'] =
"pointer"
1322 self.parent.MapWindow.mouse[
'box'] =
"point"
1323 self.parent.MapWindow.polycoords = []
1326 self.lmgr.notebook.SetSelectionByName(
'layers')
1329 self.parent.RemoveToolbar(
"nviz")
1332 """!Graphical modeler toolbar (see gmodeler.py)
1335 AbstractToolbar.__init__(self, parent)
1342 def _toolbarData(self):
1344 icons = Icons[
'modeler']
1346 self.parent.OnModelNew),
1347 (
'open', icons[
'open'],
1348 self.parent.OnModelOpen),
1349 (
'save', icons[
'save'],
1350 self.parent.OnModelSave),
1351 (
'image', icons[
'toImage'],
1352 self.parent.OnExportImage),
1353 (
'python', icons[
'toPython'],
1354 self.parent.OnExportPython),
1356 (
'action', icons[
'actionAdd'],
1357 self.parent.OnAddAction),
1358 (
'data', icons[
'dataAdd'],
1359 self.parent.OnAddData),
1360 (
'relation', icons[
'relation'],
1361 self.parent.OnDefineRelation),
1363 (
'redraw', icons[
'redraw'],
1364 self.parent.OnCanvasRefresh),
1365 (
'validate', icons[
'validate'],
1366 self.parent.OnValidateModel),
1367 (
'run', icons[
'run'],
1368 self.parent.OnRunModel),
1370 (
"variables", icons[
'variables'],
1371 self.parent.OnVariables),
1372 (
"settings", icons[
'settings'],
1373 self.parent.OnPreferences),
1374 (
"help", Icons[
'misc'][
'help'],
1375 self.parent.OnHelp),
1377 (
'quit', icons[
'quit'],
1378 self.parent.OnCloseWindow))
1382 """!Histogram toolbar (see histogram.py)
1385 AbstractToolbar.__init__(self, parent)
1392 def _toolbarData(self):
1394 icons = Icons[
'displayWindow']
1396 self.parent.OnOptions),
1397 (
'rendermao', icons[
"display"],
1398 self.parent.OnRender),
1399 (
'erase', icons[
"erase"],
1400 self.parent.OnErase),
1401 (
'font', Icons[
'misc'][
"font"],
1402 self.parent.SetHistFont),
1404 (
'save', icons[
"saveFile"],
1405 self.parent.SaveToFile),
1406 (
'hprint', icons[
"print"],
1407 self.parent.PrintMenu),
1409 (
'quit', Icons[
'misc'][
"quit"],
1410 self.parent.OnQuit))
1414 """!Layer Manager `workspace` toolbar
1417 AbstractToolbar.__init__(self, parent)
1424 def _toolbarData(self):
1427 icons = Icons[
'layerManager']
1429 self.parent.OnNewDisplay),
1431 (
'workspaceNew', icons[
"workspaceNew"],
1432 self.parent.OnWorkspaceNew),
1433 (
'workspaceOpen', icons[
"workspaceOpen"],
1434 self.parent.OnWorkspaceOpen),
1435 (
'workspaceSave', icons[
"workspaceSave"],
1436 self.parent.OnWorkspaceSave),
1440 """!Layer Manager `data` toolbar
1443 AbstractToolbar.__init__(self, parent)
1450 def _toolbarData(self):
1453 icons = Icons[
'layerManager']
1455 self.parent.OnAddMaps),
1456 (
'addrast', icons[
"addRast"],
1457 self.parent.OnAddRaster),
1458 (
'rastmisc', icons[
"rastMisc"],
1459 self.parent.OnAddRasterMisc),
1460 (
'addvect', icons[
"addVect"],
1461 self.parent.OnAddVector),
1462 (
'vectmisc', icons[
"vectMisc"],
1463 self.parent.OnAddVectorMisc),
1464 (
'addgrp', icons[
"addGroup"],
1465 self.parent.OnAddGroup),
1466 (
'addovl', icons[
"addOverlay"],
1467 self.parent.OnAddOverlay),
1468 (
'delcmd', icons[
"delCmd"],
1469 self.parent.OnDeleteLayer),
1473 """!Layer Manager `tools` toolbar
1476 AbstractToolbar.__init__(self, parent)
1483 def _toolbarData(self):
1486 icons = Icons[
'layerManager']
1488 self.parent.OnImportMenu),
1490 (
'mapCalc', icons[
"mapcalc"],
1491 self.parent.OnMapCalculator),
1492 (
'georect', Icons[
"georectify"][
"georectify"],
1493 self.parent.OnGCPManager),
1494 (
'modeler', icons[
"modeler"],
1495 self.parent.OnGModeler),
1496 (
'mapOutput', icons[
'mapOutput'],
1497 self.parent.OnPsMap)
1501 """!Layer Manager `misc` toolbar
1504 AbstractToolbar.__init__(self, parent)
1511 def _toolbarData(self):
1514 icons = Icons[
'layerManager']
1516 self.parent.OnPreferences),
1517 (
'help', Icons[
"misc"][
"help"],
1518 self.parent.OnHelp),
1522 """!Layer Manager `vector` toolbar
1525 AbstractToolbar.__init__(self, parent)
1532 def _toolbarData(self):
1535 icons = Icons[
'layerManager']
1537 self.parent.OnVDigit),
1538 (
'attribute', icons[
"attrTable"],
1539 self.parent.OnShowAttributeTable),
1544 """!Toolbar Cartographic Composer (psmap.py)
1546 @param parent parent window
1548 AbstractToolbar.__init__(self, parent)
1556 'bind' : self.parent.OnPointer }
1559 from psmap
import haveImage
1561 self.EnableTool(self.preview,
False)
1563 def _toolbarData(self):
1566 icons = Icons[
'psMap']
1568 self.parent.OnLoadFile),
1569 (
'instructionFile', icons[
'scriptSave'],
1570 self.parent.OnInstructionFile),
1572 (
'pagesetup', icons[
'pageSetup'],
1573 self.parent.OnPageSetup),
1575 (
"pointer", Icons[
"displayWindow"][
"pointer"],
1576 self.parent.OnPointer, wx.ITEM_CHECK),
1577 (
'pan', Icons[
"displayWindow"][
'pan'],
1578 self.parent.OnPan, wx.ITEM_CHECK),
1579 (
"zoomin", Icons[
"displayWindow"][
"zoomIn"],
1580 self.parent.OnZoomIn, wx.ITEM_CHECK),
1581 (
"zoomout", Icons[
"displayWindow"][
"zoomOut"],
1582 self.parent.OnZoomOut, wx.ITEM_CHECK),
1583 (
'zoomAll', icons[
'fullExtent'],
1584 self.parent.OnZoomAll),
1586 (
'addMap', icons[
'addMap'],
1587 self.parent.OnAddMap, wx.ITEM_CHECK),
1588 (
'addRaster', icons[
'addRast'],
1589 self.parent.OnAddRaster),
1590 (
'addVector', icons[
'addVect'],
1591 self.parent.OnAddVect),
1592 (
"dec", Icons[
"displayWindow"][
"overlay"],
1593 self.parent.OnDecoration),
1594 (
"delete", icons[
"deleteObj"],
1595 self.parent.OnDelete),
1597 (
"preview", icons[
"preview"],
1598 self.parent.OnPreview),
1599 (
'generatePS', icons[
'psExport'],
1600 self.parent.OnPSFile),
1601 (
'generatePDF', icons[
'pdfExport'],
1602 self.parent.OnPDFFile),
1604 (
"help", Icons[
'misc'][
'help'],
1605 self.parent.OnHelp),
1606 (
'quit', icons[
'quit'],
1607 self.parent.OnCloseWindow))