POV: added doc strings

Hoping it will help the code to be less repulsive to new developers.
This commit is contained in:
Maurice Raybaud 2019-12-08 21:41:58 +01:00
parent f0e3ea24be
commit 56dfa8c8b4
6 changed files with 2840 additions and 2078 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1468,10 +1468,10 @@ def pov_parametric_define(context, op, ob):
bpy.ops.object.mode_set(mode="EDIT")
bpy.ops.mesh.hide(unselected=False)
bpy.ops.object.mode_set(mode="OBJECT")
class POVRAY_OT_parametric_add(bpy.types.Operator):
"""Add the representation of POV parametric surfaces using pov_parametric_define() function."""
bl_idname = "pov.addparametric"
bl_label = "Parametric"
bl_description = "Add Paramertic"
@ -1517,7 +1517,7 @@ class POVRAY_OT_parametric_update(bpy.types.Operator):
Delete its previous proxy geometry and rerun pov_parametric_define() function
with the new parameters"""
bl_idname = "pov.parametric_update"
bl_label = "Update"
bl_description = "Update parametric object"

View File

@ -170,7 +170,7 @@ def string_strip_hyphen(name):
def safety(name, Level):
"""append suffix characters to names of various material declinations.
Material declinations are necessary to POV syntax and used in shading.py
by the povHasnoSpecularMaps function to create the finish map trick and
the suffixes avoid name collisions.
@ -180,7 +180,7 @@ def safety(name, Level):
Level=1 is for texture with No specular nor Mirror reflection
Level=2 is for texture with translation of spec and mir levels
for when no map influences them
Level=3 is for texture with Maximum Spec and Mirror
Level=3 is for texture with Maximum Spec and Mirror
"""
try:
@ -309,7 +309,7 @@ def write_global_setting(scene,file):
def write_object_modifiers(scene,ob,File):
"""Translate some object level POV statements from Blender UI
to POV syntax and write to exported file """
# Maybe return that string to be added instead of directly written.
'''XXX WIP
@ -410,7 +410,7 @@ def write_pov(filename, scene=None, info_callback=None):
tab = setTab(scene.pov.indentation_character, scene.pov.indentation_spaces)
if not scene.pov.tempfiles_enable:
def tabWrite(str_o):
"""Indent POV syntax from brackets levels and write to exported file """
"""Indent POV syntax from brackets levels and write to exported file """
global tabLevel
brackets = str_o.count("{") - str_o.count("}") + str_o.count("[") - str_o.count("]")
if brackets < 0:
@ -425,12 +425,12 @@ def write_pov(filename, scene=None, info_callback=None):
tabLevel = tabLevel + brackets
else:
def tabWrite(str_o):
"""write directly to exported file if user checked autonamed temp files (faster)."""
"""write directly to exported file if user checked autonamed temp files (faster)."""
file.write(str_o)
def uniqueName(name, nameSeq):
"""Increment any generated POV name that could get identical to avoid collisions"""
"""Increment any generated POV name that could get identical to avoid collisions"""
if name not in nameSeq:
name = string_strip_hyphen(name)
@ -465,8 +465,8 @@ def write_pov(filename, scene=None, info_callback=None):
def writeObjectMaterial(material, ob):
"""Translate some object level material from Blender UI (VS data level)
to POV interior{} syntax and write it to exported file """
to POV interior{} syntax and write it to exported file """
# DH - modified some variables to be function local, avoiding RNA write
# this should be checked to see if it is functionally correct
@ -484,7 +484,7 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("ior %.6f\n" % material.pov_raytrace_transparency.ior)
elif material.pov.transparency_method=='Z_TRANSPARENCY':
tabWrite("interior {\n")
tabWrite("ior 1.0\n")
tabWrite("ior 1.0\n")
else:
tabWrite("interior {\n")
tabWrite("ior %.6f\n" % material.pov_raytrace_transparency.ior)
@ -3606,7 +3606,7 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("}\n")
def exportCustomCode():
"""write all POV user defined custom code to exported file """
"""write all POV user defined custom code to exported file """
# Write CurrentAnimation Frame for use in Custom POV Code
file.write("#declare CURFRAMENUM = %d;\n" % bpy.context.scene.frame_current)
#Change path and uncomment to add an animated include file by hand:
@ -3828,7 +3828,7 @@ class PovrayRender(bpy.types.RenderEngine):
@staticmethod
def _locate_binary():
"""Identify POV engine"""
"""Identify POV engine"""
addon_prefs = bpy.context.preferences.addons[__package__].preferences
# Use the system preference if its set.
@ -3879,7 +3879,7 @@ class PovrayRender(bpy.types.RenderEngine):
return ""
def _export(self, depsgraph, povPath, renderImagePath):
"""gather all necessary output files paths user defined and auto generated and export there"""
"""gather all necessary output files paths user defined and auto generated and export there"""
import tempfile
scene = bpy.context.scene
if scene.pov.tempfiles_enable:
@ -3989,7 +3989,7 @@ class PovrayRender(bpy.types.RenderEngine):
# and Windows does not know how to delete a file in use!
time.sleep(self.DELAY)
def render(self, depsgraph):
"""Export necessary files from text editor and render image."""
"""Export necessary files from text editor and render image."""
import tempfile
scene = bpy.context.scene
r = scene.render

