GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
render.Map Class Reference

Map composition (stack of map layers and overlays) More...

Inheritance diagram for render.Map:
Collaboration diagram for render.Map:

Public Member Functions

def __init__
 
def GetProjInfo
 Get projection info. More...
 
def GetWindow
 Read WIND file and set up self.wind dictionary. More...
 
def AdjustRegion
 Adjusts display resolution to match monitor size in pixels. More...
 
def AlignResolution
 Sets display extents to even multiple of current resolution defined in WIND file from SW corner. More...
 
def AlignExtentFromDisplay
 Align region extent based on display size from center point. More...
 
def ChangeMapSize
 Change size of rendered map. More...
 
def GetRegion
 Get region settings (g.region -upgc) More...
 
def GetCurrentRegion
 Get current display region settings. More...
 
def SetRegion
 Render string for GRASS_REGION env. More...
 
def GetListOfLayers
 Returns list of layers of selected properties or list of all layers. More...
 
def Render
 Creates final image composite. More...
 
def AddLayer
 Adds generic map layer to list of layers. More...
 
def DeleteLayer
 Removes layer from list of layers. More...
 
def ReorderLayers
 Reorder list to match layer tree. More...
 
def ChangeLayer
 Change map layer properties. More...
 
def ChangeOpacity
 Changes opacity value of map layer. More...
 
def ChangeLayerActive
 Enable or disable map layer. More...
 
def ChangeLayerName
 Change name of the layer. More...
 
def RemoveLayer
 Removes layer from layer list. More...
 
def GetLayerIndex
 Get index of layer in layer list. More...
 
def AddOverlay
 Adds overlay (grid, barscale, legend, etc.) to list of overlays. More...
 
def ChangeOverlay
 Change overlay properities. More...
 
def GetOverlay
 Return overlay(s) with 'id'. More...
 
def DeleteOverlay
 Delete overlay. More...
 
def Clean
 Clean layer stack - go trough all layers and remove them from layer list. More...
 
def ReverseListOfLayers
 Reverse list of layers. More...
 
def RenderOverlays
 Render overlays only (for nviz) More...
 

Data Fields

 wind
 
 region
 
 width
 
 height
 
 layers
 
 overlays
 
 ovlookup
 
 env
 
 gisrc
 
 mapfile
 
 projinfo
 

Detailed Description

Map composition (stack of map layers and overlays)

Definition at line 369 of file render.py.

Constructor & Destructor Documentation

def render.Map.__init__ (   self,
  gisrc = None 
)

Definition at line 372 of file render.py.

Member Function Documentation

def render.Map.AddLayer (   self,
  type,
  command,
  name = None,
  l_active = True,
  l_hidden = False,
  l_opacity = 1.0,
  l_render = False,
  pos = -1 
)

Adds generic map layer to list of layers.

Parameters
typelayer type ('raster', 'vector', etc.)
commandGRASS command given as list
namelayer name
l_activelayer render only if True
l_hiddenlayer not displayed in layer tree if True
l_opacityopacity level range from 0(transparent) - 1(not transparent)
l_renderrender an image if True
posposition in layer list (-1 for append)
Returns
new layer on success
None on failure

Definition at line 958 of file render.py.

Referenced by render.Map.Render().

def render.Map.AddOverlay (   self,
  id,
  type,
  command,
  l_active = True,
  l_hidden = True,
  l_opacity = 1.0,
  l_render = False 
)

Adds overlay (grid, barscale, legend, etc.) to list of overlays.

Parameters
idoverlay id (PseudoDC)
typeoverlay type (barscale, legend)
commandGRASS command to render overlay
l_activeoverlay activated (True) or disabled (False)
l_hiddenoverlay is not shown in layer tree (if True)
l_renderrender an image (if True)
Returns
new layer on success None on failure

Definition at line 1160 of file render.py.

References render.Map.overlays.

Referenced by render.Map.GetLayerIndex().

def render.Map.AdjustRegion (   self)

Adjusts display resolution to match monitor size in pixels.

Maintains constant display resolution, not related to computational region. Do NOT use the display resolution to set computational resolution. Set computational resolution through g.region.

Definition at line 484 of file render.py.

References render.Map.height, render.Map.region, round, and render.Map.width.

Referenced by render.Map.SetRegion().

def render.Map.AlignExtentFromDisplay (   self)

Align region extent based on display size from center point.

