GRASS Programmer's Manual  6.5.svn(2012)-r51648
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
mapwindow.MapWindow Class Reference

Abstract map display window class. More...

Inheritance diagram for mapwindow.MapWindow:

Public Member Functions

def __init__
def RegisterMouseEventHandler
 Binds event handler.
def UnregisterMouseEventHandler
 Unbinds event handler a restores previous state.
def Pixel2Cell
def Cell2Pixel
def OnMotion
 Tracks mouse motion and update statusbar.
def GetLastEN
 Returns last coordinates of mouse cursor.
def GetLayerByName
 Get layer from layer tree by nam.
def GetSelectedLayer
 Get selected layer from layer tree.

Data Fields

 parent
 Map
 tree
 lmgr
 mouse
 lastEN

Detailed Description

Abstract map display window class.

Superclass for BufferedWindow class (2D display mode), and GLWindow (3D display mode).

Subclasses have to define

  • _bindMouseEvents method which binds MouseEvent handlers
  • Pixel2Cell
  • Cell2Pixel (if it is possible)

Definition at line 23 of file gui_core/mapwindow.py.


Constructor & Destructor Documentation

def mapwindow.MapWindow.__init__ (   self,
  parent,
  id = wx.ID_ANY,
  Map = None,
  tree = None,
  lmgr = None,
  kwargs 
)

Definition at line 36 of file gui_core/mapwindow.py.


Member Function Documentation

Returns last coordinates of mouse cursor.

See also:
OnMotion

Definition at line 162 of file gui_core/mapwindow.py.

References mapwindow.MapWindow.lastEN.

def mapwindow.MapWindow.GetLayerByName (   self,
  name,
  mapType,
  dataType = 'layer' 
)

Get layer from layer tree by nam.

Parameters:
namelayer name
type'item' / 'layer' / 'nviz'
Returns:
layer / map layer properties / nviz properties
None

Definition at line 169 of file gui_core/mapwindow.py.

References workspace.ProcessWorkspaceFile.tree, mapwindow.MapWindow.tree, menudata.MenuData.tree, mapdisplay.MapFrame.tree, ghelp.MenuTreeWindow.tree, and model.ProcessModelFile.tree.

def mapwindow.MapWindow.GetSelectedLayer (   self,
  type = 'layer',
  multi = False 
)

Get selected layer from layer tree.

Parameters:
type'item' / 'layer' / 'nviz'
multireturn first selected layer or all
Returns:
layer / map layer properties / nviz properties
None / [] on failure

Definition at line 196 of file gui_core/mapwindow.py.

References workspace.ProcessWorkspaceFile.tree, mapwindow.MapWindow.tree, menudata.MenuData.tree, mapdisplay.MapFrame.tree, ghelp.MenuTreeWindow.tree, and model.ProcessModelFile.tree.

Referenced by mapwindow.GLWindow.DoPaint(), mapwindow.GLWindow.LoadRaster3d(), mapwindow.GLWindow.LoadVector(), mapwindow.GLWindow.OnLeftUp(), mapwindow.BufferedWindow.OnLeftUp(), and mapwindow.BufferedWindow.ZoomToMap().

def mapwindow.MapWindow.OnMotion (   self,
  event 
)

Tracks mouse motion and update statusbar.

See also:
GetLastEN

Definition at line 140 of file gui_core/mapwindow.py.

References mapwindow.VDigitWindow._onMotion(), mapwindow.MapWindow.lastEN, and mapwindow.MapWindow.Pixel2Cell().

Referenced by mapwindow.GLWindow.StopTimer().

def mapwindow.MapWindow.RegisterMouseEventHandler (   self,
  event,
  handler,
  cursor = None 
)

Binds event handler.

Call event.Skip() in handler to allow default processing in MapWindow.

# your class methods
def OnButton(self, event):
    # current map display's map window
    # expects LayerManager to be the parent
    self.mapwin = self.parent.GetLayerTree().GetMapDisplay().GetWindow()
    if self.mapwin.RegisterMouseEventHandler(wx.EVT_LEFT_DOWN, self.OnMouseAction,
                                     wx.StockCursor(wx.CURSOR_CROSS)):
