Viewer.py
changeset 471 ea90da16a5e2
parent 469 17411b970353
child 477 fd9625f6e92a
equal deleted inserted replaced
470:cc64bbb1d654 471:ea90da16a5e2
    21 #You should have received a copy of the GNU General Public
    21 #You should have received a copy of the GNU General Public
    22 #License along with this library; if not, write to the Free Software
    22 #License along with this library; if not, write to the Free Software
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24 
    24 
    25 import math
    25 import math
       
    26 from types import TupleType
       
    27 from threading import Lock
    26 
    28 
    27 import wx
    29 import wx
    28 if wx.VERSION >= (2, 8, 0):
    30 if wx.VERSION >= (2, 8, 0):
    29     USE_AUI = True
    31     USE_AUI = True
    30 else:
    32 else:
    33 from plcopen.structures import *
    35 from plcopen.structures import *
    34 from PLCControler import ITEM_POU
    36 from PLCControler import ITEM_POU
    35 
    37 
    36 from dialogs import *
    38 from dialogs import *
    37 from graphics import *
    39 from graphics import *
    38 
       
    39 from types import TupleType
       
    40 
    40 
    41 SCROLLBAR_UNIT = 10
    41 SCROLLBAR_UNIT = 10
    42 WINDOW_BORDER = 10
    42 WINDOW_BORDER = 10
    43 SCROLL_ZONE = 10
    43 SCROLL_ZONE = 10
    44 
    44 
   523         
   523         
   524         if not self.Debug:
   524         if not self.Debug:
   525             self.SetDropTarget(ViewerDropTarget(self))
   525             self.SetDropTarget(ViewerDropTarget(self))
   526         
   526         
   527         self.NewDataRefreshRect = None
   527         self.NewDataRefreshRect = None
       
   528         self.NewDataRefreshRect_lock = Lock()
   528         
   529         
   529         dc = wx.ClientDC(self)
   530         dc = wx.ClientDC(self)
   530         font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
   531         font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
   531         dc.SetFont(font)
   532         dc.SetFont(font)
   532         width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
   533         width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
   813 #-------------------------------------------------------------------------------
   814 #-------------------------------------------------------------------------------
   814 #                          Refresh functions
   815 #                          Refresh functions
   815 #-------------------------------------------------------------------------------
   816 #-------------------------------------------------------------------------------
   816 
   817 
   817     def UpdateRefreshRect(self, refresh_rect):
   818     def UpdateRefreshRect(self, refresh_rect):
       
   819         self.NewDataRefreshRect_lock.acquire()
   818         if self.NewDataRefreshRect is None:
   820         if self.NewDataRefreshRect is None:
   819             self.NewDataRefreshRect = refresh_rect
   821             self.NewDataRefreshRect = refresh_rect
   820         else:
   822         else:
   821             self.NewDataRefreshRect.Union(refresh_rect)
   823             self.NewDataRefreshRect.Union(refresh_rect)
   822 
   824         self.NewDataRefreshRect_lock.release()
       
   825         
   823     def RefreshNewData(self):
   826     def RefreshNewData(self):
   824         if self.NewDataRefreshRect is not None:
   827         if self.NewDataRefreshRect is not None:
       
   828             self.NewDataRefreshRect_lock.acquire()
   825             refresh_rect, self.NewDataRefreshRect = self.NewDataRefreshRect, None
   829             refresh_rect, self.NewDataRefreshRect = self.NewDataRefreshRect, None
       
   830             self.NewDataRefreshRect_lock.release()
   826             self.RefreshRect(self.GetScrolledRect(refresh_rect), False)
   831             self.RefreshRect(self.GetScrolledRect(refresh_rect), False)
   827         else:
   832         else:
   828             DebugViewer.RefreshNewData(self)
   833             DebugViewer.RefreshNewData(self)
   829         
   834         
   830     def ResetBuffer(self):
   835     def ResetBuffer(self):