Definition at line 537 of file render.py.

References render.Map.height, max, min, render.Map.projinfo, render.Map.region, and render.Map.width.

def render.Map.AlignResolution (   self)

Sets display extents to even multiple of current resolution defined in WIND file from SW corner.

This must be done manually as using the -a flag can produce incorrect extents.

Definition at line 504 of file render.py.

References render.Map.GetRegion(), render.Map.region, and round.

def render.Map.ChangeLayer (   self,
  layer,
  render = False,
  kargs 
)

Change map layer properties.

Parameters
layermap layer instance
typelayer type ('raster', 'vector', etc.)
commandGRASS command given as list
namelayer name
activelayer render only if True
hiddenlayer not displayed in layer tree if True
opacityopacity level range from 0(transparent) - 1(not transparent)
renderrender an image if True

Definition at line 1040 of file render.py.

Referenced by layertree.LayerTree.GetOptData(), and layertree.LayerTree.OnCmdChanged().

def render.Map.ChangeLayerActive (   self,
  layer,
  active 
)

Enable or disable map layer.

Parameters
layerlayer instance in layer tree
activeto be rendered (True)

Definition at line 1092 of file render.py.

def render.Map.ChangeLayerName (   self,
  layer,
  name 
)

Change name of the layer.

Parameters
layerlayer instance in layer tree
namelayer name to set up

Definition at line 1103 of file render.py.

def render.Map.ChangeMapSize (   self,
  width,
  height 
)

Change size of rendered map.

Parameters
width,heightmap size given as tuple
Returns
True on success
False on failure

Definition at line 563 of file render.py.

References render.Map.GetRegion(), render.Map.height, and render.Map.width.

def render.Map.ChangeOpacity (   self,
  layer,
  l_opacity 
)

Changes opacity value of map layer.

Parameters
layerlayer instance in layer tree
l_opacityopacity level <0;1>

Definition at line 1078 of file render.py.

def render.Map.ChangeOverlay (   self,
  id,
  render = False,
  kargs 
)

Change overlay properities.

Add new overlay if overlay with 'id' doesn't exist.

Parameters
idoverlay id (PseudoDC)
typeoverlay type (barscale, legend)
commandGRASS command to render overlay
l_activeoverlay activated (True) or disabled (False)
l_hiddenoverlay is not shown in layer tree (if True)
l_renderrender an image (if True)
Returns
new layer on success

Definition at line 1187 of file render.py.

References render.Map.GetOverlay().

def render.Map.Clean (   self)

Clean layer stack - go trough all layers and remove them from layer list.

Removes also l_mapfile and l_maskfile

Returns
False on failure
True on success

Definition at line 1259 of file render.py.

References render.Map.layers, render.Layer.mapfile, render.Map.mapfile, render.Map.overlays, and utils.split().

def render.Map.DeleteLayer (   self,
  layer,
  overlay = False 
)

Removes layer from list of layers.

Parameters
layerlayer instance in layer tree
overlaydelete overlay (use self.DeleteOverlay() instead)
Returns
removed layer on success or None

Definition at line 995 of file render.py.

References render.Map.layers, and render.Map.overlays.

Referenced by render.Map.DeleteOverlay().

def render.Map.DeleteOverlay (   self,
  overlay 
)

Delete overlay.

Parameters
overlayoverlay layer
Returns
removed overlay on success or None

Definition at line 1250 of file render.py.

References render.Map.DeleteLayer().

def render.Map.GetCurrentRegion (   self)

Get current display region settings.

See Also
GetRegion()

Definition at line 685 of file render.py.

References render.Map.region.

def render.Map.GetLayerIndex (   self,
  layer,
  overlay = False 
)

Get index of layer in layer list.

Parameters
layerlayer instace in layer tree
overlayuse list of overlays instead
Returns
layer index
-1 if layer not found

Definition at line 1140 of file render.py.

References render.Map.AddOverlay(), render.Map.layers, and mapwindow.GLWindow.overlay.

def render.Map.GetListOfLayers (   self,
  l_type = None,
  l_mapset = None,
  l_name = None,
  l_active = None,
  l_hidden = None 
)

Returns list of layers of selected properties or list of all layers.

Parameters
l_typelayer type, e.g. raster/vector/wms/overlay (value or tuple of values)
l_mapsetall layers from given mapset (only for maplayers)
l_nameall layers with given name
l_activeonly layers with 'active' attribute set to True or False
l_hiddenonly layers with 'hidden' attribute set to True or False
Returns
list of selected layers

