Camera tracking: backport refactoring made in local branches with masking and dopesheet view into trunk

Mostly related on changes in poll functions for tracking operators and some changes
to how interface is initializing for different view types.
This commit is contained in:
Sergey Sharybin 2012-04-29 12:32:26 +00:00
parent 16d4c49c46
commit c27c87dde4
16 changed files with 406 additions and 191 deletions

View File

@ -829,6 +829,10 @@ class CLIP_MT_view(Menu):
def draw(self, context):
layout = self.layout
sc = context.space_data
layout.prop(sc, "show_seconds")
layout.separator()
layout.operator("clip.properties", icon='MENU_PANEL')
layout.operator("clip.tools", icon='MENU_PANEL')

View File

@ -41,6 +41,9 @@ struct wmEvent;
/* clip_editor.c */
int ED_space_clip_poll(struct bContext *C);
int ED_space_clip_tracking_poll(struct bContext *C);
int ED_space_clip_tracking_size_poll(struct bContext *C);
int ED_space_clip_tracking_frame_poll(struct bContext *C);
void ED_space_clip_set(struct bContext *C, struct SpaceClip *sc, struct MovieClip *clip);
struct MovieClip *ED_space_clip(struct SpaceClip *sc);
@ -58,6 +61,8 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2]);
void ED_clip_point_stable_pos(struct bContext *C, float x, float y, float *xr, float *yr);
void ED_clip_mouse_pos(struct bContext *C, struct wmEvent *event, float co[2]);
int ED_space_clip_show_trackedit(struct SpaceClip *sc);
/* clip_ops.c */
void ED_operatormacros_clip(void);

View File

@ -63,6 +63,13 @@
/* Panels */
static int clip_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt))
{
SpaceClip *sc = CTX_wm_space_clip(C);
return TRUE;
}
void ED_clip_buttons_register(ARegionType *art)
{
PanelType *pt;
@ -72,6 +79,7 @@ void ED_clip_buttons_register(ARegionType *art)
strcpy(pt->label, "Grease Pencil");
pt->draw = gpencil_panel_standard;
pt->flag |= PNL_DEFAULT_CLOSED;
pt->poll = clip_grease_pencil_panel_poll;
BLI_addtail(&art->paneltypes, pt);
}

View File

@ -35,6 +35,7 @@
#include "BKE_movieclip.h"
#include "BKE_context.h"
#include "BKE_tracking.h"
#include "DNA_object_types.h" /* SELECT */
#include "BLI_utildefines.h"
@ -55,6 +56,8 @@
#include "clip_intern.h" // own include
/* ******** operactor poll functions ******** */
int ED_space_clip_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
@ -65,6 +68,51 @@ int ED_space_clip_poll(bContext *C)
return FALSE;
}
int ED_space_clip_tracking_poll(bContext *C)
{
SpaceClip *sc= CTX_wm_space_clip(C);
if (sc && sc->clip)
return ED_space_clip_show_trackedit(sc);
return FALSE;
}
int ED_space_clip_tracking_size_poll(bContext *C)
{
if (ED_space_clip_tracking_poll(C)) {
MovieClip *clip = CTX_data_edit_movieclip(C);
if (clip) {
SpaceClip *sc = CTX_wm_space_clip(C);
int width, height;
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
return width > 0 && height > 0;
}
}
return FALSE;
}
int ED_space_clip_tracking_frame_poll(bContext *C)
{
if (ED_space_clip_tracking_poll(C)) {
MovieClip *clip = CTX_data_edit_movieclip(C);
if (clip) {
SpaceClip *sc = CTX_wm_space_clip(C);
return BKE_movieclip_has_frame(clip, &sc->user);
}
}
return FALSE;
}
/* ******** editing functions ******** */
void ED_space_clip_set(bContext *C, SpaceClip *sc, MovieClip *clip)
{
sc->clip = clip;
@ -314,3 +362,12 @@ void ED_clip_mouse_pos(bContext *C, wmEvent *event, float co[2])
{
ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]);
}
int ED_space_clip_show_trackedit(SpaceClip *sc)
{
if (sc) {
return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION);
}
return FALSE;
}

