14 |
|
|
15 |
from wxPython.wx import * |
from wxPython.wx import * |
16 |
|
|
17 |
from Thuban.Model.layer import Layer |
from Thuban.Model.layer import BaseLayer |
18 |
from Thuban.Model.map import Map |
from Thuban.Model.map import Map |
19 |
from Thuban.Model.classification import ClassGroup |
from Thuban.Model.classification import ClassGroup |
20 |
|
|
30 |
|
|
31 |
from Thuban.Lib.connector import ConnectorError |
from Thuban.Lib.connector import ConnectorError |
32 |
|
|
33 |
ID_LEGEND_RAISE = 4001 |
ID_LEGEND_TOP = 4001 |
34 |
ID_LEGEND_LOWER = 4002 |
ID_LEGEND_RAISE = 4002 |
35 |
ID_LEGEND_TREE = 4003 |
ID_LEGEND_LOWER = 4003 |
36 |
ID_LEGEND_PROPS = 4004 |
ID_LEGEND_BOTTOM = 4004 |
37 |
ID_LEGEND_SHOWLAYER = 4005 |
ID_LEGEND_TREE = 4005 |
38 |
ID_LEGEND_HIDELAYER = 4006 |
ID_LEGEND_PROPS = 4006 |
39 |
|
ID_LEGEND_SHOWLAYER = 4007 |
40 |
|
ID_LEGEND_HIDELAYER = 4008 |
41 |
|
|
42 |
BMP_SIZE_W = 30 |
BMP_SIZE_W = 30 |
43 |
BMP_SIZE_H = 15 |
BMP_SIZE_H = 15 |
44 |
|
|
45 |
|
TOP_BMP = "top_layer" |
46 |
RAISE_BMP = "raise_layer" |
RAISE_BMP = "raise_layer" |
47 |
LOWER_BMP = "lower_layer" |
LOWER_BMP = "lower_layer" |
48 |
|
BOTTOM_BMP = "bottom_layer" |
49 |
SHOW_BMP = "show_layer" |
SHOW_BMP = "show_layer" |
50 |
HIDE_BMP = "hide_layer" |
HIDE_BMP = "hide_layer" |
51 |
PROPS_BMP = "layer_properties" |
PROPS_BMP = "layer_properties" |
66 |
self.toolBar = wxToolBar(self, -1) |
self.toolBar = wxToolBar(self, -1) |
67 |
self.toolBar.SetToolBitmapSize(wxSize(24, 24)) |
self.toolBar.SetToolBitmapSize(wxSize(24, 24)) |
68 |
|
|
69 |
|
bmp = resource.GetBitmapResource(TOP_BMP, wxBITMAP_TYPE_XPM) |
70 |
|
self.toolBar.AddTool(ID_LEGEND_TOP, bmp, |
71 |
|
shortHelpString=_("Top Layer")) |
72 |
|
|
73 |
bmp = resource.GetBitmapResource(RAISE_BMP, wxBITMAP_TYPE_XPM) |
bmp = resource.GetBitmapResource(RAISE_BMP, wxBITMAP_TYPE_XPM) |
74 |
self.toolBar.AddTool(ID_LEGEND_RAISE, bmp, |
self.toolBar.AddTool(ID_LEGEND_RAISE, bmp, |
75 |
shortHelpString=_("Raise Layer")) |
shortHelpString=_("Raise Layer")) |
78 |
self.toolBar.AddTool(ID_LEGEND_LOWER, bmp, |
self.toolBar.AddTool(ID_LEGEND_LOWER, bmp, |
79 |
shortHelpString=_("Lower Layer")) |
shortHelpString=_("Lower Layer")) |
80 |
|
|
81 |
|
bmp = resource.GetBitmapResource(BOTTOM_BMP, wxBITMAP_TYPE_XPM) |
82 |
|
self.toolBar.AddTool(ID_LEGEND_BOTTOM, bmp, |
83 |
|
shortHelpString=_("Bottom Layer")) |
84 |
|
|
85 |
bmp = resource.GetBitmapResource(SHOW_BMP, wxBITMAP_TYPE_XPM) |
bmp = resource.GetBitmapResource(SHOW_BMP, wxBITMAP_TYPE_XPM) |
86 |
self.toolBar.AddTool(ID_LEGEND_SHOWLAYER, bmp, |
self.toolBar.AddTool(ID_LEGEND_SHOWLAYER, bmp, |
87 |
shortHelpString=_("Show Layer")) |
shortHelpString=_("Show Layer")) |
97 |
self.toolBar.Realize() |
self.toolBar.Realize() |
98 |
panelBox.Add(self.toolBar, 0, wxGROW, 0) |
panelBox.Add(self.toolBar, 0, wxGROW, 0) |
99 |
|
|
100 |
|
EVT_TOOL(self, ID_LEGEND_TOP, self._OnMoveTop) |
101 |
EVT_TOOL(self, ID_LEGEND_RAISE, self._OnMoveUp) |
EVT_TOOL(self, ID_LEGEND_RAISE, self._OnMoveUp) |
102 |
EVT_TOOL(self, ID_LEGEND_LOWER, self._OnMoveDown) |
EVT_TOOL(self, ID_LEGEND_LOWER, self._OnMoveDown) |
103 |
|
EVT_TOOL(self, ID_LEGEND_BOTTOM, self._OnMoveBottom) |
104 |
EVT_TOOL(self, ID_LEGEND_PROPS, self._OnProperties) |
EVT_TOOL(self, ID_LEGEND_PROPS, self._OnProperties) |
105 |
EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer) |
EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer) |
106 |
EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer) |
EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer) |
135 |
|
|
136 |
def DoOnSelChanged(self, layer, group): |
def DoOnSelChanged(self, layer, group): |
137 |
|
|
138 |
ok = isinstance(layer, Layer) |
ok = isinstance(layer, BaseLayer) |
139 |
self.__EnableButtons(ok) |
self.__EnableButtons(ok) |
140 |
|
|
141 |
self.mainWindow.SelectLayer(layer) |
self.mainWindow.SelectLayer(layer) |
143 |
def DoOnProperties(self): |
def DoOnProperties(self): |
144 |
list = self.tree.GetSelectedHierarchy() |
list = self.tree.GetSelectedHierarchy() |
145 |
|
|
146 |
ok = isinstance(list[0], Layer) |
ok = isinstance(list[0], BaseLayer) |
147 |
if ok: |
if ok: |
148 |
self.mainWindow.OpenLayerProperties(list[0], list[1]) |
self.mainWindow.OpenLayerProperties(list[0], list[1]) |
149 |
|
|
153 |
def _OnProperties(self, event): |
def _OnProperties(self, event): |
154 |
self.DoOnProperties() |
self.DoOnProperties() |
155 |
|
|
156 |
|
def _OnMoveTop(self, event): |
157 |
|
self.tree.MoveCurrentItemTop() |
158 |
|
|
159 |
def _OnMoveUp(self, event): |
def _OnMoveUp(self, event): |
160 |
self.tree.MoveCurrentItemUp() |
self.tree.MoveCurrentItemUp() |
161 |
|
|
162 |
def _OnMoveDown(self, event): |
def _OnMoveDown(self, event): |
163 |
self.tree.MoveCurrentItemDown() |
self.tree.MoveCurrentItemDown() |
164 |
|
|
165 |
|
def _OnMoveBottom(self, event): |
166 |
|
self.tree.MoveCurrentItemBottom() |
167 |
|
|
168 |
def _OnShowLayer(self, event): |
def _OnShowLayer(self, event): |
169 |
self.tree.DoOnShowLayer() |
self.tree.DoOnShowLayer() |
170 |
pass |
pass |
180 |
pass |
pass |
181 |
|
|
182 |
def __EnableButtons(self, on): |
def __EnableButtons(self, on): |
183 |
|
self.toolBar.EnableTool(ID_LEGEND_TOP, on) |
184 |
self.toolBar.EnableTool(ID_LEGEND_RAISE, on) |
self.toolBar.EnableTool(ID_LEGEND_RAISE, on) |
185 |
self.toolBar.EnableTool(ID_LEGEND_LOWER, on) |
self.toolBar.EnableTool(ID_LEGEND_LOWER, on) |
186 |
|
self.toolBar.EnableTool(ID_LEGEND_BOTTOM, on) |
187 |
self.toolBar.EnableTool(ID_LEGEND_SHOWLAYER, on) |
self.toolBar.EnableTool(ID_LEGEND_SHOWLAYER, on) |
188 |
self.toolBar.EnableTool(ID_LEGEND_HIDELAYER, on) |
self.toolBar.EnableTool(ID_LEGEND_HIDELAYER, on) |
189 |
self.toolBar.EnableTool(ID_LEGEND_PROPS, on) |
self.toolBar.EnableTool(ID_LEGEND_PROPS, on) |
248 |
#self._OnMsgMapsChanged) |
#self._OnMsgMapsChanged) |
249 |
self.__FillTree(self.map) |
self.__FillTree(self.map) |
250 |
|
|
251 |
|
def MoveCurrentItemTop(self): |
252 |
|
layer, group = self.GetSelectedHierarchy() |
253 |
|
|
254 |
|
if layer is not None: |
255 |
|
self.map.TopLayer(layer) |
256 |
|
else: |
257 |
|
assert False, "Shouldn't be allowed." |
258 |
|
pass |
259 |
|
|
260 |
def MoveCurrentItemUp(self): |
def MoveCurrentItemUp(self): |
261 |
layer, group = self.GetSelectedHierarchy() |
layer, group = self.GetSelectedHierarchy() |
262 |
|
|
275 |
assert False, "Shouldn't be allowed." |
assert False, "Shouldn't be allowed." |
276 |
pass |
pass |
277 |
|
|
278 |
|
def MoveCurrentItemBottom(self): |
279 |
|
layer, group = self.GetSelectedHierarchy() |
280 |
|
|
281 |
|
if layer is not None: |
282 |
|
self.map.BottomLayer(layer) |
283 |
|
else: |
284 |
|
assert False, "Shouldn't be allowed." |
285 |
|
pass |
286 |
|
|
287 |
def OnCompareItems(self, item1, item2): |
def OnCompareItems(self, item1, item2): |
288 |
|
|
289 |
data1 = self.GetPyData(item1) |
data1 = self.GetPyData(item1) |
290 |
data2 = self.GetPyData(item2) |
data2 = self.GetPyData(item2) |
291 |
|
|
292 |
if isinstance(data1, Layer): |
if isinstance(data1, BaseLayer): |
293 |
layers = self.map.Layers() |
layers = self.map.Layers() |
294 |
return layers.index(data2) - layers.index(data1) |
return layers.index(data2) - layers.index(data1) |
295 |
else: |
else: |
336 |
self.parent.DoOnProperties() |
self.parent.DoOnProperties() |
337 |
|
|
338 |
def _OnMsgLayerChanged(self, layer): |
def _OnMsgLayerChanged(self, layer): |
339 |
assert isinstance(layer, Layer) |
assert isinstance(layer, BaseLayer) |
340 |
|
|
341 |
id = self.layer2id[layer] |
id = self.layer2id[layer] |
342 |
assert id.IsOk() |
assert id.IsOk() |
364 |
self.__UpdateSelection() |
self.__UpdateSelection() |
365 |
|
|
366 |
def _OnMsgLayerVisibilityChanged(self, layer): |
def _OnMsgLayerVisibilityChanged(self, layer): |
367 |
assert isinstance(layer, Layer) |
assert isinstance(layer, BaseLayer) |
368 |
|
|
369 |
self.__ShowHideLayer(layer) |
self.__ShowHideLayer(layer) |
370 |
self.__UpdateSelection() |
self.__UpdateSelection() |
427 |
|
|
428 |
self.DeleteChildren(pid) |
self.DeleteChildren(pid) |
429 |
|
|
430 |
clazz = layer.GetClassification() |
if layer.HasClassification(): |
431 |
|
|
432 |
shapeType = layer.ShapeType() |
clazz = layer.GetClassification() |
433 |
|
|
434 |
show = layer.Visible() |
shapeType = layer.ShapeType() |
435 |
for g in clazz: |
|
436 |
if g.IsVisible(): |
show = layer.Visible() |
437 |
id = self.AppendItem(pid, g.GetDisplayText()) |
for g in clazz: |
438 |
self.SetPyData(id, g) |
if g.IsVisible(): |
439 |
self.__SetVisibilityStyle(show, id) |
id = self.AppendItem(pid, g.GetDisplayText()) |
440 |
|
self.SetPyData(id, g) |
441 |
bmp = self.__BuildGroupImage(g, shapeType) |
self.__SetVisibilityStyle(show, id) |
442 |
|
|
443 |
if bmp is None: |
bmp = self.__BuildGroupImage(g, shapeType) |
444 |
self.SetItemImage(id, self.emptyImageIndex) |
|
445 |
else: |
if bmp is None: |
446 |
i = self.image_list.Add(bmp) |
self.SetItemImage(id, self.emptyImageIndex) |
447 |
self.SetItemImage(id, i) |
else: |
448 |
|
i = self.image_list.Add(bmp) |
449 |
|
self.SetItemImage(id, i) |
450 |
|
|
451 |
self.Thaw() |
self.Thaw() |
452 |
|
|
481 |
font.SetStyle(wxNORMAL) |
font.SetStyle(wxNORMAL) |
482 |
color = wxBLACK |
color = wxBLACK |
483 |
else: |
else: |
484 |
font.SetStyle(wxITALIC) |
#font.SetStyle(wxITALIC) |
485 |
|
font.SetStyle(wxNORMAL) |
486 |
color = wxLIGHT_GREY |
color = wxLIGHT_GREY |
487 |
|
|
488 |
self.SetItemTextColour(id, color) |
self.SetItemTextColour(id, color) |
508 |
# While the width is fixed, get the height _now_. |
# While the width is fixed, get the height _now_. |
509 |
dc = wxMemoryDC() |
dc = wxMemoryDC() |
510 |
textwidth, textheight = dc.GetTextExtent("%d"%0) |
textwidth, textheight = dc.GetTextExtent("%d"%0) |
511 |
self.width = 200 |
self.width = 210 |
512 |
self.height = textheight + 3*2 + 8 |
self.height = textheight + 3*2 + 8 |
513 |
|
|
514 |
wxBoxSizer.__init__(self, wxVERTICAL) |
wxBoxSizer.__init__(self, wxVERTICAL) |