2 @package mapdisp.statusbar 
    4 @brief Classes for statusbar management 
    7  - statusbar::SbException 
   11  - statusbar::SbShowRegion 
   12  - statusbar::SbAlignExtent 
   13  - statusbar::SbResolution 
   14  - statusbar::SbMapScale 
   16  - statusbar::SbProjection 
   18  - statusbar::SbTextItem 
   19  - statusbar::SbDisplayGeometry 
   20  - statusbar::SbCoordinates 
   21  - statusbar::SbRegionExtent 
   22  - statusbar::SbCompRegionExtent 
   23  - statusbar::SbProgress 
   25 (C) 2006-2011 by the GRASS Development Team 
   27 This program is free software under the GNU General Public License 
   28 (>=v2). Read the file COPYING that comes with GRASS for details. 
   30 @author Vaclav Petras <wenzeslaus gmail.com> 
   31 @author Anna Kratochvilova <kratochanna gmail.com> 
   36 from core          
import utils
 
   37 from core.gcmd     import GMessage, RunCommand
 
   43     """! Exception class used in SbManager and SbItems""" 
   51     """!Statusbar manager for wx.Statusbar and SbItems. 
   53     Statusbar manager manages items added by AddStatusbarItem method. 
   54     Provides progress bar (SbProgress) and choice (wx.Choice). 
   55     Items with position 0 are shown according to choice selection. 
   56     Only one item of the same class is supposed to be in statusbar. 
   57     Manager user have to create statusbar on his own, add items to manager 
   58     and call Update method to show particular widgets. 
   59     User settings (group = 'display', key = 'statusbarMode', subkey = 'selection') 
   60     are taken into account. 
   62     @todo generalize access to UserSettings (specify group, etc.)  
   63     @todo add GetMode method using name instead of index 
   66         """!Connects manager to statusbar 
   68         Creates choice and progress bar. 
   86         """!Sets property represented by one of contained SbItems 
   88         @param name name of SbItem (from name attribute) 
   89         @param value value to be set 
   94         """!Returns property represented by one of contained SbItems 
   96         @param name name of SbItem (from name attribute) 
  101         """!Checks whether property is represented by one of contained SbItems 
  103         @param name name of SbItem (from name attribute) 
  105         @returns True if particular SbItem is contained, False otherwise 
  112         """!Adds item to statusbar 
  114         If item position is 0, item is managed by choice. 
  116         @see AddStatusbarItemsByClass 
  119         if item.GetPosition() == 0:
 
  120             self.choice.Append(item.label, clientData = item) 
 
  123         """!Adds items to statusbar 
  125         @param itemClasses list of classes of items to be add 
  126         @param kwargs SbItem constructor parameters 
  128         @see AddStatusbarItem 
  130         for Item 
in itemClasses:
 
  131             item = 
Item(**kwargs)
 
  135         """!Hides items showed in choice 
  137         Hides items with position 0 (items showed in choice) by removing 
  140         @param itemClasses list of classes of items to be hided 
  142         @see ShowStatusbarChoiceItemsByClass 
  143         @todo consider adding similar function which would take item names 
  146         for itemClass 
in itemClasses:
 
  147             for i 
in range(0, self.choice.GetCount() - 1):
 
  148                 item = self.choice.GetClientData(i)
 
  149                 if item.__class__ == itemClass:
 
  153         for i 
in sorted(index, reverse = 
True):
 
  154             self.choice.Delete(i)
 
  157         """!Shows items showed in choice 
  159         Shows items with position 0 (items showed in choice) by adding 
  161         Items are restored in their old positions. 
  163         @param itemClasses list of classes of items to be showed 
  165         @see HideStatusbarChoiceItemsByClass 
  168         for pos 
in sorted(self._hiddenItems.keys()):
 
  170             if item.__class__ 
in itemClasses:
 
  171                 self.choice.Insert(item.label, pos, item)
 
  174         """!Invokes showing of particular item 
  181         """!Post-initialization method 
  183         It sets internal user settings, 
  184         set choice's selection (from user settings) and does reposition. 
  185         It needs choice filled by items. 
  186         it is called automatically. 
  188         UserSettings.Set(group = 
'display',
 
  189                          key = 
'statusbarMode',
 
  191                          value = self.choice.GetItems(),
 
  194         self.choice.SetSelection(UserSettings.Get(group = 
'display',
 
  195                                                   key = 
'statusbarMode',
 
  196                                                   subkey = 
'selection')) 
 
  202         """!Updates statusbar 
  204         It always updates mask. 
  209         for item 