View File

@ -249,13 +249,13 @@ def writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments
for t in material.pov_texture_slots:
idx += 1
# index = material.pov.active_texture_index
slot = material.pov_texture_slots[idx] # [index]
slot = material.pov_texture_slots[idx] # [index]
povtex = slot.name
tex = bpy.data.textures[povtex]
tex = bpy.data.textures[povtex]
if t and t.use and tex is not None:
if (tex.type == 'IMAGE' and tex.image) or tex.type != 'IMAGE':
#validPath
if(t and t.use and
@ -272,10 +272,10 @@ def writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments
def exportPattern(texture, string_strip_hyphen):
"""Translate Blender procedural textures to POV patterns and write to pov file.
Function Patterns can be used to better access sub components of a pattern like
grey values for influence mapping"""
tex=texture
pat = tex.pov
PATname = "PAT_%s"%string_strip_hyphen(bpy.path.clean_name(tex.name))
@ -761,7 +761,7 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
imageFormat, imgMap, imgMapTransforms, tabWrite, comments,
string_strip_hyphen, safety, col, os, preview_dir, unpacked_images):
"""Translate Blender texture influences to various POV texture tricks and write to pov file."""
material_finish = materialNames[mater.name]
if mater.pov.use_transparency:
trans = 1.0 - mater.pov.alpha
@ -790,10 +790,10 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
for t in mater.pov_texture_slots:
idx += 1
# index = mater.pov.active_texture_index
slot = mater.pov_texture_slots[idx] # [index]
slot = mater.pov_texture_slots[idx] # [index]
povtex = slot.name
tex = bpy.data.textures[povtex]
if t and (t.use and (tex is not None)):
# 'NONE' ('NONE' type texture is different from no texture covered above)
if (tex.type == 'NONE' and tex.pov.tex_pattern_type == 'emulator'):
@ -1185,9 +1185,9 @@ def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image,
for t in mater.pov_texture_slots:
idx += 1
# index = mater.pov.active_texture_index
slot = mater.pov_texture_slots[idx] # [index]
slot = mater.pov_texture_slots[idx] # [index]
povtex = slot.name
tex = bpy.data.textures[povtex]
tex = bpy.data.textures[povtex]
if(t and t.use and ((tex.type == 'IMAGE' and tex.image) or tex.type != 'IMAGE') and
(t.use_map_specular or t.use_map_raymir)):
# Specular mapped textures would conflict with colored specular

View File