self.parent.GetLayerTree().GetMapDisplay().Raise()
    else:
# handle that you cannot get coordinates

def OnMouseAction(self, event):
    # get real world coordinates of mouse click
    coor = self.mapwin.Pixel2Cell(event.GetPositionTuple()[:])
    self.text.SetLabel('Coor: ' + str(coor))
    self.mapwin.UnregisterMouseEventHandler(wx.EVT_LEFT_DOWN)
    event.Skip()
Parameters:
eventone of mouse events
handlerfunction to handle event
cursorcursor which temporary overrides current cursor
Returns:
True if successful
False if event cannot be bind

Definition at line 56 of file gui_core/mapwindow.py.

References mapwindow.MapWindow._overriddenCursor, and mapwindow.MapWindow.mouse.

Unbinds event handler a restores previous state.

You should unbind to restore normal MapWindow behaviour. Note that this operation will unbind any other external (non-MapWindow) handlers.

Parameters:
eventevent to unbind
Returns:
True if successful
False if event cannot be unbind

Definition at line 105 of file gui_core/mapwindow.py.

References mapwindow.BufferedWindow._bindMouseEvents(), mapwindow.GLWindow._bindMouseEvents(), mapwindow.MapWindow._overriddenCursor, and mapwindow.MapWindow.mouse.


Field Documentation

Reimplemented in mapwindow.GLWindow.

Definition at line 44 of file gui_core/mapwindow.py.

Referenced by frame.PsMapBufferedWindow.ComputeZoom(), mapwindow.GLWindow.DragItem(), mapwindow.GLWindow.FocusPanning(), mapwindow.GLWindow.HorizontalPanning(), mapwindow.BufferedWindow.MouseDraw(), mapwindow.BufferedWindow.OnButtonDClick(), frame.PsMapBufferedWindow.OnButtonDClick(), mapwindow.GLWindow.OnDClick(), mapwindow.GLWindow.OnDragging(), mapwindow.BufferedWindow.OnDragging(), frame.PsMapBufferedWindow.OnDragging(), mapwindow.GLWindow.OnKeyDown(), mapwindow.GLWindow.OnKeyUp(), mapwindow.GLWindow.OnLeftDown(), mapwindow.BufferedWindow.OnLeftDown(), frame.PsMapBufferedWindow.OnLeftDown(), mapwindow.VDigitWindow.OnLeftDownAddLine(), mapwindow.VDigitWindow.OnLeftDownDisplayCA(), mapwindow.VDigitWindow.OnLeftDownEditLine(), mapwindow.VDigitWindow.OnLeftDownUndo(), mapwindow.GLWindow.OnLeftUp(), mapwindow.BufferedWindow.OnLeftUp(), frame.PsMapBufferedWindow.OnLeftUp(), mapwindow.VDigitWindow.OnLeftUpConnectLine(), mapwindow.VDigitWindow.OnLeftUpCopyLine(), mapwindow.VDigitWindow.OnLeftUpModifyLine(), mapwindow.VDigitWindow.OnLeftUpVarious(), mapwindow.BufferedWindow.OnMiddleDown(), frame.PsMapBufferedWindow.OnMiddleDown(), mapwindow.BufferedWindow.OnMiddleUp(), mapwindow.BufferedWindow.OnMouseMoving(), frame.PsMapBufferedWindow.OnMouseMoving(), frame.PsMapBufferedWindow.OnMouseWheel(), mapwindow.BufferedWindow.OnRightDown(), mapwindow.BufferedWindow.OnRightUp(), mapwindow.GLWindow.OnTimerFly(), mapwindow.MapWindow.RegisterMouseEventHandler(), mapwindow.MapWindow.UnregisterMouseEventHandler(), and mapwindow.BufferedWindow.UpdateMap().


The documentation for this class was generated from the following file: