/[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 246 by bh, Mon Jul 29 13:38:04 2002 UTC revision 293 by bh, Fri Aug 30 10:18:50 2002 UTC
# Line 129  class ZoomInTool(RectTool): Line 129  class ZoomInTool(RectTool):
129              Tool.MouseUp(self, event)              Tool.MouseUp(self, event)
130              sx, sy = self.start              sx, sy = self.start
131              cx, cy = self.current              cx, cy = self.current
132              if sx == cx and sy == cy:              if sx == cx or sy == cy:
133                  # Just a mouse click. Simply zoom in by a factor of two                  # Just a mouse click or a degenerate rectangle. Simply
134                    # zoom in by a factor of two
135                    # FIXME: For a click this is the desired behavior but should we
136                    # really do this for degenrate rectagles as well or
137                    # should we ignore them?
138                  self.view.ZoomFactor(2, center = (cx, cy))                  self.view.ZoomFactor(2, center = (cx, cy))
139              else:              else:
140                  # A drag. Zoom in to the rectangle                  # A drag. Zoom in to the rectangle
# Line 149  class ZoomOutTool(RectTool): Line 153  class ZoomOutTool(RectTool):
153              Tool.MouseUp(self, event)              Tool.MouseUp(self, event)
154              sx, sy = self.start              sx, sy = self.start
155              cx, cy = self.current              cx, cy = self.current
156              if sx == cx and sy == cy:              if sx == cx or sy == cy:
157                  # Just a mouse click. Simply zoom out by a factor of two                  # Just a mouse click or a degenerate rectangle. Simply
158                    # zoom out by a factor of two.
159                    # FIXME: For a click this is the desired behavior but should we
160                    # really do this for degenrate rectagles as well or
161                    # should we ignore them?
162                  self.view.ZoomFactor(0.5, center = (cx, cy))                  self.view.ZoomFactor(0.5, center = (cx, cy))
163              else:              else:
164                  # A drag. Zoom out to the rectangle                  # A drag. Zoom out to the rectangle
# Line 437  class MapCanvas(wxWindow, Publisher): Line 445  class MapCanvas(wxWindow, Publisher):
445          return ((x - offx) / self.scale, (offy - y) / self.scale)          return ((x - offx) / self.scale, (offy - y) / self.scale)
446    
447      def FitRectToWindow(self, rect):      def FitRectToWindow(self, rect):
448            """Fit the rectangular region given by rect into the window.
449            
450            Set scale so that rect (in projected coordinates) just fits into
451            the window and center it.
452            """
453          width, height = self.GetSizeTuple()          width, height = self.GetSizeTuple()
454          llx, lly, urx, ury = rect          llx, lly, urx, ury = rect
455          if llx == urx or lly == ury:          if llx == urx or lly == ury:
# Line 450  class MapCanvas(wxWindow, Publisher): Line 463  class MapCanvas(wxWindow, Publisher):
463          self.set_view_transform(scale, (offx, offy))          self.set_view_transform(scale, (offx, offy))
464    
465      def FitMapToWindow(self):      def FitMapToWindow(self):
466          """\          """Fit the map to the window
467          Set the scale and offset so that the map is centered in the          
468          window          Set the scale so that the map fits exactly into the window and
469            center it in the window.
470          """          """
471          bbox = self.map.ProjectedBoundingBox()          bbox = self.map.ProjectedBoundingBox()
472          if bbox is not None:          if bbox is not None:
# Line 478  class MapCanvas(wxWindow, Publisher): Line 492  class MapCanvas(wxWindow, Publisher):
492          self.set_view_transform(scale, offset)          self.set_view_transform(scale, offset)
493    
494      def ZoomOutToRect(self, rect):      def ZoomOutToRect(self, rect):
495          # rect is given in window coordinates          """Zoom out to fit the currently visible region into rect.
496    
497            The rect parameter is given in window coordinates
498            """
499          # determine the bbox of the displayed region in projected          # determine the bbox of the displayed region in projected
500          # coordinates          # coordinates
501          width, height = self.GetSizeTuple()          width, height = self.GetSizeTuple()
# Line 554  class MapCanvas(wxWindow, Publisher): Line 570  class MapCanvas(wxWindow, Publisher):
570              self.dragging = 1              self.dragging = 1
571    
572      def OnLeftUp(self, event):      def OnLeftUp(self, event):
         self.ReleaseMouse()  
573          self.set_current_position(event)          self.set_current_position(event)
574          if self.dragging:          if self.dragging:
575                self.ReleaseMouse()
576              self.tool.Hide(self.drag_dc)              self.tool.Hide(self.drag_dc)
577              self.tool.MouseUp(event)              self.tool.MouseUp(event)
578              self.drag_dc = None              self.drag_dc = None

Legend:
Removed from v.246  
changed lines
  Added in v.293

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26