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 2024-03-07 11:54 +0000

1import numpy as num 

2import vtk 

3 

4from .. import vtk_util 

5 

6 

7class Overlay(object): 

8 

9 def __init__(self): 

10 pass 

11 

12 def set_parent(self, parent): 

13 pass 

14 

15 def unset_parent(self): 

16 pass 

17 

18 def show(self): 

19 pass 

20 

21 def hide(self): 

22 pass 

23 

24 

25class TimeRangeOverlay(Overlay): 

26 

27 def __init__(self): 

28 self._tmin 

29 

30 def update_ranges(self, tmin, tmax, wmin, wmax): 

31 self._trange = tmin, tmax 

32 self._wrange = wmin, wmax 

33 

34 def update_size(self, renwin): 

35 

36 size_x, size_y = renwin.GetSize() 

37 cx = size_x / 2.0 

38 # cy = size_y / 2.0 

39 

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]]) 

45 

46 vpoints = vtk.vtkPoints() 

47 vpoints.SetNumberOfPoints(vertices.shape[0]) 

48 vpoints.SetData(vtk_util.numpy_to_vtk(vertices)) 

49 

50 faces = num.array([[0, 1, 2, 3]], dtype=num.int64) 

51 cells = vtk_util.faces_to_cells(faces) 

52 

53 pd = vtk.vtkPolyData() 

54 pd.SetPoints(vpoints) 

55 pd.SetLines(cells) 

56 

57 mapper = vtk.vtkPolyDataMapper2D() 

58 

59 vtk_util.vtk_set_input(mapper, pd) 

60 

61 act = vtk.vtkActor2D() 

62 act.SetMapper(mapper) 

63 

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() 

70 

71 self.ren.AddActor2D(act)