2 @package wxplot.dialogs 
    4 @brief Dialogs for different plotting routines 
    7  - dialogs::ProfileRasterDialog 
    8  - dialogs::ScatterRasterDialog 
    9  - dialogs::PlotStatsFrame 
   10  - dialogs::HistRasterDialog 
   14 (C) 2011-2012 by the GRASS Development Team 
   16 This program is free software under the GNU General Public License 
   17 (>=v2). Read the file COPYING that comes with GRASS for details. 
   19 @author Michael Barton, Arizona State University 
   23 import wx.lib.colourselect  
as csel
 
   24 import wx.lib.scrolledpanel 
as scrolled
 
   26 from core             
import globalvar
 
   33     def __init__(self, parent, id = wx.ID_ANY, 
 
   34                  title = _(
"Select raster maps to profile"),
 
   35                  style = wx.DEFAULT_DIALOG_STYLE, **kwargs):
 
   36         """!Dialog to select raster maps to profile. 
   39         wx.Dialog.__init__(self, parent, id, title, style = style, **kwargs)
 
   43         self.
colorList = [
"blue", 
"red", 
"green", 
"yellow", 
"magenta", 
"cyan", \
 
   44                     "aqua", 
"black", 
"grey", 
"orange", 
"brown", 
"purple", 
"violet", \
 
   53         sizer = wx.BoxSizer(wx.VERTICAL)
 
   55         box = wx.GridBagSizer (hgap = 3, vgap = 3)
 
   61         rastText = rastText.rstrip(
',')
 
   63         txt = _(
"Select raster map(s) to profile:")
 
   64         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = txt)
 
   66                 flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
 
   68         selection = Select(self, id = wx.ID_ANY,
 
   69                            size = globalvar.DIALOG_GSELECT_SIZE,
 
   70                            type = 
'cell', multiple=
True)
 
   71         selection.SetValue(rastText)
 
   74         box.Add(item = selection, pos = (0, 1))
 
   76         sizer.Add(item = box, proportion = 0,
 
   77                   flag = wx.ALL, border = 10)
 
   79         line = wx.StaticLine(parent = self, id = wx.ID_ANY, size = (20, -1), style = wx.LI_HORIZONTAL)
 
   80         sizer.Add(item = line, proportion = 0,
 
   81                   flag = wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border = 5)
 
   83         btnsizer = wx.StdDialogButtonSizer()
 
   85         btn = wx.Button(self, wx.ID_OK)
 
   87         btnsizer.AddButton(btn)
 
   89         btn = wx.Button(self, wx.ID_CANCEL)
 
   90         btnsizer.AddButton(btn)
 
   93         sizer.Add(item = btnsizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
 
   99         """!Choose maps to profile. Convert these into a list 
  105     def __init__(self, parent, id, message = '', title = '',
 
  106                  style = wx.DEFAULT_FRAME_STYLE, **kwargs):
 
  107         """!Dialog to display and save statistics for plots 
  109         wx.Frame.__init__(self, parent, id, style = style, **kwargs)
 
  110         self.SetLabel(_(
"Statistics"))
 
  112         sp = scrolled.ScrolledPanel(self, -1, size=(400, 400),
 
  113                                     style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER, name=
"Statistics" )
 
  122         self.CenterOnParent()  
 
  127         sizer = wx.BoxSizer(wx.VERTICAL)
 
  128         txtSizer = wx.BoxSizer(wx.VERTICAL)
 
  130         statstitle = wx.StaticText(parent = self, id = wx.ID_ANY, label = self.
title)
 
  131         sizer.Add(item = statstitle, proportion = 0,
 
  132                   flag = wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = 3)
 
  133         line = wx.StaticLine(parent = self, id = wx.ID_ANY, size = (20, -1), style = wx.LI_HORIZONTAL)
 
  134         sizer.Add(item = line, proportion = 0,
 
  135                   flag = wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = 3)
 
  137             statstxt = wx.StaticText(parent = sp, id = wx.ID_ANY, label = stats)
 
  138             statstxt.SetBackgroundColour(
"WHITE")
 
  139             txtSizer.Add(item = statstxt, proportion = 1, 
 
  140                          flag = wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border = 3)
 
  141             line = wx.StaticLine(parent = sp, id = wx.ID_ANY, size = (20, -1), style = wx.LI_HORIZONTAL) 
 
  142             txtSizer.Add(item = line, proportion = 0,
 
  143                          flag = wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, border = 3)      
 
  145         sp.SetSizer(txtSizer)
 
  149         sizer.Add(item = sp, proportion = 1, 
 
  150                   flag = wx.GROW | wx.LEFT | wx.RIGHT | wx.BOTTOM, border = 3)
 
  152         line = wx.StaticLine(parent = self, id = wx.ID_ANY, size = (20, -1), style = wx.LI_HORIZONTAL)
 
  153         sizer.Add(item = line, proportion = 0,
 
  154                   flag = wx.GROW |wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border = 3)
 
  159         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
 
  161         btn_clipboard = wx.Button(self, id = wx.ID_COPY, label = _(
'C&opy'))
 
  162         btn_clipboard.SetToolTipString(_(
"Copy regression statistics the clipboard (Ctrl+C)"))
 
  163         btnSizer.Add(item = btn_clipboard, proportion = 0, flag = wx.ALIGN_LEFT | wx.ALL, border = 5)
 
  165         btnCancel = wx.Button(self, wx.ID_CLOSE)
 
  166         btnCancel.SetDefault()
 
  167         btnSizer.Add(item = btnCancel, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)        
 
  169         sizer.Add(item = btnSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
 
  172         btnCancel.Bind(wx.EVT_BUTTON, self.
OnClose)
 
  173         btn_clipboard.Bind(wx.EVT_BUTTON, self.
OnCopy)
 
  179         """!Copy the regression stats to the clipboard 
  181         str = self.
