5 |
# This program is free software under the GPL (>=v2) |
# This program is free software under the GPL (>=v2) |
6 |
# Read the file COPYING coming with Thuban for details. |
# Read the file COPYING coming with Thuban for details. |
7 |
|
|
8 |
import sys |
"""The Classification Generator Dialog""" |
9 |
|
|
10 |
from Thuban import _ |
__version__ = "$Revision$" |
11 |
|
# $Source$ |
12 |
|
# $Id$ |
13 |
|
|
14 |
|
|
15 |
|
import sys |
16 |
|
|
17 |
from wxPython.wx import * |
from wxPython.wx import * |
18 |
|
|
19 |
|
from Thuban import _ |
20 |
|
|
21 |
from Thuban.Model.classification import ClassGroupProperties |
from Thuban.Model.classification import ClassGroupProperties |
22 |
|
|
23 |
from Thuban.Model.table import FIELDTYPE_INT, FIELDTYPE_DOUBLE, \ |
from Thuban.Model.table import FIELDTYPE_INT, FIELDTYPE_DOUBLE, \ |
31 |
|
|
32 |
from Thuban.Model.classgen import \ |
from Thuban.Model.classgen import \ |
33 |
generate_uniform_distribution, generate_singletons, generate_quantiles, \ |
generate_uniform_distribution, generate_singletons, generate_quantiles, \ |
34 |
CustomRamp, GreyRamp, RedRamp, GreenRamp, BlueRamp, GreenToRedRamp, \ |
CustomRamp, grey_ramp, red_ramp, green_ramp, blue_ramp, green_to_red_ramp, \ |
35 |
HotToColdRamp |
HotToColdRamp, FixedRamp |
36 |
|
|
37 |
|
|
38 |
USEALL_BMP = "group_use_all" |
USEALL_BMP = "group_use_all" |
143 |
self.propPanel = None |
self.propPanel = None |
144 |
custom_ramp_panel = CustomRampPanel(self, layer.ShapeType()) |
custom_ramp_panel = CustomRampPanel(self, layer.ShapeType()) |
145 |
|
|
146 |
self.propCombo.Append(PROPCOMBOSTR_GREY, GreyRamp) |
self.propCombo.Append(PROPCOMBOSTR_GREY, grey_ramp) |
147 |
self.propCombo.Append(PROPCOMBOSTR_RED, RedRamp) |
self.propCombo.Append(PROPCOMBOSTR_RED, red_ramp) |
148 |
self.propCombo.Append(PROPCOMBOSTR_GREEN, GreenRamp) |
self.propCombo.Append(PROPCOMBOSTR_GREEN, green_ramp) |
149 |
self.propCombo.Append(PROPCOMBOSTR_BLUE, BlueRamp) |
self.propCombo.Append(PROPCOMBOSTR_BLUE, blue_ramp) |
150 |
self.propCombo.Append(PROPCOMBOSTR_GREEN2RED, GreenToRedRamp) |
self.propCombo.Append(PROPCOMBOSTR_GREEN2RED, green_to_red_ramp) |
151 |
self.propCombo.Append(PROPCOMBOSTR_HOT2COLD, HotToColdRamp()) |
self.propCombo.Append(PROPCOMBOSTR_HOT2COLD, HotToColdRamp()) |
152 |
self.propCombo.Append(PROPCOMBOSTR_CUSTOM, custom_ramp_panel) |
self.propCombo.Append(PROPCOMBOSTR_CUSTOM, custom_ramp_panel) |
153 |
|
|
232 |
ramp = propPanel.GetRamp() |
ramp = propPanel.GetRamp() |
233 |
if self.border_color and self.fix_border_check.IsChecked(): |
if self.border_color and self.fix_border_check.IsChecked(): |
234 |
props = self.border_color.GetProperties() |
props = self.border_color.GetProperties() |
235 |
lineColor = props.GetLineColor() |
ramp = FixedRamp(ramp, |
236 |
lineWidth = props.GetLineWidth() |
(props.GetLineColor(), props.GetLineWidth(), None)) |
|
else: |
|
|
lineColor = None |
|
|
lineWidth = None |
|
237 |
|
|
238 |
if genSel == GENCOMBOSTR_UNIFORM: |
if genSel == GENCOMBOSTR_UNIFORM: |
239 |
|
|
246 |
|
|
247 |
self.clazz = generate_uniform_distribution( |
self.clazz = generate_uniform_distribution( |
248 |
min, max, numGroups, ramp, |
min, max, numGroups, ramp, |
249 |
self.type == FIELDTYPE_INT, |
self.type == FIELDTYPE_INT) |
|
fixes = (lineColor, lineWidth, None)) |
|
250 |
|
|
251 |
self.parent._SetClassification(self.clazz) |
self.parent._SetClassification(self.clazz) |
252 |
|
|
255 |
list = genPanel.GetValueList() |
list = genPanel.GetValueList() |
256 |
|
|
257 |
if len(list) > 0: |
if len(list) > 0: |
258 |
self.clazz = generate_singletons(list, ramp, |
self.clazz = generate_singletons(list, ramp) |
|
(lineColor, lineWidth, None)) |
|
259 |
self.parent._SetClassification(self.clazz) |
self.parent._SetClassification(self.clazz) |
260 |
|
|
261 |
elif genSel == GENCOMBOSTR_QUANTILES: |
elif genSel == GENCOMBOSTR_QUANTILES: |
267 |
delta = 1 / float(numGroups) |
delta = 1 / float(numGroups) |
268 |
percents = [delta * i for i in range(1, numGroups + 1)] |
percents = [delta * i for i in range(1, numGroups + 1)] |
269 |
adjusted, self.clazz = \ |
adjusted, self.clazz = \ |
270 |
generate_quantiles(_list, percents, ramp, _range, |
generate_quantiles(_list, percents, ramp, _range) |
|
(lineColor, lineWidth, None)) |
|
271 |
|
|
272 |
if adjusted: |
if adjusted: |
273 |
dlg = wxMessageDialog(self, |
dlg = wxMessageDialog(self, |
274 |
_("Based on the data from the table and the input\n" + |
_("Based on the data from the table and the input\n" |
275 |
"values, the exact quantiles could not be generated.\n\n" + |
"values, the exact quantiles could not be generated.\n\n" |
276 |
"Accept a close estimate?"), |
"Accept a close estimate?"), |
277 |
_("Problem with Quantiles"), |
_("Problem with Quantiles"), |
278 |
|
|