forked from kant/BDENTAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBDENTAL_Panel.py
248 lines (196 loc) · 8.33 KB
/
BDENTAL_Panel.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import bpy
# Selected icons :
red_icon = "COLORSET_01_VEC"
orange_icon = "COLORSET_02_VEC"
green_icon = "COLORSET_03_VEC"
blue_icon = "COLORSET_04_VEC"
violet_icon = "COLORSET_06_VEC"
yellow_icon = "COLORSET_09_VEC"
yellow_point = "KEYTYPE_KEYFRAME_VEC"
blue_point = "KEYTYPE_BREAKDOWN_VEC"
Wmin, Wmax = -400, 3000
####################################################################
# // CUTTING TOOLS PANEL //
####################################################################
class BDENTAL_PT_SCAN_VIEWER(bpy.types.Panel):
""" BLENDER DENTAL SCAN VIEWER"""
bl_idname = "BDENTAL_PT_SCAN_VIEWER"
bl_space_type = "VIEW_3D"
bl_region_type = "UI" # blender 2.7 and lower = TOOLS
bl_category = "BDENT"
bl_label = "BDENTAL SCAN VIEWER"
# bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
# Model operation property group :
BDENTAL_Props = context.scene.BDENTAL_Props
GroupNodeName = BDENTAL_Props.GroupNodeName
VGS = bpy.data.node_groups.get(GroupNodeName)
# Draw Addon UI :
layout = self.layout
# row = layout.row()
# row.operator("bdental.addplanes", icon="COLORSET_03_VEC")
row = layout.row()
row.prop(BDENTAL_Props, "UserProjectDir", text="Project Directory")
if BDENTAL_Props.UserProjectDir:
row = layout.row()
row.prop(BDENTAL_Props, "DataType")
if BDENTAL_Props.DataType == "DICOM Series":
row = layout.row()
row.prop(BDENTAL_Props, "UserDcmDir", text="DICOM Folder")
if BDENTAL_Props.UserDcmDir:
Box = layout.box()
Box.alert = True
row = Box.row()
row.alignment = "CENTER"
row.scale_y = 2
row.operator(
"bdental.volume_render", icon="IMPORT"
)
row = layout.row()
row.label(text=f"Threshold {Wmin} to {Wmax} HU:")
row = layout.row()
row.prop(
BDENTAL_Props, "Treshold", text="TRESHOLD", slider=True
)
row = layout.row()
row.operator("bdental.tresh_segment")
row = layout.row()
row.operator("bdental.addslices", icon="EMPTY_AXIS")
if BDENTAL_Props.DataType == "3D Image File":
row = layout.row()
row.prop(BDENTAL_Props, "UserImageFile", text="File Path")
if BDENTAL_Props.UserImageFile:
row = layout.row()
row.alignment = "CENTER"
row.scale_y = 2
row.operator(
"bdental.volume_render",icon=violet_icon
)
row = layout.row()
row.label(text=f"TRESHOLD {Wmin}/{Wmax} :")
row.operator("bdental.tresholdupdate")
row = layout.row()
row.prop(
BDENTAL_Props, "Treshold", text="TRESHOLD", slider=True
)
row = layout.row()
row.operator("bdental.tresh_segment")
row = layout.row()
row.operator("bdental.addslices", icon="EMPTY_AXIS")
# class BDENTAL_PT_AlignPanel(bpy.types.Panel):
# """ BLENDER DENTAL SCAN VIEWER"""
# bl_idname = "BDENTAL_PT_AlignPanel"
# bl_space_type = "VIEW_3D"
# bl_region_type = "UI" # blender 2.7 and lower = TOOLS
# bl_category = "BDENT"
# bl_label = "BDENTAL ALIGN TOOLS :"
# bl_options = {"DEFAULT_CLOSED"}
# def draw(self, context):
# BDENTAL_Props = context.scene.BDENTAL_Props
# AlignModalState = BDENTAL_Props.AlignModalState
# layout = self.layout
# row = layout.row()
# row.operator("bdental.alignpoints")
# row.operator("bdental.alignpointsinfo", text="", icon="INFO")
# # conditions :
# ###################################
# if not bpy.context.selected_objects:
# self.AlignLabels = "NOTREADY"
# BaseObjectLabel = " Empty !"
# BaseObjectIcon = red_icon
# AlignObjectLabel = " Empty !"
# AlignObjectIcon = red_icon
# if len(bpy.context.selected_objects) == 1:
# self.AlignLabels = "NOTREADY"
# BaseObject = bpy.context.selected_objects[0]
# BaseObjectLabel = f" {BaseObject.name}"
# BaseObjectIcon = green_icon
# AlignObjectLabel = " Empty ! "
# AlignObjectIcon = red_icon
# if len(bpy.context.selected_objects) == 2:
# self.AlignLabels = "GOOD"
# BaseObject = bpy.context.active_object
# AlignObject = [
# obj
# for obj in bpy.context.selected_objects
# if not obj is bpy.context.active_object
# ][0]
# BaseObjectLabel = f" {BaseObject.name}"
# BaseObjectIcon = green_icon
# AlignObjectLabel = f" {AlignObject.name}"
# AlignObjectIcon = orange_icon
# Condition_1 = len(bpy.context.selected_objects) != 2
# Condition_2 = bpy.context.selected_objects and not bpy.context.active_object
# Condition_3 = bpy.context.selected_objects and not (
# bpy.context.active_object in bpy.context.selected_objects
# )
# Condition_4 = not bpy.context.active_object in bpy.context.visible_objects
# if Condition_1 or Condition_2 or Condition_3 or Condition_4:
# self.AlignLabels = "INVALID"
# if AlignModalState:
# self.AlignLabels = "MODAL"
# #########################################
# if self.AlignLabels == "GOOD":
# box = layout.box()
# row = box.row()
# row.label(text=f"BASE object :{BaseObjectLabel}") # , icon=BaseObjectIcon
# row = box.row()
# row.label(
# text=f"ALIGN object :{AlignObjectLabel}"
# ) # , icon=AlignObjectIcon
# row = box.row()
# row.alert = True
# row.label(text="READY FOR ALIGNEMENT.")
# if self.AlignLabels == "NOTREADY":
# box = layout.box()
# # row = box.row()
# # row.label(text=f"BASE object :{BaseObjectLabel}", icon=BaseObjectIcon)
# # row = box.row()
# # row.label(text=f"ALIGN object :{AlignObjectLabel}", icon=AlignObjectIcon)
# row = box.row()
# row.alert = True
# row.label(text="NOT READY!")
# if self.AlignLabels == "INVALID":
# box = layout.box()
# row = box.row()
# row.alert = True
# row.label(text="Invalid objects selection, check info !", icon="ERROR")
# if self.AlignLabels == "MODAL":
# box = layout.box()
# row = box.row()
# row.alert = True
# row.label(text="WAITING FOR ALIGNEMENT...!")
# row = layout.row()
# row.operator("bdental.alignicp")
# # if self.AlignLabels == "GOOD":
# # row = layout.row()
# # row.operator("bdental.alignpoints")
#################################################################################################
# Registration :
#################################################################################################
classes = [
BDENTAL_PT_SCAN_VIEWER,
# BDENTAL_PT_AlignPanel,
]
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
##########################################################
# TreshRamp = VGS.nodes.get("TresholdRamp")
# ColorPresetRamp = VGS.nodes.get("ColorPresetRamp")
# row = layout.row()
# row.label(
# text=f"Volume Treshold ({BDENTAL_Props.Wmin}/{BDENTAL_Props.Wmax} HU) :"
# )
# row.template_color_ramp(
# TreshRamp,
# "color_ramp",
# expand=True,
# )
# row = layout.row()
# row.prop(BDENTAL_Props, "Axial_Loc", text="AXIAL Location :")
# row = layout.row()
# row.prop(BDENTAL_Props, "Axial_Rot", text="AXIAL Rotation :")