forked from appleseedhq/blenderseed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preferences.py
131 lines (97 loc) · 4.83 KB
/
preferences.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#
# This source file is part of appleseed.
# Visit https://appleseedhq.net/ for additional information and resources.
#
# This software is released under the MIT license.
#
# Copyright (c) 2014-2018 The appleseedhq Organization
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
import bpy
import appleseed as asr
path_added = False
def updated_path(self, context):
global path_added
path_added = True
class AppleseedSearchPath(bpy.types.PropertyGroup):
name: bpy.props.StringProperty(name="name",
subtype="DIR_PATH",
update=updated_path)
class ASS_UL_SearchPathList(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
search_path = item.name
if 'DEFAULT' in self.layout_type:
layout.label(text=search_path, translate=False, icon_value=icon)
class AppleseedPreferencesPanel(bpy.types.AddonPreferences):
bl_idname = __package__
def update_logger(self, context):
from .logger import set_logger_level
set_logger_level(self.log_level)
log_level: bpy.props.EnumProperty(name="log_level",
items=[('debug', "Debug", ""),
('warning', "Warning", ""),
('error', "Error", ""),
('critical', "Critical", "")],
default='error',
description="This determines what types of log messages are generated by blenderseed activities",
update=update_logger)
curve_resolution: bpy.props.IntProperty(name="curve_resolution",
default=256,
description="Determines the number of steps used to interpolate parameter curves")
search_paths: bpy.props.CollectionProperty(type=AppleseedSearchPath,
name="search_paths")
path_index: bpy.props.IntProperty(name="path_index",
description="",
default=0)
def draw(self, context):
layout = self.layout
layout.prop(self, "curve_resolution", text="Curve Interpolation Resolution")
layout.separator()
layout.prop(self, "log_level", text="Log Level")
layout.separator()
layout.label(text="Resource Search Paths")
row = layout.row()
row.template_list("ASS_UL_SearchPathList", "", self,
"search_paths", self, "path_index", rows=1, maxrows=16, type="DEFAULT")
row = layout.row(align=True)
row.operator("appleseed.add_search_path", text="Add Search Path", icon="ADD")
row.operator("appleseed.remove_search_path", text="Remove Search Path", icon="REMOVE")
if self.search_paths:
current_set = self.search_paths[self.path_index]
layout.prop(current_set, "name", text="Filepath")
global path_added
if path_added is True:
layout.label(text="Changes to search paths will take effect upon restarting Blender", icon="ERROR")
layout.separator()
layout.label(text="appleseed Library Versions:")
box = layout.box()
box.label(text=asr.get_synthetic_version_string())
lib_info = asr.get_third_parties_versions()
for key, item in lib_info.items():
box.label(text=f"{key} version {item}")
classes = (AppleseedSearchPath,
ASS_UL_SearchPathList,
AppleseedPreferencesPanel)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)