Definition at line 763 of file render.py.

References render.Map.layers, render.Map.overlays, and dialogs.type.

Referenced by render.Map.SetRegion().

def render.Map.GetOverlay (   self,
  id,
  list = False 
)

Return overlay(s) with 'id'.

Parameters
idoverlay id
listreturn list of overlays of True otherwise suppose 'id' to be unique
Returns
list of overlays (list=True)
overlay (list=False) None (list=False) if no overlay or more overlays found

Definition at line 1226 of file render.py.

References render.Map.overlays.

Referenced by render.Map.ChangeOverlay(), mapwindow.BufferedWindow.SaveToFile(), and mapwindow.BufferedWindow.UpdateMap().

def render.Map.GetProjInfo (   self)

Get projection info.

Definition at line 431 of file render.py.

References render.Map._runCommand(), and render.Map.projinfo.

def render.Map.GetRegion (   self,
  rast = [],
  zoom = False,
  vect = [],
  regionName = None,
  n = None,
  s = None,
  e = None,
  w = None,
  default = False,
  update = False 
)

Get region settings (g.region -upgc)

Optionally extent, raster or vector map layer can be given.

Parameters
rastlist of raster maps
zoomzoom to raster map (ignore NULLs)
vectlist of vector maps
regionNamenamed region or None
n,s,e,wforce extent
defaultforce default region settings
updateif True update current display region settings
Returns
region settings as directory, e.g. { 'n':'4928010', 's':'4913700', 'w':'589980',...}
See Also
GetCurrentRegion()

Definition at line 587 of file render.py.

References render.Map.gisrc, render.Map.region, and gcmd.RunCommand().

Referenced by render.Map.AlignResolution(), render.Map.ChangeMapSize(), and render.Map.SetRegion().

def render.Map.RemoveLayer (   self,
  name = None,
  id = None 
)

Removes layer from layer list.

Layer is defined by name or id.

Parameters
namelayer name (must be unique)
idlayer index in layer list
Returns
removed layer on success
None on failure

Definition at line 1113 of file render.py.

References render.Map.layers.

def render.Map.Render (   self,
  force = False,
  mapWindow = None,
  windres = False 
)

Creates final image composite.

This function can conditionaly use high-level tools, which should be avaliable in wxPython library

Parameters
forceforce rendering
referencefor MapFrame instance (for progress bar)
windresuse region resolution (True) otherwise display resolution
Returns
name of file with rendered image or None

Definition at line 861 of file render.py.

References render.Map._renderLayers(), render.Map.AddLayer(), render.Map.gisrc, render.Map.height, render.Layer.mapfile, render.Map.mapfile, gcmd.RunCommand(), render.Map.SetRegion(), and render.Map.width.

def render.Map.RenderOverlays (   self,
  force 
)

Render overlays only (for nviz)

Definition at line 1300 of file render.py.

References render.Map.overlays.

def render.Map.ReorderLayers (   self,
  layerList 
)

Reorder list to match layer tree.

Parameters
layerListlist of layers

Definition at line 1026 of file render.py.

References render.Map.layers.

def render.Map.ReverseListOfLayers (   self)

Reverse list of layers.

Definition at line 1296 of file render.py.

def render.Map.SetRegion (   self,
  windres = False 
)

Render string for GRASS_REGION env.

variable, so that the images will be rendered from desired zoom level.

Parameters
windresuses resolution from WIND file rather than display (for modules that require set resolution like d.rast.num)
Returns
String usable for GRASS_REGION variable or None

Definition at line 692 of file render.py.

References render.Map.AdjustRegion(), render.Map.GetListOfLayers(), render.Map.GetRegion(), render.Map.region, and render.Map.wind.

Referenced by render.Map.Render().

Field Documentation

render.Map.env

Definition at line 387 of file render.py.

Referenced by render.Map.GetWindow().

render.Map.gisrc

Definition at line 389 of file render.py.

Referenced by render.Map.GetRegion(), and render.Map.Render().

render.Map.ovlookup

Definition at line 383 of file render.py.

render.Map.projinfo

Definition at line 405 of file render.py.

Referenced by render.Map.AlignExtentFromDisplay(), and render.Map.GetProjInfo().


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