Esempio n. 1
0
static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
{
	MovieClip *clip= ED_space_clip(sc);
	MovieTracking *tracking= &clip->tracking;
	MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
	int width, height;
	struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } userdata;

	BKE_movieclip_get_size(clip, &sc->user, &width, &height);

	if(!width || !height)
		return;

	/* non-selected knot handles */
	userdata.hsize= UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
	userdata.sel= 0;
	userdata.act_track= act_track;
	UI_view2d_getscale(v2d, &userdata.xscale, &userdata.yscale);
	clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL);

	/* draw graph lines */
	glEnable(GL_BLEND);
	clip_graph_tracking_values_iterate(sc, act_track, tracking_segment_point_cb, tracking_segment_start_cb, tracking_segment_end_cb);
	glDisable(GL_BLEND);

	/* selected knot handles on top of curves */
	userdata.sel= 1;
	clip_graph_tracking_values_iterate(sc, &userdata, tracking_segment_knot_cb, NULL, NULL);
}
Esempio n. 2
0
static void draw_tracks_error_curves(SpaceClip *sc)
{
	MovieClip *clip = ED_space_clip_get_clip(sc);
	MovieTracking *tracking = &clip->tracking;
	TrackErrorCurveUserData data;

	data.clip = clip;
	data.tracking = tracking;
	data.tracking_object = BKE_tracking_object_get_active(tracking);
	data.active_track = BKE_tracking_track_get_active(tracking);
	data.matrix_initialized = false;
	BKE_movieclip_get_size(clip, &sc->user, &data.width, &data.height);
	data.aspy = 1.0f / tracking->camera.pixel_aspect;

	if (!data.width || !data.height) {
		return;
	}

	clip_graph_tracking_values_iterate(sc,
	                                   (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
	                                   (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
	                                   &data,
	                                   tracking_error_segment_point_cb,
	                                   tracking_error_segment_start_cb,
	                                   tracking_error_segment_end_cb);
}
Esempio n. 3
0
static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc)
{
	MovieClip *clip = ED_space_clip_get_clip(sc);
	MovieTracking *tracking = &clip->tracking;
	MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
	int width, height;
	TrackMotionCurveUserData userdata;

	BKE_movieclip_get_size(clip, &sc->user, &width, &height);

	if (!width || !height)
		return;

	/* non-selected knot handles */
	userdata.hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
	userdata.sel = false;
	userdata.act_track = act_track;
	UI_view2d_scale_get(v2d, &userdata.xscale, &userdata.yscale);
	clip_graph_tracking_values_iterate(sc,
	                                   (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
	                                   (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
	                                   &userdata, tracking_segment_knot_cb, NULL, NULL);

	/* draw graph lines */
	glEnable(GL_BLEND);
	clip_graph_tracking_values_iterate(sc,
	                                   (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
	                                   (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
	                                   act_track, tracking_segment_point_cb, tracking_segment_start_cb,
	                                   tracking_segment_end_cb);
	glDisable(GL_BLEND);

	/* selected knot handles on top of curves */
	userdata.sel = true;
	clip_graph_tracking_values_iterate(sc,
	                                   (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
	                                   (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
	                                   &userdata, tracking_segment_knot_cb, NULL, NULL);
}
Esempio n. 4
0
static bool mouse_select_curve(bContext *C, float co[2], bool extend)
{
	SpaceClip *sc = CTX_wm_space_clip(C);
	MovieClip *clip = ED_space_clip_get_clip(sc);
	MovieTracking *tracking = &clip->tracking;
	MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
	MouseSelectUserData userdata;

	mouse_select_init_data(&userdata, co);
	clip_graph_tracking_values_iterate(sc,
	                                   (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
	                                   (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
	                                   &userdata, find_nearest_tracking_segment_cb,
	                                   NULL, find_nearest_tracking_segment_end_cb);

	if (userdata.track) {
		if (extend) {
			if (act_track == userdata.track) {
				/* currently only single curve can be selected (selected curve represents active track) */
				act_track = NULL;
			}
		}
		else if (act_track != userdata.track) {
			SelectUserData selectdata = {SEL_DESELECT};
			MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);

			tracking->act_track = userdata.track;
			if ((sc->flag & SC_SHOW_GRAPH_SEL_ONLY) == 0) {
				ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
				BKE_tracking_track_select(tracksbase, userdata.track, TRACK_AREA_ALL, false);
			}

			/* deselect all knots on newly selected curve */
			clip_graph_tracking_iterate(sc,
			                            (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
			                            (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
			                            &selectdata, toggle_selection_cb);
		}

		return true;
	}

	return false;
}
Esempio n. 5
0
static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
{
	Scene *scene = CTX_data_scene(C);
	ARegion *ar = CTX_wm_region(C);
	SpaceClip *sc = CTX_wm_space_clip(C);
	View2D *v2d = &ar->v2d;
	ViewAllUserData userdata;
	float extra;

	userdata.max = -FLT_MAX;
	userdata.min = FLT_MAX;

	clip_graph_tracking_values_iterate(sc,
	                                   (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
	                                   (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
	                                   &userdata, view_all_cb, NULL, NULL);

	/* set extents of view to start/end frames */
	v2d->cur.xmin = (float) SFRA;
	v2d->cur.xmax = (float) EFRA;

	if (userdata.min < userdata.max) {
		v2d->cur.ymin = userdata.min;
		v2d->cur.ymax = userdata.max;
	}
	else {
		v2d->cur.ymin = -10;
		v2d->cur.ymax = 10;
	}

	/* we need an extra "buffer" factor on either side so that the endpoints are visible */
	extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
	v2d->cur.xmin -= extra;
	v2d->cur.xmax += extra;

	extra = 0.01f * BLI_rctf_size_y(&v2d->cur);
	v2d->cur.ymin -= extra;
	v2d->cur.ymax += extra;

	ED_region_tag_redraw(ar);

	return OPERATOR_FINISHED;
}
Esempio n. 6
0
static int mouse_select_curve(bContext *C, float co[2], int extend)
{
	SpaceClip *sc= CTX_wm_space_clip(C);
	MovieClip *clip= ED_space_clip(sc);
	MovieTracking *tracking= &clip->tracking;
	MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking);
	MouseSelectUserData userdata;

	mouse_select_init_data(&userdata, co);
	clip_graph_tracking_values_iterate(sc, &userdata, find_nearest_tracking_segment_cb, NULL, find_nearest_tracking_segment_end_cb);

	if(userdata.track) {
		if(extend) {
			if(act_track==userdata.track) {
				/* currently only single curve can be selected (selected curve represents active track) */
				act_track= NULL;
			}
		}
		else if(act_track!=userdata.track) {
			MovieTrackingMarker *marker;
			SelectUserData selectdata = {SEL_DESELECT};

			tracking->act_track= userdata.track;

			/* make active track be centered to screen */
			marker= BKE_tracking_get_marker(userdata.track, sc->user.framenr);

			clip_view_center_to_point(sc, marker->pos[0], marker->pos[1]);

			/* deselect all knots on newly selected curve */
			clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb);
		}

		return 1;
	}

	return 0;
}