View File

@ -87,60 +87,6 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float
glPopMatrix();
}
static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
{
View2D *v2d = &ar->v2d;
float xscale, yscale;
float vec[2];
/* Draw a light green line to indicate current frame */
vec[0] = (float)(sc->user.framenr * scene->r.framelen);
UI_ThemeColor(TH_CFRAME);
glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
vec[1] = v2d->cur.ymin;
glVertex2fv(vec);
vec[1] = v2d->cur.ymax;
glVertex2fv(vec);
glEnd();
glLineWidth(1.0);
UI_view2d_view_orthoSpecial(ar, v2d, 1);
/* because the frame number text is subject to the same scaling as the contents of the view */
UI_view2d_getscale(v2d, &xscale, &yscale);
glScalef(1.0f/xscale, 1.0f, 1.0f);
clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18);
/* restore view transform */
glScalef(xscale, 1.0, 1.0);
}
static void draw_graph_sfra_efra(Scene *scene, View2D *v2d)
{
UI_view2d_view_ortho(v2d);
/* currently clip editor supposes that editing clip length is equal to scene frame range */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
glDisable(GL_BLEND);
UI_ThemeColorShade(TH_BACK, -60);
/* thin lines where the actual frames are */
fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
}
static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack *UNUSED(track),
MovieTrackingMarker *marker, int UNUSED(coord), float val)
{
@ -280,8 +226,8 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
}
/* frame range */
draw_graph_sfra_efra(scene, v2d);
clip_draw_sfra_efra(v2d, scene);
/* current frame */
draw_graph_cfra(sc, ar, scene);
clip_draw_cfra(sc, ar, scene);
}

View File

@ -63,15 +63,13 @@
static int ED_space_clip_graph_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc && sc->clip) {
if (ED_space_clip_tracking_poll(C)) {
ARegion *ar = CTX_wm_region(C);
return ar->regiontype == RGN_TYPE_PREVIEW;
}
return 0;
return FALSE;
}
typedef struct {
@ -486,7 +484,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_curve_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;

View File

@ -38,6 +38,7 @@ struct MovieClip;
struct MovieTrackingMarker;
struct MovieTrackingTrack;
struct Scene;
struct ScrArea;
struct SpaceClip;
struct wmOperatorType;
@ -81,6 +82,7 @@ void CLIP_OT_rebuild_proxy(struct wmOperatorType *ot);
void CLIP_OT_mode_set(struct wmOperatorType *ot);
/* clip_toolbar.c */
struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa);
void CLIP_OT_tools(struct wmOperatorType *ot);
void CLIP_OT_properties(struct wmOperatorType *ot);
void ED_clip_tool_props_register(struct ARegionType *art);
@ -104,6 +106,9 @@ void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListB
void clip_view_center_to_point(struct SpaceClip *sc, float x, float y);
void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene);
/* tracking_ops.c */
void CLIP_OT_select(struct wmOperatorType *ot);
void CLIP_OT_select_all(struct wmOperatorType *ot);

View File

