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

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

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

revision 542 by jonathan, Thu Mar 20 09:43:16 2003 UTC revision 882 by jonathan, Fri May 9 16:34:28 2003 UTC
# Line 9  __version__ = "$Revision$" Line 9  __version__ = "$Revision$"
9    
10  from Thuban import _  from Thuban import _
11    
12    import resource
13    
14  from wxPython.wx import *  from wxPython.wx import *
 from dialogs import NonModalDialog  
15    
16  from Thuban.Model.layer import Layer  from Thuban.Model.layer import Layer
17  from Thuban.Model.map import Map  from Thuban.Model.map import Map
18    from Thuban.Model.classification import ClassGroup
19    
20  from Thuban.Model.messages import *  from Thuban.Model.messages import \
21        MAP_STACKING_CHANGED, MAP_LAYERS_ADDED, MAP_LAYERS_REMOVED, LAYER_CHANGED,\
22        LAYER_VISIBILITY_CHANGED, TITLE_CHANGED
23    
24  from Thuban.Model.classification import ClassGroup  from Thuban.UI.messages import SCALE_CHANGED
25    
26  from Thuban.UI.classifier import ClassDataPreviewer  from Thuban.UI.classifier import ClassDataPreviewer
27    from Thuban.UI.dock import DockPanel
28    from Thuban.UI.scalebar import ScaleBar
29    
30  ID_LEGEND_MOVEUP = 4001  from Thuban.Lib.connector import ConnectorError
31  ID_LEGEND_MOVEDOWN = 4002  
32    ID_LEGEND_RAISE = 4001
33    ID_LEGEND_LOWER = 4002
34  ID_LEGEND_TREE = 4003  ID_LEGEND_TREE = 4003
35  ID_LEGEND_CLASSIFY = 4004  ID_LEGEND_PROPS = 4004
36  ID_LEGEND_SHOWLAYER = 4005  ID_LEGEND_SHOWLAYER = 4005
37  ID_LEGEND_HIDELAYER = 4006  ID_LEGEND_HIDELAYER = 4006
38    
39  BMP_SIZE_W = 30  BMP_SIZE_W = 30
40  BMP_SIZE_H = 15  BMP_SIZE_H = 15
41    
42  class Legend(NonModalDialog):  RAISE_BMP = "raise_layer"
43    LOWER_BMP = "lower_layer"
44    SHOW_BMP  = "show_layer"
45    HIDE_BMP  = "hide_layer"
46    PROPS_BMP = "layer_properties"
47    
     def __init__(self, parent, name, map):  
         NonModalDialog.__init__(self, parent, name,  
                                 _("Legend: %s") % map.Title())  
48    
49          self.parent = parent  class LegendPanel(DockPanel):
50    
51        def __init__(self, parent, map, mainWindow):
52            DockPanel.__init__(self, parent, -1)
53    
54          panel = wxPanel(self, -1)          self.mainWindow = mainWindow
55            self.parent = parent
56    
57            self.buttons = []
58    
         topBox = wxBoxSizer(wxVERTICAL)  
59          panelBox = wxBoxSizer(wxVERTICAL)          panelBox = wxBoxSizer(wxVERTICAL)
60    
61          buttonBox = wxGridSizer(2, 3, 0, 0)          self.toolBar = wxToolBar(self, -1)
62            self.toolBar.SetToolBitmapSize(wxSize(24, 24))
63    
64          self.buttons = []          bmp = resource.GetBitmapResource(RAISE_BMP, wxBITMAP_TYPE_XPM)
65            self.toolBar.AddTool(ID_LEGEND_RAISE, bmp,
66                shortHelpString=_("Raise Layer"))
67    
68            bmp = resource.GetBitmapResource(LOWER_BMP, wxBITMAP_TYPE_XPM)
69            self.toolBar.AddTool(ID_LEGEND_LOWER, bmp,
70                shortHelpString=_("Lower Layer"))
71    
72          button = wxButton(self, ID_LEGEND_MOVEUP, _("Move Up"))          bmp = resource.GetBitmapResource(SHOW_BMP, wxBITMAP_TYPE_XPM)
73          buttonBox.Add(button, 0, wxGROW | wxLEFT | wxRIGHT, 0)          self.toolBar.AddTool(ID_LEGEND_SHOWLAYER, bmp,
74          self.buttons.append(button)              shortHelpString=_("Show Layer"))
75    
76          button = wxButton(self, ID_LEGEND_SHOWLAYER, _("Show Layer"))          bmp = resource.GetBitmapResource(HIDE_BMP, wxBITMAP_TYPE_XPM)
77          buttonBox.Add(button, 0, wxGROW | wxLEFT | wxRIGHT, 0)          self.toolBar.AddTool(ID_LEGEND_HIDELAYER, bmp,
78          self.buttons.append(button)              shortHelpString=_("Hide Layer"))
79    
80          button = wxButton(self, ID_LEGEND_CLASSIFY, _("Classify"))          bmp = resource.GetBitmapResource(PROPS_BMP, wxBITMAP_TYPE_XPM)
81          buttonBox.Add(button, 0, wxGROW | wxLEFT | wxRIGHT, 0)          self.toolBar.AddTool(ID_LEGEND_PROPS, bmp,
82          self.buttons.append(button)              shortHelpString=_("Edit Layer Properties"))
83    
84          button = wxButton(self, ID_LEGEND_MOVEDOWN, _("Move Down"))          self.toolBar.Realize()
85          buttonBox.Add(button, 0, wxGROW | wxLEFT | wxRIGHT, 0)          panelBox.Add(self.toolBar, 0, wxGROW, 0)
         self.buttons.append(button)  