title + 
'\n' 
  185         rdata = wx.TextDataObject()
 
  188         if wx.TheClipboard.Open():
 
  189             wx.TheClipboard.SetData(rdata)
 
  190             wx.TheClipboard.Close()
 
  191             wx.MessageBox(_(
"Regression statistics copied to clipboard"))
 
  194         """!Button 'Close' pressed 
  199     def __init__(self, parent, id, title, plottype = '', 
 
  200                  style = wx.DEFAULT_DIALOG_STYLE, **kwargs):
 
  201         """!Dialog to set plot text options: font, title 
  202         and font size, axis labels and font size 
  204         wx.Dialog.__init__(self, parent, id, title, style = style, **kwargs)
 
  210                              'decorative' : wx.FONTFAMILY_DECORATIVE,
 
  211                              'roman' : wx.FONTFAMILY_ROMAN,
 
  212                              'script' : wx.FONTFAMILY_SCRIPT,
 
  213                              'swiss' : wx.FONTFAMILY_SWISS,
 
  214                              'modern' : wx.FONTFAMILY_MODERN,
 
  215                              'teletype' : wx.FONTFAMILY_TELETYPE }
 
  218                             'slant' : wx.FONTSTYLE_SLANT,
 
  219                             'italic' : wx.FONTSTYLE_ITALIC }
 
  221         self.
fwtdict = { 
'normal' : wx.FONTWEIGHT_NORMAL,
 
  222                          'light' : wx.FONTWEIGHT_LIGHT,
 
  223                          'bold' : wx.FONTWEIGHT_BOLD }
 
  241     def _do_layout(self):
 
  244         sizer = wx.BoxSizer(wx.VERTICAL)
 
  246         box = wx.StaticBox(parent = self, id = wx.ID_ANY,
 
  247                            label = 
" %s " % _(
"Text settings"))
 
  248         boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
  249         gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
 
  254         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Profile title:"))
 
  255         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
 
  256         self.
ptitleentry = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = 
"", size = (250,-1))
 
  258         self.ptitleentry.SetValue(self.
ptitle)
 
  259         gridSizer.Add(item = self.
ptitleentry, pos = (0, 1))
 
  264         tlabel = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Title font size (pts):"))
 
  265         gridSizer.Add(item = tlabel, flag = wx.ALIGN_CENTER_VERTICAL, pos = (1, 0))
 
  266         self.
