56 |
self.fieldType = None |
self.fieldType = None |
57 |
self.__groups = [] |
self.__groups = [] |
58 |
|
|
|
self.__setLayerLock = False |
|
|
|
|
59 |
self.SetDefaultGroup(ClassGroupDefault()) |
self.SetDefaultGroup(ClassGroupDefault()) |
60 |
|
|
61 |
self.SetFieldInfo(field, None) |
self.SetFieldInfo(field, None) |
659 |
"""A Group that represents a range of values that map to the same |
"""A Group that represents a range of values that map to the same |
660 |
set of properties.""" |
set of properties.""" |
661 |
|
|
662 |
def __init__(self, min = 0, max = 1, props = None, label = "", group=None): |
def __init__(self, _range = (0,1), props = None, label = "", group=None): |
663 |
"""Constructor. |
"""Constructor. |
664 |
|
|
665 |
The minumum value must be strictly less than the maximum. |
The minumum value must be strictly less than the maximum. |
666 |
|
|
667 |
min -- the minimum range value |
_range -- either a tuple (min, max) where min < max or |
668 |
|
a Range object |
|
max -- the maximum range value |
|
669 |
|
|
670 |
prop -- a ClassGroupProperites object. If prop is None a default |
prop -- a ClassGroupProperites object. If prop is None a default |
671 |
set of properties is created. |
set of properties is created. |
678 |
#self.__min = self.__max = 0 |
#self.__min = self.__max = 0 |
679 |
#self.__range = Range("[" + repr(float(min)) + ";" + |
#self.__range = Range("[" + repr(float(min)) + ";" + |
680 |
#repr(float(max)) + "[") |
#repr(float(max)) + "[") |
681 |
self.SetRange(min, max) |
self.SetRange(_range) |
682 |
|
|
683 |
def __copy__(self): |
def __copy__(self): |
684 |
return ClassGroupRange(min = self.__range, |
return ClassGroupRange(self.__range, |
|
max = None, |
|
685 |
props = self.GetProperties(), |
props = self.GetProperties(), |
686 |
label = self.GetLabel()) |
label = self.GetLabel()) |
687 |
|
|
688 |
def __deepcopy__(self, memo): |
def __deepcopy__(self, memo): |
689 |
return ClassGroupRange(min = copy.copy(self.__range), |
return ClassGroupRange(copy.copy(self.__range), |
|
max = copy.copy(self.GetMax()), |
|
690 |
group = self) |
group = self) |
691 |
|
|
692 |
def GetMin(self): |
def GetMin(self): |
700 |
maximum value. Use SetRange() to change both min and max values. |
maximum value. Use SetRange() to change both min and max values. |
701 |
""" |
""" |
702 |
|
|
703 |
self.SetRange(min, self.__range.GetRange()[2]) |
self.SetRange((min, self.__range.GetRange()[2])) |
704 |
|
|
705 |
def GetMax(self): |
def GetMax(self): |
706 |
"""Return the range's maximum value.""" |
"""Return the range's maximum value.""" |
712 |
max -- the new maximum. Note that this must be greater than the current |
max -- the new maximum. Note that this must be greater than the current |
713 |
minimum value. Use SetRange() to change both min and max values. |
minimum value. Use SetRange() to change both min and max values. |
714 |
""" |
""" |
715 |
self.SetRange(self.__range.GetRange()[1], max) |
self.SetRange((self.__range.GetRange()[1], max)) |
716 |
|
|
717 |
def SetRange(self, min, max = None): |
def SetRange(self, _range): |
718 |
"""Set a new range. |
"""Set a new range. |
719 |
|
|
720 |
Note that min must be strictly less than max. |
_range -- Either a tuple (min, max) where min < max or |
721 |
|
a Range object. |
722 |
|
|
723 |
min -- the new minimum value |
Raises ValueError on error. |
|
min -- the new maximum value |
|
724 |
""" |
""" |
725 |
|
|
726 |
if isinstance(min, Range): |
if isinstance(_range, Range): |
727 |
self.__range = min |
self.__range = _range |
728 |
|
elif isinstance(_range, types.TupleType) and len(_range) == 2: |
729 |
|
self.__range = Range(("[", _range[0], _range[1], "[")) |
730 |
else: |
else: |
731 |
if max is None: |
raise ValueError() |
|
raise ValueError() |
|
|
|
|
|
self.__range = Range(("[", min, max, "[")) |
|
732 |
|
|
733 |
def GetRange(self): |
def GetRange(self): |
734 |
"""Return the range as a string""" |
"""Return the range as a string""" |