/[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 36 by bh, Thu Sep 6 17:16:06 2001 UTC revision 61 by bh, Thu Sep 13 17:58:49 2001 UTC
# Line 25  def color_string(color): Line 25  def color_string(color):
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.
# Line 36  class SessioinTreeCtrl(wxTreeCtrl): Line 36  class SessioinTreeCtrl(wxTreeCtrl):
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
# Line 48  class SessioinTreeCtrl(wxTreeCtrl): Line 51  class SessioinTreeCtrl(wxTreeCtrl):
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)
# Line 65  class SessioinTreeCtrl(wxTreeCtrl): Line 69  class SessioinTreeCtrl(wxTreeCtrl):
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):
# Line 125  class SessioinTreeCtrl(wxTreeCtrl): Line 130  class SessioinTreeCtrl(wxTreeCtrl):
130              # self.normalize_selection(). ignore the event.              # self.normalize_selection(). ignore the event.
131              return              return
132          self.normalize_selection()          self.normalize_selection()
133          layer = self.SelectedLayer()          # SelectedLayer returns None if no layer is selected. Since
134          if layer is not None:          # passing None to interactor.SelectLayer deselects the layer we
135              self.app.interactor.SelectLayer(layer)          # can simply pass the result of SelectedLayer on in all cases
136            self.app.interactor.SelectLayer(self.SelectedLayer())
137    
138      def layer_selected(self, layer):      def layer_selected(self, layer):
139          pass          item = self.layer_to_item.get(id(layer))
140            if item is not None and item != self.GetSelection():
141                self.SelectItem(item)
142    
143    
144  class SessionTreeView(NonModalDialog):  class SessionTreeView(NonModalDialog):
# Line 139  class SessionTreeView(NonModalDialog): Line 147  class SessionTreeView(NonModalDialog):
147    
148      def __init__(self, parent, app, name):      def __init__(self, parent, app, name):
149          NonModalDialog.__init__(self, parent, app.interactor, name, "Session")          NonModalDialog.__init__(self, parent, app.interactor, name, "Session")
150          self.tree = SessioinTreeCtrl(self, -1, app)          self.tree = SessionTreeCtrl(self, -1, app)
151    
152      def OnClose(self, event):      def OnClose(self, event):
153          #self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape)          #self.interactor.Unsubscribe(SELECTED_SHAPE, self.select_shape)

Legend:
Removed from v.36  
changed lines
  Added in v.61

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26