File headers: use SPDX license identifiers
[blender-addons.git] / space_view3d_stored_views / __init__.py
blob645c568f798d7d78ec00cd02d3a51fe3828b30d1
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 bl_info = {
4 "name": "Stored Views",
5 "description": "Save and restore User defined views, pov, layers and display configs",
6 "author": "nfloyd, Francesco Siddi",
7 "version": (0, 3, 7),
8 "blender": (2, 80, 0),
9 "location": "View3D > Sidebar > View > Stored Views",
10 "warning": "",
11 "doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/stored_views.html",
12 "category": "3D View"
15 """
16 ACKNOWLEDGMENT
17 ==============
18 import/export functionality is mostly based
19 on Bart Crouch's Theme Manager Addon
21 TODO: quadview complete support : investigate. Where's the data?
22 TODO: lock_camera_and_layers. investigate usage
23 TODO: list reordering
25 NOTE: logging setup has to be provided by the user in a separate config file
26 as Blender will not try to configure logging by default in an add-on
27 The Config File should be in the Blender Config folder > /scripts/startup/config_logging.py
28 For setting up /location of the config folder see:
29 https://docs.blender.org/manual/en/latest/getting_started/
30 installing/configuration/directories.html
31 For configuring logging itself in the file, general Python documentation should work
32 As the logging calls are not configured, they can be kept in the other modules of this add-on
33 and will not have output until the logging configuration is set up
34 """
36 # if "bpy" in locals():
37 # import importlib
38 # importlib.reload(core)
39 # importlib.reload(ui)
40 # importlib.reload(properties)
41 # importlib.reload(operators)
42 # importlib.reload(io)
43 # else:
44 import bpy
45 from . import core
46 from . import ui
47 from . import properties
48 from . import operators
49 from . import io
52 from bpy.props import (
53 BoolProperty,
54 IntProperty,
55 PointerProperty,
57 from bpy.types import (
58 AddonPreferences,
59 Operator,
63 class VIEW3D_stored_views_initialize(Operator):
64 bl_idname = "view3d.stored_views_initialize"
65 bl_label = "Initialize"
67 @classmethod
68 def poll(cls, context):
69 return not hasattr(bpy.types.Scene, 'stored_views')
71 def execute(self, context):
72 bpy.types.Scene.stored_views = PointerProperty(
73 type=properties.StoredViewsData
75 scenes = bpy.data.scenes
76 for scene in scenes:
77 core.DataStore.sanitize_data(scene)
78 return {'FINISHED'}
81 # Addon Preferences
83 class VIEW3D_stored_views_preferences(AddonPreferences):
84 bl_idname = __name__
86 show_exporters : BoolProperty(
87 name="Enable I/O Operators",
88 default=False,
89 description="Enable Import/Export Operations in the UI:\n"
90 "Import Stored Views preset,\n"
91 "Export Stored Views preset and \n"
92 "Import stored views from scene",
94 view_3d_update_rate : IntProperty(
95 name="3D view update",
96 description="Update rate of the 3D view redraw\n"
97 "Increase the value if the UI feels sluggish",
98 min=1, max=10,
99 default=1
102 def draw(self, context):
103 layout = self.layout
105 row = layout.row(align=True)
106 row.prop(self, "view_3d_update_rate", toggle=True)
107 row.prop(self, "show_exporters", toggle=True)
110 def register():
111 ui.register()
112 properties.register()
113 operators.register()
114 io.register()
115 bpy.utils.register_class(VIEW3D_stored_views_initialize)
116 bpy.utils.register_class(VIEW3D_stored_views_preferences)
119 def unregister():
120 ui.unregister()
121 properties.unregister()
122 operators.unregister()
123 io.unregister()
124 bpy.utils.unregister_class(VIEW3D_stored_views_initialize)
125 bpy.utils.unregister_class(VIEW3D_stored_views_preferences)
126 ui.VIEW3D_stored_views_draw.handle_remove(bpy.context)
127 if hasattr(bpy.types.Scene, "stored_views"):
128 del bpy.types.Scene.stored_views
131 if __name__ == "__main__":
132 register()