68
70
import compat.subprocess as subprocess
72
grassPath = os.path.join(globalvar.ETCDIR, "python")
73
sys.path.append(grassPath)
74
from grass.script import core as grass
70
76
import gui_modules.utils as utils
71
77
import gui_modules.preferences as preferences
72
78
import gui_modules.wxgui_utils as wxgui_utils
102
108
self.baseTitle = title
103
109
self.iconsize = (16, 16)
105
wx.Frame.__init__(self, parent=parent, id=id, size=(500, 400),
111
wx.Frame.__init__(self, parent=parent, id=id, size=(550, 400),
106
112
style=wx.DEFAULT_FRAME_STYLE)
108
114
self.SetTitle(self.baseTitle)
450
457
def OnRunCmd(self, event):
451
458
"""Run command"""
452
cmd = event.GetString()
459
cmdString = event.GetString()
454
if cmd[:2] == 'd.' and not self.curr_page:
461
if cmdString[:2] == 'd.' and not self.curr_page:
455
462
self.NewDisplay(show=True)
457
if len(cmd.split(' ')) > 1:
464
cmd = shlex.split(str(cmdString))
458
466
self.goutput.RunCmd(cmd, switchPage=True)
460
468
self.goutput.RunCmd(cmd, switchPage=False)
530
538
def OnAboutGRASS(self, event):
531
539
"""Display 'About GRASS' dialog"""
532
540
info = wx.AboutDialogInfo()
534
rev = "$Revision: 36287 $"
536
543
info.SetName("GRASS GIS")
538
versionCmd = gcmd.Command(['g.version'])
539
info.SetVersion(versionCmd.ReadStdOutput()[0].replace('GRASS', '').strip())
545
version, svn_gis_h_rev, svn_gis_h_date = gcmd.RunCommand('g.version',
547
read = True).splitlines()
548
version = version.replace('GRASS', '').strip()
549
info.SetVersion(version)
541
551
copyrightFile = open(os.path.join(os.getenv("GISBASE"), "COPYING"), 'r')
542
552
copyrightOut = []
543
553
copyright = copyrightFile.readlines()
544
info.SetCopyright(rev + '\n\n' + wordwrap(''.join(copyright[:11] + copyright[26:-3]),
545
550, wx.ClientDC(self)))
554
info.SetCopyright('GIS Library '+ svn_gis_h_rev + '(' + svn_gis_h_date.split(' ')[1] + ')' +
555
'\n\n' + wordwrap(''.join(copyright[:11] + copyright[26:-3]),
556
575, wx.ClientDC(self)))
546
557
copyrightFile.close()
548
559
info.SetWebSite(("http://grass.osgeo.org", "The official GRASS site"))
1015
1026
runbat = os.path.join(gisbase,'etc','grass-run.bat')
1016
1027
xtermwrapper = os.path.join(gisbase,'etc','grass-xterm-wrapper')
1017
1028
grassrun = os.path.join(gisbase,'etc','grass-run.sh')
1018
command = ' '.join(command)
1029
command = shlex.split(str(command))
1020
if 'OS' in os.environ and os.environ['OS'] == "Windows_NT":
1031
if platform.system() == 'Windows':
1021
1032
cmdlist = ["cmd.exe", "/c", 'start "%s"' % runbat, command]
1023
1034
cmdlist = [xtermwrapper, '-e "%s"' % grassrun, command]
1094
1105
('', '', '', ''),
1095
1106
('addrast', Icons["addrast"].GetBitmap(),
1096
1107
Icons["addrast"].GetLabel(), self.OnAddRaster),
1108
('addshaded', Icons["addshaded"].GetBitmap(),
1109
_("Add various raster-based map layers"), self.OnAddRasterMisc),
1097
1110
('addvect', Icons["addvect"].GetBitmap(),
1098
1111
Icons["addvect"].GetLabel(), self.OnAddVector),
1112
('addthematic', Icons["addthematic"].GetBitmap(),
1113
_("Add various vector-based map layer"), self.OnAddVectorMisc),
1099
1114
('addcmd', Icons["addcmd"].GetBitmap(),
1100
1115
Icons["addcmd"].GetLabel(), self.OnAddCommand),
1101
1116
('addgrp', Icons["addgrp"].GetBitmap(),
1102
1117
Icons["addgrp"].GetLabel(), self.OnAddGroup),
1103
1118
('addovl', Icons["addovl"].GetBitmap(),
1104
1119
Icons["addovl"].GetLabel(), self.OnAddOverlay),
1105
('addlabels', Icons["addlabels"].GetBitmap(),
1106
Icons["addlabels"].GetLabel(), self.OnAddLabels),
1107
1120
('delcmd', Icons["delcmd"].GetBitmap(),
1108
1121
Icons["delcmd"].GetLabel(), self.OnDeleteLayer),
1109
1122
('', '', '', ''),
1240
1253
# toolBar button handlers
1241
1254
def OnAddRaster(self, event):
1255
"""Add raster map layer"""
1256
# start new map display if no display is available
1257
if not self.curr_page:
1258
self.NewDisplay(show=False)
1260
self.AddRaster(event)
1262
def OnAddRasterMisc(self, event):
1242
1263
"""Add raster menu"""
1243
1264
# start new map display if no display is available
1244
1265
if not self.curr_page:
1248
1269
rastmenu = wx.Menu()
1250
1271
# add items to the menu
1251
addrast = wx.MenuItem(rastmenu, -1, Icons["addrast"].GetLabel())
1252
addrast.SetBitmap(Icons["addrast"].GetBitmap(self.iconsize))
1253
rastmenu.AppendItem(addrast)
1254
self.Bind(wx.EVT_MENU, self.AddRaster, addrast)
1256
1272
if self.curr_page.maptree.mapdisplay.toolbars['nviz']:
1257
1273
addrast3d = wx.MenuItem(rastmenu, -1, Icons ["addrast3d"].GetLabel())
1258
1274
addrast3d.SetBitmap(Icons["addrast3d"].GetBitmap (self.iconsize))
1293
1309
self.curr_page.maptree.mapdisplay.Show()
1295
1311
def OnAddVector(self, event):
1312
"""Add vector map layer"""
1313
# start new map display if no display is available
1314
if not self.curr_page:
1315
self.NewDisplay(show=False)
1317
self.AddVector(event)
1319
def OnAddVectorMisc(self, event):
1296
1320
"""Add vector menu"""
1297
1321
# start new map display if no display is available
1298
1322
if not self.curr_page:
1301
1325
point = wx.GetMousePosition()
1302
1326
vectmenu = wx.Menu()
1304
addvect = wx.MenuItem(vectmenu, -1, Icons["addvect"].GetLabel())
1305
addvect.SetBitmap(Icons["addvect"].GetBitmap(self.iconsize))
1306
vectmenu.AppendItem(addvect)
1307
self.Bind(wx.EVT_MENU, self.AddVector, addvect)
1309
1328
addtheme = wx.MenuItem(vectmenu, -1, Icons["addthematic"].GetLabel())
1310
1329
addtheme.SetBitmap(Icons["addthematic"].GetBitmap(self.iconsize))
1311
1330
vectmenu.AppendItem(addtheme)
1333
1352
point = wx.GetMousePosition()
1334
1353
ovlmenu = wx.Menu()
1336
addgrid = wx.MenuItem(ovlmenu, -1, Icons["addgrid"].GetLabel())
1355
addgrid = wx.MenuItem(ovlmenu, wx.ID_ANY, Icons["addgrid"].GetLabel())
1337
1356
addgrid.SetBitmap(Icons["addgrid"].GetBitmap(self.iconsize))
1338
1357
ovlmenu.AppendItem(addgrid)
1339
1358
self.Bind(wx.EVT_MENU, self.AddGrid, addgrid)
1341
addgeodesic = wx.MenuItem(ovlmenu, -1, Icons["addgeodesic"].GetLabel())
1360
addlabels = wx.MenuItem(ovlmenu, wx.ID_ANY, Icons["addlabels"].GetLabel())
1361
addlabels.SetBitmap(Icons["addlabels"].GetBitmap(self.iconsize))
1362
ovlmenu.AppendItem(addlabels)
1363
self.Bind(wx.EVT_MENU, self.OnAddLabels, addlabels)
1365
addgeodesic = wx.MenuItem(ovlmenu, wx.ID_ANY, Icons["addgeodesic"].GetLabel())
1342
1366
addgeodesic.SetBitmap(Icons["addgeodesic"].GetBitmap(self.iconsize))
1343
1367
ovlmenu.AppendItem(addgeodesic)
1344
1368
self.Bind(wx.EVT_MENU, self.AddGeodesic, addgeodesic)
1346
addrhumb = wx.MenuItem(ovlmenu, -1, Icons["addrhumb"].GetLabel())
1370
addrhumb = wx.MenuItem(ovlmenu, wx.ID_ANY, Icons["addrhumb"].GetLabel())
1347
1371
addrhumb.SetBitmap(Icons["addrhumb"].GetBitmap(self.iconsize))
1348
1372
ovlmenu.AppendItem(addrhumb)
1349
1373
self.Bind(wx.EVT_MENU, self.AddRhumb, addrhumb)