This function aims to test the primitives provided by the 2D API.
| 63 | |
| 64 | // This function aims to test the primitives provided by the 2D API. |
| 65 | bool StringToPathContextTest::Paint(vtkContext2D* painter) |
| 66 | { |
| 67 | // RGB color lookup table by path point code: |
| 68 | double color[4][3]; |
| 69 | color[vtkPath::MOVE_TO][0] = 1.0; |
| 70 | color[vtkPath::MOVE_TO][1] = 0.0; |
| 71 | color[vtkPath::MOVE_TO][2] = 0.0; |
| 72 | color[vtkPath::LINE_TO][0] = 0.0; |
| 73 | color[vtkPath::LINE_TO][1] = 1.0; |
| 74 | color[vtkPath::LINE_TO][2] = 0.0; |
| 75 | color[vtkPath::CONIC_CURVE][0] = 0.0; |
| 76 | color[vtkPath::CONIC_CURVE][1] = 0.0; |
| 77 | color[vtkPath::CONIC_CURVE][2] = 1.0; |
| 78 | color[vtkPath::CUBIC_CURVE][0] = 1.0; |
| 79 | color[vtkPath::CUBIC_CURVE][1] = 0.0; |
| 80 | color[vtkPath::CUBIC_CURVE][2] = 1.0; |
| 81 | |
| 82 | vtkPoints* points = this->Path->GetPoints(); |
| 83 | vtkIntArray* codes = this->Path->GetCodes(); |
| 84 | |
| 85 | if (points->GetNumberOfPoints() != codes->GetNumberOfTuples()) |
| 86 | { |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | // scaling factor and offset to ensure that the points will fit the view: |
| 91 | double scale = 5.16591; |
| 92 | double offset = 20.0; |
| 93 | |
| 94 | // Draw the control points, colored by codes: |
| 95 | double point[3]; |
| 96 | painter->GetPen()->SetWidth(2); |
| 97 | for (vtkIdType i = 0; i < points->GetNumberOfPoints(); ++i) |
| 98 | { |
| 99 | points->GetPoint(i, point); |
| 100 | int code = codes->GetValue(i); |
| 101 | |
| 102 | painter->GetPen()->SetColorF(color[code]); |
| 103 | painter->DrawPoint(point[0] * scale + offset, point[1] * scale + offset); |
| 104 | } |
| 105 | |
| 106 | return true; |
| 107 | } |
nothing calls this directly
no test coverage detected