[GRASS-SVN] r42862 - grass-addons/gui/wxpython/data_catalog
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 20 08:14:45 EDT 2010
Author: rashadkm
Date: 2010-07-20 12:14:44 +0000 (Tue, 20 Jul 2010)
New Revision: 42862
Modified:
grass-addons/gui/wxpython/data_catalog/LayerTree.py
grass-addons/gui/wxpython/data_catalog/TODO
grass-addons/gui/wxpython/data_catalog/catalog.py
grass-addons/gui/wxpython/data_catalog/mapdisplay.py
Log:
added keymap browsing/panning feature to data catalog
Modified: grass-addons/gui/wxpython/data_catalog/LayerTree.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-07-20 12:12:36 UTC (rev 42861)
+++ grass-addons/gui/wxpython/data_catalog/LayerTree.py 2010-07-20 12:14:44 UTC (rev 42862)
@@ -10,7 +10,9 @@
import gdialogs
from preferences import globalSettings as UserSettings
from vdigit import haveVDigit
-from gcmd import GMessage
+grassversion = os.getenv("GRASS_VERSION")
+if grassversion.rfind("6.4") != 0:
+ from gcmd import GMessage
import histogram
import gui_modules.profile as profile
@@ -38,13 +40,15 @@
import utils
from grass.script import core as grass
-import gui_modules.layertree as layertree
+if grassversion.rfind("6.4") != 0:
+ from gui_modules.layertree import LayerTree as layertree
+else:
+ from gui_modules.wxgui_utils import LayerTree as layertree
+class LayerTree(layertree):
-class LayerTree(layertree.LayerTree):
-
def __init__(self, parent,
id=wx.ID_ANY, pos=wx.DefaultPosition,
size=(300,300), style=wx.SUNKEN_BORDER,
@@ -191,12 +195,14 @@
self.Bind(wx.EVT_TREE_END_DRAG, self.OnEndDrag)
self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
self.Bind(wx.EVT_IDLE, self.OnIdle)
+ self.addon = os.getenv("integrated-gui")
def Minimal(self,item):
+ print "here"
mnuCopy = self.popupMenu.Append(self.ID_COPY,'&Copy Map\tCtrl+C')
mnuRename = self.popupMenu.Append(self.ID_REN,'&Rename Map\tCtrl-R')
mnuDel = self.popupMenu.Append(self.ID_DEL,'&Delete Map\tDEL')
@@ -205,19 +211,23 @@
mnuOssim = self.popupMenu.Append(self.ID_OSSIM2,'&Remove from OssimPlanet')
-
+
def OnLayerContextMenu (self, event):
"""!Contextual menu for item/layer"""
if not self.layer_selected:
event.Skip()
return
-
+
self.popupMenu = wx.Menu()
item = event.GetItem()
if self.IsItemChecked(item) == False:
- self.Minimal(item)
+
+ if self.addon == "True":
+ self.Minimal(item)
else:
- self.Minimal(item)
+
+ if self.addon == "True":
+ self.Minimal(item)
ltype = self.GetPyData(self.layer_selected)[0]['type']
Debug.msg (4, "LayerTree.OnContextMenu: layertype=%s" % \
@@ -528,6 +538,19 @@
ret = dlg.ShowModal()
if ret == wx.ID_YES:
dlg.Destroy()
+ mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
+ mltype = self.GetPyData(self.layer_selected)[0]['type']
+
+ if mltype == 'raster':
+ cmd = ['g.remove rast=']
+ elif mltype == 'vector':
+ cmd = ['g.remove vect=']
+ cmd.append('%s' % mapLayer.name)
+
+ # print output to command log area
+ self.lmgr.goutput.RunCmd(cmd, switchPage=True)
+
+
parent =self.GetItemParent(item)
if self.GetItemText(parent) == "Raster Map" :
cmdflag = 'rast=' + str(self.GetItemText(item))
Modified: grass-addons/gui/wxpython/data_catalog/TODO
===================================================================
--- grass-addons/gui/wxpython/data_catalog/TODO 2010-07-20 12:12:36 UTC (rev 42861)
+++ grass-addons/gui/wxpython/data_catalog/TODO 2010-07-20 12:14:44 UTC (rev 42862)
@@ -1,3 +1,2 @@
def onossim
def onossim2
-def ondeletemap
Modified: grass-addons/gui/wxpython/data_catalog/catalog.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/catalog.py 2010-07-20 12:12:36 UTC (rev 42861)
+++ grass-addons/gui/wxpython/data_catalog/catalog.py 2010-07-20 12:14:44 UTC (rev 42862)
@@ -29,6 +29,10 @@
import platform
import shlex
+
+#os.system("export integ=True")
+os.environ['integrated-gui'] = "True"
+
try:
import xml.etree.ElementTree as etree
except ImportError:
@@ -94,10 +98,11 @@
import gui_modules.dbm as dbm
import gui_modules.workspace as workspace
import gui_modules.colorrules as colorrules
-import gui_modules.vclean as vclean
+
+#import gui_modules.vclean as vclean
import gui_modules.nviz_tools as nviz_tools
-if grassversion != "6.4.0svn":
+if grassversion.rfind("6.4") != 0:
import gui_modules.menu as menu
import gui_modules.gmodeler as gmodeler
@@ -114,10 +119,11 @@
from preferences import globalSettings as UserSettings
import render
import gc
-from gui_modules.ghelp import MenuTreeWindow
-from gui_modules.ghelp import AboutWindow
-from gui_modules.toolbars import LayerManagerToolbar
-from gui_modules.ghelp import InstallExtensionWindow
+if grassversion.rfind("6.4") != 0:
+ from gui_modules.ghelp import MenuTreeWindow
+ from gui_modules.ghelp import AboutWindow
+ from gui_modules.toolbars import LayerManagerToolbar
+ from gui_modules.ghelp import InstallExtensionWindow
from wxgui import GMFrame
from grass.script import core as grass
@@ -127,7 +133,6 @@
def __init__(self, parent=None, id=wx.ID_ANY, title=_("Data Catalog Beta"),
workspace=None,size=wx.DefaultSize,pos=wx.DefaultPosition):
-
self.iconsize = (16, 16)
self.baseTitle = title
self.parent = parent
@@ -159,14 +164,20 @@
self.dialogs = dict()
self.dialogs['preferences'] = None
self.dialogs['atm'] = list()
+
+ #print os.getenv("integrated-gui")
# creating widgets
- self.menubar = menu.Menu(parent = self, data = menudata.ManagerData())
- self.SetMenuBar(self.menubar)
- self.menucmd = self.menubar.GetCmd()
+ if grassversion.rfind("6.4") != 0:
+ self.menubar = menu.Menu(parent = self, data = menudata.ManagerData())
+ self.SetMenuBar(self.menubar)
+ self.menucmd = self.menubar.GetCmd()
self.statusbar = self.CreateStatusBar(number=1)
self.notebook = self.__createNoteBook()
- self.toolbar = LayerManagerToolbar(parent = self)
+ if grassversion.rfind("6.4") != 0:
+ self.toolbar = LayerManagerToolbar(parent = self)
+ else:
+ self.toolbar = self.__createToolBar()
self.SetToolBar(self.toolbar)
@@ -189,13 +200,13 @@
self.loclist.sort()
#self.pg_panel4 = None
- if grassversion != "6.4.0svn":
+ if grassversion.rfind("6.4") != 0:
self.menubar = menu.Menu(parent = self, data = menudata.ManagerData())
else:
self.menubar, self.menudata = self.__createMenuBar()
self.SetMenuBar(self.menubar)
self.menucmd = self.menubar.GetCmd()
- self.statusbar = self.CreateStatusBar(number=1)
+ self.statusbar = self.CreateStatusBar(number=4, style=0)
self.notebook = self.__createNoteBook()
self.toolbar = LayerManagerToolbar(parent = self)
self.SetToolBar(self.toolbar)
@@ -239,6 +250,55 @@
self.doLayout()
+ def OnCloseWindow(self, event):
+ """!Cleanup when wxGUI is quit"""
+ if not self.curr_page:
+ self._auimgr.UnInit()
+ self.Destroy()
+ return
+ os.environ['integrated-gui'] = "False"
+ maptree = self.curr_page.maptree
+ if self.workspaceChanged and \
+ UserSettings.Get(group='manager', key='askOnQuit', subkey='enabled'):
+ if self.workspaceFile:
+ message = _("Do you want to save changes in the workspace?")
+ else:
+ message = _("Do you want to store current settings "
+ "to workspace file?")
+
+ # ask user to save current settings
+ if maptree.GetCount() > 0:
+ dlg = wx.MessageDialog(self,
+ message=message,
+ caption=_("Quit GRASS GUI"),
+ style=wx.YES_NO | wx.YES_DEFAULT |
+ wx.CANCEL | wx.ICON_QUESTION | wx.CENTRE)
+ ret = dlg.ShowModal()
+ if ret == wx.ID_YES:
+ if not self.workspaceFile:
+ self.OnWorkspaceSaveAs()
+ else:
+ self.SaveToWorkspaceFile(self.workspaceFile)
+ elif ret == wx.ID_CANCEL:
+ event.Veto()
+ dlg.Destroy()
+ return
+ dlg.Destroy()
+
+ # don't ask any more...
+ UserSettings.Set(group = 'manager', key = 'askOnQuit', subkey = 'enabled',
+ value = False)
+
+ for page in range(self.gm_cb.GetPageCount()):
+ self.gm_cb.GetPage(0).maptree.mapdisplay.OnCloseWindow(event)
+
+ self.gm_cb.DeleteAllPages()
+
+ self._auimgr.UnInit()
+ self.Destroy()
+
+
+
def __createNoteBook(self):
"""!Creates notebook widgets"""
Modified: grass-addons/gui/wxpython/data_catalog/mapdisplay.py
===================================================================
--- grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-07-20 12:12:36 UTC (rev 42861)
+++ grass-addons/gui/wxpython/data_catalog/mapdisplay.py 2010-07-20 12:14:44 UTC (rev 42862)
@@ -72,16 +72,18 @@
import utils
import gdialogs
import goutput
-import units
+grassversion = os.getenv("GRASS_VERSION")
+if grassversion.rfind("6.4") != 0:
+ import units
from grass.script import core as grass
from debug import Debug
from preferences import globalSettings as UserSettings
import dbm
-grassversion = os.getenv("GRASS_VERSION")
-if grassversion == "6.4.0.svn":
+
+if grassversion.rfind("6.4") != 0:
import dbm_dialogs
-
-from units import ConvertValue as UnitsConvertValue
+if grassversion.rfind("6.4") != 0:
+ from units import ConvertValue as UnitsConvertValue
from vdigit import GV_LINES as VDigit_Lines_Type
from vdigit import VDigitCategoryDialog
from vdigit import VDigitZBulkDialog
@@ -105,7 +107,13 @@
###
# for standalone app
cmdfilename = None
-from mapdisp_window import BufferedWindow
+if grassversion.rfind("6.4") != 0:
+ from mapdisp_window import BufferedWindow
+else:
+ from mapdisp import BufferedWindow
+
+
+from mapdisp_window import MapWindow
from mapdisp import MapFrame
class MapFrame(wx.Panel,MapFrame):
@@ -184,9 +192,55 @@
self.statusbar.SetStatusWidths([-5, -2, -1, -1])
else:
self.statusbar = self.frame.GetStatusBar()
+ self.statusbar.SetStatusWidths([-5, -2, -1, -1])
+ if grassversion.rfind("6.4") == 0:
+ self.autoRender = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY,
+ label=_("Render"))
+ self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleRender, self.autoRender)
+ self.autoRender.SetValue(UserSettings.Get(group='display', key='autoRendering', subkey='enabled'))
+ self.autoRender.SetToolTip(wx.ToolTip (_("Enable/disable auto-rendering")))
+
+ self.maskInfo = wx.StaticText(parent = self.statusbar, id = wx.ID_ANY,
+ label = '')
+ self.maskInfo.SetForegroundColour(wx.Colour(255, 0, 0))
+ self.toggleStatus = wx.Choice(self.statusbar, wx.ID_ANY,
+ choices = globalvar.MAP_DISPLAY_STATUSBAR_MODE)
+ self.toggleStatus.SetSelection(UserSettings.Get(group='display', key='statusbarMode', subkey='selection'))
+ self.statusbar.Bind(wx.EVT_CHOICE, self.OnToggleStatus, self.toggleStatus)
+ self.onRenderGauge = wx.Gauge(parent=self.statusbar, id=wx.ID_ANY,
+ range=0, style=wx.GA_HORIZONTAL)
+ self.onRenderGauge.Hide()
+
+ self.mapScale = wx.TextCtrl(parent=self.statusbar, id=wx.ID_ANY,
+ value="", style=wx.TE_PROCESS_ENTER,
+ size=(150, -1))
+ self.mapScale.Hide()
+ self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnChangeMapScale, self.mapScale)
+
+ self.compResolution = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY,
+ label=_("Constrain display resolution to computational settings"))
+ self.statusbar.Bind(wx.EVT_CHECKBOX, self.OnToggleResolution, self.compResolution)
+ self.compResolution.SetValue(UserSettings.Get(group='display', key='compResolution', subkey='enabled'))
+ self.compResolution.Hide()
+ self.compResolution.SetToolTip(wx.ToolTip (_("Constrain display resolution "
+ "to computational region settings. "
+ "Default value for new map displays can "
+ "be set up in 'User GUI settings' dialog.")))
+
+
+ self.showRegion = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY,
+ label=_("Show computational extent"))
+ self.showRegion.SetValue(False)
+ self.showRegion.Hide()
+ self.showRegion.SetToolTip(wx.ToolTip (_("Show/hide computational "
+ "region extent (set with g.region). "
+ "Display region drawn as a blue box inside the "
+ "computational region, "
+ "computational region inside a display region "
+ "as a red box).")))
self.statusbarWin = dict()
@@ -245,7 +299,8 @@
value="", style=wx.TE_PROCESS_ENTER,
size=(300, -1))
self.statusbarWin['goto'].Hide()
- self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnGoTo, self.statusbarWin['goto'])
+ if grassversion.rfind("6.4") != 0:
+ self.statusbar.Bind(wx.EVT_TEXT_ENTER, self.OnGoTo, self.statusbarWin['goto'])
# projection
self.statusbarWin['projection'] = wx.CheckBox(parent=self.statusbar, id=wx.ID_ANY,
@@ -289,6 +344,8 @@
self.lmgr= frame
+
+
self.maptree = LayerTree(self, id=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS
|wx.TR_LINES_AT_ROOT|wx.TR_HIDE_ROOT,
@@ -298,13 +355,15 @@
self.tree=self.maptree
+ if grassversion.rfind("6.4") == 0:
+ self.MapWindow2D = BufferedWindow(self, id=wx.ID_ANY,Map=self.Map, tree=self.tree, gismgr=self.gismanager)
+ else:
+ self.MapWindow2D = BufferedWindow(self, id=wx.ID_ANY, Map=self.Map, tree=self.tree, lmgr=self._layerManager)
- self.MapWindow2D = BufferedWindow(self, id=wx.ID_ANY, Map=self.Map, tree=self.tree, lmgr=self._layerManager)
-
self.tree.MapWindow = self.MapWindow2D
# default is 2D display mode
self.MapWindow = self.MapWindow2D
- self.MapWindow.Bind(wx.EVT_MOTION, self.OnMotion)
+# self.MapWindow.Bind(wx.EVT_MOTION, MapWindow.OnMotion)
#self.MapWindow.Bind(wx.EVT_LEFT_DOWN, self.OnClick)
self.MapWindow.SetCursor(self.cursors["default"])
# used by Nviz (3D display mode)
@@ -380,17 +439,117 @@
"be set up in 'User GUI settings' dialog.")))
- #self.maptree.SetBackgroundColour("red")
+
+ self.p = wx.Panel(self)
+ #hb = wx.BoxSizer(wx.HORIZONTAL)
+
+ self.p.Bind(wx.EVT_PAINT,self.onPaint)
+
+
+ self.p.Bind(wx.EVT_LEFT_DOWN,self.OnButtonDClick)
+
+
+ self.p.Bind(wx.EVT_MOTION, self.move)
+ self.moveFlag = False
+
+ self._mgr.AddPane(self.p, wx.aui.AuiPaneInfo().Right().
+ Dockable(True).BestSize((400,300)).
+ CloseButton(True).DestroyOnClose(True).
+ Layer(0).Caption("KeyMap"))
+
+
+
+
self._mgr.AddPane(self.maptree, wx.aui.AuiPaneInfo().Left().
Dockable(False).BestSize((400,300)).
CloseButton(False).DestroyOnClose(True).
Layer(0).Caption("Map Tree"))
+
+ self.previous = [0,0]
+ self.current = [0,0]
+
+
self._mgr.Update()
#r.rightSizer.Add(self.maptree)
+ def OnButtonDClick(self,event):
+
+ try:
+ e, n = event.GetPositionTuple()
+ #print e,n
+
+ except AttributeError:
+ return
+
+ self.paintwindow((e-50),(n-37),100,75,"/tmp/keymap.ppm")
+ begin = e,n
+ if self.moveFlag == False:
+ self.moveFlag=True
+ self.current = event.GetPositionTuple()[:]
+
+
+ else:
+ self.moveFlag = False
+ self.previous = event.GetPositionTuple()[:]
+ #print self.current
+ #print self.previous
+ move = (self.current[0] - self.previous[0],
+ self.current[1] - self.previous[1])
+ self.MapWindow.DragMap(move)
+
+
+
+
+
+ def move(self,event):
+ #print "here"
+ if self.moveFlag == True:
+ e,n = event.GetPosition()
+ self.paintwindow((e-50),(n-37),100,75,"/tmp/keymap.ppm")
+
+
+
+ def onPaint(self,event):
+ #print "here"
+ if self.MapWindow.mapfile is not None:
+ cmd = 'cp ' + self.MapWindow.mapfile + ' '+ '/tmp/keymap.ppm'
+ os.system(cmd)
+ self.paintwindow(50,50,100,75,"/tmp/keymap.ppm")
+
+ def paintwindow(self,x,y,length,breadth,imageFile):
+ #imageFile = "/home/rashad/keymap.png"
+ #self.dc = wx.PaintDC(self.p)
+
+ try:
+ png = wx.Image(_(imageFile), wx.BITMAP_TYPE_ANY).Scale(210,160,wx.IMAGE_QUALITY_HIGH)
+ except:
+ pass
+
+ #self.hbitmap = wx.StaticBitmap(self.p, -1, png, (10, 5), (50,50))
+ #self.hbitmap.SetCursor(wx.StockCursor(wx.CURSOR_MAGNIFIER))
+
+
+ self.wxbmp=png.ConvertToBitmap()
+ #self.wxbmp.Bind(wx.EVT_MOTION, self.move)
+ #self.dc.DrawBitmap(self.wxbmp, 0,0, True)
+ #self.dc.SetPen(wx.Pen("RED",style=wx.TRANSPARENT))
+ self.dc = wx.PaintDC(self.p)
+ self.dc.Clear()
+ self.dc.BeginDrawing()
+ self.dc.SetPen(wx.Pen("RED"))
+ self.dc.SetBrush(wx.Brush("WHITE",style=wx.TRANSPARENT))
+
+ self.dc.DrawBitmap(self.wxbmp, 0,0, True)
+ # set x, y, w, h for rectangle
+ #self.dc.DrawLine(10,10,30, 30)
+ self.dc.EndDrawing()
+
+ #self.dc.SetBrush(wx.Brush("RED"))
+ self.dc.DrawRectangle(x, y, length, breadth)
+
def read_gisrc(self):
"""
Read variables gisrc file
More information about the grass-commit
mailing list