/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/rasterlayerproperties.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Thuban/UI/rasterlayerproperties.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2562 - (hide annotations)
Wed Feb 16 21:14:47 2005 UTC (20 years ago) by jonathan
Original Path: trunk/thuban/Thuban/UI/rasterlayerproperties.py
File MIME type: text/x-python
File size: 3407 byte(s)
Further wxPython 2.5 changes using patches from Daniel Calvelo Aros
so that that wxproj doesn't crash. Added GUI support for selecting
alpha channel (opacity can't be selected yet).

1 jonathan 2551 # Copyright (c) 2005 by Intevation GmbH
2     # Authors:
3     # Jonathan Coles <[email protected]>
4     #
5     # This program is free software under the GPL (>=v2)
6     # Read the file COPYING coming with Thuban for details.
7    
8     """Raster Layer Properties dialog"""
9    
10     __version__ = "$Revision$"
11     # $Source$
12     # $Id$
13    
14     from wxPython.wx import *
15    
16     from Thuban import _
17     from Thuban.UI.layerproperties import LayerProperties
18     from Thuban.Model.resource import has_gdal_support, gdal_support_status
19    
20 jonathan 2562 from Thuban.version import versions
21    
22 jonathan 2551 class RasterLayerProperties(LayerProperties):
23    
24     def __init__(self, parent, name, layer, *args, **kw):
25     LayerProperties.__init__(self, parent, name, layer)
26    
27     self.old_state = {}
28 jonathan 2562 self.old_state["mask_type"] = layer.MaskType()
29 jonathan 2551
30     LayerProperties.dialog_layout(self)
31    
32     def dialog_layout(self, panel, panelBox):
33    
34     info = self.layer.ImageInfo()
35    
36     if info is None:
37     panelBox.Add(
38     wxStaticText(panel, -1,
39     _("GDAL image information unavailable. See About box for details.")),
40     0, wxALIGN_LEFT | wxALL, 4)
41     return
42    
43    
44     # Bounding Box
45     bbox = self.layer.LatLongBoundingBox()
46     if bbox is None:
47     text = _("Extent (lat-lon): None")
48     else:
49     text = _("Extent (lat-lon): (%g, %g, %g, %g)") % tuple(bbox)
50    
51     panelBox.Add(wxStaticText(panel, -1, text), 0, wxALIGN_LEFT|wxALL, 4)
52    
53     rasterBox = wxStaticBoxSizer(wxStaticBox(panel, -1,
54     _("Image Properties")), wxVERTICAL)
55    
56    
57     rasterBox.Add(
58     wxStaticText(panel, -1,
59     _("Source: %s") % self.layer.GetImageFilename()),
60     0, wxALIGN_LEFT | wxALL, 4)
61    
62     infoBox = wxBoxSizer(wxHORIZONTAL)
63    
64     nBands = info["nBands"]
65    
66     self.usePalIndex = nBands == 1
67    
68     infoBox.Add(
69     wxStaticText(panel, -1, _("Driver: %s") % info["Driver"]),
70     0, wxALIGN_LEFT | wxRIGHT, 10)
71     infoBox.Add(
72     wxStaticText(panel, -1, _("Size: %ix%i") % info["Size"]),
73     0, wxALIGN_LEFT | wxRIGHT, 10)
74     infoBox.Add(
75     wxStaticText(panel, -1, _("Number of Bands: %i") % nBands),
76     0, wxALIGN_LEFT | wxRIGHT, 0)
77    
78     rasterBox.Add(infoBox, 0, wxALIGN_LEFT|wxALL, 4)
79    
80     # Mask
81    
82     maskBox = wxBoxSizer(wxHORIZONTAL)
83    
84 jonathan 2562 if versions['wxPython-tuple'] < (2,5,3):
85     choices = ["None", "Bitmap",
86     "Alpha (Not support by wxPython %s)" % \
87     versions['wxPython']]
88     else:
89     choices = ["None", "Bitmap", "Alpha"]
90 jonathan 2551
91 jonathan 2562 self.maskRadioBox = wxRadioBox(panel, -1, _("Mask Type"),
92     choices=choices)
93     #self.maskCB = wxCheckBox(panel, -1, _("Use Mask"))
94     maskBox.Add(self.maskRadioBox, 0, wxRIGHT, 10)
95    
96 jonathan 2551 rasterBox.Add(maskBox, 0, wxALL, 4)
97     panelBox.Add(rasterBox, 1, wxGROW | wxALL, 4)
98    
99 jonathan 2562 self.maskRadioBox.SetSelection(self.old_state["mask_type"])
100 jonathan 2551
101     def OnTry(self, event):
102     self.set_state()
103    
104     def OnOK(self, event):
105     if self.set_state():
106     self.Close()
107    
108     def OnRevert(self, event):
109 jonathan 2562 self.maskRadioBox.SetSelection(self.old_state["mask_type"])
110 jonathan 2551 self.set_state()
111    
112     def set_state(self):
113 jonathan 2562 self.layer.SetMaskType(self.maskRadioBox.GetSelection())
114 jonathan 2551 return True

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26