/[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 115 by jan, Mon Apr 22 11:30:20 2002 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            if session.filename == None:
56                self.AppendItem(root, "Filename:")
57            else:
58                self.AppendItem(root, "Filename: %s" % session.filename)
59            if session.WasModified():
60                self.AppendItem(root, "Modified: yes")
61            else:
62                self.AppendItem(root, "Modified: no")
63    
64          for map in session.Maps():          for map in session.Maps():
65              mapitem = self.AppendItem(root, "Map: %s" % map.title)              mapitem = self.AppendItem(root, "Map: %s" % map.title)
66              self.SetPyData(mapitem, map)              self.SetPyData(mapitem, map)
67                if map.BoundingBox() != None:
68                    self.AppendItem(mapitem, ("Extent (lat-lon): (%g, %g, %g, %g)"
69                                              % map.BoundingBox()))
70              if map.projection and len(map.projection.params) > 0:              if map.projection and len(map.projection.params) > 0:
71                    self.AppendItem(mapitem,
72                                    ("Extent (projected): (%g, %g, %g, %g)"
73                                     % map.ProjectedBoundingBox()))
74                  projectionitem = self.AppendItem(mapitem, "Projection")                  projectionitem = self.AppendItem(mapitem, "Projection")
75                  for param in map.projection.params:                  for param in map.projection.params:
76                      parameteritem = self.AppendItem(projectionitem, str(param))                      parameteritem = self.AppendItem(projectionitem, str(param))
# Line 65  class SessioinTreeCtrl(wxTreeCtrl): Line 84  class SessioinTreeCtrl(wxTreeCtrl):
84                  layeritem = self.AppendItem(mapitem,                  layeritem = self.AppendItem(mapitem,
85                                              "Layer '%s'" % layer.Title(),                                              "Layer '%s'" % layer.Title(),
86                                              data = idata)                                              data = idata)
87                    self.layer_to_item[id(layer)] = layeritem
88                  if layer is self.app.interactor.selected_layer:                  if layer is self.app.interactor.selected_layer:
89                      self.SelectItem(layeritem)                      self.SelectItem(layeritem)
90                  if isinstance(layer, Layer):                  if isinstance(layer, Layer):
# Line 74  class SessioinTreeCtrl(wxTreeCtrl): Line 94  class SessioinTreeCtrl(wxTreeCtrl):
94                          text = "Hidden"                          text = "Hidden"
95                      self.AppendItem(layeritem, text)                      self.AppendItem(layeritem, text)
96                      self.AppendItem(layeritem, "Shapes: %d" %layer.NumShapes())                      self.AppendItem(layeritem, "Shapes: %d" %layer.NumShapes())
97                      self.AppendItem(layeritem, ("Extents: (%g, %g, %g, %g)"                      self.AppendItem(layeritem,
98                                                  % layer.LatLongBoundingBox()))                                      ("Extent (lat-lon): (%g, %g, %g, %g)"
99                                         % layer.LatLongBoundingBox()))
100                      self.AppendItem(layeritem,                      self.AppendItem(layeritem,
101                                      "Shapetype: %s"                                      "Shapetype: %s"
102                                      % shapetype_names[layer.ShapeType()])                                      % shapetype_names[layer.ShapeType()])
# Line 125  class SessioinTreeCtrl(wxTreeCtrl): Line 146  class SessioinTreeCtrl(wxTreeCtrl):
146              # self.normalize_selection(). ignore the event.              # self.normalize_selection(). ignore the event.
147              return              return
148          self.normalize_selection()          self.normalize_selection()
149          layer = self.SelectedLayer()          # SelectedLayer returns None if no layer is selected. Since
150          if layer is not None:          # passing None to interactor.SelectLayer deselects the layer we
151              self.app.interactor.SelectLayer(layer)          # can simply pass the result of SelectedLayer on in all cases
152            self.app.interactor.SelectLayer(self.SelectedLayer())
153    
154      def layer_selected(self, layer):      def layer_selected(self, layer):
155          pass          item = self.layer_to_item.get(id(layer))
156            if item is not None and item != self.GetSelection():
157                self.SelectItem(item)
158    
159    
160  class SessionTreeView(NonModalDialog):  class SessionTreeView(NonModalDialog):
# Line 139  class SessionTreeView(NonModalDialog): Line 163  class SessionTreeView(NonModalDialog):
163    
164      def __init__(self, parent, app, name):      def __init__(self, parent, app, name):
165          NonModalDialog.__init__(self, parent, app.interactor, name, "Session")          NonModalDialog.__init__(self, parent, app.interactor, name, "Session")
166          self.tree = SessioinTreeCtrl(self, -1, app)          self.tree = SessionTreeCtrl(self, -1, app)
167    
168      def OnClose(self, event):      def OnClose(self, event):
169          #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.115

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26