28 |
from Thuban.Model.color import Color |
from Thuban.Model.color import Color |
29 |
from Thuban.Model.proj import Projection |
from Thuban.Model.proj import Projection |
30 |
from Thuban.Model.classification import Classification, \ |
from Thuban.Model.classification import Classification, \ |
31 |
ClassDataDefault, ClassDataPoint, ClassDataRange, ClassDataMap |
ClassGroupDefault, ClassGroupSingleton, ClassGroupRange, ClassGroupMap, \ |
32 |
|
ClassGroupProperties |
33 |
|
|
34 |
|
|
35 |
def parse_color(color): |
def parse_color(color): |
168 |
end_dispatcher['classification'] = "end_classification" |
end_dispatcher['classification'] = "end_classification" |
169 |
|
|
170 |
def start_clnull(self, name, qname, attrs): |
def start_clnull(self, name, qname, attrs): |
171 |
self.cl_data = ClassDataDefault() |
self.cl_group = ClassGroupDefault() |
172 |
self.cl_data.SetLabel(attrs.get((None, 'label'), "")) |
self.cl_group.SetLabel(attrs.get((None, 'label'), "")) |
173 |
|
self.cl_prop = ClassGroupProperties() |
174 |
start_dispatcher['clnull'] = "start_clnull" |
start_dispatcher['clnull'] = "start_clnull" |
175 |
|
|
176 |
def end_clnull(self, name, qname): |
def end_clnull(self, name, qname): |
177 |
self.aLayer.GetClassification().SetDefaultData(self.cl_data) |
self.cl_group.SetProperties(self.cl_prop) |
178 |
del self.cl_data |
self.aLayer.GetClassification().SetDefaultGroup(self.cl_group) |
179 |
|
del self.cl_group, self.cl_prop |
180 |
end_dispatcher['clnull'] = "end_clnull" |
end_dispatcher['clnull'] = "end_clnull" |
181 |
|
|
182 |
def start_clpoint(self, name, qname, attrs): |
def start_clpoint(self, name, qname, attrs): |
187 |
except: |
except: |
188 |
value = attrib_value |
value = attrib_value |
189 |
|
|
190 |
self.cl_data = ClassDataPoint(value) |
self.cl_group = ClassGroupSingleton(value) |
191 |
self.cl_data.SetLabel(attrs.get((None, 'label'), "")) |
self.cl_group.SetLabel(attrs.get((None, 'label'), "")) |
192 |
|
self.cl_prop = ClassGroupProperties() |
193 |
|
|
194 |
start_dispatcher['clpoint'] = "start_clpoint" |
start_dispatcher['clpoint'] = "start_clpoint" |
195 |
|
|
196 |
def end_clpoint(self, name, qname): |
def end_clpoint(self, name, qname): |
197 |
self.aLayer.GetClassification().AddClassData(self.cl_data) |
self.cl_group.SetProperties(self.cl_prop) |
198 |
del self.cl_data |
self.aLayer.GetClassification().AddGroup(self.cl_group) |
199 |
|
del self.cl_group, self.cl_prop |
200 |
end_dispatcher['clpoint'] = "end_clpoint" |
end_dispatcher['clpoint'] = "end_clpoint" |
201 |
|
|
202 |
def start_clrange(self, name, qname, attrs): |
def start_clrange(self, name, qname, attrs): |
207 |
except ValueError: |
except ValueError: |
208 |
raise ValueError(_("Classification range is not a number!")) |
raise ValueError(_("Classification range is not a number!")) |
209 |
|
|
210 |
self.cl_data = ClassDataRange(min, max) |
self.cl_group = ClassGroupRange(min, max) |
211 |
self.cl_data.SetLabel(attrs.get((None, 'label'), "")) |
self.cl_group.SetLabel(attrs.get((None, 'label'), "")) |
212 |
|
self.cl_prop = ClassGroupProperties() |
213 |
|
|
214 |
start_dispatcher['clrange'] = "start_clrange" |
start_dispatcher['clrange'] = "start_clrange" |
215 |
|
|
216 |
def end_clrange(self, name, qname): |
def end_clrange(self, name, qname): |
217 |
self.aLayer.GetClassification().AddClassData(self.cl_data) |
self.cl_group.SetProperties(self.cl_prop) |
218 |
del self.cl_data |
self.aLayer.GetClassification().AddGroup(self.cl_group) |
219 |
|
del self.cl_group, self.cl_prop |
220 |
end_dispatcher['clrange'] = "end_clrange" |
end_dispatcher['clrange'] = "end_clrange" |
221 |
|
|
222 |
def start_cldata(self, name, qname, attrs): |
def start_cldata(self, name, qname, attrs): |
223 |
self.cl_data.SetStroke(parse_color(attrs.get((None, 'stroke'), "None"))) |
self.cl_prop.SetStroke(parse_color(attrs.get((None, 'stroke'), "None"))) |
224 |
self.cl_data.SetStrokeWidth( |
self.cl_prop.SetStrokeWidth( |
225 |
int(attrs.get((None, 'stroke_width'), "0"))) |
int(attrs.get((None, 'stroke_width'), "0"))) |
226 |
self.cl_data.SetFill(parse_color(attrs.get((None, 'fill'), "None"))) |
self.cl_prop.SetFill(parse_color(attrs.get((None, 'fill'), "None"))) |
227 |
start_dispatcher['cldata'] = "start_cldata" |
start_dispatcher['cldata'] = "start_cldata" |
228 |
|
|
229 |
def end_cldata(self, name, qname): |
def end_cldata(self, name, qname): |