86    
87          button = wxButton(self, ID_LEGEND_HIDELAYER, _("Hide Layer"))          EVT_TOOL(self, ID_LEGEND_RAISE, self._OnMoveUp)
88          buttonBox.Add(button, 0, wxGROW | wxLEFT | wxRIGHT, 0)          EVT_TOOL(self, ID_LEGEND_LOWER, self._OnMoveDown)
89          self.buttons.append(button)          EVT_TOOL(self, ID_LEGEND_PROPS, self._OnProperties)
90            EVT_TOOL(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer)
91            EVT_TOOL(self, ID_LEGEND_HIDELAYER, self._OnHideLayer)
92    
93            self.tree = LegendTree(self, ID_LEGEND_TREE, map, mainWindow)
94    
95          EVT_BUTTON(self, ID_LEGEND_MOVEUP, self._OnMoveUp)          panelBox.Add(self.tree, 1, wxGROW, 0)
         EVT_BUTTON(self, ID_LEGEND_MOVEDOWN, self._OnMoveDown)  
         EVT_BUTTON(self, ID_LEGEND_CLASSIFY, self._OnClassify)  
         EVT_BUTTON(self, ID_LEGEND_SHOWLAYER, self._OnShowLayer)  
         EVT_BUTTON(self, ID_LEGEND_HIDELAYER, self._OnHideLayer)  
96    
97          panelBox.Add(buttonBox, 0, 0, 4)          self.scalebarbitmap = ScaleBarBitmap(self, map, mainWindow)
98            panelBox.Add(self.scalebarbitmap, 0, wxGROW, 0)
99    
100          self.tree = LegendTree(self, ID_LEGEND_TREE, map)          self.SetAutoLayout(True)
101            self.SetSizer(panelBox)
102            panelBox.SetSizeHints(self)
103    
         panelBox.Add(self.tree, 1, wxGROW, 4)  
104    
105          panel.SetAutoLayout(True)          self.panelBox = panelBox
         panel.SetSizer(panelBox)  
         panelBox.SetSizeHints(panel)  
106    
107          topBox.Add(panel, 1, wxGROW, 0)          self.__EnableButtons(False)
         panelBox.SetSizeHints(self)  
