Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/gui/sparrow/overlays.py: 0%
42 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-06 15:01 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-06 15:01 +0000
1import numpy as num
2import vtk
4from .. import vtk_util
7class Overlay(object):
9 def __init__(self):
10 pass
12 def set_parent(self, parent):
13 pass
15 def unset_parent(self):
16 pass
18 def show(self):
19 pass
21 def hide(self):
22 pass
25class TimeRangeOverlay(Overlay):
27 def __init__(self):
28 self._tmin
30 def update_ranges(self, tmin, tmax, wmin, wmax):
31 self._trange = tmin, tmax
32 self._wrange = wmin, wmax
34 def update_size(self, renwin):
36 size_x, size_y = renwin.GetSize()
37 cx = size_x / 2.0
38 # cy = size_y / 2.0
40 vertices = num.array([
41 [cx - 100., cx - 100., 0.0],
42 [cx - 100., cx + 100., 0.0],
43 [cx + 100., cx + 100., 0.0],
44 [cx - 100., cx - 100., 0.0]])
46 vpoints = vtk.vtkPoints()
47 vpoints.SetNumberOfPoints(vertices.shape[0])
48 vpoints.SetData(vtk_util.numpy_to_vtk(vertices))
50 faces = num.array([[0, 1, 2, 3]], dtype=num.int64)
51 cells = vtk_util.faces_to_cells(faces)
53 pd = vtk.vtkPolyData()
54 pd.SetPoints(vpoints)
55 pd.SetLines(cells)
57 mapper = vtk.vtkPolyDataMapper2D()
59 vtk_util.vtk_set_input(mapper, pd)
61 act = vtk.vtkActor2D()
62 act.SetMapper(mapper)
64 prop = act.GetProperty()
65 prop.SetColor(1.0, 1.0, 1.0)
66 prop.SetOpacity(0.5)
67 prop.SetLineWidth(2.0)
68 print(type(prop), dir(prop))
69 # prop.EdgeVisibilityOn()
71 self.ren.AddActor2D(act)