Shortcuts to set solver frames: alt-1 for Keyframe A, alt-2 for keyframe B.
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 26 Jul 2012 09:50:27 +0000 (09:50 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 26 Jul 2012 09:50:27 +0000 (09:50 +0000)
source/blender/editors/space_clip/clip_intern.h
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_clip/tracking_ops.c

index c61a0baa82e3b9ebc538454e4eb2c943f0fc073f..c4652c2f04db88455b78936f6d94bd035de1d0e6 100644 (file)
@@ -150,6 +150,8 @@ void CLIP_OT_hide_tracks(struct wmOperatorType *ot);
 void CLIP_OT_hide_tracks_clear(struct wmOperatorType *ot);
 void CLIP_OT_lock_tracks(struct wmOperatorType *ot);
 
+void CLIP_OT_set_solver_keyframe(struct wmOperatorType *ot);
+
 void CLIP_OT_set_origin(struct wmOperatorType *ot);
 void CLIP_OT_set_plane(struct wmOperatorType *ot);
 void CLIP_OT_set_axis(struct wmOperatorType *ot);
index 7e08372441fe3acb8f19c1f59242b8e416042e31..1b70588b59de81c4ddc0f229f19b17a23eff7de5 100644 (file)
@@ -477,6 +477,8 @@ static void clip_operatortypes(void)
        WM_operatortype_append(CLIP_OT_hide_tracks_clear);
        WM_operatortype_append(CLIP_OT_lock_tracks);
 
+       WM_operatortype_append(CLIP_OT_set_solver_keyframe);
+
        /* orientation */
        WM_operatortype_append(CLIP_OT_set_origin);
        WM_operatortype_append(CLIP_OT_set_plane);
@@ -562,6 +564,12 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "CLIP_OT_solve_camera", SKEY, KM_PRESS, KM_SHIFT, 0);
 
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_set_solver_keyframe", ONEKEY, KM_PRESS, KM_ALT, 0);
+       RNA_enum_set(kmi->ptr, "keyframe", 0);
+
+       kmi = WM_keymap_add_item(keymap, "CLIP_OT_set_solver_keyframe", TWOKEY, KM_PRESS, KM_ALT, 0);
+       RNA_enum_set(kmi->ptr, "keyframe", 1);
+
        /* ******** Hotkeys avalaible for main region only ******** */
 
        keymap = WM_keymap_find(keyconf, "Clip Editor", SPACE_CLIP, 0);
index 2e4ba844646801ecd36aa8dea26dd95ae7638abc..97c25df914a1e76001c5e510cbbb5f931eed0520 100644 (file)
@@ -2842,6 +2842,49 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot)
        RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Lock action to execute");
 }
 
+/********************** set keyframe operator *********************/
+
+static int set_solver_keyframe_exec(bContext *C, wmOperator *op)
+{
+       SpaceClip *sc = CTX_wm_space_clip(C);
+       MovieClip *clip = ED_space_clip_get_clip(sc);
+       MovieTracking *tracking = &clip->tracking;
+       MovieTrackingSettings *settings = &tracking->settings;
+       int keyframe = RNA_enum_get(op->ptr, "keyframe");
+       int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr);
+
+       if (keyframe == 0)
+               settings->keyframe1 = framenr;
+       else
+               settings->keyframe2 = framenr;
+
+       return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_set_solver_keyframe(wmOperatorType *ot)
+{
+       static EnumPropertyItem keyframe_items[] = {
+               {0, "KEYFRAME_A", 0, "Keyframe A", ""},
+               {1, "KEYFRAME_B", 0, "Keyframe B", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       /* identifiers */
+       ot->name = "Set Selver Keyframe";
+       ot->description = "Set keyframe used by solver";
+       ot->idname = "CLIP_OT_set_solver_keyframe";
+
+       /* api callbacks */
+       ot->exec = set_solver_keyframe_exec;
+       ot->poll = ED_space_clip_tracking_poll;
+
+       /* flags */
+       ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+       /* properties */
+       RNA_def_enum(ot->srna, "keyframe", keyframe_items, 0, "Keyframe", "keyframe to set");
+}
+
 /********************** track copy color operator *********************/
 
 static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op))