ptitlesize = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = 
"", pos = (30, 50),
 
  267                                       size = (50,-1), style = wx.SP_ARROW_KEYS)
 
  268         self.ptitlesize.SetRange(5,100)
 
  269         self.ptitlesize.SetValue(int(self.
properties[
'font'][
'prop'][
'titleSize']))
 
  270         gridSizer.Add(item = self.
ptitlesize, pos = (1, 1))
 
  275         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"X-axis label:"))
 
  276         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (2, 0))
 
  277         self.
xlabelentry = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = 
"", size = (250,-1))
 
  279         self.xlabelentry.SetValue(self.
xlabel)
 
  280         gridSizer.Add(item = self.
xlabelentry, pos = (2, 1))
 
  285         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Y-axis label:"))
 
  286         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (3, 0))
 
  287         self.
ylabelentry = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = 
"", size = (250,-1))
 
  289         self.ylabelentry.SetValue(self.
ylabel)
 
  290         gridSizer.Add(item = self.
ylabelentry, pos = (3, 1))
 
  295         llabel = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Label font size (pts):"))
 
  296         gridSizer.Add(item = llabel, flag = wx.ALIGN_CENTER_VERTICAL, pos = (4, 0))
 
  297         self.
axislabelsize = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = 
"", pos = (30, 50),
 
  298                                          size = (50, -1), style = wx.SP_ARROW_KEYS)
 
  299         self.axislabelsize.SetRange(5, 100) 
 
  300         self.axislabelsize.SetValue(int(self.
properties[
'font'][
'prop'][
'axisSize']))
 
  303         boxSizer.Add(item = gridSizer)
 
  304         sizer.Add(item = boxSizer, flag = wx.ALL | wx.EXPAND, border = 3)
 
  309         box = wx.StaticBox(parent = self, id = wx.ID_ANY,
 
  310                            label = 
" %s " % _(
"Font settings"))
 
  311         boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
  312         gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
 
  313         gridSizer.AddGrowableCol(1)
 
  318         label1 = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Font family:"))
 
  319         gridSizer.Add(item = label1, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
 
  320         self.
ffamilycb = wx.ComboBox(parent = self, id = wx.ID_ANY, size = (250, -1),
 
  321                                 choices = self.ffamilydict.keys(), style = wx.CB_DROPDOWN)
 
  322         self.ffamilycb.SetStringSelection(
'swiss')
 
  323         for item 
in self.ffamilydict.items():
 
  325                 self.ffamilycb.SetStringSelection(item[0])
 
  327         gridSizer.Add(item = self.
ffamilycb, pos = (0, 1), flag = wx.ALIGN_RIGHT)
 
  332         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Style:"))
 
  333         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (1, 0))
 
  334         self.
fstylecb = wx.ComboBox(parent = self, id = wx.ID_ANY, size = (250, -1),
 
  335                                     choices = self.fstyledict.keys(), style = wx.CB_DROPDOWN)
 
  336         self.fstylecb.SetStringSelection(
'normal')
 
  337         for item 
in self.fstyledict.items():
 
  339                 self.fstylecb.SetStringSelection(item[0])
 
  341         gridSizer.Add(item = self.
fstylecb, pos = (1, 1), flag = wx.ALIGN_RIGHT)
 
  346         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Weight:"))
 
  347         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (2, 0))
 
  348         self.
fwtcb = wx.ComboBox(parent = self, size = (250, -1),
 
  349                                  choices = self.fwtdict.keys(), style = wx.CB_DROPDOWN)
 
  350         self.fwtcb.SetStringSelection(
'normal')
 
  351         for item 
