Commit: 2d1218a76e74e055d1de28da7a20113170aefaf8
Author: Dalai Felinto
Date:   Thu Sep 11 01:04:42 2014 +0200
Branches: multiview
https://developer.blender.org/rB2d1218a76e74e055d1de28da7a20113170aefaf8

Expose Image Stereo 3d format in the Properties Panel

This allow the users to change the stereo type after loading the image (in case 
the wrong encoding was wrongly pick)

Note: we do not let the user change between stereo and views after loading

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

M       release/scripts/startup/bl_ui/space_image.py
M       source/blender/editors/include/UI_interface.h
M       source/blender/editors/space_image/image_buttons.c
M       source/blender/makesrna/intern/rna_image.c
M       source/blender/makesrna/intern/rna_scene.c
M       source/blender/makesrna/intern/rna_ui_api.c

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

diff --git a/release/scripts/startup/bl_ui/space_image.py 
b/release/scripts/startup/bl_ui/space_image.py
index 7f2e317..47dca2f 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -665,6 +665,28 @@ class IMAGE_PT_view_properties(Panel):
             sub.row().prop(uvedit, "draw_stretch_type", expand=True)
 
 
+class IMAGE_PT_stereo_3d_properties(Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'UI'
+    bl_label = "Stereoscopy"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        sima = context.space_data
+        image = sima.image if sima else None
+        return (sima and image and image.type == 'IMAGE' and 
image.is_multiview and image.views_format == 'STEREO_3D')
+
+    def draw(self, context):
+        layout = self.layout
+
+        sima = context.space_data
+        ima = sima.image
+
+        box = layout.box()
+        box.template_image_stereo_3d(ima.stereo_3d_format)
+
+
 class IMAGE_PT_tools_transform_uvs(Panel, UVToolsPanel):
     bl_label = "Transform"
 
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 9952dfa..7994906 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -876,6 +876,7 @@ void uiTemplateGameStates(uiLayout *layout, struct 
PointerRNA *ptr, const char *
                       PointerRNA *used_ptr, const char *used_propname, int 
active_state);
 void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA 
*ptr, const char *propname, struct PointerRNA *userptr, int compact);
 void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int 
color_management);
+void uiTemplateImageStereo3d(uiLayout *layout, struct PointerRNA 
*stereo3d_format_ptr);
 void uiTemplateImageViews(uiLayout *layout, struct PointerRNA *imfptr);
 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image 
*ima, struct ImageUser *iuser);
 void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
diff --git a/source/blender/editors/space_image/image_buttons.c 
b/source/blender/editors/space_image/image_buttons.c
index 9094c61..676c3d7 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -1027,58 +1027,64 @@ void uiTemplateImageSettings(uiLayout *layout, 
PointerRNA *imfptr, int color_man
        }
 }
 
-void uiTemplateImageViews(uiLayout *layout, PointerRNA *imfptr)
+void uiTemplateImageStereo3d(uiLayout *layout, PointerRNA *stereo3d_format_ptr)
 {
-       ImageFormatData *imf = imfptr->data;
-       PropertyRNA *prop;
-       PointerRNA stereo3d_format_ptr;
-       Stereo3dFormat *stereo3d_format = &imf->stereo3d_format;
-
-       uiLayout *col, *box;
-
-       /* OpenEXR multiview is only to save multiview exr */
-       if (imf->imtype == R_IMF_IMTYPE_MULTIVIEW)
-               return;
+       Stereo3dFormat *stereo3d_format = stereo3d_format_ptr->data;
+       uiLayout *col;
 
        col = uiLayoutColumn(layout, false);
-
-       uiItemL(col, IFACE_("Views Format:"), ICON_NONE);
-       uiItemR(uiLayoutRow(col, false), imfptr, "views_format", 
UI_ITEM_R_EXPAND, NULL, ICON_NONE);
-
-       prop = RNA_struct_find_property(imfptr, "stereo_3d_format");
-       stereo3d_format_ptr = RNA_property_pointer_get(imfptr, prop);
-
-       box = uiLayoutBox(col);
-       uiLayoutSetActive(box, imf->views_format == R_IMF_VIEWS_STEREO_3D);
-       col = uiLayoutColumn(box, false);
-
-       uiItemR(col, &stereo3d_format_ptr, "display_mode", 0, NULL, ICON_NONE);
+       uiItemR(col, stereo3d_format_ptr, "display_mode", 0, NULL, ICON_NONE);
 
        switch (stereo3d_format->display_mode) {
                case S3D_DISPLAY_ANAGLYPH:
                {
-                       uiItemR(col, &stereo3d_format_ptr, "anaglyph_type", 0, 
NULL, ICON_NONE);
+                       uiItemR(col, stereo3d_format_ptr, "anaglyph_type", 0, 
NULL, ICON_NONE);
                        break;
                }
                case S3D_DISPLAY_INTERLACE:
                {
-                       uiItemR(col, &stereo3d_format_ptr, "interlace_type", 0, 
NULL, ICON_NONE);
-                       uiItemR(col, &stereo3d_format_ptr, 
"use_interlace_swap", 0, NULL, ICON_NONE);
+                       uiItemR(col, stereo3d_format_ptr, "interlace_type", 0, 
NULL, ICON_NONE);
+                       uiItemR(col, stereo3d_format_ptr, "use_interlace_swap", 
0, NULL, ICON_NONE);
                        break;
                }
                case S3D_DISPLAY_SIDEBYSIDE:
                {
-                       uiItemR(col, &stereo3d_format_ptr, 
"use_sidebyside_crosseyed", 0, NULL, ICON_NONE);
+                       uiItemR(col, stereo3d_format_ptr, 
"use_sidebyside_crosseyed", 0, NULL, ICON_NONE);
                        /* fall-through */
                }
                case S3D_DISPLAY_TOPBOTTOM:
                {
-                       uiItemR(col, &stereo3d_format_ptr, 
"use_squeezed_frame", 0, NULL, ICON_NONE);
+                       uiItemR(col, stereo3d_format_ptr, "use_squeezed_frame", 
0, NULL, ICON_NONE);
                        break;
                }
        }
 }
 
