forked from nortikin/sverchok
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
217 lines (168 loc) · 6.76 KB
/
settings.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import bpy
from bpy.types import AddonPreferences
from bpy.props import BoolProperty, FloatVectorProperty, EnumProperty
from sverchok import data_structure
from sverchok.core import handlers
from sverchok.core import update_system
from sverchok.utils import sv_panels_tools
from sverchok.ui import color_def
class SverchokPreferences(AddonPreferences):
bl_idname = __package__
def update_debug_mode(self, context):
data_structure.DEBUG_MODE = self.show_debug
def update_heat_map(self, context):
data_structure.heat_map_state(self.heat_map)
def set_frame_change(self, context):
handlers.set_frame_change(self.frame_change_mode)
def update_theme(self, context):
color_def.rebuild_color_cache()
if self.auto_apply_theme:
color_def.apply_theme()
# debugish...
show_debug = BoolProperty(
name="Print update timings",
description="Print update timings in console",
default=False, subtype='NONE',
update=update_debug_mode)
no_data_color = FloatVectorProperty(
name="No data", description='When a node can not get data',
size=3, min=0.0, max=1.0,
default=(1, 0.3, 0), subtype='COLOR',
update=update_system.update_error_colors)
exception_color = FloatVectorProperty(
name="Error", description='When node has an exception',
size=3, min=0.0, max=1.0,
default=(0.8, 0.0, 0), subtype='COLOR',
update=update_system.update_error_colors)
# heat map settings
heat_map = BoolProperty(
name="Heat map",
description="Color nodes according to time",
default=False, subtype='NONE',
update=update_heat_map)
heat_map_hot = FloatVectorProperty(
name="Heat map hot", description='',
size=3, min=0.0, max=1.0,
default=(.8, 0, 0), subtype='COLOR')
heat_map_cold = FloatVectorProperty(
name="Heat map cold", description='',
size=3, min=0.0, max=1.0,
default=(1, 1, 1), subtype='COLOR')
# theme settings
sv_theme = EnumProperty(
items=color_def.themes,
name="Theme preset",
description="Select a theme preset",
update=color_def.color_callback,
default="default_theme")
auto_apply_theme = BoolProperty(
name="Apply theme", description="Apply theme automaticlly",
default=False)
apply_theme_on_open = BoolProperty(
name="Apply theme", description="Apply theme automaticlly",
default=False)
color_viz = FloatVectorProperty(
name="Visualization", description='',
size=3, min=0.0, max=1.0,
default=(1, 0.3, 0), subtype='COLOR',
update=update_theme)
color_tex = FloatVectorProperty(
name="Text", description='',
size=3, min=0.0, max=1.0,
default=(0.5, 0.5, 1), subtype='COLOR',
update=update_theme)
color_sce = FloatVectorProperty(
name="Scene", description='',
size=3, min=0.0, max=1.0,
default=(0, 0.5, 0.2), subtype='COLOR',
update=update_theme)
color_lay = FloatVectorProperty(
name="Layout", description='',
size=3, min=0.0, max=1.0,
default=(0.674, 0.242, 0.363), subtype='COLOR',
update=update_theme)
color_gen = FloatVectorProperty(
name="Generator", description='',
size=3, min=0.0, max=1.0,
default=(0, 0.5, 0.5), subtype='COLOR',
update=update_theme)
# frame change
frame_change_modes = [
("PRE", "Pre", "Update Sverchok before frame change", 0),
("POST", "Post", "Update Sverchok after frame change", 1),
("NONE", "None", "Sverchok doesn't update on frame change", 2)
]
frame_change_mode = EnumProperty(
items=frame_change_modes,
name="Frame change",
description="Select frame change handler",
default="POST",
update=set_frame_change)
# ctrl+space settings
show_icons = BoolProperty(
name="Show icons in ctrl+space menu",
default=False,
description="Use icons in ctrl+space menu")
over_sized_buttons = BoolProperty(default=False, name="Big buttons",
description="Very big buttons")
enable_live_objin = BoolProperty(
description="Objects in edit mode will be updated in object-in Node")
def draw(self, context):
layout = self.layout
# row = layout.split(percentage=0.33)
row = layout
col = row.column(align=True)
col.label(text="General:")
col.label(text="Frame change handler:")
row1 = col.row()
row1.prop(self, "frame_change_mode", expand=True)
col.prop(self, "show_icons")
col.prop(self, "over_sized_buttons")
col.prop(self, "enable_live_objin", text='Enable Live Object-In')
col.separator()
col.label(text="Sverchok node theme settings")
row2 = col.row()
row2.prop(self, 'auto_apply_theme', text="Auto apply theme changes")
row2.prop(self, 'apply_theme_on_open', text="Apply theme when opening file")
row2.operator('node.sverchok_apply_theme', text="Apply theme to layouts")
col1 = col.split(percentage=.5, align=True)
col1.prop(self, 'sv_theme')
col.separator()
split = col.split(percentage=0.5, align=True)
col1 = split.column()
for name in ['color_viz', 'color_tex', 'color_sce']:
r = col1.row()
r.prop(self, name)
col2 = split.column()
for name in ['color_lay', 'color_gen']:
r = col2.row()
r.prop(self, name)
# debug
col = row.column(align=True)
col.label(text="Debug:")
col.prop(self, "show_debug")
col.label("Error colors")
row1 = col.row()
row1.prop(self, "exception_color")
row1.prop(self, "no_data_color")
col.prop(self, "heat_map")
row1 = col.row()
row1.active = self.heat_map
row1.prop(self, "heat_map_hot")
row1.prop(self, "heat_map_cold")
col = row.column(align=True)
col.label(text="Links:")
row1 = col.row(align=True)
row1.scale_y = 2.0
row1.operator('wm.url_open', text='Sverchok home page').url = 'http://nikitron.cc.ua/blend_scripts.html'
row1.operator('wm.url_open', text='Documentation').url = 'http://nikitron.cc.ua/sverch/html/main.html'
if context.scene.sv_new_version:
row1.operator('node.sverchok_update_addon', text='Upgrade Sverchok addon')
else:
row1.operator('node.sverchok_check_for_upgrades', text='Check for new version')
def register():
bpy.utils.register_class(SverchokPreferences)
def unregister():
bpy.utils.unregister_class(SverchokPreferences)
if __name__ == '__main__':
register()