in self.statusbarItems.values():
 
  210             if item.GetPosition() == 0:
 
  215         if self.choice.GetCount() > 0:
 
  216             item = self.choice.GetClientData(self.choice.GetSelection())
 
  220         """!Reposition items in statusbar 
  222         Set positions to all items managed by statusbar manager. 
  223         It should not be necessary to call it manually. 
  227         for item 
in self.statusbarItems.values():
 
  228             widgets.append((item.GetPosition(), item.GetWidget()))
 
  230         widgets.append((1, self.
choice))
 
  231         widgets.append((0, self.progressbar.GetWidget()))
 
  233         for idx, win 
in widgets:
 
  236             rect = self.statusbar.GetFieldRect(idx)
 
  239                 wWin, hWin = win.GetBestSize()
 
  240                 if win == self.progressbar.GetWidget():
 
  241                     wWin = rect.width - 6
 
  247                 x, y = rect.x + 3, rect.y - 1
 
  248                 w, h = wWin, rect.height + 2
 
  250                 x, y = rect.x, rect.y - 1
 
  251                 w, h = rect.width, rect.height + 2
 
  257             win.SetPosition((x, y))
 
  261         """!Returns progress bar""" 
  265         """!Toggle status text 
  270         """!Sets current mode 
  272         Mode is usually driven by user through choice. 
  274         self.choice.SetSelection(modeIndex)
 
  277         """!Returns current mode""" 
  278         return self.choice.GetSelection()
 
  281     """!Base class for statusbar items. 
  283     Each item represents functionality (or action) controlled by statusbar 
  284     and related to MapFrame. 
  285     One item is usually connected with one widget but it is not necessary. 
  286     Item can represent property (depends on manager). 
  287     Items are not widgets but can provide interface to them. 
  288     Items usually has requirements to MapFrame instance 
  289     (specified as MapFrame.methodname or MapWindow.methodname). 
  291     @todo consider externalizing position (see SbProgress use in SbManager) 
  293     def __init__(self, mapframe, statusbar, position = 0):
 
  296         @param mapframe instance of class with MapFrame interface 
  297         @param statusbar statusbar instance (wx.Statusbar) 
  298         @param position item position in statusbar 
  300         @todo rewrite Update also in derived classes to take in account item position 
  307         """!Invokes showing of underlying widget. 
  309         In derived classes it can do what is appropriate for it, 
  310         e.g. showing text on statusbar (only). 
  318         self.widget.SetValue(value)
 
  321         return self.widget.GetValue()
 
  327         """!Returns underlaying winget. 
  329         @return widget or None if doesn't exist 
  333     def _update(self, longHelp):
 
  334         """!Default implementation for Update method. 
  336         @param longHelp True to enable long help (help from toolbars) 
  338         self.statusbar.SetStatusText(
"", 0)
 
  340         self.mapFrame.StatusbarEnableLongHelp(longHelp)
 
  343         """!Called when statusbar action is activated (e.g. through wx.Choice). 
  348     """!Checkbox to enable and disable auto-rendering. 
  350     Requires MapFrame.OnRender method. 
  352     def __init__(self, mapframe, statusbar, position = 0):
 
  353         SbItem.__init__(self, mapframe, statusbar, position)
 
  359         self.widget.SetValue(UserSettings.Get(group = 
'display',
 
  360                                               key = 
'autoRendering',
 
  363         self.widget.SetToolTip(wx.ToolTip (_(
"Enable/disable auto-rendering")))
 
  370             self.mapFrame.OnRender(
None)
 
  376     """!Checkbox to enable and disable showing of computational region. 
  378     Requires MapFrame.OnRender, MapFrame.IsAutoRendered, MapFrame.GetWindow. 
  379     Expects that instance returned by MapFrame.GetWindow will handle 
  380     regionCoords attribute.  
  382     def __init__(self, mapframe, statusbar, position = 0):
 
  383         SbItem.__init__(self, mapframe, statusbar, position)
 
  388                                   label = _(
"Show computational extent"))
 
  390         self.widget.SetValue(
False)
 
  392         self.widget.SetToolTip(wx.ToolTip (_(
"Show/hide computational " 
  393                                              "region extent (set with g.region). " 
  394                                              "Display region drawn as a blue box inside the " 
  395                                              "computational region, " 
  396                                              "computational region inside a display region " 
  402         """!Shows/Hides extent (comp. region) in map canvas. 
  404         Shows or hides according to checkbox value. 
  406         if self.widget.GetValue():
 
  408             self.mapFrame.GetWindow().regionCoords = []
 
  409         elif hasattr(self.mapFrame.GetWindow(), 
'regionCoords'):
 
  410             del self.mapFrame.GetWindow().regionCoords
 
  413         if self.mapFrame.IsAutoRendered():
 
  414             self.mapFrame.OnRender(
None)
 
  417         SbItem.SetValue(self, value)
 
  419             self.mapFrame.GetWindow().regionCoords = []
 
  420         elif hasattr(self.mapFrame.GetWindow(), 
'regionCoords'):
 
  421             del self.mapFrame.GetWindow().regionCoords
 
  424     """!Checkbox to select zoom behavior. 
  426     Used by BufferedWindow (through MapFrame property). 
  427     See tooltip for explanation. 
  429     def __init__(self, mapframe, statusbar, position = 0):
 
  430         SbItem.__init__(self, mapframe, statusbar, position)
 
  435                                   label = _(
"Align region extent based on display size"))
 
  437         self.widget.SetValue(UserSettings.Get(group = 
'display', key = 
'alignExtent', subkey = 
'enabled'))
 
  439         self.widget.SetToolTip(wx.ToolTip (_(
"Align region extent based on display " 
  440                                              "size from center point. " 
  441                                              "Default value for new map displays can " 
  442                                              "be set up in 'User GUI settings' dialog.")))      
 
  445     """!Checkbox to select used display resolution. 
  447     Requires MapFrame.OnRender method.  
  449     def __init__(self, mapframe, statusbar, position = 0):
 
  450         SbItem.__init__(self, mapframe, statusbar, position)
 
  452         self.
label = _(
"Display resolution")
 
  455                                   label = _(
"Constrain display resolution to computational settings"))
 
  457         self.widget.SetValue(UserSettings.Get(group = 
'display', key = 
'compResolution', subkey = 
'enabled'))
 
  459         self.widget.SetToolTip(wx.ToolTip (_(
"Constrain display resolution " 
  460                                              "to computational region settings. " 
  461                                              "Default value for new map displays can " 
  462                                              "be set up in 'User GUI settings' dialog.")))
 
  467         """!Update display when toggle display mode 
  470         if self.mapFrame.IsAutoRendered():
 
  471             self.mapFrame.OnRender(
None)
 
  475     """!Editable combobox to get/set current map scale. 
  477     Requires MapFrame.GetMapScale, MapFrame.SetMapScale 
  478     and MapFrame.GetWindow (and GetWindow().UpdateMap()). 
  480     def __init__(self, mapframe, statusbar, position = 0):
 
  481         SbItem.__init__(self, mapframe, statusbar, position)
 
  486                                                     style = wx.TE_PROCESS_ENTER,
 
  489         self.widget.SetItems([
'1:1000',
 
  497         self.widget.SetToolTip(wx.ToolTip (_(
"As everyone's monitors and resolutions " 
  498                                             "are set differently these values are not " 
  499                                             "true map scales, but should get you into " 
  500                                             "the right neighborhood.")))
 
  508         scale = self.mapFrame.GetMapScale()
 
  509         self.statusbar.SetStatusText(
"")
 
  511             self.
SetValue(
"1:%ld" % (scale + 0.5))
 
  519         self.mapFrame.StatusbarEnableLongHelp(
False)
 
  522         """!Map scale changed by user 
  524         scale = event.GetString()
 
  527             if scale[:2] != 
'1:':
 
  529             value = int(scale[2:])
 
  534         self.mapFrame.SetMapScale(value)
 
  537         self.mapFrame.GetWindow().UpdateMap()
 
  542     """!Textctrl to set coordinates which to focus on. 
  544     Requires MapFrame.GetWindow, MapWindow.GoTo method. 
  547     def __init__(self, mapframe, statusbar, position = 0):
 
  548         SbItem.__init__(self, mapframe, statusbar, position)
 
  553                                                 value = 
"", style = wx.TE_PROCESS_ENTER,
 
  558         self.widget.Bind(wx.EVT_TEXT_ENTER, self.
OnGoTo)
 
  561         """!Reproject east, north from user defined projection 
  563         @param e,n coordinate (for DMS string, else float or string) 
  564         @param useDefinedProjection projection defined by user in settings dialog 
  566         @throws SbException if useDefinedProjection is True and projection is not defined in UserSettings 
  568         if useDefinedProjection:
 
  569             settings = UserSettings.Get(group = 
'projection', key = 
'statusbar', subkey = 
'proj4')
 
  571                 raise SbException(_(
"Projection not defined (check the settings)"))
 
  578                 proj = projIn.split(
' ')[0].
split(
'=')[1]
 
  579                 if proj 
in (
'll', 
'latlong', 
'longlat'):
 
  583                                                               projOut = projOut, flags = 
'd')
 
  586                     e, n = float(e), float(n)
 
  589                                                               projOut = projOut, flags = 
'd')
 
  591         elif self.mapFrame.GetMap().projinfo[
'proj'] == 
'll':
 
  594             e, n = float(e), float(n)
 
  603             self.mapFrame.GetWindow().GoTo(e, n)
 
  604             self.widget.SetFocus()
 
  607             region = self.mapFrame.GetMap().GetCurrentRegion()
 
  608             precision = int(UserSettings.Get(group = 
'projection', key = 
'format',
 
  609                                              subkey = 
'precision'))
 
  610             format = UserSettings.Get(group = 
'projection', key = 
'format',
 
  612             if self.mapFrame.GetMap().projinfo[
'proj'] == 
'll' and format == 
'DMS':
 
  614                                                                             region[
'center_northing'],
 
  615                                                                             precision = precision))
 
  618                                (precision, region[
'center_easting'],
 
  619                                 precision, region[
'center_northing']))
 
  620         except SbException, e:
 
  622             self.statusbar.SetStatusText(str(e), 0)
 
  625         """!Get current map center in appropriate format""" 
  626         region = map.GetCurrentRegion()
 
  627         precision = int(UserSettings.Get(group = 
'projection', key = 
'format',
 
  628                                          subkey = 
'precision'))
 
  629         format = UserSettings.Get(group = 
'projection', key = 
'format',
 
  631         projection = UserSettings.Get(group=
'projection', key=
'statusbar', subkey=
'proj4')
 
  633         if self.mapFrame.GetProperty(
'projection'):
 
  635                 raise SbException(_(
"Projection not defined (check the settings)"))
 
  638                                                                    region[
'center_northing']),
 
  639                                                           projOut = projection,
 
  642                     if proj 