+void uiTemplateImageViews(uiLayout *layout, PointerRNA *imfptr)
+{
+       ImageFormatData *imf = imfptr->data;
+       PropertyRNA *prop;
+       PointerRNA stereo3d_format_ptr;
+
+       uiLayout *col, *box;
+
+       /* OpenEXR multiview is only to save multiview exr */
+       if (imf->imtype == R_IMF_IMTYPE_MULTIVIEW)
+               return;
+
+       col = uiLayoutColumn(layout, false);
+
+       uiItemL(col, IFACE_("Views Format:"), ICON_NONE);
+       uiItemR(uiLayoutRow(col, false), imfptr, "views_format", 
UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+
+       prop = RNA_struct_find_property(imfptr, "stereo_3d_format");
+       stereo3d_format_ptr = RNA_property_pointer_get(imfptr, prop);
+
+       box = uiLayoutBox(col);
+       uiLayoutSetActive(box, imf->views_format == R_IMF_VIEWS_STEREO_3D);
+       uiTemplateImageStereo3d(box, &stereo3d_format_ptr);
+}
+
 void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, 
ImageUser *iuser)
 {
        Scene *scene = CTX_data_scene(C);
diff --git a/source/blender/makesrna/intern/rna_image.c 
b/source/blender/makesrna/intern/rna_image.c
index cda7047..821adeb 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -564,6 +564,11 @@ static void rna_def_image(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Stereo 3D", "Image has left and right 
views");
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
+       prop = RNA_def_property(srna, "is_multiview", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_IS_MULTIVIEW);
+       RNA_def_property_ui_text(prop, "Multiple Views", "Image has more than 
one view");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
        prop = RNA_def_property(srna, "is_dirty", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_funcs(prop, "rna_Image_dirty_get", NULL);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -740,7 +745,7 @@ static void rna_def_image(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "views_format");
        RNA_def_property_enum_items(prop, views_format_items);
        RNA_def_property_ui_text(prop, "Views Format", "Mode to save scene 
views");
-       RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
        prop = RNA_def_property(srna, "stereo_3d_format", PROP_POINTER, 
PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "stereo3d_format");
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 2eea27d..cbd8975 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -36,6 +36,8 @@
 #include "DNA_userdef_types.h"
 #include "DNA_world_types.h"
 
+#include "IMB_imbuf_types.h"
+
 #include "BLI_math.h"
 
 #include "BLF_translation.h"
@@ -1825,6 +1827,27 @@ static void rna_FreestyleSettings_module_remove(ID *id, 
FreestyleSettings *confi
        WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
 }
 
+static void rna_Stereo3dFormat_update(Main *UNUSED(bmain), Scene 
*UNUSED(scene), PointerRNA *ptr)
+{
+       ID *id = ptr->id.data;
+
+       if (GS(id->name) == ID_IM) {
+               Image *ima = (Image *)id;
+               ImBuf *ibuf;
+               void *lock;
+
+               if ((ima->flag & IMA_IS_STEREO) == 0)
+                       return;
+
+               ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
+
+               if (ibuf) {
+                       BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
+               }
+               BKE_image_release_ibuf(ima, ibuf, lock);
+       }
+}
+
 #else
 
 static void rna_def_transform_orientation(BlenderRNA *brna)
@@ -4104,26 +4127,32 @@ static void 
rna_def_image_format_stereo3d_format(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "display_mode");
        RNA_def_property_enum_items(prop, stereo3d_display_items);
        RNA_def_property_ui_text(prop, "Stereo Mode", "");
+       RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, 
"rna_Stereo3dFormat_update");
 
        prop = RNA_def_property(srna, "anaglyph_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, stereo3d_anaglyph_type_items);
        RNA_def_property_ui_text(prop, "Anaglyph Type", "");
+       RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, 
"rna_Stereo3dFormat_update");
 
        prop = RNA_def_property(srna, "interlace_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_items(prop, stereo3d_interlace_type_items);
        RNA_def_property_ui_text(prop, "Interlace Type", "");
+       RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, 
"rna_Stereo3dFormat_update");
 
        prop = RNA_def_property(srna, "use_interlace_swap", PROP_BOOLEAN, 
PROP_BOOLEAN);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", S3D_INTERLACE_SWAP);
        RNA_def_property_ui_text(prop, "Swap Left/Right", "Swap left and right 
stereo channels");
+       RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, 
"rna_Stereo3dFormat_update");
 
        prop = RNA_def_property(srna, "use_sidebyside_crosseyed", PROP_BOOLEAN, 
PROP_BOOLEAN);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", 
S3D_SIDEBYSIDE_CROSSEYED);
        RNA_def_property_ui_text(prop, "Cross-Eyed", "Right eye should see left 
image and vice-versa");
+       RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, 
"rna_Stereo3dFormat_update");
 
        prop = RNA_def_property(srna, "use_squeezed_frame", PROP_BOOLEAN, 
PROP_BOOLEAN);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", 
S3D_UNSQUEEZED_FRAME);
        RNA_def_property_ui_text(prop, "Squeezed Frame", "Combine both views in 
a squeezed image");
+       RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, 
"rna_Stereo3dFormat_update");
 }
 
 /* use for render output and image save operator,
diff --git a/source/blender/makesrna/intern/rna_ui_api.c 
b/source/blender/makesrna/intern/rna_ui_api.c
index ff

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to