108    
109          self.SetAutoLayout(True)          self.Create()
110          self.SetSizer(topBox)  
111            EVT_CLOSE(self, self._OnClose)
112    
113    
114        def GetMap(self):
115            return self.tree.GetMap()
116    
117        def SetMap(self, map):
118            self.tree.SetMap(map)
119            self.scalebarbitmap.SetCanvas(self.mainWindow.canvas)
120    
121        def DoOnSelChanged(self, layer, group):
122    
123            ok = isinstance(layer, Layer)
124            self.__EnableButtons(ok)
125    
126            self.mainWindow.SelectLayer(layer)
127    
128      def DoOnSelChanged(self):      def DoOnProperties(self):
129          self.__EnableButtons(self.tree.GetSelection().IsOk())          list = self.tree.GetSelectedHierarchy()
130    
131      def _OnClassify(self, event):          ok = isinstance(list[0], Layer)
132          self.tree.DoOnClassify()          if ok:
133                self.mainWindow.OpenLayerProperties(list[0], list[1])
134    
135        def Destroy(self):
136            self.__Close()
137    
138        def _OnProperties(self, event):
139            self.DoOnProperties()
140    
141      def _OnMoveUp(self, event):      def _OnMoveUp(self, event):
142          self.tree.MoveCurrentItemUp()          self.tree.MoveCurrentItemUp()
# Line 109  class Legend(NonModalDialog): Line 148  class Legend(NonModalDialog):
148          self.tree.DoOnShowLayer()          self.tree.DoOnShowLayer()
149          pass          pass
150    
151        #def Close(self, force = False):
152            #DockPanel.Close(self, force)
153            
154        def _OnClose(self, event):
155            self.__Close()
156    
157      def _OnHideLayer(self, event):      def _OnHideLayer(self, event):
158          self.tree.DoOnHideLayer()          self.tree.DoOnHideLayer()
159          pass          pass
160    
   
161      def __EnableButtons(self, on):      def __EnableButtons(self, on):
162          for b in self.buttons:          self.toolBar.EnableTool(ID_LEGEND_RAISE, on)
163              b.Enable(on)          self.toolBar.EnableTool(ID_LEGEND_LOWER, on)
164            self.toolBar.EnableTool(ID_LEGEND_SHOWLAYER,  on)
165            self.toolBar.EnableTool(ID_LEGEND_HIDELAYER,  on)
166            self.toolBar.EnableTool(ID_LEGEND_PROPS, on)
167    
168        def __Close(self):
169            self.tree.Close()
170    
171  class LegendTree(wxTreeCtrl):  class LegendTree(wxTreeCtrl):
172    
173      def __init__(self, parent, id, map):      def __init__(self, parent, id, map, mainWindow):
174          wxTreeCtrl.__init__(self, parent, id,          wxTreeCtrl.__init__(self, parent, id,
175                              style = wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT,                              style = wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT,
176                              size = (200, 200))                              size = (200, 200))
177    
178            self.mainWindow = mainWindow
179            self.map = None
180          self.parent = parent          self.parent = parent
181          self.map = map          self.layer2id = {}
         self.layer2id = None  
   
182    
183          self.image_list = None          self.image_list = None
184          self.emptyImageIndex = 0          self.emptyImageIndex = 0
185    
186          self.previewer = ClassDataPreviewer()          self.previewer = ClassDataPreviewer()
187    
   
188          EVT_TREE_ITEM_ACTIVATED(self, ID_LEGEND_TREE, self._OnItemActivated)          EVT_TREE_ITEM_ACTIVATED(self, ID_LEGEND_TREE, self._OnItemActivated)
189          EVT_TREE_SEL_CHANGED(self, ID_LEGEND_TREE, self._OnSelChanged)          EVT_TREE_SEL_CHANGED(self, ID_LEGEND_TREE, self._OnSelChanged)
190    
191          map.Subscribe(MAP_STACKING_CHANGED, self._OnMsgMapStackingChanged)          EVT_CLOSE(self, self._OnClose)
         map.Subscribe(MAP_LAYERS_CHANGED, self._OnMsgMapLayersChanged)  
192    
193          self.__FillTree(map)          self.SetMap(map)
194    
195      def MoveCurrentItemUp(self):      def _OnClose(self, event):
196          cur_id = self.GetSelection()          self.SetMap(None)
         assert(cur_id.IsOk())  
197    
198          cur_data = self.GetPyData(cur_id)      def GetMap(self):
199            return self.map
200    
201        def SetMap(self, map):
202    
203            sub_list = [(MAP_STACKING_CHANGED, self._OnMsgMapStackingChanged),
204                        (MAP_LAYERS_ADDED, self._OnMsgMapLayersAddedRemoved),
205                        (MAP_LAYERS_REMOVED, self._OnMsgMapLayersAddedRemoved)]
206    
207            if self.map is not None:
208                for msg, func in sub_list: self.map.Unsubscribe(msg, func)
209                #self.mainWindow.application.Unsubscribe(SESSION_REPLACED,
210                    #self._OnMsgMapsChanged)
211                #try:
212                    #self.mainWindow.application.session.Unsubscribe(MAPS_CHANGED,
213                        #self._OnMsgMapsChanged)
214                #except ConnectorError:
215                    #pass
216                self.__DeleteAllItems()
217            
218            self.map = map
219    
220          #prev_id = self.GetPrevSibling(cur_id)          if self.map is not None:
221                for msg, func in sub_list: self.map.Subscribe(msg, func)
222                #self.mainWindow.application.session.Subscribe(MAPS_CHANGED,
223                    #self._OnMsgMapsChanged)
224                #self.mainWindow.application.Subscribe(SESSION_REPLACED,
225                    #self._OnMsgMapsChanged)
226                self.__FillTree(self.map)
227    
228          #      def MoveCurrentItemUp(self):
229          # Get out if there's nowhere to go          layer, group = self.GetSelectedHierarchy()
         #  
         #if prev_id == INVALID_TREE_ID: return  
