diff options
18 files changed, 552 insertions, 27 deletions
diff --git a/extern/libmv/libmv-capi.cpp b/extern/libmv/libmv-capi.cpp index 863e16515df..8a56135a8f6 100644 --- a/extern/libmv/libmv-capi.cpp +++ b/extern/libmv/libmv-capi.cpp @@ -457,6 +457,37 @@ double libmv_reporojectionErrorForTrack(libmv_Reconstruction *libmv_reconstructi return total_error / num_reprojected; } +double libmv_reporojectionErrorForImage(libmv_Reconstruction *libmv_reconstruction, int image) +{ + libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction; + libmv::CameraIntrinsics *intrinsics = &libmv_reconstruction->intrinsics; + libmv::vector<libmv::Marker> markers = libmv_reconstruction->tracks.MarkersInImage(image); + const libmv::EuclideanCamera *camera = reconstruction->CameraForImage(image); + int num_reprojected = 0; + double total_error = 0.0; + + if (!camera) + return 0; + + for (int i = 0; i < markers.size(); ++i) { + const libmv::EuclideanPoint *point = reconstruction->PointForTrack(markers[i].track); + + if (!point) { + continue; + } + + num_reprojected++; + + libmv::Marker reprojected_marker = ProjectMarker(*point, *camera, *intrinsics); + double ex = reprojected_marker.x - markers[i].x; + double ey = reprojected_marker.y - markers[i].y; + + total_error += sqrt(ex*ex + ey*ey); + } + + return total_error / num_reprojected; +} + int libmv_reporojectionCameraForImage(libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4]) { libmv::EuclideanReconstruction *reconstruction = &libmv_reconstruction->reconstruction; diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h index d77e9ac62fa..e48b5526152 100644 --- a/extern/libmv/libmv-capi.h +++ b/extern/libmv/libmv-capi.h @@ -67,6 +67,7 @@ struct libmv_Reconstruction *libmv_solveReconstruction(struct libmv_Tracks *trac double focal_length, double principal_x, double principal_y, double k1, double k2, double k3); int libmv_reporojectionPointForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track, double pos[3]); double libmv_reporojectionErrorForTrack(struct libmv_Reconstruction *libmv_reconstruction, int track); +double libmv_reporojectionErrorForImage(struct libmv_Reconstruction *libmv_reconstruction, int image); int libmv_reporojectionCameraForImage(struct libmv_Reconstruction *libmv_reconstruction, int image, double mat[4][4]); double libmv_reprojectionError(struct libmv_Reconstruction *libmv_reconstruction); void libmv_destroyReconstruction(struct libmv_Reconstruction *libmv_reconstruction); diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index 53297dbea32..fab6886b314 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -94,6 +94,7 @@ KM_HIERARCHY = [ ('Console', 'CONSOLE', 'WINDOW', []), ('Clip', 'CLIP_EDITOR', 'WINDOW', [ ('Clip Editor', 'CLIP_EDITOR', 'WINDOW', []), + ('Clip Graph Editor', 'CLIP_EDITOR', 'WINDOW', []), ]), ('View3D Gesture Circle', 'EMPTY', 'WINDOW', []), diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 2f0a825a7ba..3ff625a815c 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -45,6 +45,17 @@ class CLIP_HT_header(Header): if clip: layout.prop(sc, "mode", text="") + layout.prop(sc, "view", text="", expand=True) + + if sc.view == 'GRAPH': + row = layout.row(align=True) + + if sc.show_filters: + row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN', text="Filters") + row.prop(sc, "show_graph_frames", icon='SEQUENCE', text="") + row.prop(sc, "show_graph_tracks", icon='ANIM', text="") + else: + row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT', text="Filters") row = layout.row() row.template_ID(sc, "clip", open='clip.open') @@ -891,6 +902,5 @@ class CLIP_MT_stabilize_2d_specials(Menu): layout.operator('clip.stabilize_2d_select') - if __name__ == "__main__": # only for live edit. bpy.utils.register_module(__name__) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 3208450f5a4..00b1553b02e 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1235,6 +1235,7 @@ static int retrive_libmv_reconstruct(MovieTracking *tracking, struct libmv_Recon if(libmv_reporojectionCameraForImage(libmv_reconstruction, a, matd)) { int i, j; float mat[4][4]; + float error= libmv_reporojectionErrorForImage(libmv_reconstruction, a); for(i=0; i<4; i++) for(j= 0; j<4; j++) @@ -1250,6 +1251,7 @@ static int retrive_libmv_reconstruct(MovieTracking *tracking, struct libmv_Recon copy_m4_m4(reconstructed[reconstruction->camnr].mat, mat); reconstructed[reconstruction->camnr].framenr= a; + reconstructed[reconstruction->camnr].error= error; reconstruction->camnr++; } else { ok= 0; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 16bccd416f6..309ea28c400 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -842,6 +842,8 @@ void ui_theme_init_default(void) SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255); SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255); SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255); + SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255); + SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255); } @@ -1671,6 +1673,8 @@ void init_userdef_do_versions(void) SETCOL(btheme->tclip.lock_marker, 0x7f, 0x7f, 0x7f, 255); SETCOL(btheme->tclip.path_before, 0xff, 0x00, 0x00, 255); SETCOL(btheme->tclip.path_after, 0x00, 0x00, 0xff, 255); + SETCOL(btheme->tclip.grid, 0x5e, 0x5e, 0x5e, 255); + SETCOL(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255); } } } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index a27350110fb..09329b6b98d 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2804,6 +2804,8 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) if(redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) return 1; break; + case SPACE_CLIP: + return 1; } } return 0; diff --git a/source/blender/editors/space_clip/CMakeLists.txt b/source/blender/editors/space_clip/CMakeLists.txt index ba0b584b5ca..e3d36c50db9 100644 --- a/source/blender/editors/space_clip/CMakeLists.txt +++ b/source/blender/editors/space_clip/CMakeLists.txt @@ -41,7 +41,8 @@ set(INC_SYS set(SRC space_clip.c - clip_draw.c + clip_draw_graph.c + clip_draw_main.c clip_toolbar.c clip_ops.c tracking_ops.c diff --git a/source/blender/editors/space_clip/clip_draw_graph.c b/source/blender/editors/space_clip/clip_draw_graph.c new file mode 100644 index 00000000000..d7222d4f65c --- /dev/null +++ b/source/blender/editors/space_clip/clip_draw_graph.c @@ -0,0 +1,225 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2011 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_clip/clip_draw_graph.c + * \ingroup spclip + */ + +#include "DNA_movieclip_types.h" +#include "DNA_scene_types.h" +#include "DNA_object_types.h" /* SELECT */ + +#include "MEM_guardedalloc.h" + +#include "BKE_context.h" +#include "BKE_movieclip.h" +#include "BKE_tracking.h" + +#include "BLI_utildefines.h" +#include "BLI_math.h" +#include "BLI_string.h" + +#include "ED_screen.h" +#include "ED_clip.h" + +#include "BIF_gl.h" + +#include "WM_types.h" + +#include "UI_interface.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "BLF_api.h" + +#include "clip_intern.h" // own include + +static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) +{ + View2D *v2d= &ar->v2d; + uiStyle *style= UI_GetStyle(); + int fontid= style->widget.uifont_id, fontsize; + float xscale, yscale, x, y; + char str[32] = " t"; /* t is the character to start replacing from */ + short slen; + 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); + + BLI_snprintf(&str[4], sizeof(str)-4, "%d", sc->user.framenr); + slen= BLF_width(fontid, str); + fontsize= BLF_height(fontid, str); + + /* get starting coordinates for drawing */ + x= (float)sc->user.framenr * xscale; + y= 18; + + /* draw green box around/behind text */ + UI_ThemeColorShade(TH_CFRAME, 0); + glRectf(x, y, x+slen, y+fontsize+4); + + /* draw current frame number - black text */ + UI_ThemeColor(TH_TEXT); + BLF_position(fontid, x-5, y+2, 0.f); + BLF_draw(fontid, str, strlen(str)); + + /* restore view transform */ + glScalef(xscale, 1.0, 1.0); +} + +static void draw_clip_tracks_curves(SpaceClip *sc) +{ + MovieClip *clip= ED_space_clip(sc); + MovieTracking *tracking= &clip->tracking; + MovieTrackingTrack *track; + int size[2]; + + static float colors[2][3] = {{1.f, 0.f, 0.f}, + {0.f, 1.f, 0.f}}; + + + BKE_movieclip_acquire_size(clip, &sc->user, &size[0], &size[1]); + + if(!size[0] || !size[1]) + return; + + track= tracking->tracks.first; + while(track) { + if(TRACK_VIEW_SELECTED(sc, track)) { + int coord; + + for(coord= 0; coord<2; coord++) { + int i, lines= 0, prevfra= 0; + float prevval= 0.f; + + glColor3fv(colors[coord]); + + for(i= 0; i<track->markersnr; i++) { + MovieTrackingMarker *marker= &track->markers[i]; + + if(marker->flag&MARKER_DISABLED) + continue; + + if(lines && marker->framenr!=prevfra+1) { + glEnd(); + lines= 0; + } + + if(!lines) { + glBegin(GL_LINE_STRIP); + lines= 1; + prevval= marker->pos[coord]; + } + + glVertex2f(marker->framenr, (marker->pos[coord] - prevval) * size[coord]); + + prevval= marker->pos[coord]; + prevfra= marker->framenr; + } + + if(lines) + glEnd(); + } + } + + track= track->next; + } +} + +static void draw_clip_frame_curves(SpaceClip *sc) +{ + MovieClip *clip= ED_space_clip(sc); + MovieTracking *tracking= &clip->tracking; + MovieTrackingReconstruction *reconstruction= &tracking->reconstruction; + int i, lines= 0, prevfra= 0; + + glColor3f(0.f, 0.f, 1.f); + + for(i= 0; i<reconstruction->camnr; i++) { + MovieReconstructedCamera *camera= &reconstruction->cameras[i]; + + if(lines && camera->framenr!=prevfra+1) { + glEnd(); + lines= 0; + } + + if(!lines) { + glBegin(GL_LINE_STRIP); + lines= 1; + } + + glVertex2f(camera->framenr, camera->error); + + prevfra= camera->framenr; + } + + if(lines) + glEnd(); +} + +void draw_clip_graph(SpaceClip *sc, ARegion *ar, Scene *scene) +{ + 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(sc->flag&SC_SHOW_GRAPH_TRACKS) + draw_clip_tracks_curves(sc); + + if(sc->flag&SC_SHOW_GRAPH_FRAMES) + draw_clip_frame_curves(sc); + + /* current frame */ + draw_graph_cfra(sc, ar, scene); +} diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw_main.c index f6d13e3e5b9..97e85b1e856 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw_main.c @@ -27,7 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/editors/space_clip/clip_draw.c +/** \file blender/editors/space_clip/clip_draw_main.c * \ingroup spclip */ @@ -61,6 +61,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "UI_interface.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -77,7 +78,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc float x; int *points, totseg, i, a; float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1), fontsize, fontwidth; - uiStyle *style= U.uistyles.first; + uiStyle *style= UI_GetStyle(); int fontid= style->widget.uifont_id; char str[32]; @@ -179,13 +180,13 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc if(x+fontwidth+6.f<=ar->winx) { glRecti(x, 8.f, x+fontwidth+6.f, 12.f+fontsize); - glColor3f(0.f, 0.f, 0.f); + UI_ThemeColor(TH_TEXT); BLF_position(fontid, x+2.f, 10.f, 0.f); BLF_draw(fontid, str, strlen(str)); } else { glRecti(x+framelen, 8.f, x+framelen-fontwidth-6.f, 12.f+fontsize); - glColor3f(0.f, 0.f, 0.f); + UI_ThemeColor(TH_TEXT); BLF_position(fontid, x-2.f-fontwidth+framelen, 10.f, 0.f); BLF_draw(fontid, str, strlen(str)); } @@ -936,6 +937,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, marker= BKE_tracking_get_marker(track, framenr); if(MARKER_VISIBLE(sc, marker)) { + float npos[2]; copy_v4_v4(vec, track->bundle_pos); vec[3]=1; @@ -944,10 +946,9 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, pos[0]= (pos[0]/(pos[3]*2.0f)+0.5f)*width; pos[1]= (pos[1]/(pos[3]*2.0f)+0.5f)*height*aspy; - if(pos[0]>=0.f && pos[1]>=0.f && pos[0]<=width && pos[1]<=height*aspy) { - float npos[2]; - BKE_tracking_apply_intrinsics(tracking, pos, npos); + BKE_tracking_apply_intrinsics(tracking, pos, npos); + if(npos[0]>=0.f && npos[1]>=0.f && npos[0]<=width && npos[1]<=height*aspy) { vec[0]= (marker->pos[0]+track->offset[0])*width; vec[1]= (marker->pos[1]+track->offset[1])*height*aspy; diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index a991566e9a2..c3fee663b54 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -102,10 +102,13 @@ void CLIP_OT_stabilize_2d_set_rotation(struct wmOperatorType *ot); void CLIP_OT_clean_tracks(wmOperatorType *ot); -/* clip_draw.c */ +/* clip_draw_main.c */ void draw_clip_main(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); void draw_clip_grease_pencil(struct bContext *C, int onlyv2d); +/* clip_draw_graph.c */ +void draw_clip_graph(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); + /* clip_buttons.c */ void ED_clip_buttons_register(struct ARegionType *art); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 88426089946..14318d276ff 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -60,6 +60,8 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "UI_view2d.h" + #include "clip_intern.h" // own include /** \file blender/editors/space_clip/clip_ops.c @@ -329,7 +331,6 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event) static void view_pan_exit(bContext *C, wmOperator *op, int cancel) { - SpaceClip *sc= CTX_wm_space_clip(C); ViewPanData *vpd= op->customdata; if(cancel) { @@ -795,16 +796,31 @@ static int frame_from_event(bContext *C, wmEvent *event) { ARegion *ar= CTX_wm_region(C); Scene *scene= CTX_data_scene(C); + int framenr= 0; + + if(ar->regiontype == RGN_TYPE_WINDOW) { + float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1); + + framenr= sfra+event->mval[0]/framelen; + } else { + float viewx, viewy; - float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); - return sfra+event->mval[0]/framelen; + framenr= (int)floor(viewx+0.5f); + } + + return framenr; } static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(event->mval[1]>16) - return OPERATOR_PASS_THROUGH; + ARegion *ar= CTX_wm_region(C); + + if(ar->regiontype == RGN_TYPE_WINDOW) { + if(event->mval[1]>16) + return OPERATOR_PASS_THROUGH; + } RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index b4d851cb72d..961c1f3b5fe 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -41,6 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BKE_main.h" #include "BKE_context.h" @@ -70,6 +71,56 @@ #include "clip_intern.h" // own include +static void init_preview_region(const bContext *C, ARegion *ar) +{ + Scene *scene= CTX_data_scene(C); + + ar->regiontype= RGN_TYPE_PREVIEW; + ar->alignment= RGN_ALIGN_TOP; + ar->flag|= RGN_FLAG_HIDDEN; + + ar->v2d.tot.xmin= 0.0f; + ar->v2d.tot.ymin= (float)scene->r.sfra - 10.0f; + ar->v2d.tot.xmax= (float)scene->r.efra; + ar->v2d.tot.ymax= 10.0f; + + ar->v2d.cur= ar->v2d.tot; + + ar->v2d.min[0]= FLT_MIN; + ar->v2d.min[1]= FLT_MIN; + + ar->v2d.max[0]= MAXFRAMEF; + ar->v2d.max[1]= FLT_MAX; + + ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + + ar->v2d.keeptot= 0; +} + +static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa) +{ + ARegion *ar, *arnew; + + ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); + if(ar) + return ar; + + /* add subdiv level; after header */ + ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + + /* is error! */ + if(ar==NULL) + return NULL; + + arnew= MEM_callocN(sizeof(ARegion), "clip preview region"); + + BLI_insertlinkbefore(&sa->regionbase, ar, arnew); + init_preview_region(C, arnew); + + return arnew; +} + static void clip_scopes_tag_refresh(ScrArea *sa) { SpaceClip *sc= (SpaceClip *)sa->spacedata.first; @@ -101,14 +152,14 @@ static void clip_stabilization_tag_refresh(ScrArea *sa) /* ******************** default callbacks for clip space ***************** */ -static SpaceLink *clip_new(const bContext *UNUSED(C)) +static SpaceLink *clip_new(const bContext *C) { ARegion *ar; SpaceClip *sc; sc= MEM_callocN(sizeof(SpaceClip), "initclip"); sc->spacetype= SPACE_CLIP; - sc->flag= SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_SHOW_GPENCIL|SC_MANUAL_CALIBRATION; + sc->flag= SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_SHOW_GPENCIL|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES; sc->zoom= 1.0f; sc->path_length= 20; sc->scopes.track_preview_height= 120; @@ -121,7 +172,7 @@ static SpaceLink *clip_new(const bContext *UNUSED(C)) ar->alignment= RGN_ALIGN_BOTTOM; /* tools view */ - ar= MEM_callocN(sizeof(ARegion), "tools for logic"); + ar= MEM_callocN(sizeof(ARegion), "tools for clip"); BLI_addtail(&sc->regionbase, ar); ar->regiontype= RGN_TYPE_TOOLS; @@ -135,12 +186,18 @@ static SpaceLink *clip_new(const bContext *UNUSED(C)) ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; /* properties view */ - ar= MEM_callocN(sizeof(ARegion), "properties for logic"); + ar= MEM_callocN(sizeof(ARegion), "properties for clip"); BLI_addtail(&sc->regionbase, ar); ar->regiontype= RGN_TYPE_UI; ar->alignment= RGN_ALIGN_RIGHT; + /* preview view */ + ar= MEM_callocN(sizeof(ARegion), "preview for clip"); + + BLI_addtail(&sc->regionbase, ar); + init_preview_region(C, ar); + /* main area */ ar= MEM_callocN(sizeof(ARegion), "main area for clip"); @@ -450,6 +507,13 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path", "space_data.use_mute_footage"); transform_keymap_for_space(keyconf, keymap, SPACE_CLIP); + + /* ******** Hotkeys avalaible for preview region only ******** */ + + keymap= WM_keymap_find(keyconf, "Clip Graph Editor", SPACE_CLIP, 0); + + /* "timeline" */ + WM_keymap_add_item(keymap, "CLIP_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0); } const char *clip_context_dir[]= {"edit_movieclip", NULL}; @@ -470,9 +534,54 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul return 0; } -static void clip_refresh(const bContext *C, ScrArea *UNUSED(sa)) +static void clip_refresh(const bContext *C, ScrArea *sa) { - SpaceClip *sc= CTX_wm_space_clip(C); + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *window= CTX_wm_window(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); + int view_changed= 0; + + 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= 1; + } + if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { + ar_main->alignment= RGN_ALIGN_NONE; + view_changed= 1; + } + if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { + ar_preview->alignment= RGN_ALIGN_NONE; + view_changed= 1; + } + 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= 1; + } + if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) { + ar_main->alignment= RGN_ALIGN_NONE; + view_changed= 1; + } + if (ar_preview && ar_preview->alignment != RGN_ALIGN_TOP) { + ar_preview->alignment= RGN_ALIGN_TOP; + view_changed= 1; + } + break; + } + + if(view_changed) { + ED_area_initialize(wm, window, sa); + ED_area_tag_redraw(sa); + } BKE_movieclip_user_set_frame(&sc->user, CTX_data_scene(C)->r.cfra); } @@ -601,6 +710,52 @@ static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn) } } +/****************** preview region ******************/ + +static void clip_preview_area_init(wmWindowManager *wm, ARegion *ar) +{ + wmKeyMap *keymap; + + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); + + /* own keymap */ + keymap= WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0); + WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + + keymap= WM_keymap_find(wm->defaultconf, "Clip Graph Editor", SPACE_CLIP, 0); + 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) +{ + 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; + + /* clear and setup matrix */ + UI_ThemeClearColor(TH_BACK); + glClear(GL_COLOR_BUFFER_BIT); + + UI_view2d_view_ortho(v2d); + + /* data... */ + draw_clip_graph(sc, ar, scene); + + /* reset view matrix */ + UI_view2d_view_restore(C); + + /* scrollers */ + 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_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn)) +{ +} + /****************** header region ******************/ /* add handlers, stuff you only do once or on area/region changes */ @@ -720,6 +875,17 @@ void ED_spacetype_clip(void) BLI_addhead(&st->regiontypes, art); + /* preview */ + art= MEM_callocN(sizeof(ARegionType), "spacetype clip region preview"); + art->regionid = RGN_TYPE_PREVIEW; + art->prefsizey = 240; + art->init= clip_preview_area_init; + art->draw= clip_preview_area_draw; + art->listener= clip_preview_area_listener; + art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + + BLI_addhead(&st->regiontypes, art); + /* regions: properties */ art= MEM_callocN(sizeof(ARegionType), "spacetype clip region properties"); art->regionid= RGN_TYPE_UI; diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 585ebde2c9a..ff6817bb9fe 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -579,7 +579,8 @@ typedef struct SpaceClip { struct MovieClipScopes scopes; /* different scoped displayed in space panels */ int flag; /* flags */ - int mode; /*editor mode */ + short mode; /* editor mode (editing context being displayed) */ + short view; /* type of the clip editor view */ int path_length; /* length of displaying path, in frames */ @@ -977,12 +978,19 @@ enum { #define SC_SHOW_STABLE (1<<10) #define SC_MANUAL_CALIBRATION (1<<11) #define SC_SHOW_GPENCIL (1<<12) +#define SC_SHOW_FILTERS (1<<13) +#define SC_SHOW_GRAPH_FRAMES (1<<14) +#define SC_SHOW_GRAPH_TRACKS (1<<15) /* SpaceClip->mode */ #define SC_MODE_TRACKING 0 #define SC_MODE_RECONSTRUCTION 1 #define SC_MODE_DISTORTION 2 +/* SpaceClip->view */ +#define SC_VIEW_CLIP 0 +#define SC_VIEW_GRAPH 1 + /* space types, moved from DNA_screen_types.h */ /* Do NOT change order, append on end. types are hardcoded needed */ enum { diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index a023a59a0cb..aad67d36731 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -50,7 +50,8 @@ struct MovieTrackingTrack; struct MovieTracking; typedef struct MovieReconstructedCamera { - int framenr, pad; + int framenr; + float error; float mat[4][4]; } MovieReconstructedCamera; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 3cd20194876..202fb759e89 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -964,6 +964,12 @@ static void rna_SpaceClipEditor_lock_selection_update(Main *UNUSED(bmain), Scene sc->ylockof= 0.f; } +static void rna_SpaceClipEditor_view_type_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + ScrArea *sa= rna_area_from_space(ptr); + ED_area_tag_refresh(sa); +} + #else static void rna_def_space(BlenderRNA *brna) @@ -2747,9 +2753,14 @@ static void rna_def_space_clip(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem mode_items[] = { - {SC_MODE_TRACKING, "TRACKING", 0, "Tracking", "Show tracking and solving tools"}, - {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", 0, "Reconstruction", "Show tracking/reconstruction tools"}, - {SC_MODE_DISTORTION, "DISTORTION", 0, "Distortion", "Show distortion tools"}, + {SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"}, + {SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction", "Show tracking/reconstruction tools"}, + {SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem view_items[] = { + {SC_VIEW_CLIP, "CLIP", ICON_SEQUENCE, "Clip", "Show editing clip preview"}, + {SC_VIEW_GRAPH, "GRAPH", ICON_IPO, "Graph", "Show graph view for active element"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceClipEditor", "Space"); @@ -2775,9 +2786,16 @@ static void rna_def_space_clip(BlenderRNA *brna) prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, mode_items); - RNA_def_property_ui_text(prop, "Mode", "Current clip editor mode"); + RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, "rna_SpaceClipEditor_clip_mode_update"); + /* view */ + prop= RNA_def_property(srna, "view", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "view"); + RNA_def_property_enum_items(prop, view_items); + RNA_def_property_ui_text(prop, "View", "Type of the clip editor view"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, "rna_SpaceClipEditor_view_type_update"); + /* show pattern */ prop= RNA_def_property(srna, "show_marker_pattern", PROP_BOOLEAN, PROP_NONE); RNA_def_property_ui_text(prop, "Show Marker Pattern", "Show pattern boundbox for markers"); @@ -2868,6 +2886,24 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GPENCIL); RNA_def_property_ui_text(prop, "Show Grease Pencil", "Show grease pencil strokes over the footage"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); + + /* show filters */ + prop= RNA_def_property(srna, "show_filters", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_FILTERS); + RNA_def_property_ui_text(prop, "Show Filters", "Show filters for graph editor"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); + + /* show graph_frames */ + prop= RNA_def_property(srna, "show_graph_frames", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_FRAMES); + RNA_def_property_ui_text(prop, "Show Frames", "Show curves for frames in graph editor"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); + + /* show graph_tracks */ + prop= RNA_def_property(srna, "show_graph_tracks", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_TRACKS); + RNA_def_property_ui_text(prop, "Show Tracks", "Show curves for tracks in graph editor"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index b0e77b8921f..54c51d31452 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -656,6 +656,12 @@ static void rna_def_reconstructedCamera(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); RNA_def_property_ui_text(prop, "Matrix", "Worldspace transformation matrix"); + + /* average_error */ + prop= RNA_def_property(srna, "average_error", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "error"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Average Error", "Average error of resonctruction"); } static void rna_def_trackingReconstruction(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 75493a27758..bf83a6e043c 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1848,6 +1848,17 @@ static void rna_def_userdef_theme_space_clip(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Path After", "Color of path after current frame"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Grid", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop= RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "cframe"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Current Frame", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_themes(BlenderRNA *brna) |