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 |
|
|
class RasterLayerProperties(LayerProperties): |
21 |
|
|
|
22 |
|
|
def __init__(self, parent, name, layer, *args, **kw): |
23 |
|
|
LayerProperties.__init__(self, parent, name, layer) |
24 |
|
|
|
25 |
|
|
self.old_state = {} |
26 |
|
|
self.old_state["use_mask"] = layer.UseMask() |
27 |
|
|
|
28 |
|
|
LayerProperties.dialog_layout(self) |
29 |
|
|
|
30 |
|
|
def dialog_layout(self, panel, panelBox): |
31 |
|
|
|
32 |
|
|
info = self.layer.ImageInfo() |
33 |
|
|
|
34 |
|
|
if info is None: |
35 |
|
|
panelBox.Add( |
36 |
|
|
wxStaticText(panel, -1, |
37 |
|
|
_("GDAL image information unavailable. See About box for details.")), |
38 |
|
|
0, wxALIGN_LEFT | wxALL, 4) |
39 |
|
|
return |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
# Bounding Box |
43 |
|
|
bbox = self.layer.LatLongBoundingBox() |
44 |
|
|
if bbox is None: |
45 |
|
|
text = _("Extent (lat-lon): None") |
46 |
|
|
else: |
47 |
|
|
text = _("Extent (lat-lon): (%g, %g, %g, %g)") % tuple(bbox) |
48 |
|
|
|
49 |
|
|
panelBox.Add(wxStaticText(panel, -1, text), 0, wxALIGN_LEFT|wxALL, 4) |
50 |
|
|
|
51 |
|
|
rasterBox = wxStaticBoxSizer(wxStaticBox(panel, -1, |
52 |
|
|
_("Image Properties")), wxVERTICAL) |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
rasterBox.Add( |
56 |
|
|
wxStaticText(panel, -1, |
57 |
|
|
_("Source: %s") % self.layer.GetImageFilename()), |
58 |
|
|
0, wxALIGN_LEFT | wxALL, 4) |
59 |
|
|
|
60 |
|
|
infoBox = wxBoxSizer(wxHORIZONTAL) |
61 |
|
|
|
62 |
|
|
nBands = info["nBands"] |
63 |
|
|
|
64 |
|
|
self.usePalIndex = nBands == 1 |
65 |
|
|
|
66 |
|
|
infoBox.Add( |
67 |
|
|
wxStaticText(panel, -1, _("Driver: %s") % info["Driver"]), |
68 |
|
|
0, wxALIGN_LEFT | wxRIGHT, 10) |
69 |
|
|
infoBox.Add( |
70 |
|
|
wxStaticText(panel, -1, _("Size: %ix%i") % info["Size"]), |
71 |
|
|
0, wxALIGN_LEFT | wxRIGHT, 10) |
72 |
|
|
infoBox.Add( |
73 |
|
|
wxStaticText(panel, -1, _("Number of Bands: %i") % nBands), |
74 |
|
|
0, wxALIGN_LEFT | wxRIGHT, 0) |
75 |
|
|
|
76 |
|
|
rasterBox.Add(infoBox, 0, wxALIGN_LEFT|wxALL, 4) |
77 |
|
|
|
78 |
|
|
# Mask |
79 |
|
|
|
80 |
|
|
maskBox = wxBoxSizer(wxHORIZONTAL) |
81 |
|
|
|
82 |
|
|
self.maskCB = wxCheckBox(panel, -1, _("Use Mask")) |
83 |
|
|
maskBox.Add(self.maskCB, 0, wxRIGHT, 10) |
84 |
|
|
|
85 |
|
|
rasterBox.Add(maskBox, 0, wxALL, 4) |
86 |
|
|
panelBox.Add(rasterBox, 1, wxGROW | wxALL, 4) |
87 |
|
|
|
88 |
|
|
self.maskCB.SetValue(self.old_state["use_mask"]) |
89 |
|
|
|
90 |
|
|
def OnTry(self, event): |
91 |
|
|
self.set_state() |
92 |
|
|
|
93 |
|
|
def OnOK(self, event): |
94 |
|
|
if self.set_state(): |
95 |
|
|
self.Close() |
96 |
|
|
|
97 |
|
|
def OnRevert(self, event): |
98 |
|
|
self.maskCB.SetValue(self.old_state["use_mask"]) |
99 |
|
|
self.set_state() |
100 |
|
|
|
101 |
|
|
def set_state(self): |
102 |
|
|
self.layer.SetUseMask(self.maskCB.GetValue() == 1) |
103 |
|
|
return True |