25 |
return "(%.3f, %.3f, %.3f)" % (color.red, color.green, color.blue) |
return "(%.3f, %.3f, %.3f)" % (color.red, color.green, color.blue) |
26 |
|
|
27 |
|
|
28 |
class SessioinTreeCtrl(wxTreeCtrl): |
class SessionTreeCtrl(wxTreeCtrl): |
29 |
|
|
30 |
def __init__(self, parent, ID, app): |
def __init__(self, parent, ID, app): |
31 |
# Use the WANTS_CHARS style so the panel doesn't eat the Return key. |
# Use the WANTS_CHARS style so the panel doesn't eat the Return key. |
36 |
# so that we can ignore the selection events generated |
# so that we can ignore the selection events generated |
37 |
self.changing_selection = 0 |
self.changing_selection = 0 |
38 |
|
|
39 |
|
# Dictionary mapping layer id's to tree items |
40 |
|
self.layer_to_item = {} |
41 |
|
|
42 |
self.app.Subscribe(SESSION_CHANGED, self.session_changed) |
self.app.Subscribe(SESSION_CHANGED, self.session_changed) |
43 |
self.app.interactor.Subscribe(SELECTED_LAYER, self.layer_selected) |
self.app.interactor.Subscribe(SELECTED_LAYER, self.layer_selected) |
44 |
# pretend the session has changed to build the initial tree |
# pretend the session has changed to build the initial tree |
51 |
self.DeleteAllItems() |
self.DeleteAllItems() |
52 |
session = self.app.session |
session = self.app.session |
53 |
root = self.AddRoot("Session: %s" % session.title) |
root = self.AddRoot("Session: %s" % session.title) |
54 |
|
self.layer_to_item.clear() |
55 |
for map in session.Maps(): |
for map in session.Maps(): |
56 |
mapitem = self.AppendItem(root, "Map: %s" % map.title) |
mapitem = self.AppendItem(root, "Map: %s" % map.title) |
57 |
self.SetPyData(mapitem, map) |
self.SetPyData(mapitem, map) |
69 |
layeritem = self.AppendItem(mapitem, |
layeritem = self.AppendItem(mapitem, |
70 |
"Layer '%s'" % layer.Title(), |
"Layer '%s'" % layer.Title(), |
71 |
data = idata) |
data = idata) |
72 |
|
self.layer_to_item[id(layer)] = layeritem |
73 |
if layer is self.app.interactor.selected_layer: |
if layer is self.app.interactor.selected_layer: |
74 |
self.SelectItem(layeritem) |
self.SelectItem(layeritem) |
75 |
if isinstance(layer, Layer): |
if isinstance(layer, Layer): |
135 |
self.app.interactor.SelectLayer(layer) |
self.app.interactor.SelectLayer(layer) |
136 |
|
|
137 |
def layer_selected(self, layer): |
def layer_selected(self, layer): |
138 |
pass |
item = self.layer_to_item.get(id(layer)) |
139 |
|
if item is not None and item != self.GetSelection(): |
140 |
|
self.SelectItem(item) |
141 |
|
|
142 |
|
|
143 |
class SessionTreeView(NonModalDialog): |
class SessionTreeView(NonModalDialog): |
146 |
|
|
147 |
def __init__(self, parent, app, name): |
def __init__(self, parent, app, name): |
148 |
NonModalDialog.__init__(self, parent, app.interactor, name, "Session") |
NonModalDialog.__init__(self, parent, app.interactor, name, "Session") |
149 |
self.tree = SessioinTreeCtrl(self, -1, app) |
self.tree = SessionTreeCtrl(self, -1, app) |
150 |
|
|
151 |
def OnClose(self, event): |
def OnClose(self, event): |
152 |
#self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape) |
#self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape) |