in self.fwtdict.items():
 
  353                 self.fwtcb.SetStringSelection(item[0])
 
  356         gridSizer.Add(item = self.
fwtcb, pos = (2, 1), flag = wx.ALIGN_RIGHT)
 
  358         boxSizer.Add(item = gridSizer, flag = wx.EXPAND)
 
  359         sizer.Add(item = boxSizer, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
 
  361         line = wx.StaticLine(parent = self, id = wx.ID_ANY, size = (20, -1), style = wx.LI_HORIZONTAL)
 
  362         sizer.Add(item = line, proportion = 0,
 
  363                   flag = wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border = 3)
 
  368         btnSave = wx.Button(self, wx.ID_SAVE)
 
  369         btnApply = wx.Button(self, wx.ID_APPLY)
 
  370         btnOk = wx.Button(self, wx.ID_OK)
 
  371         btnCancel = wx.Button(self, wx.ID_CANCEL)
 
  375         btnApply.Bind(wx.EVT_BUTTON, self.
OnApply)
 
  376         btnApply.SetToolTipString(_(
"Apply changes for the current session"))
 
  377         btnOk.Bind(wx.EVT_BUTTON, self.
OnOk)
 
  378         btnOk.SetToolTipString(_(
"Apply changes for the current session and close dialog"))
 
  380         btnSave.Bind(wx.EVT_BUTTON, self.
OnSave)
 
  381         btnSave.SetToolTipString(_(
"Apply and save changes to user settings file (default for next sessions)"))
 
  382         btnCancel.Bind(wx.EVT_BUTTON, self.
OnCancel)
 
  383         btnCancel.SetToolTipString(_(
"Close dialog and ignore changes"))
 
  386         btnStdSizer = wx.StdDialogButtonSizer()
 
  387         btnStdSizer.AddButton(btnOk)
 
  388         btnStdSizer.AddButton(btnApply)
 
  389         btnStdSizer.AddButton(btnCancel)
 
  390         btnStdSizer.Realize()
 
  392         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
 
  393         btnSizer.Add(item = btnSave, proportion = 0, flag = wx.ALIGN_LEFT | wx.ALL, border = 5)
 
  394         btnSizer.Add(item = btnStdSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
 
  395         sizer.Add(item = btnSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
 
  400         self.ptitleentry.Bind(wx.EVT_TEXT, self.
OnTitle)
 
  401         self.xlabelentry.Bind(wx.EVT_TEXT, self.
OnXLabel)
 
  402         self.ylabelentry.Bind(wx.EVT_TEXT, self.
OnYLabel)
 
  408         self.
ptitle = event.GetString()
 
  411         self.
xlabel = event.GetString()
 
  414         self.
ylabel = event.GetString()
 
  417         self.
properties[
'font'][
'prop'][
'titleSize'] = self.ptitlesize.GetValue()
 
  418         self.
properties[
'font'][
'prop'][
'axisSize'] = self.axislabelsize.GetValue()
 
  420         family = self.
ffamilydict[self.ffamilycb.GetStringSelection()]
 
  421         self.
properties[
'font'][
'wxfont'].SetFamily(family)
 
  422         style = self.
fstyledict[self.fstylecb.GetStringSelection()]
 
  423         self.
properties[
'font'][
'wxfont'].SetStyle(style)
 
  424         weight = self.
fwtdict[self.fwtcb.GetStringSelection()]
 
  425         self.
properties[
'font'][
'wxfont'].SetWeight(weight)
 
  428         """!Button 'Save' pressed""" 
  431         UserSettings.ReadSettingsFile(settings = fileSettings)
 
  433         UserSettings.SaveToFile(fileSettings)
 
  434         self.parent.parent.GetLayerManager().goutput.WriteLog(_(
'Plot text sizes saved to file \'%s\'.') % UserSettings.filePath)
 
  435         self.EndModal(wx.ID_OK)
 
  438         """!Button 'Apply' pressed""" 
  440         self.parent.OnPlotText(self)
 
  443         """!Button 'OK' pressed""" 
  445         self.EndModal(wx.ID_OK)
 
  448         """!Button 'Cancel' pressed""" 
  449         self.EndModal(wx.ID_CANCEL)
 
  452     def __init__(self, parent, id, title, plottype = '', 
 
  453                  style = wx.DEFAULT_DIALOG_STYLE, **kwargs): 
 
  454         """!Dialog to set various options for data plotted, including: line 
  455         width, color, style; marker size, color, fill, and style; grid 
  458         wx.Dialog.__init__(self, parent, id, title, style = style, **kwargs)
 
  491             wx.MessageBox(parent = self,
 
  492                               message = _(
"No map or image group selected to plot."),
 
  493                               caption = _(
"Warning"), style = wx.OK | wx.ICON_ERROR)
 
  497     def _do_layout(self):
 
  498         """!Options dialog layout 
  500         sizer = wx.BoxSizer(wx.VERTICAL)
 
  502         box = wx.StaticBox(parent = self, id = wx.ID_ANY,
 
  503                            label = 
" %s " % _(
"Plot settings")) 
 
  504         boxMainSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
  506         self.
wxId[
'pcolor']  = 0
 
  507         self.
wxId[
'pwidth']  = 0
 
  508         self.
wxId[
'pstyle']  = 0
 
  509         self.
wxId[
'psize'] = 0
 
  510         self.
wxId[
'ptype'] = 0
 
  511         self.
wxId[
'pfill'] = 0
 
  512         self.
wxId[
'plegend'] = 0
 
  513         self.
wxId[
'marker'] = {}
 
  514         self.
wxId[
'x-axis'] = {}
 
  515         self.
wxId[
'y-axis'] = {}
 
  522         box = wx.StaticBox(parent = self, id = wx.ID_ANY,
 
  523                            label = _(
"Map/image plotted"))
 
  524         boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
  526         gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
 
  531             choicelist.append(str(i))
 
  533         self.
mapchoice = wx.Choice(parent = self, id = wx.ID_ANY, size = (300, -1),
 
  534                                    choices = choicelist)
 
  535         self.mapchoice.SetToolTipString(_(
"Settings for selected map"))
 
  538             self.
map = self.
rasterList[self.mapchoice.GetCurrentSelection()]
 
  540             self.mapchoice.SetStringSelection(str(self.
map))
 
  543         gridSizer.Add(item = self.
mapchoice, flag = wx.ALIGN_CENTER_VERTICAL, 
 
  544                       pos = (row, 0), span = (1, 2))
 
  550         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Line color"))
 
  551         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  552         color = csel.ColourSelect(parent = self, id = wx.ID_ANY, colour = self.
raster[self.
map][
'pcolor'])
 
  553         self.
wxId[
'pcolor'] = color.GetId()
 
  554         gridSizer.Add(item = color, pos = (row, 1))
 
  557         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Line width"))
 
  558         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  559         width = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = 
"",
 
  560                              size = (50,-1), style = wx.SP_ARROW_KEYS)
 
  561         width.SetRange(1, 10)
 
  562         width.SetValue(self.
raster[self.
map][
'pwidth'])
 
  563         self.
wxId[
'pwidth'] = width.GetId()
 
  564         gridSizer.Add(item = width, pos = (row, 1))
 
  567         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Line style"))
 
  568         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  569         style = wx.Choice(parent = self, id = wx.ID_ANY, 
 
  570                              size = (120, -1), choices = self.linestyledict.keys())
 
  571         style.SetStringSelection(self.
raster[self.
map][
'pstyle'])
 
  572         self.
wxId[
'pstyle'] = style.GetId()
 
  573         gridSizer.Add(item = style, pos = (row, 1))
 
  576         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Legend"))
 
  577         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  578         legend = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = 
"", size = (200,-1))
 
  579         legend.SetValue(self.
raster[self.
map][
'plegend'])
 
  580         gridSizer.Add(item = legend, pos = (row, 1))
 
  581         self.
wxId[
'plegend'] = legend.GetId()
 
  583         boxSizer.Add(item = gridSizer)
 
  584         boxMainSizer.Add(item = boxSizer, flag = wx.ALL, border = 3)
 
  589         box = wx.StaticBox(parent = self, id = wx.ID_ANY,
 
  590                            label = 
" %s " % _(
"Transect segment marker settings"))
 
  592         boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
 
  594         gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
 
  595         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Color"))
 
  596         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
 
  597         ptcolor = csel.ColourSelect(parent = self, id = wx.ID_ANY, colour = self.
properties[
'marker'][
'color'])
 
  598         self.
wxId[
'marker'][
'color'] = ptcolor.GetId()
 
  599         gridSizer.Add(item = ptcolor, pos = (0, 1))
 
  601         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Size"))
 
  602         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (1, 0))
 
  603         ptsize = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = 