@ -192,8 +192,8 @@ for member in dir(properties_material):
subclass = getattr(properties_material, member)
try:
# mat=bpy.context.active_object.active_material
# if (mat and mat.pov.type == "SURFACE"
# and not (mat.pov.material_use_nodes or mat.use_nodes)):
# if (mat and mat.pov.type == "SURFACE"
# and not (mat.pov.material_use_nodes or mat.use_nodes)):
# and (engine in cls.COMPAT_ENGINES)) if subclasses were sorted
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
except:
@ -272,7 +272,7 @@ class WORLD_OT_POV_add_preset(AddPresetBase, Operator):
# where to store the preset
preset_subdir = "pov/world"
def check_material(mat):
if mat is not None:
if mat.use_nodes:
@ -287,10 +287,10 @@ def simple_material(mat):
if (mat is not None) and (not mat.use_nodes):
return True
return False
def check_add_mesh_extra_objects():
"""Test if Add mesh extra objects addon is activated
This addon is currently used to generate the proxy for POV parametric
surface which is almost the same priciple as its Math xyz surface
"""
@ -300,10 +300,10 @@ def check_add_mesh_extra_objects():
def locate_docpath():
"""POV can be installed with some include files.
Get their path as defined in user preferences or registry keys for
the user to be able to invoke them."""
addon_prefs = bpy.context.preferences.addons[__package__].preferences
# Use the system preference if its set.
pov_documents = addon_prefs.docpath_povray
@ -338,7 +338,7 @@ def locate_docpath():
def pov_context_tex_datablock(context):
"""Texture context type recreated as deprecated in blender 2.8"""
idblock = context.brush
if idblock and bpy.context.scene.texture_context == 'OTHER':
return idblock
@ -351,7 +351,7 @@ def pov_context_tex_datablock(context):
idblock = context.world
if idblock:
return idblock
idblock = context.light
if idblock:
return idblock
@ -364,11 +364,11 @@ def pov_context_tex_datablock(context):
idblock = context.line_style
if idblock:
return idblock
class RenderButtonsPanel():
"""Use this class to define buttons from the render tab of
properties window."""
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "render"
@ -670,7 +670,7 @@ class LIGHT_PT_POV_sunsky(PovLampButtonsPanel, Panel):
class LIGHT_PT_POV_shadow(PovLampButtonsPanel, Panel):
bl_label = "Shadow"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
lamp = context.lamp
@ -683,7 +683,7 @@ class LIGHT_PT_POV_shadow(PovLampButtonsPanel, Panel):
lamp = context.lamp
layout.row().prop(lamp, "shadow_method", expand=True)
split = layout.split()
col = split.column()
@ -746,7 +746,7 @@ class LIGHT_PT_POV_shadow(PovLampButtonsPanel, Panel):
elif lamp.shape == 'RECTANGLE':
sub.prop(lamp, "shadow_ray_samples_x", text="Samples X")
sub.prop(lamp, "shadow_ray_samples_y", text="Samples Y")
'''
if lamp.shadow_method == 'NOSHADOW' and lamp.type == 'AREA':
split = layout.split()
@ -985,7 +985,7 @@ class WORLD_PT_POV_mist(WorldButtonsPanel, Panel):
col.prop(world.mist_settings, "height")
layout.prop(world.mist_settings, "falloff")
class RENDER_PT_POV_export_settings(RenderButtonsPanel, Panel):
"""Use this class to define pov ini settingss buttons."""
@ -1058,11 +1058,11 @@ class RENDER_PT_POV_render_settings(RenderButtonsPanel, Panel):
if sys.platform[:3] != "win":
layout.prop(scene.pov, "sdl_window_enable", text="POV-Ray SDL Window")
col = layout.column()
col.label(text="Main Path Tracing:")
col.prop(scene.pov, "max_trace_level", text="Ray Depth")
align = True
align = True
layout.active = scene.pov.global_settings_advanced
layout.prop(scene.pov,"charset")
row = layout.row(align = align)
@ -1077,15 +1077,15 @@ class RENDER_PT_POV_render_settings(RenderButtonsPanel, Panel):
row.prop(scene.pov,"number_of_waves")
row = layout.row(align = align)
row.prop(scene.pov,"noise_generator")
split = layout.split()
split.label(text="Shading:")
split = layout.split()
row = split.row(align = align)
row.prop(scene.pov, "use_shadows")
row.prop(scene.pov, "alpha_mode")
row.prop(scene.pov, "alpha_mode")
class RENDER_PT_POV_photons(RenderButtonsPanel, Panel):
"""Use this class to define pov photons buttons."""
@ -1473,7 +1473,7 @@ class MATERIAL_PT_POV_sss(MaterialButtonsPanel, Panel):
sub.prop(sss, "back")
col.separator()
col.prop(sss, "error_threshold", text="Error")
class MATERIAL_PT_POV_activate_node(MaterialButtonsPanel, Panel):
"""Use this class to define an activate pov nodes button."""
@ -1558,7 +1558,7 @@ class MATERIAL_PT_POV_mirror(MaterialButtonsPanel, Panel):
bl_idname = "MATERIAL_PT_POV_raytrace_mirror"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
@ -1677,12 +1677,12 @@ class MATERIAL_PT_POV_transp(MaterialButtonsPanel, Panel):
sub.active = rayt.gloss_factor < 1.0
sub.prop(rayt, "gloss_threshold", text="Threshold")
sub.prop(rayt, "gloss_samples", text="Samples")
class MATERIAL_PT_POV_reflection(MaterialButtonsPanel, Panel):
"""Use this class to define more pov specific reflectivity buttons."""
bl_label = "POV-Ray Reflection"
bl_parent_id = "MATERIAL_PT_POV_raytrace_mirror"
bl_parent_id = "MATERIAL_PT_POV_raytrace_mirror"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
@ -1718,8 +1718,8 @@ class MATERIAL_PT_POV_reflection(MaterialButtonsPanel, Panel):
#group some native Blender (SSS) and POV (Fade)settings under such a parent panel?
class MATERIAL_PT_POV_interior(MaterialButtonsPanel, Panel):
bl_label = "POV-Ray Interior"
bl_idname = "material.pov_interior"
#bl_parent_id = "material.absorption"
bl_idname = "material.pov_interior"
#bl_parent_id = "material.absorption"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
@ -1731,14 +1731,14 @@ class MATERIAL_PT_POV_interior(MaterialButtonsPanel, Panel):
def draw_header(self, context):
mat = context.material
'''
'''
class MATERIAL_PT_POV_fade_color(MaterialButtonsPanel, Panel):
"""Use this class to define pov fading (absorption) color buttons."""
bl_label = "POV-Ray Absorption"
COMPAT_ENGINES = {'POVRAY_RENDER'}
#bl_parent_id = "material.pov_interior"
#bl_parent_id = "material.pov_interior"
@classmethod
def poll(cls, context):
@ -1859,7 +1859,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel, Panel):
sub.label(text="Surface diffuse:")
sub = col.column()
sub.prop(tan, "blend_distance", text="Distance")
class MATERIAL_PT_POV_replacement_text(MaterialButtonsPanel, Panel):
"""Use this class to define pov custom code declared name field."""
@ -1920,8 +1920,8 @@ class MATERIAL_TEXTURE_SLOTS_UL_List(UIList):
material = context.material#.pov
active_data = material
#tex = context.texture #may be needed later?
# We could write some code to decide which icon to use here...
custom_icon = 'TEXTURE'
@ -1932,7 +1932,7 @@ class MATERIAL_TEXTURE_SLOTS_UL_List(UIList):
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label("", icon = custom_icon)
'''
'''
class WORLD_TEXTURE_SLOTS_UL_List(UIList):
"""Use this class to show pov texture slots list.""" # XXX Not used yet
@ -1943,8 +1943,8 @@ class WORLD_TEXTURE_SLOTS_UL_List(UIList):
world = context.world#.pov
active_data = world.pov
#tex = context.texture #may be needed later?
# We could write some code to decide which icon to use here...
custom_icon = 'TEXTURE'
@ -1955,7 +1955,7 @@ class WORLD_TEXTURE_SLOTS_UL_List(UIList):
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label("", icon = custom_icon)
class MATERIAL_TEXTURE_SLOTS_UL_POV_layerlist(bpy.types.UIList):
"""Use this class to show pov texture slots list."""
@ -1980,7 +1980,7 @@ class MATERIAL_TEXTURE_SLOTS_UL_POV_layerlist(bpy.types.UIList):
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
class TEXTURE_PT_POV_context_texture(TextureButtonsPanel, Panel):
"""Use this class to show pov texture context buttons."""
@ -1991,7 +1991,7 @@ class TEXTURE_PT_POV_context_texture(TextureButtonsPanel, Panel):
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return (engine in cls.COMPAT_ENGINES)
return (engine in cls.COMPAT_ENGINES)
# if not (hasattr(context, "texture_slot") or hasattr(context, "texture_node")):
# return False
return ((context.material or
@ -1999,14 +1999,14 @@ class TEXTURE_PT_POV_context_texture(TextureButtonsPanel, Panel):
context.light or
context.texture or
context.line_style or
context.particle_system or
context.particle_system or
isinstance(context.space_data.pin_id, ParticleSettings) or
context.texture_user) and
(engine in cls.COMPAT_ENGINES))
def draw(self, context):
layout = self.layout
scene = context.scene
layout.prop(scene, "texture_context", expand=True)
if scene.texture_context == 'MATERIAL':
@ -2017,7 +2017,7 @@ class TEXTURE_PT_POV_context_texture(TextureButtonsPanel, Panel):
col.operator("pov.textureslotadd",icon='ADD',text='')
col.operator("pov.textureslotremove",icon='REMOVE',text='')
col.separator()
if mat.pov_texture_slots:
index = mat.pov.active_texture_index
slot = mat.pov_texture_slots[index]
@ -2028,37 +2028,37 @@ class TEXTURE_PT_POV_context_texture(TextureButtonsPanel, Panel):
layout.prop_search(slot,'texture_search',bpy.data,'textures',text='')
# else:
# for i in range(18): # length of material texture slots
# mat.pov_texture_slots.add()
# mat.pov_texture_slots.add()
# Commented out below is a reminder of what existed in Blender Internal
# Commented out below is a reminder of what existed in Blender Internal
# attributes need to be recreated
'''
slot = getattr(context, "texture_slot", None)
node = getattr(context, "texture_node", None)
space = context.space_data
#attempt at replacing removed space_data
#attempt at replacing removed space_data
mtl = getattr(context, "material", None)
if mtl != None:
spacedependant = mtl
spacedependant = mtl
wld = getattr(context, "world", None)
if wld != None:
spacedependant = wld
spacedependant = wld
lgt = getattr(context, "light", None)
if lgt != None:
spacedependant = lgt
spacedependant = lgt
#idblock = context.particle_system.settings
tex = getattr(context, "texture", None)
if tex != None:
spacedependant = tex
spacedependant = tex
scene = context.scene
idblock = scene.pov#pov_context_tex_datablock(context)
idblock = scene.pov#pov_context_tex_datablock(context)
pin_id = space.pin_id
#spacedependant.use_limited_texture_context = True
@ -2100,7 +2100,7 @@ class TEXTURE_PT_POV_context_texture(TextureButtonsPanel, Panel):
tex_collection = (pin_id is None) and (node is None) and (spacedependant.texture_context not in ('LINESTYLE','OTHER'))
if tex_collection:
pov = getattr(context, "pov", None)
active_texture_index = getattr(spacedependant, "active_texture_index", None)
print (pov)
@ -2110,10 +2110,10 @@ class TEXTURE_PT_POV_context_texture(TextureButtonsPanel, Panel):
row.template_list("TEXTURE_UL_texslots", "", idblock, "texture_slots",
idblock, "active_texture_index", rows=2, maxrows=16, type="DEFAULT")
# row.template_list("WORLD_TEXTURE_SLOTS_UL_List", "texture_slots", world,
# world.texture_slots, world, "active_texture_index", rows=2)
col = row.column(align=True)
col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
@ -2214,7 +2214,7 @@ class MATERIAL_OT_POV_texture_slot_remove(Operator):
return {'FINISHED'}
class TextureSlotPanel(TextureButtonsPanel):
"""Use this class to show pov texture slots panel."""
"""Use this class to show pov texture slots panel."""
COMPAT_ENGINES = {'POVRAY_RENDER'}
@ -2245,8 +2245,8 @@ class TEXTURE_PT_POV_type(TextureButtonsPanel, Panel):
# row = layout.row()
# row.template_list("WORLD_TEXTURE_SLOTS_UL_List", "texture_slots", world,
# world.texture_slots, world, "active_texture_index")
class TEXTURE_PT_POV_preview(TextureButtonsPanel, Panel):
"""Use this class to define pov texture preview panel."""
@ -2527,7 +2527,7 @@ class TEXTURE_PT_POV_influence(TextureSlotPanel, Panel):
if isinstance(idblock, Material):
split = layout.split()
col = split.column()
col = split.column()
if idblock.pov.type in {'SURFACE', 'WIRE'}:
split = layout.split()
@ -3242,11 +3242,11 @@ class CAMERA_PT_POV_cam_dof(CameraDataButtonsPanel, Panel):
col = flow.column()
col.label(text="F-Stop value will export as")
col.label(text="POV aperture : " + "%.3f" % (1/cam.dof.aperture_fstop*1000))
col = flow.column()
col.prop(cam.pov, "dof_samples_min")
col.prop(cam.pov, "dof_samples_max")
col.prop(cam.pov, "dof_variance")
col.prop(cam.pov, "dof_variance")
col.prop(cam.pov, "dof_confidence")
@ -3296,7 +3296,7 @@ class CAMERA_PT_POV_replacement_text(CameraDataButtonsPanel, Panel):
class TEXT_OT_POV_insert(Operator):
"""Use this class to create blender text editor operator to insert pov snippets like other pov IDEs."""
bl_idname = "text.povray_insert"
bl_label = "Insert"
@ -3416,7 +3416,7 @@ classes = (
WORLD_MT_POV_presets,
WORLD_OT_POV_add_preset,
WORLD_TEXTURE_SLOTS_UL_List,
WORLD_PT_POV_mist,
WORLD_PT_POV_mist,
#RenderButtonsPanel,
#ModifierButtonsPanel,
#MaterialButtonsPanel,
@ -3462,7 +3462,7 @@ classes = (
MATERIAL_PT_POV_caustics,
MATERIAL_PT_POV_replacement_text,
TEXTURE_MT_POV_specials,
TEXTURE_PT_POV_context_texture,
TEXTURE_PT_POV_context_texture,
TEXTURE_PT_POV_type,
TEXTURE_PT_POV_preview,
TEXTURE_PT_POV_parameters,
@ -3490,7 +3490,7 @@ classes = (
# TEXTURE_PT_context,
#TEXTURE_PT_POV_povray_texture_slots,
TEXTURE_UL_POV_texture_slots,
MATERIAL_TEXTURE_SLOTS_UL_POV_layerlist,
MATERIAL_TEXTURE_SLOTS_UL_POV_layerlist,
MATERIAL_OT_POV_texture_slot_add,
MATERIAL_OT_POV_texture_slot_remove,
TEXTURE_PT_POV_influence

View File

@ -17,7 +17,7 @@
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
"""update new variables to values from older API.
"""update new variables to values from older API.
It does not have a UI and used to be found with F3 search field.
This file needs an update."""