/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/UI/tree.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/UI/tree.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 218 by bh, Thu Jul 18 12:54:48 2002 UTC revision 374 by jan, Mon Jan 27 14:20:02 2003 UTC
# Line 13  from types import StringType Line 13  from types import StringType
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
# Line 45  class SessionTreeCtrl(wxTreeCtrl): Line 45  class SessionTreeCtrl(wxTreeCtrl):
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)
# Line 76  class SessionTreeCtrl(wxTreeCtrl): Line 70  class SessionTreeCtrl(wxTreeCtrl):
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)
# Line 131  class SessionTreeCtrl(wxTreeCtrl): Line 124  class SessionTreeCtrl(wxTreeCtrl):
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    
# Line 147  class SessionTreeCtrl(wxTreeCtrl): Line 138  class SessionTreeCtrl(wxTreeCtrl):
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:
# Line 184  class SessionTreeView(NonModalDialog): Line 179  class SessionTreeView(NonModalDialog):
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):

Legend:
Removed from v.218  
changed lines
  Added in v.374

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26