void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) { MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; View2DGrid *grid; short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES; /* grid */ grid = UI_view2d_grid_calc(scene, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); if (clip) { if (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) draw_tracks_motion_curves(v2d, sc); if (sc->flag & SC_SHOW_GRAPH_TRACKS_ERROR) draw_tracks_error_curves(sc); if (sc->flag & SC_SHOW_GRAPH_FRAMES) draw_frame_curves(sc); } /* frame range */ clip_draw_sfra_efra(v2d, scene); /* current frame */ clip_draw_cfra(sc, ar, scene); }
void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene) { MovieClip *clip = ED_space_clip_get_clip(sc); View2D *v2d = &ar->v2d; /* frame range */ clip_draw_sfra_efra(v2d, scene); if (clip) { MovieTracking *tracking = &clip->tracking; MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; MovieTrackingDopesheetChannel *channel; float y, xscale, yscale; float strip[4], selected_strip[4]; float height = (dopesheet->tot_channel * CHANNEL_STEP) + (CHANNEL_HEIGHT); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); y = (float) CHANNEL_FIRST; UI_view2d_getscale(v2d, &xscale, &yscale); /* setup colors for regular and selected strips */ UI_GetThemeColor3fv(TH_STRIP, strip); UI_GetThemeColor3fv(TH_STRIP_SELECT, selected_strip); strip[3] = 0.5f; selected_strip[3] = 1.0f; glEnable(GL_BLEND); clip_draw_dopesheet_background(ar, clip); for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float) (y - CHANNEL_HEIGHT_HALF); float ymaxc = (float) (y + CHANNEL_HEIGHT_HALF); /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax)) { MovieTrackingTrack *track = channel->track; float alpha; int i, sel = track->flag & TRACK_DOPE_SEL; /* selection background */ if (sel) { float color[4] = {0.0f, 0.0f, 0.0f, 0.3f}; float default_color[4] = {0.8f, 0.93f, 0.8f, 0.3f}; track_channel_color(track, default_color, color); glColor4fv(color); glRectf(v2d->cur.xmin, (float) y - CHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float) y + CHANNEL_HEIGHT_HALF); } alpha = (track->flag & TRACK_LOCKED) ? 0.5f : 1.0f; /* tracked segments */ for (i = 0; i < channel->tot_segment; i++) { int start_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i]); int end_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, channel->segments[2 * i + 1]); if (sel) glColor4fv(selected_strip); else glColor4fv(strip); if (start_frame != end_frame) { glRectf(start_frame, (float) y - STRIP_HEIGHT_HALF, end_frame, (float) y + STRIP_HEIGHT_HALF); draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); draw_keyframe_shape(end_frame, y, xscale, yscale, sel, alpha); } else { draw_keyframe_shape(start_frame, y, xscale, yscale, sel, alpha); } } /* keyframes */ i = 0; while (i < track->markersnr) { MovieTrackingMarker *marker = &track->markers[i]; if ((marker->flag & (MARKER_DISABLED | MARKER_TRACKED)) == 0) { int framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr); draw_keyframe_shape(framenr, y, xscale, yscale, sel, alpha); } i++; } } /* adjust y-position for next one */ y -= CHANNEL_STEP; } glDisable(GL_BLEND); } /* current frame */ clip_draw_cfra(sc, ar, scene); }