--- a/Viewer.py Mon Jan 30 16:12:19 2012 +0100
+++ b/Viewer.py Tue Jan 31 13:38:06 2012 +0100
@@ -499,8 +499,8 @@
if not self.Debug:
self.Editor.SetDropTarget(ViewerDropTarget(self))
- self.NewDataRefreshRect = None
- self.NewDataRefreshRect_lock = Lock()
+ self.ElementRefreshList = []
+ self.ElementRefreshList_lock = Lock()
dc = wx.ClientDC(self.Editor)
font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["mono"])
@@ -885,19 +885,23 @@
# Refresh functions
#-------------------------------------------------------------------------------
- def UpdateRefreshRect(self, refresh_rect):
- self.NewDataRefreshRect_lock.acquire()
- if self.NewDataRefreshRect is None:
- self.NewDataRefreshRect = refresh_rect
- else:
- self.NewDataRefreshRect.Union(refresh_rect)
- self.NewDataRefreshRect_lock.release()
+ def ElementNeedRefresh(self, element):
+ self.ElementRefreshList_lock.acquire()
+ self.ElementRefreshList.append(element)
+ self.ElementRefreshList_lock.release()
def RefreshNewData(self):
- if self.NewDataRefreshRect is not None:
- self.NewDataRefreshRect_lock.acquire()
- refresh_rect, self.NewDataRefreshRect = self.NewDataRefreshRect, None
- self.NewDataRefreshRect_lock.release()
+ refresh_rect = None
+ self.ElementRefreshList_lock.acquire()
+ for element in self.ElementRefreshList:
+ if refresh_rect is None:
+ refresh_rect = element.GetRedrawRect()
+ else:
+ refresh_rect.Union(element.GetRedrawRect())
+ self.ElementRefreshList = []
+ self.ElementRefreshList_lock.release()
+
+ if refresh_rect is not None:
self.RefreshRect(self.GetScrolledRect(refresh_rect), False)
else:
DebugViewer.RefreshNewData(self)
--- a/graphics/GraphicCommons.py Mon Jan 30 16:12:19 2012 +0100
+++ b/graphics/GraphicCommons.py Tue Jan 31 13:38:06 2012 +0100
@@ -333,8 +333,8 @@
def AddDataConsumer(self, iec_path, consumer):
if self.DataProducer is None:
- return False
- result = self.DataProducer.SubscribeDebugIECVariable(iec_path, consumer) is not None
+ return None
+ result = self.DataProducer.SubscribeDebugIECVariable(iec_path, consumer)
if result is not None and consumer != self:
self.DataConsumers[consumer] = iec_path
consumer.SetDataType(self.GetDataType(iec_path))
@@ -1920,6 +1920,8 @@
rect = rect.Union(self.StartConnected.GetRedrawRect(movex, movey))
if self.EndConnected:
rect = rect.Union(self.EndConnected.GetRedrawRect(movex, movey))
+ if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)):
+ self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
if self.ValueSize is not None:
width, height = self.ValueSize
if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
@@ -2063,7 +2065,7 @@
if self.EndConnected:
self.EndConnected.RefreshForced()
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
def SetValue(self, value):
if self.Value != value:
@@ -2077,16 +2079,13 @@
self.ToolTip.SetTip(self.ComputedValue)
if len(self.ComputedValue) > 4:
self.ComputedValue = self.ComputedValue[:4] + "..."
- if isinstance(self.ComputedValue, (StringType, UnicodeType)):
- self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
- else:
- self.ValueSize = None
+ self.ValueSize = None
if self.StartConnected:
self.StartConnected.RefreshValue()
if self.EndConnected:
self.EndConnected.RefreshValue()
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
if isinstance(value, BooleanType) and self.StartConnected is not None:
block = self.StartConnected.GetParentBlock()
block.SpreadCurrent()
@@ -3001,6 +3000,8 @@
if self.Value is not None and not isinstance(self.Value, BooleanType) and self.Value != "undefined":
dc.SetFont(self.Parent.GetMiniFont())
dc.SetTextForeground(wx.NamedColour("purple"))
+ if self.ValueSize is None and isinstance(self.ComputedValue, (StringType, UnicodeType)):
+ self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
if self.ValueSize is not None:
width, height = self.ValueSize
if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
--- a/graphics/LD_Objects.py Mon Jan 30 16:12:19 2012 +0100
+++ b/graphics/LD_Objects.py Tue Jan 31 13:38:06 2012 +0100
@@ -375,7 +375,7 @@
if self.Forced != forced:
self.Forced = forced
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
def SetValue(self, value):
if self.Type == CONTACT_RISING:
@@ -388,7 +388,7 @@
self.Value = value
if self.Value != self.PreviousValue or refresh:
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
self.SpreadCurrent()
def SpreadCurrent(self):
@@ -725,7 +725,7 @@
elif not self.Value and self.PreviousValue:
self.Output.SpreadCurrent(False)
if self.Value != self.PreviousValue and self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
# Make a clone of this LD_Coil
def Clone(self, parent, id = None, pos = None):
--- a/graphics/SFC_Objects.py Mon Jan 30 16:12:19 2012 +0100
+++ b/graphics/SFC_Objects.py Tue Jan 31 13:38:06 2012 +0100
@@ -77,14 +77,14 @@
if self.Forced != forced:
self.Forced = forced
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
def SetValue(self, value):
self.PreviousValue = self.Value
self.Value = value
if self.Value != self.PreviousValue:
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
self.SpreadCurrent()
def SpreadCurrent(self):
@@ -608,14 +608,14 @@
if self.Forced != forced:
self.Forced = forced
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
def SetValue(self, value):
self.PreviousValue = self.Value
self.Value = value
if self.Value != self.PreviousValue:
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
self.SpreadCurrent()
def SpreadCurrent(self):
@@ -1077,12 +1077,12 @@
self.Value = False
if self.Value and not self.PreviousValue:
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
for output in self.Outputs:
output.SpreadCurrent(True)
elif not self.Value and self.PreviousValue:
if self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
for output in self.Outputs:
output.SpreadCurrent(False)
@@ -1517,7 +1517,7 @@
self.PreviousValue = self.Value
self.Value = self.Input.ReceivingCurrent()
if self.Value != self.PreviousValue and self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
# Make a clone of this SFC_Jump
def Clone(self, parent, id = None, pos = None):
@@ -1783,7 +1783,7 @@
self.PreviousValue = self.Value
self.Value = self.Input.ReceivingCurrent()
if self.Value != self.PreviousValue and self.Visible:
- self.Parent.UpdateRefreshRect(self.GetRedrawRect())
+ self.Parent.ElementNeedRefresh(self)
# Make a clone of this SFC_ActionBlock
def Clone(self, parent, id = None, pos = None):