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

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

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

revision 535 by bh, Fri Mar 14 20:42:18 2003 UTC revision 799 by jonathan, Wed Apr 30 17:02:21 2003 UTC
# Line 11  Classes for display of a map and interac Line 11  Classes for display of a map and interac
11    
12  __version__ = "$Revision$"  __version__ = "$Revision$"
13    
14    import sys
15    
16  from math import hypot  from math import hypot
17    
18  from wxPython.wx import wxWindow,\  from wxPython.wx import wxWindow,\
# Line 24  from wxproj import point_in_polygon_shap Line 26  from wxproj import point_in_polygon_shap
26    
27    
28  from Thuban.Model.messages import MAP_PROJECTION_CHANGED, \  from Thuban.Model.messages import MAP_PROJECTION_CHANGED, \
29       LAYERS_CHANGED, LAYER_LEGEND_CHANGED, LAYER_VISIBILITY_CHANGED       MAP_LAYERS_CHANGED, LAYER_CHANGED, LAYER_VISIBILITY_CHANGED
30  from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \  from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \
31       SHAPETYPE_POINT       SHAPETYPE_POINT
32  from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \  from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \
# Line 259  class MapCanvas(wxWindow, Publisher): Line 261  class MapCanvas(wxWindow, Publisher):
261      """A widget that displays a map and offers some interaction"""      """A widget that displays a map and offers some interaction"""
262    
263      # Some messages that can be subscribed/unsubscribed directly through      # Some messages that can be subscribed/unsubscribed directly through
264      # the MapCanvas come in fact from other objects. This is a map to      # the MapCanvas come in fact from other objects. This is a dict
265      # map those messages to the names of the instance variables they      # mapping those messages to the names of the instance variables they
266      # actually come from. This delegation is implemented in the      # actually come from. The delegation is implemented in the Subscribe
267      # Subscribe and unsubscribed methods      # and Unsubscribe methods
268      delegated_messages = {LAYER_SELECTED: "selection",      delegated_messages = {LAYER_SELECTED: "selection",
269                            SHAPES_SELECTED: "selection"}                            SHAPES_SELECTED: "selection"}
270    
# Line 353  class MapCanvas(wxWindow, Publisher): Line 355  class MapCanvas(wxWindow, Publisher):
355    
356      def OnPaint(self, event):      def OnPaint(self, event):
357          dc = wxPaintDC(self)          dc = wxPaintDC(self)
358          if self.map is not None and self.map.HasLayers():          clear = self.map is None or not self.map.HasLayers()
359              self.do_redraw()  
360          else:          if not clear:
361                try:
362                    self.do_redraw()
363                except:
364                    print "Error during drawing:", sys.exc_info()[0]
365                    clear = True
366    
367            if clear:
368              # If we've got no map or if the map is empty, simply clear              # If we've got no map or if the map is empty, simply clear
369              # the screen.              # the screen.
370    
# Line 383  class MapCanvas(wxWindow, Publisher): Line 392  class MapCanvas(wxWindow, Publisher):
392              dc.BeginDrawing()              dc.BeginDrawing()
393    
394              # clear the background              # clear the background
395              dc.SetBrush(wx.wxWHITE_BRUSH)              #dc.SetBrush(wx.wxWHITE_BRUSH)
396              dc.SetPen(wx.wxTRANSPARENT_PEN)              #dc.SetPen(wx.wxTRANSPARENT_PEN)
397              dc.DrawRectangle(0, 0, width, height)              #dc.DrawRectangle(0, 0, width, height)
398                dc.SetBackground(wx.wxWHITE_BRUSH)
399                dc.Clear()
400    
401              selected_layer = self.selection.SelectedLayer()              selected_layer = self.selection.SelectedLayer()
402              selected_shapes = self.selection.SelectedShapes()              selected_shapes = self.selection.SelectedShapes()
# Line 417  class MapCanvas(wxWindow, Publisher): Line 428  class MapCanvas(wxWindow, Publisher):
428          printout.Destroy()          printout.Destroy()
429    
430      def SetMap(self, map):      def SetMap(self, map):
431          redraw_channels = (LAYERS_CHANGED, LAYER_LEGEND_CHANGED,          redraw_channels = (MAP_LAYERS_CHANGED, LAYER_CHANGED,
432                             LAYER_VISIBILITY_CHANGED)                             LAYER_VISIBILITY_CHANGED)
433          if self.map is not None:          if self.map is not None:
434              for channel in redraw_channels:              for channel in redraw_channels:
# Line 479  class MapCanvas(wxWindow, Publisher): Line 490  class MapCanvas(wxWindow, Publisher):
490          width, height = self.GetSizeTuple()          width, height = self.GetSizeTuple()
491          llx, lly, urx, ury = rect          llx, lly, urx, ury = rect
492          if llx == urx or lly == ury:          if llx == urx or lly == ury:
493              # zero with or zero height. Do Nothing              # zero width or zero height. Do Nothing
494              return              return
495          scalex = width / (urx - llx)          scalex = width / (urx - llx)
496          scaley = height / (ury - lly)          scaley = height / (ury - lly)
# Line 639  class MapCanvas(wxWindow, Publisher): Line 650  class MapCanvas(wxWindow, Publisher):
650          # Even when the window becomes larger some parts of the bitmap          # Even when the window becomes larger some parts of the bitmap
651          # could be reused.          # could be reused.
652          self.full_redraw()          self.full_redraw()
653            pass
654    
655      def shape_selected(self, layer, shape):      def shape_selected(self, layer, shape):
656          """Receiver for the SHAPES_SELECTED messages. Redraw the map."""          """Receiver for the SHAPES_SELECTED messages. Redraw the map."""
# Line 741  class MapCanvas(wxWindow, Publisher): Line 753  class MapCanvas(wxWindow, Publisher):
753                  continue                  continue
754    
755              filled = layer.GetClassification().GetDefaultFill() \              filled = layer.GetClassification().GetDefaultFill() \
756                       is not Color.None                       is not Color.Transparent
757              stroked = layer.GetClassification().GetDefaultLineColor() \              stroked = layer.GetClassification().GetDefaultLineColor() \
758                        is not Color.None                        is not Color.Transparent
759    
760              layer_proj = layer.projection              layer_proj = layer.projection
761              if layer_proj is not None:              if layer_proj is not None:

Legend:
Removed from v.535  
changed lines
  Added in v.799

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26