graphics/GraphicCommons.py
branchpython3
changeset 3752 9f6f46dbe3ae
parent 3750 f62625418bff
child 3759 f713566d5d01
equal deleted inserted replaced
3751:a80a66ba52d6 3752:9f6f46dbe3ae
    21 # You should have received a copy of the GNU General Public License
    21 # You should have received a copy of the GNU General Public License
    22 # along with this program; if not, write to the Free Software
    22 # along with this program; if not, write to the Free Software
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 
    24 
    25 
    25 
    26 
       
    27 
       
    28 from math import *
    26 from math import *
    29 from future.builtins import round
       
    30 from six import string_types
       
    31 from six.moves import xrange
       
    32 
    27 
    33 import wx
    28 import wx
    34 from graphics.ToolTipProducer import ToolTipProducer
    29 from graphics.ToolTipProducer import ToolTipProducer
    35 from graphics.DebugDataConsumer import DebugDataConsumer
    30 from graphics.DebugDataConsumer import DebugDataConsumer
    36 
    31 
  1082             height = CONNECTOR_SIZE
  1077             height = CONNECTOR_SIZE
  1083             if self.Edge == "rising" and self.Direction[1] == 1:
  1078             if self.Edge == "rising" and self.Direction[1] == 1:
  1084                 y -= 5
  1079                 y -= 5
  1085                 height += 5
  1080                 height += 5
  1086         rect = wx.Rect(x - abs(movex), y - abs(movey), width + 2 * abs(movex), height + 2 * abs(movey))
  1081         rect = wx.Rect(x - abs(movex), y - abs(movey), width + 2 * abs(movex), height + 2 * abs(movey))
  1087         if self.ValueSize is None and isinstance(self.ComputedValue, string_types):
  1082         if self.ValueSize is None and isinstance(self.ComputedValue, str):
  1088             self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue)
  1083             self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue)
  1089         if self.ValueSize is not None:
  1084         if self.ValueSize is not None:
  1090             width, height = self.ValueSize
  1085             width, height = self.ValueSize
  1091             rect = rect.Union(
  1086             rect = rect.Union(
  1092                 wx.Rect(
  1087                 wx.Rect(
  1540             DrawHighlightedText(dc, self.Name, self.Highlights, xtext, ytext)
  1535             DrawHighlightedText(dc, self.Name, self.Highlights, xtext, ytext)
  1541 
  1536 
  1542         if self.Value is not None and not isinstance(self.Value, bool) and self.Value != "undefined":
  1537         if self.Value is not None and not isinstance(self.Value, bool) and self.Value != "undefined":
  1543             dc.SetFont(self.ParentBlock.Parent.GetMiniFont())
  1538             dc.SetFont(self.ParentBlock.Parent.GetMiniFont())
  1544             dc.SetTextForeground(wx.NamedColour("purple"))
  1539             dc.SetTextForeground(wx.NamedColour("purple"))
  1545             if self.ValueSize is None and isinstance(self.ComputedValue, string_types):
  1540             if self.ValueSize is None and isinstance(self.ComputedValue, str):
  1546                 self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue)
  1541                 self.ValueSize = self.ParentBlock.Parent.GetMiniTextExtent(self.ComputedValue)
  1547             if self.ValueSize is not None:
  1542             if self.ValueSize is not None:
  1548                 width, height = self.ValueSize
  1543                 width, height = self.ValueSize
  1549                 dc.DrawText(self.ComputedValue,
  1544                 dc.DrawText(self.ComputedValue,
  1550                             parent_pos[0] + self.Pos.x + CONNECTOR_SIZE * self.Direction[0] +
  1545                             parent_pos[0] + self.Pos.x + CONNECTOR_SIZE * self.Direction[0] +
  1608         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
  1603         rect = Graphic_Element.GetRedrawRect(self, movex, movey)
  1609         if self.StartConnected:
  1604         if self.StartConnected:
  1610             rect = rect.Union(self.StartConnected.GetRedrawRect(movex, movey))
  1605             rect = rect.Union(self.StartConnected.GetRedrawRect(movex, movey))
  1611         if self.EndConnected:
  1606         if self.EndConnected:
  1612             rect = rect.Union(self.EndConnected.GetRedrawRect(movex, movey))
  1607             rect = rect.Union(self.EndConnected.GetRedrawRect(movex, movey))
  1613         if self.ValueSize is None and isinstance(self.ComputedValue, string_types):
  1608         if self.ValueSize is None and isinstance(self.ComputedValue, str):
  1614             self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
  1609             self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
  1615         if self.ValueSize is not None:
  1610         if self.ValueSize is not None:
  1616             width, height = self.ValueSize
  1611             width, height = self.ValueSize
  1617             if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
  1612             if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
  1618                 x = self.Points[0].x + width * self.StartPoint[1][0] // 2
  1613                 x = self.Points[0].x + width * self.StartPoint[1][0] // 2
  2748             dc.DrawLine(self.Points[self.SelectedSegment].x - 1, self.Points[self.SelectedSegment].y,
  2743             dc.DrawLine(self.Points[self.SelectedSegment].x - 1, self.Points[self.SelectedSegment].y,
  2749                         self.Points[self.SelectedSegment + 1].x + end, self.Points[self.SelectedSegment + 1].y)
  2744                         self.Points[self.SelectedSegment + 1].x + end, self.Points[self.SelectedSegment + 1].y)
  2750         if self.Value is not None and not isinstance(self.Value, bool) and self.Value != "undefined":
  2745         if self.Value is not None and not isinstance(self.Value, bool) and self.Value != "undefined":
  2751             dc.SetFont(self.Parent.GetMiniFont())
  2746             dc.SetFont(self.Parent.GetMiniFont())
  2752             dc.SetTextForeground(wx.NamedColour("purple"))
  2747             dc.SetTextForeground(wx.NamedColour("purple"))
  2753             if self.ValueSize is None and isinstance(self.ComputedValue, string_types):
  2748             if self.ValueSize is None and isinstance(self.ComputedValue, str):
  2754                 self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
  2749                 self.ValueSize = self.Parent.GetMiniTextExtent(self.ComputedValue)
  2755             if self.ValueSize is not None:
  2750             if self.ValueSize is not None:
  2756                 width, height = self.ValueSize
  2751                 width, height = self.ValueSize
  2757                 if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
  2752                 if self.BoundingBox[2] > width * 4 or self.BoundingBox[3] > height * 4:
  2758                     x = self.Points[0].x + width * (self.StartPoint[1][0] - 1) // 2
  2753                     x = self.Points[0].x + width * (self.StartPoint[1][0] - 1) // 2