Cleanup: simplify file name incrementing logic
[blender-addons.git] / space_view3d_stored_views / __init__.py
blob6a174fdbfc286b23450e55db3045df0a1b0b6840
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 bl_info = {
20 "name": "Stored Views",
21 "description": "Save and restore User defined views, pov, layers and display configs",
22 "author": "nfloyd, Francesco Siddi",
23 "version": (0, 3, 7),
24 "blender": (2, 80, 0),
25 "location": "View3D > Sidebar > View > Stored Views",
26 "warning": "",
27 "doc_url": "{BLENDER_MANUAL_URL}/addons/3d_view/stored_views.html",
28 "category": "3D View"
31 """
32 ACKNOWLEDGMENT
33 ==============
34 import/export functionality is mostly based
35 on Bart Crouch's Theme Manager Addon
37 TODO: quadview complete support : investigate. Where's the data?
38 TODO: lock_camera_and_layers. investigate usage
39 TODO: list reordering
41 NOTE: logging setup has to be provided by the user in a separate config file
42 as Blender will not try to configure logging by default in an add-on
43 The Config File should be in the Blender Config folder > /scripts/startup/config_logging.py
44 For setting up /location of the config folder see:
45 https://docs.blender.org/manual/en/latest/getting_started/
46 installing/configuration/directories.html
47 For configuring logging itself in the file, general Python documentation should work
48 As the logging calls are not configured, they can be kept in the other modules of this add-on
49 and will not have output until the logging configuration is set up
50 """
52 # if "bpy" in locals():
53 # import importlib
54 # importlib.reload(core)
55 # importlib.reload(ui)
56 # importlib.reload(properties)
57 # importlib.reload(operators)
58 # importlib.reload(io)
59 # else:
60 import bpy
61 from . import core
62 from . import ui
63 from . import properties
64 from . import operators
65 from . import io
68 from bpy.props import (
69 BoolProperty,
70 IntProperty,
71 PointerProperty,
73 from bpy.types import (
74 AddonPreferences,
75 Operator,
79 class VIEW3D_stored_views_initialize(Operator):
80 bl_idname = "view3d.stored_views_initialize"
81 bl_label = "Initialize"
83 @classmethod
84 def poll(cls, context):
85 return not hasattr(bpy.types.Scene, 'stored_views')
87 def execute(self, context):
88 bpy.types.Scene.stored_views = PointerProperty(
89 type=properties.StoredViewsData
91 scenes = bpy.data.scenes
92 for scene in scenes:
93 core.DataStore.sanitize_data(scene)
94 return {'FINISHED'}
97 # Addon Preferences
99 class VIEW3D_stored_views_preferences(AddonPreferences):
100 bl_idname = __name__
102 show_exporters : BoolProperty(
103 name="Enable I/O Operators",
104 default=False,
105 description="Enable Import/Export Operations in the UI:\n"
106 "Import Stored Views preset,\n"
107 "Export Stored Views preset and \n"
108 "Import stored views from scene",
110 view_3d_update_rate : IntProperty(
111 name="3D view update",
112 description="Update rate of the 3D view redraw\n"
113 "Increse the value if the UI feels sluggish",
114 min=1, max=10,
115 default=1
118 def draw(self, context):
119 layout = self.layout
121 row = layout.row(align=True)
122 row.prop(self, "view_3d_update_rate", toggle=True)
123 row.prop(self, "show_exporters", toggle=True)
126 def register():
127 ui.register()
128 properties.register()
129 operators.register()
130 io.register()
131 bpy.utils.register_class(VIEW3D_stored_views_initialize)
132 bpy.utils.register_class(VIEW3D_stored_views_preferences)
135 def unregister():
136 ui.unregister()
137 properties.unregister()
138 operators.unregister()
139 io.unregister()
140 bpy.utils.unregister_class(VIEW3D_stored_views_initialize)
141 bpy.utils.unregister_class(VIEW3D_stored_views_preferences)
142 ui.VIEW3D_stored_views_draw.handle_remove(bpy.context)
143 if hasattr(bpy.types.Scene, "stored_views"):
144 del bpy.types.Scene.stored_views
147 if __name__ == "__main__":
148 register()