230    
231          if isinstance(cur_data, Layer):          if layer is not None:
232              self.map.RaiseLayer(cur_data)              self.map.RaiseLayer(layer)
         elif isinstance(cur_data, ClassGroup):  
             pass  
233          else:          else:
234              assert(False, "Shouldn't be here.")              assert False, "Shouldn't be allowed."
235              pass              pass
236    
237      def MoveCurrentItemDown(self):      def MoveCurrentItemDown(self):
238          cur_id = self.GetSelection()          layer, group = self.GetSelectedHierarchy()
         assert(cur_id.IsOk())  
239    
240          cur_data = self.GetPyData(cur_id)          if layer is not None:
241                self.map.LowerLayer(layer)
         if isinstance(cur_data, Layer):  
             self.map.LowerLayer(cur_data)  
         elif isinstance(cur_data, ClassGroup):  
             pass  
242          else:          else:
243              assert(False, "Shouldn't be here.")              assert False, "Shouldn't be allowed."
244              pass              pass
245    
   
246      def OnCompareItems(self, item1, item2):      def OnCompareItems(self, item1, item2):
247    
248          data1 = self.GetPyData(item1)          data1 = self.GetPyData(item1)
# Line 191  class LegendTree(wxTreeCtrl): Line 254  class LegendTree(wxTreeCtrl):
254          else:          else:
255              return wxTreeCtrl.OnCompareItems(self, item1, item2)              return wxTreeCtrl.OnCompareItems(self, item1, item2)
256    
   
257      def DoOnShowLayer(self):      def DoOnShowLayer(self):
258          self.__ShowHideLayer(True)          #self.__ShowHideLayer(True)
259            layer, group = self.GetSelectedHierarchy()
260            layer.SetVisible(True)
261    
262      def DoOnHideLayer(self):      def DoOnHideLayer(self):
263          self.__ShowHideLayer(False)          #self.__ShowHideLayer(False)
264            layer, group = self.GetSelectedHierarchy()
265            layer.SetVisible(False)
266    
267      def DoOnClassify(self):      def Sort(self):
268          id = self.GetSelection()          self.SortChildren(self.GetRootItem())
         assert(id.IsOk())  
269    
270          item = self.GetPyData(id)      def GetSelectedHierarchy(self):
271          if isinstance(item, ClassGroup):          id = self.GetSelection()
             id = self.GetItemParent(id)  
             assert(id.IsOk())  
             item = self.GetPyData(id)  
