-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.py
199 lines (167 loc) · 7.21 KB
/
ui.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
import bpy
import bpy.utils.previews
import os
from bpy.types import Panel
# ############################################################
# User interface definition
# ############################################################
class EvertimsUIBase:
bl_category = "Evertims"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
@classmethod
def poll(cls, context):
return True
class VIEW3D_PT_EvertimsToolBar(EvertimsUIBase, Panel):
bl_label = "Evertims"
def draw(self, context):
# get locals
layout = self.layout
scene = context.scene
evertims = scene.evertims
addon_prefs = context.preferences.addons[__package__].preferences
# Network configuration
box = layout.box()
box.enabled = not evertims.enable_auralization
box.label(text="Network", icon='URL')
#
rowsub = box.row(align=True)
rowsub.label(text="Remote Address")
rowsub = box.row(align=True)
split = rowsub.split(factor=0.6)
colsub = split.column()
colsub.prop(evertims, "ip_remote", text="")
colsub = split.column()
colsub.prop(evertims, "port_write", text="")
#
rowsub = box.row(align=True)
rowsub.label(text="Local Address")
rowsub = box.row(align=True)
split = rowsub.split(factor=0.6)
colsub = split.column()
colsub.prop(evertims, "ip_local", text="")
colsub = split.column()
colsub.prop(evertims, "port_read", text="")
# Engine configuration
box = layout.box()
box.enabled = not evertims.enable_auralization
box.label(text="Engine Configuration", icon='PREFERENCES')
#
rowsub = box.row(align=True)
rowsub.prop(evertims, "engine_type", expand=False)
rowsub = box.row(align=True)
rowsub.prop(evertims, "ism_max_order", text="Order Max")
rowsub = box.row(align=True)
rowsub.prop(evertims, "sound_velocity", text="Sound Velocity (m/s)")
rowsub = box.row(align=True)
rowsub.prop(evertims, "air_absorption", text="Air Absorption")
#
rowsub = box.row(align=True)
rowsub.label(text="Update Throttle:")
rowsub = box.row(align=True)
split = rowsub.split(factor=0.5)
colsub = split.column()
colsub.prop(evertims, "update_thresh_loc", text="Loc (m)")
colsub = split.column()
colsub.prop(evertims, "update_thresh_rot", text="Rot (deg)")
rowsub = box.row(align=True)
rowsub.prop(evertims, "update_thresh_time", text="Time (sec)")
#
rowsub = box.row(align=True)
rowsub.prop(addon_prefs, "material_file_path", text="Material File")
rowsub = box.row(align=True)
rowsub.operator("evertims.import", text="Import Materials", icon="IMPORT").arg = 'materials'
# Import elements
# box = layout.box()
# box.label(text="Import elements", icon='GROUP')
# rowsub = box.row(align=True)
# rowsub.operator("evertims.import_template", text="Template scene", icon='MESH_CUBE').arg = 'scene'
# Define scene objects as evertims elements
box = layout.box()
box.enabled = not evertims.enable_auralization
box.label(text="Scene Components", icon='SCENE_DATA')
#
col = box.column(align=True)
col.prop_search(evertims, "room_group", bpy.data, "collections")
col = box.column(align=True)
col.prop_search(evertims, "listener_object", bpy.data, "objects")
col = box.column(align=True)
col.prop_search(evertims, "source_object", bpy.data, "objects")
# Source directivity
self.drawSourceDirectivity(context)
# Auralization run
box = layout.box()
box.label(text="Auralization", icon='PARTICLE_DATA')
#
rowsub = box.row(align=True)
rowsub.enabled = not evertims.enable_auralization
split = rowsub.split(factor=0.5)
colsub = split.column()
colsub.prop(evertims, "draw_rays", text="Draw Paths")
colsub = split.column()
colsub.prop(evertims, "draw_order_max", text="Draw Order Max")
colsub.enabled = not evertims.enable_auralization
#
rowsub = box.row(align=True)
rowsub.prop(evertims, "debug_logs", text="Print Logs To Console")
rowsub.enabled = not evertims.enable_auralization
#
rowsub = box.row(align=True)
rowsub.alignment = 'CENTER'
rowsub.label(text="(Avoid using undo during auralization)")
rowsub = box.row(align=True)
if not evertims.enable_auralization:
rowsub.operator("evertims.run", text="Start", icon="RADIOBUT_OFF").arg = 'start'
else:
rowsub.operator("evertims.run", text="Stop", icon="REC").arg = 'stop'
# Exporter
box = layout.box()
box.label(text="Export", icon='EXPORT')
#
# export scene to disk (.txt) as list of osc messages
rowsub = box.row(align=True)
rowsub.enabled = not evertims.enable_auralization
rowsub.prop(evertims, "export_file_path", text="Export File")
rowsub = box.row(align=True)
rowsub.enabled = not evertims.enable_auralization
rowsub.operator("evertims.export", text="Export Scene To Disk", icon="EXPORT")
# crystalize acoustic rays in scene as curves
rowsub = box.row(align=True)
rowsub.enabled = evertims.enable_auralization
rowsub.operator("evertims.run", text="Solidify Visible Paths", icon="STRANDS").arg = 'solidify'
def drawSourceDirectivity(self, context):
# get locals
layout = self.layout
scene = context.scene
evertims = scene.evertims
# header
box = layout.box()
box.enabled = not evertims.enable_auralization
box.label(text="Source directivity", icon='MOD_CAST')
# add umenu to directivity type enum
rowsub = box.row(align=True)
rowsub.prop(evertims, "source_directivity_type", expand=False, text="Type")
# discard if source directivity disabled
if evertims.source_directivity_type == "disabled":
return
# # display directivity values (all vector at once)
# colsub = box.column(align=True)
# colsub.prop(evertims, "source_directivity_values", text="Selectivity coefficients")
# display directivity values (with freq values beside)
colsub = box.column(align=True)
for iFreq in range(0, len(evertims.source_directivity_frequencies)):
# get freq string (Hz / kHz)
freq = evertims.source_directivity_frequencies[iFreq]
if( freq >= 1000 ): freq = str(round(freq/1000)) + "kHz"
else: freq = str(freq) + "Hz"
# create new row, populate it
rowsub = colsub.row(align=True)
rowsub.label(text=freq)
rowsub.prop(evertims, 'source_directivity_values', index = iFreq, text="")
# ############################################################
# Register / Unregister
# ############################################################
def register():
bpy.utils.register_class(VIEW3D_PT_EvertimsToolBar)
def unregister():
bpy.utils.unregister_class(VIEW3D_PT_EvertimsToolBar)