MCPcopy Create free account
hub / github.com/Kitware/VTK / StringToPathContextTest

Class StringToPathContextTest

Rendering/Matplotlib/Testing/Python/TestStringToPath.py:44–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43#------------------------------------------------------------------------------
44class StringToPathContextTest(object):
45 def __init__(self):
46 self.Path = None
47
48 def SetPath(self, path):
49 self.Path = path
50
51 def Initialize(self, vtkSelf):
52 return True
53
54 def Paint(self, vtkSelf, painter):
55 # Paint event for the chart, called whenever the chart needs to be drawn
56 # This function aims to test the primitives provided by the 2D API.
57 # RGB color lookup table by path point code:
58 color = [(), (), (), ()]
59 color[vtkPath.MOVE_TO] = (1.0, 0.0, 0.0)
60 color[vtkPath.LINE_TO] = (0.0, 1.0, 0.0)
61 color[vtkPath.CONIC_CURVE] = (0.0, 0.0, 1.0)
62 color[vtkPath.CUBIC_CURVE] = (1.0, 0.0, 1.0)
63
64 points = self.Path.GetPoints()
65 codes = self.Path.GetCodes()
66
67 if points.GetNumberOfPoints() != codes.GetNumberOfTuples():
68 return False
69
70 # scaling factor and offset to ensure that the points will fit the view:
71 scale = 5.16591
72 offset = 20.0
73
74 # Draw the control points, colored by codes:
75 point = [0.0, 0.0, 0.0]
76 painter.GetPen().SetWidth(2)
77 for i in range(points.GetNumberOfPoints()):
78 points.GetPoint(i, point)
79 code = codes.GetValue(i)
80
81 painter.GetPen().SetColorF(color[code])
82 painter.DrawPoint(point[0] * scale + offset, point[1] * scale + offset)
83
84 return True
85
86#------------------------------------------------------------------------------
87# Set up a 2D context view, context test object and add it to the scene

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected