/[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 1343 by jonathan, Mon Jun 23 10:30:53 2003 UTC revision 1344 by jonathan, Tue Jul 1 16:11:26 2003 UTC
# Line 43  from Thuban.Model.layer import SHAPETYPE Line 43  from Thuban.Model.layer import SHAPETYPE
43  from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \  from Thuban.Model.label import ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM, \
44       ALIGN_LEFT, ALIGN_RIGHT       ALIGN_LEFT, ALIGN_RIGHT
45  from Thuban.Lib.connector import Publisher  from Thuban.Lib.connector import Publisher
46  from Thuban.Model.color import Color  from Thuban.Model.color import Color, Transparent
47    
48  import resource  import resource
49    
# Line 55  import labeldialog Line 55  import labeldialog
55  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION, \  from messages import LAYER_SELECTED, SHAPES_SELECTED, VIEW_POSITION, \
56                       SCALE_CHANGED                       SCALE_CHANGED
57    
58    #from common import ThubanBeginBusyCursor, ThubanEndBusyCursor
59    
60  #  #
61  #   The tools  #   The tools
# Line 336  class MapCanvas(wxWindow, Publisher): Line 337  class MapCanvas(wxWindow, Publisher):
337          self.last_selected_layer = None          self.last_selected_layer = None
338          self.last_selected_shape = None          self.last_selected_shape = None
339    
340            self.backgroundColor = wx.wxWHITE_BRUSH
341    
342          # subscribe the WX events we're interested in          # subscribe the WX events we're interested in
343          EVT_PAINT(self, self.OnPaint)          EVT_PAINT(self, self.OnPaint)
344          EVT_LEFT_DOWN(self, self.OnLeftDown)          EVT_LEFT_DOWN(self, self.OnLeftDown)
# Line 343  class MapCanvas(wxWindow, Publisher): Line 346  class MapCanvas(wxWindow, Publisher):
346          EVT_MOTION(self, self.OnMotion)          EVT_MOTION(self, self.OnMotion)
347          EVT_LEAVE_WINDOW(self, self.OnLeaveWindow)          EVT_LEAVE_WINDOW(self, self.OnLeaveWindow)
348          wx.EVT_SIZE(self, self.OnSize)          wx.EVT_SIZE(self, self.OnSize)
349            wx.EVT_IDLE(self, self.OnIdle)
350    
351      def __del__(self):      def __del__(self):
352          wxWindow.__del__(self)          wxWindow.__del__(self)
# Line 382  class MapCanvas(wxWindow, Publisher): Line 386  class MapCanvas(wxWindow, Publisher):
386      def OnPaint(self, event):      def OnPaint(self, event):
387          dc = wxPaintDC(self)          dc = wxPaintDC(self)
388    
389          clear = self.map is None or not self.map.HasLayers()          if self.map is not None and self.map.HasLayers():
390                if self.bitmap in (None, -1):
391                    # set the flag that we should redraw the
392                    # bitmap in idle time
393                    self.bitmap = -1
394                    return
395    
396          wxBeginBusyCursor()              # blit the bitmap to the screen
397          try:              dc.BeginDrawing()
398              if not clear:              dc.DrawBitmap(self.bitmap, 0, 0)
399                  self.do_redraw()              dc.EndDrawing()
400              else:          else:
401                  # 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
402                  # the screen.              # the screen.
403    
404                  # XXX it's probably possible to get rid of this. The              # XXX it's probably possible to get rid of this. The
405                  # background color of the window is already white and the              # background color of the window is already white and the
406                  # only thing we may have to do is to call self.Refresh()              # only thing we may have to do is to call self.Refresh()
407                  # with a true argument in the right places.              # with a true argument in the right places.
408                  dc.BeginDrawing()              dc.BeginDrawing()
409                  dc.Clear()              dc.SetBackground(self.backgroundColor)
410                  dc.EndDrawing()              dc.Clear()
411          finally:              dc.EndDrawing()
             wxEndBusyCursor()  
412    
413      def do_redraw(self):      def OnIdle(self, event):
414          # This should only be called if we have a non-empty map.          # render the screen if necessary
415    
416          # Get the window size.          if self.bitmap != -1:
417          width, height = self.GetSizeTuple()              return
418    
419            wxBeginBusyCursor()
420            try:
421                width, height = self.GetSizeTuple()
422    
         # If self.bitmap's still there, reuse it. Otherwise redraw it  
         if self.bitmap is not None:  
             bitmap = self.bitmap  
         else:  
423              bitmap = wx.wxEmptyBitmap(width, height)              bitmap = wx.wxEmptyBitmap(width, height)
424              dc = wx.wxMemoryDC()              dc = wx.wxMemoryDC()
425              dc.SelectObject(bitmap)              dc.SelectObject(bitmap)
426              dc.BeginDrawing()              dc.BeginDrawing()
427    
428              # clear the background              dc.SetBackground(self.backgroundColor)
             #dc.SetBrush(wx.wxWHITE_BRUSH)  
             #dc.SetPen(wx.wxTRANSPARENT_PEN)  
             #dc.DrawRectangle(0, 0, width, height)  
             dc.SetBackground(wx.wxWHITE_BRUSH)  
429              dc.Clear()              dc.Clear()
430    
431              selected_layer = self.selection.SelectedLayer()              selected_layer = self.selection.SelectedLayer()
# Line 437  class MapCanvas(wxWindow, Publisher): Line 441  class MapCanvas(wxWindow, Publisher):
441    
442              dc.EndDrawing()              dc.EndDrawing()
443              dc.SelectObject(wx.wxNullBitmap)              dc.SelectObject(wx.wxNullBitmap)
444    
445              self.bitmap = bitmap              self.bitmap = bitmap
446            finally:
447                wxEndBusyCursor()
448                pass
449    
450          # blit the bitmap to the screen          # This causes a paint event that then draws the bitmap
451          dc = wx.wxMemoryDC()          self.redraw()
         dc.SelectObject(bitmap)  
         clientdc = wxClientDC(self)  
         clientdc.BeginDrawing()  
         clientdc.Blit(0, 0, width, height, dc, 0, 0)  
         clientdc.EndDrawing()  
452    
453      def Export(self):      def Export(self):
454          if self.scale == 0:          if self.scale == 0:
# Line 525  class MapCanvas(wxWindow, Publisher): Line 528  class MapCanvas(wxWindow, Publisher):
528          return self.map          return self.map
529    
530      def redraw(self, *args):      def redraw(self, *args):
531          self.Refresh(0)          self.Refresh(False)
532    
533      def full_redraw(self, *args):      def full_redraw(self, *args):
534          self.bitmap = None          self.bitmap = None
# Line 942  class MapCanvas(wxWindow, Publisher): Line 945  class MapCanvas(wxWindow, Publisher):
945                  continue                  continue
946    
947              filled = layer.GetClassification().GetDefaultFill() \              filled = layer.GetClassification().GetDefaultFill() \
948                       is not Color.Transparent                       is not Transparent
949              stroked = layer.GetClassification().GetDefaultLineColor() \              stroked = layer.GetClassification().GetDefaultLineColor() \
950                        is not Color.Transparent                        is not Transparent
951    
952              layer_proj = layer.projection              layer_proj = layer.projection
953              if layer_proj is not None:              if layer_proj is not None:

Legend:
Removed from v.1343  
changed lines
  Added in v.1344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26