Commit: 03870ea9d8c861d9fc5bfb65d1e7b65872a9ea58
Author: Sybren A. Stüvel
Date:   Thu Dec 15 12:14:16 2016 +0100
Branches: temp-sybren-poselib
https://developer.blender.org/rB03870ea9d8c861d9fc5bfb65d1e7b65872a9ea58

Added rendering of previews of single poses

===================================================================

M       release/scripts/startup/bl_operators/poselib.py
M       release/scripts/startup/bl_ui/properties_data_armature.py

===================================================================

diff --git a/release/scripts/startup/bl_operators/poselib.py 
b/release/scripts/startup/bl_operators/poselib.py
index 24e8123..fca0365 100644
--- a/release/scripts/startup/bl_operators/poselib.py
+++ b/release/scripts/startup/bl_operators/poselib.py
@@ -56,6 +56,10 @@ class POSELIB_OT_render_previews(Operator):
         default='OPENGL'
     )
 
+    render_pose_index = IntProperty(name='Pose index',
+                                    default=-1,
+                                    description='Index of the pose to render, 
-1 renders all poses')
+
     plib_index = 0
     image_size = 64, 64
     icon_size = 16, 16
@@ -67,7 +71,14 @@ class POSELIB_OT_render_previews(Operator):
         return bool(plib and plib.pose_markers)
 
     def execute(self, context):
-        return {'PASS_THROUGH'}
+        if self.render_pose_index < 0:
+            self.report({'WARNING'}, "Rendering multiple previews is only 
available when INVOKE'd.")
+            return {'PASS_THROUGH'}
+
+        plib = context.object.pose_library
+        self.setup_plib(plib)
+        self.render_pose(context, plib, self.render_pose_index)
+        return {'FINISHED'}
 
     def modal(self, context, event):
         if event.type == 'ESC':
@@ -130,23 +141,28 @@ class POSELIB_OT_render_previews(Operator):
         bpy.data.images.remove(im)
 
     def invoke(self, context, event):
+        if self.render_pose_index >= 0:
+            self.execute(context)
+            return {'FINISHED'}
+
+        plib = context.object.pose_library
+
         wm = context.window_manager
         wm.modal_handler_add(self)
+        wm.progress_begin(0, len(plib.pose_markers))
 
         self.wm = context.window_manager
         self.timer = self.wm.event_timer_add(0.01, context.window)
         self.plib_index = 0
+        self.setup_plib(plib)
 
-        plib = context.object.pose_library
-        nr_of_poses = len(plib.pose_markers)
-        context.window_manager.progress_begin(0, nr_of_poses)
+        return {'RUNNING_MODAL'}
 
+    def setup_plib(self, plib):
         plib.preview.icon_size = self.icon_size
         plib.preview.image_size = self.image_size
         plib.preview.frames_number = len(plib.pose_markers)
 
-        return {'RUNNING_MODAL'}
-
     def _finish(self, context):
         self.wm.event_timer_remove(self.timer)
         context.window_manager.progress_end()
diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py 
b/release/scripts/startup/bl_ui/properties_data_armature.py
index f1c03f0..74ba937 100644
--- a/release/scripts/startup/bl_ui/properties_data_armature.py
+++ b/release/scripts/startup/bl_ui/properties_data_armature.py
@@ -212,13 +212,32 @@ class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
             layout.prop(pose_marker_active, "camera",
                         text='Camera for %s' % pose_marker_active.name)
 
+        previews = layout.box()
+        row = previews.column_flow(4)
         for marker in poselib.pose_markers:
-            col.label(marker.name, icon_value=poselib.preview.icon_id, 
icon_frame=marker.preview_frame_index)
+            row.label(marker.name,
+                      icon_value=poselib.preview.icon_id,
+                      icon_frame=marker.preview_frame_index)
 
         row = layout.row(align=True)
         row.operator_context = 'INVOKE_DEFAULT'
-        row.operator("poselib.render_previews", text='Render 
OGL').render_method='OPENGL'
-        row.operator("poselib.render_previews", text='Render 
Full').render_method='FULL'
+        props = row.operator("poselib.render_previews", text='Render OGL all')
+        props.render_method = 'OPENGL'
+        props.render_pose_index = -1
+        props = row.operator("poselib.render_previews", text='Render Full all')
+        props.render_method = 'FULL'
+        props.render_pose_index = -1
+
+        if pose_marker_active:
+            row = layout.row(align=True)
+            props = row.operator("poselib.render_previews",
+                                 text='Render OGL %s' % 
pose_marker_active.name)
+            props.render_method = 'OPENGL'
+            props.render_pose_index = poselib.pose_markers.active_index
+            props = row.operator("poselib.render_previews",
+                                 text='Render Full %s' % 
pose_marker_active.name)
+            props.render_method = 'FULL'
+            props.render_pose_index = poselib.pose_markers.active_index
 
 
 # TODO: this panel will soon be deprecated too

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to