Cleanup: strip trailing space
[blender-addons.git] / amaranth / scene / stats.py
blob0cae37bee04139b1777a996631bca4f5e7c5913c
1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 """
6 Scene, Cameras, and Meshlights Count
8 Increase the stats by displaying the number of scenes, cameras, and light
9 emitting meshes.
10 On the Info header.
11 """
13 import bpy
14 from amaranth import utils
17 def stats_scene(self, context):
18 get_addon = "amaranth" in context.preferences.addons.keys()
19 if not get_addon:
20 return
22 if context.preferences.addons["amaranth"].preferences.use_scene_stats:
23 scenes_count = str(len(bpy.data.scenes))
24 cameras_count = str(len(bpy.data.cameras))
25 cameras_selected = 0
26 meshlights = 0
27 meshlights_visible = 0
29 for ob in context.scene.objects:
30 if utils.cycles_is_emission(context, ob):
31 meshlights += 1
32 if ob in context.visible_objects:
33 meshlights_visible += 1
35 if ob in context.selected_objects:
36 if ob.type == 'CAMERA':
37 cameras_selected += 1
39 meshlights_string = '| Meshlights:{}/{}'.format(
40 meshlights_visible, meshlights)
42 row = self.layout.row(align=True)
43 row.label(text="Scenes:{} | Cameras:{}/{} {}".format(
44 scenes_count, cameras_selected, cameras_count,
45 meshlights_string if utils.cycles_active(context) else ''))
48 def register():
49 bpy.types.STATUSBAR_HT_header.append(stats_scene)
52 def unregister():
53 bpy.types.STATUSBAR_HT_header.remove(stats_scene)