"",
 
  604                              size = (50, -1), style = wx.SP_ARROW_KEYS)
 
  605         ptsize.SetRange(1, 10)
 
  606         ptsize.SetValue(self.
properties[
'marker'][
'size'])
 
  607         self.
wxId[
'marker'][
'size'] = ptsize.GetId()
 
  608         gridSizer.Add(item = ptsize, pos = (1, 1))
 
  610         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Fill"))
 
  611         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (2, 0))
 
  612         ptfill = wx.Choice(parent = self, id = wx.ID_ANY, 
 
  613                            size = (120, -1), choices = self.ptfilldict.keys())
 
  614         ptfill.SetStringSelection(self.
properties[
'marker'][
'fill'])
 
  615         self.
wxId[
'marker'][
'fill'] = ptfill.GetId()
 
  616         gridSizer.Add(item = ptfill, pos = (2, 1))
 
  618         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Legend"))
 
  619         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (3, 0))
 
  620         ptlegend = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = 
"", size = (200,-1))
 
  621         ptlegend.SetValue(self.
properties[
'marker'][
'legend'])
 
  622         self.
wxId[
'marker'][
'legend'] = ptlegend.GetId()
 
  623         gridSizer.Add(item = ptlegend, pos = (3, 1))
 
  625         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Style"))
 
  626         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (4, 0))
 
  627         pttype = wx.Choice(parent = self, size = (200, -1), choices = self.
pttypelist)
 
  628         pttype.SetStringSelection(self.
properties[
'marker'][
'type'])
 
  629         self.