@ -56,7 +56,7 @@
/************************** properties ******************************/
static ARegion *clip_has_properties_region(ScrArea *sa)
ARegion *ED_clip_has_properties_region(ScrArea *sa)
{
ARegion *ar, *arnew;
@ -90,9 +90,9 @@ static int properties_poll(bContext *C)
static int properties_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = clip_has_properties_region(sa);
ARegion *ar = ED_clip_has_properties_region(sa);
if (ar)
if (ar && ar->alignment != RGN_ALIGN_NONE)
ED_region_toggle_hidden(C, ar);
return OPERATOR_FINISHED;
@ -167,7 +167,7 @@ static int tools_exec(bContext *C, wmOperator *UNUSED(op))
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = clip_has_tools_region(sa);
if (ar)
if (ar && ar->alignment != RGN_ALIGN_NONE)
ED_region_toggle_hidden(C, ar);
return OPERATOR_FINISHED;

View File

@ -29,6 +29,7 @@
* \ingroup spclip
*/
#include "DNA_scene_types.h"
#include "DNA_object_types.h" /* SELECT */
#include "MEM_guardedalloc.h"
@ -42,6 +43,9 @@
#include "BKE_tracking.h"
#include "BKE_depsgraph.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "WM_api.h"
#include "WM_types.h"
@ -53,6 +57,8 @@
#include "RNA_access.h"
#include "RNA_define.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "UI_view2d.h"
#include "clip_intern.h" // own include
@ -220,3 +226,57 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y)
sc->xof = (x - 0.5f) * width * aspx;
sc->yof = (y - 0.5f) * height * aspy;
}
void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
{
View2D *v2d = &ar->v2d;
float xscale, yscale;
float vec[2];
/* Draw a light green line to indicate current frame */
vec[0] = (float)(sc->user.framenr * scene->r.framelen);
UI_ThemeColor(TH_CFRAME);
glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
vec[1] = v2d->cur.ymin;
glVertex2fv(vec);
vec[1] = v2d->cur.ymax;
glVertex2fv(vec);
glEnd();
glLineWidth(1.0);
UI_view2d_view_orthoSpecial(ar, v2d, 1);
/* because the frame number text is subject to the same scaling as the contents of the view */
UI_view2d_getscale(v2d, &xscale, &yscale);
glScalef(1.0f/xscale, 1.0f, 1.0f);
clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18);
/* restore view transform */
glScalef(xscale, 1.0, 1.0);
}
void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
{
UI_view2d_view_ortho(v2d);
/* currently clip editor supposes that editing clip length is equal to scene frame range */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
glDisable(GL_BLEND);
UI_ThemeColorShade(TH_BACK, -60);
/* thin lines where the actual frames are */
fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
}

View File

