/[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 288 by bh, Thu Aug 29 13:31:43 2002 UTC revision 295 by bh, Fri Aug 30 10:39:17 2002 UTC
# Line 412  class MapCanvas(wxWindow, Publisher): Line 412  class MapCanvas(wxWindow, Publisher):
412          self.full_redraw()          self.full_redraw()
413    
414      def Map(self):      def Map(self):
415            """Return the map displayed by this canvas"""
416          return self.map          return self.map
417    
418      def redraw(self, *args):      def redraw(self, *args):
# Line 445  class MapCanvas(wxWindow, Publisher): Line 446  class MapCanvas(wxWindow, Publisher):
446          return ((x - offx) / self.scale, (offy - y) / self.scale)          return ((x - offx) / self.scale, (offy - y) / self.scale)
447    
448      def FitRectToWindow(self, rect):      def FitRectToWindow(self, rect):
449            """Fit the rectangular region given by rect into the window.
450            
451            Set scale so that rect (in projected coordinates) just fits into
452            the window and center it.
453            """
454          width, height = self.GetSizeTuple()          width, height = self.GetSizeTuple()
455          llx, lly, urx, ury = rect          llx, lly, urx, ury = rect
456          if llx == urx or lly == ury:          if llx == urx or lly == ury:
# Line 458  class MapCanvas(wxWindow, Publisher): Line 464  class MapCanvas(wxWindow, Publisher):
464          self.set_view_transform(scale, (offx, offy))          self.set_view_transform(scale, (offx, offy))
465    
466      def FitMapToWindow(self):      def FitMapToWindow(self):
467          """\          """Fit the map to the window
468          Set the scale and offset so that the map is centered in the          
469          window          Set the scale so that the map fits exactly into the window and
470            center it in the window.
471          """          """
472          bbox = self.map.ProjectedBoundingBox()          bbox = self.map.ProjectedBoundingBox()
473          if bbox is not None:          if bbox is not None:
# Line 486  class MapCanvas(wxWindow, Publisher): Line 493  class MapCanvas(wxWindow, Publisher):
493          self.set_view_transform(scale, offset)          self.set_view_transform(scale, offset)
494    
495      def ZoomOutToRect(self, rect):      def ZoomOutToRect(self, rect):
496          # rect is given in window coordinates          """Zoom out to fit the currently visible region into rect.
497    
498            The rect parameter is given in window coordinates
499            """
500          # determine the bbox of the displayed region in projected          # determine the bbox of the displayed region in projected
501          # coordinates          # coordinates
502          width, height = self.GetSizeTuple()          width, height = self.GetSizeTuple()
# Line 504  class MapCanvas(wxWindow, Publisher): Line 513  class MapCanvas(wxWindow, Publisher):
513          self.set_view_transform(scale, (offx, offy))          self.set_view_transform(scale, (offx, offy))
514    
515      def Translate(self, dx, dy):      def Translate(self, dx, dy):
516            """Move the map by dx, dy pixels"""
517          offx, offy = self.offset          offx, offy = self.offset
518          self.set_view_transform(self.scale, (offx + dx, offy + dy))          self.set_view_transform(self.scale, (offx + dx, offy + dy))
519    
520      def ZoomInTool(self):      def ZoomInTool(self):
521            """Start the zoom in tool"""
522          self.tool = ZoomInTool(self)          self.tool = ZoomInTool(self)
523    
524      def ZoomOutTool(self):      def ZoomOutTool(self):
525            """Start the zoom out tool"""
526          self.tool = ZoomOutTool(self)          self.tool = ZoomOutTool(self)
527    
528      def PanTool(self):      def PanTool(self):
529            """Start the pan tool"""
530          self.tool = PanTool(self)          self.tool = PanTool(self)
531    
532      def IdentifyTool(self):      def IdentifyTool(self):
533            """Start the identify tool"""
534          self.tool = IdentifyTool(self)          self.tool = IdentifyTool(self)
535    
536      def LabelTool(self):      def LabelTool(self):
537            """Start the label tool"""
538          self.tool = LabelTool(self)          self.tool = LabelTool(self)
539    
540      def CurrentTool(self):      def CurrentTool(self):
541            """Return the name of the current tool or None if no tool is active"""
542          return self.tool and self.tool.Name() or None          return self.tool and self.tool.Name() or None
543    
544      def CurrentPosition(self):      def CurrentPosition(self):
# Line 782  class MapCanvas(wxWindow, Publisher): Line 798  class MapCanvas(wxWindow, Publisher):
798          return result          return result
799    
800      def LabelShapeAt(self, x, y):      def LabelShapeAt(self, x, y):
801            """Add or remove a label at window position x, y.
802    
803            If there's a label at the given position, remove it. Otherwise
804            determine the shape at the position, run the label dialog and
805            unless the user cancels the dialog, add a laber.
806            """
807          ox = x; oy = y          ox = x; oy = y
808          label_layer = self.map.LabelLayer()          label_layer = self.map.LabelLayer()
809          layer, shape_index = self.find_shape_at(x, y, select_labels = 1)          layer, shape_index = self.find_shape_at(x, y, select_labels = 1)

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26