wxId[
'marker'][
'type'] = pttype.GetId()
 
  630         gridSizer.Add(item = pttype, pos = (4, 1))
 
  632         boxSizer.Add(item = gridSizer)
 
  633         boxMainSizer.Add(item = boxSizer, flag = wx.ALL, border = 3)
 
  635         sizer.Add(item = boxMainSizer, flag = wx.ALL | wx.EXPAND, border = 3)
 
  640         box = wx.StaticBox(parent = self, id = wx.ID_ANY,
 
  641                            label = 
" %s " % _(
"Axis settings"))
 
  642         boxMainSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
  644         middleSizer = wx.BoxSizer(wx.HORIZONTAL)
 
  647         for axis, atype 
in [(_(
"X-Axis"), 
'x-axis'),
 
  648                      (_(
"Y-Axis"), 
'y-axis')]:
 
  649             box = wx.StaticBox(parent = self, id = wx.ID_ANY,
 
  650                                label = 
" %s " % axis)
 
  651             boxSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
  652             gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
 
  657             label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Scale"))
 
  658             gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  659             type = wx.Choice(parent = self, id = wx.ID_ANY, 
 
  660                              size = (100, -1), choices = self.
axislist)
 
  661             type.SetStringSelection(prop[
'type']) 
 
  662             type.SetToolTipString(_(
"Automatic axis scaling, custom max and min, or scale matches data range (min)" ))
 
  663             self.
wxId[atype][
'type'] = type.GetId()
 
  664             gridSizer.Add(item = type, pos = (row, 1))
 
  667             label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Custom min"))
 
  668             gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  669             min = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = 
"", size = (70, -1))
 
  670             min.SetValue(str(prop[
'min']))
 
  671             self.
wxId[atype][
'min'] = min.GetId()
 
  672             gridSizer.Add(item = min, pos = (row, 1))
 
  675             label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Custom max"))
 
  676             gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  677             max = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = 
"", size = (70, -1))
 
  678             max.SetValue(str(prop[
'max']))
 
  679             self.
wxId[atype][
'max'] = max.GetId()
 
  680             gridSizer.Add(item = max, pos = (row, 1))
 
  683             log = wx.CheckBox(parent = self, id = wx.ID_ANY, label = _(
"Log scale"))
 
  684             log.SetValue(prop[
'log'])
 
  685             self.
wxId[atype][
'log'] = log.GetId()
 
  686             gridSizer.Add(item = log, pos = (row, 0), span = (1, 2))
 
  689                 flag = wx.ALL | wx.EXPAND
 
  691                 flag = wx.TOP | wx.BOTTOM | wx.RIGHT | wx.EXPAND
 
  693             boxSizer.Add(item = gridSizer, flag = wx.ALL, border = 3)
 
  694             boxMainSizer.Add(item = boxSizer, flag = flag, border = 3)
 
  698         middleSizer.Add(item = boxMainSizer, flag = wx.ALL | wx.EXPAND, border = 3)
 
  703         self.
wxId[
'grid'] = {}
 
  704         self.
wxId[
'legend'] = {}
 
  705         self.
