/[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 910 by frank, Fri May 16 16:23:43 2003 UTC revision 1035 by jan, Mon May 26 17:03:08 2003 UTC
# Line 34  from wxPython import wx Line 34  from wxPython import wx
34    
35  from wxproj import point_in_polygon_shape, shape_centroid  from wxproj import point_in_polygon_shape, shape_centroid
36    
   
37  from Thuban.Model.messages import MAP_PROJECTION_CHANGED, \  from Thuban.Model.messages import MAP_PROJECTION_CHANGED, \
38       MAP_LAYERS_CHANGED, LAYER_CHANGED, LAYER_VISIBILITY_CHANGED       MAP_LAYERS_CHANGED, LAYER_CHANGED, LAYER_VISIBILITY_CHANGED
39  from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \  from Thuban.Model.layer import SHAPETYPE_POLYGON, SHAPETYPE_ARC, \
# Line 272  class MapPrintout(wx.wxPrintout): Line 271  class MapPrintout(wx.wxPrintout):
271                                  (height/canvas_scale)*scale),                                  (height/canvas_scale)*scale),
272                                  mapregion,                                  mapregion,
273                             self.selected_layer, self.selected_shapes)                             self.selected_layer, self.selected_shapes)
274          return wx.true          return True
275    
276    
277  class MapCanvas(wxWindow, Publisher):  class MapCanvas(wxWindow, Publisher):
# Line 378  class MapCanvas(wxWindow, Publisher): Line 377  class MapCanvas(wxWindow, Publisher):
377          dc = wxPaintDC(self)          dc = wxPaintDC(self)
378          clear = self.map is None or not self.map.HasLayers()          clear = self.map is None or not self.map.HasLayers()
379    
380          #wxBeginBusyCursor()          wxBeginBusyCursor()
381    
382          if not clear:          if not clear:
383                self.do_redraw()
384              try:              try:
385                  self.do_redraw()                  pass
386              except:              except:
387                  print "Error during drawing:", sys.exc_info()[0]                  print "Error during drawing:", sys.exc_info()[0]
388                  clear = True                  clear = True
# Line 399  class MapCanvas(wxWindow, Publisher): Line 399  class MapCanvas(wxWindow, Publisher):
399              dc.Clear()              dc.Clear()
400              dc.EndDrawing()              dc.EndDrawing()
401    
402          #wxEndBusyCursor()          wxEndBusyCursor()
403    
404      def do_redraw(self):      def do_redraw(self):
405          # This should only be called if we have a non-empty map.          # This should only be called if we have a non-empty map.
# Line 447  class MapCanvas(wxWindow, Publisher): Line 447  class MapCanvas(wxWindow, Publisher):
447          clientdc.EndDrawing()          clientdc.EndDrawing()
448    
449      def Export(self):      def Export(self):
450            if self.scale == 0:
451                return
452    
453          if hasattr(self, "export_path"):          if hasattr(self, "export_path"):
454              export_path = self.export_path              export_path = self.export_path
455          else:          else:
# Line 459  class MapCanvas(wxWindow, Publisher): Line 462  class MapCanvas(wxWindow, Publisher):
462              dc = wxMetaFileDC(dlg.GetPath())              dc = wxMetaFileDC(dlg.GetPath())
463            
464              scale, offset, mapregion = OutputTransform(self.scale,              scale, offset, mapregion = OutputTransform(self.scale,
465                                                         self.canvas.offset,                                                         self.offset,
466                                                         self.GetSizeTuple(),                                                         self.GetSizeTuple(),
467                                                         dc.GetSizeTuple())                                                         dc.GetSizeTuple())
468    
# Line 489  class MapCanvas(wxWindow, Publisher): Line 492  class MapCanvas(wxWindow, Publisher):
492                    
493          printout = MapPrintout(self, self.map, (0, 0, width, height),          printout = MapPrintout(self, self.map, (0, 0, width, height),
494                                 selected_layer, selected_shapes)                                 selected_layer, selected_shapes)
495          printer.Print(self, printout, wx.true)          printer.Print(self, printout, True)
496          printout.Destroy()          printout.Destroy()
497    
498      def SetMap(self, map):      def SetMap(self, map):
# Line 529  class MapCanvas(wxWindow, Publisher): Line 532  class MapCanvas(wxWindow, Publisher):
532    
533      def set_view_transform(self, scale, offset):      def set_view_transform(self, scale, offset):
534          self.scale = scale          self.scale = scale
535    
536          self.offset = offset          self.offset = offset
537          self.full_redraw()          self.full_redraw()
538          self.issue(SCALE_CHANGED, scale)          self.issue(SCALE_CHANGED, scale)
# Line 537  class MapCanvas(wxWindow, Publisher): Line 541  class MapCanvas(wxWindow, Publisher):
541          """\          """\
542          Return the point in  window coords given by projected coordinates x y          Return the point in  window coords given by projected coordinates x y
543          """          """
544            if self.scale == 0:
545                return (0, 0)
546    
547          offx, offy = self.offset          offx, offy = self.offset
548          return (self.scale * x + offx, -self.scale * y + offy)          return (self.scale * x + offx, -self.scale * y + offy)
549    
# Line 544  class MapCanvas(wxWindow, Publisher): Line 551  class MapCanvas(wxWindow, Publisher):
551          """\          """\
552          Return the point in projected coordinates given by window coords x y          Return the point in projected coordinates given by window coords x y
553          """          """
554            if self.scale == 0:
555                return (0, 0)
556    
557          offx, offy = self.offset          offx, offy = self.offset
558          return ((x - offx) / self.scale, (offy - y) / self.scale)          return ((x - offx) / self.scale, (offy - y) / self.scale)
559    
# Line 611  class MapCanvas(wxWindow, Publisher): Line 621  class MapCanvas(wxWindow, Publisher):
621          that should be centered. If it is omitted, it defaults to the          that should be centered. If it is omitted, it defaults to the
622          center of the window          center of the window
623          """          """
624          width, height = self.GetSizeTuple()          if self.scale > 0:
625          scale = self.scale * factor              width, height = self.GetSizeTuple()
626          offx, offy = self.offset              scale = self.scale * factor
627          if center is not None:              offx, offy = self.offset
628              cx, cy = center              if center is not None:
629          else:                  cx, cy = center
630              cx = width / 2              else:
631              cy = height / 2                  cx = width / 2
632          offset = (factor * (offx - cx) + width / 2,                  cy = height / 2
633                    factor * (offy - cy) + height / 2)              offset = (factor * (offx - cx) + width / 2,
634          self.set_view_transform(scale, offset)                      factor * (offy - cy) + height / 2)
635                self.set_view_transform(scale, offset)
636    
637      def ZoomOutToRect(self, rect):      def ZoomOutToRect(self, rect):
638          """Zoom out to fit the currently visible region into rect.          """Zoom out to fit the currently visible region into rect.
# Line 807  class MapCanvas(wxWindow, Publisher): Line 818  class MapCanvas(wxWindow, Publisher):
818              forward = None              forward = None
819    
820          scale = self.scale          scale = self.scale
821    
822            if scale == 0:
823                return None, None
824    
825          offx, offy = self.offset          offx, offy = self.offset
826    
827          if select_labels:          if select_labels:

Legend:
Removed from v.910  
changed lines
  Added in v.1035

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26