4 @brief dialogs for wxPsMap 
    8  - dialogs::PenStyleComboBox 
    9  - dialogs::CheckListCtrl 
   10  - dialogs::PsmapDialog 
   11  - dialogs::PageSetupDialog 
   13  - dialogs::MapFramePanel 
   14  - dialogs::RasterPanel 
   15  - dialogs::VectorPanel 
   16  - dialogs::RasterDialog 
   17  - dialogs::MainVectorDialog 
   18  - dialogs::VPropertiesDialog 
   19  - dialogs::LegendDialog 
   20  - dialogs::MapinfoDialog 
   21  - dialogs::ScalebarDialog 
   23  - dialogs::ImageDialog 
   24  - dialogs::NorthArrowDialog 
   25  - dialogs::PointDialog 
   26  - dialogs::RectangleDialog 
   28 (C) 2011-2012 by Anna Kratochvilova, and the GRASS Development Team 
   30 This program is free software under the GNU General Public License 
   31 (>=v2). Read the file COPYING that comes with GRASS for details. 
   33 @author Anna Kratochvilova <kratochanna gmail.com> (bachelor's project) 
   34 @author Martin Landa <landa.martin gmail.com> (mentor) 
   40 from copy 
import deepcopy
 
   43 import wx.lib.scrolledpanel    
as scrolled
 
   44 import wx.lib.filebrowsebutton 
as filebrowse
 
   45 from wx.lib.mixins.listctrl 
import CheckListCtrlMixin, ListCtrlAutoWidthMixin
 
   46 from wx.lib.expando         
import ExpandoTextCtrl, EVT_ETC_LAYOUT_NEEDED
 
   48     import wx.lib.agw.floatspin 
as fs
 
   54 from core               
import globalvar
 
   55 from dbmgr.vinfo        
import VectorDBInfo
 
   57 from core.gcmd          import RunCommand, GError, GMessage
 
   64 PSMAP_COLORS = [
'aqua', 
'black', 
'blue', 
'brown', 
'cyan', 
'gray', 
'grey', 
'green', 
'indigo',
 
   65                 'magenta',
'orange', 
'purple', 
'red', 
'violet', 
'white', 
'yellow']
 
   69     """!validates input in textctrls, combobox, taken from wxpython demo""" 
   71         wx.PyValidator.__init__(self)
 
   73         self.Bind(wx.EVT_CHAR, self.
OnChar)
 
   83         if self.
flag == 
'DIGIT_ONLY':
 
   85                 if x 
not in string.digits:
 
   90         key = event.GetKeyCode()
 
   91         if key < wx.WXK_SPACE 
or key == wx.WXK_DELETE 
or key > 255:
 
   94         if self.
flag == 
'DIGIT_ONLY' and chr(key) 
in string.digits + 
'.-':
 
  100         if self.
flag == 
'ZERO_AND_ONE_ONLY' and chr(key) 
in '01':
 
  103         if not wx.Validator_IsSilent():
 
  111     """!Combo for selecting line style, taken from wxpython demo""" 
  116         if item == wx.NOT_FOUND:
 
  125             penStyle = wx.LONG_DASH
 
  129             penStyle = wx.DOT_DASH
 
  131         pen = wx.Pen(dc.GetTextForeground(), 3, penStyle)
 
  135         dc.DrawText(self.GetString(item ),
 
  137                     (r.y + 0) + ((r.height/2) - dc.GetCharHeight() )/2
 
  139         dc.DrawLine(r.x+5, r.y+((r.height/4)*3)+1, r.x+r.width - 5, r.y+((r.height/4)*3)+1 )
 
  143         """!Overridden from OwnerDrawnComboBox, called for drawing the 
  144         background area of each item.""" 
  147         if (item & 1 == 0 
or flags & (wx.combo.ODCB_PAINTING_CONTROL |
 
  148                                       wx.combo.ODCB_PAINTING_SELECTED)):
 
  149             wx.combo.OwnerDrawnComboBox.OnDrawBackground(self, dc, rect, item, flags)
 
  153         bgCol = wx.Colour(240,240,250)
 
  154         dc.SetBrush(wx.Brush(bgCol))
 
  155         dc.SetPen(wx.Pen(bgCol))
 
  156         dc.DrawRectangleRect(rect);
 
  159         """!Overridden from OwnerDrawnComboBox, should return the height 
  160         needed to display an item in the popup, or -1 for default""" 
  164         """!Overridden from OwnerDrawnComboBox.  Callback for item width, or 
  165         -1 for default/undetermined""" 
  169 class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin, ListCtrlAutoWidthMixin):
 
  170     """!List control for managing order and labels of vector maps in legend""" 
  172         wx.ListCtrl.__init__(self, parent, id = wx.ID_ANY, 
 
  173                              style = wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.BORDER_SUNKEN|wx.LC_VRULES|wx.LC_HRULES)
 
  174         CheckListCtrlMixin.__init__(self) 
 
  175         ListCtrlAutoWidthMixin.__init__(self)
 
  179     def __init__(self, parent, id,  title, settings, apply = True):
 
  180         wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, 
 
  181                             title = title, size = wx.DefaultSize,
 
  182                             style = wx.CAPTION|wx.MINIMIZE_BOX|wx.CLOSE_BOX)
 
  191         self.Bind(wx.EVT_CLOSE, self.OnClose)
 
  196         parent.units = dict()
 
  197         parent.units[
'unitsLabel'] = wx.StaticText(parent, id = wx.ID_ANY, label = _(
"Units:"))
 
  198         choices = self.unitConv.getPageUnitsNames()
 
  199         parent.units[
'unitsCtrl'] = wx.Choice(parent, id = wx.ID_ANY, choices = choices)  
 
  200         parent.units[
'unitsCtrl'].SetStringSelection(self.unitConv.findName(dialogDict[
'unit']))
 
  203         if not hasattr(parent, 
"position"):
 
  204             parent.position = dict()
 
  205         parent.position[
'comment'] = wx.StaticText(parent, id = wx.ID_ANY,\
 
  206                     label = _(
"Position of the top left corner\nfrom the top left edge of the paper"))
 
  207         parent.position[
'xLabel'] = wx.StaticText(parent, id = wx.ID_ANY, label = _(
"X:"))
 
  208         parent.position[
'yLabel'] = wx.StaticText(parent, id = wx.ID_ANY, label = _(
"Y:"))
 
  209         parent.position[
'xCtrl'] = wx.TextCtrl(parent, id = wx.ID_ANY, value = str(dialogDict[
'where'][0]), validator = 
TCValidator(flag = 
'DIGIT_ONLY'))
 
  210         parent.position[
'yCtrl'] = wx.TextCtrl(parent, id = wx.ID_ANY, value = str(dialogDict[
'where'][1]), validator = 
TCValidator(flag = 
'DIGIT_ONLY'))
 
  211         if dialogDict.has_key(
'unit'):
 
  212             x = self.unitConv.convert(value = dialogDict[
'where'][0], fromUnit = 
'inch', toUnit = dialogDict[
'unit'])
 
  213             y = self.unitConv.convert(value = dialogDict[
'where'][1], fromUnit = 
'inch', toUnit = dialogDict[
'unit'])
 
  214             parent.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
  215             parent.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
  218         """!Add widgets for setting position relative to paper and to map""" 
  219         panel.position = dict()
 
  220         positionLabel = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Position is given:"))
 
  221         panel.position[
'toPaper'] = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"relative to paper"), style = wx.RB_GROUP)
 
  222         panel.position[
'toMap'] = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"by map coordinates"))
 
  223         panel.position[
'toPaper'].
SetValue(dialogDict[
'XY'])
 
  224         panel.position[
'toMap'].
SetValue(
not dialogDict[
'XY'])
 
  226         gridBagSizer.Add(positionLabel, pos = (0,0), span = (1,3), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, border = 0)
 
  227         gridBagSizer.Add(panel.position[
'toPaper'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, border = 0)
 
  228         gridBagSizer.Add(panel.position[
'toMap'], pos = (1,1),flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT, border = 0)
 
  231         box1   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
"")
 
  232         sizerP = wx.StaticBoxSizer(box1, wx.VERTICAL)
 
  234         self.gridBagSizerP.AddGrowableCol(1)
 
  235         self.gridBagSizerP.AddGrowableRow(3)
 
  237         self.
AddPosition(parent = panel, dialogDict = dialogDict)
 
  238         panel.position[
'comment'].SetLabel(_(
"Position from the top left\nedge of the paper"))
 
  239         self.
