[Bf-blender-cvs] [33d6e6e] alembic: Display basic metadata of a cache archive in the cache library input settings.

Lukas Tönne noreply at git.blender.org
Tue Jun 2 15:26:34 CEST 2015


Commit: 33d6e6ed42f3a092355211bc92e84d91d1fcc413
Author: Lukas Tönne
Date:   Tue Jun 2 13:05:11 2015 +0200
Branches: alembic
https://developer.blender.org/rB33d6e6ed42f3a092355211bc92e84d91d1fcc413

Display basic metadata of a cache archive in the cache library input
settings.

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

M	release/scripts/startup/bl_ui/properties_object.py
M	source/blender/blenkernel/intern/cache_library.c
M	source/blender/makesdna/DNA_cache_library_types.h
M	source/blender/makesrna/intern/rna_cache_library.c
M	source/blender/pointcache/PTC_api.cpp
M	source/blender/pointcache/PTC_api.h
M	source/blender/pointcache/alembic/abc_info.cpp
M	source/blender/pointcache/alembic/abc_reader.cpp
M	source/blender/pointcache/alembic/abc_reader.h
M	source/blender/pointcache/alembic/alembic.h
M	source/blender/pointcache/intern/reader.h

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

diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 6c2a5a9..63161bc6 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -394,7 +394,79 @@ class CACHELIBRARY_MT_hair_simulation_presets(Menu):
     draw = Menu.draw_preset
 
 
-class OBJECT_PT_cache_library(ObjectButtonsPanel, Panel):
+class CacheArchiveInfoPanel():
+    def draw_node_structure(self, context, layout, node, indent):
+        row = layout.row()
+        for i in range(indent):
+            row.label(text="", icon='BLANK1')
+        
+        if not node.child_nodes:
+            row.label(text="", icon='DOT')
+        elif not node.expand:
+            row.prop(node, "expand", text="", icon='DISCLOSURE_TRI_RIGHT', icon_only=True, emboss=False)
+        else:
+            row.prop(node, "expand", text="", icon='DISCLOSURE_TRI_DOWN', icon_only=True, emboss=False)
+
+            for child in node.child_nodes:
+                self.draw_node_structure(context, layout, child, indent + 1)
+
+
+    info_columns = ['Name', 'Node', 'Samples', 'Size', 'Data', '', 'Array Size']
+
+    def draw_node_info(self, context, layout, node, column):
+        if column == 0:
+            layout.prop(node, "name", text="")
+        if column == 1:
+            layout.prop(node, "type", text="")
+        if column == 2:
+            if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
+                layout.prop(node, "samples", text="")
+            else:
+                layout.label(" ")
+        if column == 3:
+            size = int(node.bytes_size)
+            layout.label(sizeof_fmt(size) if size >= 0 else "-")
+        if column == 4:
+            if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
+                layout.prop(node, "datatype", text="")
+            else:
+                layout.label(" ")
+        if column == 5:
+            if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
+                layout.prop(node, "datatype_extent", text="")
+            else:
+                layout.label(" ")
+        if column == 6:
+            if node.type in {'ARRAY_PROPERTY'}:
+                layout.label(node.array_size if node.array_size >= 0 else "-")
+            else:
+                layout.label(" ")
+
+        if node.expand:
+            for child in node.child_nodes:
+                self.draw_node_info(context, layout, child, column)
+
+    def draw_info(self, context, layout, info):
+        layout.prop(info, "filepath", text="File")
+        row = layout.row(align=True)
+        row.prop(info, "app_name", text="Created by")
+        row.prop(info, "date_written", text="")
+        layout.prop(info, "description", text="")
+
+        if info.root_node:
+            row = layout.row()
+
+            col = row.column()
+            col.label(" ")
+            self.draw_node_structure(context, col, info.root_node, 0)
+
+            for i, column in enumerate(self.info_columns):
+                col = row.column()
+                col.label(column)
+                self.draw_node_info(context, col, info.root_node, i)
+
+
+class OBJECT_PT_cache_library(CacheArchiveInfoPanel, ObjectButtonsPanel, Panel):
     bl_label = "Cache"
 
     @classmethod
@@ -415,18 +487,15 @@ class OBJECT_PT_cache_library(ObjectButtonsPanel, Panel):
         getattr(self, md.type)(context, layout, cachelib, md)
 
     def draw_cachelib(self, context, layout, ob, cachelib, objects):
-        col = layout.column()
-        row = col.row()
+        box = layout.box()
+        row = box.row()
         row.label("Source:")
         row.prop(cachelib, "source_mode", text="Source", expand=True)
-        row = col.row(align=True)
+        row = box.row(align=True)
         row.enabled = (cachelib.source_mode == 'CACHE')
         row.prop(cachelib, "input_filepath", text="")
-        props = row.operator("cachelibrary.archive_info", text="", icon='QUESTION')
-        props.filepath = cachelib.input_filepath
-        props.use_stdout = True
-        props.use_popup = True
-        props.use_clipboard = True
+        if cachelib.archive_info:
+            self.draw_info(context, box, cachelib.archive_info)
 
         layout.separator()
 
@@ -699,7 +768,7 @@ def sizeof_fmt(num, suffix='B'):
         num /= 1024.0
     return "%.1f%s%s" % (num, 'Y', suffix)
 
-class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
+class OBJECT_PT_cache_archive_info(CacheArchiveInfoPanel, ObjectButtonsPanel, Panel):
     bl_label = "Cache Archive Info"
     bl_options = {'DEFAULT_CLOSED'}
 
