Test if line plots can be built with python
(self)
| 12 | |
| 13 | class TestLinePlot(vtkmodules.test.Testing.vtkTest): |
| 14 | def testLinePlot(self): |
| 15 | "Test if line plots can be built with python" |
| 16 | |
| 17 | # Set up a 2D scene, add an XY chart to it |
| 18 | view = vtkContextView() |
| 19 | view.GetRenderer().SetBackground(1.0,1.0,1.0) |
| 20 | view.GetRenderWindow().SetSize(400,300) |
| 21 | chart = vtkChartXY() |
| 22 | view.GetScene().AddItem(chart) |
| 23 | |
| 24 | # Create a table with some points in it |
| 25 | table = vtkTable() |
| 26 | |
| 27 | arrX = vtkFloatArray() |
| 28 | arrX.SetName("X Axis") |
| 29 | |
| 30 | arrC = vtkFloatArray() |
| 31 | arrC.SetName("Cosine") |
| 32 | |
| 33 | arrS = vtkFloatArray() |
| 34 | arrS.SetName("Sine") |
| 35 | |
| 36 | arrS2 = vtkFloatArray() |
| 37 | arrS2.SetName("Sine2") |
| 38 | |
| 39 | numPoints = 69 |
| 40 | inc = 7.5 / (numPoints - 1) |
| 41 | |
| 42 | for i in range(0,numPoints): |
| 43 | arrX.InsertNextValue(i*inc) |
| 44 | arrC.InsertNextValue(math.cos(i * inc) + 0.0) |
| 45 | arrS.InsertNextValue(math.sin(i * inc) + 0.0) |
| 46 | arrS2.InsertNextValue(math.sin(i * inc) + 0.5) |
| 47 | |
| 48 | table.AddColumn(arrX) |
| 49 | table.AddColumn(arrC) |
| 50 | table.AddColumn(arrS) |
| 51 | table.AddColumn(arrS2) |
| 52 | |
| 53 | # Now add the line plots with appropriate colors |
| 54 | line = chart.AddPlot(0) |
| 55 | line.SetInputData(table,0,1) |
| 56 | line.SetColor(0,255,0,255) |
| 57 | line.SetWidth(1.0) |
| 58 | |
| 59 | line = chart.AddPlot(0) |
| 60 | line.SetInputData(table,0,2) |
| 61 | line.SetColor(255,0,0,255) |
| 62 | line.SetWidth(5.0) |
| 63 | |
| 64 | line = chart.AddPlot(0) |
| 65 | line.SetInputData(table,0,3) |
| 66 | line.SetColor(0,0,255,255) |
| 67 | line.SetWidth(4.0) |
| 68 | |
| 69 | view.GetRenderWindow().SetMultiSamples(0) |
| 70 | view.GetRenderWindow().Render() |
| 71 |
nothing calls this directly
no test coverage detected