AddUnits(parent = panel, dialogDict = dialogDict)
 
  240         self.gridBagSizerP.Add(panel.units[
'unitsLabel'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  241         self.gridBagSizerP.Add(panel.units[
'unitsCtrl'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  242         self.gridBagSizerP.Add(panel.position[
'xLabel'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  243         self.gridBagSizerP.Add(panel.position[
'xCtrl'], pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  244         self.gridBagSizerP.Add(panel.position[
'yLabel'], pos = (2,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  245         self.gridBagSizerP.Add(panel.position[
'yCtrl'], pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  246         self.gridBagSizerP.Add(panel.position[
'comment'], pos = (3,0), span = (1,2), flag = wx.ALIGN_BOTTOM, border = 0)
 
  248         sizerP.Add(self.
gridBagSizerP, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
  249         gridBagSizer.Add(sizerP, pos = (2,0),span = (1,1), flag = wx.ALIGN_CENTER_HORIZONTAL|wx.EXPAND, border = 0)
 
  252         box2   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
"")
 
  253         sizerM = wx.StaticBoxSizer(box2, wx.VERTICAL)
 
  255         self.gridBagSizerM.AddGrowableCol(0)
 
  256         self.gridBagSizerM.AddGrowableCol(1)
 
  258         eastingLabel  = wx.StaticText(panel, id = wx.ID_ANY, label = 
"E:")
 
  259         northingLabel  = wx.StaticText(panel, id = wx.ID_ANY, label = 
"N:")
 
  260         panel.position[
'eCtrl'] = wx.TextCtrl(panel, id = wx.ID_ANY, value = 
"")
 
  261         panel.position[
'nCtrl'] = wx.TextCtrl(panel, id = wx.ID_ANY, value = 
"")
 
  262         east, north = 
PaperMapCoordinates(mapInstr = self.
instruction[self.mapId], x = dialogDict[
'where'][0], y = dialogDict[
'where'][1], paperToMap = 
True)
 
  263         panel.position[
'eCtrl'].
SetValue(str(east))
 
  264         panel.position[
'nCtrl'].
SetValue(str(north))
 
  266         self.gridBagSizerM.Add(eastingLabel, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  267         self.gridBagSizerM.Add(northingLabel, pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  268         self.gridBagSizerM.Add(panel.position[
'eCtrl'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  269         self.gridBagSizerM.Add(panel.position[
'nCtrl'], pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  271         sizerM.Add(self.
gridBagSizerM, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
  272         gridBagSizer.Add(sizerM, pos = (2,1), flag = wx.ALIGN_LEFT|wx.EXPAND, border = 0)
 
  274     def AddFont(self, parent, dialogDict, color = True):
 
  290         parent.font[
'fontLabel'] = wx.StaticText(parent, id = wx.ID_ANY, label = _(
"Font:"))
 
  291         parent.font[
'fontSizeLabel'] = wx.StaticText(parent, id = wx.ID_ANY, label = _(
"Font size:"))
 
  292         fontChoices = [ 
'Times-Roman', 
'Times-Italic', 
'Times-Bold', 
'Times-BoldItalic', 
'Helvetica',\
 
  293                         'Helvetica-Oblique', 
'Helvetica-Bold', 
'Helvetica-BoldOblique', 
'Courier',\
 
  294                         'Courier-Oblique', 
'Courier-Bold', 
'Courier-BoldOblique'] 
 
  295         parent.font[
'fontCtrl'] = wx.Choice(parent, id = wx.ID_ANY, choices = fontChoices)
 
  296         if dialogDict[
'font'] 
in fontChoices:
 
  297             parent.font[
'fontCtrl'].SetStringSelection(dialogDict[
'font'])
 
  299             parent.font[
'fontCtrl'].SetStringSelection(
'Helvetica')
 
  300         parent.font[
'fontSizeCtrl'] = wx.SpinCtrl(parent, id = wx.ID_ANY, min = 4, max = 50, initial = 10)
 
  301         parent.font[
'fontSizeCtrl'].
SetValue(dialogDict[
'fontsize'])
 
  304             parent.font[
'colorLabel'] = wx.StaticText(parent, id = wx.ID_ANY, label = _(
"Choose color:"))
 
  305             parent.font[
'colorCtrl'] = wx.ColourPickerCtrl(parent, id = wx.ID_ANY)
 
  306             parent.font[
'colorCtrl'].SetColour(
convertRGB(dialogDict[
'color']))
 
  317             self.parent.DialogDataChanged(id = self.id)
 
  323         """!Apply changes, close dialog""" 
  324         ok = self.OnApply(event)
 
  333         """!Destroy dialog and delete it from open dialogs""" 
  335             for each 
in  self.objectType:
 
  336                 if each 
in self.parent.openDialogs:
 
  337                     del self.parent.openDialogs[each]
 
  341     def _layout(self, panel):
 
  343         btnCancel = wx.Button(self, wx.ID_CANCEL)
 
  344         btnOK = wx.Button(self, wx.ID_OK)
 
  347             btnApply = wx.Button(self, wx.ID_APPLY)
 
  351         btnOK.Bind(wx.EVT_BUTTON, self.OnOK)
 
  352         btnOK.SetToolTipString(_(
"Close dialog and apply changes"))
 
  354         btnCancel.SetToolTipString(_(
"Close dialog and ignore changes"))
 
  355         btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
 
  357             btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
 
  358             btnApply.SetToolTipString(_(
"Apply changes"))
 
  361         btnSizer = wx.StdDialogButtonSizer()
 
  362         btnSizer.AddButton(btnCancel)
 
  364             btnSizer.AddButton(btnApply)
 
  365         btnSizer.AddButton(btnOK)
 
  368         mainSizer = wx.BoxSizer(wx.VERTICAL)
 
  369         mainSizer.Add(item = panel, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
 
  370         mainSizer.Add(item = btnSizer, proportion = 0,
 
  371                       flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
 
  374         self.SetSizer(mainSizer)
 
  380         PsmapDialog.__init__(self, parent = parent, id = id, title = 
"Page setup",  settings = settings)
 
  382         self.
cat = [
'Units', 
'Format', 
'Orientation', 
'Width', 
'Height', 
'Left', 
'Right', 
'Top', 
'Bottom']
 
  383         labels = [_(
'Units'), _(
'Format'), _(
'Orientation'), _(
'Width'), _(
'Height'),
 
  384                   _(
'Left'), _(
'Right'), _(
'Top'), _(
'Bottom')]
 
  386         paperString = 
RunCommand(
'ps.map', flags = 
'p', read = 
True, quiet = 
True)
 
  396                 self.
getCtrl(
'Format').SetSelection(self.
getCtrl(
'Format').GetCount() - 1)
 
  400                 self.
getCtrl(
'Orientation').SetSelection(0)
 
  402                 self.
getCtrl(
'Orientation').SetSelection(1)
 
  404             for item 
in self.
cat[3:]:
 
  405                 val = self.unitConv.convert(value = self.
pageSetupDict[item],
 
  410         if self.
getCtrl(
'Format').GetSelection() != self.
getCtrl(
'Format').GetCount() - 1: 
 
  411             self.
getCtrl(
'Width').Disable()
 
  412             self.
getCtrl(
'Height').Disable()
 
  414             self.
getCtrl(
'Orientation').Disable()
 
  419         self.btnOk.Bind(wx.EVT_BUTTON, self.
OnOK)
 
  423         self.
pageSetupDict[
'Units'] = self.unitConv.findUnit(self.
getCtrl(
'Units').GetStringSelection())
 
  425         if self.
getCtrl(
'Orientation').GetSelection() == 0:
 
  429         for item 
in self.
cat[3:]:
 
  439                 wx.MessageBox(message = _(
"Literal is not allowed!"), caption = _(
'Invalid input'),
 
  440                                     style = wx.OK|wx.ICON_ERROR)
 
  447         mainSizer = wx.BoxSizer(wx.VERTICAL)
 
  448         pageBox = wx.StaticBox(self, id = wx.ID_ANY, label = 
" %s " % _(
"Page size"))
 
  449         pageSizer = wx.StaticBoxSizer(pageBox, wx.VERTICAL)
 
  450         marginBox = wx.StaticBox(self, id = wx.ID_ANY, label = 
" %s " % _(
"Margins"))
 
  451         marginSizer = wx.StaticBoxSizer(marginBox, wx.VERTICAL)
 
  452         horSizer = wx.BoxSizer(wx.HORIZONTAL) 
 
  454         choices = [self.
unitsList, [item[
'Format'] 
for item 
in self.
paperTable], [_(
'Portrait'), _(
'Landscape')]]
 
  458         for i, item 
in enumerate(self.
cat[:3]):
 
  459             hBox = wx.BoxSizer(wx.HORIZONTAL)
 
  460             stText = wx.StaticText(self, id = wx.ID_ANY, label = self.
catsLabels[item] + 
':')
 
  461             choice = wx.Choice(self, id = wx.ID_ANY, choices = choices[i], size = size)
 
  462             hBox.Add(stText, proportion = propor[i], flag = wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = border[i])
 
  463             hBox.Add(choice, proportion = 0, flag = wx.ALL, border = border[i])
 
  469         for item 
in self.
cat[3:]:
 
  470             hBox = wx.BoxSizer(wx.HORIZONTAL)
 
  471             label = wx.StaticText(self, id = wx.ID_ANY, label = self.
catsLabels[item] + 
':')
 
  472             textctrl = wx.TextCtrl(self, id = wx.ID_ANY, size = size, value = 
'')
 
  473             hBox.Add(label, proportion = 1, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = 3)
 
  474             hBox.Add(textctrl, proportion = 0, flag = wx.ALIGN_CENTRE|wx.ALL, border = 3)
 
  477         sizer = list([mainSizer] + [pageSizer]*4 + [marginSizer]*4)
 
  478         for i, item 
in enumerate(self.
cat):
 
  479                 sizer[i].Add(self.
hBoxDict[item], 0, wx.GROW|wx.RIGHT|wx.LEFT,5)
 
  481         btnSizer = wx.StdDialogButtonSizer()
 
  482         self.
btnOk = wx.Button(self, wx.ID_OK)
 
  483         self.btnOk.SetDefault()
 
  484         btnSizer.AddButton(self.
btnOk)
 
  485         btn = wx.Button(self, wx.ID_CANCEL)
 
  486         btnSizer.AddButton(btn)
 
  490         horSizer.Add(pageSizer, proportion = 0, flag = wx.LEFT|wx.RIGHT|wx.BOTTOM, border = 10)
 
  491         horSizer.Add(marginSizer, proportion = 0, flag = wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, border = 10)
 
  492         mainSizer.Add(horSizer, proportion = 0, border = 10)  
 
  493         mainSizer.Add(btnSizer, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL,  border = 10)      
 
  494         self.SetSizer(mainSizer)
 
  499         currUnit = self.unitConv.findUnit(self.
getCtrl(
'Units').GetStringSelection())
 
  500         currOrientIdx = self.
getCtrl(
'Orientation').GetSelection()
 
  502         for item 
in self.
cat[3:]:
 
  503             newSize[item] = self.unitConv.convert(float(currPaper[item]), fromUnit = 
'inch', toUnit = currUnit)
 
  506         if currPaper[
'Format'] != _(
'custom'):
 
  507             if currOrientIdx == 1: 
 
  508                 newSize[
'Width'], newSize[
'Height'] = newSize[
'Height'], newSize[
'Width']
 
  509             for item 
in self.
cat[3:]:
 
  510                 self.
getCtrl(item).ChangeValue(
"%4.3f" % newSize[item])
 
  512         self.
getCtrl(
'Width').Enable(enable)
 
  513         self.
getCtrl(
'Height').Enable(enable)
 
  514         self.
getCtrl(
'Orientation').Enable(
not enable)
 
  518          return self.
hBoxDict[item].GetItem(1).GetWindow()
 
  520     def _toList(self, paperStr):
 
  523         for line 
in paperStr.strip().
split(
'\n'):
 
  524             d = dict(zip([self.
cat[1]]+ self.
cat[3:],line.split()))
 
  526         d = {}.fromkeys([self.
cat[1]]+ self.
cat[3:], 100)
 
  527         d.update(Format = _(
'custom'))
 
  532     """!Dialog for map frame settings and optionally  raster and vector map selection""" 
  533     def __init__(self, parent, id, settings,  rect = None, notebook = False):
 
  534         PsmapDialog.__init__(self, parent = parent, id = id, title = 
"", settings = settings)
 
  545             self.
notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
 
  547                                         rect = rect, notebook = 
True)
 
  548             self.
id[0] = self.mPanel.getId()
 
  551             self.
id[1] = self.rPanel.getId()
 
  554             self.
id[2] = self.vPanel.getId()
 
  556             self.SetTitle(_(
"Map settings"))
 
  559                                         rect = rect, notebook = 
False)
 
  560             self.
id[0] = self.mPanel.getId()
 
  562             self.SetTitle(_(
"Map frame settings"))
 
  568             okV = self.vPanel.update()
 
  569             okR = self.rPanel.update()
 
  571                 self.parent.DialogDataChanged(id = self.
id[2])
 
  573                 self.parent.DialogDataChanged(id = self.
id[1])
 
  574             if not okR 
or not okV:
 
  577         ok = self.mPanel.update()
 
  579             self.parent.DialogDataChanged(id = self.
id[0])
 
  585         """!Close dialog and remove tmp red box""" 
  586         self.parent.canvas.pdcTmp.RemoveId(self.parent.canvas.idZoomBoxTmp)
 
  587         self.parent.canvas.Refresh() 
 
  591         """!Update raster and vector information""" 
  592         if self.mPanel.scaleChoice.GetSelection() == 0:
 
  593             if self.mPanel.rasterTypeRadio.GetValue():
 
  594                 if 'raster' in self.parent.openDialogs:
 
  595                     if self.parent.openDialogs[
'raster'].rPanel.rasterYesRadio.GetValue() 
and \
 
  596                             self.parent.openDialogs[
'raster'].rPanel.rasterSelect.GetValue() == self.mPanel.select.GetValue():
 
  597                             self.mPanel.drawMap.SetValue(
True)
 
  599                         self.mPanel.drawMap.SetValue(
False)
 
  601                 if 'vector' in self.parent.openDialogs:
 
  603                     for each 
in self.parent.openDialogs[
'vector'].vPanel.vectorList:
 
  604                         if each[0] == self.mPanel.select.GetValue():
 
  606                     self.mPanel.drawMap.SetValue(found)    
 
  609     """!wx.Panel with map (scale, region, border) settings""" 
  610     def __init__(self, parent, id, settings, rect, notebook = True):
 
  611         wx.Panel.__init__(self, parent, id = wx.ID_ANY, style = wx.TAB_TRAVERSAL)
 
  618             self.book.AddPage(page = self, text = _(
"Map frame"))
 
  623         if self.
id is not None:
 
  627             mapFrame = MapFrame(self.
id)
 
  643         self.scaleChoice.SetSelection(self.
mapFrameDict[
'scaleType'])
 
  647             self.drawMap.SetValue(
True)
 
  651                 self.rasterTypeRadio.SetValue(
True)
 
  652                 self.vectorTypeRadio.SetValue(
False)
 
  654                 self.rasterTypeRadio.SetValue(
False)
 
  655                 self.vectorTypeRadio.SetValue(
True)
 
  671         border = wx.BoxSizer(wx.VERTICAL)
 
  673         box   = wx.StaticBox (parent = self, id = wx.ID_ANY, label = 
" %s " % _(
"Map frame"))
 
  674         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
  675         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
  679         frameText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"Map frame options:"))
 
  680         scaleChoices = [_(
"fit frame to match selected map"),
 
  681                         _(
"fit frame to match saved region"),
 
  682                         _(
"fit frame to match current computational region"),
 
  683                         _(
"fixed scale and map center")]
 
  684         self.
scaleChoice = wx.Choice(self, id = wx.ID_ANY, choices = scaleChoices)
 
  687         gridBagSizer.Add(frameText, pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  688         gridBagSizer.Add(self.
scaleChoice, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
  691         self.
staticBox = wx.StaticBox (parent = self, id = wx.ID_ANY, label = 
" %s " % _(
"Map selection"))
 
  692         sizerM = wx.StaticBoxSizer(self.
staticBox, wx.HORIZONTAL)
 
  693         self.
mapSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
  695         self.
rasterTypeRadio = wx.RadioButton(self, id = wx.ID_ANY, label = 
" %s " % _(
"raster"), style = wx.RB_GROUP)
 
  696         self.
vectorTypeRadio = wx.RadioButton(self, id = wx.ID_ANY, label = 
" %s " % _(
"vector"))
 
  697         self.
drawMap = wx.CheckBox(self, id = wx.ID_ANY, label = 
"add selected map")
 
  700         dc = wx.ClientDC(self)
 
  703         self.
select = Select(self, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
 
  704                              type = 
'raster', multiple = 
False,
 
  705                              updateOnPopup = 
True, onPopup = 
None)
 
  707         self.mapSizer.Add(self.
rasterTypeRadio, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  708         self.mapSizer.Add(self.
vectorTypeRadio, pos = (0, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  709         self.mapSizer.Add(self.
drawMap, pos = (0, 3), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border = 0)
 
  710         self.mapSizer.Add(self.
mapText, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  711         self.mapSizer.Add(self.
select, pos = (1, 1), span = (1, 3), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  713         sizerM.Add(self.
mapSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
  714         gridBagSizer.Add(sizerM, pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
  718         boxC   = wx.StaticBox (parent = self, id = wx.ID_ANY, label = 
" %s " % _(
"Map scale and center"))
 
  719         sizerC = wx.StaticBoxSizer(boxC, wx.HORIZONTAL)
 
  720         self.
centerSizer = wx.FlexGridSizer(rows = 2, cols = 5, hgap = 5, vgap = 5)        
 
  723         centerText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"Center:"))
 
  724         self.
eastingText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"E:"))
 
  725         self.
northingText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"N:"))
 
  728         scaleText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"Scale:"))
 
  729         scalePrefixText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"1 :"))
 
  732         self.centerSizer.Add(centerText, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, border = 10)
 
  733         self.centerSizer.Add(self.
eastingText, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border = 0)
 
  734         self.centerSizer.Add(self.
eastingTextCtrl, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  735         self.centerSizer.Add(self.
northingText, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border = 0)
 
  736         self.centerSizer.Add(self.
northingTextCtrl, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  738         self.centerSizer.Add(scaleText, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, border = 10)
 
  739         self.centerSizer.Add(scalePrefixText, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border = 0)
 
  740         self.centerSizer.Add(self.
scaleTextCtrl, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  742         sizerC.Add(self.
centerSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
  743         gridBagSizer.Add(sizerC, pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
  747         flexSizer = wx.FlexGridSizer(rows = 1, cols = 2, hgap = 5, vgap = 5)
 
  749         resolutionText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"Map max resolution (dpi):"))
 
  750         self.
resolutionSpin = wx.SpinCtrl(self, id = wx.ID_ANY, min = 1, max = 1000, initial = 300)
 
  752         flexSizer.Add(resolutionText, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  753         flexSizer.Add(self.
resolutionSpin, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  754         self.resolutionSpin.SetValue(self.
mapFrameDict[
'resolution'])
 
  756         gridBagSizer.Add(flexSizer, pos = (4, 0), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
  758         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
  759         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
  762         box   = wx.StaticBox (parent = self, id = wx.ID_ANY, label = 
" %s " % _(
"Border"))        
 
  763         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
  764         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
  766         self.
borderCheck = wx.CheckBox(self, id = wx.ID_ANY, label = (_(
"draw border around map frame")))
 
  768             self.borderCheck.SetValue(
True)
 
  770             self.borderCheck.SetValue(
False)
 
  772         self.
borderColorText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"border color:"))
 
  773         self.
borderWidthText = wx.StaticText(self, id = wx.ID_ANY, label = _(
"border width (pts):"))
 
  775         self.
borderWidthCtrl = wx.SpinCtrl(self, id = wx.ID_ANY, min = 1, max = 100, initial = 1)
 
  778             self.borderWidthCtrl.SetValue(int(self.
mapFrameDict[
'width']))
 
  782         gridBagSizer.Add(self.
borderCheck, pos = (0, 0), span = (1,2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
  783         gridBagSizer.Add(self.
borderColorText, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  784         gridBagSizer.Add(self.
borderWidthText, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
  785         gridBagSizer.Add(self.
borderColourPicker, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
  786         gridBagSizer.Add(self.
borderWidthCtrl, pos = (2, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
  788         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
  789         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
  791         self.SetSizer(border)
 
  796             self.scaleChoice.SetItems(self.scaleChoice.GetItems()[0:3])
 
  798             for each 
in self.centerSizer.GetChildren():
 
  799                 each.GetWindow().Hide()
 
  804         self.select.GetTextCtrl().Bind(wx.EVT_TEXT, self.
OnMap)
 
  812         """!Selected map or region changing""" 
  814         if self.select.GetValue():
 
  819         if self.scaleChoice.GetSelection() == 0:
 
  821             if self.rasterTypeRadio.GetValue():
 
  830         elif self.scaleChoice.GetSelection() == 1:
 
  834         elif self.scaleChoice.GetSelection() == 2:
 
  846         """!Selected scale type changing""" 
  848         scaleType = self.scaleChoice.GetSelection()
 
  851             self.select.SetValue(
"")
 
  853         if scaleType 
in (0, 1): 
 
  856                 self.rasterTypeRadio.Show()
 
  857                 self.vectorTypeRadio.Show()
 
  859                 self.staticBox.SetLabel(
" %s " % _(
"Map selection"))
 
  860                 if self.rasterTypeRadio.GetValue():
 
  865                 self.select.SetElementList(type = stype)
 
  867                 self.select.SetToolTipString(_(
"Region is set to match this map,\nraster or vector map must be added later"))
 
  871                 self.rasterTypeRadio.Hide()
 
  872                 self.vectorTypeRadio.Hide()
 
  874                 self.staticBox.SetLabel(
" %s " % _(
"Region selection"))
 
  876                 self.select.SetElementList(type = stype)
 
  878                 self.select.SetToolTipString(
"")
 
  880             for each 
in self.mapSizer.GetChildren():
 
  881                 each.GetWindow().Enable()
 
  882             for each 
in self.centerSizer.GetChildren():
 
  883                 each.GetWindow().Disable()
 
  885             if self.
scale[scaleType]:
 
  887                 self.scaleTextCtrl.SetValue(
"%.0f" % (1/self.
scale[scaleType]))
 
  888             if self.
center[scaleType]:
 
  889                 self.eastingTextCtrl.SetValue(str(self.
center[scaleType][0]))
 
  890                 self.northingTextCtrl.SetValue(str(self.
center[scaleType][1]))
 
  892             for each 
in self.mapSizer.GetChildren():
 
  893                 each.GetWindow().Disable()
 
  894             for each 
in self.centerSizer.GetChildren():
 
  895                 each.GetWindow().Disable()
 
  897             if self.
scale[scaleType]:
 
  898                 self.scaleTextCtrl.SetValue(
"%.0f" % (1/self.
scale[scaleType]))
 
  899             if self.
center[scaleType]:
 
  900                 self.eastingTextCtrl.SetValue(str(self.
center[scaleType][0]))
 
  901                 self.northingTextCtrl.SetValue(str(self.
center[scaleType][1]))
 
  903             for each 
in self.mapSizer.GetChildren():
 
  904                 each.GetWindow().Disable()
 
  905             for each 
in self.centerSizer.GetChildren():
 
  906                 each.GetWindow().Enable()
 
  908             if self.
scale[scaleType]:
 
  909                 self.scaleTextCtrl.SetValue(
"%.0f" % (1/self.
scale[scaleType]))
 
  910             if self.
center[scaleType]:
 
  911                 self.eastingTextCtrl.SetValue(str(self.
center[scaleType][0]))
 
  912                 self.northingTextCtrl.SetValue(str(self.
center[scaleType][1]))
 
  915         """!Changes data in map selection tree ctrl popup""" 
  916         if self.rasterTypeRadio.GetValue():
 
  920         self.select.SetElementList(type  = mapType)
 
  921         if self.
mapType != mapType 
and event 
is not None:
 
  923             self.select.SetValue(
'')
 
  927         """!Enables/disable the part relating to border of map frame""" 
  929             each.Enable(self.borderCheck.GetValue())
 
  932         """!Returns id of raster map""" 
  939         mapFrameDict[
'resolution'] = self.resolutionSpin.GetValue()
 
  942         mapFrameDict[
'scaleType'] = scaleType
 
  944         if mapFrameDict[
'scaleType'] == 0:
 
  945             if self.select.GetValue():
 
  946                 mapFrameDict[
'drawMap'] = self.drawMap.GetValue()
 
  947                 mapFrameDict[
'map'] = self.select.GetValue()
 
  948                 mapFrameDict[
'mapType'] = self.
mapType 
  949                 mapFrameDict[
'region'] = 
None 
  951                 if mapFrameDict[
'drawMap']:
 
  953                     if mapFrameDict[
'mapType'] == 
'raster':
 
  954                         mapFile = grass.find_file(mapFrameDict[
'map'], element = 
'cell')
 
  955                         if mapFile[
'file'] == 
'':
 
  956                             GMessage(
"Raster %s not found" % mapFrameDict[
'map'])
 
  958                         raster = self.instruction.FindInstructionByType(
'raster')
 
  960                             raster[
'raster'] = mapFrameDict[
'map']
 
  962                             raster = Raster(wx.NewId())
 
  963                             raster[
'raster'] = mapFrameDict[
'map']
 
  964                             raster[
'isRaster'] = 
True 
  965                             self.instruction.AddInstruction(raster)
 
  967                     elif mapFrameDict[
'mapType'] == 
'vector':
 
  969                         mapFile = grass.find_file(mapFrameDict[
'map'], element = 
'vector')
 
  970                         if mapFile[
'file'] == 
'':
 
  971                             GMessage(
"Vector %s not found" % mapFrameDict[
'map'])
 
  974                         vector = self.instruction.FindInstructionByType(
'vector')
 
  977                             for each 
in vector[
'list']:
 
  978                                 if each[0] == mapFrameDict[
'map']:
 
  981                             topoInfo = grass.vector_info_topo(map = mapFrameDict[
'map'])
 
  983                                 if bool(topoInfo[
'areas']):
 
  985                                 elif bool(topoInfo[
'lines']):
 
  989                                 label = 
'('.join(mapFrameDict[
'map'].
split(
'@')) + 
')' 
  992                                     vector = Vector(wx.NewId())
 
  994                                     self.instruction.AddInstruction(vector)
 
  996                                 vector[
'list'].insert(0, [mapFrameDict[
'map'], topoType, id, 1, label])
 
  997                                 vProp = VProperties(id, topoType)
 
  998                                 vProp[
'name'], vProp[
'label'], vProp[
'lpos'] = mapFrameDict[
'map'], label, 1
 
  999                                 self.instruction.AddInstruction(vProp)
 
 1011                 mapFrameDict[
'scale'] = self.
scale[0]
 
 1013                 mapFrameDict[
'center'] = self.
center[0]
 
 1016                     RunCommand(
'g.region', rast = mapFrameDict[
'map'])
 
 1018                     raster = self.instruction.FindInstructionByType(
'raster')
 
 1020                         rasterId = raster.id 
 
 1028                         RunCommand(
'g.region', vect = mapFrameDict[
'map'])
 
 1033                 wx.MessageBox(message = _(
"No map selected!"),
 
 1034                                     caption = _(
'Invalid input'), style = wx.OK|wx.ICON_ERROR)
 
 1037         elif mapFrameDict[
'scaleType'] == 1:
 
 1038             if self.select.GetValue():
 
 1039                 mapFrameDict[
'drawMap'] = 
False 
 1040                 mapFrameDict[
'map'] = 
None 
 1041                 mapFrameDict[
'mapType'] = 
None 
 1042                 mapFrameDict[
'region'] = self.select.GetValue()
 
 1050                 mapFrameDict[
'scale'] = self.
scale[1]
 
 1051                 mapFrameDict[
'center'] = self.
center[1]
 
 1053                 RunCommand(
'g.region', region = mapFrameDict[
'region'])
 
 1055                 wx.MessageBox(message = _(
"No region selected!"),
 
 1056                                     caption = _(
'Invalid input'), style = wx.OK|wx.ICON_ERROR)
 
 1059         elif scaleType == 2:
 
 1060             mapFrameDict[
'drawMap'] = 
False 
 1061             mapFrameDict[
'map'] = 
None 
 1062             mapFrameDict[
'mapType'] = 
None 
 1063             mapFrameDict[
'region'] = 
None 
 1070             mapFrameDict[
'scale'] = self.
scale[2]
 
 1071             mapFrameDict[
'center'] = self.
center[2]
 
 1073             env = grass.gisenv()
 
 1074             windFilePath = os.path.join(env[
'GISDBASE'], env[
'LOCATION_NAME'], env[
'MAPSET'], 
'WIND')
 
 1076                 windFile = open(windFilePath, 
'r').read() 
 1077                 region = grass.parse_key_val(windFile, sep = ':', val_type = float)
 
 1079                 region = grass.region()
 
 1081             raster = self.instruction.FindInstructionByType(
'raster')
 
 1083                 rasterId = raster.id 
 
 1088                 RunCommand(
'g.region', n = region[
'north'], s = region[
'south'],
 
 1089                             e = region[
'east'], w = region[
'west'], rast = self.
instruction[rasterId][
'raster'])
 
 1091                 RunCommand(
'g.region', n = region[
'north'], s = region[
'south'],
 
 1092                            e = region[
'east'], w = region[
'west'])
 
 1094         elif scaleType == 3:
 
 1095             mapFrameDict[
'drawMap'] = 
False 
 1096             mapFrameDict[
'map'] = 
None 
 1097             mapFrameDict[
'mapType'] = 
None 
 1098             mapFrameDict[
'region'] = 
None 
 1101                 scaleNumber = float(self.scaleTextCtrl.GetValue())
 
 1102                 centerE = float(self.eastingTextCtrl.GetValue()) 
 
 1103                 centerN = float(self.northingTextCtrl.GetValue())
 
 1104             except (ValueError, SyntaxError):
 
 1105                 wx.MessageBox(message = _(
"Invalid scale or map center!"),
 
 1106                                     caption = _(
'Invalid input'), style = wx.OK|wx.ICON_ERROR)
 
 1108             mapFrameDict[
'scale'] = 1/scaleNumber
 
 1109             mapFrameDict[
'center'] = centerE, centerN
 
 1114         SetResolution(dpi = mapFrameDict[
'resolution'], width = mapFrameDict[
'rect'].width,
 
 1115                                                         height = mapFrameDict[
'rect'].height)
 
 1117         if self.borderCheck.GetValue():
 
 1118             mapFrameDict[
'border'] = 
'y'  
 1120             mapFrameDict[
'border'] = 
'n' 
 1122         if mapFrameDict[
'border'] == 
'y':
 
 1123             mapFrameDict[
'width'] = self.borderWidthCtrl.GetValue()
 
 1124             mapFrameDict[
'color'] = 
convertRGB(self.borderColourPicker.GetColour())
 
 1127             mapFrame = MapFrame(self.
id)
 
 1128             self.instruction.AddInstruction(mapFrame)
 
 1131         if self.
id not in self.mapDialog.parent.objectId:
 
 1132             self.mapDialog.parent.objectId.insert(0, self.
id)
 
 1136     """!Panel for raster map settings""" 
 1137     def __init__(self, parent, id, settings,  notebook = True):
 
 1138         wx.Panel.__init__(self, parent, id = wx.ID_ANY, style = wx.TAB_TRAVERSAL)
 
 1143             self.book.AddPage(page = self, text = _(
"Raster map"))
 
 1151             self.
id = wx.NewId()
 
 1152             raster = Raster(self.
id)
 
 1161         border = wx.BoxSizer(wx.VERTICAL)
 
 1165         box   = wx.StaticBox (parent = self, id = wx.ID_ANY, label = 
" %s " % _(
"Choose raster map"))
 
 1166         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 1167         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 1169         self.
rasterNoRadio = wx.RadioButton(self, id = wx.ID_ANY, label = _(
"no raster map"), style = wx.RB_GROUP)
 
 1172         self.
rasterSelect = Select(self, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
 
 1173                              type = 
'raster', multiple = 
False,
 
 1174                              updateOnPopup = 
True, onPopup = 
None)
 
 1176             self.rasterYesRadio.SetValue(
True)
 
 1177             self.rasterNoRadio.SetValue(
False)
 
 1178             self.rasterSelect.SetValue(self.
rasterDict[
'raster'])
 
 1180             self.rasterYesRadio.SetValue(
False)
 
 1181             self.rasterNoRadio.SetValue(
True)
 
 1182             mapId = self.instruction.FindInstructionByType(
'map').id
 
 1185                 self.rasterSelect.SetValue(self.
instruction[mapId][
'map'])
 
 1187                 self.rasterSelect.SetValue(
'')                
 
 1188         gridBagSizer.Add(self.
rasterNoRadio, pos = (0, 0), span = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)            
 
 1189         gridBagSizer.Add(self.
rasterYesRadio, pos = (1, 0),  flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1190         gridBagSizer.Add(self.
rasterSelect, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1192         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1193         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1199         self.SetSizer(border)
 
 1203         """!Enable/disable raster selection""" 
 1204         self.rasterSelect.Enable(self.rasterYesRadio.GetValue())
 
 1208         mapInstr = self.instruction.FindInstructionByType(
'map')
 
 1210             GMessage(message = _(
"Please, create map frame first."))
 
 1213         if self.rasterNoRadio.GetValue() 
or not self.rasterSelect.GetValue():
 
 1216             mapInstr[
'drawMap'] = 
False 
 1222             self.
rasterDict[
'raster'] = self.rasterSelect.GetValue()
 
 1223             if self.
rasterDict[
'raster'] != mapInstr[
'drawMap']:
 
 1224                 mapInstr[
'drawMap'] = 
False 
 1226             raster = self.instruction.FindInstructionByType(
'raster')
 
 1228                 raster = Raster(self.
id)
 
 1229                 self.instruction.AddInstruction(raster)
 
 1234         if 'map' in self.mainDialog.parent.openDialogs:
 
 1235             self.mainDialog.parent.openDialogs[
'map'].
updateDialog()
 
 1242     """!Panel for vector maps settings""" 
 1243     def __init__(self, parent, id, settings, notebook = True):
 
 1244         wx.Panel.__init__(self, parent, id = wx.ID_ANY, style = wx.TAB_TRAVERSAL)
 
 1249         vectors = self.instruction.FindInstructionByType(
'vProperties', list = 
True)
 
 1250         for vector 
in vectors:
 
 1257             self.
id = wx.NewId()
 
 1260         vLegend = self.instruction.FindInstructionByType(
'vectorLegend')
 
 1270             self.parent.AddPage(page = self, text = _(
"Vector maps"))
 
 1271             self.
parent = self.parent.GetParent()
 
 1275         border = wx.BoxSizer(wx.VERTICAL)
 
 1279         box   = wx.StaticBox (parent = self, id = wx.ID_ANY, label = 
" %s " % _(
"Add map"))
 
 1280         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 1281         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 1283         text = wx.StaticText(self, id = wx.ID_ANY, label = _(
"Map:"))
 
 1285                              type = 
'vector', multiple = 
False,
 
 1286                              updateOnPopup = 
True, onPopup = 
None)
 
 1287         topologyTypeTr = [_(
"points"), _(
"lines"), _(
"areas")]
 
 1289         self.
vectorType = wx.RadioBox(self, id = wx.ID_ANY, label = 
" %s " % _(
"Data Type"), choices = topologyTypeTr,
 
 1290                                       majorDimension = 3, style = wx.RA_SPECIFY_COLS)
 
 1292         self.
AddVector = wx.Button(self, id = wx.ID_ANY, label = _(
"Add"))
 
 1294         gridBagSizer.Add(text, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1295         gridBagSizer.Add(self.
select, pos = (0,1), span = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1296         gridBagSizer.Add(self.
vectorType, pos = (1,1), flag = wx.ALIGN_CENTER, border = 0)
 
 1297         gridBagSizer.Add(self.
AddVector, pos = (1,2), flag = wx.ALIGN_BOTTOM|wx.ALIGN_RIGHT, border = 0)
 
 1299         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1300         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1304         box   = wx.StaticBox (parent = self, id = wx.ID_ANY, label = 
" %s " % _(
"Manage vector maps"))
 
 1305         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 1306         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 1307         gridBagSizer.AddGrowableCol(0,2)
 
 1308         gridBagSizer.AddGrowableCol(1,1)
 
 1312         text = wx.StaticText(self, id = wx.ID_ANY, label = _(
"The topmost vector map overlaps the others"))
 
 1313         self.
listbox = wx.ListBox(self, id = wx.ID_ANY, choices = [], style = wx.LB_SINGLE|wx.LB_NEEDED_SB)
 
 1314         self.
btnUp = wx.Button(self, id = wx.ID_ANY, label = _(
"Up"))
 
 1315         self.
btnDown = wx.Button(self, id = wx.ID_ANY, label = _(
"Down"))
 
 1316         self.
btnDel = wx.Button(self, id = wx.ID_ANY, label = _(
"Delete"))
 
 1317         self.
btnProp = wx.Button(self, id = wx.ID_ANY, label = _(
"Properties..."))
 
 1322         gridBagSizer.Add(text, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1323         gridBagSizer.Add(self.
listbox, pos = (1,0), span = (4, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1324         gridBagSizer.Add(self.
btnUp, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1325         gridBagSizer.Add(self.
btnDown, pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1326         gridBagSizer.Add(self.
btnDel, pos = (3,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1327         gridBagSizer.Add(self.
btnProp, pos = (4,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1329         sizer.Add(gridBagSizer, proportion = 0, flag = wx.ALL, border = 5)
 
 1330         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1334         self.Bind(wx.EVT_BUTTON, self.
OnUp, self.
btnUp)
 
 1337         self.select.GetTextCtrl().Bind(wx.EVT_TEXT, self.
OnVector)
 
 1339         self.SetSizer(border)
 
 1345         """!Gets info about toplogy and enables/disables choices point/line/area""" 
 1346         vmap = self.select.GetValue()   
 
 1348             topoInfo = grass.vector_info_topo(map = vmap)
 
 1349         except grass.ScriptError:
 
 1353             self.vectorType.EnableItem(2, bool(topoInfo[
'areas']))
 
 1354             self.vectorType.EnableItem(1, bool(topoInfo[
'boundaries']) 
or bool(topoInfo[
'lines']))
 
 1355             self.vectorType.EnableItem(0, bool(topoInfo[
'centroids'] 
or bool(topoInfo[
'points']) ))
 
 1356             for item 
in range(2,-1,-1):
 
 1357                 if self.vectorType.IsItemEnabled(item):
 
 1358                     self.vectorType.SetSelection(item)
 
 1361             self.AddVector.SetFocus()        
 
 1364         """!Adds vector map to list""" 
 1365         vmap = self.select.GetValue()
 
 1367             mapname = vmap.split(
'@')[0]
 
 1369                 mapset = 
'(' + vmap.split(
'@')[1] + 
')' 
 1372             idx = self.vectorType.GetSelection()
 
 1374             record = 
"%s - %s" % (vmap, ttype)
 
 1377             label = mapname + mapset 
 
 1378             self.vectorList.insert(0, [vmap, ttype, id, lpos, label])
 
 1380             self.listbox.InsertItems([record], 0)
 
 1382             vector = VProperties(id, ttype)
 
 1387             self.listbox.SetSelection(0)  
 
 1388             self.listbox.EnsureVisible(0)
 
 1389             self.btnProp.SetFocus()
 
 1393         """!Deletes vector map from the list""" 
 1394         if self.listbox.GetSelections():
 
 1395             pos = self.listbox.GetSelection()
 
 1409             if self.listbox.IsEmpty():
 
 1414         """!Moves selected map to top""" 
 1415         if self.listbox.GetSelections():
 
 1416             pos = self.listbox.GetSelection()
 
 1418                 self.vectorList.insert(pos - 1, self.vectorList.pop(pos))
 
 1429         """!Moves selected map to bottom""" 
 1430         if self.listbox.GetSelections():
 
 1431             pos = self.listbox.GetSelection()
 
 1433                 self.vectorList.insert(pos + 1, self.vectorList.pop(pos))
 
 1443         """!Opens vector map properties dialog""" 
 1444         if self.listbox.GetSelections():
 
 1445             pos = self.listbox.GetSelection()
 
 1452             self.parent.FindWindowById(wx.ID_OK).SetFocus()
 
 1455         """!Enable/disable up, down, properties, delete buttons""" 
 1456         self.btnUp.Enable(enable)
 
 1457         self.btnDown.Enable(enable)
 
 1458         self.btnProp.Enable(enable)
 
 1459         self.btnDel.Enable(enable)
 
 1462         mapList = [
"%s - %s" % (item[0], item[1]) 
for item 
in self.
vectorList]
 
 1463         self.listbox.Set(mapList)
 
 1464         if self.listbox.IsEmpty():
 
 1468             if selected 
is not None:
 
 1469                 self.listbox.SetSelection(selected)  
 
 1470                 self.listbox.EnsureVisible(selected)  
 
 1473         """!Update position in legend, used only if there is no vlegend yet""" 
 1482         vectors = self.instruction.FindInstructionByType(
'vProperties', list = 
True)
 
 1484         for vector 
in vectors:
 
 1490             vector = Vector(self.
id)
 
 1491             self.instruction.AddInstruction(vector)
 
 1493             vector.SetInstruction({
'list': deepcopy(self.
vectorList)})
 
 1499                 vLayer = VProperties(id, item[1])
 
 1500                 self.instruction.AddInstruction(vLayer)
 
 1502                 vLayer[
'name'] = item[0]
 
 1503                 vLayer[
'label'] = item[4]
 
 1504                 vLayer[
'lpos'] = item[3]
 
 1510         if 'map' in self.parent.parent.openDialogs:
 
 1517         PsmapDialog.__init__(self, parent = parent, id = id, title = _(
"Raster map settings"), settings = settings)
 
 1522         self.
id = self.rPanel.getId()
 
 1523         self._layout(self.
rPanel)
 
 1526         ok = self.rPanel.update()
 
 1537             self.parent.DialogDataChanged(id = self.
id)
 
 1539             mapId = self.instruction.FindInstructionByType(
'map').id
 
 1540             self.parent.DialogDataChanged(id = mapId)
 
 1544         """!Update information (not used)""" 
 1552 class MainVectorDialog(PsmapDialog):
 
 1554         PsmapDialog.__init__(self, parent = parent, id = id, title = _(
"Vector maps settings"), settings = settings)
 
 1558         self.
id = self.vPanel.getId()
 
 1559         self._layout(self.
vPanel)
 
 1562         self.vPanel.update()
 
 1567             self.parent.DialogDataChanged(id = self.
id)
 
 1569             mapId = self.instruction.FindInstructionByType(
'map').id
 
 1570             self.parent.DialogDataChanged(id = mapId)
 
 1574         """!Update information (not used)""" 
 1577 class VPropertiesDialog(PsmapDialog):
 
 1578     def __init__(self, parent, id, settings, vectors, tmpSettings):
 
 1579         PsmapDialog.__init__(self, parent = parent, id = id, title = 
"", settings = settings, apply = 
False)
 
 1581         vectorList = vectors
 
 1585         for item 
in vectorList:
 
 1589         self.SetTitle(_(
"%s properties") % self.
vectorName)
 
 1596         except grass.ScriptError:
 
 1606         gisbase = os.getenv(
"GISBASE")
 
 1610             for symbol 
in os.listdir(os.path.join(self.
symbolPath, dir)):
 
 1611                 self.symbols.append(os.path.join(dir, symbol))
 
 1615         notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
 
 1617         self.EnableLayerSelection(enable = self.
connection)
 
 1623         self.OnOutline(
None)
 
 1624         if self.
type in (
'points', 
'areas'):
 
 1629         if self.
type == 
'points':
 
 1631             self.OnRotation(
None)
 
 1632             self.OnSymbology(
None)
 
 1633         if self.
type == 
'areas':
 
 1634             self.OnPattern(
None)
 
 1636         self._layout(notebook)
 
 1638     def _DataSelectionPanel(self, notebook):
 
 1639         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 1640         notebook.AddPage(page = panel, text = _(
"Data selection"))
 
 1642         border = wx.BoxSizer(wx.VERTICAL)
 
 1646         if self.
type in (
'lines', 
'points'):
 
 1647             box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Feature type"))
 
 1648             sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1649             gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 1650             if self.
type == 
'points':
 
 1651                 label = (_(
"points"), _(
"centroids"))
 
 1653                 label = (_(
"lines"), _(
"boundaries"))
 
 1654             if self.
type == 
'points':
 
 1655                 name = (
"point", 
"centroid")
 
 1657                 name = (
"line", 
"boundary")
 
 1658             self.
checkType1 = wx.CheckBox(panel, id = wx.ID_ANY, label = label[0], name = name[0])
 
 1659             self.
checkType2 = wx.CheckBox(panel, id = wx.ID_ANY, label = label[1], name = name[1])
 
 1660             self.checkType1.SetValue(self.
vPropertiesDict[
'type'].find(name[0]) >= 0)
 
 1661             self.checkType2.SetValue(self.
vPropertiesDict[
'type'].find(name[1]) >= 0)
 
 1663             gridBagSizer.Add(self.
checkType1, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1664             gridBagSizer.Add(self.
checkType2, pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1665             sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1666             border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1669         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Layer selection"))
 
 1670         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1673         self.
warning =  wx.StaticText(panel, id = wx.ID_ANY, label = 
"")
 
 1675             self.
warning = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Database connection is not defined in DB file."))
 
 1676         text = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Select layer:"))
 
 1679         self.layerChoice.SetStringSelection(self.
currLayer)
 
 1682             table = self.mapDBInfo.layers[int(self.
currLayer)][
'table'] 
 
 1686         self.
radioWhere = wx.RadioButton(panel, id = wx.ID_ANY, label = 
"SELECT * FROM %s WHERE" % table, style = wx.RB_GROUP)
 
 1691             cols = self.mapDBInfo.GetColumns(self.mapDBInfo.layers[int(self.
currLayer)][
'table']) 
 
 1697         self.
radioCats = wx.RadioButton(panel, id = wx.ID_ANY, label = 
"Choose categories ")
 
 1699         self.textCtrlCats.SetToolTipString(_(
"list of categories (e.g. 1,3,5-7)"))
 
 1701         if self.vPropertiesDict.has_key(
'cats'):
 
 1702             self.radioCats.SetValue(
True)
 
 1704         if self.vPropertiesDict.has_key(
'where'):
 
 1705             self.radioWhere.SetValue(
True)
 
 1707             self.choiceColumns.SetStringSelection(where[0])
 
 1708             self.textCtrlWhere.SetValue(where[1])
 
 1712             self.gridBagSizerL.Add(self.
warning, pos = (0,0), span = (1,3), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1714         self.gridBagSizerL.Add(text, pos = (0 + row,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1715         self.gridBagSizerL.Add(self.
layerChoice, pos = (0 + row,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1716         self.gridBagSizerL.Add(self.
radioWhere, pos = (1 + row,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1717         self.gridBagSizerL.Add(self.
choiceColumns, pos = (1 + row,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1718         self.gridBagSizerL.Add(self.
textCtrlWhere, pos = (1 + row,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1719         self.gridBagSizerL.Add(self.
radioCats, pos = (2 + row,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1720         self.gridBagSizerL.Add(self.
textCtrlCats, pos = (2 + row,1), span = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1722         sizer.Add(self.
gridBagSizerL, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1723         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1726         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Mask"))
 
 1727         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1729         self.
mask = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"Use current mask"))
 
 1731             self.mask.SetValue(
True) 
 
 1733             self.mask.SetValue(
False)
 
 1735         sizer.Add(self.
mask, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1736         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1738         self.Bind(wx.EVT_CHOICE, self.OnLayer, self.
layerChoice)
 
 1740         panel.SetSizer(border)
 
 1744     def _ColorsPointAreaPanel(self, notebook):
 
 1745         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 1746         notebook.AddPage(page = panel, text = _(
"Colors"))
 
 1748         border = wx.BoxSizer(wx.VERTICAL)
 
 1751         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Outline"))
 
 1752         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1755         self.
outlineCheck = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"draw outline"))
 
 1758         widthText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Width (pts):"))
 
 1760             self.
widthSpin = fs.FloatSpin(panel, id = wx.ID_ANY, min_val = 0, max_val = 30,
 
 1761                                           increment = 0.5, value = 1, style = fs.FS_RIGHT)
 
 1762             self.widthSpin.SetFormat(
"%f")
 
 1763             self.widthSpin.SetDigits(2)
 
 1765             self.
widthSpin = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 25, initial = 1,
 
 1774             self.widthSpin.SetValue(1)
 
 1776         colorText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Color:"))
 
 1781             self.colorPicker.SetColour(
convertRGB(
'black'))
 
 1783         self.gridBagSizerO.Add(self.
outlineCheck, pos = (0, 0), span = (1,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1784         self.gridBagSizerO.Add(widthText, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1785         self.gridBagSizerO.Add(self.
widthSpin, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)        
 
 1786         self.gridBagSizerO.Add(colorText, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)                
 
 1787         self.gridBagSizerO.Add(self.
colorPicker, pos = (2, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1789         sizer.Add(self.
gridBagSizerO, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1790         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1792         self.Bind(wx.EVT_CHECKBOX, self.OnOutline, self.
outlineCheck)
 
 1795         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Fill")) 
 
 1796         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1799         self.
fillCheck = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"fill color"))
 
 1802         self.
colorPickerRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"choose color:"), style = wx.RB_GROUP)
 
 1807             self.colorPickerRadio.SetValue(
False)            
 
 1812             self.fillColorPicker.SetColour(
convertRGB(
'red'))        
 
 1814         self.
colorColRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"color from map table column:"))
 
 1818                 self.colorColRadio.SetValue(
True)
 
 1819                 self.colorColChoice.SetStringSelection(self.
vPropertiesDict[
'rgbcolumn'])
 
 1821                 self.colorColRadio.SetValue(
False)
 
 1822                 self.colorColChoice.SetSelection(0)
 
 1826         self.gridBagSizerF.Add(self.
fillCheck, pos = (0, 0), span = (1,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1827         self.gridBagSizerF.Add(self.
colorPickerRadio, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1828         self.gridBagSizerF.Add(self.
fillColorPicker, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1829         self.gridBagSizerF.Add(self.
colorColRadio, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1830         self.gridBagSizerF.Add(self.
colorColChoice, pos = (2, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)        
 
 1832         sizer.Add(self.
gridBagSizerF, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1833         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1835         self.Bind(wx.EVT_CHECKBOX, self.OnFill, self.
fillCheck)
 
 1836         self.Bind(wx.EVT_RADIOBUTTON, self.OnColor, self.
colorColRadio)
 
 1839         panel.SetSizer(border)
 
 1843     def _ColorsLinePanel(self, notebook):
 
 1844         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 1845         notebook.AddPage(page = panel, text = _(
"Colors"))
 
 1847         border = wx.BoxSizer(wx.VERTICAL)
 
 1850         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Outline"))
 
 1851         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1859         self.
outlineCheck = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"draw outline"))
 
 1861         self.outlineCheck.SetToolTipString(_(
"No effect for fill color from table column"))
 
 1863         widthText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Width (pts):"))
 
 1866             self.
outWidthSpin = fs.FloatSpin(panel, id = wx.ID_ANY, min_val = 0, max_val = 30,
 
 1867                                              increment = 0.5, value = 1, style = fs.FS_RIGHT)
 
 1868             self.outWidthSpin.SetFormat(
"%f")
 
 1869             self.outWidthSpin.SetDigits(1)
 
 1871             self.
outWidthSpin = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 30, initial = 1,
 
 1877             self.outWidthSpin.SetValue(1)
 
 1879         colorText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Color:"))
 
 1880         self.
colorPicker = wx.ColourPickerCtrl(panel, id = wx.ID_ANY)
 
 1884             self.colorPicker.SetColour(
convertRGB(
'black'))
 
 1887         self.gridBagSizerO.Add(self.
outlineCheck, pos = (0, 0), span = (1,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1888         self.gridBagSizerO.Add(widthText, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1889         self.gridBagSizerO.Add(self.
outWidthSpin, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)        
 
 1890         self.gridBagSizerO.Add(colorText, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)                
 
 1891         self.gridBagSizerO.Add(self.
colorPicker, pos = (2, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1893         sizer.Add(self.
gridBagSizerO, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1894         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1896         self.Bind(wx.EVT_CHECKBOX, self.OnOutline, self.
outlineCheck)
 
 1899         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Fill"))
 
 1900         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1903         fillText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Color of lines:"))
 
 1905         self.
colorPickerRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"choose color:"), style = wx.RB_GROUP)
 
 1911             self.colorPickerRadio.SetValue(
False)            
 
 1916             self.fillColorPicker.SetColour(
convertRGB(
'black'))
 
 1918         self.
colorColRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"color from map table column:"))
 
 1922                 self.colorColRadio.SetValue(
True)
 
 1923                 self.colorColChoice.SetStringSelection(self.
vPropertiesDict[
'rgbcolumn'])
 
 1925                 self.colorColRadio.SetValue(
False)
 
 1926                 self.colorColChoice.SetSelection(0)
 
 1930         self.gridBagSizerF.Add(fillText, pos = (0, 0), span = (1,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1931         self.gridBagSizerF.Add(self.
colorPickerRadio, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1932         self.gridBagSizerF.Add(self.
fillColorPicker, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1933         self.gridBagSizerF.Add(self.
colorColRadio, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 1934         self.gridBagSizerF.Add(self.
colorColChoice, pos = (2, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)        
 
 1936         sizer.Add(self.
gridBagSizerF, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1937         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1939         self.Bind(wx.EVT_RADIOBUTTON, self.OnColor, self.
colorColRadio)
 
 1942         panel.SetSizer(border)
 
 1946     def _StylePointPanel(self, notebook):
 
 1947         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 1948         notebook.AddPage(page = panel, text = _(
"Size and style"))
 
 1950         border = wx.BoxSizer(wx.VERTICAL)
 
 1953         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Symbology"))        
 
 1954         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1955         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 1956         gridBagSizer.AddGrowableCol(1)
 
 1958         self.
symbolRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"symbol:"), style = wx.RB_GROUP)
 
 1963         bitmap = wx.Bitmap(os.path.join(globalvar.ETCSYMBOLDIR,
 
 1965         self.
symbolButton = wx.BitmapButton(panel, id = wx.ID_ANY, bitmap = bitmap)
 
 1967         self.
epsRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"eps file:"))
 
 1970         self.
epsFileCtrl = filebrowse.FileBrowseButton(panel, id = wx.ID_ANY, labelText = 
'',
 
 1971                                 buttonText =  _(
"Browse"), toolTip = _(
"Type filename or click browse to choose file"), 
 
 1972                                 dialogTitle = _(
"Choose a file"), startDirectory = 
'', initialValue = 
'',
 
 1973                                 fileMask = 
"Encapsulated PostScript (*.eps)|*.eps|All files (*.*)|*.*", fileMode = wx.OPEN)
 
 1975             self.epsFileCtrl.SetValue(
'')
 
 1979         gridBagSizer.AddGrowableCol(2)
 
 1980         gridBagSizer.Add(self.
symbolRadio, pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1981         gridBagSizer.Add(self.
symbolName, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL | wx.LEFT, border = 10)
 
 1982         gridBagSizer.Add(self.
symbolButton, pos = (0, 2), flag = wx.ALIGN_RIGHT , border = 0)
 
 1983         gridBagSizer.Add(self.
epsRadio, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 1984         gridBagSizer.Add(self.
epsFileCtrl, pos = (1, 1), span = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 1986         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 1987         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 1989         self.Bind(wx.EVT_BUTTON, self.OnSymbolSelection, self.
symbolButton)
 
 1990         self.Bind(wx.EVT_RADIOBUTTON, self.OnSymbology, self.
symbolRadio)
 
 1991         self.Bind(wx.EVT_RADIOBUTTON, self.OnSymbology, self.
epsRadio)
 
 1995         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Size"))
 
 1996         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 1997         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 1998         gridBagSizer.AddGrowableCol(0)
 
 2000         self.
sizeRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"size:"), style = wx.RB_GROUP)
 
 2001         self.
sizeSpin = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 50, initial = 1)
 
 2002         self.
sizecolumnRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"size from map table column:"))
 
 2004         self.
scaleText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"scale:"))
 
 2005         self.
scaleSpin = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 25, initial = 1)
 
 2008         self.sizecolumnRadio.SetValue(bool(self.
vPropertiesDict[
'sizecolumn']))
 
 2011         else: self.sizeSpin.SetValue(5)
 
 2014             self.sizeColChoice.SetStringSelection(self.
vPropertiesDict[
'sizecolumn'])
 
 2016             self.scaleSpin.SetValue(1)
 
 2017             self.sizeColChoice.SetSelection(0)
 
 2022         gridBagSizer.Add(self.
sizeRadio, pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2023         gridBagSizer.Add(self.
sizeSpin, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2024         gridBagSizer.Add(self.
sizecolumnRadio, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2025         gridBagSizer.Add(self.
sizeColChoice, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 2026         gridBagSizer.Add(self.
scaleText, pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border = 0)
 
 2027         gridBagSizer.Add(self.
scaleSpin, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2029         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 2030         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2032         self.Bind(wx.EVT_RADIOBUTTON, self.OnSize, self.
sizeRadio)
 
 2036         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Rotation"))
 
 2037         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 2038         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 2039         gridBagSizer.AddGrowableCol(1)
 
 2042         self.
rotateCheck = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"rotate symbols:"))
 
 2043         self.
rotateRadio = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"counterclockwise in degrees:"), style = wx.RB_GROUP)
 
 2044         self.
rotateSpin = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 0, max = 360, initial = 0)
 
 2050         self.rotatecolumnRadio.SetValue(bool(self.
vPropertiesDict[
'rotatecolumn']))
 
 2054             self.rotateSpin.SetValue(0)
 
 2056             self.rotateColChoice.SetStringSelection(self.
vPropertiesDict[
'rotatecolumn'])
 
 2058             self.rotateColChoice.SetSelection(0)
 
 2060         gridBagSizer.Add(self.
rotateCheck, pos = (0, 0), span = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2061         gridBagSizer.Add(self.
rotateRadio, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2062         gridBagSizer.Add(self.
rotateSpin, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2063         gridBagSizer.Add(self.
rotatecolumnRadio, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2064         gridBagSizer.Add(self.
rotateColChoice, pos = (2, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 2066         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 2067         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2069         self.Bind(wx.EVT_CHECKBOX, self.OnRotation, self.
rotateCheck)
 
 2070         self.Bind(wx.EVT_RADIOBUTTON, self.OnRotationType, self.
rotateRadio)
 
 2073         panel.SetSizer(border)
 
 2077     def _StyleLinePanel(self, notebook):
 
 2078         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 2079         notebook.AddPage(page = panel, text = _(
"Size and style"))
 
 2081         border = wx.BoxSizer(wx.VERTICAL)
 
 2084         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Width"))       
 
 2085         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 2086         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 2088         widthText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Set width (pts):"))
 
 2090             self.
widthSpin = fs.FloatSpin(panel, id = wx.ID_ANY, min_val = 0, max_val = 30,
 
 2091                                         increment = 0.5, value = 1, style = fs.FS_RIGHT)
 
 2092             self.widthSpin.SetFormat(
"%f")
 
 2093             self.widthSpin.SetDigits(1)
 
 2095             self.
widthSpin = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 30, initial = 1)
 
 2097         self.
cwidthCheck = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"multiply width by category value"))
 
 2101             self.cwidthCheck.SetValue(
False)
 
 2104             self.cwidthCheck.SetValue(
True)
 
 2106         gridBagSizer.Add(widthText, pos = (0, 0),  flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2107         gridBagSizer.Add(self.
widthSpin, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2108         gridBagSizer.Add(self.
cwidthCheck, pos = (1, 0), span = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2110         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 2111         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2114         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Line style"))
 
 2115         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 2116         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 2118         styleText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Choose line style:"))
 
 2119         penStyles = [
"solid", 
"dashed", 
"dotted", 
"dashdotted"]
 
 2128         linecapText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Choose linecap:"))
 
 2129         self.linecapChoice = wx.Choice(panel, id = wx.ID_ANY, choices = [
"butt", 
"round", 
"extended_butt"])
 
 2131         self.styleCombo.SetValue(self.vPropertiesDict[
'style'])
 
 2132         self.linecapChoice.SetStringSelection(self.vPropertiesDict[
'linecap'])
 
 2134         gridBagSizer.Add(styleText, pos = (0, 0),  flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2135         gridBagSizer.Add(self.styleCombo, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 2136         gridBagSizer.Add(linecapText, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2137         gridBagSizer.Add(self.linecapChoice, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 2139         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 2140         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2142         panel.SetSizer(border)
 
 2146     def _StyleAreaPanel(self, notebook):
 
 2147         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 2148         notebook.AddPage(page = panel, text = _(
"Size and style"))
 
 2150         border = wx.BoxSizer(wx.VERTICAL)
 
 2153         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Pattern"))
 
 2154         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 2155         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 2156         gridBagSizer.AddGrowableCol(1)
 
 2158         self.patternCheck = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"use pattern:"))
 
 2159         self.patFileCtrl = filebrowse.FileBrowseButton(panel, id = wx.ID_ANY, labelText = _(
"Choose pattern file:"),
 
 2160                                 buttonText =  _(
"Browse"), toolTip = _(
"Type filename or click browse to choose file"), 
 
 2161                                 dialogTitle = _(
"Choose a file"), startDirectory = self.patternPath, initialValue = 
'',
 
 2162                                 fileMask = 
"Encapsulated PostScript (*.eps)|*.eps|All files (*.*)|*.*", fileMode = wx.OPEN)
 
 2163         self.patWidthText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"pattern line width (pts):"))
 
 2164         self.patWidthSpin = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 25, initial = 1)
 
 2165         self.patScaleText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"pattern scale factor:"))
 
 2166         self.patScaleSpin = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 25, initial = 1)
 
 2168         self.patternCheck.SetValue(bool(self.vPropertiesDict[
'pat']))
 
 2169         if self.patternCheck.GetValue():
 
 2170             self.patFileCtrl.SetValue(self.vPropertiesDict[
'pat'])
 
 2171             self.patWidthSpin.SetValue(self.vPropertiesDict[
'pwidth'])
 
 2172             self.patScaleSpin.SetValue(self.vPropertiesDict[
'scale'])
 
 2174         gridBagSizer.Add(self.patternCheck, pos = (0, 0),  flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2175         gridBagSizer.Add(self.patFileCtrl, pos = (1, 0), span = (1, 2),flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 2176         gridBagSizer.Add(self.patWidthText, pos = (2, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2177         gridBagSizer.Add(self.patWidthSpin, pos = (2, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2178         gridBagSizer.Add(self.patScaleText, pos = (3, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2179         gridBagSizer.Add(self.patScaleSpin, pos = (3, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2182         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 2183         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2185         self.Bind(wx.EVT_CHECKBOX, self.OnPattern, self.patternCheck)
 
 2187         panel.SetSizer(border)
 
 2192         """!Change columns on layer change """ 
 2193         if self.layerChoice.GetStringSelection() == self.currLayer:
 
 2195         self.currLayer = self.layerChoice.GetStringSelection()
 
 2197             cols = self.mapDBInfo.GetColumns(self.mapDBInfo.layers[int(self.currLayer)][
'table']) 
 
 2201         self.choiceColumns.SetItems(cols)
 
 2203         self.choiceColumns.SetSelection(0)
 
 2204         if self.type 
in (
'points', 
'lines'):
 
 2205             self.colorColChoice.SetItems(cols)
 
 2206             self.colorColChoice.SetSelection(0)
 
 2209         for widget 
in self.gridBagSizerO.GetChildren():
 
 2210             if widget.GetWindow() != self.outlineCheck:
 
 2211                 widget.GetWindow().Enable(self.outlineCheck.GetValue())
 
 2214         enable = self.fillCheck.GetValue()
 
 2216         self.colorColChoice.Enable(enable)
 
 2217         self.colorColRadio.Enable(enable)
 
 2218         self.fillColorPicker.Enable(enable)
 
 2219         self.colorPickerRadio.Enable(enable)
 
 2222         if not self.connection:
 
 2223             self.colorColChoice.Disable()
 
 2224             self.colorColRadio.Disable()
 
 2227         self.colorColChoice.Enable(self.colorColRadio.GetValue())
 
 2228         self.fillColorPicker.Enable(self.colorPickerRadio.GetValue())
 
 2231         self.sizeSpin.Enable(self.sizeRadio.GetValue())
 
 2232         self.sizeColChoice.Enable(self.sizecolumnRadio.GetValue())
 
 2233         self.scaleText.Enable(self.sizecolumnRadio.GetValue())
 
 2234         self.scaleSpin.Enable(self.sizecolumnRadio.GetValue())
 
 2237         for each 
in (self.rotateRadio, self.rotatecolumnRadio, self.rotateColChoice, self.rotateSpin):
 
 2238             if self.rotateCheck.GetValue():
 
 2240                 self.OnRotationType(event = 
None)     
 
 2245         self.rotateSpin.Enable(self.rotateRadio.GetValue())
 
 2246         self.rotateColChoice.Enable(self.rotatecolumnRadio.GetValue())
 
 2249         for each 
in (self.patFileCtrl, self.patWidthText, self.patWidthSpin, self.patScaleText, self.patScaleSpin):
 
 2250             each.Enable(self.patternCheck.GetValue())
 
 2253         useSymbol = self.symbolRadio.GetValue()
 
 2255         self.symbolButton.Enable(useSymbol)
 
 2256         self.symbolName.Enable(useSymbol)
 
 2257         self.epsFileCtrl.Enable(
not useSymbol)
 
 2260         dlg = 
SymbolDialog(self, symbolPath = globalvar.ETCSYMBOLDIR,
 
 2261                            currentSymbol = self.symbolName.GetLabel())
 
 2262         if dlg.ShowModal() == wx.ID_OK:
 
 2263             img = dlg.GetSelectedSymbolPath()
 
 2264             name = dlg.GetSelectedSymbolName()
 
 2265             self.symbolButton.SetBitmapLabel(wx.Bitmap(img + 
'.png'))
 
 2266             self.symbolName.SetLabel(name)
 
 2271         for widget 
in self.gridBagSizerL.GetChildren():
 
 2272             if widget.GetWindow() != self.warning:
 
 2273                 widget.GetWindow().Enable(enable)
 
 2276         """!Returns a wx.Choice with table columns""" 
 2278             cols = self.mapDBInfo.GetColumns(self.mapDBInfo.layers[int(self.currLayer)][
'table']) 
 
 2282         choice = wx.Choice(parent = parent, id = wx.ID_ANY, choices = cols)
 
 2287         if self.type 
in (
'lines', 
'points'):
 
 2289             if self.checkType1.GetValue():
 
 2290                 featureType = self.checkType1.GetName()
 
 2291                 if self.checkType2.GetValue():
 
 2292                     featureType += 
" or " + self.checkType2.GetName()
 
 2293             elif self.checkType2.GetValue():
 
 2294                 featureType = self.checkType2.GetName()
 
 2296                 self.vPropertiesDict[
'type'] = featureType
 
 2299         self.vPropertiesDict[
'connection'] = self.connection
 
 2301             self.vPropertiesDict[
'layer'] = self.layerChoice.GetStringSelection()
 
 2302             if self.radioCats.GetValue() 
and not self.textCtrlCats.IsEmpty():
 
 2303                 self.vPropertiesDict[
'cats'] = self.textCtrlCats.GetValue()
 
 2304             elif self.radioWhere.GetValue() 
and not self.textCtrlWhere.IsEmpty():
 
 2305                 self.vPropertiesDict[
'where'] = self.choiceColumns.GetStringSelection() + 
" " \
 
 2306                                                                 + self.textCtrlWhere.GetValue()
 
 2308         if self.mask.GetValue():
 
 2309             self.vPropertiesDict[
'masked'] = 
'y'  
 2311             self.vPropertiesDict[
'masked'] = 
'n' 
 2314         if self.type 
in (
'points', 
'areas'):
 
 2315             if self.outlineCheck.GetValue():
 
 2316                 self.vPropertiesDict[
'color'] = 
convertRGB(self.colorPicker.GetColour())
 
 2317                 self.vPropertiesDict[
'width'] = self.widthSpin.GetValue()
 
 2319                 self.vPropertiesDict[
'color'] = 
'none' 
 2321             if self.fillCheck.GetValue():
 
 2322                 if self.colorPickerRadio.GetValue():
 
 2323                     self.vPropertiesDict[
'fcolor'] = 
convertRGB(self.fillColorPicker.GetColour())
 
 2324                     self.vPropertiesDict[
'rgbcolumn'] = 
None 
 2325                 if self.colorColRadio.GetValue():
 
 2326                     self.vPropertiesDict[
'fcolor'] = 
'none' 
 2327                     self.vPropertiesDict[
'rgbcolumn'] = self.colorColChoice.GetStringSelection()
 
 2329                 self.vPropertiesDict[
'fcolor'] = 
'none'     
 2331         if self.type == 
'lines':
 
 2333             if self.outlineCheck.GetValue():
 
 2334                 self.vPropertiesDict[
'hcolor'] = 
convertRGB(self.colorPicker.GetColour())
 
 2335                 self.vPropertiesDict[
'hwidth'] = self.outWidthSpin.GetValue()
 
 2338                 self.vPropertiesDict[
'hcolor'] = 
'none' 
 2340             if self.colorPickerRadio.GetValue():
 
 2341                 self.vPropertiesDict[
'color'] = 
convertRGB(self.fillColorPicker.GetColour())
 
 2342                 self.vPropertiesDict[
'rgbcolumn'] = 
None 
 2343             if self.colorColRadio.GetValue():
 
 2344                 self.vPropertiesDict[
'color'] = 
'none' 
 2345                 self.vPropertiesDict[
'rgbcolumn'] = self.colorColChoice.GetStringSelection()
 
 2350         if self.type == 
'points':
 
 2352             if self.symbolRadio.GetValue():
 
 2353                 self.vPropertiesDict[
'symbol'] = self.symbolName.GetLabel()
 
 2354                 self.vPropertiesDict[
'eps'] = 
None 
 2356                 self.vPropertiesDict[
'eps'] = self.epsFileCtrl.GetValue()
 
 2358             if self.sizeRadio.GetValue():
 
 2359                 self.vPropertiesDict[
'size'] = self.sizeSpin.GetValue()
 
 2360                 self.vPropertiesDict[
'sizecolumn'] = 
None 
 2361                 self.vPropertiesDict[
'scale'] = 
None 
 2363                 self.vPropertiesDict[
'sizecolumn'] = self.sizeColChoice.GetStringSelection()
 
 2364                 self.vPropertiesDict[
'scale'] = self.scaleSpin.GetValue()
 
 2365                 self.vPropertiesDict[
'size'] = 
None 
 2368             self.vPropertiesDict[
'rotate'] = 
None 
 2369             self.vPropertiesDict[
'rotatecolumn'] = 
None 
 2370             self.vPropertiesDict[
'rotation'] = 
False 
 2371             if self.rotateCheck.GetValue():
 
 2372                 self.vPropertiesDict[
'rotation'] = 
True 
 2373             if self.rotateRadio.GetValue():
 
 2374                 self.vPropertiesDict[
'rotate'] = self.rotateSpin.GetValue()
 
 2376                 self.vPropertiesDict[
'rotatecolumn'] = self.rotateColChoice.GetStringSelection()
 
 2378         if self.type == 
'areas':
 
 2380             self.vPropertiesDict[
'pat'] = 
None  
 2381             if self.patternCheck.GetValue() 
and bool(self.patFileCtrl.GetValue()):
 
 2382                 self.vPropertiesDict[
'pat'] = self.patFileCtrl.GetValue()
 
 2383                 self.vPropertiesDict[
'pwidth'] = self.patWidthSpin.GetValue()
 
 2384                 self.vPropertiesDict[
'scale'] = self.patScaleSpin.GetValue()
 
 2386         if self.type == 
'lines':
 
 2388             if self.cwidthCheck.GetValue():
 
 2389                 self.vPropertiesDict[
'cwidth'] = self.widthSpin.GetValue()
 
 2390                 self.vPropertiesDict[
'width'] = 
None 
 2392                 self.vPropertiesDict[
'width'] = self.widthSpin.GetValue()
 
 2393                 self.vPropertiesDict[
'cwidth'] = 
None 
 2395             if self.styleCombo.GetValue():
 
 2396                 self.vPropertiesDict[
'style'] = self.styleCombo.GetValue() 
 
 2398                 self.vPropertiesDict[
'style'] = 
'solid' 
 2400             self.vPropertiesDict[
'linecap'] = self.linecapChoice.GetStringSelection()
 
 2402     def OnOK(self, event):
 
 2408         PsmapDialog.__init__(self, parent = parent, id = id, title = 
"Legend settings", settings = settings)
 
 2411         map = self.instruction.FindInstructionByType(
'map')
 
 2417         vector = self.instruction.FindInstructionByType(
'vector')
 
 2423         raster = self.instruction.FindInstructionByType(
'raster')
 
 2429         self.
pageId = self.instruction.FindInstructionByType(
'page').id
 
 2432         if self.
id[0] 
is not None:
 
 2436             self.
id[0] = wx.NewId()
 
 2438             self.
rLegendDict = self.rasterLegend.GetInstruction()
 
 2439             self.
rLegendDict[
'where'] = currPage[
'Left'], currPage[
'Top']
 
 2443         if self.
id[1] 
is not None:
 
 2446             self.
id[1] = wx.NewId()
 
 2447             vectorLegend = VectorLegend(self.
id[1])
 
 2449             self.
vLegendDict[
'where'] = currPage[
'Left'], currPage[
'Top']
 
 2457         self.
notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
 
 2462         self.OnIsLegend(
None)
 
 2467         self.notebook.ChangeSelection(page)
 
 2468         self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.
OnPageChanging)
 
 2471         """!Workaround to scroll up to see the checkbox""" 
 2472         wx.CallAfter(self.FindWindowByName(
'rasterPanel').ScrollChildIntoView,
 
 2473                                             self.FindWindowByName(
'showRLegend'))
 
 2474         wx.CallAfter(self.FindWindowByName(
'vectorPanel').ScrollChildIntoView,
 
 2475                                             self.FindWindowByName(
'showVLegend'))
 
 2477     def _rasterLegend(self, notebook):
 
 2478         panel = scrolled.ScrolledPanel(parent = notebook, id = wx.ID_ANY, size = (-1, 500), style = wx.TAB_TRAVERSAL)
 
 2479         panel.SetupScrolling(scroll_x = 
False, scroll_y = 
True)
 
 2480         panel.SetName(
'rasterPanel')
 
 2481         notebook.AddPage(page = panel, text = _(
"Raster legend"))
 
 2483         border = wx.BoxSizer(wx.VERTICAL)
 
 2485         self.
isRLegend = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"Show raster legend"))
 
 2486         self.isRLegend.SetValue(self.
rLegendDict[
'rLegend'])
 
 2487         self.isRLegend.SetName(
"showRLegend")
 
 2488         border.Add(item = self.
isRLegend, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2491         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Source raster"))
 
 2492         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 2493         flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
 
 2494         flexSizer.AddGrowableCol(1)
 
 2496         self.
rasterDefault = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"current raster"), style = wx.RB_GROUP)
 
 2497         self.
rasterOther = wx.RadioButton(panel, id = wx.ID_ANY, label = _(
"select raster"))
 
 2498         self.rasterDefault.SetValue(self.
rLegendDict[
'rasterDefault'])
 
 2499         self.rasterOther.SetValue(
not self.
rLegendDict[
'rasterDefault'])
 
 2504                                 label = _(
"%(rast)s: type %(type)s") % { 
'rast' : self.
currRaster,
 
 2505                                                                          'type' : rasterType })
 
 2506         self.
rasterSelect = Select(panel, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
 
 2507                                     type = 
'raster', multiple = 
False,
 
 2508                                     updateOnPopup = 
True, onPopup = 
None)
 
 2510             self.rasterSelect.SetValue(self.
rLegendDict[
'raster'])
 
 2512             self.rasterSelect.SetValue(
'')
 
 2513         flexSizer.Add(self.
rasterDefault, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2514         flexSizer.Add(self.
rasterCurrent, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.LEFT, border = 10)
 
 2515         flexSizer.Add(self.
rasterOther, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2516         flexSizer.Add(self.
rasterSelect, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border = 0)
 
 2518         sizer.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
 
 2519         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2523         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Type of legend"))        
 
 2524         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 2525         vbox = wx.BoxSizer(wx.VERTICAL)
 
 2526         self.
discrete = wx.RadioButton(parent = panel, id = wx.ID_ANY, 
 
 2527                         label = 
" %s " % _(
"discrete legend (categorical maps)"), style = wx.RB_GROUP)
 
 2529                         label = 
" %s " % _(
"continuous color gradient legend (floating point map)"))
 
 2531         vbox.Add(self.
discrete, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 0)
 
 2532         vbox.Add(self.
continuous, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 0)
 
 2533         sizer.Add(item = vbox, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
 
 2534         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2537         self.sizePositionFont(legendType = 
'raster', parent = panel, mainSizer = border)
 
 2540         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Advanced legend settings"))
 
 2541         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 2542         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 2544         self.
nodata = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
'draw "no data" box'))
 
 2546             self.nodata.SetValue(
True)
 
 2548             self.nodata.SetValue(
False)
 
 2550         self.
ticks = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"draw ticks across color table"))
 
 2552             self.ticks.SetValue(
True)
 
 2554             self.ticks.SetValue(
False)
 
 2558             self.minim, self.
maxim = rinfo[
'min'], rinfo[
'max']
 
 2560             self.minim, self.
maxim = 0,0
 
 2561         self.
range = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"range"))
 
 2563         self.
minText =  wx.StaticText(panel, id = wx.ID_ANY, label = 
"min (%s)" % self.minim)
 
 2564         self.
maxText =  wx.StaticText(panel, id = wx.ID_ANY, label = 
"max (%s)" % self.
maxim)       
 
 2568         gridBagSizer.Add(self.
nodata, pos = (0,0), span = (1,5), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2569         gridBagSizer.Add(self.
ticks, pos = (1,0), span = (1,5), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2570         gridBagSizer.Add(self.
range, pos = (2,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2571         gridBagSizer.Add(self.
minText, pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border = 0)
 
 2572         gridBagSizer.Add(self.
min, pos = (2,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2573         gridBagSizer.Add(self.
maxText, pos = (2,3), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT, border = 0)
 
 2574         gridBagSizer.Add(self.
max, pos = (2,4), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2576         sizer.Add(gridBagSizer, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2577         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2579         panel.SetSizer(border)
 
 2583         self.Bind(wx.EVT_RADIOBUTTON, self.OnRaster, self.
rasterDefault)
 
 2584         self.Bind(wx.EVT_RADIOBUTTON, self.OnRaster, self.
rasterOther)
 
 2585         self.Bind(wx.EVT_CHECKBOX, self.OnIsLegend, self.
isRLegend)
 
 2586         self.Bind(wx.EVT_RADIOBUTTON, self.OnDiscrete, self.
discrete)
 
 2587         self.Bind(wx.EVT_RADIOBUTTON, self.OnDiscrete, self.
continuous)
 
 2589         self.Bind(wx.EVT_CHECKBOX, self.OnRange, self.
range)
 
 2590         self.rasterSelect.GetTextCtrl().Bind(wx.EVT_TEXT, self.OnRaster)
 
 2594     def _vectorLegend(self, notebook):
 
 2595         panel = scrolled.ScrolledPanel(parent = notebook, id = wx.ID_ANY, size = (-1, 500), style = wx.TAB_TRAVERSAL)
 
 2596         panel.SetupScrolling(scroll_x = 
False, scroll_y = 
True)
 
 2597         panel.SetName(
'vectorPanel')
 
 2598         notebook.AddPage(page = panel, text = _(
"Vector legend"))
 
 2600         border = wx.BoxSizer(wx.VERTICAL)
 
 2602         self.isVLegend = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"Show vector legend"))
 
 2603         self.isVLegend.SetValue(self.vLegendDict[
'vLegend'])
 
 2604         self.isVLegend.SetName(
"showVLegend")
 
 2605         border.Add(item = self.isVLegend, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2608         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Source vector maps"))
 
 2609         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 2610         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 2611         gridBagSizer.AddGrowableCol(0,3)
 
 2612         gridBagSizer.AddGrowableCol(1,1)
 
 2614         vectorText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Choose vector maps and their order in legend"))
 
 2618         self.vectorListCtrl.InsertColumn(0, _(
"Vector map"))
 
 2619         self.vectorListCtrl.InsertColumn(1, _(
"Label"))
 
 2621             vectors = sorted(self.instruction[self.vectorId][
'list'], key = 
lambda x: x[3])
 
 2623             for vector 
in vectors:
 
 2624                 index = self.vectorListCtrl.InsertStringItem(sys.maxint, vector[0].
split(
'@')[0])
 
 2625                 self.vectorListCtrl.SetStringItem(index, 1, vector[4])
 
 2626                 self.vectorListCtrl.SetItemData(index, index)
 
 2627                 self.vectorListCtrl.CheckItem(index, 
True)
 
 2629                     self.vectorListCtrl.CheckItem(index, 
False)
 
 2630         if not self.vectorId:
 
 2631             self.vectorListCtrl.SetColumnWidth(0, 100)
 
 2633             self.vectorListCtrl.SetColumnWidth(0, wx.LIST_AUTOSIZE)
 
 2634         self.vectorListCtrl.SetColumnWidth(1, wx.LIST_AUTOSIZE)
 
 2636         self.btnUp = wx.Button(panel, id = wx.ID_ANY, label = _(
"Up"))
 
 2637         self.btnDown = wx.Button(panel, id = wx.ID_ANY, label = _(
"Down"))
 
 2638         self.btnLabel = wx.Button(panel, id = wx.ID_ANY, label = _(
"Edit label"))
 
 2640         gridBagSizer.Add(vectorText, pos = (0,0), span = (1,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2641         gridBagSizer.Add(self.vectorListCtrl, pos = (1,0), span = (3,1), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 2642         gridBagSizer.Add(self.btnUp, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2643         gridBagSizer.Add(self.btnDown, pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2644         gridBagSizer.Add(self.btnLabel, pos = (3,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2646         sizer.Add(gridBagSizer, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 2647         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2650         self.sizePositionFont(legendType = 
'vector', parent = panel, mainSizer = border)
 
 2653         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Border"))
 
 2654         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 2655         flexGridSizer = wx.FlexGridSizer(cols = 2, hgap = 5, vgap = 5)
 
 2657         self.borderCheck = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"draw border around legend"))
 
 2658         self.borderColorCtrl = wx.ColourPickerCtrl(panel, id = wx.ID_ANY, style = wx.FNTP_FONTDESC_AS_LABEL)
 
 2659         if self.vLegendDict[
'border'] == 
'none':
 
 2660             self.borderColorCtrl.SetColour(wx.BLACK)
 
 2661             self.borderCheck.SetValue(
False)
 
 2663             self.borderColorCtrl.SetColour(
convertRGB(self.vLegendDict[
'border']))
 
 2664             self.borderCheck.SetValue(
True)
 
 2666         flexGridSizer.Add(self.borderCheck, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)    
 
 2667         flexGridSizer.Add(self.borderColorCtrl, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2668         sizer.Add(item = flexGridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
 
 2669         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2671         self.Bind(wx.EVT_BUTTON, self.OnUp, self.btnUp)
 
 2672         self.Bind(wx.EVT_BUTTON, self.OnDown, self.btnDown)  
 
 2673         self.Bind(wx.EVT_BUTTON, self.OnEditLabel, self.btnLabel)
 
 2674         self.Bind(wx.EVT_CHECKBOX, self.OnIsLegend, self.isVLegend)    
 
 2675         self.Bind(wx.EVT_CHECKBOX, self.OnSpan, panel.spanRadio)  
 
 2676         self.Bind(wx.EVT_CHECKBOX, self.OnBorder, self.borderCheck)
 
 2677         self.Bind(wx.EVT_FONTPICKER_CHANGED, self.OnFont, panel.font[
'fontCtrl']) 
 
 2679         panel.SetSizer(border)
 
 2685         """!Insert widgets for size, position and font control""" 
 2686         if legendType == 
'raster':
 
 2687             legendDict = self.rLegendDict  
 
 2689             legendDict = self.vLegendDict
 
 2694         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Size and position"))
 
 2695         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 2697         self.AddUnits(parent = panel, dialogDict = legendDict)
 
 2698         unitBox = wx.BoxSizer(wx.HORIZONTAL)
 
 2699         unitBox.Add(panel.units[
'unitsLabel'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.LEFT, border = 10)
 
 2700         unitBox.Add(panel.units[
'unitsCtrl'], proportion = 1, flag = wx.ALL, border = 5)
 
 2701         sizer.Add(unitBox, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2703         hBox = wx.BoxSizer(wx.HORIZONTAL)
 
 2704         posBox = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " %_(
"Position"))
 
 2705         posSizer = wx.StaticBoxSizer(posBox, wx.VERTICAL)       
 
 2706         sizeBox = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Size"))
 
 2707         sizeSizer = wx.StaticBoxSizer(sizeBox, wx.VERTICAL) 
 
 2708         posGridBagSizer = wx.GridBagSizer(hgap = 10, vgap = 5)
 
 2709         posGridBagSizer.AddGrowableRow(2)
 
 2712         self.AddPosition(parent = panel, dialogDict = legendDict)
 
 2714         posGridBagSizer.Add(panel.position[
'xLabel'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2715         posGridBagSizer.Add(panel.position[
'xCtrl'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2716         posGridBagSizer.Add(panel.position[
'yLabel'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2717         posGridBagSizer.Add(panel.position[
'yCtrl'], pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2718         posGridBagSizer.Add(panel.position[
'comment'], pos = (2,0), span = (1,2), flag =wx.ALIGN_BOTTOM, border = 0)
 
 2719         posSizer.Add(posGridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 2722         width = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Width:"))
 
 2723         if legendDict[
'width']:
 
 2724             w = self.unitConv.convert(value = float(legendDict[
'width']), fromUnit = 
'inch', toUnit = legendDict[
'unit'])
 
 2727         panel.widthCtrl = wx.TextCtrl(panel, id = wx.ID_ANY, value = str(w), validator = 
TCValidator(
"DIGIT_ONLY"))
 
 2728         panel.widthCtrl.SetToolTipString(_(
"Leave the edit field empty, to use default values."))
 
 2730         if legendType == 
'raster':
 
 2734             panel.heightOrColumnsLabel = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Height:"))
 
 2735             if legendDict[
'height']:
 
 2736                 h = self.unitConv.convert(value = float(legendDict[
'height']), fromUnit = 
'inch', toUnit = legendDict[
'unit'])
 
 2739             panel.heightOrColumnsCtrl = wx.TextCtrl(panel, id = wx.ID_ANY, value = str(h), validator = 
TCValidator(
"DIGIT_ONLY"))
 
 2741             self.rSizeGBSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 2743             self.rSizeGBSizer.Add(width, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2744             self.rSizeGBSizer.Add(panel.widthCtrl, pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2745             self.rSizeGBSizer.Add(panel.heightOrColumnsLabel, pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2746             self.rSizeGBSizer.Add(panel.heightOrColumnsCtrl, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2747             sizeSizer.Add(self.rSizeGBSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 2749         if legendType == 
'vector':
 
 2750             panel.widthCtrl.SetToolTipString(_(
"Width of the color symbol (for lines)\nin front of the legend text")) 
 
 2752             minVect, maxVect = 0, 0
 
 2755                 maxVect = 
min(10, len(self.instruction[self.vectorId][
'list']))
 
 2756             cols = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Columns:"))
 
 2757             panel.colsCtrl = wx.SpinCtrl(panel, id = wx.ID_ANY, value = 
"",
 
 2758                                         min = minVect, max = maxVect, initial = legendDict[
'cols'])
 
 2760             panel.spanRadio = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"column span:"))
 
 2761             panel.spanTextCtrl = wx.TextCtrl(panel, id = wx.ID_ANY, value = 
'')
 
 2762             panel.spanTextCtrl.SetToolTipString(_(
"Column separation distance between the left edges\n"\
 
 2763                                                 "of two columns in a multicolumn legend"))
 
 2764             if legendDict[
'span']:
 
 2765                 panel.spanRadio.SetValue(
True)
 
 2766                 s = self.unitConv.convert(value = float(legendDict[
'span']), fromUnit = 
'inch', toUnit = legendDict[
'unit'])    
 
 2767                 panel.spanTextCtrl.SetValue(str(s))
 
 2769                 panel.spanRadio.SetValue(
False)
 
 2771             self.vSizeGBSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 2772             self.vSizeGBSizer.AddGrowableCol(1)
 
 2773             self.vSizeGBSizer.Add(width, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2774             self.vSizeGBSizer.Add(panel.widthCtrl, pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2775             self.vSizeGBSizer.Add(cols, pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2776             self.vSizeGBSizer.Add(panel.colsCtrl, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2777             self.vSizeGBSizer.Add(panel.spanRadio, pos = (2,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2778             self.vSizeGBSizer.Add(panel.spanTextCtrl, pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2779             sizeSizer.Add(self.vSizeGBSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)        
 
 2781         hBox.Add(posSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 3)
 
 2782         hBox.Add(sizeSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 3)
 
 2783         sizer.Add(hBox, proportion = 0, flag = wx.EXPAND, border = 0)
 
 2784         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 2787         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Font settings"))
 
 2788         fontSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 2789         flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
 
 2790         flexSizer.AddGrowableCol(1)
 
 2792         if legendType == 
'raster':
 
 2793             self.AddFont(parent = panel, dialogDict = legendDict, color = 
True)
 
 2795             self.AddFont(parent = panel, dialogDict = legendDict, color = 
False)            
 
 2796         flexSizer.Add(panel.font[
'fontLabel'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2797         flexSizer.Add(panel.font[
'fontCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2798         flexSizer.Add(panel.font[
'fontSizeLabel'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2799         flexSizer.Add(panel.font[
'fontSizeCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2800         if legendType == 
'raster':
 
 2801             flexSizer.Add(panel.font[
'colorLabel'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 2802             flexSizer.Add(panel.font[
'colorCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2804         fontSizer.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
 
 2805         border.Add(item = fontSizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)    
 
 2810         """!Enables and disables controls, it depends if raster or vector legend is checked""" 
 2811         page = self.notebook.GetSelection()
 
 2812         if page == 0 
or event 
is None:
 
 2813             children = self.panelRaster.GetChildren()
 
 2814             if self.isRLegend.GetValue():
 
 2815                 for i,widget 
in enumerate(children):
 
 2819                 self.OnDiscrete(
None)
 
 2821                 for widget 
in children:
 
 2822                     if widget.GetName() != 
'showRLegend':
 
 2824         if page == 1 
or event 
is None:
 
 2825             children = self.panelVector.GetChildren()
 
 2826             if self.isVLegend.GetValue():
 
 2827                 for i, widget 
in enumerate(children):
 
 2832                 for widget 
in children:
 
 2833                     if widget.GetName() != 
'showVLegend':
 
 2837         if self.rasterDefault.GetValue():
 
 2838             self.rasterSelect.Disable()
 
 2841             self.rasterSelect.Enable()
 
 2842             map = self.rasterSelect.GetValue()
 
 2846             self.discrete.SetValue(
True)
 
 2847         elif type 
in (
'FCELL', 
'DCELL'):
 
 2848             self.continuous.SetValue(
True)
 
 2850             if self.rLegendDict[
'discrete'] == 
'y':
 
 2851                 self.discrete.SetValue(
True)
 
 2852             elif self.rLegendDict[
'discrete'] == 
'n':
 
 2853                 self.continuous.SetValue(
True)
 
 2854         self.OnDiscrete(
None)
 
 2857         """! Change control according to the type of legend""" 
 2858         enabledSize = self.panelRaster.heightOrColumnsCtrl.IsEnabled()
 
 2859         self.panelRaster.heightOrColumnsCtrl.Destroy()
 
 2860         if self.discrete.GetValue():
 
 2861             self.panelRaster.heightOrColumnsLabel.SetLabel(_(
"Columns:"))
 
 2862             self.panelRaster.heightOrColumnsCtrl = wx.SpinCtrl(self.panelRaster, id = wx.ID_ANY, value = 
"", min = 1, max = 10, initial = self.rLegendDict[
'cols'])
 
 2863             self.panelRaster.heightOrColumnsCtrl.Enable(enabledSize)
 
 2864             self.nodata.Enable()
 
 2865             self.range.Disable()
 
 2868             self.minText.Disable()
 
 2869             self.maxText.Disable()
 
 2870             self.ticks.Disable()
 
 2872             self.panelRaster.heightOrColumnsLabel.SetLabel(_(
"Height:"))
 
 2873             if self.rLegendDict[
'height']:
 
 2874                 h = self.unitConv.convert(value = float(self.rLegendDict[
'height']), fromUnit = 
'inch', toUnit = self.rLegendDict[
'unit'])
 
 2877             self.panelRaster.heightOrColumnsCtrl = wx.TextCtrl(self.panelRaster, id = wx.ID_ANY,
 
 2878                                                     value = str(h), validator = 
TCValidator(
"DIGIT_ONLY"))
 
 2879             self.panelRaster.heightOrColumnsCtrl.Enable(enabledSize)
 
 2880             self.nodata.Disable()
 
 2882             if self.range.GetValue():
 
 2883                 self.minText.Enable()
 
 2884                 self.maxText.Enable()
 
 2889         self.rSizeGBSizer.Add(self.panelRaster.heightOrColumnsCtrl, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 2890         self.panelRaster.Layout()
 
 2891         self.panelRaster.Fit()   
 
 2894         if not self.range.GetValue():
 
 2897             self.minText.Disable()
 
 2898             self.maxText.Disable()
 
 2902             self.minText.Enable()
 
 2903             self.maxText.Enable()           
 
 2906         """!Moves selected map up, changes order in vector legend""" 
 2907         if self.vectorListCtrl.GetFirstSelected() != -1:
 
 2908             pos = self.vectorListCtrl.GetFirstSelected()
 
 2910                 idx1 = self.vectorListCtrl.GetItemData(pos) - 1
 
 2911                 idx2 = self.vectorListCtrl.GetItemData(pos - 1) + 1
 
 2912                 self.vectorListCtrl.SetItemData(pos, idx1) 
 
 2913                 self.vectorListCtrl.SetItemData(pos - 1, idx2) 
 
 2914                 self.vectorListCtrl.SortItems(cmp)
 
 2916                     selected = (pos - 1) 
 
 2920                 self.vectorListCtrl.Select(selected)
 
 2923         """!Moves selected map down, changes order in vector legend""" 
 2924         if self.vectorListCtrl.GetFirstSelected() != -1:
 
 2925             pos = self.vectorListCtrl.GetFirstSelected()
 
 2926             if pos != self.vectorListCtrl.GetItemCount() - 1:
 
 2927                 idx1 = self.vectorListCtrl.GetItemData(pos) + 1
 
 2928                 idx2 = self.vectorListCtrl.GetItemData(pos + 1) - 1
 
 2929                 self.vectorListCtrl.SetItemData(pos, idx1) 
 
 2930                 self.vectorListCtrl.SetItemData(pos + 1, idx2) 
 
 2931                 self.vectorListCtrl.SortItems(cmp)
 
 2932                 if pos < self.vectorListCtrl.GetItemCount() -1:
 
 2933                     selected = (pos + 1) 
 
 2935                     selected = self.vectorListCtrl.GetItemCount() -1
 
 2937                 self.vectorListCtrl.Select(selected)
 
 2940         """!Change legend label of vector map""" 
 2941         if self.vectorListCtrl.GetFirstSelected() != -1:
 
 2942             idx = self.vectorListCtrl.GetFirstSelected()
 
 2943             default = self.vectorListCtrl.GetItem(idx, 1).GetText()
 
 2944             dlg = wx.TextEntryDialog(self, message = _(
"Edit legend label:"), caption = _(
"Edit label"),
 
 2945                                     defaultValue = default, style = wx.OK|wx.CANCEL|wx.CENTRE)
 
 2946             if dlg.ShowModal() == wx.ID_OK:
 
 2947                 new = dlg.GetValue()
 
 2948                 self.vectorListCtrl.SetStringItem(idx, 1, new)
 
 2952         self.panelVector.spanTextCtrl.Enable(self.panelVector.spanRadio.GetValue())
 
 2954         """!Changes default width according to fontsize, width [inch] = fontsize[pt]/24"""    
 2956         fontsize = self.panelVector.font[
'fontSizeCtrl'].
GetValue()
 
 2957         unit = self.unitConv.findUnit(self.panelVector.units[
'unitsCtrl'].GetStringSelection())
 
 2959         width = self.unitConv.convert(value = w, fromUnit = 
'inch', toUnit = unit)
 
 2960         self.panelVector.widthCtrl.SetValue(
"%3.2f" % width)
 
 2963         """!Enables/disables colorPickerCtrl for border"""     
 2964         self.borderColorCtrl.Enable(self.borderCheck.GetValue())
 
 2967         """!Save information from raster legend dialog to dictionary""" 
 2970         if not self.isRLegend.GetValue():
 
 2971             self.rLegendDict[
'rLegend'] = 
False 
 2973             self.rLegendDict[
'rLegend'] = 
True 
 2975         currUnit = self.unitConv.findUnit(self.panelRaster.units[
'unitsCtrl'].GetStringSelection())
 
 2976         self.rLegendDict[
'unit'] = currUnit
 
 2978         if self.rasterDefault.GetValue():
 
 2979             self.rLegendDict[
'rasterDefault'] = 
True 
 2980             self.rLegendDict[
'raster'] = self.currRaster
 
 2982             self.rLegendDict[
'rasterDefault'] = 
False 
 2983             self.rLegendDict[
'raster'] = self.rasterSelect.GetValue()
 
 2984         if self.rLegendDict[
'rLegend'] 
and not self.rLegendDict[
'raster']:
 
 2985             wx.MessageBox(message = _(
"No raster map selected!"),
 
 2986                                     caption = _(
'No raster'), style = wx.OK|wx.ICON_ERROR)
 
 2989         if self.rLegendDict[
'raster']:
 
 2992             if rasterType 
is None:
 
 2994             self.rLegendDict[
'type'] = rasterType
 
 2998             if self.discrete.GetValue():
 
 2999                 self.rLegendDict[
'discrete'] = 
'y' 
 3001                 self.rLegendDict[
'discrete'] = 
'n'    
 3004             self.rLegendDict[
'font'] = self.panelRaster.font[
'fontCtrl'].GetStringSelection()
 
 3005             self.rLegendDict[
'fontsize'] = self.panelRaster.font[
'fontSizeCtrl'].
GetValue()
 
 3006             color = self.panelRaster.font[
'colorCtrl'].GetColour()
 
 3007             self.rLegendDict[
'color'] = 
convertRGB(color)
 
 3010             x = self.unitConv.convert(value = float(self.panelRaster.position[
'xCtrl'].
GetValue()), fromUnit = currUnit, toUnit = 
'inch')
 
 3011             y = self.unitConv.convert(value = float(self.panelRaster.position[
'yCtrl'].
GetValue()), fromUnit = currUnit, toUnit = 
'inch')
 
 3012             self.rLegendDict[
'where'] = (x, y)
 
 3014             width = self.panelRaster.widthCtrl.GetValue()
 
 3016                 width = float(width)
 
 3017                 width = self.unitConv.convert(value = width, fromUnit = currUnit, toUnit = 
'inch')
 
 3020             self.rLegendDict[
'width'] = width
 
 3021             if self.rLegendDict[
'discrete'] == 
'n':
 
 3022                 height = self.panelRaster.heightOrColumnsCtrl.GetValue()    
 
 3024                     height = float(height)
 
 3025                     height = self.unitConv.convert(value = height, fromUnit = currUnit, toUnit = 
'inch')
 
 3028                 self.rLegendDict[
'height'] = height
 
 3030                 cols = self.panelRaster.heightOrColumnsCtrl.GetValue()
 
 3031                 self.rLegendDict[
'cols'] = cols
 
 3032             drawHeight = self.rasterLegend.EstimateHeight(raster = self.rLegendDict[
'raster'], discrete = self.rLegendDict[
'discrete'],
 
 3033                                             fontsize = self.rLegendDict[
'fontsize'], cols = self.rLegendDict[
'cols'],
 
 3034                                             height = self.rLegendDict[
'height'])
 
 3035             drawWidth = self.rasterLegend.EstimateWidth(raster = self.rLegendDict[
'raster'], discrete = self.rLegendDict[
'discrete'],
 
 3036                                             fontsize = self.rLegendDict[
'fontsize'], cols = self.rLegendDict[
'cols'],
 
 3037                                             width = self.rLegendDict[
'width'], paperInstr = self.instruction[self.pageId])
 
 3038             self.rLegendDict[
'rect'] = Rect2D(x = x, y = y, width = drawWidth, height = drawHeight)
 
 3041             if self.rLegendDict[
'discrete'] == 
'y':
 
 3042                 if self.nodata.GetValue():
 
 3043                     self.rLegendDict[
'nodata'] = 
'y' 
 3045                     self.rLegendDict[
'nodata'] = 
'n' 
 3047             elif self.rLegendDict[
'discrete'] == 
'n':
 
 3048                 if self.ticks.GetValue():
 
 3049                     self.rLegendDict[
'tickbar'] = 
'y' 
 3051                     self.rLegendDict[
'tickbar'] = 
'n' 
 3053                 if self.range.GetValue():
 
 3054                     self.rLegendDict[
'range'] = 
True 
 3055                     self.rLegendDict[
'min'] = self.min.GetValue()
 
 3056                     self.rLegendDict[
'max'] = self.max.GetValue()
 
 3058                     self.rLegendDict[
'range'] = 
False 
 3060         if not self.id[0] 
in self.instruction:
 
 3061             rasterLegend = RasterLegend(self.id[0])
 
 3062             self.instruction.AddInstruction(rasterLegend)
 
 3063         self.instruction[self.id[0]].SetInstruction(self.rLegendDict)
 
 3065         if self.id[0] 
not in self.parent.objectId:
 
 3066             self.parent.objectId.append(self.id[0])
 
 3070         """!Save information from vector legend dialog to dictionary""" 
 3072         vector = self.instruction.FindInstructionByType(
'vector')
 
 3074             self.vectorId = vector.id 
 
 3076             self.vectorId = 
None 
 3079         if not self.isVLegend.GetValue():
 
 3080             self.vLegendDict[
'vLegend'] = 
False 
 3082             self.vLegendDict[
'vLegend'] = 
True    
 3083         if self.vLegendDict[
'vLegend'] == 
True and self.vectorId 
is not None:
 
 3087             for item 
in range(self.vectorListCtrl.GetItemCount()):
 
 3088                 if self.vectorListCtrl.IsChecked(item):
 
 3089                     self.vectorListCtrl.SetItemData(item, idx)
 
 3092                     self.vectorListCtrl.SetItemData(item, 0)
 
 3094                 self.vLegendDict[
'vLegend'] = 
False      
 3096                 vList = self.instruction[self.vectorId][
'list']
 
 3097                 for i, vector 
in enumerate(vList):
 
 3098                     item = self.vectorListCtrl.FindItem(start = -1, str = vector[0].
split(
'@')[0])
 
 3099                     vList[i][3] = self.vectorListCtrl.GetItemData(item)
 
 3100                     vList[i][4] = self.vectorListCtrl.GetItem(item, 1).GetText()
 
 3101                 vmaps = self.instruction.FindInstructionByType(
'vProperties', list = 
True)
 
 3102                 for vmap, vector 
in zip(vmaps, vList):
 
 3103                     self.instruction[vmap.id][
'lpos'] = vector[3]
 
 3104                     self.instruction[vmap.id][
'label'] = vector[4]
 
 3106                 currUnit = self.unitConv.findUnit(self.panelVector.units[
'unitsCtrl'].GetStringSelection())
 
 3107                 self.vLegendDict[
'unit'] = currUnit
 
 3109                 x = self.unitConv.convert(value = float(self.panelVector.position[
'xCtrl'].
GetValue()),
 
 3110                                                                 fromUnit = currUnit, toUnit = 
'inch')
 
 3111                 y = self.unitConv.convert(value = float(self.panelVector.position[
'yCtrl'].
GetValue()),
 
 3112                                                                 fromUnit = currUnit, toUnit = 
'inch')
 
 3113                 self.vLegendDict[
'where'] = (x, y)
 
 3116                 self.vLegendDict[
'font'] = self.panelVector.font[
'fontCtrl'].GetStringSelection()
 
 3117                 self.vLegendDict[
'fontsize'] = self.panelVector.font[
'fontSizeCtrl'].
GetValue()
 
 3118                 dc = wx.ClientDC(self)
 
 3119                 dc.SetFont(wx.Font(pointSize = self.vLegendDict[
'fontsize'], family = wx.FONTFAMILY_DEFAULT,
 
 3120                                    style = wx.FONTSTYLE_NORMAL, weight = wx.FONTWEIGHT_NORMAL))
 
 3122                 width = self.unitConv.convert(value = float(self.panelVector.widthCtrl.GetValue()),
 
 3123                                               fromUnit = currUnit, toUnit = 
'inch')
 
 3124                 self.vLegendDict[
'width'] = width
 
 3125                 self.vLegendDict[
'cols'] = self.panelVector.colsCtrl.GetValue()
 
 3126                 if self.panelVector.spanRadio.GetValue() 
and self.panelVector.spanTextCtrl.GetValue():
 
 3127                     self.vLegendDict[
'span'] = self.panelVector.spanTextCtrl.GetValue()
 
 3129                     self.vLegendDict[
'span'] = 
None 
 3132                 vectors = self.instruction[self.vectorId][
'list']
 
 3133                 labels = [vector[4] 
for vector 
in vectors 
if vector[3] != 0]
 
 3134                 extent = dc.GetTextExtent(
max(labels, key = len))
 
 3135                 wExtent = self.unitConv.convert(value = extent[0], fromUnit = 
'pixel', toUnit = 
'inch')
 
 3136                 hExtent = self.unitConv.convert(value = extent[1], fromUnit = 
'pixel', toUnit = 
'inch')
 
 3137                 w = (width + wExtent) * self.vLegendDict[
'cols']
 
 3138                 h = len(labels) * hExtent / self.vLegendDict[
'cols']
 
 3140                 self.vLegendDict[
'rect'] = Rect2D(x, y, w, h)
 
 3143                 if self.borderCheck.GetValue():
 
 3144                     color = self.borderColorCtrl.GetColour()
 
 3145                     self.vLegendDict[
'border'] = 
convertRGB(color)
 
 3148                     self.vLegendDict[
'border'] = 
'none' 
 3150         if not self.id[1] 
in self.instruction:
 
 3151             vectorLegend = VectorLegend(self.id[1])
 
 3152             self.instruction.AddInstruction(vectorLegend)
 
 3153         self.instruction[self.id[1]].SetInstruction(self.vLegendDict)
 
 3154         if self.id[1] 
not in self.parent.objectId:
 
 3155             self.parent.objectId.append(self.id[1])
 
 3159         okR = self.updateRasterLegend()
 
 3160         okV = self.updateVectorLegend()
 
 3166         """!Update legend coordinates after moving""" 
 3169         if 'rect' in self.rLegendDict:
 
 3170             x, y = self.rLegendDict[
'rect'][:2]
 
 3171             currUnit = self.unitConv.findUnit(self.panelRaster.units[
'unitsCtrl'].GetStringSelection())
 
 3172             x = self.unitConv.convert(value = x, fromUnit = 
'inch', toUnit = currUnit)
 
 3173             y = self.unitConv.convert(value = y, fromUnit = 
'inch', toUnit = currUnit)
 
 3174             self.panelRaster.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
 3175             self.panelRaster.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
 3177         raster = self.instruction.FindInstructionByType(
'raster')
 
 3179             self.rasterId = raster.id 
 
 3181             self.rasterId = 
None  
 3184             currRaster = raster[
'raster'] 
 
 3189         self.rasterCurrent.SetLabel(_(
"%(rast)s: type %(type)s") % \
 
 3190                                         { 
'rast' : currRaster, 
'type' : str(rasterType) })
 
 3193         if 'rect' in self.vLegendDict:
 
 3194             x, y = self.vLegendDict[
'rect'][:2]
 
 3195             currUnit = self.unitConv.findUnit(self.panelVector.units[
'unitsCtrl'].GetStringSelection())
 
 3196             x = self.unitConv.convert(value = x, fromUnit = 
'inch', toUnit = currUnit)
 
 3197             y = self.unitConv.convert(value = y, fromUnit = 
'inch', toUnit = currUnit)
 
 3198             self.panelVector.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
 3199             self.panelVector.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
 3201         if self.instruction.FindInstructionByType(
'vector'):
 
 3202             vectors = sorted(self.instruction.FindInstructionByType(
'vector')[
'list'], key = 
lambda x: x[3])
 
 3203             self.vectorListCtrl.DeleteAllItems()
 
 3204             for vector 
in vectors:
 
 3205                 index = self.vectorListCtrl.InsertStringItem(sys.maxint, vector[0].
split(
'@')[0])
 
 3206                 self.vectorListCtrl.SetStringItem(index, 1, vector[4])
 
 3207                 self.vectorListCtrl.SetItemData(index, index)
 
 3208                 self.vectorListCtrl.CheckItem(index, 
True)
 
 3210                     self.vectorListCtrl.CheckItem(index, 
False)
 
 3211             self.panelVector.colsCtrl.SetRange(1, 
min(10, len(self.instruction.FindInstructionByType(
'vector')[
'list'])))
 
 3212             self.panelVector.colsCtrl.SetValue(1)
 
 3214             self.vectorListCtrl.DeleteAllItems()
 
 3215             self.panelVector.colsCtrl.SetRange(0,0)
 
 3216             self.panelVector.colsCtrl.SetValue(0)
 
 3220         PsmapDialog.__init__(self, parent = parent, id = id, title = _(
"Mapinfo settings"), settings = settings)
 
 3223         if self.
id is not None:
 
 3230             page = self.instruction.FindInstructionByType(
'page').GetInstruction()
 
 3231             self.
mapinfoDict[
'where'] = page[
'Left'], page[
'Top']
 
 3235         self._layout(self.
panel)
 
 3239     def _mapinfoPanel(self):
 
 3240         panel = wx.Panel(parent = self, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 3242         border = wx.BoxSizer(wx.VERTICAL)
 
 3245         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Position"))
 
 3246         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3247         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 3248         gridBagSizer.AddGrowableCol(1)
 
 3252         gridBagSizer.Add(panel.units[
'unitsLabel'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3253         gridBagSizer.Add(panel.units[
'unitsCtrl'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3254         gridBagSizer.Add(panel.position[
'xLabel'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3255         gridBagSizer.Add(panel.position[
'xCtrl'], pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3256         gridBagSizer.Add(panel.position[
'yLabel'], pos = (2,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3257         gridBagSizer.Add(panel.position[
'yCtrl'], pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3258         gridBagSizer.Add(panel.position[
'comment'], pos = (3,0), span = (1,2), flag =wx.ALIGN_BOTTOM, border = 0)
 
 3260         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 3261         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3264         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Font settings"))
 
 3265         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3266         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 3267         gridBagSizer.AddGrowableCol(1)
 
 3271         gridBagSizer.Add(panel.font[
'fontLabel'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3272         gridBagSizer.Add(panel.font[
'fontCtrl'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3273         gridBagSizer.Add(panel.font[
'fontSizeLabel'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3274         gridBagSizer.Add(panel.font[
'fontSizeCtrl'], pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3275         gridBagSizer.Add(panel.font[
'colorLabel'], pos = (2,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 3276         gridBagSizer.Add(panel.font[
'colorCtrl'], pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3278         sizer.Add(item = gridBagSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
 
 3279         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3282         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " %_(
"Color settings"))
 
 3283         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3284         flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
 
 3285         flexSizer.AddGrowableCol(1)
 
 3288         self.
colors[
'borderCtrl'] = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"use border color:"))
 
 3289         self.
colors[
'backgroundCtrl'] = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"use background color:"))
 
 3290         self.
colors[
'borderColor'] = wx.ColourPickerCtrl(panel, id = wx.ID_ANY)
 
 3291         self.
colors[
'backgroundColor'] = wx.ColourPickerCtrl(panel, id = wx.ID_ANY)
 
 3311         flexSizer.Add(self.
colors[
'borderCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3312         flexSizer.Add(self.
colors[
'borderColor'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3313         flexSizer.Add(self.
colors[
'backgroundCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3314         flexSizer.Add(self.
colors[
'backgroundColor'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3316         sizer.Add(item = flexSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
 
 3317         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3319         panel.SetSizer(border)
 
 3328             self.
colors[
'backgroundColor'].Enable()
 
 3331             self.
colors[
'backgroundColor'].Disable()
 
 3335             self.
colors[
'borderColor'].Enable()
 
 3338             self.
colors[
'borderColor'].Disable() 
 
 3343         currUnit = self.unitConv.findUnit(self.panel.units[
'unitsCtrl'].GetStringSelection())
 
 3347         if self.panel.position[
'xCtrl'].
GetValue():
 
 3348             x = self.panel.position[
'xCtrl'].
GetValue() 
 
 3352         if self.panel.position[
'yCtrl'].
GetValue():
 
 3353             y = self.panel.position[
'yCtrl'].
GetValue() 
 
 3357         x = self.unitConv.convert(value = float(self.panel.position[
'xCtrl'].
GetValue()), fromUnit = currUnit, toUnit = 
'inch')
 
 3358         y = self.unitConv.convert(value = float(self.panel.position[
'yCtrl'].
GetValue()), fromUnit = currUnit, toUnit = 
'inch')
 
 3362         self.
mapinfoDict[
'font'] =  self.panel.font[
'fontCtrl'].GetStringSelection()
 
 3366         color = self.panel.font[
'colorCtrl'].GetColour()
 
 3370             background = self.
colors[
'backgroundColor'].GetColour()
 
 3376             border = self.
colors[
'borderColor'].GetColour()
 
 3385             mapinfo = Mapinfo(self.
id)
 
 3386             self.instruction.AddInstruction(mapinfo)
 
 3390         if self.
id not in self.parent.objectId:
 
 3391             self.parent.objectId.append(self.
id)
 
 3398         """!Update mapinfo coordinates, after moving""" 
 3400         currUnit = self.unitConv.findUnit(self.panel.units[
'unitsCtrl'].GetStringSelection())
 
 3401         x = self.unitConv.convert(value = x, fromUnit = 
'inch', toUnit = currUnit)
 
 3402         y = self.unitConv.convert(value = y, fromUnit = 
'inch', toUnit = currUnit)
 
 3403         self.panel.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
 3404         self.panel.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
 3407     """!Dialog for scale bar""" 
 3409         PsmapDialog.__init__(self, parent = parent, id = id, title = 
"Scale bar settings", settings = settings)
 
 3411         if self.
id is not None:
 
 3418             page = self.instruction.FindInstructionByType(
'page').GetInstruction()
 
 3423         self._layout(self.
panel)
 
 3428         if self.
mapUnit not in self.unitConv.getAllUnits():
 
 3429             wx.MessageBox(message = _(
"Units of current projection are not supported,\n meters will be used!"),
 
 3430                             caption = _(
'Unsupported units'),
 
 3431                                     style = wx.OK|wx.ICON_ERROR)
 
 3434     def _scalebarPanel(self):
 
 3435         panel = wx.Panel(parent = self, id = wx.ID_ANY, style = wx.TAB_TRAVERSAL)
 
 3436         border = wx.BoxSizer(wx.VERTICAL)
 
 3440         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Position"))
 
 3441         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3442         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 3443         gridBagSizer.AddGrowableCol(1)
 
 3454             panel.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
 3455             panel.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
 3457         gridBagSizer.Add(panel.units[
'unitsLabel'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3458         gridBagSizer.Add(panel.units[
'unitsCtrl'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3459         gridBagSizer.Add(panel.position[
'xLabel'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3460         gridBagSizer.Add(panel.position[
'xCtrl'], pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3461         gridBagSizer.Add(panel.position[
'yLabel'], pos = (2,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3462         gridBagSizer.Add(panel.position[
'yCtrl'], pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3463         gridBagSizer.Add(panel.position[
'comment'], pos = (3,0), span = (1,2), flag =wx.ALIGN_BOTTOM, border = 0)
 
 3465         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 3466         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3470         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Size"))
 
 3471         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3472         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 3473         gridBagSizer.AddGrowableCol(1)
 
 3475         lengthText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Length:"))
 
 3476         heightText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Height:"))
 
 3479         self.lengthTextCtrl.SetToolTipString(_(
"Scalebar length is given in map units"))
 
 3482         self.heightTextCtrl.SetToolTipString(_(
"Scalebar height is real height on paper"))
 
 3484         choices = [_(
'default')] + self.unitConv.getMapUnitsNames()
 
 3485         self.
unitsLength = wx.Choice(panel, id = wx.ID_ANY, choices = choices)
 
 3486         choices = self.unitConv.getPageUnitsNames()
 
 3487         self.
unitsHeight = wx.Choice(panel, id = wx.ID_ANY, choices = choices)
 
 3490         unitName = self.unitConv.findName(self.
scalebarDict[
'unitsLength'])
 
 3492             self.unitsLength.SetStringSelection(unitName)
 
 3495                  self.unitsLength.SetSelection(0)
 
 3497                  self.unitsLength.SetStringSelection(self.unitConv.findName(
"nautical miles"))
 
 3498         self.unitsHeight.SetStringSelection(self.unitConv.findName(self.
scalebarDict[
'unitsHeight']))
 
 3500             self.lengthTextCtrl.SetValue(str(self.
scalebarDict[
'length']))
 
 3502             reg = grass.region()
 
 3503             w = int((reg[
'e'] - reg[
'w'])/3)
 
 3504             w = 
round(w, -len(str(w)) + 2) 
 
 3505             self.lengthTextCtrl.SetValue(str(w))
 
 3507         h = self.unitConv.convert(value = self.
scalebarDict[
'height'], fromUnit = 
'inch',
 
 3509         self.heightTextCtrl.SetValue(str(h))
 
 3511         gridBagSizer.Add(lengthText, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3512         gridBagSizer.Add(self.
lengthTextCtrl, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3513         gridBagSizer.Add(self.
unitsLength, pos = (0, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 3514         gridBagSizer.Add(heightText, pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3515         gridBagSizer.Add(self.
heightTextCtrl, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3516         gridBagSizer.Add(self.
unitsHeight, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 3518         sizer.Add(gridBagSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 3519         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3523         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Style"))
 
 3524         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3525         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 3528         sbTypeText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Type:"))
 
 3529         self.
sbCombo = wx.combo.BitmapComboBox(panel, style = wx.CB_READONLY)
 
 3531         imagePath = os.path.join(globalvar.ETCIMGDIR, 
"scalebar-fancy.png"), os.path.join(globalvar.ETCIMGDIR, 
"scalebar-simple.png") 
 
 3532         for item, path 
in zip([
'fancy', 
'simple'], imagePath):
 
 3533             if not os.path.exists(path):
 
 3534                 bitmap = wx.EmptyBitmap(0,0)
 
 3536                 bitmap = wx.Bitmap(path)
 
 3537             self.sbCombo.Append(item = 
'', bitmap = bitmap, clientData = item[0])
 
 3540             self.sbCombo.SetSelection(0)
 
 3542             self.sbCombo.SetSelection(1)
 
 3544         sbSegmentsText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Number of segments:"))
 
 3545         self.
sbSegmentsCtrl = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 30, initial = 4)
 
 3546         self.sbSegmentsCtrl.SetValue(self.
scalebarDict[
'segment'])
 
 3548         sbLabelsText1 = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Label every "))
 
 3549         sbLabelsText2 = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"segments"))
 
 3550         self.
sbLabelsCtrl = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 1, max = 30, initial = 1)
 
 3551         self.sbLabelsCtrl.SetValue(self.
scalebarDict[
'numbers'])
 
 3554         fontsizeText = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Font size:"))
 
 3555         self.
fontsizeCtrl = wx.SpinCtrl(panel, id = wx.ID_ANY, min = 4, max = 30, initial = 10)
 
 3556         self.fontsizeCtrl.SetValue(self.
scalebarDict[
'fontsize'])
 
 3558         self.
backgroundCheck = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"transparent text background"))
 
 3560             self.backgroundCheck.SetValue(
False)
 
 3562             self.backgroundCheck.SetValue(
True)
 
 3564         gridBagSizer.Add(sbTypeText, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3565         gridBagSizer.Add(self.
sbCombo, pos = (0,1), span = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, border = 0)
 
 3566         gridBagSizer.Add(sbSegmentsText, pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3567         gridBagSizer.Add(self.
sbSegmentsCtrl, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3568         gridBagSizer.Add(sbLabelsText1, pos = (2,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3569         gridBagSizer.Add(self.
sbLabelsCtrl, pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3570         gridBagSizer.Add(sbLabelsText2, pos = (2,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3571         gridBagSizer.Add(fontsizeText, pos = (3,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3572         gridBagSizer.Add(self.
fontsizeCtrl, pos = (3,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3573         gridBagSizer.Add(self.
backgroundCheck, pos = (4, 0), span = (1,3), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3575         sizer.Add(gridBagSizer, proportion = 1, flag = wx.ALIGN_CENTER_VERTICAL, border = 5)
 
 3576         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3578         panel.SetSizer(border)
 
 3583         """!Save information from dialog""" 
 3586         currUnit = self.unitConv.findUnit(self.panel.units[
'unitsCtrl'].GetStringSelection())
 
 3589         if self.panel.position[
'xCtrl'].
GetValue():
 
 3590             x = self.panel.position[
'xCtrl'].
GetValue() 
 
 3594         if self.panel.position[
'yCtrl'].
GetValue():
 
 3595             y = self.panel.position[
'yCtrl'].
GetValue() 
 
 3599         x = self.unitConv.convert(value = float(self.panel.position[
'xCtrl'].
GetValue()), fromUnit = currUnit, toUnit = 
'inch')
 
 3600         y = self.unitConv.convert(value = float(self.panel.position[
'yCtrl'].
GetValue()), fromUnit = currUnit, toUnit = 
'inch')
 
 3603         self.
scalebarDict[
'scalebar'] = self.sbCombo.GetClientData(self.sbCombo.GetSelection())
 
 3604         self.
scalebarDict[
'segment'] = self.sbSegmentsCtrl.GetValue()
 
 3605         self.
scalebarDict[
'numbers'] = self.sbLabelsCtrl.GetValue()
 
 3606         self.
scalebarDict[
'fontsize'] = self.fontsizeCtrl.GetValue()
 
 3607         if self.backgroundCheck.GetValue():
 
 3616         self.
scalebarDict[
'unitsHeight'] = self.unitConv.findUnit(self.unitsHeight.GetStringSelection())
 
 3618             height = float(self.heightTextCtrl.GetValue())  
 
 3619             height = self.unitConv.convert(value = height, fromUnit = self.
scalebarDict[
'unitsHeight'], toUnit = 
'inch') 
 
 3620         except (ValueError, SyntaxError):
 
 3625         if self.unitsLength.GetSelection() == 0:
 
 3628             selected = self.unitConv.findUnit(self.unitsLength.GetStringSelection())
 
 3629             if selected == 
'nautical miles':
 
 3630                 selected = 
'nautmiles' 
 3633             length = float(self.lengthTextCtrl.GetValue())
 
 3634         except (ValueError, SyntaxError):
 
 3635             wx.MessageBox(message = _(
"Length of scale bar is not defined"),
 
 3636                                     caption = _(
'Invalid input'), style = wx.OK|wx.ICON_ERROR)
 
 3641         map = self.instruction.FindInstructionByType(
'map')
 
 3643             map = self.instruction.FindInstructionByType(
'initMap')
 
 3646         rectSize = self.scalebar.EstimateSize(scalebarDict = self.
scalebarDict,
 
 3648         self.
scalebarDict[
'rect'] = Rect2D(x = x, y = y, width = rectSize[0], height = rectSize[1])
 
 3652             scalebar = Scalebar(self.
id)
 
 3653             self.instruction.AddInstruction(scalebar)
 
 3655         if self.
id not in self.parent.objectId:
 
 3656             self.parent.objectId.append(self.
id)
 
 3661         """!Update scalebar coordinates, after moving""" 
 3663         currUnit = self.unitConv.findUnit(self.panel.units[
'unitsCtrl'].GetStringSelection())
 
 3664         x = self.unitConv.convert(value = x, fromUnit = 
'inch', toUnit = currUnit)
 
 3665         y = self.unitConv.convert(value = y, fromUnit = 
'inch', toUnit = currUnit)
 
 3666         self.panel.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
 3667         self.panel.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
 3673         PsmapDialog.__init__(self, parent = parent, id = id, title = 
"Text settings", settings = settings)
 
 3675         if self.
id is not None:
 
 3679             text = Text(self.
id)
 
 3680             self.
textDict = text.GetInstruction()
 
 3681             page = self.instruction.FindInstructionByType(
'page').GetInstruction()
 
 3682             self.
textDict[
'where'] = page[
'Left'], page[
'Top'] 
 
 3684         map = self.instruction.FindInstructionByType(
'map')
 
 3686             map = self.instruction.FindInstructionByType(
'initMap')
 
 3691         notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)     
 
 3700         self._layout(notebook)
 
 3702     def _textPanel(self, notebook):
 
 3703         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, style = wx.TAB_TRAVERSAL)
 
 3704         notebook.AddPage(page = panel, text = _(
"Text"))
 
 3706         border = wx.BoxSizer(wx.VERTICAL)
 
 3709         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Text"))
 
 3710         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 3712         textLabel = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Enter text:"))
 
 3715         sizer.Add(textLabel, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = 5)
 
 3716         sizer.Add(self.
textCtrl, proportion = 1, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = 5)
 
 3717         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)        
 
 3720         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Font settings"))
 
 3721         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3722         flexGridSizer = wx.FlexGridSizer (rows = 3, cols = 2, hgap = 5, vgap = 5)
 
 3723         flexGridSizer.AddGrowableCol(1)
 
 3727         flexGridSizer.Add(panel.font[
'fontLabel'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3728         flexGridSizer.Add(panel.font[
'fontCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3729         flexGridSizer.Add(panel.font[
'fontSizeLabel'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3730         flexGridSizer.Add(panel.font[
'fontSizeCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3731         flexGridSizer.Add(panel.font[
'colorLabel'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)        
 
 3732         flexGridSizer.Add(panel.font[
'colorCtrl'], proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3734         sizer.Add(item = flexGridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
 
 3735         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3738         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Text effects"))
 
 3739         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3740         gridBagSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 3743         self.
effect[
'backgroundCtrl'] = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"text background"))
 
 3744         self.
effect[
'backgroundColor'] = wx.ColourPickerCtrl(panel, id = wx.ID_ANY)
 
 3746         self.
effect[
'highlightCtrl'] = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"highlight"))
 
 3747         self.
effect[
'highlightColor'] = wx.ColourPickerCtrl(panel, id = wx.ID_ANY)
 
 3748         self.
effect[
'highlightWidth'] = wx.SpinCtrl(panel, id = wx.ID_ANY, size = self.
spinCtrlSize, min = 0, max = 5, initial = 1)
 
 3749         self.
effect[
'highlightWidthLabel'] = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Width (pts):"))
 
 3751         self.
effect[
'borderCtrl'] = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"text border"))
 
 3752         self.
effect[
'borderColor'] = wx.ColourPickerCtrl(panel, id = wx.ID_ANY)
 
 3753         self.
effect[
'borderWidth'] = wx.SpinCtrl(panel, id = wx.ID_ANY, size = self.
spinCtrlSize, min = 1, max = 25, initial = 1)
 
 3754         self.
effect[
'borderWidthLabel'] = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"Width (pts):"))
 
 3757         if self.
textDict[
'background'] == 
None:
 
 3758             self.
textDict[
'background'] = 
'none' 
 3759         if self.
textDict[
'background'] != 
'none':
 
 3766         if self.
textDict[
'hcolor'] == 
None:
 
 3768         if self.
textDict[
'hcolor'] != 
'none':
 
 3777         if self.
textDict[
'border'] == 
None:
 
 3779         if self.
textDict[
'border'] != 
'none':
 
 3788         gridBagSizer.Add(self.
effect[
'backgroundCtrl'], pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3789         gridBagSizer.Add(self.
effect[
'backgroundColor'], pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3790         gridBagSizer.Add(self.
effect[
'highlightCtrl'], pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3791         gridBagSizer.Add(self.
effect[
'highlightColor'], pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3792         gridBagSizer.Add(self.
effect[
'highlightWidthLabel'], pos = (1,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3793         gridBagSizer.Add(self.
effect[
'highlightWidth'], pos = (1,3), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3794         gridBagSizer.Add(self.
effect[
'borderCtrl'], pos = (2,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3795         gridBagSizer.Add(self.
effect[
'borderColor'], pos = (2,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3796         gridBagSizer.Add(self.
effect[
'borderWidthLabel'], pos = (2,2), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3797         gridBagSizer.Add(self.
effect[
'borderWidth'], pos = (2,3), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3799         sizer.Add(item = gridBagSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 1)
 
 3800         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3805         self.Bind(wx.EVT_CHECKBOX, self.
OnBorder, self.
effect[
'borderCtrl'])
 
 3807         panel.SetSizer(border)
 
 3812     def _positionPanel(self, notebook):
 
 3813         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, style = wx.TAB_TRAVERSAL)
 
 3814         notebook.AddPage(page = panel, text = _(
"Position"))
 
 3816         border = wx.BoxSizer(wx.VERTICAL) 
 
 3818         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Position"))
 
 3819         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 3820         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 3821         gridBagSizer.AddGrowableCol(0)
 
 3822         gridBagSizer.AddGrowableCol(1)
 
 3828         box3   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " %_(
"Offset"))
 
 3829         sizerO = wx.StaticBoxSizer(box3, wx.VERTICAL)
 
 3830         gridBagSizerO = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 3831         self.
xoffLabel = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"horizontal (pts):"))
 
 3832         self.
yoffLabel = wx.StaticText(panel, id = wx.ID_ANY, label = _(
"vertical (pts):"))
 
 3833         self.
xoffCtrl = wx.SpinCtrl(panel, id = wx.ID_ANY, size = (50, -1), min = -50, max = 50, initial = 0)
 
 3834         self.
yoffCtrl = wx.SpinCtrl(panel, id = wx.ID_ANY, size = (50, -1), min = -50, max = 50, initial = 0) 
 
 3835         self.xoffCtrl.SetValue(self.
textDict[
'xoffset'])       
 
 3836         self.yoffCtrl.SetValue(self.
textDict[
'yoffset'])
 
 3837         gridBagSizerO.Add(self.
xoffLabel, pos = (0,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3838         gridBagSizerO.Add(self.
yoffLabel, pos = (1,0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3839         gridBagSizerO.Add(self.
xoffCtrl, pos = (0,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3840         gridBagSizerO.Add(self.
yoffCtrl, pos = (1,1), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 3842         sizerO.Add(gridBagSizerO, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 3843         gridBagSizer.Add(sizerO, pos = (3,0), flag = wx.ALIGN_CENTER_HORIZONTAL|wx.EXPAND, border = 0)
 
 3845         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " %_(
" Reference point"))
 
 3846         sizerR = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 3847         flexSizer = wx.FlexGridSizer(rows = 3, cols = 3, hgap = 5, vgap = 5)
 
 3848         flexSizer.AddGrowableCol(0)
 
 3849         flexSizer.AddGrowableCol(1)
 
 3850         flexSizer.AddGrowableCol(2)
 
 3852         for row 
in [
"upper", 
"center", 
"lower"]:
 
 3853             for col 
in [
"left", 
"center", 
"right"]:
 
 3854                 ref.append(row + 
" " + col)
 
 3855         self.
radio = [wx.RadioButton(panel, id = wx.ID_ANY, label = 
'', style = wx.RB_GROUP, name = ref[0])]
 
 3857         flexSizer.Add(self.
radio[0], proportion = 0, flag = wx.ALIGN_CENTER, border = 0)
 
 3858         for i 
in range(1,9):
 
 3859             self.radio.append(wx.RadioButton(panel, id = wx.ID_ANY, label = 
'', name = ref[i]))
 
 3861             flexSizer.Add(self.
radio[-1], proportion = 0, flag = wx.ALIGN_CENTER, border = 0)
 
 3864         sizerR.Add(flexSizer, proportion = 1, flag = wx.EXPAND, border = 0)
 
 3865         gridBagSizer.Add(sizerR, pos = (3,1), flag = wx.ALIGN_LEFT|wx.EXPAND, border = 0)
 
 3867         sizer.Add(gridBagSizer, proportion = 1, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = 5)
 
 3868         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3871         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Text rotation"))
 
 3872         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 3874         self.
rotCtrl = wx.CheckBox(panel, id = wx.ID_ANY, label = _(
"rotate text (counterclockwise)"))
 
 3875         self.
rotValue = wx.SpinCtrl(panel, wx.ID_ANY, size = (50, -1), min = 0, max = 360, initial = 0)
 
 3877             self.rotValue.SetValue(int(self.
textDict[
'rotate']))
 
 3878             self.rotCtrl.SetValue(
True)
 
 3880             self.rotValue.SetValue(0)
 
 3881             self.rotCtrl.SetValue(
False)
 
 3882         sizer.Add(self.
rotCtrl, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, border = 5)
 
 3883         sizer.Add(self.
rotValue, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, border = 5)
 
 3885         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 3887         panel.SetSizer(border)
 
 3890         self.Bind(wx.EVT_RADIOBUTTON, self.
OnPositionType, panel.position[
'toPaper']) 
 
 3891         self.Bind(wx.EVT_RADIOBUTTON, self.
OnPositionType, panel.position[
'toMap'])
 
 3900         if self.rotCtrl.GetValue():
 
 3901             self.rotValue.Enable()
 
 3903             self.rotValue.Disable()
 
 3906         if self.positionPanel.position[
'toPaper'].
GetValue():
 
 3907             for widget 
in self.gridBagSizerP.GetChildren():
 
 3908                 widget.GetWindow().Enable()
 
 3909             for widget 
in self.gridBagSizerM.GetChildren():
 
 3910                 widget.GetWindow().Disable()
 
 3912             for widget 
in self.gridBagSizerM.GetChildren():
 
 3913                 widget.GetWindow().Enable()
 
 3914             for widget 
in self.gridBagSizerP.GetChildren():
 
 3915                 widget.GetWindow().Disable()
 
 3919             self.
effect[
'backgroundColor'].Enable()
 
 3922             self.
effect[
'backgroundColor'].Disable()
 
 3926             self.
effect[
'highlightColor'].Enable()
 
 3927             self.
effect[
'highlightWidth'].Enable()
 
 3928             self.
effect[
'highlightWidthLabel'].Enable()
 
 3931             self.
effect[
'highlightColor'].Disable()
 
 3932             self.
effect[
'highlightWidth'].Disable()
 
 3933             self.
effect[
'highlightWidthLabel'].Disable()
 
 3937             self.
effect[
'borderColor'].Enable()
 
 3938             self.
effect[
'borderWidth'].Enable()
 
 3939             self.
effect[
'borderWidthLabel'].Enable()
 
 3942             self.
effect[
'borderColor'].Disable()
 
 3943             self.
effect[
'borderWidth'].Disable()
 
 3944             self.
effect[
'borderWidthLabel'].Disable()
 
 3948         self.
textDict[
'text'] = self.textCtrl.GetValue()
 
 3950             wx.MessageBox(_(
"No text entered!"), _(
"Error"))
 
 3954         self.
textDict[
'font'] = self.textPanel.font[
'fontCtrl'].GetStringSelection()
 
 3956         color = self.textPanel.font[
'colorCtrl'].GetColour()
 
 3961             background = self.
effect[
'backgroundColor'].GetColour()
 
 3964             self.
textDict[
'background'] = 
'none'         
 3967             border = self.
effect[
'borderColor'].GetColour()
 
 3975             highlight = self.
effect[
'highlightColor'].GetColour()
 
 3983         self.
textDict[
'xoffset'] = self.xoffCtrl.GetValue()
 
 3984         self.
textDict[
'yoffset'] = self.yoffCtrl.GetValue()
 
 3987         if self.positionPanel.position[
'toPaper'].
GetValue():
 
 3989             currUnit = self.unitConv.findUnit(self.positionPanel.units[
'unitsCtrl'].GetStringSelection())
 
 3991             if self.positionPanel.position[
'xCtrl'].
GetValue():
 
 3992                 x = self.positionPanel.position[
'xCtrl'].
GetValue() 
 
 3996             if self.positionPanel.position[
'yCtrl'].
GetValue():
 
 3997                 y = self.positionPanel.position[
'yCtrl'].
GetValue() 
 
 4001             x = self.unitConv.convert(value = float(x), fromUnit = currUnit, toUnit = 
'inch')
 
 4002             y = self.unitConv.convert(value = float(y), fromUnit = currUnit, toUnit = 
'inch')
 
 4007             if self.positionPanel.position[
'eCtrl'].
GetValue():
 
 4012             if self.positionPanel.position[
'nCtrl'].
GetValue():
 
 4018                                                             y = float(self.
textDict[
'north']), paperToMap = 
False)
 
 4020         if self.rotCtrl.GetValue():
 
 4021             self.
textDict[
'rotate'] = self.rotValue.GetValue()
 
 4025         for radio 
in self.
radio:
 
 4026             if radio.GetValue() == 
True:
 
 4027                 self.
textDict[
'ref'] = radio.GetName()
 
 4030             text = Text(self.
id)
 
 4031             self.instruction.AddInstruction(text)
 
 4034         if self.
id not in self.parent.objectId:
 
 4035             self.parent.objectId.append(self.
id)
 
 4042         """!Update text coordinates, after moving""" 
 4045         currUnit = self.unitConv.findUnit(self.positionPanel.units[
'unitsCtrl'].GetStringSelection())
 
 4046         x = self.unitConv.convert(value = x, fromUnit = 
'inch', toUnit = currUnit)
 
 4047         y = self.unitConv.convert(value = y, fromUnit = 
'inch', toUnit = currUnit)
 
 4048         self.positionPanel.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
 4049         self.positionPanel.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
 4056     """!Dialog for setting image properties. 
 4058     It's base dialog for North Arrow dialog. 
 4060     def __init__(self, parent, id, settings, imagePanelName = _(
"Image")):
 
 4061         PsmapDialog.__init__(self, parent = parent, id = id, title = 
"Image settings",
 
 4062                              settings = settings)
 
 4065         if self.
id is not None:
 
 4071             self.
imageDict = self.imageObj.GetInstruction()
 
 4072             page = self.instruction.FindInstructionByType(
'page').GetInstruction()
 
 4073             self.
imageDict[
'where'] = page[
'Left'], page[
'Top'] 
 
 4075         map = self.instruction.FindInstructionByType(
'map')
 
 4077             map = self.instruction.FindInstructionByType(
'initMap')
 
 4082         notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
 
 4089             self.imagePanel.image[
'dir'].
SetValue(os.path.dirname(self.
imageDict[
'epsfile']))
 
 4094         self._layout(notebook)
 
 4097     def _newObject(self):
 
 4098         """!Create corresponding instruction object""" 
 4101     def _imagePanel(self, notebook):
 
 4102         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 4104         border = wx.BoxSizer(wx.VERTICAL)
 
 4108         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Image"))
 
 4109         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 4114             startDir = os.path.dirname(self.
imageDict[
'epsfile'])
 
 4117         dir = filebrowse.DirBrowseButton(parent = panel, id = wx.ID_ANY,
 
 4118                                          labelText = _(
"Choose a directory:"),
 
 4119                                          dialogTitle = _(
"Choose a directory with images"),
 
 4120                                          buttonText = _(
'Browse'),
 
 4121                                          startDirectory = startDir,
 
 4123         panel.image[
'dir'] = dir
 
 4126         sizer.Add(item = dir, proportion = 0, flag = wx.EXPAND, border = 0)
 
 4129         hSizer = wx.BoxSizer(wx.HORIZONTAL)
 
 4131         imageList = wx.ListBox(parent = panel, id = wx.ID_ANY)
 
 4132         panel.image[
'list'] = imageList
 
 4135         hSizer.Add(item = imageList, proportion = 1, flag = wx.EXPAND | wx.RIGHT, border = 10)
 
 4138         vSizer = wx.BoxSizer(wx.VERTICAL)
 
 4141         panel.image[
'preview'] = wx.StaticBitmap(parent = panel, id = wx.ID_ANY,
 
 4142                                                 bitmap = wx.BitmapFromImage(img))
 
 4143         vSizer.Add(item = panel.image[
'preview'], proportion = 0, flag = wx.EXPAND | wx.BOTTOM, border = 5)
 
 4144         panel.image[
'sizeInfo'] = wx.StaticText(parent = panel, id = wx.ID_ANY)
 
 4145         vSizer.Add(item = panel.image[
'sizeInfo'], proportion = 0, flag = wx.ALIGN_CENTER, border = 0)
 
 4147         hSizer.Add(item = vSizer, proportion = 0, flag = wx.EXPAND, border = 0)
 
 4148         sizer.Add(item = hSizer, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 3)
 
 4150         epsInfo = wx.StaticText(parent = panel, id = wx.ID_ANY,
 
 4151                                 label = _(
"Note: only EPS format supported"))
 
 4152         sizer.Add(item = epsInfo, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALL, border = 3)
 
 4155         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4160         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Scale And Rotation"))
 
 4161         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 4163         gridSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 4165         scaleLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Scale:"))
 
 4167             panel.image[
'scale'] = fs.FloatSpin(panel, id = wx.ID_ANY, min_val = 0, max_val = 50,
 
 4168                                           increment = 0.5, value = 1, style = fs.FS_RIGHT, size = self.
spinCtrlSize)
 
 4169             panel.image[
'scale'].SetFormat(
"%f")
 
 4170             panel.image[
'scale'].SetDigits(1)
 
 4172             panel.image[
'scale'] = wx.TextCtrl(panel, id = wx.ID_ANY, size = self.
spinCtrlSize,
 
 4185         panel.image[
'scale'].
SetValue(value)
 
 4187         gridSizer.Add(item = scaleLabel, pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4188         gridSizer.Add(item = panel.image[
'scale'], pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4191         rotLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Rotation angle (deg):"))
 
 4193             panel.image[
'rotate'] = fs.FloatSpin(panel, id = wx.ID_ANY, min_val = 0, max_val = 360,
 
 4194                                           increment = 0.5, value = 0, style = fs.FS_RIGHT, size = self.
spinCtrlSize)
 
 4195             panel.image[
'rotate'].SetFormat(
"%f")
 
 4196             panel.image[
'rotate'].SetDigits(1)
 
 4198             panel.image[
'rotate'] = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = self.
spinCtrlSize,
 
 4199                                                 min = 0, max = 359, initial = 0)
 
 4200         panel.image[
'rotate'].SetToolTipString(_(
"Counterclockwise rotation in degrees"))
 
 4206         gridSizer.Add(item = rotLabel, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 4207         gridSizer.Add(item = panel.image[
'rotate'], pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4210         sizer.Add(item = gridSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = 5)
 
 4211         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4213         panel.SetSizer(border)
 
 4218     def _positionPanel(self, notebook):
 
 4219         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 4220         notebook.AddPage(page = panel, text = _(
"Position"))
 
 4221         border = wx.BoxSizer(wx.VERTICAL)
 
 4225         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Position"))
 
 4226         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 4228         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 4229         gridBagSizer.AddGrowableCol(0)
 
 4230         gridBagSizer.AddGrowableCol(1)
 
 4234         self.Bind(wx.EVT_RADIOBUTTON, self.
OnPositionType, panel.position[
'toPaper']) 
 
 4235         self.Bind(wx.EVT_RADIOBUTTON, self.
OnPositionType, panel.position[
'toMap'])
 
 4238         sizer.Add(gridBagSizer, proportion = 1, flag = wx.ALIGN_CENTER_VERTICAL| wx.ALL, border = 5)
 
 4239         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4241         panel.SetSizer(border)
 
 4247         """!Image directory changed""" 
 4248         path = self.imagePanel.image[
'dir'].
GetValue()
 
 4250             files = os.listdir(path)
 
 4257             self.imagePanel.image[
'dir'].startDirectory = path
 
 4258         except AttributeError: 
 
 4261             if os.path.splitext(file)[1].lower() == 
'.eps':
 
 4262                 imageList.append(file)
 
 4265         self.imagePanel.image[
'list'].SetItems(imageList)
 
 4267             file = os.path.basename(self.
imageDict[
'epsfile'])
 
 4268             self.imagePanel.image[
'list'].SetStringSelection(file)
 
 4270             self.imagePanel.image[
'list'].SetSelection(0)
 
 4274         if self.positionPanel.position[
'toPaper'].
GetValue():
 
 4275             for widget 
in self.gridBagSizerP.GetChildren():
 
 4276                 widget.GetWindow().Enable()
 
 4277             for widget 
in self.gridBagSizerM.GetChildren():
 
 4278                 widget.GetWindow().Disable()
 
 4280             for widget 
in self.gridBagSizerM.GetChildren():
 
 4281                 widget.GetWindow().Enable()
 
 4282             for widget 
in self.gridBagSizerP.GetChildren():
 
 4283                 widget.GetWindow().Disable()
 
 4285     def _getImageDirectory(self):
 
 4286         """!Default image directory""" 
 4289     def _addConvergence(self, panel, gridBagSizer):
 
 4293         """!Image selected, show preview and size""" 
 4294         if not self.imagePanel.image[
'dir']: 
 
 4297         if not havePILImage:
 
 4298             self.DrawWarningText(_(
"PIL\nmissing"))
 
 4301         imageName = self.imagePanel.image[
'list'].GetStringSelection()
 
 4305         basePath = self.imagePanel.image[
'dir'].
GetValue()
 
 4306         file = os.path.join(basePath, imageName)
 
 4307         if not os.path.exists(file):
 
 4310         if os.path.splitext(file)[1].lower() == 
'.eps':
 
 4312                 pImg = PILImage.open(file)
 
 4313                 if sys.platform == 
'win32':
 
 4315                     pImg.load = types.MethodType(loadPSForWindows, pImg)
 
 4318                 GError(message = _(
"Unable to read file %s") % file)
 
 4321             self.SetSizeInfoLabel(img)
 
 4322             img = self.ScaleToPreview(img)
 
 4323             bitmap = img.ConvertToBitmap()
 
 4324             self.DrawBitmap(bitmap)
 
 4331         """!Scale image to preview size""" 
 4342         return img.Scale(newW, newH, wx.IMAGE_QUALITY_HIGH)
 
 4345         """!Draw text on preview window""" 
 4348         dc.SelectObject(buffer)
 
 4349         dc.SetBrush(wx.Brush(wx.Colour(250, 250, 250)))
 
 4351         extent = dc.GetTextExtent(warning)
 
 4354         dc.DrawText(warning, posX, posY)
 
 4355         self.imagePanel.image[
'preview'].SetBitmap(buffer)
 
 4356         dc.SelectObject(wx.NullBitmap)
 
 4359         """!Draw bitmap, center it if smaller than preview size""" 
 4363             dc.SelectObject(buffer)
 
 4364             dc.SetBrush(dc.GetBrush())
 
 4366             posX = self.
previewSize[0] / 2 - bitmap.GetWidth() / 2
 
 4367             posY = self.
previewSize[1] / 2 - bitmap.GetHeight() / 2
 
 4368             dc.DrawBitmap(bitmap, posX, posY)
 
 4369             self.imagePanel.image[
'preview'].SetBitmap(buffer)
 
 4370             dc.SelectObject(wx.NullBitmap)
 
 4372             self.imagePanel.image[
'preview'].SetBitmap(bitmap)
 
 4373         self.imagePanel.Refresh()
 
 4376         """!Update image size label""" 
 4377         self.imagePanel.image[
'sizeInfo'].SetLabel(_(
"size: %(width)s x %(height)s pts") % \
 
 4378                                                        { 
'width'  : image.GetWidth(),
 
 4379                                                          'height' : image.GetHeight() })
 
 4380         self.imagePanel.image[
'sizeInfo'].GetContainingSizer().Layout()
 
 4383         """!Clear preview window""" 
 4386         dc.SelectObject(buffer)
 
 4387         dc.SetBrush(wx.WHITE_BRUSH)
 
 4389         dc.SelectObject(wx.NullBitmap)
 
 4390         mask = wx.Mask(buffer, wx.WHITE)
 
 4391         buffer.SetMask(mask)
 
 4392         self.imagePanel.image[
'preview'].SetBitmap(buffer)
 
 4396         selected = self.imagePanel.image[
'list'].GetStringSelection()
 
 4397         basePath = self.imagePanel.image[
'dir'].
GetValue()
 
 4399             GMessage(parent = self, message = _(
"No image selected."))
 
 4402         self.
imageDict[
'epsfile'] = os.path.join(basePath, selected)
 
 4405         if self.positionPanel.position[
'toPaper'].
GetValue():
 
 4407             currUnit = self.unitConv.findUnit(self.positionPanel.units[
'unitsCtrl'].GetStringSelection())
 
 4409             if self.positionPanel.position[
'xCtrl'].
GetValue():
 
 4410                 x = self.positionPanel.position[
'xCtrl'].
GetValue() 
 
 4414             if self.positionPanel.position[
'yCtrl'].
GetValue():
 
 4415                 y = self.positionPanel.position[
'yCtrl'].
GetValue() 
 
 4419             x = self.unitConv.convert(value = float(x), fromUnit = currUnit, toUnit = 
'inch')
 
 4420             y = self.unitConv.convert(value = float(y), fromUnit = currUnit, toUnit = 
'inch')
 
 4425             if self.positionPanel.position[
'eCtrl'].
GetValue():
 
 4426                 e = self.positionPanel.position[
'eCtrl'].
GetValue() 
 
 4430             if self.positionPanel.position[
'nCtrl'].
GetValue():
 
 4431                 n = self.positionPanel.position[
'nCtrl'].
GetValue() 
 
 4436                                        y = float(self.
imageDict[
'north']), paperToMap = 
False)
 
 4439         rot = self.imagePanel.image[
'rotate'].
GetValue()
 
 4449         w, h = self.imageObj.GetImageOrigSize(self.
imageDict[
'epsfile'])
 
 4455         w = self.unitConv.convert(value = self.
imageDict[
'size'][0],
 
 4456                                   fromUnit = 
'point', toUnit = 
'inch')
 
 4457         h = self.unitConv.convert(value = self.
imageDict[
'size'][1],
 
 4458                                   fromUnit = 
'point', toUnit = 
'inch')
 
 4461         self.
imageDict[
'rect'] = Rect2D(x = x, y = y,
 
 4467             self.instruction.AddInstruction(image)
 
 4470         if self.
id not in self.parent.objectId:
 
 4471             self.parent.objectId.append(self.
id)
 
 4476         """!Update text coordinates, after moving""" 
 4479         currUnit = self.unitConv.findUnit(self.positionPanel.units[
'unitsCtrl'].GetStringSelection())
 
 4480         x = self.unitConv.convert(value = x, fromUnit = 
'inch', toUnit = currUnit)
 
 4481         y = self.unitConv.convert(value = y, fromUnit = 
'inch', toUnit = currUnit)
 
 4482         self.positionPanel.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
 4483         self.positionPanel.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
 4492         ImageDialog.__init__(self, parent = parent, id = id, settings = settings,
 
 4493                              imagePanelName = _(
"North Arrow"))
 
 4496         self.SetTitle(_(
"North Arrow settings"))
 
 4498     def _newObject(self):
 
 4501     def _getImageDirectory(self):
 
 4502         gisbase = os.getenv(
"GISBASE")
 
 4503         return os.path.join(gisbase, 
'etc', 
'paint', 
'decorations')
 
 4505     def _addConvergence(self, panel, gridBagSizer):
 
 4506         convergence = wx.Button(parent = panel, id = wx.ID_ANY,
 
 4507                                                label = _(
"Compute convergence"))
 
 4508         gridBagSizer.Add(item = convergence, pos = (1, 2),
 
 4509                       flag = wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
 
 4511         panel.image[
'convergence'] = convergence
 
 4514         ret = 
RunCommand(
'g.region', read = 
True, flags = 
'ng')
 
 4516             convergence = float(ret.strip().
split(
'=')[1])
 
 4518                 self.imagePanel.image[
'rotate'].
SetValue(abs(convergence))
 
 4520                 self.imagePanel.image[
'rotate'].
SetValue(360 - convergence)
 
 4524     """!Dialog for setting point properties.""" 
 4525     def __init__(self, parent, id, settings, coordinates = None, pointPanelName = _(
"Point")):
 
 4526         PsmapDialog.__init__(self, parent = parent, id = id, title = 
"Point settings",
 
 4527                              settings = settings)
 
 4530         if self.
id is not None:
 
 4536             self.
pointDict = self.pointObj.GetInstruction()
 
 4540         mapObj = self.instruction.FindInstructionByType(
'map')
 
 4542             mapObj = self.instruction.FindInstructionByType(
'initMap')
 
 4547         notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
 
 4554         self._layout(notebook)
 
 4556     def _pointPanel(self, notebook):
 
 4557         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 4559         border = wx.BoxSizer(wx.VERTICAL)
 
 4563         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Symbol"))
 
 4564         sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
 4566         gridSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 4567         gridSizer.AddGrowableCol(1)
 
 4569         gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Select symbol:")),
 
 4570                       pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4574         gridSizer.Add(item = self.
symbolLabel, pos = (0, 1),
 
 4575                       flag = wx.ALIGN_CENTER_VERTICAL )
 
 4576         bitmap = wx.Bitmap(os.path.join(globalvar.ETCSYMBOLDIR,
 
 4578         self.
symbolButton = wx.BitmapButton(panel, id = wx.ID_ANY, bitmap = bitmap)
 
 4581         gridSizer.Add(self.
symbolButton, pos = (0, 2), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4582         self.
noteLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, 
 
 4583                                        label = _(
"Note: Selected symbol is not displayed\n" 
 4584                                                  "in draft mode (only in preview mode)"))
 
 4585         gridSizer.Add(self.
noteLabel, pos = (1, 0), span = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4587         sizer.Add(item = gridSizer, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
 
 4589         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4596         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Color"))
 
 4597         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 4599         gridSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 4601         outlineLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Outline color:"))
 
 4606             self.outlineTranspCtrl.SetValue(
False)
 
 4609             self.outlineTranspCtrl.SetValue(
True)
 
 4612         gridSizer.Add(item = outlineLabel, pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4613         gridSizer.Add(item = self.
outlineColorCtrl, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4614         gridSizer.Add(item = self.
outlineTranspCtrl, pos = (0, 2), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4616         fillLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Fill color:"))
 
 4621             self.fillTranspCtrl.SetValue(
False)
 
 4624             self.fillTranspCtrl.SetValue(
True)
 
 4627         gridSizer.Add(item = fillLabel, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4628         gridSizer.Add(item = self.
fillColorCtrl, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4629         gridSizer.Add(item = self.
fillTranspCtrl, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4631         sizer.Add(item = gridSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = 5)
 
 4632         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4639         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Size and Rotation"))
 
 4640         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 4642         gridSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 4644         sizeLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Size (pt):"))
 
 4646         self.sizeCtrl.SetToolTipString(_(
"Symbol size in points"))
 
 4647         self.sizeCtrl.SetValue(self.
pointDict[
'size'])
 
 4649         gridSizer.Add(item = sizeLabel, pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4650         gridSizer.Add(item = self.
sizeCtrl, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4653         rotLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Rotation angle (deg):"))
 
 4655             self.
rotCtrl = fs.FloatSpin(panel, id = wx.ID_ANY, min_val = -360, max_val = 360,
 
 4656                                           increment = 1, value = 0, style = fs.FS_RIGHT, size = self.
spinCtrlSize)
 
 4657             self.rotCtrl.SetFormat(
"%f")
 
 4658             self.rotCtrl.SetDigits(1)
 
 4661                                                 min = -360, max = 360, initial = 0)
 
 4662         self.rotCtrl.SetToolTipString(_(
"Counterclockwise rotation in degrees"))
 
 4663         self.rotCtrl.SetValue(float(self.
pointDict[
'rotate']))
 
 4665         gridSizer.Add(item = rotLabel, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL, border = 0)
 
 4666         gridSizer.Add(item = self.
rotCtrl, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4668         sizer.Add(item = gridSizer, proportion = 0, flag = wx.EXPAND | wx.ALL, border = 5)
 
 4669         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4671         panel.SetSizer(border)
 
 4676     def _positionPanel(self, notebook):
 
 4677         panel = wx.Panel(parent = notebook, id = wx.ID_ANY, size = (-1, -1), style = wx.TAB_TRAVERSAL)
 
 4678         notebook.AddPage(page = panel, text = _(
"Position"))
 
 4679         border = wx.BoxSizer(wx.VERTICAL)
 
 4683         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Position"))
 
 4684         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 4686         gridBagSizer = wx.GridBagSizer(hgap = 5, vgap = 5)
 
 4687         gridBagSizer.AddGrowableCol(0)
 
 4688         gridBagSizer.AddGrowableCol(1)
 
 4692         self.Bind(wx.EVT_RADIOBUTTON, self.
OnPositionType, panel.position[
'toPaper']) 
 
 4693         self.Bind(wx.EVT_RADIOBUTTON, self.
OnPositionType, panel.position[
'toMap'])
 
 4696         sizer.Add(gridBagSizer, proportion = 1, flag = wx.ALIGN_CENTER_VERTICAL| wx.ALL, border = 5)
 
 4697         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4699         panel.SetSizer(border)
 
 4705         if self.positionPanel.position[
'toPaper'].
GetValue():
 
 4706             for widget 
in self.gridBagSizerP.GetChildren():
 
 4707                 widget.GetWindow().Enable()
 
 4708             for widget 
in self.gridBagSizerM.GetChildren():
 
 4709                 widget.GetWindow().Disable()
 
 4711             for widget 
in self.gridBagSizerM.GetChildren():
 
 4712                 widget.GetWindow().Enable()
 
 4713             for widget 
in self.gridBagSizerP.GetChildren():
 
 4714                 widget.GetWindow().Disable()
 
 4717         dlg = 
SymbolDialog(self, symbolPath = globalvar.ETCSYMBOLDIR,
 
 4718                            currentSymbol = self.symbolLabel.GetLabel())
 
 4719         if dlg.ShowModal() == wx.ID_OK:
 
 4720             img = dlg.GetSelectedSymbolPath()
 
 4721             name = dlg.GetSelectedSymbolName()
 
 4722             self.symbolButton.SetBitmapLabel(wx.Bitmap(img + 
'.png'))
 
 4723             self.symbolLabel.SetLabel(name)
 
 4729         self.
pointDict[
'symbol'] = self.symbolLabel.GetLabel()
 
 4733         if self.positionPanel.position[
'toPaper'].
GetValue():
 
 4735             currUnit = self.unitConv.findUnit(self.positionPanel.units[
'unitsCtrl'].GetStringSelection())
 
 4737             if self.positionPanel.position[
'xCtrl'].
GetValue():
 
 4738                 x = self.positionPanel.position[
'xCtrl'].
GetValue() 
 
 4742             if self.positionPanel.position[
'yCtrl'].
GetValue():
 
 4743                 y = self.positionPanel.position[
'yCtrl'].
GetValue() 
 
 4747             x = self.unitConv.convert(value = float(x), fromUnit = currUnit, toUnit = 
'inch')
 
 4748             y = self.unitConv.convert(value = float(y), fromUnit = currUnit, toUnit = 
'inch')
 
 4753             if self.positionPanel.position[
'eCtrl'].
GetValue():
 
 4754                 e = self.positionPanel.position[
'eCtrl'].
GetValue() 
 
 4758             if self.positionPanel.position[
'nCtrl'].
GetValue():
 
 4759                 n = self.positionPanel.position[
'nCtrl'].
GetValue() 
 
 4764                                        y = float(self.
pointDict[
'north']), paperToMap = 
False)
 
 4767         self.
pointDict[
'rotate'] = self.rotCtrl.GetValue()
 
 4770         self.
pointDict[
'size'] = self.sizeCtrl.GetValue()
 
 4772         w = h = self.unitConv.convert(value = self.
pointDict[
'size'],
 
 4773                                   fromUnit = 
'point', toUnit = 
'inch')
 
 4776         if self.outlineTranspCtrl.GetValue():
 
 4782         if self.fillTranspCtrl.GetValue():
 
 4787         self.
pointDict[
'rect'] = Rect2D(x = x - w / 2, y = y - h / 2, width = w, height = h)
 
 4790             point = Point(self.
id)
 
 4791             self.instruction.AddInstruction(point)
 
 4794         if self.
id not in self.parent.objectId:
 
 4795             self.parent.objectId.append(self.
id)
 
 4800         """!Update text coordinates, after moving""" 
 4803         currUnit = self.unitConv.findUnit(self.positionPanel.units[
'unitsCtrl'].GetStringSelection())
 
 4804         x = self.unitConv.convert(value = x, fromUnit = 
'inch', toUnit = currUnit)
 
 4805         y = self.unitConv.convert(value = y, fromUnit = 
'inch', toUnit = currUnit)
 
 4806         self.positionPanel.position[
'xCtrl'].
SetValue(
"%5.3f" % x)
 
 4807         self.positionPanel.position[
'yCtrl'].
SetValue(
"%5.3f" % y)
 
 4814     def __init__(self, parent, id, settings, type = 'rectangle', coordinates = None):
 
 4817         @param coordinates begin and end point coordinate (wx.Point, wx.Point) 
 4819         if type == 
'rectangle':
 
 4820             title = _(
"Rectangle settings")
 
 4822             title = _(
"Line settings")
 
 4823         PsmapDialog.__init__(self, parent = parent, id = id, title = title, settings = settings)
 
 4827         if self.
id is not None:
 
 4832             if type == 
'rectangle':
 
 4836             self.
rectDict = self.rectObj.GetInstruction()
 
 4838             self.
rectDict[
'rect'] = Rect2DPP(coordinates[0], coordinates[1])
 
 4839             self.
rectDict[
'where'] = coordinates
 
 4844         self._layout(self.
panel)
 
 4846     def _rectPanel(self):
 
 4847         panel = wx.Panel(parent = self, id = wx.ID_ANY, style = wx.TAB_TRAVERSAL)
 
 4848         border = wx.BoxSizer(wx.VERTICAL)
 
 4851         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Color"))
 
 4852         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 4853         gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 4855         outlineLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Outline color:"))
 
 4859         if self.
rectDict[
'color'] != 
'none':
 
 4860             self.outlineTranspCtrl.SetValue(
False)
 
 4863             self.outlineTranspCtrl.SetValue(
True)
 
 4868             self.outlineTranspCtrl.Hide()
 
 4870         gridSizer.Add(item = outlineLabel, pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4871         gridSizer.Add(item = self.
outlineColorCtrl, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4872         gridSizer.Add(item = self.
outlineTranspCtrl, pos = (0, 2), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4876             fillLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Fill color:"))
 
 4880             if self.
rectDict[
'fcolor'] != 
'none':
 
 4881                 self.fillTranspCtrl.SetValue(
False)
 
 4884                 self.fillTranspCtrl.SetValue(
True)
 
 4885                 self.fillColorCtrl.SetColour(wx.WHITE)
 
 4887             gridSizer.Add(item = fillLabel, pos = (1, 0), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4888             gridSizer.Add(item = self.
fillColorCtrl, pos = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4889             gridSizer.Add(item = self.
fillTranspCtrl, pos = (1, 2), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4891         sizer.Add(gridSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 4892         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4893         gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
 
 4896         box   = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = 
" %s " % _(
"Line style"))
 
 4897         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
 4899         widthLabel = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Line width:"))
 
 4901             self.
widthCtrl = fs.FloatSpin(panel, id = wx.ID_ANY, min_val = 0, max_val = 50,
 
 4902                                           increment = 1, value = 0, style = fs.FS_RIGHT, size = self.
spinCtrlSize)
 
 4903             self.widthCtrl.SetFormat(
"%f")
 
 4904             self.widthCtrl.SetDigits(1)
 
 4907                                                 min = -360, max = 360, initial = 0)
 
 4908         self.widthCtrl.SetToolTipString(_(
"Line width in points"))
 
 4909         self.widthCtrl.SetValue(float(self.
rectDict[
'width']))
 
 4911         gridSizer.Add(item = widthLabel, pos = (0, 0), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4912         gridSizer.Add(item = self.
widthCtrl, pos = (0, 1), flag = wx.ALIGN_CENTER_VERTICAL)
 
 4914         sizer.Add(gridSizer, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)
 
 4915         border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 5)
 
 4917         panel.SetSizer(border)
 
 4923         mapInstr = self.instruction.FindInstructionByType(
'map')
 
 4925             mapInstr = self.instruction.FindInstructionByType(
'initMap')
 
 4938         self.
rectDict[
'width'] = self.widthCtrl.GetValue()
 
 4941         if self.outlineTranspCtrl.GetValue():
 
 4948             if self.fillTranspCtrl.GetValue():
 
 4955                 rect = Rectangle(self.
id)
 
 4957                 rect = Line(self.
id)
 
 4958             self.instruction.AddInstruction(rect)
 
 4962         if self.
id not in self.parent.objectId:
 
 4963             self.parent.objectId.append(self.
id)
 
 4970         """!Update text coordinates, after moving""" 
def convertRGB
Converts wx.Colour(r,g,b,a) to string 'r:g:b' or named color, or named color/r:g:b string to wx...
if self.flag == 'SCALE' and chr(key) in string.digits + ':': event.Skip() return 
def OnPageChanging
Workaround to scroll up to see the checkbox. 
def ScaleToPreview
Scale image to preview size. 
Panel for raster map settings. 
Panel for vector maps settings. 
def OnIsLegend
Enables and disables controls, it depends if raster or vector legend is checked. 
def projInfo
Return region projection and map units information, taken from render.py. 
def updateRasterLegend
Save information from raster legend dialog to dictionary. 
def getRasterType
Returns type of raster map (CELL, FCELL, DCELL) 
Dialog for GRASS symbols selection. 
def getId
Returns id of raster map. 
def OnMeasureItemWidth
Overridden from OwnerDrawnComboBox. 
def updateDialog
Update information (not used) 
def PaperMapCoordinates
Converts paper (inch) coordinates <-> map coordinates. 
def OnBorder
Enables/disables colorPickerCtrl for border. 
def OnClose
Destroy dialog and delete it from open dialogs. 
def updateDialog
Update text coordinates, after moving. 
def update
Save information from dialog. 
def updateDialog
Update scalebar coordinates, after moving. 
def OnDown
Moves selected map to bottom. 
def OnLayer
Change columns on layer change. 
def updateDialog
Update text coordinates, after moving. 
def SetSizeInfoLabel
Update image size label. 
def SetResolution
If resolution is too high, lower it. 
def reposition
Update position in legend, used only if there is no vlegend yet. 
def OnVector
Gets info about toplogy and enables/disables choices point/line/area. 
def OnRaster
Enable/disable raster selection. 
def OnOK
Apply changes, close dialog. 
def OnMap
Selected map or region changing. 
def enableButtons
Enable/disable up, down, properties, delete buttons. 
def ClearPreview
Clear preview window. 
def sizePositionFont
Insert widgets for size, position and font control. 
def AutoAdjust
Computes map scale, center and map frame rectangle to fit region (scale is not fixed) ...
def OnMeasureItem
Overridden from OwnerDrawnComboBox, should return the height needed to display an item in the popup...
def _ColorsPointAreaPanel
def OnFont
Changes default width according to fontsize, width [inch] = fontsize[pt]/24. 
Various dialogs used in wxGUI. 
def _getImageDirectory
Default image directory. 
def OnAddVector
Adds vector map to list. 
def DrawBitmap
Draw bitmap, center it if smaller than preview size. 
Custom control that selects elements. 
def getColsChoice
Returns a wx.Choice with table columns. 
def split
Platform spefic shlex.split. 
def OnDown
Moves selected map down, changes order in vector legend. 
def updateDialog
Update text coordinates, after moving. 
def updateDialog
Update information (not used) 
def OnCancel
Close dialog. 
def ComputeSetRegion
Computes and sets region from current scale, map center coordinates and map rectangle. 
def BBoxAfterRotation
Compute bounding box or rotated rectangle. 
def OnApply
Apply changes. 
Dialog for map frame settings and optionally raster and vector map selection. 
utilities for wxpsmap (classes, functions) 
def updateDialog
Update text coordinates, after moving. 
def updateDialog
Update legend coordinates after moving. 
def updateDialog
Update raster and vector information. 
def OnProperties
Opens vector map properties dialog. 
List control for managing order and labels of vector maps in legend. 
def _newObject
Create corresponding instruction object. 
def OnUp
Moves selected map up, changes order in vector legend. 
def OnElementType
Changes data in map selection tree ctrl popup. 
def OnCancel
Close dialog and remove tmp red box. 
def PilImageToWxImage
Convert PIL image to wx.Image. 
wx.Panel with map (scale, region, border) settings 
def OnDirChanged
Image directory changed. 
def updateDialog
Update mapinfo coordinates, after moving. 
Dialog for setting point properties. 
def OnScaleChoice
Selected scale type changing. 
def OnImageSelectionChanged
Image selected, show preview and size. 
Dialog for setting image properties. 
def AddExtendedPosition
Add widgets for setting position relative to paper and to map. 
def OnDelete
Deletes vector map from the list. 
def OnDrawBackground
Overridden from OwnerDrawnComboBox, called for drawing the background area of each item...
def OnBorder
Enables/disable the part relating to border of map frame. 
def OnEditLabel
Change legend label of vector map. 
def OnApply
parent.font['colorLabel'] = wx.StaticText(parent, id = wx.ID_ANY, label = _("Color:")) colorChoices...
validates input in textctrls, combobox, taken from wxpython demo 
def updateVectorLegend
Save information from vector legend dialog to dictionary. 
def OnDiscrete
Change control according to the type of legend. 
def RunCommand
Run GRASS command. 
def OnUp
Moves selected map to top. 
def DrawWarningText
Draw text on preview window.