in (
'll', 
'latlong', 
'longlat') 
and format == 
'DMS':
 
  645                                                                                 precision = precision)
 
  647                         return "%.*f; %.*f" % (precision, coord[0], precision, coord[1])
 
  649                     raise SbException(_(
"Error in projection (check the settings)"))
 
  651             if self.mapFrame.GetMap().projinfo[
'proj'] == 
'll' and format == 
'DMS':
 
  652                 return "%s" % 
utils.Deg2DMS(region[
'center_easting'], region[
'center_northing'],
 
  653                                                                       precision = precision)
 
  655                 return "%.*f; %.*f" % (precision, region[
'center_easting'], precision, region[
'center_northing'])
 
  659         """!Set current map center as item value""" 
  664         self.statusbar.SetStatusText(
"")
 
  669         except SbException, e:
 
  670             self.statusbar.SetStatusText(str(e), 0)
 
  673         self.mapFrame.StatusbarEnableLongHelp(
False)
 
  677     """!Checkbox to enable user defined projection (can be set in settings)""" 
  678     def __init__(self, mapframe, statusbar, position = 0):
 
  679         SbItem.__init__(self, mapframe, statusbar, position)
 
  688         self.widget.SetValue(
False)
 
  691         size = self.widget.GetSize()
 
  692         self.widget.SetMinSize((size[0] + 150, size[1]))
 
  695         self.widget.SetToolTip(wx.ToolTip (_(
"Reproject coordinates displayed " 
  696                                              "in the statusbar. Projection can be " 
  697                                              "defined in GUI preferences dialog " 
  698                                              "(tab 'Projection')")))
 
  701         self.statusbar.SetStatusText(
"")
 
  702         epsg = UserSettings.Get(group = 
'projection', key = 
'statusbar', subkey = 
'epsg')
 
  705             self.widget.SetLabel(label)
 
  711         self.mapFrame.StatusbarEnableLongHelp(
False)
 
  715     """!StaticText to show whether mask is activated.""" 
  716     def __init__(self, mapframe, statusbar, position = 0):
 
  717         SbItem.__init__(self, mapframe, statusbar, position)
 
  720         self.
