16 |
|
|
17 |
from Thuban import _ |
from Thuban import _ |
18 |
|
|
19 |
|
from Thuban.Model.classification import Classification |
20 |
|
|
21 |
|
from Thuban.Model.layer import SHAPETYPE_ARC, SHAPETYPE_POLYGON, SHAPETYPE_POINT |
22 |
|
|
23 |
ID_PROPERTY_SELECT = 4010 |
ID_PROPERTY_SELECT = 4010 |
24 |
ID_CLASS_TABLE = 40011 |
ID_CLASS_TABLE = 40011 |
25 |
|
|
30 |
|
|
31 |
def __init__(self, clinfo): |
def __init__(self, clinfo): |
32 |
wxPyGridTableBase.__init__(self) |
wxPyGridTableBase.__init__(self) |
|
self.clinfo = copy.deepcopy(clinfo) |
|
33 |
|
|
34 |
self.tdata = [] |
self.tdata = [] |
35 |
|
|
36 |
for value, data in self.clinfo.points.items(): |
self.tdata.append([clinfo.DefaultData, 'DEFAULT']) |
37 |
|
|
38 |
|
for value, data in clinfo.points.items(): |
39 |
self.tdata.append([data, value]) |
self.tdata.append([data, value]) |
40 |
|
|
41 |
for range in self.clinfo.ranges: |
for range in self.clinfo.ranges: |
42 |
self.tdata.append([range[2], '%s-%s' % range[0], range[1]]) |
self.tdata.append([range[2], '%s-%s' % range[0], range[1]]) |
43 |
|
|
44 |
self.SetColLabelValue(1, "Data Values") |
self.SetColLabelValue(1, _("Data Values")) |
45 |
|
|
46 |
def GetNumberRows(self): |
def GetNumberRows(self): |
47 |
return len(self.tdata) |
return len(self.tdata) |
56 |
return self.tdata[row][col] |
return self.tdata[row][col] |
57 |
|
|
58 |
def SetValue(self, row, col, value): |
def SetValue(self, row, col, value): |
59 |
pass |
self.tdata[row][col] = value |
60 |
|
|
61 |
|
def GetValueAsCustom(self, row, col, typeName): |
62 |
|
return self.tdata[row][col] |
63 |
|
|
64 |
|
|
65 |
class Classifier(wxDialog): |
class Classifier(wxDialog): |
86 |
self.properties.Append(name) |
self.properties.Append(name) |
87 |
|
|
88 |
self.properties.SetSelection(cur_hilight) |
self.properties.SetSelection(cur_hilight) |
89 |
propertyBox.Add(self.properties, 0, wxGROW, 4) |
propertyBox.Add(self.properties, 1, wxGROW, 4) |
90 |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self.OnPropertySelect) |
EVT_COMBOBOX(self, ID_PROPERTY_SELECT, self.OnPropertySelect) |
91 |
|
|
92 |
topBox.Add(propertyBox, 0, wxGROW, 4) |
topBox.Add(propertyBox, 0, wxGROW, 4) |
99 |
|
|
100 |
table = ClassTable(layer.classification) |
table = ClassTable(layer.classification) |
101 |
self.classTable.SetTable(table, true) |
self.classTable.SetTable(table, true) |
102 |
<<<<<<< classifier.py |
self.classTable.EnableEditing(false) |
103 |
|
cr = ClassRenderer(layer.ShapeType()) |
104 |
|
for i in range(self.classTable.GetNumberRows()): |
105 |
|
self.classTable.SetCellRenderer(i, 0, cr) |
106 |
|
|
107 |
topBox.Add(self.classTable, 0, wxGROW, 0) |
topBox.Add(self.classTable, 1, wxGROW, 0) |
|
======= |
|
|
#table.SetNumberRows(10) |
|
|
#table.SetNumberCols(2) |
|
|
table.SetColLabelValue(0, _("Class")) |
|
|
table.SetColLabelValue(1, _("Value")) |
|
|
#self.classTable.SetColLabelValue(0, _("Class")) |
|
|
#self.classTable.SetColLabelValue(1, _("Value")) |
|
|
#self.classTable.SetCellValue(1, 1, _("Value")) |
|
|
|
|
|
tableBox.Add(self.classTable, 0, wxALL, 4) |
|
|
|
|
|
topBox.Add(self.classTable, 0, 0) |
|
|
>>>>>>> 1.2 |
|
108 |
|
|
109 |
# |
# |
110 |
# Control buttons: |
# Control buttons: |
132 |
def OnCancel(self, event): |
def OnCancel(self, event): |
133 |
self.EndModal(wxID_CANCEL) |
self.EndModal(wxID_CANCEL) |
134 |
|
|
135 |
|
|
136 |
|
class ClassRenderer(wxPyGridCellRenderer): |
137 |
|
|
138 |
|
def __init__(self, shapeType): |
139 |
|
wxPyGridCellRenderer.__init__(self) |
140 |
|
self.shapeType = shapeType |
141 |
|
|
142 |
|
def Draw(self, grid, attr, dc, rect, row, col, isSelected): |
143 |
|
value = grid.GetTable().GetValueAsCustom(row, col, "") |
144 |
|
# XXX: check if value is a dictionary |
145 |
|
stroke = value.GetStroke() |
146 |
|
if stroke is None: |
147 |
|
pen = wxTRANSPARENT_PEN |
148 |
|
else: |
149 |
|
pen = wxPen(wxColour(stroke.red * 255, |
150 |
|
stroke.green * 255, |
151 |
|
stroke.blue * 255), |
152 |
|
value.GetStrokeWidth(), |
153 |
|
wxSOLID) |
154 |
|
|
155 |
|
stroke = value.GetFill() |
156 |
|
if stroke is None: |
157 |
|
brush = wxTRANSPARENT_BRUSH |
158 |
|
else: |
159 |
|
brush = wxBrush(wxColour(stroke.red * 255, |
160 |
|
stroke.green * 255, |
161 |
|
stroke.blue * 255), wxSOLID) |
162 |
|
|
163 |
|
dc.SetClippingRegion(rect.GetX(), rect.GetY(), |
164 |
|
rect.GetWidth(), rect.GetHeight()) |
165 |
|
dc.SetPen(wxPen(wxLIGHT_GREY)) |
166 |
|
dc.SetBrush(wxBrush(wxLIGHT_GREY, wxSOLID)) |
167 |
|
dc.DrawRectangle(rect.GetX(), rect.GetY(), |
168 |
|
rect.GetWidth(), rect.GetHeight()) |
169 |
|
|
170 |
|
dc.SetPen(pen) |
171 |
|
dc.SetBrush(brush) |
172 |
|
|
173 |
|
if self.shapeType == SHAPETYPE_ARC: |
174 |
|
dc.DrawSpline([wxPoint(rect.GetX(), rect.GetY() + rect.GetHeight()), |
175 |
|
wxPoint(rect.GetX() + rect.GetWidth()/2, |
176 |
|
rect.GetY() + rect.GetHeight()/4), |
177 |
|
wxPoint(rect.GetX() + rect.GetWidth()/2, |
178 |
|
rect.GetY() + rect.GetHeight()/4*3), |
179 |
|
wxPoint(rect.GetX() + rect.GetWidth(), rect.GetY())]) |
180 |
|
|
181 |
|
elif self.shapeType == SHAPETYPE_POINT or self.shapeType == SHAPETYPE_POLYGON: |
182 |
|
dc.DrawCircle(rect.GetX() + rect.GetWidth()/2, |
183 |
|
rect.GetY() + rect.GetHeight()/2, |
184 |
|
(min(rect.GetWidth(), rect.GetHeight()) |
185 |
|
- value.GetStrokeWidth())/2) |
186 |
|
|
187 |
|
dc.DestroyClippingRegion() |
188 |
|
|
189 |
|
|