/[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 799 by jonathan, Wed Apr 30 17:02:21 2003 UTC revision 883 by jonathan, Fri May 9 16:34:39 2003 UTC
# Line 17  from math import hypot Line 17  from math import hypot
17    
18  from wxPython.wx import wxWindow,\  from wxPython.wx import wxWindow,\
19       wxPaintDC, wxColour, wxClientDC, wxINVERT, wxTRANSPARENT_BRUSH, wxFont,\       wxPaintDC, wxColour, wxClientDC, wxINVERT, wxTRANSPARENT_BRUSH, wxFont,\
20       EVT_PAINT, EVT_LEFT_DOWN, EVT_LEFT_UP, EVT_MOTION, EVT_LEAVE_WINDOW       EVT_PAINT, EVT_LEFT_DOWN, EVT_LEFT_UP, EVT_MOTION, EVT_LEAVE_WINDOW, \
21         wxBITMAP_TYPE_XPM, wxBeginBusyCursor, wxEndBusyCursor, wxCursor, \
22         wxImageFromBitmap
23    
24    
25  from wxPython import wx  from wxPython import wx
# Line 34  from Thuban.Model.label import ALIGN_CEN Line 36  from Thuban.Model.label import ALIGN_CEN
36  from Thuban.Lib.connector import Publisher  from Thuban.Lib.connector import Publisher
37  from Thuban.Model.color import Color  from Thuban.Model.color import Color
38    
39    import resource
40    
41  from selection import Selection  from selection import Selection
42  from renderer import ScreenRenderer, PrinterRender  from renderer import ScreenRenderer, PrinterRender
43    
44  import labeldialog  import labeldialog
45    
46  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION, \
47                         SCALE_CHANGED
48    
49    
50  #  #
# Line 273  class MapCanvas(wxWindow, Publisher): Line 278  class MapCanvas(wxWindow, Publisher):
278      delegated_methods = {"SelectLayer": "selection",      delegated_methods = {"SelectLayer": "selection",
279                           "SelectShapes": "selection",                           "SelectShapes": "selection",
280                           "SelectedLayer": "selection",                           "SelectedLayer": "selection",
281                           "HasSelectedLayer": "selection"}                           "HasSelectedLayer": "selection",
282                             "HasSelectedShapes": "selection",
283                             "SelectedShapes": "selection"}
284    
285      def __init__(self, parent, winid):      def __init__(self, parent, winid):
286          wxWindow.__init__(self, parent, winid)          wxWindow.__init__(self, parent, winid)
# Line 357  class MapCanvas(wxWindow, Publisher): Line 364  class MapCanvas(wxWindow, Publisher):
364          dc = wxPaintDC(self)          dc = wxPaintDC(self)
365          clear = self.map is None or not self.map.HasLayers()          clear = self.map is None or not self.map.HasLayers()
366    
367            #wxBeginBusyCursor()
368    
369          if not clear:          if not clear:
370              try:              try:
371                  self.do_redraw()                  self.do_redraw()
# Line 376  class MapCanvas(wxWindow, Publisher): Line 385  class MapCanvas(wxWindow, Publisher):
385              dc.Clear()              dc.Clear()
386              dc.EndDrawing()              dc.EndDrawing()
387    
388            #wxEndBusyCursor()
389    
390      def do_redraw(self):      def do_redraw(self):
391          # This should only be called if we have a non-empty map.          # This should only be called if we have a non-empty map.
392    
# Line 466  class MapCanvas(wxWindow, Publisher): Line 477  class MapCanvas(wxWindow, Publisher):
477          self.scale = scale          self.scale = scale
478          self.offset = offset          self.offset = offset
479          self.full_redraw()          self.full_redraw()
480            self.issue(SCALE_CHANGED, scale)
481    
482      def proj_to_win(self, x, y):      def proj_to_win(self, x, y):
483          """\          """\
# Line 509  class MapCanvas(wxWindow, Publisher): Line 521  class MapCanvas(wxWindow, Publisher):
521          if bbox is not None:          if bbox is not None:
522              self.FitRectToWindow(bbox)              self.FitRectToWindow(bbox)
523    
524        def FitLayerToWindow(self, layer):
525            """Fit the given layer to the window.
526    
527            Set the scale so that the layer fits exactly into the window and
528            center it in the window.
529            """
530            
531            bbox = layer.LatLongBoundingBox()
532            if bbox is not None:
533                proj = self.map.GetProjection()
534                if proj is not None:
535                    bbox = proj.ForwardBBox(bbox)
536    
537                if bbox is not None:
538                    self.FitRectToWindow(bbox)
539    
540        def FitSelectedToWindow(self):
541            layer = self.selection.SelectedLayer()
542            shapes = self.selection.SelectedShapes()
543    
544            bbox = layer.ShapesBoundingBox(shapes)
545            if bbox is not None:
546                proj = self.map.GetProjection()
547                if proj is not None:
548                    bbox = proj.ForwardBBox(bbox)
549    
550                if bbox is not None:
551                    self.FitRectToWindow(bbox)
552    
553      def ZoomFactor(self, factor, center = None):      def ZoomFactor(self, factor, center = None):
554          """Multiply the zoom by factor and center on center.          """Multiply the zoom by factor and center on center.
555    
# Line 572  class MapCanvas(wxWindow, Publisher): Line 613  class MapCanvas(wxWindow, Publisher):
613      def PanTool(self):      def PanTool(self):
614          """Start the pan tool"""          """Start the pan tool"""
615          self.SelectTool(PanTool(self))          self.SelectTool(PanTool(self))
616            #img = resource.GetImageResource("pan", wxBITMAP_TYPE_XPM)
617            #bmp = resource.GetBitmapResource("pan", wxBITMAP_TYPE_XPM)
618            #print bmp
619            #img = wxImageFromBitmap(bmp)
620            #print img
621            #cur = wxCursor(img)
622            #print cur
623            #self.SetCursor(cur)
624    
625      def IdentifyTool(self):      def IdentifyTool(self):
626          """Start the identify tool"""          """Start the identify tool"""

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26