forked from WASPMed/WASP-Med-Add-on-for-Blender-2-9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaspmed_sculpt.py
194 lines (157 loc) · 5.94 KB
/
waspmed_sculpt.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
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
from utils import draw_measurement_tools_panel
'''
def store_parameters(operator, ob):
ob.tissue_tessellate.generator = operator.generator
return ob
class waspmed_prop(bpy.types.PropertyGroup):
patientID = bpy.props.StringProperty()
status = bpy.props.IntProperty(default=0)
zscale = bpy.props.FloatProperty(default=1)
merge = bpy.props.BoolProperty()
class next(bpy.types.Operator):
bl_idname = "object.next"
bl_label = "Next"
bl_description = ("")
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if context.object.waspmed_prop.patientID == "":
context.object.waspmed_prop.patientID = context.object.name
status = context.object.waspmed_prop.status
bpy.ops.object.duplicate_move()
context.object.waspmed_prop.status = status + 1
return {'FINISHED'}
class back(bpy.types.Operator):
bl_idname = "object.back"
bl_label = "Back"
bl_description = ("")
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
patientID = context.object.waspmed_prop.patientID
status = context.object.waspmed_prop.status - 1
for o in bpy.data.objects:
if o.waspmed_prop.patientID == patientID and status == o.waspmed_prop.status:
context.object = o
return {'FINISHED'}
'''
class OBJECT_OT_wm_set_sculpt(bpy.types.Operator):
bl_idname = "object.wm_set_sculpt"
bl_label = "Sculpt"
bl_description = ""
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
ob = context.object
if ob.parent != None: ob = ob.parent
bpy.context.view_layer.objects.active = ob
ob.select_set(True)
bpy.ops.object.mode_set(mode='SCULPT')
return {'FINISHED'}
class OBJECT_OT_wm_set_draw(bpy.types.Operator):
bl_idname = "object.wm_set_draw"
bl_label = "Draw"
bl_description = ""
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
try:
return context.object.mode == 'SCULPT'
except: return False
def execute(self, context):
context.tool_settings.sculpt.brush.sculpt_tool = 'DRAW'
return {'FINISHED'}
class OBJECT_OT_wm_set_smooth(bpy.types.Operator):
bl_idname = "object.wm_set_smooth"
bl_label = "Smooth"
bl_description = ""
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
try:
return context.object.mode == 'SCULPT'
except: return False
def execute(self, context):
context.tool_settings.sculpt.brush.sculpt_tool = 'SMOOTH'
return {'FINISHED'}
class OBJECT_OT_wm_set_grab(bpy.types.Operator):
bl_idname = "object.wm_set_grab"
bl_label = "Grab"
bl_description = ""
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
try:
return context.object.mode == 'SCULPT'
except: return False
def execute(self, context):
context.tool_settings.sculpt.brush.sculpt_tool = 'GRAB'
return {'FINISHED'}
### Sculpt Tools ###
from bl_ui.properties_paint_common import (
UnifiedPaintPanel,
#brush_texpaint_common,
)
class View3DPanel:
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
class View3DPaintPanel(UnifiedPaintPanel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
### END Sculpt Tools ###
class WASPMED_PT_sculpt(View3DPaintPanel, bpy.types.Panel):
#class waspmed_scan_panel(, bpy.types.View3DPaintPanel):
bl_label = "Sculpt"
bl_category = "Waspmed"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
#bl_options = {}
#bl_context = "objectmode"
#@classmethod
#def poll(cls, context):
# return context.mode in {'OBJECT', 'EDIT_MESH'}
@classmethod
def poll(cls, context):
try:
ob = context.object
if ob.parent is not None:
ob = ob.parent
status = ob.waspmed_prop.status
is_mesh = ob.type == 'MESH'
return (status == 2 and is_mesh) and not context.object.hide_viewport
except: return False
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
if context.mode == 'SCULPT':
settings = self.paint_settings(context)
#col.template_ID_preview(settings, "brush", rows=3, cols=8)
brush = settings.brush
col.separator()
row = col.row(align=True)
row.scale_y = 2
row.operator("object.wm_set_draw", icon="OUTLINER_DATA_GP_LAYER")#, icon="BRUSH_SCULPT_DRAW")
row.operator("object.wm_set_smooth", icon="MOD_SMOOTH")#, icon="BRUSH_SMOOTH")
row.operator("object.wm_set_grab", icon="MOD_WARP")#"BRUSH_GRAB")
#row.prop(context.tool_settings.sculpt.brush, 'sculpt_tool', icon_only = True, expand=True)
col.prop(context.scene.tool_settings.unified_paint_settings, 'size')
col.prop(context.scene.tool_settings.unified_paint_settings, 'strength')
else:
col.operator("object.wm_set_sculpt", icon="SCULPTMODE_HLT")
col.separator()
draw_measurement_tools_panel(layout, context)