properties_data_lattice.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. import bpy
  20. from bpy.types import Panel
  21. from rna_prop_ui import PropertyPanel
  22. class DataButtonsPanel:
  23. bl_space_type = 'PROPERTIES'
  24. bl_region_type = 'WINDOW'
  25. bl_context = "data"
  26. @classmethod
  27. def poll(cls, context):
  28. return context.lattice
  29. class DATA_PT_context_lattice(DataButtonsPanel, Panel):
  30. bl_label = ""
  31. bl_options = {'HIDE_HEADER'}
  32. def draw(self, context):
  33. layout = self.layout
  34. ob = context.object
  35. lat = context.lattice
  36. space = context.space_data
  37. split = layout.split(factor=0.65)
  38. if ob:
  39. split.template_ID(ob, "data")
  40. split.separator()
  41. elif lat:
  42. split.template_ID(space, "pin_id")
  43. split.separator()
  44. class DATA_PT_lattice(DataButtonsPanel, Panel):
  45. bl_label = "Lattice"
  46. def draw(self, context):
  47. layout = self.layout
  48. layout.use_property_split = True
  49. lat = context.lattice
  50. col = layout.column()
  51. sub = col.column(align=True)
  52. sub.prop(lat, "points_u", text="Resolution U")
  53. sub.prop(lat, "points_v", text="V")
  54. sub.prop(lat, "points_w", text="W")
  55. col.separator()
  56. sub = col.column(align=True)
  57. sub.prop(lat, "interpolation_type_u", text="Interpolation U")
  58. sub.prop(lat, "interpolation_type_v", text="V")
  59. sub.prop(lat, "interpolation_type_w", text="W")
  60. col.separator()
  61. col.prop(lat, "use_outside")
  62. col.separator()
  63. col.prop_search(lat, "vertex_group", context.object, "vertex_groups")
  64. class DATA_PT_custom_props_lattice(DataButtonsPanel, PropertyPanel, Panel):
  65. COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
  66. _context_path = "object.data"
  67. _property_type = bpy.types.Lattice
  68. classes = (
  69. DATA_PT_context_lattice,
  70. DATA_PT_lattice,
  71. DATA_PT_custom_props_lattice,
  72. )
  73. if __name__ == "__main__": # only for live edit.
  74. from bpy.utils import register_class
  75. for cls in classes:
  76. register_class(cls)