[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1745] trunk/py/scripts/addons/ system_demo_mode: Many small improvements, its generally usable now.
Campbell Barton
ideasman42 at gmail.com
Tue Mar 29 10:16:09 CEST 2011
Revision: 1745
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1745
Author: campbellbarton
Date: 2011-03-29 08:16:09 +0000 (Tue, 29 Mar 2011)
Log Message:
-----------
Many small improvements, its generally usable now.
Modified Paths:
--------------
trunk/py/scripts/addons/system_demo_mode/__init__.py
trunk/py/scripts/addons/system_demo_mode/config.py
trunk/py/scripts/addons/system_demo_mode/demo_mode.py
Modified: trunk/py/scripts/addons/system_demo_mode/__init__.py
===================================================================
--- trunk/py/scripts/addons/system_demo_mode/__init__.py 2011-03-29 06:19:48 UTC (rev 1744)
+++ trunk/py/scripts/addons/system_demo_mode/__init__.py 2011-03-29 08:16:09 UTC (rev 1745)
@@ -40,14 +40,14 @@
import bpy
-from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
+from bpy.props import StringProperty, BoolProperty, IntProperty, FloatProperty, EnumProperty
from io_utils import ImportHelper
class DemoModeSetup(bpy.types.Operator):
'''Creates a demo script and optionally executes'''
bl_idname = "wm.demo_mode_setup"
- bl_label = "Demo Mode"
+ bl_label = "Demo Mode (Setup)"
bl_options = {'PRESET'}
# List of operator properties, the attributes will be assigned
@@ -57,7 +57,7 @@
filepath = StringProperty(name="File Path", description="Filepath used for importing the file", maxlen=1024, default="", subtype='FILE_PATH')
random_order = BoolProperty(name="Random Order", description="Select files randomly", default=False)
mode = EnumProperty(items=(
- ('AUTO', "Automatic", ""),
+ ('AUTO', "Auto", ""),
('PLAY', "Play", ""),
('RENDER', "Render", ""),
),
@@ -69,9 +69,9 @@
#
# anim
# ====
- anim_cycles = FloatProperty(name="Cycles", description="Number of times to play the animation", min=0.1, max=1000.0, soft_min=1.0, soft_max=1000.0, default=1.0)
+ anim_cycles = IntProperty(name="Cycles", description="Number of times to play the animation", min=1, max=1000, default=2)
anim_time_min = FloatProperty(name="Time Min", description="Minimum number of seconds to show the animation for (for small loops)", min=0.0, max=1000.0, soft_min=1.0, soft_max=1000.0, default=4.0)
- anim_time_max = FloatProperty(name="Time Max", description="Maximum number of seconds to show the animation for (incase the end frame is very high for no reason)", min=0.0, max=100000000.0, soft_min=1.0, soft_max=100000000.0, default=60.0)
+ anim_time_max = FloatProperty(name="Time Max", description="Maximum number of seconds to show the animation for (incase the end frame is very high for no reason)", min=0.0, max=100000000.0, soft_min=1.0, soft_max=100000000.0, default=8.0)
anim_screen_switch = FloatProperty(name="Screen Switch", description="Time between switching screens (in seconds) or 0 to disable", min=0.0, max=100000000.0, soft_min=1.0, soft_max=60.0, default=0.0)
#
# render
@@ -91,6 +91,10 @@
text = bpy.data.texts.new("demo.py")
text.from_string(cfg_str)
+
+ if self.run:
+ extern_demo_mode_run()
+
return {'FINISHED'}
def invoke(self, context, event):
@@ -102,44 +106,100 @@
def draw(self, context):
layout = self.layout
+
+ box = layout.box()
+ box.label("Search *.blend recursively")
+ box.label("Writes: demo.py config text.")
+
col = layout.column()
col.prop(self, "run")
col.label("Generate Settings:")
- col.prop(self, "mode")
+ row = col.row()
+ row.prop(self, "mode", expand=True)
col.prop(self, "random_order")
-
+
mode = self.mode
-
+
col.separator()
colsub = col.column()
- colsub.active = (mode in ('AUTO', 'ANIMATE'))
+ colsub.active = (mode in ('AUTO', 'PLAY'))
colsub.label("Animate Settings:")
colsub.prop(self, "anim_cycles")
colsub.prop(self, "anim_time_min")
colsub.prop(self, "anim_time_max")
+ colsub.prop(self, "anim_screen_switch")
col.separator()
colsub = col.column()
colsub.active = (mode in ('AUTO', 'RENDER'))
colsub.label("Render Settings:")
- colsub.prop(self, "render_anim")
+ colsub.prop(self, "display_render")
+class DemoModeRun(bpy.types.Operator):
+ bl_idname = "wm.demo_mode_run"
+ bl_label = "Demo Mode (Start)"
+
+ def execute(self, context):
+ if extern_demo_mode_run():
+ return {'FINISHED'}
+ else:
+ self.report({'ERROR'}, "Cant load demo.py config, run: File -> Demo Mode (Setup)")
+ return {'CANCELLED'}
+
+
+# --- call demo_mode.py funcs
+def extern_demo_mode_run():
+ # this accesses demo_mode.py which is kept standalone
+ # and can be run direct.
+ from . import demo_mode
+ if demo_mode.load_config():
+ demo_mode.demo_mode_load_file() # kick starts the modal operator
+ return True
+ else:
+ return False
+
+
+def extern_demo_mode_register():
+ # this accesses demo_mode.py which is kept standalone
+ # and can be run direct.
+ from . import demo_mode
+ demo_mode.register()
+
+
+def extern_demo_mode_unregister():
+ # this accesses demo_mode.py which is kept standalone
+ # and can be run direct.
+ from . import demo_mode
+ demo_mode.unregister()
+
+# --- intergration
+
+
def menu_func(self, context):
- self.layout.operator(DemoModeSetup.bl_idname)
+ layout = self.layout
+ layout.operator(DemoModeSetup.bl_idname, icon='PREFERENCES')
+ layout.operator(DemoModeRun.bl_idname, icon='PLAY')
+ layout.separator()
def register():
bpy.utils.register_class(DemoModeSetup)
+ bpy.utils.register_class(DemoModeRun)
- bpy.types.INFO_MT_file_import.append(menu_func)
+ bpy.types.INFO_MT_file.prepend(menu_func)
+ extern_demo_mode_register()
+
def unregister():
bpy.utils.unregister_class(DemoModeSetup)
+ bpy.utils.unregister_class(DemoModeRun)
- bpy.types.INFO_MT_file_import.remove(menu_func)
+ bpy.types.INFO_MT_file.remove(menu_func)
+ extern_demo_mode_unregister()
+
if __name__ == "__main__":
register()
Modified: trunk/py/scripts/addons/system_demo_mode/config.py
===================================================================
--- trunk/py/scripts/addons/system_demo_mode/config.py 2011-03-29 06:19:48 UTC (rev 1744)
+++ trunk/py/scripts/addons/system_demo_mode/config.py 2011-03-29 08:16:09 UTC (rev 1745)
@@ -1,5 +1,6 @@
import os
+
def blend_list(path):
for dirpath, dirnames, filenames in os.walk(path):
@@ -36,8 +37,10 @@
def as_string(dirpath, random_order, **kwargs):
+ """ Config loader is in demo_mode.py
+ """
cfg, dirpath = generate(dirpath, random_order, **kwargs)
-
+
# hint for reader, can be used if files are not found.
cfg_str = []
cfg_str += ["# generated file\n"]
@@ -48,9 +51,8 @@
cfg_str += ["search_path = %r\n" % dirpath]
cfg_str += ["\n"]
-
# All these work but use nicest formatting!
- if 0: # works but not nice to edit.
+ if 0: # works but not nice to edit.
cfg_str += ["config = %r" % cfg]
elif 0:
import pprint
@@ -59,6 +61,7 @@
cfg_str += [("config = %r" % cfg).replace("{", "\n {")]
else:
import pprint
+
def dict_as_kw(d):
return "dict(%s)" % ", ".join(("%s=%s" % (k, pprint.pformat(v))) for k, v in sorted(d.items()))
ident = " "
@@ -66,6 +69,5 @@
for cfg_item in cfg:
cfg_str += ["%s%s,\n" % (ident, dict_as_kw(cfg_item))]
cfg_str += ["%s]\n\n" % ident]
-
-
+
return "".join(cfg_str), dirpath
Modified: trunk/py/scripts/addons/system_demo_mode/demo_mode.py
===================================================================
--- trunk/py/scripts/addons/system_demo_mode/demo_mode.py 2011-03-29 06:19:48 UTC (rev 1744)
+++ trunk/py/scripts/addons/system_demo_mode/demo_mode.py 2011-03-29 08:16:09 UTC (rev 1745)
@@ -27,10 +27,11 @@
looks for demo.py textblock or file in the same path as the blend:
# --- example
config = [
- dict(anim_cycles=1.0, anim_render=False, anim_screen_switch=0.0, anim_time_max=10.0, anim_time_min=4.0, mode='AUTO', display_render=4.0, file='/l/19534_simplest_mesh_2.blend'),
- dict(anim_cycles=1.0, anim_render=False, anim_screen_switch=0.0, anim_time_max=10.0, anim_time_min=4.0, mode='AUTO', display_render=4.0, file='/l/252_pivotConstraint_01.blend'),
+ dict(anim_cycles=1, anim_render=False, anim_screen_switch=0.0, anim_time_max=10.0, anim_time_min=4.0, mode='AUTO', display_render=4.0, file='/l/19534_simplest_mesh_2.blend'),
+ dict(anim_cycles=1, anim_render=False, anim_screen_switch=0.0, anim_time_max=10.0, anim_time_min=4.0, mode='AUTO', display_render=4.0, file='/l/252_pivotConstraint_01.blend'),
]
# ---
+/data/src/blender/lib/tests/rendering/
'''
import bpy
@@ -39,11 +40,13 @@
import tempfile
import os
+DEMO_CFG = "demo.py"
+
# populate from script
global_config_files = []
-global_config = dict(anim_cycles=1.0,
+global_config = dict(anim_cycles=1,
anim_render=False,
anim_screen_switch=0.0,
anim_time_max=60.0,
@@ -52,7 +55,7 @@
display_render=4.0)
# switch to the next file in 2 sec.
-global_config_fallback = dict(anim_cycles=1.0,
+global_config_fallback = dict(anim_cycles=1,
anim_render=False,
anim_screen_switch=0.0,
anim_time_max=60.0,
@@ -61,13 +64,12 @@
display_render=4.0)
-
global_state = {
"init_time": 0.0,
"last_switch": 0.0,
"reset_anim": False,
- "anim_cycles": 0.0, # count how many times we played the anim
- "last_frame": 0,
+ "anim_cycles": 0, # count how many times we played the anim
+ "last_frame": -1,
"render_out": "",
"render_time": "", # time render was finished.
"timer": None,
@@ -75,23 +77,39 @@
"demo_index": 0,
}
+
def demo_mode_auto_select():
-
+
play_area = 0
render_area = 0
-
+
+ totimg = 0
+
for area in bpy.context.window.screen.areas:
size = area.width * area.height
if area.type in {'VIEW_3D', 'GRAPH_EDITOR', 'DOPESHEET_EDITOR', 'NLA_EDITOR', 'TIMELINE'}:
play_area += size
elif area.type in {'IMAGE_EDITOR', 'SEQUENCE_EDITOR', 'NODE_EDITOR'}:
render_area += size
+
+ if area.type == 'IMAGE_EDITOR':
+ totimg += 1
- mode = 'PLAY' if play_area >= render_area else 'RENDER'
- print(mode, play_area, render_area)
- return 'PLAY'
-
+ # since our test files have this as defacto standard
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list