[Bf-blender-cvs] [01bf0f3] gooseberry: Archive Info operator for Cache Library archives.
Lukas Tönne
noreply at git.blender.org
Mon Mar 23 13:02:44 CET 2015
Commit: 01bf0f37a7af77a8d25e5766e06b6ae57605be8a
Author: Lukas Tönne
Date: Thu Mar 5 16:28:12 2015 +0100
Branches: gooseberry
https://developer.blender.org/rB01bf0f37a7af77a8d25e5766e06b6ae57605be8a
Archive Info operator for Cache Library archives.
This creates a string with information about all the objects and
properties contained within a (Alembic) archive, used by a cache
library.
The operator has 3 modes of presenting the info string:
- stdout, ie. printing to the terminal
- popup window (not very useful usually due to size limits and lack of
scrolling)
- clipboard copy
===================================================================
M release/scripts/startup/bl_ui/properties_scene.py
M source/blender/editors/io/io_cache_library.c
M source/blender/editors/io/io_cache_library.h
M source/blender/editors/io/io_ops.c
M source/blender/pointcache/PTC_api.cpp
M source/blender/pointcache/PTC_api.h
M source/blender/pointcache/alembic/CMakeLists.txt
A source/blender/pointcache/alembic/abc_info.cpp
M source/blender/pointcache/alembic/abc_reader.cpp
M source/blender/pointcache/alembic/abc_reader.h
A source/blender/pointcache/alembic/alembic.h
M source/blender/pointcache/intern/reader.h
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 0356981..5dd9c5b 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -490,11 +490,17 @@ class SCENE_PT_cache_manager(SceneButtonsPanel, Panel):
row.template_ID(cachelib, "group")
col = layout.column(align=True)
- col.label("Archive:")
+ colrow = col.row(align=True)
+ colrow.label("Archive:")
+ props = colrow.operator("cachelibrary.archive_info", text="", icon='QUESTION')
+ props.use_stdout = True
+ props.use_popup = True
+ props.use_clipboard = True
col.prop(cachelib, "filepath", text="")
- row = col.row(align=True)
- row.prop(cachelib, "read", text="Read", toggle=True)
- row.operator("cachelibrary.bake")
+
+ colrow = col.row(align=True)
+ colrow.prop(cachelib, "read", text="Read", toggle=True)
+ colrow.operator("cachelibrary.bake")
col.prop(cachelib, "eval_mode", expand=False)
row = layout.row(align=True)
diff --git a/source/blender/editors/io/io_cache_library.c b/source/blender/editors/io/io_cache_library.c
index b422ba9..5eadb72 100644
--- a/source/blender/editors/io/io_cache_library.c
+++ b/source/blender/editors/io/io_cache_library.c
@@ -36,6 +36,7 @@
#include "BLI_blenlib.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
+#include "BLI_math.h"
#include "BLI_path_util.h"
#include "BLI_utildefines.h"
@@ -457,3 +458,118 @@ void CACHELIBRARY_OT_bake(wmOperatorType *ot)
/* no undo for this operator, cannot restore old cache files anyway */
ot->flag = OPTYPE_REGISTER;
}
+
+/* ========================================================================= */
+
+static int cache_library_archive_info_poll(bContext *C)
+{
+ CacheLibrary *cachelib = CTX_data_pointer_get_type(C, "cache_library", &RNA_CacheLibrary).data;
+
+ if (!cachelib)
+ return false;
+
+ return true;
+}
+
+static void ui_item_nlabel(uiLayout *layout, const char *s, size_t len)
+{
+ char buf[256];
+
+ BLI_strncpy(buf, s, sizeof(buf)-1);
+ buf[min_ii(len, sizeof(buf)-1)] = '\0';
+
+ uiItemL(layout, buf, ICON_NONE);
+}
+
+static void archive_info_labels(uiLayout *layout, const char *info)
+{
+ const char delim[] = {'\n', '\0'};
+ const char *cur = info;
+ size_t linelen;
+ char *sep, *suf;
+
+ linelen = BLI_str_partition(cur, delim, &sep, &suf);
+ while (sep) {
+ ui_item_nlabel(layout, cur, linelen);
+ cur = suf;
+
+ linelen = BLI_str_partition(cur, delim, &sep, &suf);
+ }
+ ui_item_nlabel(layout, cur, linelen);
+}
+
+static uiBlock *archive_info_popup_create(bContext *C, ARegion *ar, void *arg)
+{
+ const char *info = arg;
+ uiBlock *block;
+ uiLayout *layout;
+
+ block = UI_block_begin(C, ar, "_popup", UI_EMBOSS);
+ UI_block_flag_disable(block, UI_BLOCK_LOOP);
+ UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
+
+ layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 20, UI_UNIT_Y, 0, UI_style_get());
+
+ archive_info_labels(layout, info);
+
+ UI_block_bounds_set_centered(block, 0);
+ UI_block_direction_set(block, UI_DIR_DOWN);
+
+ return block;
+}
+
+static int cache_library_archive_info_exec(bContext *C, wmOperator *op)
+{
+ CacheLibrary *cachelib = CTX_data_pointer_get_type(C, "cache_library", &RNA_CacheLibrary).data;
+ Scene *scene = CTX_data_scene(C);
+
+ const bool use_stdout = RNA_boolean_get(op->ptr, "use_stdout");
+ const bool use_popup = RNA_boolean_get(op->ptr, "use_popup");
+ const bool use_clipboard = RNA_boolean_get(op->ptr, "use_clipboard");
+
+ char filename[FILE_MAX];
+ struct PTCReaderArchive *archive;
+ char *info;
+
+ BKE_cache_archive_path(cachelib->filepath, (ID *)cachelib, cachelib->id.lib, filename, sizeof(filename));
+ archive = PTC_open_reader_archive(scene, filename);
+ info = PTC_get_archive_info(archive);
+ PTC_close_reader_archive(archive);
+
+ if (info) {
+ if (use_stdout) {
+ printf("%s", info);
+ }
+
+ if (use_popup) {
+ UI_popup_block_invoke(C, archive_info_popup_create, info);
+ }
+
+ if (use_clipboard) {
+ WM_clipboard_text_set(info, false);
+ }
+
+ MEM_freeN(info);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void CACHELIBRARY_OT_archive_info(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Archive Info";
+ ot->description = "Get archive details from a cache library archive";
+ ot->idname = "CACHELIBRARY_OT_archive_info";
+
+ /* api callbacks */
+ ot->exec = cache_library_archive_info_exec;
+ ot->poll = cache_library_archive_info_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_boolean(ot->srna, "use_stdout", false, "Use stdout", "Print info in standard output");
+ RNA_def_boolean(ot->srna, "use_popup", false, "Show Popup", "Display archive info in a popup");
+ RNA_def_boolean(ot->srna, "use_clipboard", false, "Copy to Clipboard", "Copy archive info to the clipboard");
+}
diff --git a/source/blender/editors/io/io_cache_library.h b/source/blender/editors/io/io_cache_library.h
index f08b9eb..29c2e68 100644
--- a/source/blender/editors/io/io_cache_library.h
+++ b/source/blender/editors/io/io_cache_library.h
@@ -39,4 +39,6 @@ void CACHELIBRARY_OT_item_enable(struct wmOperatorType *ot);
void CACHELIBRARY_OT_bake(struct wmOperatorType *ot);
+void CACHELIBRARY_OT_archive_info(struct wmOperatorType *ot);
+
#endif
diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c
index 3e8ed53..4f4d3e7 100644
--- a/source/blender/editors/io/io_ops.c
+++ b/source/blender/editors/io/io_ops.c
@@ -43,6 +43,7 @@ void ED_operatortypes_io(void)
WM_operatortype_append(CACHELIBRARY_OT_delete);
WM_operatortype_append(CACHELIBRARY_OT_item_enable);
WM_operatortype_append(CACHELIBRARY_OT_bake);
+ WM_operatortype_append(CACHELIBRARY_OT_archive_info);
#ifdef WITH_COLLADA
/* Collada operators: */
diff --git a/source/blender/pointcache/PTC_api.cpp b/source/blender/pointcache/PTC_api.cpp
index 5da5268..2c79495 100644
--- a/source/blender/pointcache/PTC_api.cpp
+++ b/source/blender/pointcache/PTC_api.cpp
@@ -186,6 +186,15 @@ PTCReadSampleResult PTC_test_sample(PTCReader *_reader, float frame)
return reader->test_sample(frame);
}
+char *PTC_get_archive_info(PTCReaderArchive *_archive)
+{
+ PTC::ReaderArchive *archive = (PTC::ReaderArchive *)_archive;
+
+ std::string info = archive->get_info();
+ return BLI_sprintfN("%s", info.c_str());
+}
+
+
/* get writer/reader from RNA type */
PTCWriter *PTC_writer_from_rna(Scene *scene, PointerRNA *ptr)
{
diff --git a/source/blender/pointcache/PTC_api.h b/source/blender/pointcache/PTC_api.h
index 5afa651..c875ecb 100644
--- a/source/blender/pointcache/PTC_api.h
+++ b/source/blender/pointcache/PTC_api.h
@@ -83,6 +83,8 @@ bool PTC_reader_get_frame_range(struct PTCReader *reader, int *start_frame, int
PTCReadSampleResult PTC_read_sample(struct PTCReader *reader, float frame);
PTCReadSampleResult PTC_test_sample(struct PTCReader *reader, float frame);
+char *PTC_get_archive_info(struct PTCReaderArchive *archive);
+
/* get writer/reader from RNA type */
struct PTCWriter *PTC_writer_from_rna(struct Scene *scene, struct PointerRNA *ptr);
struct PTCReader *PTC_reader_from_rna(struct Scene *scene, struct PointerRNA *ptr);
diff --git a/source/blender/pointcache/alembic/CMakeLists.txt b/source/blender/pointcache/alembic/CMakeLists.txt
index 1eb5dec..becf845 100644
--- a/source/blender/pointcache/alembic/CMakeLists.txt
+++ b/source/blender/pointcache/alembic/CMakeLists.txt
@@ -41,9 +41,11 @@ set(INC_SYS
set(SRC
alembic.cpp
+ alembic.h
abc_frame_mapper.cpp
abc_frame_mapper.h
+ abc_info.cpp
abc_reader.cpp
abc_reader.h
abc_schema.h
diff --git a/source/blender/pointcache/alembic/abc_info.cpp b/source/blender/pointcache/alembic/abc_info.cpp
new file mode 100644
index 0000000..3b4c97f
--- /dev/null
+++ b/source/blender/pointcache/alembic/abc_info.cpp
@@ -0,0 +1,246 @@
+//-*****************************************************************************
+//
+// Copyright (c) 2009-2013,
+// Sony Pictures Imageworks, Inc. and
+// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Sony Pictures Imageworks, nor
+// Industrial Light & Magic nor the names of their contributors may be used
+// to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//-*****************************************************************************
+
+/*
+ * Copyright 2015, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list