13 |
|
|
14 |
from wxPython.wx import * |
from wxPython.wx import * |
15 |
|
|
16 |
from Thuban.Model.messages import MAPS_CHANGED, MAP_PROJECTION_CHANGED, \ |
from Thuban import _ |
17 |
LAYERS_CHANGED, LAYER_LEGEND_CHANGED, LAYER_VISIBILITY_CHANGED, \ |
|
18 |
EXTENSIONS_CHANGED, EXTENSION_OBJECTS_CHANGED |
from Thuban.Model.messages import CHANGED |
19 |
from Thuban.Model.layer import Layer, shapetype_names |
from Thuban.Model.layer import Layer |
20 |
from Thuban.Model.map import Map |
from Thuban.Model.map import Map |
21 |
|
|
22 |
from dialogs import NonModalDialog |
from dialogs import NonModalDialog |
45 |
value of TreeInfo. |
value of TreeInfo. |
46 |
""" |
""" |
47 |
|
|
|
# the session channels to subscribe to update the tree |
|
|
session_channels = (MAPS_CHANGED, MAP_PROJECTION_CHANGED, |
|
|
LAYERS_CHANGED, LAYER_LEGEND_CHANGED, |
|
|
LAYER_VISIBILITY_CHANGED, EXTENSIONS_CHANGED, |
|
|
EXTENSION_OBJECTS_CHANGED) |
|
|
|
|
48 |
def __init__(self, parent, ID, app): |
def __init__(self, parent, ID, app): |
49 |
# 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. |
50 |
wxTreeCtrl.__init__(self, parent, ID) |
wxTreeCtrl.__init__(self, parent, ID) |
70 |
|
|
71 |
def unsubscribe_all(self): |
def unsubscribe_all(self): |
72 |
if self.session is not None: |
if self.session is not None: |
73 |
for channel in self.session_channels: |
self.session.Unsubscribe(CHANGED, self.update_tree) |
|
self.session.Unsubscribe(channel, self.update_tree) |
|
74 |
self.session = None |
self.session = None |
75 |
self.app.Unsubscribe(SESSION_CHANGED, self.session_changed) |
self.app.Unsubscribe(SESSION_CHANGED, self.session_changed) |
76 |
self.app.interactor.Unsubscribe(SELECTED_LAYER, self.layer_selected) |
self.app.interactor.Unsubscribe(SELECTED_LAYER, self.layer_selected) |
124 |
# if the session has changed subscribe/unsubscribe |
# if the session has changed subscribe/unsubscribe |
125 |
if self.session is not new_session: |
if self.session is not new_session: |
126 |
if self.session is not None: |
if self.session is not None: |
127 |
for channel in self.session_channels: |
self.session.Unsubscribe(CHANGED, self.update_tree) |
|
self.session.Unsubscribe(channel, self.update_tree) |
|
128 |
if new_session is not None: |
if new_session is not None: |
129 |
for channel in self.session_channels: |
new_session.Subscribe(CHANGED, self.update_tree) |
|
new_session.Subscribe(channel, self.update_tree) |
|
130 |
self.session = new_session |
self.session = new_session |
131 |
self.update_tree() |
self.update_tree() |
132 |
|
|
138 |
if isinstance(object, Layer) or isinstance(object, Map): |
if isinstance(object, Layer) or isinstance(object, Map): |
139 |
break |
break |
140 |
item = self.GetItemParent(item) |
item = self.GetItemParent(item) |
141 |
|
else: |
142 |
|
# No layer or map was found in the chain of parents, so |
143 |
|
# there's nothing we can do. |
144 |
|
return |
145 |
|
|
146 |
self.changing_selection = 1 |
self.changing_selection = 1 |
147 |
try: |
try: |
179 |
"""Non modal dialog showing the session as a tree""" |
"""Non modal dialog showing the session as a tree""" |
180 |
|
|
181 |
def __init__(self, parent, app, name): |
def __init__(self, parent, app, name): |
182 |
NonModalDialog.__init__(self, parent, app.interactor, name, "Session") |
NonModalDialog.__init__(self, parent, app.interactor, name, |
183 |
|
_("Session")) |
184 |
self.tree = SessionTreeCtrl(self, -1, app) |
self.tree = SessionTreeCtrl(self, -1, app) |
185 |
|
|
186 |
def OnClose(self, event): |
def OnClose(self, event): |