--- a/Viewer.py Fri Sep 30 17:16:02 2011 +0200
+++ b/Viewer.py Sun Oct 09 19:51:14 2011 +0200
@@ -77,7 +77,6 @@
ZOOM_FACTORS = [math.sqrt(2) ** x for x in xrange(-6, 7)]
-
def GetVariableCreationFunction(variable_type):
def variableCreationFunction(viewer, id, specific_values):
return FBD_Variable(viewer, variable_type,
@@ -466,7 +465,7 @@
self.DrawingWire = False
self.current_id = 0
self.TagName = tagname
- self.Errors = []
+ self.Highlights = []
self.InstancePath = instancepath
self.StartMousePos = None
self.StartScreenPos = None
@@ -507,6 +506,9 @@
self.SetScale(len(ZOOM_FACTORS) / 2)
+ self.RefreshHighlightsTimer = wx.Timer(self, -1)
+ self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer)
+
self.ResetView()
# Link Viewer event to corresponding methods
@@ -526,6 +528,10 @@
self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheelWindow)
self.Bind(wx.EVT_SIZE, self.OnMoveWindow)
+ def __del__(self):
+ DebugViewer.__del__(self)
+ self.RefreshHighlightsTimer.Stop()
+
def SetCurrentCursor(self, cursor):
global CURSORS
if self.CurrentCursor != cursor:
@@ -839,7 +845,7 @@
self.Inhibit(False)
self.RefreshVisibleElements()
- self.ShowErrors()
+ self.ShowHighlights()
self.Refresh(False)
def GetPreviousSteps(self, connectors):
@@ -1848,6 +1854,7 @@
dialog = wx.TextEntryDialog(self.ParentWindow, _("Edit comment"), _("Please enter comment text"), "", wx.OK|wx.CANCEL|wx.TE_MULTILINE)
else:
dialog = wx.TextEntryDialog(self.ParentWindow, _("Edit comment"), _("Please enter comment text"), "", wx.OK|wx.CANCEL)
+ dialog.SetClientSize(wx.Size(400, 200))
if dialog.ShowModal() == wx.ID_OK:
value = dialog.GetValue()
id = self.GetNewId()
@@ -2349,6 +2356,7 @@
dialog = wx.TextEntryDialog(self.ParentWindow, _("Edit comment"), _("Please enter comment text"), comment.GetContent(), wx.OK|wx.CANCEL|wx.TE_MULTILINE)
else:
dialog = wx.TextEntryDialog(self.ParentWindow, _("Edit comment"), _("Please enter comment text"), comment.GetContent(), wx.OK|wx.CANCEL)
+ dialog.SetClientSize(wx.Size(400, 200))
if dialog.ShowModal() == wx.ID_OK:
value = dialog.GetValue()
rect = comment.GetRedrawRect(1, 1)
@@ -2747,22 +2755,30 @@
#-------------------------------------------------------------------------------
-# Errors showing functions
-#-------------------------------------------------------------------------------
-
- def ClearErrors(self):
- self.Errors = []
+# Highlights showing functions
+#-------------------------------------------------------------------------------
+
+ def OnRefreshHighlightsTimer(self, event):
self.RefreshView()
-
- def AddShownError(self, infos, start, end):
- self.Errors.append((infos, start, end))
-
- def ShowErrors(self):
- for infos, start, end in self.Errors:
- if infos[0] in ["io_variable", "block", "coil", "contact", "transition", "step", "action_block"]:
+ event.Skip()
+
+ def ClearHighlights(self, highlight_type=None):
+ if highlight_type is None:
+ self.Highlights = []
+ else:
+ self.Highlights = [(infos, start, end, highlight) for (infos, start, end, highlight) in self.Highlights if highlight != highlight_type]
+ self.RefreshView()
+
+ def AddHighlight(self, infos, start, end, highlight_type):
+ self.Highlights.append((infos, start, end, highlight_type))
+ self.RefreshHighlightsTimer.Start(int(REFRESH_HIGHLIGHT_PERIOD * 1000), oneShot=True)
+
+ def ShowHighlights(self):
+ for infos, start, end, highlight_type in self.Highlights:
+ if infos[0] in ["comment", "io_variable", "block", "connector", "coil", "contact", "step", "transition", "jump", "action_block"]:
block = self.FindElementById(infos[1])
if block is not None:
- block.AddError(infos[2:], start, end)
+ block.AddHighlight(infos[2:], start, end, highlight_type)
#-------------------------------------------------------------------------------
# Drawing functions