/[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 295 by bh, Fri Aug 30 10:39:17 2002 UTC revision 301 by bh, Mon Sep 2 15:59:11 2002 UTC
# Line 284  class MapCanvas(wxWindow, Publisher): Line 284  class MapCanvas(wxWindow, Publisher):
284          # To force a redraw call full_redraw().          # To force a redraw call full_redraw().
285          self.redraw_on_idle = 0          self.redraw_on_idle = 0
286    
         # The region to update when idle  
         self.update_region = wx.wxRegion()  
   
287          # the bitmap serving as backing store          # the bitmap serving as backing store
288          self.bitmap = None          self.bitmap = None
289    
# Line 317  class MapCanvas(wxWindow, Publisher): Line 314  class MapCanvas(wxWindow, Publisher):
314          if self.map is not None and self.map.HasLayers():          if self.map is not None and self.map.HasLayers():
315              # We have a non-empty map. Redraw it in idle time              # We have a non-empty map. Redraw it in idle time
316              self.redraw_on_idle = 1              self.redraw_on_idle = 1
             # update the region that has to be redrawn  
             self.update_region.UnionRegion(self.GetUpdateRegion())  
317          else:          else:
318              # 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
319              # the screen.              # the screen.
# Line 331  class MapCanvas(wxWindow, Publisher): Line 326  class MapCanvas(wxWindow, Publisher):
326              dc.Clear()              dc.Clear()
327              dc.EndDrawing()              dc.EndDrawing()
328    
             # clear the region  
             self.update_region = wx.wxRegion()  
   
329      def do_redraw(self):      def do_redraw(self):
330          # This should only be called if we have a non-empty map.          # This should only be called if we have a non-empty map.
331    
         # get the update region and reset it. We're not actually using  
         # it anymore, though.  
         update_box = self.update_region.GetBox()  
         self.update_region = wx.wxRegion()  
   
332          # Get the window size.          # Get the window size.
333          width, height = self.GetSizeTuple()          width, height = self.GetSizeTuple()
334    
# Line 369  class MapCanvas(wxWindow, Publisher): Line 356  class MapCanvas(wxWindow, Publisher):
356              # draw the map into the bitmap              # draw the map into the bitmap
357              renderer = ScreenRenderer(dc, self.scale, self.offset)              renderer = ScreenRenderer(dc, self.scale, self.offset)
358    
359              # Pass the entire bitmap as update_region to the renderer.              # Pass the entire bitmap as update region to the renderer.
360              # We're redrawing the whole bitmap, after all.              # We're redrawing the whole bitmap, after all.
361              renderer.RenderMap(self.map, (0, 0, width, height),              renderer.RenderMap(self.map, (0, 0, width, height),
362                                 selected_layer, selected_shape)                                 selected_layer, selected_shape)
# Line 631  class MapCanvas(wxWindow, Publisher): Line 618  class MapCanvas(wxWindow, Publisher):
618          self.last_selected_layer = layer          self.last_selected_layer = layer
619          self.last_selected_shape = shape          self.last_selected_shape = shape
620    
621      def unprojected_rect_around_point(self, x, y):      def unprojected_rect_around_point(self, x, y, dist):
622          """return a rect a few pixels around (x, y) in unprojected corrdinates          """return a rect dist pixels around (x, y) in unprojected corrdinates
623    
624          The return value is a tuple (minx, miny, maxx, maxy) suitable a          The return value is a tuple (minx, miny, maxx, maxy) suitable a
625          parameter to a layer's ShapesInRegion method.          parameter to a layer's ShapesInRegion method.
# Line 646  class MapCanvas(wxWindow, Publisher): Line 633  class MapCanvas(wxWindow, Publisher):
633          xs = []          xs = []
634          ys = []          ys = []
635          for dx, dy in ((-1, -1), (1, -1), (1, 1), (-1, 1)):          for dx, dy in ((-1, -1), (1, -1), (1, 1), (-1, 1)):
636              px, py = self.win_to_proj(x + dx, y + dy)              px, py = self.win_to_proj(x + dist * dx, y + dist * dy)
637              if inverse:              if inverse:
638                  px, py = inverse(px, py)                  px, py = inverse(px, py)
639              xs.append(px)              xs.append(px)
# Line 675  class MapCanvas(wxWindow, Publisher): Line 662  class MapCanvas(wxWindow, Publisher):
662          scale = self.scale          scale = self.scale
663          offx, offy = self.offset          offx, offy = self.offset
664    
         box = self.unprojected_rect_around_point(px, py)  
   
665          if select_labels:          if select_labels:
666              labels = self.map.LabelLayer().Labels()              labels = self.map.LabelLayer().Labels()
667    
# Line 736  class MapCanvas(wxWindow, Publisher): Line 721  class MapCanvas(wxWindow, Publisher):
721    
722              select_shape = -1              select_shape = -1
723    
724                # Determine the ids of the shapes that overlap a tiny area
725                # around the point. For layers containing points we have to
726                # choose a larger size of the box we're testing agains so
727                # that we take the size of the markers into account
728                # FIXME: Once the markers are more flexible this part has to
729                # become more flexible too, of course
730                if shapetype == SHAPETYPE_POINT:
731                    box = self.unprojected_rect_around_point(px, py, 5)
732                else:
733                    box = self.unprojected_rect_around_point(px, py, 1)
734              shape_ids = layer.ShapesInRegion(box)              shape_ids = layer.ShapesInRegion(box)
735              shape_ids.reverse()              shape_ids.reverse()
736    

Legend:
Removed from v.295  
changed lines
  Added in v.301

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26