/[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 2700 - (hide annotations)
Mon Sep 18 14:27:02 2006 UTC (18 years, 5 months ago) by dpinte
Original Path: trunk/thuban/Thuban/UI/rasterlayerproperties.py
File MIME type: text/x-python
File size: 4363 byte(s)
2006-09-18 Didrik Pinte <dpinte@itae.be>
    
        * wxPython 2.6 update : wx 2.4 syntax has been updated to 2.6


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 dpinte 2700 import wx
15 jonathan 2551
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 2587 ID_RB_MASK = 4002
23    
24 jonathan 2551 class RasterLayerProperties(LayerProperties):
25    
26     def __init__(self, parent, name, layer, *args, **kw):
27     LayerProperties.__init__(self, parent, name, layer)
28    
29     self.old_state = {}
30 jonathan 2562 self.old_state["mask_type"] = layer.MaskType()
31 jonathan 2551
32     LayerProperties.dialog_layout(self)
33    
34     def dialog_layout(self, panel, panelBox):
35    
36     info = self.layer.ImageInfo()
37    
38     if info is None:
39     panelBox.Add(
40 dpinte 2700 wx.StaticText(panel, -1,
41 jonathan 2551 _("GDAL image information unavailable. See About box for details.")),
42 dpinte 2700 0, wx.ALIGN_LEFT | wx.ALL, 4)
43 jonathan 2551 return
44    
45 dpinte 2700
46 jonathan 2551 # Bounding Box
47     bbox = self.layer.LatLongBoundingBox()
48     if bbox is None:
49     text = _("Extent (lat-lon): None")
50     else:
51     text = _("Extent (lat-lon): (%g, %g, %g, %g)") % tuple(bbox)
52    
53 dpinte 2700 panelBox.Add(wx.StaticText(panel, -1, text), 0, wx.ALIGN_LEFT|wx.ALL, 4)
54 jonathan 2551
55 dpinte 2700 rasterBox = wx.StaticBoxSizer(wx.StaticBox(panel, -1,
56     _("Image Properties")), wx.VERTICAL)
57 jonathan 2551
58    
59     rasterBox.Add(
60 dpinte 2700 wx.StaticText(panel, -1,
61 jonathan 2551 _("Source: %s") % self.layer.GetImageFilename()),
62 dpinte 2700 0, wx.ALIGN_LEFT | wx.ALL, 4)
63 jonathan 2551
64 dpinte 2700 infoBox = wx.BoxSizer(wx.HORIZONTAL)
65 jonathan 2551
66     nBands = info["nBands"]
67    
68     self.usePalIndex = nBands == 1
69 dpinte 2700
70 jonathan 2551 infoBox.Add(
71 dpinte 2700 wx.StaticText(panel, -1, _("Driver: %s") % info["Driver"]),
72     0, wx.ALIGN_LEFT | wx.RIGHT, 10)
73 jonathan 2551 infoBox.Add(
74 dpinte 2700 wx.StaticText(panel, -1, _("Size: %ix%i") % info["Size"]),
75     0, wx.ALIGN_LEFT | wx.RIGHT, 10)
76 jonathan 2551 infoBox.Add(
77 dpinte 2700 wx.StaticText(panel, -1, _("Number of Bands: %i") % nBands),
78     0, wx.ALIGN_LEFT | wx.RIGHT, 0)
79 jonathan 2551
80 dpinte 2700 rasterBox.Add(infoBox, 0, wx.ALIGN_LEFT|wx.ALL, 4)
81 jonathan 2551
82     # Mask
83    
84 dpinte 2700 maskBox = wx.BoxSizer(wx.HORIZONTAL)
85 jonathan 2551
86 jonathan 2562 if versions['wxPython-tuple'] < (2,5,3):
87 dpinte 2700 choices = ["None", "Bitmap",
88 jonathan 2562 "Alpha (Not support by wxPython %s)" % \
89     versions['wxPython']]
90     else:
91     choices = ["None", "Bitmap", "Alpha"]
92 jonathan 2551
93 dpinte 2700 self.maskRadioBox = wx.RadioBox(panel, ID_RB_MASK, _("Mask Type"),
94 jonathan 2562 choices=choices)
95     #self.maskCB = wxCheckBox(panel, -1, _("Use Mask"))
96 dpinte 2700 maskBox.Add(self.maskRadioBox, 0, wx.RIGHT, 10)
97 jonathan 2562
98 dpinte 2700 self.opBox = wx.BoxSizer(wx.HORIZONTAL)
99     self.opSpinLabel = wx.StaticText(panel, -1, _("Opacity:"))
100     self.opBox.Add(self.opSpinLabel, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 4)
101     self.opSpin = wx.SpinCtrl(panel, -1,
102 jonathan 2587 str(self.layer.Opacity()*255),
103     initial = self.layer.Opacity()*255,
104     min=0, max=255)
105 dpinte 2700 self.opBox.Add(self.opSpin, 0, wx.ALL, 4)
106     maskBox.Add(self.opBox, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
107 jonathan 2587
108 dpinte 2700 rasterBox.Add(maskBox, 0, wx.ALL, 4)
109 jonathan 2587 #rasterBox.Add(opBox, 0, wxALL, 4)
110    
111 dpinte 2700 panelBox.Add(rasterBox, 1, wx.GROW | wx.ALL, 4)
112 jonathan 2551
113 jonathan 2562 self.maskRadioBox.SetSelection(self.old_state["mask_type"])
114 jonathan 2551
115 jonathan 2587 self.OnMaskSelect(None)
116    
117 dpinte 2700 self.Bind(wx.EVT_RADIOBOX, self.OnMaskSelect, id=ID_RB_MASK)
118 jonathan 2587
119 jonathan 2551 def OnTry(self, event):
120     self.set_state()
121    
122     def OnOK(self, event):
123 dpinte 2700 if self.set_state():
124 jonathan 2551 self.Close()
125    
126     def OnRevert(self, event):
127 jonathan 2562 self.maskRadioBox.SetSelection(self.old_state["mask_type"])
128 jonathan 2551 self.set_state()
129    
130 jonathan 2587 def OnMaskSelect(self, event):
131     allowOpacity = self.maskRadioBox.GetSelection()==2
132     self.opSpin.Enable(allowOpacity)
133     self.opSpinLabel.Enable(allowOpacity)
134    
135 jonathan 2551 def set_state(self):
136 jonathan 2562 self.layer.SetMaskType(self.maskRadioBox.GetSelection())
137 jonathan 2587 self.layer.SetOpacity(self.opSpin.GetValue()/255.0)
138 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