17 |
FIELDTYPE_STRING |
FIELDTYPE_STRING |
18 |
|
|
19 |
from Thuban.Model.range import Range |
from Thuban.Model.range import Range |
20 |
|
from Thuban.UI.common import ThubanBeginBusyCursor, ThubanEndBusyCursor |
21 |
|
|
22 |
import classifier, resource |
import classifier, resource |
23 |
|
|
24 |
from Thuban.Model.classgen import \ |
from Thuban.Model.classgen import \ |
25 |
GenUniformDistribution, GenSingletonsFromList, GenQuantiles, \ |
generate_uniform_distribution, generate_singletons, generate_quantiles, \ |
26 |
CustomRamp, GreyRamp, RedRamp, GreenRamp, BlueRamp, GreenToRedRamp, \ |
CustomRamp, GreyRamp, RedRamp, GreenRamp, BlueRamp, GreenToRedRamp, \ |
27 |
HotToColdRamp |
HotToColdRamp |
28 |
|
|
61 |
self.layer = layer |
self.layer = layer |
62 |
self.clazz = None |
self.clazz = None |
63 |
|
|
64 |
col = layer.table.Column(fieldName) |
col = layer.ShapeStore().Table().Column(fieldName) |
65 |
self.type = col.type |
self.type = col.type |
66 |
|
|
67 |
self.fieldName = fieldName |
self.fieldName = fieldName |
212 |
and max is not None \ |
and max is not None \ |
213 |
and numGroups is not None: |
and numGroups is not None: |
214 |
|
|
215 |
self.clazz = GenUniformDistribution( |
self.clazz = generate_uniform_distribution( |
216 |
min, max, numGroups, ramp, |
min, max, numGroups, ramp, |
217 |
self.type == FIELDTYPE_INT) |
self.type == FIELDTYPE_INT) |
218 |
|
|
225 |
if len(list) > 0 \ |
if len(list) > 0 \ |
226 |
and numGroups is not None: |
and numGroups is not None: |
227 |
|
|
228 |
self.clazz = GenSingletonsFromList( |
self.clazz = generate_singletons( |
229 |
list, numGroups, ramp) |
list, numGroups, ramp) |
230 |
|
|
231 |
self.parent._SetClassification(self.clazz) |
self.parent._SetClassification(self.clazz) |
239 |
delta = 1 / float(numGroups) |
delta = 1 / float(numGroups) |
240 |
percents = [delta * i for i in range(1, numGroups + 1)] |
percents = [delta * i for i in range(1, numGroups + 1)] |
241 |
adjusted, self.clazz = \ |
adjusted, self.clazz = \ |
242 |
GenQuantiles(_list, percents, ramp, _range) |
generate_quantiles(_list, percents, ramp, _range) |
243 |
|
|
244 |
if adjusted: |
if adjusted: |
245 |
dlg = wxMessageDialog(self, |
dlg = wxMessageDialog(self, |
505 |
self.parent.AllowGenerate(False) |
self.parent.AllowGenerate(False) |
506 |
|
|
507 |
def _OnRetrieve(self, event): |
def _OnRetrieve(self, event): |
508 |
|
table = self.layer.ShapeStore().Table() |
509 |
if self.layer.table is not None: |
if table is not None: |
510 |
wxBeginBusyCursor() |
ThubanBeginBusyCursor() |
511 |
try: |
try: |
512 |
min, max = self.layer.table.ValueRange(self.fieldName) |
min, max = table.ValueRange(self.fieldName) |
513 |
self.minCtrl.SetValue(str(min)) |
self.minCtrl.SetValue(str(min)) |
514 |
self.maxCtrl.SetValue(str(max)) |
self.maxCtrl.SetValue(str(max)) |
515 |
finally: |
finally: |
516 |
wxEndBusyCursor() |
ThubanEndBusyCursor() |
517 |
|
|
518 |
def __GetValidatedTypeEntry(self, win, value, type, badValue = None): |
def __GetValidatedTypeEntry(self, win, value, type, badValue = None): |
519 |
|
|
555 |
return valid |
return valid |
556 |
|
|
557 |
def __CalcStepping(self, min, max, ngroups): |
def __CalcStepping(self, min, max, ngroups): |
|
step = (max - min) / float(ngroups) |
|
558 |
if self.fieldType == FIELDTYPE_INT: |
if self.fieldType == FIELDTYPE_INT: |
559 |
step = int(step) |
step = int((max - min + 1) / float(ngroups)) |
560 |
|
else: |
561 |
|
step = (max - min) / float(ngroups) |
562 |
|
|
563 |
return step |
return step |
564 |
|
|
721 |
self.list_avail.DeleteAllItems() |
self.list_avail.DeleteAllItems() |
722 |
self.list_avail_data = [] |
self.list_avail_data = [] |
723 |
|
|
724 |
list = self.layer.table.UniqueValues(self.fieldName) |
ThubanBeginBusyCursor() |
725 |
index = 0 |
try: |
726 |
for v in list: |
list = self.layer.ShapeStore().Table().UniqueValues(self.fieldName) |
727 |
self.dataList.append(v) |
index = 0 |
728 |
i = self.list_avail.InsertStringItem(index, str(v)) |
for v in list: |
729 |
self.list_avail.SetItemData(index, i) |
self.dataList.append(v) |
730 |
|
i = self.list_avail.InsertStringItem(index, str(v)) |
731 |
self.list_avail_data.append(v) |
self.list_avail.SetItemData(index, i) |
732 |
index += 1 |
|
733 |
|
self.list_avail_data.append(v) |
734 |
|
index += 1 |
735 |
|
finally: |
736 |
|
ThubanEndBusyCursor() |
737 |
|
|
738 |
def _OnUseAll(self, event): |
def _OnUseAll(self, event): |
739 |
for i in range(self.list_avail.GetItemCount()): |
for i in range(self.list_avail.GetItemCount()): |
837 |
return self.__range |
return self.__range |
838 |
|
|
839 |
def GetList(self): |
def GetList(self): |
|
|
|
840 |
_list = [] |
_list = [] |
841 |
|
table = self.layer.ShapeStore().Table() |
842 |
if self.layer.table is not None: |
if table is not None: |
843 |
|
ThubanBeginBusyCursor() |
844 |
try: |
try: |
|
wxBeginBusyCursor() |
|
|
|
|
845 |
# |
# |
846 |
# FIXME: Replace with a call to table when the method |
# FIXME: Replace with a call to table when the method |
847 |
# has been written to get all the values |
# has been written to get all the values |
848 |
# |
# |
|
table = self.layer.table |
|
849 |
for i in range(table.NumRows()): |
for i in range(table.NumRows()): |
850 |
_list.append(table.ReadValue(i, self.fieldName)) |
_list.append(table.ReadValue(i, self.fieldName)) |
851 |
finally: |
finally: |
852 |
wxEndBusyCursor() |
ThubanEndBusyCursor() |
853 |
|
|
854 |
return _list |
return _list |
855 |
|
|
866 |
self.text_range.SetForegroundColour(wxRED) |
self.text_range.SetForegroundColour(wxRED) |
867 |
|
|
868 |
def OnRetrieve(self, event): |
def OnRetrieve(self, event): |
869 |
|
table = self.layer.ShapeStore().Table() |
870 |
if self.layer.table is not None: |
if table is not None: |
871 |
wxBeginBusyCursor() |
ThubanBeginBusyCursor() |
872 |
try: |
try: |
873 |
min, max = self.layer.table.ValueRange(self.fieldName) |
min, max = table.ValueRange(self.fieldName) |
874 |
self.text_range.SetValue("[" + str(min) + ";" + str(max) + "]") |
self.text_range.SetValue("[" + str(min) + ";" + str(max) + "]") |
875 |
finally: |
finally: |
876 |
wxEndBusyCursor() |
ThubanEndBusyCursor() |
877 |
|
|
878 |
ID_CUSTOMRAMP_COPYSTART = 4001 |
ID_CUSTOMRAMP_COPYSTART = 4001 |
879 |
ID_CUSTOMRAMP_COPYEND = 4002 |
ID_CUSTOMRAMP_COPYEND = 4002 |