widget = wx.StaticText(parent = self.
statusbar, id = wx.ID_ANY, label = _(
'MASK'))
 
  721         self.widget.SetForegroundColour(wx.Colour(255, 0, 0))
 
  725         if grass.find_file(name = 
'MASK', element = 
'cell',
 
  726                            mapset = grass.gisenv()[
'MAPSET'])[
'name']:
 
  732     """!Base class for items without widgets. 
  734     Only sets statusbar text. 
  736     def __init__(self, mapframe, statusbar, position = 0):
 
  737         SbItem.__init__(self, mapframe, statusbar, position)
 
  745         self.statusbar.SetStatusText(
"", self.
position)
 
  760     """!Show current display resolution.""" 
  761     def __init__(self, mapframe, statusbar, position = 0):
 
  762         SbTextItem.__init__(self, mapframe, statusbar, position)
 
  767         region = self.mapFrame.GetMap().GetCurrentRegion()
 
  768         self.
SetValue(
"rows=%d; cols=%d; nsres=%.2f; ewres=%.2f" %
 
  769                      (region[
"rows"], region[
"cols"],
 
  770                       region[
"nsres"], region[
"ewres"]))
 
  771         SbTextItem.Show(self)
 
  774     """!Show map coordinates when mouse moves. 
  776     Requires MapWindow.GetLastEN method.""" 
  777     def __init__(self, mapframe, statusbar, position = 0):
 
  778         SbTextItem.__init__(self, mapframe, statusbar, position)
 
  783         precision = int(UserSettings.Get(group = 
'projection', key = 
'format',
 
  784                              subkey = 
'precision'))
 
  785         format = UserSettings.Get(group = 
'projection', key = 
'format',
 
  787         projection = self.mapFrame.GetProperty(
'projection')
 
  789             e, n = self.mapFrame.GetWindow().GetLastEN()
 
  791         except SbException, e:
 
  795         except AttributeError:
 
  797         SbTextItem.Show(self)
 
  800         """!Reproject east, north to user defined projection. 
  802         @param e,n coordinate 
  804         @throws SbException if useDefinedProjection is True and projection is not defined in UserSettings 
  806         if useDefinedProjection:
 
  807             settings = UserSettings.Get(group = 
'projection', key = 
'statusbar', subkey = 
'proj4')
 
  809                 raise SbException(_(
"Projection not defined (check the settings)"))
 
  817                     if proj 