@ -96,7 +96,7 @@ static void init_preview_region(const bContext *C, ARegion *ar)
ar->v2d.keeptot = 0;
}
static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa)
static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa)
{
ARegion *ar, *arnew;
@ -619,10 +619,13 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul
if (CTX_data_dir(member)) {
CTX_data_dir_set(result, clip_context_dir);
return TRUE;
}
else if (CTX_data_equals(member, "edit_movieclip")) {
CTX_data_id_pointer_set(result, &sc->clip->id);
if (sc->clip)
CTX_data_id_pointer_set(result, &sc->clip->id);
return TRUE;
}
@ -636,54 +639,163 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
Scene *scene = CTX_data_scene(C);
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
ARegion *ar_preview = clip_has_preview_region(C, sa);
ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
ARegion *ar_preview = ED_clip_has_preview_region(C, sa);
ARegion *ar_properties = ED_clip_has_properties_region(sa);
int main_visible = FALSE, preview_visible = FALSE, tools_visible = FALSE;
int tool_props_visible = FALSE, properties_visible = FALSE;
int view_changed = FALSE;
switch (sc->view) {
case SC_VIEW_CLIP:
if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) {
ar_preview->flag |= RGN_FLAG_HIDDEN;
ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
WM_event_remove_handlers((bContext*)C, &ar_preview->handlers);
view_changed = TRUE;
}
if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
ar_main->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
/* store graph region align */
if (ar_preview->alignment == RGN_ALIGN_TOP)
sc->runtime_flag &= ~SC_GRAPH_BOTTOM;
else
sc->runtime_flag |= SC_GRAPH_BOTTOM;
ar_preview->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
main_visible = TRUE;
preview_visible = FALSE;
tools_visible = TRUE;
tool_props_visible = TRUE;
properties_visible = TRUE;
break;
case SC_VIEW_GRAPH:
if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
ar_preview->flag &= ~RGN_FLAG_HIDDEN;
ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
ar_preview->v2d.cur = ar_preview->v2d.tot;
view_changed = TRUE;
}
if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
ar_main->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
if (sc->runtime_flag & SC_GRAPH_BOTTOM)
ar_preview->alignment = RGN_ALIGN_BOTTOM;
else
ar_preview->alignment = RGN_ALIGN_TOP;
view_changed = TRUE;
}
main_visible = TRUE;
preview_visible = TRUE;
tools_visible = TRUE;
tool_props_visible = TRUE;
properties_visible = TRUE;
break;
}
if (main_visible) {
if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) {
ar_main->flag &= ~RGN_FLAG_HIDDEN;
ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = TRUE;
}
if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
ar_main->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
}
else {
if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) {
ar_main->flag |= RGN_FLAG_HIDDEN;
ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
WM_event_remove_handlers((bContext *)C, &ar_main->handlers);
view_changed = TRUE;
}
if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
ar_main->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
}
if (properties_visible) {
if (ar_properties && (ar_properties->flag & RGN_FLAG_HIDDEN)) {
ar_properties->flag &= ~RGN_FLAG_HIDDEN;
ar_properties->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = TRUE;
}
if (ar_properties && ar_properties->alignment != RGN_ALIGN_RIGHT) {
ar_properties->alignment = RGN_ALIGN_RIGHT;
view_changed = TRUE;
}
}
else {
if (ar_properties && !(ar_properties->flag & RGN_FLAG_HIDDEN)) {
ar_properties->flag |= RGN_FLAG_HIDDEN;
ar_properties->v2d.flag &= ~V2D_IS_INITIALISED;
WM_event_remove_handlers((bContext *)C, &ar_properties->handlers);
view_changed = TRUE;
}
if (ar_properties && ar_properties->alignment != RGN_ALIGN_NONE) {
ar_properties->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
}
if (tools_visible) {
if (ar_tools && (ar_tools->flag & RGN_FLAG_HIDDEN)) {
ar_tools->flag &= ~RGN_FLAG_HIDDEN;
ar_tools->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = TRUE;
}
if (ar_tools && ar_tools->alignment != RGN_ALIGN_LEFT) {
ar_tools->alignment = RGN_ALIGN_LEFT;
view_changed = TRUE;
}
}
else {
if (ar_tools && !(ar_tools->flag & RGN_FLAG_HIDDEN)) {
ar_tools->flag |= RGN_FLAG_HIDDEN;
ar_tools->v2d.flag &= ~V2D_IS_INITIALISED;
WM_event_remove_handlers((bContext *)C, &ar_tools->handlers);
view_changed = TRUE;
}
if (ar_tools && ar_tools->alignment != RGN_ALIGN_NONE) {
ar_tools->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
}
if (tool_props_visible) {
if (ar_tool_props && (ar_tool_props->flag & RGN_FLAG_HIDDEN)) {
ar_tool_props->flag &= ~RGN_FLAG_HIDDEN;
ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED;
view_changed = TRUE;
}
if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV))) {
ar_tool_props->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
view_changed = TRUE;
}
}
else {
if (ar_tool_props && !(ar_tool_props->flag & RGN_FLAG_HIDDEN)) {
ar_tool_props->flag |= RGN_FLAG_HIDDEN;
ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED;
WM_event_remove_handlers((bContext *)C, &ar_tool_props->handlers);
view_changed = TRUE;
}
if (ar_tool_props && ar_tool_props->alignment != RGN_ALIGN_NONE) {
ar_tool_props->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
}
if (preview_visible) {
if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
ar_preview->flag &= ~RGN_FLAG_HIDDEN;
ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
ar_preview->v2d.cur = ar_preview->v2d.tot;
view_changed = TRUE;
}
if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
if (sc->runtime_flag & SC_GRAPH_BOTTOM)
ar_preview->alignment = RGN_ALIGN_BOTTOM;
else
ar_preview->alignment = RGN_ALIGN_TOP;
view_changed = TRUE;
}
}
else {
/* store graph region align */
if (ar_preview->alignment == RGN_ALIGN_TOP)
sc->runtime_flag &= ~SC_GRAPH_BOTTOM;
else if (ar_preview->alignment == RGN_ALIGN_BOTTOM)
sc->runtime_flag |= SC_GRAPH_BOTTOM;
if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) {
ar_preview->flag |= RGN_FLAG_HIDDEN;
ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
WM_event_remove_handlers((bContext *)C, &ar_preview->handlers);
view_changed = TRUE;
}
if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
ar_preview->alignment = RGN_ALIGN_NONE;
view_changed = TRUE;
}
}
if (view_changed) {
ED_area_initialize(wm, window, sa);
ED_area_tag_redraw(sa);
@ -832,13 +944,13 @@ static void clip_preview_area_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
static void clip_preview_area_draw(const bContext *C, ARegion *ar)
static void graph_area_draw(const bContext *C, ARegion *ar)
{
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
SpaceClip *sc = CTX_wm_space_clip(C);
Scene *scene = CTX_data_scene(C);
short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES;
short unitx, unity;
if (sc->flag & SC_LOCK_TIMECURSOR)
ED_clip_graph_center_current_frame(scene, ar);
@ -856,11 +968,20 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
unitx = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
unity = V2D_UNIT_VALUES;
scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
static void clip_preview_area_draw(const bContext *C, ARegion *ar)
{
SpaceClip *sc = CTX_wm_space_clip(C);
graph_area_draw(C, ar);
}
static void clip_preview_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn))
{
}

