forked from kant/BDENTAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBDENTAL_Props.py
234 lines (190 loc) · 6.18 KB
/
BDENTAL_Props.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import bpy
from os.path import abspath
from bpy.props import (
StringProperty,
IntProperty,
FloatProperty,
EnumProperty,
FloatVectorProperty,
BoolProperty,
)
def TresholdUpdateFunction(self, context):
BDENTAL_Props = context.scene.BDENTAL_Props
GpShader = BDENTAL_Props.GroupNodeName
Treshold = BDENTAL_Props.Treshold
CtVolumeList = [obj for obj in bpy.context.scene.objects if obj.name.startswith("BD") and obj.name.endswith("_CTVolume") ]
if context.object in CtVolumeList :
Vol = context.object
Preffix = Vol.name[:5]
GpNode = bpy.data.node_groups.get(f"{Preffix}_{GpShader}")
if GpShader == "VGS_Marcos_modified":
Low_Treshold = GpNode.nodes["Low_Treshold"].outputs[0]
Low_Treshold.default_value = Treshold
if GpShader == "VGS_Dakir_01":
DcmInfo = eval(BDENTAL_Props.DcmInfo)
Wmin = DcmInfo["Wmin"]
Wmax = DcmInfo["Wmax"]
treshramp = GpNode.nodes["TresholdRamp"].color_ramp.elements[0]
value = (Treshold-Wmin)/(Wmax-Wmin)
treshramp = value
class BDENTAL_Props(bpy.types.PropertyGroup):
#####################
#############################################################################################
# CT_Scan props :
#############################################################################################
#####################
UserProjectDir: StringProperty(
name="Project Directory Path",
default="",
description="Project Directory Path",
subtype="DIR_PATH",
)
#####################
UserDcmDir: StringProperty(
name="DICOM Path",
default="",
description="DICOM Directory Path",
subtype="DIR_PATH",
)
UserImageFile: StringProperty(
name="User 3D Image File Path",
default="",
description="User Image File Path",
subtype="FILE_PATH",
)
#####################
Data_Types = ["DICOM Series", "3D Image File", ""]
items = []
for i in range(len(Data_Types)):
item = (str(Data_Types[i]), str(Data_Types[i]), str(""), int(i))
items.append(item)
DataType: EnumProperty(items=items, description="Data type", default="DICOM Series")
#######################
DcmInfo: StringProperty(
name="(str) DicomInfo",
default="{}",
description="Dicom series files list",
)
#######################
PngDir: StringProperty(
name="Png Directory",
default="",
description=" PNG files Sequence Directory Path",
)
#######################
SlicesDir: StringProperty(
name="Slices Directory",
default="",
description="Slices PNG files Directory Path",
)
#######################
NrrdHuPath: StringProperty(
name="NrrdHuPath",
default="",
description="Nrrd image3D file Path",
)
Nrrd255Path: StringProperty(
name="Nrrd255Path",
default="",
description="Nrrd image3D file Path",
)
#######################
IcpVidDict: StringProperty(
name="IcpVidDict",
default="None",
description="ICP Vertices Pairs str(Dict)",
)
#######################
Wmin: IntProperty()
Wmax: IntProperty()
#######################
# SoftTissueMode = BoolProperty(description="SoftTissue Mode ", default=False)
GroupNodeName: StringProperty(
name="Group shader Name",
default="",
description="Group shader Name",
)
#######################
Treshold: IntProperty(
name="Treshold",
description="Volume Treshold",
default=600,
min=-400,
max=3000,
soft_min=-400,
soft_max=3000,
step=1,
update=TresholdUpdateFunction,
)
Progress_Bar: FloatProperty(
name="Progress_Bar",
description="Progress_Bar",
subtype="PERCENTAGE",
default=0.0,
min=0.0,
max=100.0,
soft_min=0.0,
soft_max=100.0,
step=1,
precision=1,
)
#######################
CT_Loaded: BoolProperty(description="CT loaded ", default=False)
CT_Rendered: BoolProperty(description="CT Rendered ", default=False)
sceneUpdate: BoolProperty(description="scene update ", default=True)
AlignModalState: BoolProperty(description="Align Modal state ", default=False)
#######################
#################################################################################################
# Registration :
#################################################################################################
classes = [
BDENTAL_Props,
]
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.BDENTAL_Props = bpy.props.PointerProperty(type=BDENTAL_Props)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
del bpy.types.Scene.BDENTAL_Props
# props examples :
# Axial_Loc: FloatVectorProperty(
# name="AXIAL location",
# description="AXIAL location",
# subtype="TRANSLATION",
# update=AxialSliceUpdate,
# )
# Axial_Rot: FloatVectorProperty(
# name="AXIAL Rotation",
# description="AXIAL Rotation",
# subtype="EULER",
# update=AxialSliceUpdate,
# )
################################################
# Str_Prop_Search_1: StringProperty(
# name="String Search Property 1",
# default="",
# description="Str_Prop_Search_1",
# )
# Float Props :
#########################################################################################
# F_Prop_1: FloatProperty(
# description="Float Property 1 ",
# default=0.0,
# min=-200.0,
# max=200.0,
# step=1,
# precision=1,
# unit="NONE",
# update=None,
# get=None,
# set=None,
# )
#########################################################################################
# # FloatVector Props :
# ##############################################
# FloatV_Prop_1: FloatVectorProperty(
# name="FloatVectorProperty 1", description="FloatVectorProperty 1", size=3
# )
#########################################################################################