wxId[
'font'] = {}
 
  706         box = wx.StaticBox(parent = self, id = wx.ID_ANY,
 
  707                            label = 
" %s " % _(
"Grid and Legend settings"))
 
  708         boxMainSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
 
  709         gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
 
  712         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Grid color"))
 
  713         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  714         gridcolor = csel.ColourSelect(parent = self, id = wx.ID_ANY, colour = self.
properties[
'grid'][
'color'])
 
  715         self.
wxId[
'grid'][
'color'] = gridcolor.GetId()
 
  716         gridSizer.Add(item = gridcolor, pos = (row, 1))
 
  719         gridshow = wx.CheckBox(parent = self, id = wx.ID_ANY, label = _(
"Show grid"))
 
  720         gridshow.SetValue(self.
properties[
'grid'][
'enabled'])
 
  721         self.
wxId[
'grid'][
'enabled'] = gridshow.GetId()
 
  722         gridSizer.Add(item = gridshow, pos = (row, 0), span = (1, 2))
 
  725         label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _(
"Legend font size"))
 
  726         gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
 
  727         legendfontsize = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = 
"", 
 
  728                                      size = (50, -1), style = wx.SP_ARROW_KEYS)
 
  729         legendfontsize.SetRange(5,100)
 
  730         legendfontsize.SetValue(int(self.
properties[
'font'][
'prop'][
'legendSize']))
 
  731         self.
wxId[
'font'][
'legendSize'] = legendfontsize.GetId()
 
  732         gridSizer.Add(item = legendfontsize, pos = (row, 1))
 
  735         legendshow = wx.CheckBox(parent = self, id = wx.ID_ANY, label = _(
"Show legend"))
 
  736         legendshow.SetValue(self.
properties[
'legend'][
'enabled'])
 
  737         self.
