Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/gui/sparrow/light.py: 95%

21 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2024-03-07 11:54 +0000

1from pyrocko.plot import mpl_color 

2from pyrocko import icosphere 

3import vtk 

4 

5 

6tetra, _ = icosphere.tetrahedron() 

7tetra *= -1.0 

8 

9lighting_themes = [ 

10 ('workbench', [ 

11 ((0.7, 0.6, 0.5), (-1.0, 1.0, 1.0)), 

12 ((0.7, 0.6, 0.5), (0.0, 0.0, 1.0))]), 

13 ('desk', [ 

14 ((1.0, 0.9, 0.8), (-1.0, 1.0, 1.0))]), 

15 ('interrogation', [ 

16 ((1.0, 1.0, 1.0), (0.0, 0.0, 1.0))]), 

17 ('morning', [ 

18 ((1.0, 0.9, 0.8), (1.0, 0.0, 0.0))]), 

19 ('forenoon', [ 

20 ((1.0, 0.9, 0.8), (1.0, 0.0, 1.0))]), 

21 ('afternoon', [ 

22 ((1.0, 0.9, 0.8), (-1.0, 0.0, 1.0))]), 

23 ('evening', [ 

24 ((1.0, 0.8, 0.7), (-1.0, 0.0, 0.0))]), 

25 ('warm', [ 

26 ((1., 1., 0.69), tetra[0, :]), 

27 ((1., 0.53, 0.0), tetra[1, :]), 

28 ((0.53, 0.53, 0.37), tetra[2, :])]), 

29 ('tilda', [ 

30 ((1., 0.5, 0.5), tetra[0, :]), 

31 ((0.5, 1.0, 1.0), tetra[1, :]), 

32 ((1., 0.5, 0.5), tetra[2, :])]), 

33 ('disco', [ 

34 (mpl_color('scarletred1'), tetra[0, :]), 

35 (mpl_color('skyblue1'), tetra[1, :]), 

36 (mpl_color('orange1'), tetra[2, :])])] 

37 

38lighting_themes_d = dict(lighting_themes) 

39 

40 

41def get_lighting_theme(theme): 

42 # also check for user defined? 

43 return lighting_themes_d[theme] 

44 

45 

46def get_lighting_theme_names(): 

47 return [name for (name, _) in lighting_themes] 

48 

49 

50def get_lights(theme): 

51 lights = [] 

52 for color, position in lighting_themes_d[theme]: 

53 light = vtk.vtkLight() 

54 light.SetColor(*color) 

55 light.SetPosition(*position) 

56 light.SetFocalPoint(0., 0., 0.) 

57 light.SetLightTypeToCameraLight() 

58 lights.append(light) 

59 

60 return lights