in (
'll', 
'latlong', 
'longlat') 
and format == 
'DMS':
 
  820                         return "%.*f; %.*f" % (precision, e, precision, n)
 
  822                     raise SbException(_(
"Error in projection (check the settings)"))
 
  824             if self.mapFrame.GetMap().projinfo[
'proj'] == 
'll' and format == 
'DMS':
 
  827                 return "%.*f; %.*f" % (precision, e, precision, n)
 
  830     """!Shows current display region""" 
  831     def __init__(self, mapframe, statusbar, position = 0):
 
  832         SbTextItem.__init__(self, mapframe, statusbar, position)
 
  837         precision = int(UserSettings.Get(group = 
'projection', key = 
'format',
 
  838                              subkey = 
'precision'))
 
  839         format = UserSettings.Get(group = 
'projection', key = 
'format',
 
  841         projection = self.mapFrame.GetProperty(
'projection')        
 
  846         except SbException, e:
 
  848         SbTextItem.Show(self)
 
  850     def _getRegion(self):
 
  851         """!Get current display region""" 
  852         return self.mapFrame.GetMap().GetCurrentRegion() 
 
  854     def _formatRegion(self, w, e, s, n, nsres, ewres, precision = None):
 
  855         """!Format display region string for statusbar 
  857         @param nsres,ewres unused 
  859         if precision 
is not None:
 
  860             return "%.*f - %.*f, %.*f - %.*f" % (precision, w, precision, e,
 
  861                                                  precision, s, precision, n)
 
  863             return "%s - %s, %s - %s" % (w, e, s, n)
 
  867         """!Reproject region values 
  869         @todo reorganize this method to remove code useful only for derived class SbCompRegionExtent 
  871         if useDefinedProjection:
 
  872             settings = UserSettings.Get(group = 
'projection', key = 
'statusbar', subkey = 
'proj4')
 
  875                 raise SbException(_(
"Projection not defined (check the settings)"))
 
  879                                                           projOut = projOut, flags = 
'd')
 
  881                                                           projOut = projOut, flags = 