wxId[
'legend'][
'enabled'] = legendshow.GetId()
 
  738         gridSizer.Add(item = legendshow, pos = (row, 0), span = (1, 2))
 
  740         boxMainSizer.Add(item = gridSizer, flag = flag, border = 3)
 
  742         middleSizer.Add(item = boxMainSizer, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
 
  744         sizer.Add(item = middleSizer, flag = wx.ALL, border = 0)
 
  749         line = wx.StaticLine(parent = self, id = wx.ID_ANY, size = (20, -1), style = wx.LI_HORIZONTAL)
 
  750         sizer.Add(item = line, proportion = 0,
 
  751                   flag = wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border = 3)
 
  756         btnSave = wx.Button(self, wx.ID_SAVE)
 
  757         btnApply = wx.Button(self, wx.ID_APPLY)
 
  758         btnOk = wx.Button(self, wx.ID_OK)
 
  759         btnCancel = wx.Button(self, wx.ID_CANCEL)
 
  763         btnApply.SetToolTipString(_(
"Apply changes for the current session"))
 
  764         btnOk.SetToolTipString(_(
"Apply changes for the current session and close dialog"))
 
  765         btnSave.SetToolTipString(_(
"Apply and save changes to user settings file (default for next sessions)"))
 
  766         btnCancel.SetToolTipString(_(
"Close dialog and ignore changes"))
 
  769         btnStdSizer = wx.StdDialogButtonSizer()
 
  770         btnStdSizer.AddButton(btnOk)
 
  771         btnStdSizer.AddButton(btnApply)
 
  772         btnStdSizer.AddButton(btnCancel)
 
  773         btnStdSizer.Realize()
 
  775         btnSizer = wx.BoxSizer(wx.HORIZONTAL)
 
  776         btnSizer.Add(item = btnSave, proportion = 0, flag = wx.ALIGN_LEFT | wx.ALL, border = 5)
 
  777         btnSizer.Add(item = btnStdSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
 
  778         sizer.Add(item = btnSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
 
  783         self.mapchoice.Bind(wx.EVT_CHOICE, self.
OnSetMap)
 
  786         btnApply.Bind(wx.EVT_BUTTON, self.
OnApply)
 
  787         btnOk.Bind(wx.EVT_BUTTON, self.
OnOk)
 
  789         btnSave.Bind(wx.EVT_BUTTON, self.
OnSave)
 
  790         btnCancel.Bind(wx.EVT_BUTTON, self.
OnCancel)
 
  796         """!Handler for changing map selection""" 
  797         idx = event.GetSelection()
 
  801         self.FindWindowById(self.
wxId[
'pcolor']).SetColour(self.
raster[self.
map][
'pcolor'])
 
  804         self.FindWindowById(self.
wxId[
'pstyle']).SetStringSelection(self.
raster[self.
map][
'pstyle'])
 
  809         """!Handler for changing any other option""" 
  810         self.
map = self.
rasterList[self.mapchoice.GetCurrentSelection()]
 
  812         self.parent.SetGraphStyle()
 
  813         p = self.parent.CreatePlotList()
 
  814         self.parent.DrawPlot(p)
 
  817         """!Apply settings to each map and to entire plot""" 
  818         self.
raster[self.
map][
'pcolor'] = self.FindWindowById(self.
wxId[
'pcolor']).GetColour()
 
  825         self.
raster[self.
map][
'pstyle'] = self.FindWindowById(self.
wxId[
'pstyle']).GetStringSelection()
 
  829         for axis 
in (
'x-axis', 
'y-axis'):
 
  830             self.
properties[axis][
'prop'][
'type'] = self.FindWindowById(self.
wxId[axis][
'type']).GetStringSelection()
 
  833             self.
properties[axis][
'prop'][
'log'] = self.FindWindowById(self.
wxId[axis][
'log']).IsChecked()
 
  836             self.
properties[
'marker'][
'color'] = self.FindWindowById(self.
wxId[
'marker'][
'color']).GetColour()
 
  837             self.
properties[
'marker'][
'fill'] = self.FindWindowById(self.
wxId[
'marker'][
'fill']).GetStringSelection()
 
  839             self.
properties[
'marker'][
'type'] = self.FindWindowById(self.
wxId[
'marker'][
'type']).GetStringSelection()
 
  842         self.
properties[
'grid'][
'color'] = self.FindWindowById(self.
wxId[
'grid'][
'color']).GetColour()
 
  843         self.
properties[
'grid'][
'enabled'] = self.FindWindowById(self.
wxId[
'grid'][
'enabled']).IsChecked()
 
  847         self.
properties[
'font'][
'prop'][
'legendSize'] = self.FindWindowById(self.
wxId[
'font'][
'legendSize']).
GetValue()
 
  848         self.
properties[
'legend'][
'enabled'] = self.FindWindowById(self.
wxId[
'legend'][
'enabled']).IsChecked()
 
  851         """!Button 'Save' pressed""" 
  854         UserSettings.ReadSettingsFile(settings = fileSettings)
 
  856         UserSettings.SaveToFile(fileSettings)
 
  857         self.parent.parent.GetLayerManager().goutput.WriteLog(_(
'Plot settings saved to file \'%s\'.') % UserSettings.filePath)
 
  861         """!Button 'Apply' pressed. Does not close dialog""" 
  863         self.parent.SetGraphStyle()
 
  864         p = self.parent.CreatePlotList()
 
  865         self.parent.DrawPlot(p)
 
  868         """!Button 'OK' pressed""" 
  870         self.EndModal(wx.ID_OK)
 
  873         """!Button 'Cancel' pressed""" 
def OnSetMap
Handler for changing map selection. 
 
def OnSave
Button 'Save' pressed. 
 
def OnCancel
Button 'Cancel' pressed. 
 
def OnSelection
Choose maps to profile. 
 
def OnOk
Button 'OK' pressed. 
 
def __init__
Dialog to set various options for data plotted, including: line width, color, style; marker size...
 
def OnCancel
Button 'Cancel' pressed. 
 
def OnSetOpt
Handler for changing any other option. 
 
def OnClose
Button 'Close' pressed. 
 
def OnOk
Button 'OK' pressed. 
 
def __init__
Dialog to select raster maps to profile. 
 
Custom control that selects elements. 
 
def __init__
Dialog to display and save statistics for plots. 
 
def split
Platform spefic shlex.split. 
 
def OnSave
Button 'Save' pressed. 
 
def UpdateSettings
Apply settings to each map and to entire plot. 
 
def OnCopy
Copy the regression stats to the clipboard. 
 
def OnApply
Button 'Apply' pressed. 
 
def OnApply
Button 'Apply' pressed. 
 
def _do_layout
Options dialog layout.