Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/transform/transform_ops.c')
-rw-r--r--source/blender/editors/transform/transform_ops.c126
1 files changed, 121 insertions, 5 deletions
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 4ae0bca3284..0440a957539 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -99,6 +99,7 @@ char OP_SHRINK_FATTEN[] = "TFM_OT_shrink_fatten";
char OP_TILT[] = "TFM_OT_tilt";
char OP_TRACKBALL[] = "TFM_OT_trackball";
char OP_MIRROR[] = "TFM_OT_mirror";
+char OP_EDGE_SLIDE[] = "TFM_OT_edge_slide";
TransformModeItem transform_modes[] =
@@ -113,6 +114,7 @@ TransformModeItem transform_modes[] =
{OP_TILT, TFM_TILT},
{OP_TRACKBALL, TFM_TRACKBALL},
{OP_MIRROR, TFM_MIRROR},
+ {OP_EDGE_SLIDE, TFM_EDGE_SLIDE},
{NULL, 0}
};
@@ -150,8 +152,9 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot)
/* identifiers */
ot->name = "Select Orientation";
- ot->description= "Select orientation type.";
+ ot->description= "Select transformation orientation.";
ot->idname = "TFM_OT_select_orientation";
+ ot->flag = OPTYPE_UNDO;
/* api callbacks */
ot->invoke = select_orientation_invoke;
@@ -162,6 +165,92 @@ void TFM_OT_select_orientation(struct wmOperatorType *ot)
RNA_def_enum_funcs(prop, select_orientation_itemf);
}
+
+static int delete_orientation_exec(bContext *C, wmOperator *op)
+{
+ View3D *v3d = CTX_wm_view3d(C);
+ int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
+
+ BIF_removeTransformOrientationIndex(C, selected_index);
+
+ return OPERATOR_FINISHED;
+}
+
+static int delete_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ return delete_orientation_exec(C, op);
+}
+
+static int delete_orientation_poll(bContext *C)
+{
+ int selected_index = -1;
+ View3D *v3d = CTX_wm_view3d(C);
+
+ if (ED_operator_areaactive(C) == 0)
+ return 0;
+
+
+ if(v3d) {
+ selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
+ }
+
+ return selected_index >= 0;
+}
+
+void TFM_OT_delete_orientation(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Delete Orientation";
+ ot->description= "Delete transformation orientation.";
+ ot->idname = "TFM_OT_delete_orientation";
+ ot->flag = OPTYPE_UNDO;
+
+ /* api callbacks */
+ ot->invoke = delete_orientation_invoke;
+ ot->exec = delete_orientation_exec;
+ ot->poll = delete_orientation_poll;
+}
+
+static int create_orientation_exec(bContext *C, wmOperator *op)
+{
+ char name[36];
+ int use = RNA_boolean_get(op->ptr, "use");
+ int overwrite = RNA_boolean_get(op->ptr, "overwrite");
+
+ RNA_string_get(op->ptr, "name", name);
+
+ BIF_createTransformOrientation(C, op->reports, name, use, overwrite);
+
+ /* Do we need more refined tags? */
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static int create_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+ return create_orientation_exec(C, op);
+}
+
+void TFM_OT_create_orientation(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Create Orientation";
+ ot->description= "Create transformation orientation from selection.";
+ ot->idname = "TFM_OT_create_orientation";
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* api callbacks */
+ ot->invoke = create_orientation_invoke;
+ ot->exec = create_orientation_exec;
+ ot->poll = ED_operator_areaactive;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ RNA_def_string(ot->srna, "name", "", 35, "Name", "Text to insert at the cursor position.");
+ RNA_def_boolean(ot->srna, "use", 0, "Use after creation", "Select orientation after its creation");
+ RNA_def_boolean(ot->srna, "overwrite", 0, "Overwrite previous", "Overwrite previously created orientation with same name");
+}
+
static void transformops_exit(bContext *C, wmOperator *op)
{
saveTransform(C, op->customdata, op);
@@ -270,7 +359,7 @@ static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event)
TransInfo *t = op->customdata;
/* add temp handler */
- WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+ WM_event_add_modal_handler(C, op);
t->flag |= T_MODAL; // XXX meh maybe somewhere else
@@ -523,7 +612,7 @@ void TFM_OT_tosphere(struct wmOperatorType *ot)
ot->cancel = transform_cancel;
ot->poll = ED_operator_areaactive;
- RNA_def_float_percentage(ot->srna, "value", 0, 0, 1, "Percentage", "", 0, 1);
+ RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
Properties_Proportional(ot);
@@ -549,6 +638,26 @@ void TFM_OT_mirror(struct wmOperatorType *ot)
Properties_Constraints(ot);
}
+void TFM_OT_edge_slide(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Edge Slide";
+ ot->description= "Slide an edge loop along a mesh.";
+ ot->idname = OP_EDGE_SLIDE;
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+
+ /* api callbacks */
+ ot->invoke = transform_invoke;
+ ot->exec = transform_exec;
+ ot->modal = transform_modal;
+ ot->cancel = transform_cancel;
+ ot->poll = ED_operator_editmesh;
+
+ RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
+
+ RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
+}
+
void TFM_OT_transform(struct wmOperatorType *ot)
{
static EnumPropertyItem transform_mode_types[] = {
@@ -578,6 +687,7 @@ void TFM_OT_transform(struct wmOperatorType *ot)
{TFM_BEVEL, "BEVEL", 0, "Bevel", ""},
{TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""},
{TFM_ALIGN, "ALIGN", 0, "Align", ""},
+ {TFM_EDGE_SLIDE, "EDGESLIDE", 0, "Edge Slide", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -617,11 +727,14 @@ void transform_operatortypes(void)
WM_operatortype_append(TFM_OT_tilt);
WM_operatortype_append(TFM_OT_trackball);
WM_operatortype_append(TFM_OT_mirror);
+ WM_operatortype_append(TFM_OT_edge_slide);
WM_operatortype_append(TFM_OT_select_orientation);
+ WM_operatortype_append(TFM_OT_create_orientation);
+ WM_operatortype_append(TFM_OT_delete_orientation);
}
-void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid)
+void transform_keymap_for_space(struct wmWindowManager *wm, struct wmKeyMap *keymap, int spaceid)
{
wmKeymapItem *km;
@@ -641,7 +754,7 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
km = WM_keymap_add_item(keymap, "TFM_OT_warp", WKEY, KM_PRESS, KM_SHIFT, 0);
- km = WM_keymap_add_item(keymap, "TFM_OT_tosphere", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+ km = WM_keymap_add_item(keymap, "TFM_OT_tosphere", SKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_shear", SKEY, KM_PRESS, KM_ALT|KM_CTRL|KM_SHIFT, 0);
@@ -651,6 +764,9 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
km = WM_keymap_add_item(keymap, "TFM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
+ km = WM_keymap_add_item(keymap, "TFM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+ RNA_boolean_set(km->ptr, "use", 1);
+
break;
case SPACE_ACTION:
km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);