[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23762] trunk/blender: Bringing back the transform orientations panel.

Martin Poirier theeth at yahoo.com
Sat Oct 10 19:40:56 CEST 2009


Revision: 23762
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23762
Author:   theeth
Date:     2009-10-10 19:40:56 +0200 (Sat, 10 Oct 2009)

Log Message:
-----------
Bringing back the transform orientations panel.

Orientations enum in view3d. Full list of custom orientation (RNAified) in scene.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_view3d.py
    trunk/blender/source/blender/editors/transform/transform_ops.c
    trunk/blender/source/blender/makesrna/RNA_enum_types.h
    trunk/blender/source/blender/makesrna/intern/rna_scene.c
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/release/scripts/ui/space_view3d.py
===================================================================
--- trunk/blender/release/scripts/ui/space_view3d.py	2009-10-10 17:19:49 UTC (rev 23761)
+++ trunk/blender/release/scripts/ui/space_view3d.py	2009-10-10 17:40:56 UTC (rev 23762)
@@ -1256,8 +1256,15 @@
 		view = context.space_data
 
 		col = layout.column()
-		col.itemO("TFM_OT_select_orientation", text="Select")
+
+		col.itemR(view, "transform_orientation")
 		col.itemO("TFM_OT_create_orientation", text="Create")
+		
+#		orientation_index = view.__rna__.properties["transform_orientation"].items[view.transform_orientation].value
+#		
+#		if orientation_index >= 4:
+#			orientation = context.scene.orientations[orientation_index - 4]
+#			col.itemR(orientation, "name")
 		col.itemO("TFM_OT_delete_orientation", text="Delete")
 
 # Operators 

Modified: trunk/blender/source/blender/editors/transform/transform_ops.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_ops.c	2009-10-10 17:19:49 UTC (rev 23761)
+++ trunk/blender/source/blender/editors/transform/transform_ops.c	2009-10-10 17:40:56 UTC (rev 23762)
@@ -123,6 +123,8 @@
 	int orientation = RNA_enum_get(op->ptr, "orientation");
 
 	BIF_selectTransformOrientationValue(C, orientation);
+	
+	WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
 
 	return OPERATOR_FINISHED;
 }
@@ -140,12 +142,6 @@
 	return OPERATOR_CANCELLED;
 }
 
-static EnumPropertyItem *select_orientation_itemf(bContext *C, PointerRNA *ptr, int *free)
-{
-	*free= 1;
-	return BIF_enumTransformOrientation(C);
-}
-
 void TFM_OT_select_orientation(struct wmOperatorType *ot)
 {
 	PropertyRNA *prop;
@@ -162,7 +158,7 @@
 	ot->poll   = ED_operator_areaactive;
 
 	prop= RNA_def_enum(ot->srna, "orientation", orientation_items, V3D_MANIP_GLOBAL, "Orientation", "DOC_BROKEN");
-	RNA_def_enum_funcs(prop, select_orientation_itemf);
+	RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
 }
 
 
@@ -172,6 +168,8 @@
 	int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
 
 	BIF_removeTransformOrientationIndex(C, selected_index);
+	
+	WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
 
 	return OPERATOR_FINISHED;
 }
@@ -221,8 +219,7 @@
 
 	BIF_createTransformOrientation(C, op->reports, name, use, overwrite);
 
-	/* Do we need more refined tags? */
-	WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+	WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
 	
 	return OPERATOR_FINISHED;
 }
@@ -393,7 +390,7 @@
 
 	RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
 	prop= RNA_def_enum(ot->srna, "constraint_orientation", orientation_items, V3D_MANIP_GLOBAL, "Orientation", "DOC_BROKEN");
-	RNA_def_enum_funcs(prop, select_orientation_itemf);
+	RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
 }
 
 void TFM_OT_translate(struct wmOperatorType *ot)

Modified: trunk/blender/source/blender/makesrna/RNA_enum_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_enum_types.h	2009-10-10 17:19:49 UTC (rev 23761)
+++ trunk/blender/source/blender/makesrna/RNA_enum_types.h	2009-10-10 17:40:56 UTC (rev 23762)
@@ -58,6 +58,10 @@
 
 extern EnumPropertyItem object_type_items[];
 
+struct bContext;
+struct PointerRNA;
+EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
+
 #endif /* RNA_ENUM_TYPES */
 
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c	2009-10-10 17:19:49 UTC (rev 23761)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c	2009-10-10 17:40:56 UTC (rev 23762)
@@ -428,6 +428,24 @@
 }
 #else
 
