| 
									
										
										
										
											2009-11-01 15:21:20 +00:00
										 |  |  | # ##### 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. | 
					
						
							| 
									
										
										
										
											2009-11-03 07:23:02 +00:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2009-11-01 15:21:20 +00:00
										 |  |  | #  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. | 
					
						
							| 
									
										
										
										
											2009-11-03 07:23:02 +00:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2009-11-01 15:21:20 +00:00
										 |  |  | #  You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  | #  along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  | #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2009-11-01 15:21:20 +00:00
										 |  |  | # | 
					
						
							|  |  |  | # ##### END GPL LICENSE BLOCK ##### | 
					
						
							| 
									
										
										
										
											2009-10-31 20:16:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-31 23:35:56 +00:00
										 |  |  | # <pep8 compliant> | 
					
						
							| 
									
										
										
										
											2009-07-29 12:35:09 +00:00
										 |  |  | import bpy | 
					
						
							| 
									
										
										
										
											2010-01-08 08:54:41 +00:00
										 |  |  | from rna_prop_ui import PropertyPanel | 
					
						
							| 
									
										
										
										
											2009-07-29 12:35:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-16 10:21:00 +00:00
										 |  |  | narrowui = bpy.context.user_preferences.view.properties_width_check | 
					
						
							| 
									
										
										
										
											2009-10-31 23:35:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-21 00:05:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-29 12:35:09 +00:00
										 |  |  | class DataButtonsPanel(bpy.types.Panel): | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  |     bl_space_type = 'PROPERTIES' | 
					
						
							|  |  |  |     bl_region_type = 'WINDOW' | 
					
						
							|  |  |  |     bl_context = "data" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def poll(self, context): | 
					
						
							|  |  |  |         return context.meta_ball | 
					
						
							| 
									
										
										
										
											2009-07-29 12:35:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-31 23:35:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-29 12:35:09 +00:00
										 |  |  | class DATA_PT_context_metaball(DataButtonsPanel): | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  |     bl_label = "" | 
					
						
							|  |  |  |     bl_show_header = False | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def draw(self, context): | 
					
						
							|  |  |  |         layout = self.layout | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ob = context.object | 
					
						
							|  |  |  |         mball = context.meta_ball | 
					
						
							|  |  |  |         space = context.space_data | 
					
						
							| 
									
										
										
										
											2009-11-19 13:26:51 +00:00
										 |  |  |         wide_ui = context.region.width > narrowui | 
					
						
							| 
									
										
										
										
											2009-11-14 23:24:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-19 13:26:51 +00:00
										 |  |  |         if wide_ui: | 
					
						
							| 
									
										
										
										
											2009-11-14 23:24:15 +00:00
										 |  |  |             split = layout.split(percentage=0.65) | 
					
						
							|  |  |  |             if ob: | 
					
						
							|  |  |  |                 split.template_ID(ob, "data") | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |                 split.separator() | 
					
						
							| 
									
										
										
										
											2009-11-14 23:24:15 +00:00
										 |  |  |             elif mball: | 
					
						
							|  |  |  |                 split.template_ID(space, "pin_id") | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |                 split.separator() | 
					
						
							| 
									
										
										
										
											2009-11-14 23:24:15 +00:00
										 |  |  |         else: | 
					
						
							|  |  |  |             if ob: | 
					
						
							|  |  |  |                 layout.template_ID(ob, "data") | 
					
						
							|  |  |  |             elif mball: | 
					
						
							|  |  |  |                 layout.template_ID(space, "pin_id") | 
					
						
							| 
									
										
										
										
											2009-07-29 12:35:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-31 23:35:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:54:41 +00:00
										 |  |  | class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel): | 
					
						
							|  |  |  |     _context_path = "object.data" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-29 12:35:09 +00:00
										 |  |  | class DATA_PT_metaball(DataButtonsPanel): | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  |     bl_label = "Metaball" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def draw(self, context): | 
					
						
							|  |  |  |         layout = self.layout | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         mball = context.meta_ball | 
					
						
							| 
									
										
										
										
											2009-11-19 13:26:51 +00:00
										 |  |  |         wide_ui = context.region.width > narrowui | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         split = layout.split() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         col = split.column() | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |         col.label(text="Resolution:") | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  |         sub = col.column(align=True) | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |         sub.prop(mball, "wire_size", text="View") | 
					
						
							|  |  |  |         sub.prop(mball, "render_size", text="Render") | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-19 13:26:51 +00:00
										 |  |  |         if wide_ui: | 
					
						
							| 
									
										
										
										
											2009-11-14 23:24:15 +00:00
										 |  |  |             col = split.column() | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |         col.label(text="Settings:") | 
					
						
							|  |  |  |         col.prop(mball, "threshold", text="Threshold") | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |         layout.label(text="Update:") | 
					
						
							| 
									
										
										
										
											2009-11-19 13:26:51 +00:00
										 |  |  |         if wide_ui: | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |             layout.prop(mball, "flag", expand=True) | 
					
						
							| 
									
										
										
										
											2009-11-14 23:24:15 +00:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |             layout.prop(mball, "flag", text="") | 
					
						
							| 
									
										
										
										
											2009-07-29 12:35:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-31 23:35:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-29 17:15:17 +00:00
										 |  |  | class DATA_PT_metaball_element(DataButtonsPanel): | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  |     bl_label = "Active Element" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def poll(self, context): | 
					
						
							|  |  |  |         return (context.meta_ball and context.meta_ball.active_element) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def draw(self, context): | 
					
						
							|  |  |  |         layout = self.layout | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         metaelem = context.meta_ball.active_element | 
					
						
							| 
									
										
										
										
											2009-11-19 13:26:51 +00:00
										 |  |  |         wide_ui = context.region.width > narrowui | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-19 13:26:51 +00:00
										 |  |  |         if wide_ui: | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |             layout.prop(metaelem, "type") | 
					
						
							| 
									
										
										
										
											2009-11-14 23:24:15 +00:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |             layout.prop(metaelem, "type", text="") | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         split = layout.split() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-14 23:24:15 +00:00
										 |  |  |         col = split.column(align=True) | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |         col.label(text="Settings:") | 
					
						
							|  |  |  |         col.prop(metaelem, "stiffness", text="Stiffness") | 
					
						
							|  |  |  |         col.prop(metaelem, "negative", text="Negative") | 
					
						
							|  |  |  |         col.prop(metaelem, "hide", text="Hide") | 
					
						
							| 
									
										
										
										
											2009-11-21 00:05:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-19 13:26:51 +00:00
										 |  |  |         if wide_ui: | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  |             col = split.column(align=True) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-20 20:40:29 +00:00
										 |  |  |         if metaelem.type in ('CUBE', 'ELLIPSOID'): | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |             col.label(text="Size:") | 
					
						
							|  |  |  |             col.prop(metaelem, "size_x", text="X") | 
					
						
							|  |  |  |             col.prop(metaelem, "size_y", text="Y") | 
					
						
							|  |  |  |             col.prop(metaelem, "size_z", text="Z") | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         elif metaelem.type == 'TUBE': | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |             col.label(text="Size:") | 
					
						
							|  |  |  |             col.prop(metaelem, "size_x", text="X") | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         elif metaelem.type == 'PLANE': | 
					
						
							| 
									
										
										
										
											2009-11-23 00:27:30 +00:00
										 |  |  |             col.label(text="Size:") | 
					
						
							|  |  |  |             col.prop(metaelem, "size_x", text="X") | 
					
						
							|  |  |  |             col.prop(metaelem, "size_y", text="Y") | 
					
						
							| 
									
										
										
										
											2009-10-31 19:31:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:54:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-14 11:21:21 +00:00
										 |  |  | classes = [ | 
					
						
							|  |  |  |     DATA_PT_context_metaball, | 
					
						
							|  |  |  |     DATA_PT_metaball, | 
					
						
							|  |  |  |     DATA_PT_metaball_element, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     DATA_PT_custom_props_metaball] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def register(): | 
					
						
							|  |  |  |     register = bpy.types.register | 
					
						
							|  |  |  |     for cls in classes: | 
					
						
							|  |  |  |         register(cls) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-22 23:32:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-14 11:21:21 +00:00
										 |  |  | def unregister(): | 
					
						
							|  |  |  |     unregister = bpy.types.unregister | 
					
						
							|  |  |  |     for cls in classes: | 
					
						
							|  |  |  |         unregister(cls) | 
					
						
							| 
									
										
										
										
											2010-02-16 09:55:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == "__main__": | 
					
						
							|  |  |  |     register() |