'd')
 
  884                                                           projOut = projOut, flags = 
'd')
 
  886                                                           projOut = projOut, flags = 
'd')
 
  887                 if coord1 
and coord2:
 
  888                     if proj 
in (
'll', 
'latlong', 
'longlat') 
and format == 
'DMS':
 
  890                                              precision = precision)
 
  892                                              precision = precision)
 
  893                         ewres, nsres = 
utils.Deg2DMS(abs(coord3[0]) - abs(coord4[0]),
 
  894                                                          abs(coord3[1]) - abs(coord4[1]),
 
  895                                                          string = 
False, hemisphere = 
False,
 
  896                                                          precision = precision)
 
  897                         return self.
_formatRegion(w = w, s = s, e = e, n = n, ewres = ewres, nsres = nsres)
 
  901                         ewres, nsres = coord3
 
  902                         return self.
_formatRegion(w = w, s = s, e = e, n = n, ewres = ewres,
 
  903                                                   nsres = nsres, precision = precision)
 
  905                     raise SbException(_(
"Error in projection (check the settings)"))
 
  908             if self.mapFrame.GetMap().projinfo[
'proj'] == 
'll' and format == 
'DMS':
 
  910                                      string = 
False, precision = precision)
 
  912                                      string = 
False, precision = precision)
 
  913                 ewres, nsres = 
utils.Deg2DMS(region[
'ewres'], region[
'nsres'],
 
  914                                              string = 
False, precision = precision)
 
  915                 return self.
