diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-01-10 00:18:48 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-01-10 00:18:48 +0400 |
commit | 5bf5d5a8445da66a7da3e06a160bf9771f624d1b (patch) | |
tree | 26993a0362cc693e69c60e8f9e73c8fe249f1987 /source/blender/editors/space_clip | |
parent | dadb0d81221bb8ec706bea5da814dc4995723ba8 (diff) |
Camera tracking: tracks copy/paste operator
This commit implements basic clipboard support for movie tracking data
int clip editor. Used own implementation of clipboard like it's done
for sequencer.
Ideally it needed to be switched to more general clipboard system, but
currently this system is designed for text data only and it need to
be re-designed itself. But this feature is quite useful since object
tracking is implemented, so it should be OK to live with such own
implementation for a while.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_clip/tracking_ops.c | 101 |
3 files changed, 102 insertions, 6 deletions
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 64881499a31..3f7456e90dc 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -145,4 +145,7 @@ void CLIP_OT_clean_tracks(struct wmOperatorType *ot); void CLIP_OT_tracking_object_new(struct wmOperatorType *ot); void CLIP_OT_tracking_object_remove(struct wmOperatorType *ot); +void CLIP_OT_copy_tracks(struct wmOperatorType *ot); +void CLIP_OT_paste_tracks(struct wmOperatorType *ot); + #endif /* ED_CLIP_INTERN_H */ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 5291121571c..82da9b3b956 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -377,6 +377,10 @@ static void clip_operatortypes(void) /* object tracking */ WM_operatortype_append(CLIP_OT_tracking_object_new); WM_operatortype_append(CLIP_OT_tracking_object_remove); + + /* clipboard */ + WM_operatortype_append(CLIP_OT_copy_tracks); + WM_operatortype_append(CLIP_OT_paste_tracks); } static void clip_keymap(struct wmKeyConfig *keyconf) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index d6940d14dbf..b67fac69745 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1220,21 +1220,39 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip) return tot; } +static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) +{ + ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); + int hidden = 0; + + if ((sc->flag&SC_SHOW_MARKER_PATTERN)==0) + hidden |= TRACK_AREA_PAT; + + if ((sc->flag&SC_SHOW_MARKER_SEARCH)==0) + hidden |= TRACK_AREA_SEARCH; + + if (hidden) { + MovieTrackingTrack *track = tracksbase->first; + + while(track) { + BKE_tracking_track_flag(track, hidden, SELECT, 1); + + track = track->next; + } + } +} + static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit_r) { ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); MovieTrackingTrack *track; - int framenr= sc->user.framenr, hidden= 0; + int framenr= sc->user.framenr; int frames_limit= 0; - if((sc->flag&SC_SHOW_MARKER_PATTERN)==0) hidden|= TRACK_AREA_PAT; - if((sc->flag&SC_SHOW_MARKER_SEARCH)==0) hidden|= TRACK_AREA_SEARCH; + clear_invisible_track_selection(sc, clip); track= tracksbase->first; while(track) { - if(hidden) - BKE_tracking_track_flag(track, hidden, SELECT, 1); - if(TRACK_SELECTED(track)) { if((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { BKE_tracking_ensure_marker(track, framenr); @@ -3504,3 +3522,74 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } + +/********************** copy tracks to clipboard operator *********************/ + +static int copy_tracks_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *object = BKE_tracking_active_object(tracking); + + clear_invisible_track_selection(sc, clip); + + BKE_tracking_clipboard_copy_tracks(tracking, object); + + return OPERATOR_FINISHED; +} + +void CLIP_OT_copy_tracks(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Copy Tracks"; + ot->description = "Copy selected tracks to clipboard"; + ot->idname = "CLIP_OT_copy_tracks"; + + /* api callbacks */ + ot->exec = copy_tracks_exec; + ot->poll = ED_space_clip_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER; +} + +/********************** paste tracks from clipboard operator *********************/ + +static int paste_tracks_poll(bContext *C) +{ + if (ED_space_clip_poll(C)) { + return BKE_tracking_clipboard_has_tracks(); + } + + return 0; +} + +static int paste_tracks_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip(sc); + MovieTracking *tracking = &clip->tracking; + MovieTrackingObject *object = BKE_tracking_active_object(tracking); + + BKE_tracking_clipboard_paste_tracks(tracking, object); + + WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + + return OPERATOR_FINISHED; +} + +void CLIP_OT_paste_tracks(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Paste Tracks"; + ot->description = "Paste tracks from clipboard"; + ot->idname = "CLIP_OT_paste_tracks"; + + /* api callbacks */ + ot->exec = paste_tracks_exec; + ot->poll = paste_tracks_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} |