@@ -708,57 +777,6 @@ class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
         ob = context.object
         return (ob and ob.dupli_type == 'GROUP' and ob.dupli_group and ob.cache_library)
 
-    def draw_node_structure(self, context, layout, node, indent):
-        row = layout.row()
-        for i in range(indent):
-            row.label(text="", icon='BLANK1')
-        
-        if not node.child_nodes:
-            row.label(text="", icon='DOT')
-        elif not node.expand:
-            row.prop(node, "expand", text="", icon='DISCLOSURE_TRI_RIGHT', icon_only=True, emboss=False)
-        else:
-            row.prop(node, "expand", text="", icon='DISCLOSURE_TRI_DOWN', icon_only=True, emboss=False)
-
-            for child in node.child_nodes:
-                self.draw_node_structure(context, layout, child, indent + 1)
-
-
-    info_columns = ['Name', 'Node', 'Samples', 'Size', 'Data', '', 'Array Size']
-
-    def draw_node_info(self, context, layout, node, column):
-        if column == 0:
-            layout.prop(node, "name", text="")
-        if column == 1:
-            layout.prop(node, "type", text="")
-        if column == 2:
-            if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
-                layout.prop(node, "samples", text="")
-            else:
-                layout.label(" ")
-        if column == 3:
-            size = int(node.bytes_size)
-            layout.label(sizeof_fmt(size) if size >= 0 else "-")
-        if column == 4:
-            if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
-                layout.prop(node, "datatype", text="")
-            else:
-                layout.label(" ")
-        if column == 5:
-            if node.type in {'SCALAR_PROPERTY', 'ARRAY_PROPERTY'}:
-                layout.prop(node, "datatype_extent", text="")
-            else:
-                layout.label(" ")
-        if column == 6:
-            if node.type in {'ARRAY_PROPERTY'}:
-                layout.label(node.array_size if node.array_size >= 0 else "-")
-            else:
-                layout.label(" ")
-
-        if node.expand:
-            for child in node.child_nodes:
-                self.draw_node_info(context, layout, child, column)
-
     def draw(self, context):
         ob = context.object
         cachelib = ob.cache_library
@@ -784,19 +802,7 @@ class OBJECT_PT_cache_archive_info(ObjectButtonsPanel, Panel):
 
             layout.separator()
 
-            layout.prop(info, "filepath")
-
-            if info.root_node:
-                row = layout.row()
-
-                col = row.column()
-                col.label(" ")
-                self.draw_node_structure(context, col, info.root_node, 0)
-
-                for i, column in enumerate(self.info_columns):
-                    col = row.column()
-                    col.label(column)
-                    self.draw_node_info(context, col, info.root_node, i)
+            self.draw_info(context, layout, info)
 
 
 class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/intern/cache_library.c b/source/blender/blenkernel/intern/cache_library.c
index 1a1672c..37cc45d 100644
--- a/source/blender/blenkernel/intern/cache_library.c
+++ b/source/blender/blenkernel/intern/cache_library.c
@@ -371,6 +371,15 @@ static struct PTCReaderArchive *find_active_cache(Scene *scene, CacheLibrary *ca
 		archive = PTC_open_reader_archive(scene, filename);
 	}
 	
+	/* get basic archive info */
+	if (cachelib->archive_info)
+		BKE_cache_archive_info_clear(cachelib->archive_info);
+	else
+		cachelib->archive_info = BKE_cache_archive_info_new();
+	BLI_strncpy(cachelib->archive_info->filepath, filename, sizeof(cachelib->archive_info->filepath));
+	if (archive)
+		PTC_get_archive_info(archive, cachelib->archive_info);
+	
 	return archive;
 }
 
@@ -2166,6 +2175,11 @@ void BKE_cache_archive_info_free(CacheArchiveInfo *info)
 
 void BKE_cache_archive_info_clear(CacheArchiveInfo *info)
 {
+	info->filepath[0] = '\0';
+	info->app_name[0] = '\0';
+	info->date_written[0] = '\0';
+	info->description[0] = '\0';
+	
 	if (info->root_node) {
 		cache_archive_info_node_free(info->root_node);
 		info->root_node = NULL;
diff --git a/source/blender/makesdna/DNA_cache_library_types.h b/source/blender/makesdna/DNA_cache_library_types.h
index 88ddaff..5a00368 100644
--- a/source/blender/makesdna/DNA_cache_library_types.h
+++ b/source/blender/makesdna/DNA_cache_library_types.h
@@ -137,6 +137,11 @@ typedef enum eCacheArchiveInfoNode_Type {
 
 typedef struct CacheArchiveInfo {
 	char filepath[1024]; /* FILE_MAX */
+	
+	char app_name[64]; /* MAX_NAME */
+	char date_written[64]; /* MAX_NAME */
+	char description[256];
+	
 	struct CacheArchiveInfoNode *root_node;
 } CacheArchiveInfo;
 
diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c
index bf91f57..41424c8 100644
--- a/source/blender/makesrna/intern/rna_cache_library.c
+++ b/source/blender/makesrna/intern/rna_cache_library.c
@@ -1019,6 +1019,18 @@ static void rna_def_cache_archive_info(BlenderRNA *brna)
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "File Path", "Path to the cache archive");
 	
+	prop = RNA_def_property(srna, "app_name", PROP_STRING, PROP_NONE);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Application", "Name of the application that created the archive");
+	
+	prop = RNA_def_property(srna, "date_written", PROP_STRING, PROP_NONE);
+	RNA_def_property_clear_flag(prop, PROP

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list