272    
273          self.parent.parent.OpenClassifier(item)          if not id.IsOk():
274                return (None, None)
275    
276      def Sort(self):          layer = self.GetPyData(id)
277          self.SortChildren(self.GetRootItem())          group = None
278    
279            if isinstance(layer, ClassGroup):
280                id = self.GetItemParent(id)
281                assert id.IsOk()
282                group = layer
283                layer = self.GetPyData(id)
284    
285            return (layer, group)
286    
287        def _OnMsgMapsChanged(self):
288            #print self.map is self.mainWindow.Map()
289            self.SetMap(self.mainWindow.Map())
290            
291      def _OnSelChanged(self, event):      def _OnSelChanged(self, event):
292          self.parent.DoOnSelChanged()          self.__UpdateSelection()
293    
294      def _OnItemActivated(self, event):      def _OnItemActivated(self, event):
295          self.DoOnClassify()          self.parent.DoOnProperties()
296    
297      def _OnMsgLayerChanged(self, layer):      def _OnMsgLayerChanged(self, layer):
298          assert(isinstance(layer, Layer))          assert isinstance(layer, Layer)
299    
300          id = self.layer2id[layer]          id = self.layer2id[layer]
301            assert id.IsOk()
302    
303          self.__FillTreeLayer(id)          # XXX: yikes! this is so bad, we should be doing what is
304            #      commented out, but there is a problem with keeping
305            #      track of the images in the image list when we replace
306            #      a layer. it ends up causing a seg fault.
307            self.__FillTree(self.map)
308            self.__UpdateSelection()
309            #self.__FillTreeLayer(id)
310    
311      def _OnMsgMapStackingChanged(self, *args):      def _OnMsgMapStackingChanged(self, *args):
312          self.Sort()          self.Sort()
313            id = self.GetSelection()
314    
315      def _OnMsgMapLayersChanged(self, map):          if id.IsOk():
316          assert(id(map) == id(self.map))              self.EnsureVisible(id)
317            self.__UpdateSelection()
318    
319        def _OnMsgMapLayersAddedRemoved(self, map):
320            assert map is self.map
321    
322          self.__FillTree(self.map)          self.__FillTree(self.map)
323            self.__UpdateSelection()
324    
325      def __FillTree(self, map):      def _OnMsgLayerVisibilityChanged(self, layer):
326            assert isinstance(layer, Layer)
327    
328            self.__ShowHideLayer(layer)
329            self.__UpdateSelection()
330    
331          assert(isinstance(map, Map))      def _OnMsgLayerTitleChanged(self, layer):
332    
333            id = self.layer2id[layer]
334            if id.IsOk():
335                self.SetItemText(id, layer.Title())
336            self.__UpdateSelection()
337    
338        def __UpdateSelection(self):
339            layer, group = self.GetSelectedHierarchy()
340            self.parent.DoOnSelChanged(layer, group)
341            
342        def __FillTree(self, map):
343    
344          self.Freeze()          self.Freeze()
345    
# Line 263  class LegendTree(wxTreeCtrl): Line 366  class LegendTree(wxTreeCtrl):
366              for l in map.Layers():              for l in map.Layers():
367                  id = self.PrependItem(root, l.Title())                  id = self.PrependItem(root, l.Title())
368                  l.Subscribe(LAYER_CHANGED, self._OnMsgLayerChanged)                  l.Subscribe(LAYER_CHANGED, self._OnMsgLayerChanged)
369                    l.Subscribe(LAYER_VISIBILITY_CHANGED,
370                                self._OnMsgLayerVisibilityChanged)
371                    l.Subscribe(TITLE_CHANGED, self._OnMsgLayerTitleChanged)
372                  self.SetPyData(id, l)                  self.SetPyData(id, l)
373                  font = self.GetItemFont(id)                  self.__SetVisibilityStyle(l.Visible(), id)
                 if not l.Visible():  
                     font.SetStyle(wxITALIC)  
                     self.SetItemFont(id, font)  
374    
375                  self.layer2id[l] = id                  self.layer2id[l] = id
376    
# Line 287  class LegendTree(wxTreeCtrl): Line 390  class LegendTree(wxTreeCtrl):
390    
391          shapeType = layer.ShapeType()          shapeType = layer.ShapeType()
392    
393            show = layer.Visible()
394          for g in clazz:          for g in clazz:
395              id = self.AppendItem(pid, g.GetDisplayText())              if g.IsVisible():
396              self.SetPyData(id, g)                  id = self.AppendItem(pid, g.GetDisplayText())
397                    self.SetPyData(id, g)
398              bmp = self.__BuildGroupImage(g, shapeType)                  self.__SetVisibilityStyle(show, id)
399    
400              if bmp is None:                  bmp = self.__BuildGroupImage(g, shapeType)
401                  self.SetItemImage(id, self.emptyImageIndex)  
402              else:                  if bmp is None:
403                  i = self.image_list.Add(bmp)                      self.SetItemImage(id, self.emptyImageIndex)
404                  self.SetItemImage(id, i)                  else:
405                        i = self.image_list.Add(bmp)
406              #self.layer2id[g] = id                      self.SetItemImage(id, i)
407    
408          self.Thaw()          self.Thaw()
409    
410      def __BuildGroupImage(self, group, shapeType):      def __BuildGroupImage(self, group, shapeType):
         assert(isinstance(group, ClassGroup))  