+static void rna_def_transform_orientation(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	int matrix_dimsize[]= {3, 3};
+	
+	srna= RNA_def_struct(brna, "TransformOrientation", NULL);
+	
+	prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
+	RNA_def_property_float_sdna(prop, NULL, "mat");
+	RNA_def_property_multi_array(prop, 2, matrix_dimsize);
+	
+	prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+	RNA_def_property_string_sdna(prop, NULL, "name");
+	RNA_def_struct_name_property(srna, prop);
+}
+
 static void rna_def_tool_settings(BlenderRNA  *brna)
 {
 	StructRNA *srna;
@@ -2247,12 +2265,19 @@
 	RNA_def_property_struct_type(prop, "GreasePencil");
 	RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock");
 	
+	/* Transform Orientations */
+	prop= RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE);
+	RNA_def_property_collection_sdna(prop, NULL, "transform_spaces", NULL);
+	RNA_def_property_struct_type(prop, "TransformOrientation");
+	RNA_def_property_ui_text(prop, "Transform Orientations", "");
+
 	/* Nestled Data  */
 	rna_def_tool_settings(brna);
 	rna_def_unit_settings(brna);
 	rna_def_scene_render_data(brna);
 	rna_def_scene_game_data(brna);
 	rna_def_scene_render_layer(brna);
+	rna_def_transform_orientation(brna);
 	
 	/* Scene API */
 	RNA_api_scene(srna);

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c	2009-10-10 17:19:49 UTC (rev 23761)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c	2009-10-10 17:40:56 UTC (rev 23762)
@@ -77,6 +77,7 @@
 
 static EnumPropertyItem dc_all_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_Z, DC_LCMS, DC_ZERO};
 
+
 #ifdef RNA_RUNTIME
 
 #include "DNA_anim_types.h"
@@ -142,6 +143,66 @@
 	}
 }
 
+static int rna_TransformOrientation_getf(PointerRNA *ptr)
+{
+	View3D *v3d= (View3D*)ptr->data;
+
+	return v3d->twmode;
+}
+
+EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, int *free)
+{
+	Scene *scene;
+	ListBase *transform_spaces;
+	TransformOrientation *ts= NULL;
+
+	EnumPropertyItem global	= {V3D_MANIP_GLOBAL, "Global", 0, "Global", ""};
+	EnumPropertyItem normal = {V3D_MANIP_NORMAL, "Normal", 0, "Normal", ""};
+	EnumPropertyItem local = {V3D_MANIP_LOCAL, "Local", 0, "Local", ""};
+	EnumPropertyItem view = {V3D_MANIP_VIEW, "View", 0, "View", ""};
+	EnumPropertyItem tmp = {0, "", 0, "", ""};
+	EnumPropertyItem *item= NULL;
+	int i = V3D_MANIP_CUSTOM, totitem= 0;
+
+	RNA_enum_item_add(&item, &totitem, &global);
+	RNA_enum_item_add(&item, &totitem, &normal);
+	RNA_enum_item_add(&item, &totitem, &local);
+	RNA_enum_item_add(&item, &totitem, &view);
+
+	if(C) {
+		scene= CTX_data_scene(C);
+
+		if(scene) {
+			transform_spaces = &scene->transform_spaces;
+			ts = transform_spaces->first;
+		}
+		else
+		{
+			printf("no scene\n");
+		}
+	}
+	else
+	{
+		printf("no context\n");
+	}
+		
+	if(ts)
+		RNA_enum_item_add_separator(&item, &totitem);
+
+	for(; ts; ts = ts->next) {
+		tmp.identifier = ts->name;
+		tmp.name= ts->name;
+		tmp.value = i++;
+		RNA_enum_item_add(&item, &totitem, &tmp);
+	}
+
+	RNA_enum_item_end(&item, &totitem);
+
+	*free= 1;
+
+	return item;
+}
+
 /* Space Image Editor */
 
 static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
@@ -728,7 +789,8 @@
 	prop= RNA_def_property(srna, "transform_orientation", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "twmode");
 	RNA_def_property_enum_items(prop, transform_orientation_items);
-	RNA_def_property_ui_text(prop, "Transform Orientation", "The alignment of manipulator handles.");
+	RNA_def_property_enum_funcs(prop, "rna_TransformOrientation_getf", NULL, "rna_TransformOrientation_itemf");
+	RNA_def_property_ui_text(prop, "Transform Orientation", "Transformation orientation.");
 	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
 
 	prop= RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);





More information about the Bf-blender-cvs mailing list