[GRASS-SVN] r49623 - in grass/branches/develbranch_6/gui/wxpython:
. core dbmgr gui_core icons mapdisp nviz wxplot
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Dec 8 08:10:24 EST 2011
Author: martinl
Date: 2011-12-08 05:10:24 -0800 (Thu, 08 Dec 2011)
New Revision: 49623
Modified:
grass/branches/develbranch_6/gui/wxpython/Makefile
grass/branches/develbranch_6/gui/wxpython/core/gcmd.py
grass/branches/develbranch_6/gui/wxpython/core/render.py
grass/branches/develbranch_6/gui/wxpython/core/settings.py
grass/branches/develbranch_6/gui/wxpython/core/utils.py
grass/branches/develbranch_6/gui/wxpython/dbmgr/vinfo.py
grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py
grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py
grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py
grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py
grass/branches/develbranch_6/gui/wxpython/icons/grass2_icons.py
grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py
grass/branches/develbranch_6/gui/wxpython/icons/icon.py
grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py
grass/branches/develbranch_6/gui/wxpython/mapdisp/frame.py
grass/branches/develbranch_6/gui/wxpython/nviz/wxnviz.py
grass/branches/develbranch_6/gui/wxpython/wxgui.py
grass/branches/develbranch_6/gui/wxpython/wxplot/dialogs.py
Log:
wxGUI major code reorganization (part3 - wxGUI starts again)
Modified: grass/branches/develbranch_6/gui/wxpython/Makefile
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/Makefile 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/Makefile 2011-12-08 13:10:24 UTC (rev 49623)
@@ -1,8 +1,7 @@
MODULE_TOPDIR = ../..
-SUBDIRS = docs scripts
+SUBDIRS = docs
EXTRA_CLEAN_FILES = menustrings.py build_ext.pyc
-CLEAN_SUBDIRS = scripts
include $(MODULE_TOPDIR)/include/Make/Dir.make
include $(MODULE_TOPDIR)/include/Make/Doxygen.make
@@ -10,29 +9,35 @@
ETCDIR = $(ETC)/wxpython
-SRCFILES := $(wildcard compat/* gui_modules/* icons/*.* icons/silk/* xml/*) gis_set.py wxgui.py README
+SRCFILES := $(wildcard compat/* icons/*.* scripts/* xml/*) \
+ $(wildcard core/* dbmgr/* gcp/* gmodeler/* gui_core/* lmgr/* location_wizard/* \
+ mapdisp/* modules/* nviz/* psmap/* vdigit/* wxplot/* ) \
+ gis_set.py wxgui.py README
DSTFILES := $(patsubst %,$(ETCDIR)/%,$(SRCFILES)) $(patsubst %.py,$(ETCDIR)/%.pyc,$(filter %.py,$(SRCFILES)))
-default: install_scripts
+PYDSTDIRS := $(patsubst %,$(ETCDIR)/%,core dbmgr gcp gmodeler gui_core lmgr location_wizard \
+ mapdisp modules nviz psmap vdigit wxplot)
+DSTDIRS := $(patsubst %,$(ETCDIR)/%,compat icons scripts xml)
+
+default: $(DSTFILES) menustrings.py
$(MAKE) parsubdirs
-clean: cleansubdirs
+$(ETCDIR)/%: % | $(PYDSTDIRS) $(DSTDIRS)
+ $(INSTALL_DATA) $< $@
-install_scripts:
- -for dir in '' compat gui_modules icons icons/silk xml; do \
- if [ ! -d $(ETCDIR)/$$dir ] ; then $(MKDIR) $(ETCDIR)/$$dir ; fi ; \
- done
- $(MAKE) $(DSTFILES)
- $(MAKE) menustrings.py
+menustrings.py: core/menudata.py $(ETCDIR)/xml/menudata.xml $(ETCDIR)/xml/menudata_modeler.xml
+ $(call run_grass,$(PYTHON) $< > $@)
+ $(call run_grass,$(PYTHON) $< "modeler" >> $@)
-$(ETCDIR)/%: %
- $(INSTALL_DATA) $< $@
+$(PYDSTDIRS): %: | $(ETCDIR)
+ $(MKDIR) $@
+ $(call run_grass,$(PYTHON) create__init__.py $@)
-menustrings.py: gui_modules/menudata.py $(ETCDIR)/xml/menudata.xml $(ETCDIR)/xml/menudata_modeler.xml
- GISBASE="$(GISBASE)" \
- $(PYTHON) $< > $@
- GISBASE="$(GISBASE)" \
- $(PYTHON) $< "modeler" >> $@
+$(DSTDIRS): %: | $(ETCDIR)
+ $(MKDIR) $@
+$(ETCDIR):
+ $(MKDIR) $@
+
#doxygen:
DOXNAME=wxpython
Modified: grass/branches/develbranch_6/gui/wxpython/core/gcmd.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/gcmd.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/core/gcmd.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -142,7 +142,7 @@
"""!Subclass subprocess.Popen"""
def __init__(self, args, **kwargs):
if subprocess.mswindows:
- args = map(utils.EncodeString, args)
+ args = map(EncodeString, args)
subprocess.Popen.__init__(self, args, **kwargs)
@@ -637,7 +637,7 @@
ps.stdin = None
Debug.msg(3, "gcmd.RunCommand(): decoding string")
- stdout, stderr = map(utils.DecodeString, ps.communicate())
+ stdout, stderr = map(DecodeString, ps.communicate())
ret = ps.returncode
Debug.msg(1, "gcmd.RunCommand(): get return code %d" % ret)
Modified: grass/branches/develbranch_6/gui/wxpython/core/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/render.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/core/render.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -890,7 +890,7 @@
self._renderLayers(force, mapWindow, maps, masks, opacities)
# ugly hack for MSYS
- if not subprocess.mswindows:
+ if sys.platform != 'win32':
mapstr = ",".join(maps)
maskstr = ",".join(masks)
mapoutstr = self.mapfile
Modified: grass/branches/develbranch_6/gui/wxpython/core/settings.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/settings.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/core/settings.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -983,4 +983,4 @@
else:
self.userSettings[key] = copy.deepcopy(self.defaultSettings[key])
-globalSettings = Settings()
+UserSettings = Settings()
Modified: grass/branches/develbranch_6/gui/wxpython/core/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/utils.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/core/utils.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -750,7 +750,7 @@
"""!Get full path to the settings directory
"""
try:
- verFd = open(os.path.join(globalvar.ETCDIR, "VERSIONNUMBER"))
+ verFd = open(os.path.join(ETCDIR, "VERSIONNUMBER"))
version = int(verFd.readlines()[0].split(' ')[0].split('.')[0])
except (IOError, ValueError, TypeError, IndexError), e:
sys.exit(_("ERROR: Unable to determine GRASS version. Details: %s") % e)
Modified: grass/branches/develbranch_6/gui/wxpython/dbmgr/vinfo.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/dbmgr/vinfo.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/dbmgr/vinfo.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -67,7 +67,7 @@
return infoFlexSizer
-class VectorDBInfo(gselect.VectorDBInfoBase):
+class VectorDBInfo(VectorDBInfoBase):
"""!Class providing information about attribute tables
linked to the vector map"""
def __init__(self, map):
Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -43,7 +43,7 @@
from core import globalvar
from core.gcmd import GError, RunCommand, GMessage
-from gui_core.gselect import ElementSelect, LocationSelect, MapsetSelect, Select, OgrTypeSelect, GdalSelect
+from gui_core.gselect import ElementSelect, LocationSelect, MapsetSelect, Select, GdalSelect
from gui_core.forms import GUI
from core.utils import GetListOfMapsets, GetLayerNameFromCmd, GetValidLayerName
from core.settings import UserSettings
Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/forms.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -1,4 +1,4 @@
-p"""
+"""
@package gui_core.forms
@brief Construct simple wxPython GUI from a GRASS command interface
Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -1051,7 +1051,7 @@
"""!Set styles for styled text output windows with type face
and point size selected by user (Courier New 10 is default)"""
- settings = preferences.Settings()
+ settings = Settings()
typeface = settings.Get(group = 'appearance', key = 'outputfont', subkey = 'type')
if typeface == "":
Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -228,7 +228,7 @@
class PreferencesDialog(PreferencesBaseDialog):
"""!User preferences dialog"""
def __init__(self, parent, title = _("GUI Settings"),
- settings = globalSettings):
+ settings = UserSettings):
PreferencesBaseDialog.__init__(self, parent = parent, title = title,
settings = settings)
@@ -1251,7 +1251,7 @@
def __init__(self, parent, title, id = wx.ID_ANY,
style = wx.DEFAULT_DIALOG_STYLE |
wx.RESIZE_BORDER,
- settings = globalSettings,
+ settings = UserSettings,
type = 'font'):
self.settings = settings
Modified: grass/branches/develbranch_6/gui/wxpython/icons/grass2_icons.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/grass2_icons.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/icons/grass2_icons.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -7,7 +7,7 @@
import os
-from gui_modules import globalvar
+from core import globalvar
iconPath = os.path.join(globalvar.ETCDIR, "gui", "icons", "grass2")
Modified: grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -4,7 +4,7 @@
import os
-import globalvar
+from core import globalvar
iconPath = os.path.join(globalvar.ETCDIR, "gui", "icons", "grass")
iconPathVDigit = os.path.join(globalvar.ETCDIR, "gui", "icons", "grass", "edit")
Modified: grass/branches/develbranch_6/gui/wxpython/icons/icon.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -27,7 +27,7 @@
import wx
-from preferences import globalSettings as UserSettings
+from core.settings import UserSettings
import grass2_icons # default icon set
iconPathDefault = grass2_icons.iconPath
Modified: grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -10,7 +10,7 @@
import wx
-import globalvar
+from core import globalvar
iconPath = os.path.join(globalvar.ETCDIR, "gui", "icons", "silk")
Modified: grass/branches/develbranch_6/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/mapdisp/frame.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/mapdisp/frame.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -48,7 +48,6 @@
from gui_core.mapdisp import MapFrameBase
from mapdisp.mapwindow import BufferedWindow
from modules.histogram import HistogramFrame
-from wxplot.histogram import Histogram2Frame
from wxplot.profile import ProfileFrame
from nviz.main import haveNviz
from nviz.mapwindow import GLWindow
Modified: grass/branches/develbranch_6/gui/wxpython/nviz/wxnviz.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/nviz/wxnviz.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/nviz/wxnviz.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -41,11 +41,10 @@
from ctypes import *
try:
from grass.lib.gis import *
- from grass.lib.raster3d import *
+ from grass.lib.g3d import *
from grass.lib.vector import *
from grass.lib.ogsf import *
from grass.lib.nviz import *
- from grass.lib.raster import *
except ImportError, e:
sys.stderr.write(_("3D view mode: %s\n") % e)
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -58,7 +58,7 @@
from dbmgr.manager import AttributeManager
from core.workspace import ProcessWorkspaceFile, ProcessGrcFile, WriteWorkspaceFile
from gui_core.goutput import GMConsole
-from gui_core.dialogs import GdalOutputDialog, DxfImportDialog, GdalImportDialog, MapLayersDialog
+from gui_core.dialogs import DxfImportDialog, GdalImportDialog, MapLayersDialog
from gui_core.dialogs import LocationDialog, MapsetDialog, CreateNewVector, GroupDialog
from modules.ogc_services import WMSDialog
from modules.colorrules import RasterColorTable, VectorColorTable
Modified: grass/branches/develbranch_6/gui/wxpython/wxplot/dialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxplot/dialogs.py 2011-12-08 12:47:06 UTC (rev 49622)
+++ grass/branches/develbranch_6/gui/wxpython/wxplot/dialogs.py 2011-12-08 13:10:24 UTC (rev 49623)
@@ -6,6 +6,8 @@
Classes:
- dialogs::ProfileRasterDialog
- dialogs::PlotStatsFrame
+ - dialogs::TextDialog
+ - dialogs::OptDialog
(C) 2011 by the GRASS Development Team
@@ -190,3 +192,605 @@
"""!Button 'Close' pressed
"""
self.Close(True)
+
+class TextDialog(wx.Dialog):
+ def __init__(self, parent, id, title,
+ style = wx.DEFAULT_DIALOG_STYLE, **kwargs):
+ """!Dialog to set profile text options: font, title
+ and font size, axis labels and font size
+ """
+ wx.Dialog.__init__(self, parent, id, title, style = style, **kwargs)
+ #
+ # initialize variables
+ #
+ # combo box entry lists
+ self.ffamilydict = { 'default' : wx.FONTFAMILY_DEFAULT,
+ 'decorative' : wx.FONTFAMILY_DECORATIVE,
+ 'roman' : wx.FONTFAMILY_ROMAN,
+ 'script' : wx.FONTFAMILY_SCRIPT,
+ 'swiss' : wx.FONTFAMILY_SWISS,
+ 'modern' : wx.FONTFAMILY_MODERN,
+ 'teletype' : wx.FONTFAMILY_TELETYPE }
+
+ self.fstyledict = { 'normal' : wx.FONTSTYLE_NORMAL,
+ 'slant' : wx.FONTSTYLE_SLANT,
+ 'italic' : wx.FONTSTYLE_ITALIC }
+
+ self.fwtdict = { 'normal' : wx.FONTWEIGHT_NORMAL,
+ 'light' : wx.FONTWEIGHT_LIGHT,
+ 'bold' : wx.FONTWEIGHT_BOLD }
+
+ self.parent = parent
+
+ self.ptitle = self.parent.ptitle
+ self.xlabel = self.parent.xlabel
+ self.ylabel = self.parent.ylabel
+
+ self.properties = self.parent.properties # read-only
+
+ # font size
+ self.fontfamily = self.properties['font']['wxfont'].GetFamily()
+ self.fontstyle = self.properties['font']['wxfont'].GetStyle()
+ self.fontweight = self.properties['font']['wxfont'].GetWeight()
+
+ self._do_layout()
+
+ def _do_layout(self):
+ """!Do layout"""
+ # dialog layout
+ sizer = wx.BoxSizer(wx.VERTICAL)
+
+ box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s " % _("Text settings"))
+ boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+ gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+
+ #
+ # profile title
+ #
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Profile title:"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
+ self.ptitleentry = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = "", size = (250,-1))
+ # self.ptitleentry.SetFont(self.font)
+ self.ptitleentry.SetValue(self.ptitle)
+ gridSizer.Add(item = self.ptitleentry, pos = (0, 1))
+
+ #
+ # title font
+ #
+ tlabel = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Title font size (pts):"))
+ gridSizer.Add(item = tlabel, flag = wx.ALIGN_CENTER_VERTICAL, pos = (1, 0))
+ self.ptitlesize = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = "", pos = (30, 50),
+ size = (50,-1), style = wx.SP_ARROW_KEYS)
+ self.ptitlesize.SetRange(5,100)
+ self.ptitlesize.SetValue(int(self.properties['font']['prop']['titleSize']))
+ gridSizer.Add(item = self.ptitlesize, pos = (1, 1))
+
+ #
+ # x-axis label
+ #
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("X-axis label:"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (2, 0))
+ self.xlabelentry = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = "", size = (250,-1))
+ # self.xlabelentry.SetFont(self.font)
+ self.xlabelentry.SetValue(self.xlabel)
+ gridSizer.Add(item = self.xlabelentry, pos = (2, 1))
+
+ #
+ # y-axis label
+ #
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Y-axis label:"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (3, 0))
+ self.ylabelentry = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = "", size = (250,-1))
+ # self.ylabelentry.SetFont(self.font)
+ self.ylabelentry.SetValue(self.ylabel)
+ gridSizer.Add(item = self.ylabelentry, pos = (3, 1))
+
+ #
+ # font size
+ #
+ llabel = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Label font size (pts):"))
+ gridSizer.Add(item = llabel, flag = wx.ALIGN_CENTER_VERTICAL, pos = (4, 0))
+ self.axislabelsize = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = "", pos = (30, 50),
+ size = (50, -1), style = wx.SP_ARROW_KEYS)
+ self.axislabelsize.SetRange(5, 100)
+ self.axislabelsize.SetValue(int(self.properties['font']['prop']['axisSize']))
+ gridSizer.Add(item = self.axislabelsize, pos = (4,1))
+
+ boxSizer.Add(item = gridSizer)
+ sizer.Add(item = boxSizer, flag = wx.ALL | wx.EXPAND, border = 3)
+
+ #
+ # font settings
+ #
+ box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s " % _("Font settings"))
+ boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+ gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+ gridSizer.AddGrowableCol(1)
+
+ #
+ # font family
+ #
+ label1 = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Font family:"))
+ gridSizer.Add(item = label1, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
+ self.ffamilycb = wx.ComboBox(parent = self, id = wx.ID_ANY, size = (250, -1),
+ choices = self.ffamilydict.keys(), style = wx.CB_DROPDOWN)
+ self.ffamilycb.SetStringSelection('swiss')
+ for item in self.ffamilydict.items():
+ if self.fontfamily == item[1]:
+ self.ffamilycb.SetStringSelection(item[0])
+ break
+ gridSizer.Add(item = self.ffamilycb, pos = (0, 1), flag = wx.ALIGN_RIGHT)
+
+ #
+ # font style
+ #
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Style:"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (1, 0))
+ self.fstylecb = wx.ComboBox(parent = self, id = wx.ID_ANY, size = (250, -1),
+ choices = self.fstyledict.keys(), style = wx.CB_DROPDOWN)
+ self.fstylecb.SetStringSelection('normal')
+ for item in self.fstyledict.items():
+ if self.fontstyle == item[1]:
+ self.fstylecb.SetStringSelection(item[0])
+ break
+ gridSizer.Add(item = self.fstylecb, pos = (1, 1), flag = wx.ALIGN_RIGHT)
+
+ #
+ # font weight
+ #
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Weight:"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (2, 0))
+ self.fwtcb = wx.ComboBox(parent = self, size = (250, -1),
+ choices = self.fwtdict.keys(), style = wx.CB_DROPDOWN)
+ self.fwtcb.SetStringSelection('normal')
+ for item in self.fwtdict.items():
+ if self.fontweight == item[1]:
+ self.fwtcb.SetStringSelection(item[0])
+ break
+
+ gridSizer.Add(item = self.fwtcb, pos = (2, 1), flag = wx.ALIGN_RIGHT)
+
+ boxSizer.Add(item = gridSizer, flag = wx.EXPAND)
+ sizer.Add(item = boxSizer, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
+
+ line = wx.StaticLine(parent = self, id = wx.ID_ANY, size = (20, -1), style = wx.LI_HORIZONTAL)
+ sizer.Add(item = line, proportion = 0,
+ flag = wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border = 3)
+
+ #
+ # buttons
+ #
+ btnSave = wx.Button(self, wx.ID_SAVE)
+ btnApply = wx.Button(self, wx.ID_APPLY)
+ btnOk = wx.Button(self, wx.ID_OK)
+ btnCancel = wx.Button(self, wx.ID_CANCEL)
+ btnOk.SetDefault()
+
+ # bindigs
+ btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
+ btnApply.SetToolTipString(_("Apply changes for the current session"))
+ btnOk.Bind(wx.EVT_BUTTON, self.OnOk)
+ btnOk.SetToolTipString(_("Apply changes for the current session and close dialog"))
+ btnOk.SetDefault()
+ btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
+ btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
+ btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
+ btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
+
+ # sizers
+ btnStdSizer = wx.StdDialogButtonSizer()
+ btnStdSizer.AddButton(btnOk)
+ btnStdSizer.AddButton(btnApply)
+ btnStdSizer.AddButton(btnCancel)
+ btnStdSizer.Realize()
+
+ btnSizer = wx.BoxSizer(wx.HORIZONTAL)
+ btnSizer.Add(item = btnSave, proportion = 0, flag = wx.ALIGN_LEFT | wx.ALL, border = 5)
+ btnSizer.Add(item = btnStdSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+ sizer.Add(item = btnSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+
+ #
+ # bindings
+ #
+ self.ptitleentry.Bind(wx.EVT_TEXT, self.OnTitle)
+ self.xlabelentry.Bind(wx.EVT_TEXT, self.OnXLabel)
+ self.ylabelentry.Bind(wx.EVT_TEXT, self.OnYLabel)
+
+ self.SetSizer(sizer)
+ sizer.Fit(self)
+
+ def OnTitle(self, event):
+ self.ptitle = event.GetString()
+
+ def OnXLabel(self, event):
+ self.xlabel = event.GetString()
+
+ def OnYLabel(self, event):
+ self.ylabel = event.GetString()
+
+ def UpdateSettings(self):
+ self.properties['font']['prop']['titleSize'] = self.ptitlesize.GetValue()
+ self.properties['font']['prop']['axisSize'] = self.axislabelsize.GetValue()
+
+ family = self.ffamilydict[self.ffamilycb.GetStringSelection()]
+ self.properties['font']['wxfont'].SetFamily(family)
+ style = self.fstyledict[self.fstylecb.GetStringSelection()]
+ self.properties['font']['wxfont'].SetStyle(style)
+ weight = self.fwtdict[self.fwtcb.GetStringSelection()]
+ self.properties['font']['wxfont'].SetWeight(weight)
+
+ def OnSave(self, event):
+ """!Button 'Save' pressed"""
+ self.UpdateSettings()
+ fileSettings = {}
+ UserSettings.ReadSettingsFile(settings = fileSettings)
+ fileSettings['profile'] = UserSettings.Get(group = 'profile')
+ file = UserSettings.SaveToFile(fileSettings)
+ self.parent.parent.GetLayerManager().goutput.WriteLog(_('Profile settings saved to file \'%s\'.') % file)
+ self.EndModal(wx.ID_OK)
+
+ def OnApply(self, event):
+ """!Button 'Apply' pressed"""
+ self.UpdateSettings()
+ self.parent.OnPText(self)
+
+ def OnOk(self, event):
+ """!Button 'OK' pressed"""
+ self.UpdateSettings()
+ self.EndModal(wx.ID_OK)
+
+ def OnCancel(self, event):
+ """!Button 'Cancel' pressed"""
+ self.EndModal(wx.ID_CANCEL)
+
+class OptDialog(wx.Dialog):
+ def __init__(self, parent, id, title,
+ style = wx.DEFAULT_DIALOG_STYLE, **kwargs):
+ """!Dialog to set various profile options, including: line
+ width, color, style; marker size, color, fill, and style; grid
+ and legend options.
+ """
+ wx.Dialog.__init__(self, parent, id, title, style = style, **kwargs)
+ # init variables
+ self.pstyledict = parent.pstyledict
+ self.ptfilldict = parent.ptfilldict
+
+ self.pttypelist = ['circle',
+ 'dot',
+ 'square',
+ 'triangle',
+ 'triangle_down',
+ 'cross',
+ 'plus']
+
+ self.axislist = ['min',
+ 'auto',
+ 'custom']
+
+ # widgets ids
+ self.wxId = {}
+
+ self.parent = parent
+
+ # read-only
+ self.raster = self.parent.raster
+ self.properties = self.parent.properties
+
+ self._do_layout()
+
+ def _do_layout(self):
+ """!Do layout"""
+ # dialog layout
+ sizer = wx.BoxSizer(wx.VERTICAL)
+
+ #
+ # profile line settings
+ #
+ box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s " % _("Profile line settings"))
+ boxMainSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
+
+ idx = 1
+ self.wxId['pcolor'] = []
+ self.wxId['pwidth'] = []
+ self.wxId['pstyle'] = []
+ self.wxId['plegend'] = []
+ for r in self.raster.itervalues():
+ box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s %d " % (_("Profile"), idx))
+ boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+ gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+ row = 0
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Line color"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ pcolor = csel.ColourSelect(parent = self, id = wx.ID_ANY, colour = r['prop']['pcolor'])
+ self.wxId['pcolor'].append(pcolor.GetId())
+ gridSizer.Add(item = pcolor, pos = (row, 1))
+
+ row += 1
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Line width"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ pwidth = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = "",
+ size = (50,-1), style = wx.SP_ARROW_KEYS)
+ pwidth.SetRange(1, 10)
+ pwidth.SetValue(r['prop']['pwidth'])
+ self.wxId['pwidth'].append(pwidth.GetId())
+ gridSizer.Add(item = pwidth, pos = (row, 1))
+
+ row +=1
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Line style"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ pstyle = wx.ComboBox(parent = self, id = wx.ID_ANY,
+ size = (120, -1), choices = self.pstyledict.keys(), style = wx.CB_DROPDOWN)
+ pstyle.SetStringSelection(r['prop']['pstyle'])
+ self.wxId['pstyle'].append(pstyle.GetId())
+ gridSizer.Add(item = pstyle, pos = (row, 1))
+
+ row += 1
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Legend"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ plegend = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = "", size = (200,-1))
+ plegend.SetValue(r['plegend'])
+ gridSizer.Add(item = plegend, pos = (row, 1))
+ self.wxId['plegend'].append(plegend.GetId())
+ boxSizer.Add(item = gridSizer)
+
+ if idx == 0:
+ flag = wx.ALL
+ else:
+ flag = wx.TOP | wx.BOTTOM | wx.RIGHT
+ boxMainSizer.Add(item = boxSizer, flag = flag, border = 3)
+
+ idx += 1
+
+ sizer.Add(item = boxMainSizer, flag = wx.ALL | wx.EXPAND, border = 3)
+
+ middleSizer = wx.BoxSizer(wx.HORIZONTAL)
+
+ #
+ # segment marker settings
+ #
+ box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s " % _("Transect segment marker settings"))
+ boxMainSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
+
+ self.wxId['marker'] = {}
+ gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Color"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (0, 0))
+ ptcolor = csel.ColourSelect(parent = self, id = wx.ID_ANY, colour = self.properties['marker']['color'])
+ self.wxId['marker']['color'] = ptcolor.GetId()
+ gridSizer.Add(item = ptcolor, pos = (0, 1))
+
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Size"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (1, 0))
+ ptsize = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = "",
+ size = (50, -1), style = wx.SP_ARROW_KEYS)
+ ptsize.SetRange(1, 10)
+ ptsize.SetValue(self.properties['marker']['size'])
+ self.wxId['marker']['size'] = ptsize.GetId()
+ gridSizer.Add(item = ptsize, pos = (1, 1))
+
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Style"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (2, 0))
+ ptfill = wx.ComboBox(parent = self, id = wx.ID_ANY,
+ size = (120, -1), choices = self.ptfilldict.keys(), style = wx.CB_DROPDOWN)
+ ptfill.SetStringSelection(self.properties['marker']['fill'])
+ self.wxId['marker']['fill'] = ptfill.GetId()
+ gridSizer.Add(item = ptfill, pos = (2, 1))
+
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Legend"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (3, 0))
+ ptlegend = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = "", size = (200,-1))
+ ptlegend.SetValue(self.properties['marker']['legend'])
+ self.wxId['marker']['legend'] = ptlegend.GetId()
+ gridSizer.Add(item = ptlegend, pos = (3, 1))
+
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Type"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (4, 0))
+ pttype = wx.ComboBox(parent = self,
+ size = (200, -1), choices = self.pttypelist, style = wx.CB_DROPDOWN)
+ pttype.SetStringSelection(self.properties['marker']['type'])
+ self.wxId['marker']['type'] = pttype.GetId()
+ gridSizer.Add(item = pttype, pos = (4, 1))
+
+ boxMainSizer.Add(item = gridSizer, flag = wx.ALL, border = 3)
+ middleSizer.Add(item = boxMainSizer, flag = wx.ALL | wx.EXPAND, border = 3)
+
+ #
+ # axis options
+ #
+ box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s " % _("Axis settings"))
+ boxMainSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
+
+ self.wxId['x-axis'] = {}
+ self.wxId['y-axis'] = {}
+ idx = 0
+ for axis, atype in [(_("X-Axis"), 'x-axis'),
+ (_("Y-Axis"), 'y-axis')]:
+ box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s " % axis)
+ boxSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
+ gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+
+ prop = self.properties[atype]['prop']
+
+ row = 0
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Style"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ type = wx.ComboBox(parent = self, id = wx.ID_ANY,
+ size = (100, -1), choices = self.axislist, style = wx.CB_DROPDOWN)
+ type.SetStringSelection(prop['type'])
+ self.wxId[atype]['type'] = type.GetId()
+ gridSizer.Add(item = type, pos = (row, 1))
+
+ row += 1
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Custom min"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ min = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = "", size = (70, -1))
+ min.SetValue(str(prop['min']))
+ self.wxId[atype]['min'] = min.GetId()
+ gridSizer.Add(item = min, pos = (row, 1))
+
+ row += 1
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Custom max"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ max = wx.TextCtrl(parent = self, id = wx.ID_ANY, value = "", size = (70, -1))
+ max.SetValue(str(prop['max']))
+ self.wxId[atype]['max'] = max.GetId()
+ gridSizer.Add(item = max, pos = (row, 1))
+
+ row += 1
+ log = wx.CheckBox(parent = self, id = wx.ID_ANY, label = _("Log scale"))
+ log.SetValue(prop['log'])
+ self.wxId[atype]['log'] = log.GetId()
+ gridSizer.Add(item = log, pos = (row, 0), span = (1, 2))
+
+ if idx == 0:
+ flag = wx.ALL | wx.EXPAND
+ else:
+ flag = wx.TOP | wx.BOTTOM | wx.RIGHT | wx.EXPAND
+
+ boxSizer.Add(item = gridSizer, flag = wx.ALL, border = 3)
+ boxMainSizer.Add(item = boxSizer, flag = flag, border = 3)
+
+ idx += 1
+
+ middleSizer.Add(item = boxMainSizer, flag = wx.ALL | wx.EXPAND, border = 3)
+
+ #
+ # grid & legend options
+ #
+ self.wxId['grid'] = {}
+ self.wxId['legend'] = {}
+ self.wxId['font'] = {}
+ box = wx.StaticBox(parent = self, id = wx.ID_ANY,
+ label = " %s " % _("Grid and Legend settings"))
+ boxMainSizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
+ gridSizer = wx.GridBagSizer(vgap = 5, hgap = 5)
+
+ row = 0
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Grid color"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ gridcolor = csel.ColourSelect(parent = self, id = wx.ID_ANY, colour = self.properties['grid']['color'])
+ self.wxId['grid']['color'] = gridcolor.GetId()
+ gridSizer.Add(item = gridcolor, pos = (row, 1))
+
+ row +=1
+ gridshow = wx.CheckBox(parent = self, id = wx.ID_ANY, label = _("Show grid"))
+ gridshow.SetValue(self.properties['grid']['enabled'])
+ self.wxId['grid']['enabled'] = gridshow.GetId()
+ gridSizer.Add(item = gridshow, pos = (row, 0), span = (1, 2))
+
+ row +=1
+ label = wx.StaticText(parent = self, id = wx.ID_ANY, label = _("Legend font size"))
+ gridSizer.Add(item = label, flag = wx.ALIGN_CENTER_VERTICAL, pos = (row, 0))
+ legendfontsize = wx.SpinCtrl(parent = self, id = wx.ID_ANY, value = "",
+ size = (50, -1), style = wx.SP_ARROW_KEYS)
+ legendfontsize.SetRange(5,100)
+ legendfontsize.SetValue(int(self.properties['font']['prop']['legendSize']))
+ self.wxId['font']['legendSize'] = legendfontsize.GetId()
+ gridSizer.Add(item = legendfontsize, pos = (row, 1))
+
+ row += 1
+ legendshow = wx.CheckBox(parent = self, id = wx.ID_ANY, label = _("Show legend"))
+ legendshow.SetValue(self.properties['legend']['enabled'])
+ self.wxId['legend']['enabled'] = legendshow.GetId()
+ gridSizer.Add(item = legendshow, pos = (row, 0), span = (1, 2))
+
+ boxMainSizer.Add(item = gridSizer, flag = flag, border = 3)
+
+ middleSizer.Add(item = boxMainSizer, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
+
+ sizer.Add(item = middleSizer, flag = wx.ALL, border = 0)
+
+ #
+ # line & buttons
+ #
+ line = wx.StaticLine(parent = self, id = wx.ID_ANY, size = (20, -1), style = wx.LI_HORIZONTAL)
+ sizer.Add(item = line, proportion = 0,
+ flag = wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, border = 3)
+
+ #
+ # buttons
+ #
+ btnSave = wx.Button(self, wx.ID_SAVE)
+ btnApply = wx.Button(self, wx.ID_APPLY)
+ btnCancel = wx.Button(self, wx.ID_CANCEL)
+ btnSave.SetDefault()
+
+ # bindigs
+ btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
+ btnApply.SetToolTipString(_("Apply changes for the current session"))
+ btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
+ btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
+ btnSave.SetDefault()
+ btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
+ btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
+
+ # sizers
+ btnStdSizer = wx.StdDialogButtonSizer()
+ btnStdSizer.AddButton(btnCancel)
+ btnStdSizer.AddButton(btnSave)
+ btnStdSizer.AddButton(btnApply)
+ btnStdSizer.Realize()
+
+ sizer.Add(item = btnStdSizer, proportion = 0, flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+
+ self.SetSizer(sizer)
+ sizer.Fit(self)
+
+ def UpdateSettings(self):
+ idx = 0
+ for r in self.raster.itervalues():
+ r['prop']['pcolor'] = self.FindWindowById(self.wxId['pcolor'][idx]).GetColour()
+ r['prop']['pwidth'] = int(self.FindWindowById(self.wxId['pwidth'][idx]).GetValue())
+ r['prop']['pstyle'] = self.FindWindowById(self.wxId['pstyle'][idx]).GetStringSelection()
+ r['plegend'] = self.FindWindowById(self.wxId['plegend'][idx]).GetValue()
+ idx +=1
+
+ self.properties['marker']['color'] = self.FindWindowById(self.wxId['marker']['color']).GetColour()
+ self.properties['marker']['fill'] = self.FindWindowById(self.wxId['marker']['fill']).GetStringSelection()
+ self.properties['marker']['size'] = self.FindWindowById(self.wxId['marker']['size']).GetValue()
+ self.properties['marker']['type'] = self.FindWindowById(self.wxId['marker']['type']).GetValue()
+ self.properties['marker']['legend'] = self.FindWindowById(self.wxId['marker']['legend']).GetValue()
+
+ for axis in ('x-axis', 'y-axis'):
+ self.properties[axis]['prop']['type'] = self.FindWindowById(self.wxId[axis]['type']).GetValue()
+ self.properties[axis]['prop']['min'] = float(self.FindWindowById(self.wxId[axis]['min']).GetValue())
+ self.properties[axis]['prop']['max'] = float(self.FindWindowById(self.wxId[axis]['max']).GetValue())
+ self.properties[axis]['prop']['log'] = self.FindWindowById(self.wxId[axis]['log']).IsChecked()
+
+ self.properties['grid']['color'] = self.FindWindowById(self.wxId['grid']['color']).GetColour()
+ self.properties['grid']['enabled'] = self.FindWindowById(self.wxId['grid']['enabled']).IsChecked()
+
+ self.properties['font']['prop']['legendSize'] = self.FindWindowById(self.wxId['font']['legendSize']).GetValue()
+ self.properties['legend']['enabled'] = self.FindWindowById(self.wxId['legend']['enabled']).IsChecked()
+
+ def OnSave(self, event):
+ """!Button 'Save' pressed"""
+ self.UpdateSettings()
+ fileSettings = {}
+ UserSettings.ReadSettingsFile(settings = fileSettings)
+ fileSettings['profile'] = UserSettings.Get(group = 'profile')
+ file = UserSettings.SaveToFile(fileSettings)
+ self.parent.parent.GetLayerManager().goutput.WriteLog(_('Profile settings saved to file \'%s\'.') % file)
+ self.parent.SetGraphStyle()
+ if self.parent.profile:
+ self.parent.DrawPlot()
+ self.Close()
+
+ def OnApply(self, event):
+ """!Button 'Apply' pressed. Does not close dialog"""
+ self.UpdateSettings()
+ self.parent.SetGraphStyle()
+ if self.parent.profile:
+ self.parent.DrawPlot()
+
+ def OnCancel(self, event):
+ """!Button 'Cancel' pressed"""
+ self.Close()
More information about the grass-commit
mailing list