411    
412          bmp = wxEmptyBitmap(BMP_SIZE_W, BMP_SIZE_H)          bmp = wxEmptyBitmap(BMP_SIZE_W, BMP_SIZE_H)
413          #brush = wxBrush(Color2wxColour(item[1]), wxSOLID)          #brush = wxBrush(Color2wxColour(item[1]), wxSOLID)
# Line 317  class LegendTree(wxTreeCtrl): Line 420  class LegendTree(wxTreeCtrl):
420          return bmp          return bmp
421    
422      def __DeleteAllItems(self):      def __DeleteAllItems(self):
423    
424            while len(self.layer2id) > 0:
425                layer, id = self.layer2id.popitem()
426                layer.Unsubscribe(LAYER_CHANGED,
427                                  self._OnMsgLayerChanged)
428                layer.Unsubscribe(LAYER_VISIBILITY_CHANGED,
429                                  self._OnMsgLayerVisibilityChanged)
430                layer.Unsubscribe(TITLE_CHANGED, self._OnMsgLayerTitleChanged)
431    
432          self.DeleteAllItems()          self.DeleteAllItems()
         self.layer2id = {}  
433    
434        def __SetVisibilityStyle(self, visible, id):
435            font = self.GetItemFont(id)
436    
437      def __ShowHideLayer(self, show):          if visible:
438          id = self.GetSelection()              font.SetStyle(wxNORMAL)
439          assert(id.IsOk())              color = wxBLACK
440            else:
441                font.SetStyle(wxITALIC)
442                color = wxLIGHT_GREY
443    
444            self.SetItemTextColour(id, color)
445            self.SetItemFont(id, font)
446                    
447          item = self.GetPyData(id)      def __ShowHideLayer(self, layer):
448          if isinstance(item, ClassGroup):          parent = self.layer2id[layer]
449              id = self.GetItemParent(id)          assert parent.IsOk()
450              assert(id.IsOk())  
451              item = self.GetPyData(id)          visible = layer.Visible()
452    
453            self.__SetVisibilityStyle(visible, parent)
454    
455            id, cookie = self.GetFirstChild(parent, 123)
456    
457            while id.IsOk():
458                self.__SetVisibilityStyle(visible, id)
459                id, cookie = self.GetNextChild(parent, cookie)
460                
461    class ScaleBarBitmap(wxBoxSizer):
462    
463          if show != item.Visible():      def __init__(self, parent, map, mainWindow):
464            # While the width is fixed, get the height _now_.
465            dc = wxMemoryDC()
466            textwidth, textheight = dc.GetTextExtent("%d"%0)
467            self.width = 200
468            self.height = textheight + 3*2 + 8
469    
470            wxBoxSizer.__init__(self, wxVERTICAL)
471            bmp=wxEmptyBitmap(self.width, self.height)
472            self.scalebarBitmap = wxStaticBitmap(parent, -1, bmp)
473            self.Add(self.scalebarBitmap, 0, wxALIGN_CENTER|wxLEFT|wxTOP|wxRIGHT, 1)
474    
475            self.mainWindow = mainWindow
476            self.parent = parent
477            self.canvas = None
478            self.SetCanvas(self.mainWindow.canvas)
479    
480        def SetCanvas(self, canvas):
481            sub_list = [(SCALE_CHANGED, self._OnMsgScaleChanged)]
482    
483            if self.canvas is not None:
484                for msg, func in sub_list: self.canvas.Unsubscribe(msg, func)
485            
486            self.canvas = canvas
487            self.scalebar = ScaleBar(canvas.map)
488    
489            if self.canvas is not None:
490                for msg, func in sub_list: self.canvas.Subscribe(msg, func)
491                self.__SetScale(self.canvas.scale)
492    
493              item.SetVisible(show)      def _OnMsgScaleChanged(self, scale):
494            self.__SetScale(scale)
495    
496              font = self.GetItemFont(id)      def __SetScale(self, scale):
497              if show:          bmp = wxEmptyBitmap(self.width, self.height)
498                  font.SetStyle(wxNORMAL)          dc = wxMemoryDC()
499                  self.SetItemFont(id, font)          dc.SelectObject(bmp)
500              else:          dc.Clear()
                 font.SetStyle(wxITALIC)  
                 self.SetItemFont(id, font)  
501    
502            self.scalebar.DrawScalebar(scale, dc)
503    
504            self.scalebarBitmap.SetBitmap(bmp)
505    

Legend:
Removed from v.542  
changed lines
  Added in v.882

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26