_formatRegion(w = w, s = s, e = e, n = n, ewres = ewres, nsres = nsres)
 
  917                 w, s = region[
"w"], region[
"s"]
 
  918                 e, n = region[
"e"], region[
"n"]
 
  919                 ewres, nsres = region[
'ewres'], region[
'nsres']
 
  920                 return self.
_formatRegion(w = w, s = s, e = e, n = n, ewres = ewres,
 
  921                                           nsres = nsres, precision = precision)
 
  925     """!Shows computational region.""" 
  926     def __init__(self, mapframe, statusbar, position = 0):
 
  927         SbRegionExtent.__init__(self, mapframe, statusbar, position)
 
  928         self.
name = 
'computationalRegion' 
  929         self.
label = _(
"Computational region")
 
  931     def _formatRegion(self, w, e, s, n, ewres, nsres, precision = None):
 
  932         """!Format computational region string for statusbar""" 
  933         if precision 
is not None:
 
  934             return "%.*f - %.*f, %.*f - %.*f (%.*f, %.*f)" % (precision, w, precision, e,
 
  935                                                               precision, s, precision, n,
 
  936                                                               precision, ewres, precision, nsres)
 
  938             return "%s - %s, %s - %s (%s, %s)" % (w, e, s, n, ewres, nsres)
 
  940     def _getRegion(self):
 
  941         """!Returns computational region.""" 
  942         return self.mapFrame.GetMap().GetRegion() 
 
  946     """!General progress bar to show progress. 
  948     Underlaying widget is wx.Gauge. 
  950     def __init__(self, mapframe, statusbar, position = 0):
 
  951         SbItem.__init__(self, mapframe, statusbar, position)
 
  956                                       range = 0, style = wx.GA_HORIZONTAL)
 
  960         """!Returns progress range.""" 
  961         return self.widget.GetRange()
 
  964         """!Sets progress range.""" 
  965         self.widget.SetRange(range)
 
  969             self.widget.SetValue(self.
GetRange())
 
  971             self.widget.SetValue(value)
 
  975     """!SpinCtrl to select GCP to focus on 
  977     Requires MapFrame.GetSrcWindow, MapFrame.GetTgtWindow, MapFrame.GetListCtrl, 
  978     MapFrame.GetMapCoordList. 
  981     def __init__(self, mapframe, statusbar, position = 0):
 
  982         SbItem.__init__(self, mapframe, statusbar, position)
 
  990         self.widget.Bind(wx.EVT_TEXT_ENTER, self.
OnGoToGCP)
 
  991         self.widget.Bind(wx.EVT_SPINCTRL, self.
OnGoToGCP)
 
  994         """!Zooms to given GCP.""" 
  996         mapCoords = self.mapFrame.GetMapCoordList()
 
  998         if GCPNo < 0 
