Fix #19473: Toggle Quad View options missing from UI.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 30 Jan 2010 03:22:22 +0000 (03:22 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 30 Jan 2010 03:22:22 +0000 (03:22 +0000)
release/scripts/ui/space_view3d.py
source/blender/editors/include/ED_view3d.h
source/blender/editors/space_view3d/view3d_edit.c
source/blender/makesrna/intern/rna_space.c

index 943b07d6af628bdb5da9876a90b65e7e99d122dd..225f7c5c5bb6c8f3627098ad23786bbbbb02192a 100644 (file)
@@ -1740,15 +1740,21 @@ class VIEW3D_PT_3dview_display(bpy.types.Panel):
         col.prop(gs, "material_mode", text="")
         col.prop(view, "textured_solid")
 
-# XXX - the Quad View options don't work yet
-#              layout.separator()
-#
-#              layout.operator("screen.region_foursplit", text="Toggle Quad View")
-#              col = layout.column()
-#              col.prop(view, "lock_rotation")
-#              col.prop(view, "box_preview")
-#              col.prop(view, "box_clip")
+        layout.separator()
+
+        region = view.region_quadview
+
+        layout.operator("screen.region_quadview", text="Toggle Quad View")
 
+        if region:
+            col = layout.column()
+            col.prop(region, "lock_rotation")
+            row = col.row()
+            row.enabled = region.lock_rotation
+            row.prop(region, "box_preview")
+            row = col.row()
+            row.enabled = region.lock_rotation and region.box_preview
+            row.prop(region, "box_clip")
 
 class VIEW3D_PT_3dview_meshdisplay(bpy.types.Panel):
     bl_space_type = 'VIEW_3D'
index b2ce1c76f83606bf8e75a7ce60d43365d570df62..fea92d5440485651f8bb53ab4eafa276fe20a2e1 100644 (file)
@@ -160,6 +160,7 @@ void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct AR
 void view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]);
 
 Base *ED_view3d_give_base_under_cursor(struct bContext *C, short *mval);
+void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar);
 
 #endif /* ED_VIEW3D_H */
 
index 1196ea73f54ef047e0d35e2c5d7bca3f80819989..ad061532045f696c71d03cef7a3a40d45d852053 100644 (file)
@@ -162,6 +162,8 @@ static void view3d_boxview_clip(ScrArea *sa)
                        if(rv3d->viewlock & RV3D_BOXCLIP) {
                                rv3d->rflag |= RV3D_CLIPPING;
                                memcpy(rv3d->clip, clip, sizeof(clip));
+                               if(rv3d->clipbb) MEM_freeN(rv3d->clipbb);
+                               rv3d->clipbb= MEM_dupallocN(bb);
                        }
                }
        }
@@ -227,6 +229,34 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
        view3d_boxview_clip(sa);
 }
 
+void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar)
+{
+       RegionView3D *rv3d= ar->regiondata;
+       short viewlock;
+
+       /* this function copies flags from the first of the 3 other quadview
+          regions to the 2 other, so it assumes this is the region whose
+          properties are always being edited, weak */
+       viewlock= rv3d->viewlock;
+
+       if((viewlock & RV3D_LOCKED)==0)
+               viewlock= 0;
+       else if((viewlock & RV3D_BOXVIEW)==0)
+               viewlock &= ~RV3D_BOXCLIP;
+
+       for(; ar; ar= ar->prev) {
+               if(ar->alignment==RGN_ALIGN_QSPLIT) {
+                       rv3d= ar->regiondata;
+                       rv3d->viewlock= viewlock;
+               }
+       }
+
+       if(rv3d->viewlock & RV3D_BOXVIEW)
+               view3d_boxview_copy(sa, sa->regionbase.last);
+
+       ED_area_tag_redraw(sa);
+}
+
 /* ************************** init for view ops **********************************/
 
 typedef struct ViewOpsData {
index 4d742c5d4d6df3e89c5639788e9ed171adb05398..71de3a19ce7b5d3cd80f3d2dab11f7b2884d3191 100644 (file)
@@ -158,6 +158,40 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr)
        }
 }
 
+static ScrArea *rna_area_from_space(PointerRNA *ptr)
+{
+       bScreen *sc = (bScreen*)ptr->id.data;
+       SpaceLink *link= (SpaceLink*)ptr->data;
+       ScrArea *sa;
+
+       for(sa=sc->areabase.first; sa; sa=sa->next)
+               if(BLI_findindex(&sa->spacedata, link) != -1)
+                       return sa;
+
+       return NULL;
+}
+
+static void rna_area_region_from_regiondata(PointerRNA *ptr, ScrArea **sa_r, ARegion **ar_r)
+{
+       bScreen *sc = (bScreen*)ptr->id.data;
+       ScrArea *sa;
+       ARegion *ar;
+       void *regiondata= ptr->data;
+
+       *sa_r= NULL;
+       *ar_r= NULL;
+
+       for(sa=sc->areabase.first; sa; sa=sa->next) {
+               for(ar=sa->regionbase.first; ar; ar=ar->next) {
+                       if(ar->regiondata == regiondata) {
+                               *sa_r= sa;
+                               *ar_r= ar;
+                               return;
+                       }
+               }
+       }
+}
+
 static PointerRNA rna_CurrentOrientation_get(PointerRNA *ptr)
 {
        Scene *scene = ((bScreen*)ptr->id.data)->scene;
@@ -243,6 +277,38 @@ static void rna_Space3DView_layer_set(PointerRNA *ptr, const int *values)
        v3d->lay= ED_view3d_scene_layer_set(v3d->lay, values);
 }
 
