本文整理匯總了C++中ED_space_clip_get_clip函數的典型用法代碼示例。如果您正苦於以下問題:C++ ED_space_clip_get_clip函數的具體用法?C++ ED_space_clip_get_clip怎麽用?C++ ED_space_clip_get_clip使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ED_space_clip_get_clip函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: circle_select_exec
static int circle_select_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *track;
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
int x, y, radius, width, height, mode, change = FALSE;
float zoomx, zoomy, offset[2], ellipse[2];
int framenr = ED_space_clip_get_clip_frame_number(sc);
/* get operator properties */
x = RNA_int_get(op->ptr, "x");
y = RNA_int_get(op->ptr, "y");
radius = RNA_int_get(op->ptr, "radius");
mode = RNA_int_get(op->ptr, "gesture_mode");
/* compute ellipse and position in unified coordinates */
ED_space_clip_get_size(sc, &width, &height);
ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy);
ellipse[0] = width * zoomx / radius;
ellipse[1] = height * zoomy / radius;
ED_clip_point_stable_pos(sc, ar, x, y, &offset[0], &offset[1]);
/* do selection */
track = tracksbase->first;
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0) {
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) {
if (mode == GESTURE_MODAL_SELECT)
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
else
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
change = TRUE;
}
}
track = track->next;
}
if (change) {
BKE_tracking_dopesheet_tag_update(tracking);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
return OPERATOR_FINISHED;
}
return OPERATOR_CANCELLED;
}
示例2: set_origin_exec
static int set_origin_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
Scene *scene = CTX_data_scene(C);
Object *camera = get_camera_with_movieclip(scene, clip);
int selected_count = count_selected_bundles(C);
if (selected_count == 0) {
BKE_report(op->reports,
RPT_ERROR,
"At least one track with bundle should be selected to "
"define origin position");
return OPERATOR_CANCELLED;
}
Object *object = get_orientation_object(C);
if (object == NULL) {
BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on");
return OPERATOR_CANCELLED;
}
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
float median[3] = {0.0f, 0.0f, 0.0f};
zero_v3(median);
for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_HAS_BUNDLE)) {
add_v3_v3(median, track->bundle_pos);
}
}
mul_v3_fl(median, 1.0f / selected_count);
float mat[4][4], vec[3];
BKE_tracking_get_camera_object_matrix(scene, camera, mat);
mul_v3_m4v3(vec, mat, median);
if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
sub_v3_v3(object->loc, vec);
}
else {
object_solver_inverted_matrix(scene, object, mat);
mul_v3_m4v3(vec, mat, vec);
copy_v3_v3(object->loc, vec);
}
DEG_id_tag_update(&clip->id, 0);
DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
}
示例3: apply_solution_scale_invoke
static int apply_solution_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
if (!RNA_struct_property_is_set(op->ptr, "distance")) {
RNA_float_set(op->ptr, "distance", clip->tracking.settings.dist);
}
return apply_solution_scale_exec(C, op);
}
示例4: clip_draw_cache_and_notes
void clip_draw_cache_and_notes(const bContext *C, SpaceClip *sc, ARegion *ar)
{
Scene *scene = CTX_data_scene(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
if (clip) {
draw_movieclip_cache(sc, ar, clip, scene);
draw_movieclip_notes(sc, ar);
}
}
示例5: mouse_select_knot
static bool mouse_select_knot(bContext *C, float co[2], bool extend)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
static const int delta = 6;
if (act_track) {
MouseSelectUserData userdata;
mouse_select_init_data(&userdata, co);
clip_graph_tracking_values_iterate_track(sc, act_track, &userdata,
find_nearest_tracking_knot_cb, NULL, NULL);
if (userdata.marker) {
int x1, y1, x2, y2;
if (UI_view2d_view_to_region_clip(v2d, co[0], co[1], &x1, &y1) &&
UI_view2d_view_to_region_clip(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2) &&
(abs(x2 - x1) <= delta && abs(y2 - y1) <= delta))
{
if (!extend) {
SelectUserData selectdata = {SEL_DESELECT};
clip_graph_tracking_iterate(sc,
(sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
(sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
&selectdata,
toggle_selection_cb);
}
if (userdata.coord == 0) {
if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_X) != 0)
userdata.marker->flag &= ~MARKER_GRAPH_SEL_X;
else
userdata.marker->flag |= MARKER_GRAPH_SEL_X;
}
else {
if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_Y) != 0)
userdata.marker->flag &= ~MARKER_GRAPH_SEL_Y;
else
userdata.marker->flag |= MARKER_GRAPH_SEL_Y;
}
return true;
}
}
}
return false;
}
示例6: do_lasso_select_marker
static int do_lasso_select_marker(bContext *C, int mcords[][2], short moves, short select)
{
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *track;
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
rcti rect;
int change = FALSE;
int framenr = ED_space_clip_get_clip_frame_number(sc);
/* get rectangle from operator */
BLI_lasso_boundbox(&rect, mcords, moves);
/* do actual selection */
track = tracksbase->first;
while (track) {
if ((track->flag & TRACK_HIDDEN) == 0) {
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (MARKER_VISIBLE(sc, track, marker)) {
float screen_co[2];
/* marker in screen coords */
ED_clip_point_stable_pos__reverse(sc, ar, marker->pos, screen_co);
if (BLI_in_rcti(&rect, screen_co[0], screen_co[1]) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED))
{
if (select)
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
else
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
}
change = TRUE;
}
}
track = track->next;
}
if (change) {
BKE_tracking_dopesheet_tag_update(tracking);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
}
return change;
}
示例7: apply_solution_scale_poll
static bool apply_solution_scale_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc != NULL) {
MovieClip *clip = ED_space_clip_get_clip(sc);
if (clip != NULL) {
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
return (tracking_object->flag & TRACKING_OBJECT_CAMERA) != 0;
}
}
return 0;
}
示例8: count_selected_bundles
static int count_selected_bundles(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
ListBase *tracksbase = BKE_tracking_get_active_tracks(&clip->tracking);
int tot = 0;
for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_HAS_BUNDLE)) {
tot++;
}
}
return tot;
}
示例9: delete_curve_exec
static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op))
{
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);
if (!act_track)
return OPERATOR_CANCELLED;
clip_delete_track(C, clip, act_track);
return OPERATOR_FINISHED;
}
示例10: CTX_wm_space_clip
static MovieTrackingPlaneTrack *tracking_plane_marker_check_slide(bContext *C,
const wmEvent *event,
int *corner_r)
{
const float distance_clip_squared = 12.0f * 12.0f;
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
int width, height;
float co[2];
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
int framenr = ED_space_clip_get_clip_frame_number(sc);
ED_space_clip_get_size(sc, &width, &height);
if (width == 0 || height == 0) {
return NULL;
}
ED_clip_mouse_pos(sc, ar, event->mval, co);
float min_distance_squared = FLT_MAX;
int min_corner = -1;
MovieTrackingPlaneTrack *min_plane_track = NULL;
for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
plane_track = plane_track->next) {
if (PLANE_TRACK_VIEW_SELECTED(plane_track)) {
MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
for (int i = 0; i < 4; i++) {
float distance_squared = mouse_to_plane_slide_zone_distance_squared(
co, plane_marker->corners[i], width, height);
if (distance_squared < min_distance_squared) {
min_distance_squared = distance_squared;
min_corner = i;
min_plane_track = plane_track;
}
}
}
}
if (min_distance_squared < distance_clip_squared / sc->zoom) {
if (corner_r != NULL) {
*corner_r = min_corner;
}
return min_plane_track;
}
return NULL;
}
示例11: graph_select_all_markers_exec
static int graph_select_all_markers_exec(bContext *C, wmOperator *op)
{
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);
MovieTrackingMarker *marker;
int action = RNA_enum_get(op->ptr, "action");
int a;
if (!act_track)
return OPERATOR_CANCELLED;
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
for (a = 0; a < act_track->markersnr; a++) {
marker = &act_track->markers[a];
if (marker->flag & MARKER_GRAPH_SEL) {
action = SEL_DESELECT;
break;
}
}
}
for (a = 0; a < act_track->markersnr; a++) {
marker = &act_track->markers[a];
switch (action) {
case SEL_SELECT:
marker->flag |= MARKER_GRAPH_SEL;
break;
case SEL_DESELECT:
marker->flag &= ~MARKER_GRAPH_SEL;
break;
case SEL_INVERT:
marker->flag ^= MARKER_GRAPH_SEL;
break;
}
}
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
return OPERATOR_FINISHED;
}
示例12: set_axis_exec
static int set_axis_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
Scene *scene = CTX_data_scene(C);
Object *object;
int axis = RNA_enum_get(op->ptr, "axis");
if (count_selected_bundles(C) != 1) {
BKE_report(op->reports,
RPT_ERROR,
"Single track with bundle should be selected to define axis");
return OPERATOR_CANCELLED;
}
object = get_orientation_object(C);
if (object == NULL) {
BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on");
return OPERATOR_CANCELLED;
}
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking,
tracking_object);
MovieTrackingTrack *track = tracksbase->first;
while (track) {
if (TRACK_VIEW_SELECTED(sc, track) &&
(track->flag & TRACK_HAS_BUNDLE))
{
break;
}
track = track->next;
}
set_axis(scene, object, clip, tracking_object, track, axis == 0 ? 'X' : 'Y');
DAG_id_tag_update(&clip->id, 0);
DAG_id_tag_update(&object->id, OB_RECALC_OB);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
}
示例13: mouse_select_curve
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;
}
示例14: dopesheet_select_channel_exec
static int dopesheet_select_channel_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
MovieTrackingDopesheetChannel *channel;
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
float location[2];
const bool extend = RNA_boolean_get(op->ptr, "extend");
int current_channel_index = 0, channel_index;
const bool show_selected_only = (dopesheet->flag & TRACKING_DOPE_SELECTED_ONLY) != 0;
RNA_float_get_array(op->ptr, "location", location);
channel_index = -(location[1] - (CHANNEL_FIRST + CHANNEL_HEIGHT_HALF)) / CHANNEL_STEP;
for (channel = dopesheet->channels.first; channel; channel = channel->next) {
MovieTrackingTrack *track = channel->track;
if (current_channel_index == channel_index) {
if (extend)
track->flag ^= TRACK_DOPE_SEL;
else
track->flag |= TRACK_DOPE_SEL;
if (track->flag & TRACK_DOPE_SEL) {
tracking->act_track = track;
BKE_tracking_track_select(tracksbase, track, TRACK_AREA_ALL, true);
}
else if (show_selected_only == false) {
BKE_tracking_track_deselect(track, TRACK_AREA_ALL);
}
}
else if (!extend)
track->flag &= ~TRACK_DOPE_SEL;
current_channel_index++;
}
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
return OPERATOR_FINISHED;
}
示例15: draw_movieclip_notes
static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
char str[256] = {0};
int block = FALSE;
if (tracking->stats) {
BLI_strncpy(str, tracking->stats->message, sizeof(str));
block = TRUE;
}
else {
if (sc->flag & SC_LOCK_SELECTION)
strcpy(str, "Locked");
}
if (str[0])
ED_region_info_draw(ar, str, block, 0.6f);
}