View File

@ -78,39 +78,6 @@
#include "clip_intern.h" // own include
static int space_clip_frame_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc) {
MovieClip *clip = ED_space_clip(sc);
if (clip)
return BKE_movieclip_has_frame(clip, &sc->user);
}
return FALSE;
}
static int space_clip_size_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc) {
MovieClip *clip = ED_space_clip(sc);
if (clip) {
int width, height;
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
return width > 0 && height > 0;
}
}
return FALSE;
}
/********************** add marker operator *********************/
static void add_marker(SpaceClip *sc, float x, float y)
@ -175,7 +142,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot)
/* api callbacks */
ot->invoke = add_marker_invoke;
ot->exec = add_marker_exec;
ot->poll = space_clip_size_poll;
ot->poll = ED_space_clip_tracking_size_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -220,7 +187,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_track_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -271,7 +238,7 @@ void CLIP_OT_delete_marker(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_marker_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -662,7 +629,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot)
ot->idname = "CLIP_OT_slide_marker";
/* api callbacks */
ot->poll = space_clip_size_poll;
ot->poll = ED_space_clip_tracking_size_poll;
ot->invoke = slide_marker_invoke;
ot->modal = slide_marker_modal;
@ -876,7 +843,7 @@ void CLIP_OT_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = select_exec;
ot->invoke = select_invoke;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
@ -953,7 +920,7 @@ void CLIP_OT_select_border(wmOperatorType *ot)
ot->invoke = WM_border_select_invoke;
ot->exec = border_select_exec;
ot->modal = WM_border_select_modal;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
@ -1037,7 +1004,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot)
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->exec = circle_select_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -1128,7 +1095,7 @@ void CLIP_OT_select_all(wmOperatorType *ot)
/* api callbacks */
ot->exec = select_all_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -1219,7 +1186,7 @@ void CLIP_OT_select_grouped(wmOperatorType *ot)
/* api callbacks */
ot->exec = select_groped_exec;
ot->poll = space_clip_size_poll;
ot->poll = ED_space_clip_tracking_size_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -1596,7 +1563,7 @@ void CLIP_OT_track_markers(wmOperatorType *ot)
/* api callbacks */
ot->exec = track_markers_exec;
ot->invoke = track_markers_invoke;
ot->poll = space_clip_frame_poll;
ot->poll = ED_space_clip_tracking_frame_poll;
ot->modal = track_markers_modal;
/* flags */
@ -1819,7 +1786,7 @@ void CLIP_OT_solve_camera(wmOperatorType *ot)
ot->exec = solve_camera_exec;
ot->invoke = solve_camera_invoke;
ot->modal = solve_camera_modal;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -1867,7 +1834,7 @@ void CLIP_OT_clear_solution(wmOperatorType *ot)
/* api callbacks */
ot->exec = clear_solution_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -1919,7 +1886,7 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot)
/* api callbacks */
ot->exec = clear_track_path_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -1977,7 +1944,7 @@ void CLIP_OT_disable_markers(wmOperatorType *ot)
/* api callbacks */
ot->exec = disable_markers_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -2035,7 +2002,7 @@ static Object *get_orientation_object(bContext *C)
static int set_orientation_poll(bContext *C)
{
if (space_clip_size_poll(C)) {
if (ED_space_clip_tracking_size_poll(C)) {
Scene *scene = CTX_data_scene(C);
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
@ -2645,7 +2612,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot)
static int set_solution_scale_poll(bContext *C)
{
if (space_clip_size_poll(C)) {
if (ED_space_clip_tracking_size_poll(C)) {
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
@ -2723,7 +2690,7 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot)
/* api callbacks */
ot->exec = set_center_principal_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -2777,7 +2744,7 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = hide_tracks_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -2816,7 +2783,7 @@ void CLIP_OT_hide_tracks_clear(wmOperatorType *ot)
/* api callbacks */
ot->exec = hide_tracks_clear_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -2898,7 +2865,7 @@ void CLIP_OT_detect_features(wmOperatorType *ot)
/* api callbacks */
ot->exec = detect_features_exec;
ot->poll = space_clip_frame_poll;
ot->poll = ED_space_clip_tracking_frame_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -2993,7 +2960,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot)
/* api callbacks */
ot->exec = frame_jump_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3050,7 +3017,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = join_tracks_exec;
ot->poll = space_clip_size_poll;
ot->poll = ED_space_clip_tracking_size_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3100,7 +3067,7 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = lock_tracks_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3150,7 +3117,7 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot)
/* api callbacks */
ot->exec = track_copy_color_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3199,7 +3166,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_add_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3259,7 +3226,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_remove_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3302,7 +3269,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_select_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3339,7 +3306,7 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_set_rotation_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3530,7 +3497,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = clean_tracks_exec;
ot->invoke = clean_tracks_invoke;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3567,7 +3534,7 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot)
/* api callbacks */
ot->exec = tracking_object_new_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3605,7 +3572,7 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = tracking_object_remove_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@ -3636,7 +3603,7 @@ void CLIP_OT_copy_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = copy_tracks_exec;
ot->poll = ED_space_clip_poll;
ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER;
@ -3646,7 +3613,7 @@ void CLIP_OT_copy_tracks(wmOperatorType *ot)
static int paste_tracks_poll(bContext *C)
{
if (ED_space_clip_poll(C)) {
if (ED_space_clip_tracking_poll(C)) {
return BKE_tracking_clipboard_has_tracks();
}

View File

@ -225,7 +225,11 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2])
adr[1]= out[1];
}
else if (t->spacetype==SPACE_CLIP) {
UI_view2d_to_region_no_clip(t->view, vec[0], vec[1], adr, adr+1);
float v[2];
copy_v2_v2(v, vec);
UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
}
}
@ -274,6 +278,19 @@ void applyAspectRatio(TransInfo *t, float *vec)
vec[0] /= aspx;
vec[1] /= aspy;
}
else if ((t->spacetype==SPACE_CLIP) && (t->mode==TFM_TRANSLATION)) {
if (t->options & CTX_MOVIECLIP) {
SpaceClip *sc = t->sa->spacedata.first;
float aspx, aspy;
int width, height;
ED_space_clip_size(sc, &width, &height);
ED_space_clip_aspect(sc, &aspx, &aspy);
vec[0] *= width / aspx;
vec[1] *= height / aspy;
}
}
}
void removeAspectRatio(TransInfo *t, float *vec)
@ -294,6 +311,19 @@ void removeAspectRatio(TransInfo *t, float *vec)
vec[0] *= aspx;
vec[1] *= aspy;
}
else if ((t->spacetype==SPACE_CLIP) && (t->mode==TFM_TRANSLATION)) {
if (t->options & CTX_MOVIECLIP) {
SpaceClip *sc = t->sa->spacedata.first;
float aspx, aspy;
int width, height;
ED_space_clip_size(sc, &width, &height);
ED_space_clip_aspect(sc, &aspx, &aspy);
vec[0] *= aspx / width;
vec[1] *= aspy / height;
}
}
}
static void viewRedrawForce(const bContext *C, TransInfo *t)
@ -624,10 +654,10 @@ int transformEvent(TransInfo *t, wmEvent *event)
t->redraw |= TREDRAW_HARD;
}
else if (t->mode == TFM_TRANSLATION) {
if (t->options&CTX_MOVIECLIP) {
if(t->options & CTX_MOVIECLIP) {
restoreTransObjects(t);
t->flag^= T_ALT_TRANSFORM;
t->flag ^= T_ALT_TRANSFORM;
t->redraw |= TREDRAW_HARD;
}
}
@ -1561,6 +1591,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
}
else if (t->spacetype == SPACE_CLIP) {
SpaceClip *sc = CTX_wm_space_clip(C);
unit_m3(t->spacemtx);
t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
t->options |= CTX_MOVIECLIP;

View File

@ -4924,14 +4924,16 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
ED_node_link_intersect_test(t->sa, 0);
}
else if (t->spacetype == SPACE_CLIP) {
SpaceClip *sc = t->sa->spacedata.first;
MovieClip *clip = ED_space_clip(sc);
if (t->options & CTX_MOVIECLIP) {
SpaceClip *sc = t->sa->spacedata.first;
MovieClip *clip = ED_space_clip(sc);
if (t->scene->nodetree) {
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
nodeUpdateID(t->scene->nodetree, &clip->id);
WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
if (t->scene->nodetree) {
/* tracks can be used for stabilization nodes,
* flush update for such nodes */
nodeUpdateID(t->scene->nodetree, &clip->id);
WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
}
}
}
else if (t->spacetype == SPACE_ACTION) {
@ -5402,6 +5404,8 @@ static void createTransNodeData(bContext *C, TransInfo *t)
/* *** CLIP EDITOR *** */
/* * motion tracking * */
enum {
transDataTracking_ModeTracks = 0,
transDataTracking_ModeCurves = 1,
@ -5923,7 +5927,8 @@ void createTransData(bContext *C, TransInfo *t)
}
else if (t->spacetype == SPACE_CLIP) {
t->flag |= T_POINTS|T_2D_EDIT;
createTransTrackingData(C, t);
if (t->options & CTX_MOVIECLIP)
createTransTrackingData(C, t);
}
else if (t->obedit) {
t->ext = NULL;

View File

@ -633,15 +633,16 @@ static void recalcData_image(TransInfo *t)
}
/* helper for recalcData() - for Movie Clip transforms */
static void recalcData_clip(TransInfo *t)
static void recalcData_spaceclip(TransInfo *t)
{
SpaceClip *sc = t->sa->spacedata.first;
MovieClip *clip = ED_space_clip(sc);
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
MovieTrackingTrack *track;
flushTransTracking(t);
track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
@ -658,10 +659,10 @@ static void recalcData_clip(TransInfo *t)
BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
}
}
track = track->next;
}
DAG_id_tag_update(&clip->id, 0);
}
@ -900,7 +901,7 @@ void recalcData(TransInfo *t)
recalcData_view3d(t);
}
else if (t->spacetype == SPACE_CLIP) {
recalcData_clip(t);
recalcData_spaceclip(t);
}
}

View File

@ -904,6 +904,7 @@ enum {
#define SC_SHOW_GRAPH_TRACKS (1<<15)
/*#define SC_SHOW_PYRAMID_LEVELS (1<<16) */ /* UNUSED */
#define SC_LOCK_TIMECURSOR (1<<17)
#define SC_SHOW_SECONDS (1<<18)
/* SpaceClip->mode */
#define SC_MODE_TRACKING 0

View File

@ -3104,6 +3104,12 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "postproc_flag", MOVIECLIP_PREVIEW_GRAYSCALE);
RNA_def_property_ui_text(prop, "Grayscale", "Display frame in grayscale mode");
RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
/* timeline */
prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_SECONDS);
RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
}