+static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr)
+{
+       View3D *v3d= (View3D*)(ptr->data);
+       ScrArea *sa= rna_area_from_space(ptr);
+       ListBase *regionbase= (sa->spacedata.first == v3d)? &sa->regionbase: &v3d->regionbase;
+       ARegion *ar= regionbase->last; /* always last in list, weak .. */
+
+       return rna_pointer_inherit_refine(ptr, &RNA_Region3DView, ar->regiondata);
+}
+
+static PointerRNA rna_SpaceView3D_region_quadview_get(PointerRNA *ptr)
+{
+       View3D *v3d= (View3D*)(ptr->data);
+       ScrArea *sa= rna_area_from_space(ptr);
+       ListBase *regionbase= (sa->spacedata.first == v3d)? &sa->regionbase: &v3d->regionbase;
+       ARegion *ar= regionbase->last; /* always before last in list, weak .. */
+
+       ar= (ar->alignment == RGN_ALIGN_QSPLIT)? ar->prev: NULL;
+
+       return rna_pointer_inherit_refine(ptr, &RNA_Region3DView, (ar)? ar->regiondata: NULL);
+}
+
+static void rna_Region3DView_quadview_update(Main *main, Scene *scene, PointerRNA *ptr)
+{
+       ScrArea *sa;
+       ARegion *ar;
+
+       rna_area_region_from_regiondata(ptr, &sa, &ar);
+       if(sa && ar && ar->alignment==RGN_ALIGN_QSPLIT)
+               ED_view3d_quadview_update(sa, ar);
+}
+
 /* Space Image Editor */
 
 static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
@@ -914,21 +980,6 @@ static void rna_def_space_3dview(BlenderRNA *brna)
        RNA_def_property_pointer_funcs(prop, "rna_CurrentOrientation_get", NULL, NULL);
        RNA_def_property_ui_text(prop, "Current Transform Orientation", "Current Transformation orientation.");
 
-       prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, "RegionView3D", "viewlock", RV3D_LOCKED);
-       RNA_def_property_ui_text(prop, "Lock", "Lock View Rotation");
-       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
-       
-       prop= RNA_def_property(srna, "box_preview", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, "RegionView3D", "viewlock", RV3D_BOXVIEW);
-       RNA_def_property_ui_text(prop, "Box", "");
-       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
-       
-       prop= RNA_def_property(srna, "box_clip", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, "RegionView3D", "viewlock", RV3D_BOXCLIP);
-       RNA_def_property_ui_text(prop, "Clip", "");
-       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
-
        prop= RNA_def_property(srna, "lock_camera_and_layers", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "scenelock", 1);
        RNA_def_property_boolean_funcs(prop, NULL, "rna_Space3DView_lock_camera_and_layers_set");
@@ -948,6 +999,37 @@ static void rna_def_space_3dview(BlenderRNA *brna)
        RNA_def_property_array(prop, 20);
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Used Layers", "Layers that contain something.");
+
+       prop= RNA_def_property(srna, "region_3d", PROP_POINTER, PROP_NONE);
+       RNA_def_property_struct_type(prop, "Region3DView");
+       RNA_def_property_pointer_funcs(prop, "rna_SpaceView3D_region_3d_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "3D Region", "3D region in this space, in case of quad view the camera region.");
+
+       prop= RNA_def_property(srna, "region_quadview", PROP_POINTER, PROP_NONE);
+       RNA_def_property_struct_type(prop, "Region3DView");
+       RNA_def_property_pointer_funcs(prop, "rna_SpaceView3D_region_quadview_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "Quad View Region", "3D region that defines the quad view settings.");
+
+       /* region */
+
+       srna= RNA_def_struct(brna, "Region3DView", "Region");
+       RNA_def_struct_sdna(srna, "RegionView3D");
+       RNA_def_struct_ui_text(srna, "3D View Region", "3D View region data");
+
+       prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "viewlock", RV3D_LOCKED);
+       RNA_def_property_ui_text(prop, "Lock", "Lock view rotation in side views.");
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_Region3DView_quadview_update");
+       
+       prop= RNA_def_property(srna, "box_preview", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "viewlock", RV3D_BOXVIEW);
+       RNA_def_property_ui_text(prop, "Box", "Sync view position between side views.");
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_Region3DView_quadview_update");
+       
+       prop= RNA_def_property(srna, "box_clip", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "viewlock", RV3D_BOXCLIP);
+       RNA_def_property_ui_text(prop, "Clip", "Clip objects based on what's visible in other side views.");
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_Region3DView_quadview_update");
 }
 
 static void rna_def_space_buttons(BlenderRNA *brna)