1 |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003, 2005 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Jonathan Coles <[email protected]> |
# Jonathan Coles <[email protected]> |
4 |
# Frank Koormann <[email protected]> |
# Frank Koormann <[email protected]> |
15 |
import resource |
import resource |
16 |
|
|
17 |
from wxPython.wx import * |
from wxPython.wx import * |
18 |
|
import wxPython |
19 |
|
|
20 |
from Thuban.Model.layer import BaseLayer |
from Thuban.Model.layer import BaseLayer |
21 |
from Thuban.Model.map import Map |
from Thuban.Model.map import Map |
285 |
def find_layer(self, layer): |
def find_layer(self, layer): |
286 |
"""Return the tree item for the layer""" |
"""Return the tree item for the layer""" |
287 |
root = self.GetRootItem() |
root = self.GetRootItem() |
288 |
id, cookie = self.GetFirstChild(root, 0) |
id, cookie = self.GetFirstChild(root) |
289 |
while id.IsOk(): |
while id.IsOk(): |
290 |
if self.GetPyData(id) is layer: |
if self.GetPyData(id) is layer: |
291 |
return id |
return id |
488 |
# Build a dict with all layers known by the the tree as keys |
# Build a dict with all layers known by the the tree as keys |
489 |
layers = {} |
layers = {} |
490 |
root = self.GetRootItem() |
root = self.GetRootItem() |
491 |
id, cookie = self.GetFirstChild(root, 0) |
id, cookie = self.GetFirstChild(root) |
492 |
while id.IsOk(): |
while id.IsOk(): |
493 |
layers[self.GetPyData(id)] = 1 |
layers[self.GetPyData(id)] = 1 |
494 |
id, cookie = self.GetNextChild(root, cookie) |
id, cookie = self.GetNextChild(root, cookie) |
507 |
layers = map.Layers() |
layers = map.Layers() |
508 |
|
|
509 |
root = self.GetRootItem() |
root = self.GetRootItem() |
510 |
id, cookie = self.GetFirstChild(root, 0) |
id, cookie = self.GetFirstChild(root) |
511 |
while id.IsOk(): |
while id.IsOk(): |
512 |
if self.GetPyData(id) not in layers: |
if self.GetPyData(id) not in layers: |
513 |
self.__RemoveLayer(id) |
self.__RemoveLayer(id) |
599 |
|
|
600 |
pid = self.GetRootItem() |
pid = self.GetRootItem() |
601 |
|
|
602 |
id, cookie = self.GetFirstChild(pid, 123) |
id, cookie = self.GetFirstChild(pid) |
603 |
while id.IsOk(): |
while id.IsOk(): |
604 |
self.__RemoveLayer(id) |
self.__RemoveLayer(id) |
605 |
id, cookie = self.GetNextChild(pid, cookie) |
id, cookie = self.GetNextChild(pid, cookie) |
637 |
self.Delete(id) |
self.Delete(id) |
638 |
|
|
639 |
def DeleteChildren(self, pid): |
def DeleteChildren(self, pid): |
640 |
id, cookie = self.GetFirstChild(pid, 123) |
id, cookie = self.GetFirstChild(pid) |
641 |
while id.IsOk(): |
while id.IsOk(): |
642 |
self.availImgListIndices.append(self.GetItemImage(id)) |
self.availImgListIndices.append(self.GetItemImage(id)) |
643 |
id, cookie = self.GetNextChild(pid, cookie) |
id, cookie = self.GetNextChild(pid, cookie) |
693 |
|
|
694 |
self.__SetVisibilityStyle(visible, parent) |
self.__SetVisibilityStyle(visible, parent) |
695 |
|
|
696 |
id, cookie = self.GetFirstChild(parent, 123) |
id, cookie = self.GetFirstChild(parent) |
697 |
|
|
698 |
while id.IsOk(): |
while id.IsOk(): |
699 |
self.__SetVisibilityStyle(visible, id) |
self.__SetVisibilityStyle(visible, id) |
700 |
id, cookie = self.GetNextChild(parent, cookie) |
id, cookie = self.GetNextChild(parent, cookie) |
701 |
|
|
702 |
|
# In wxPython 2.4 the GetFirstChild method has to be called with a |
703 |
|
# second argument and in 2.5 it must not. Reading the code of |
704 |
|
# wxPython 2.4 it seems that the second parameter was intended to be |
705 |
|
# optional there but due to a bug in the C++ code it doesn't work |
706 |
|
# and omitting the second argument leads to a segfault. To cope |
707 |
|
# with this and to make the code usable with both 2.5 and 2.4 we |
708 |
|
# overwrite the inherited method when running with 2.4 to provide a |
709 |
|
# default value for the second argument. |
710 |
|
if map(int, wxPython.__version__.split(".")[:2]) < [2, 5]: |
711 |
|
def GetFirstChild(self, item): |
712 |
|
return wxTreeCtrl.GetFirstChild(self, item, 0) |
713 |
|
|
714 |
|
|
715 |
class ScaleBarBitmap(wxBoxSizer): |
class ScaleBarBitmap(wxBoxSizer): |
716 |
|
|
717 |
def __init__(self, parent, map, mainWindow): |
def __init__(self, parent, map, mainWindow): |