Bringing back the transform orientations panel.

Orientations enum in view3d. Full list of custom orientation (RNAified) in scene.
This commit is contained in:
Martin Poirier 2009-10-10 17:40:56 +00:00
parent 811a767827
commit 622ffe263a
5 changed files with 107 additions and 12 deletions

@ -1256,8 +1256,15 @@ class VIEW3D_PT_transform_orientations(bpy.types.Panel):
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

@ -123,6 +123,8 @@ static int select_orientation_exec(bContext *C, wmOperator *op)
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 @@ static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event
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 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot)
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 @@ static int delete_orientation_exec(bContext *C, wmOperator *op)
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 @@ static int create_orientation_exec(bContext *C, wmOperator *op)
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 @@ void Properties_Constraints(struct wmOperatorType *ot)
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)

@ -58,6 +58,10 @@ extern EnumPropertyItem unpack_method_items[];
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 */

@ -428,6 +428,24 @@ static void rna_Physics_update(bContext *C, PointerRNA *ptr)
}
#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 @@ void RNA_def_scene(BlenderRNA *brna)
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);

@ -77,6 +77,7 @@ EnumPropertyItem space_type_items[] = {
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 StructRNA* rna_Space_refine(struct PointerRNA *ptr)
}
}
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 @@ static void rna_def_space_3dview(BlenderRNA *brna)
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);