fix issue with printing scheme (FBD, LD or SFC) with comment element on GNU/Linux
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 13 Jan 2017 19:51:36 +0300
changeset 1631 940e20a8865b
parent 1630 f0030c3cd6ab
child 1632 6e1ea3451c23
fix issue with printing scheme (FBD, LD or SFC) with comment element on GNU/Linux

If you draw FBD scheme and place comment on it and then try to print
it, then no wires will be printed and comment box is empty (text is
missing). This happens only for wx.PrinterDC and not on wx.MemoryDC
that is used to draw print preview window in Beremiz IDE.
Looks like a bug in wxPython or wxWidgets.

There were found several workaround for this issue.
1) If some dc.DrawLines call is placed before dc.DrawPolygon, then the
problem is gone.

...
dc.DrawLines(polygon)
dc.DrawPolygon(polygon)
...

2) Reseting DC brush solves the problem as well (see this changeset).
graphics/GraphicCommons.py
--- a/graphics/GraphicCommons.py	Fri Jan 13 16:47:46 2017 +0300
+++ b/graphics/GraphicCommons.py	Fri Jan 13 19:51:36 2017 +0300
@@ -2895,10 +2895,15 @@
                    wx.Point(self.Pos.x + self.Size[0], self.Pos.y + self.Size[1]),
                    wx.Point(self.Pos.x, self.Pos.y + self.Size[1])]
         dc.DrawPolygon(polygon)
+
+        # dc.SetBrush call is workaround for the issue with wx.PrinterDC
+        # with wxPython 3.0 on GNU/Linux (don't remove it)
+        dc.SetBrush(wx.WHITE_BRUSH)
         lines = [wx.Point(self.Pos.x + self.Size[0] - 10, self.Pos.y),
                  wx.Point(self.Pos.x + self.Size[0] - 10, self.Pos.y + 10),
                  wx.Point(self.Pos.x + self.Size[0], self.Pos.y + 10)]
         dc.DrawLines(lines)
+
         # Draws the comment content
         y = self.Pos.y + 10
         for idx, line in enumerate(self.Content.splitlines()):