or GCPNo > len(mapCoords): 
 
  999             GMessage(parent = self,
 
 1000                      message = 
"%s 1 - %s." % (_(
"Valid Range:"),
 
 1007         listCtrl = self.mapFrame.GetListCtrl()
 
 1009         listCtrl.selectedkey = GCPNo
 
 1010         listCtrl.selected = listCtrl.FindItemData(-1, GCPNo)
 
 1011         listCtrl.render = 
False 
 1012         listCtrl.SetItemState(listCtrl.selected,
 
 1013                           wx.LIST_STATE_SELECTED,
 
 1014                           wx.LIST_STATE_SELECTED)
 
 1015         listCtrl.render = 
True 
 1017         listCtrl.EnsureVisible(listCtrl.selected)
 
 1019         srcWin = self.mapFrame.GetSrcWindow()
 
 1020         tgtWin = self.mapFrame.GetTgtWindow()
 
 1023         begin = (mapCoords[GCPNo][1], mapCoords[GCPNo][2])
 
 1024         begin = srcWin.Cell2Pixel(begin)
 
 1026         srcWin.Zoom(begin, end, 0)
 
 1031         if self.mapFrame.GetShowTarget():
 
 1033             begin = (mapCoords[GCPNo][3], mapCoords[GCPNo][4])
 
 1034             begin = tgtWin.Cell2Pixel(begin)
 
 1036             tgtWin.Zoom(begin, end, 0)
 
 1044         self.statusbar.SetStatusText(
"")
 
 1045         max = self.mapFrame.GetListCtrl().GetItemCount()
 
 1048         self.widget.SetRange(0, max)
 
 1052         self.mapFrame.StatusbarEnableLongHelp(
False)
 
 1055     """!Shows RMS error. 
 1057     Requires MapFrame.GetFwdError, MapFrame.GetBkwError. 
 1060         SbTextItem.__init__(self, mapframe, statusbar, position)
 
 1065         self.
SetValue(_(
"Forward: %(forw)s, Backward: %(back)s") %
 
 1066                                    { 
'forw' : self.mapFrame.GetFwdError(),
 
 1067                                      'back' : self.mapFrame.GetBkwError() })
 
 1068         SbTextItem.Show(self)
 
def SetProperty
Sets property represented by one of contained SbItems. 
 
Statusbar manager for wx.Statusbar and SbItems. 
 
Base class for items without widgets. 
 
def __init__
Connects manager to statusbar. 
 
def _update
Default implementation for Update method. 
 
def OnToggleShowRegion
Shows/Hides extent (comp. 
 
StaticText to show whether mask is activated. 
 
def _postInit
Post-initialization method. 
 
def GetWidget
Returns underlaying winget. 
 
def Update
Updates statusbar. 
 
def _getRegion
Get current display region. 
 
def SetCenter
Set current map center as item value. 
 
Textctrl to set coordinates which to focus on. 
 
def SetRange
Sets progress range. 
 
def Update
Called when statusbar action is activated (e.g. 
 
def Show
Invokes showing of underlying widget. 
 
Exception class used in SbManager and SbItems. 
 
def ShowItem
Invokes showing of particular item. 
 
def AddStatusbarItem
Adds item to statusbar. 
 
Editable combobox to get/set current map scale. 
 
def split
Platform spefic shlex.split. 
 
def OnToggleStatus
Toggle status text. 
 
Checkbox to enable user defined projection (can be set in settings) 
 
def GetRange
Returns progress range. 
 
def SetMode
Sets current mode. 
 
def OnGoToGCP
Zooms to given GCP. 
 
def ReprojectRegionFromMap
Reproject region values. 
 
def GetProperty
Returns property represented by one of contained SbItems. 
 
def GetProgressBar
Returns progress bar. 
 
def OnChangeMapScale
Map scale changed by user. 
 
def HideStatusbarChoiceItemsByClass
Hides items showed in choice. 
 
Checkbox to enable and disable auto-rendering. 
 
def HasProperty
Checks whether property is represented by one of contained SbItems. 
 
def DMS2Deg
Convert dms value to deg. 
 
def OnGoTo
Go to position. 
 
SpinCtrl to select GCP to focus on. 
 
Show map coordinates when mouse moves. 
 
def OnToggleUpdateMap
Update display when toggle display mode. 
 
def Reposition
Reposition items in statusbar. 
 
Checkbox to select used display resolution. 
 
Shows computational region. 
 
def GetMode
Returns current mode. 
 
Base class for statusbar items. 
 
Shows current display region. 
 
def ShowStatusbarChoiceItemsByClass
Shows items showed in choice. 
 
Show current display resolution. 
 
General progress bar to show progress. 
 
def ReprojectENFromMap
Reproject east, north to user defined projection. 
 
def GetCenterString
Get current map center in appropriate format. 
 
def AddStatusbarItemsByClass
Adds items to statusbar. 
 
def ReprojectENToMap
Reproject east, north from user defined projection. 
 
Checkbox to select zoom behavior. 
 
def ReprojectCoordinates
Reproject coordinates. 
 
def _formatRegion
Format display region string for statusbar. 
 
Checkbox to enable and disable showing of computational region. 
 
def RunCommand
Run GRASS command. 
 
def Deg2DMS
Convert deg value to dms string.