Added Selected Only and Show Hidden flags to clip editor's curve view
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 12 Jun 2012 17:11:16 +0000 (17:11 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 12 Jun 2012 17:11:16 +0000 (17:11 +0000)
release/scripts/startup/bl_ui/space_clip.py
source/blender/editors/space_clip/clip_graph_draw.c
source/blender/editors/space_clip/clip_graph_ops.c
source/blender/editors/space_clip/clip_intern.h
source/blender/editors/space_clip/clip_utils.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_tracking.c

index 8d55d678c5d06bbbd4ecc1356c0af333aba3b484..e9997d43c04cedba58c8950c981759e8707b7866 100644 (file)
@@ -67,6 +67,10 @@ class CLIP_HT_header(Header):
             elif sc.view == 'GRAPH':
                 layout.prop(sc, "view", text="", expand=True)
 
+                row = layout.row(align=True)
+                row.prop(sc, "show_graph_only_selected", text="")
+                row.prop(sc, "show_graph_hidden", text="")
+
                 row = layout.row(align=True)
 
                 if sc.show_filters:
index 7da5dae1b50bcf6313913516182217c149462501..ce48681c5bddc7ee3acc36ffe1ad8cb3ff0bfde6 100644 (file)
@@ -162,17 +162,20 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc)
        userdata.sel = FALSE;
        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);
+       clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+                                          &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);
+       clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+                                          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, &userdata, tracking_segment_knot_cb, NULL, NULL);
+       clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+                                          &userdata, tracking_segment_knot_cb, NULL, NULL);
 }
 
 static void draw_frame_curves(SpaceClip *sc)
index 9af67a2b10467d1de7c022814e81e7c137f459c3..64547d3288972a24c980db3f9edcbf675ec323bb 100644 (file)
@@ -190,7 +190,9 @@ static int mouse_select_knot(bContext *C, float co[2], int extend)
                                if (!extend) {
                                        SelectUserData selectdata = {SEL_DESELECT};
 
-                                       clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb);
+                                       clip_graph_tracking_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY,
+                                                                   sc->flag & SC_SHOW_GRAPH_HIDDEN, &selectdata,
+                                                                   toggle_selection_cb);
                                }
 
                                if (userdata.coord == 0)
@@ -215,7 +217,8 @@ static int mouse_select_curve(bContext *C, float co[2], int extend)
        MouseSelectUserData userdata;
 
        mouse_select_init_data(&userdata, co);
-       clip_graph_tracking_values_iterate(sc, &userdata, find_nearest_tracking_segment_cb,
+       clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY, sc->flag & SC_SHOW_GRAPH_HIDDEN,
+                                          &userdata, find_nearest_tracking_segment_cb,
                                           NULL, find_nearest_tracking_segment_end_cb);
 
        if (userdata.track) {
@@ -227,11 +230,16 @@ static int mouse_select_curve(bContext *C, float co[2], int extend)
                }
                else if (act_track != userdata.track) {
                        SelectUserData selectdata = {SEL_DESELECT};
+                       MovieTrackingObject *object = BKE_tracking_active_object(tracking);
+                       ListBase *tracksbase = BKE_tracking_object_tracks(tracking, object);
 
                        tracking->act_track = userdata.track;
+                       BKE_tracking_select_track(tracksbase, userdata.track, TRACK_AREA_ALL, TRUE);
 
                        /* deselect all knots on newly selected curve */
-                       clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb);
+                       clip_graph_tracking_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY,
+                                                   sc->flag & SC_SHOW_GRAPH_HIDDEN, &selectdata,
+                                                   toggle_selection_cb);
                }
 
                return TRUE;
@@ -556,7 +564,9 @@ static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
        userdata.max = -FLT_MAX;
        userdata.min = FLT_MAX;
 
-       clip_graph_tracking_values_iterate(sc, &userdata, view_all_cb, NULL, NULL);
+       clip_graph_tracking_values_iterate(sc, sc->flag & SC_SHOW_GRAPH_SEL_ONLY,
+                                          sc->flag & SC_SHOW_GRAPH_HIDDEN, &userdata,
+                                          view_all_cb, NULL, NULL);
 
        /* set extents of view to start/end frames */
        v2d->cur.xmin = (float) SFRA;
index dd1addd715c97bf724cec038cd60610ef638688e..e0db3b1c99578f8a3e1fc69cfec3c3c2ecca4b9b 100644 (file)
@@ -114,12 +114,12 @@ void clip_graph_tracking_values_iterate_track(struct SpaceClip *sc, struct Movie
                                               void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord),
                                               void (*segment_end)(void *userdata));
 
-void clip_graph_tracking_values_iterate(struct SpaceClip *sc, void *userdata,
+void clip_graph_tracking_values_iterate(struct SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
                                         void (*func)(void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
                                         void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord),
                                         void (*segment_end)(void *userdata));
 
-void clip_graph_tracking_iterate(struct SpaceClip *sc, void *userdata,
+void clip_graph_tracking_iterate(struct SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
                                  void (*func)(void *userdata, struct MovieTrackingMarker *marker));
 
 void clip_delete_track(struct bContext *C, struct MovieClip *clip, struct ListBase *tracksbase, struct MovieTrackingTrack *track);
index 8175a84e188af953dde7e647b266bfa67c9aad65..51870c6e43d023eacc82fb261b6f4ddee9681810 100644 (file)
@@ -121,7 +121,7 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack
        }
 }
 
-void clip_graph_tracking_values_iterate(SpaceClip *sc, void *userdata,
+void clip_graph_tracking_values_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
                                         void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
                                         void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
                                         void (*segment_end)(void *userdata))
@@ -131,17 +131,18 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, void *userdata,
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        MovieTrackingTrack *track;
 
-       track = tracksbase->first;
-       while (track) {
-               if (TRACK_VIEW_SELECTED(sc, track)) {
-                       clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end);
-               }
+       for (track = tracksbase->first; track; track = track->next) {
+               if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
+                       continue;
+
+               if (selected_only && !TRACK_SELECTED(track))
+                       continue;
 
-               track = track->next;
+               clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end);
        }
 }
 
-void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata,
+void clip_graph_tracking_iterate(SpaceClip *sc, int selected_only, int include_hidden, void *userdata,
                                  void (*func)(void *userdata, MovieTrackingMarker *marker))
 {
        MovieClip *clip = ED_space_clip(sc);
@@ -149,23 +150,24 @@ void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata,
        ListBase *tracksbase = BKE_tracking_get_tracks(tracking);
        MovieTrackingTrack *track;
 
-       track = tracksbase->first;
-       while (track) {
-               if (TRACK_VIEW_SELECTED(sc, track)) {
-                       int i;
+       for (track = tracksbase->first; track; track = track->next) {
+               int i;
 
-                       for (i = 0; i < track->markersnr; i++) {
-                               MovieTrackingMarker *marker = &track->markers[i];
+               if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
+                       continue;
 
-                               if (marker->flag & MARKER_DISABLED)
-                                       continue;
+               if (selected_only && !TRACK_SELECTED(track))
+                       continue;
 
-                               if (func)
-                                       func(userdata, marker);
-                       }
-               }
+               for (i = 0; i < track->markersnr; i++) {
+                       MovieTrackingMarker *marker = &track->markers[i];
+
+                       if (marker->flag & MARKER_DISABLED)
+                               continue;
 
-               track = track->next;
+                       if (func)
+                               func(userdata, marker);
+               }
        }
 }
 
index e9a07bfbf296c6f1447aaefe684e1576baa674f7..6a95628b650a63d172a615f12821660feb27f028 100644 (file)
@@ -1037,6 +1037,8 @@ typedef enum eSpaceClip_Flag {
 /*     SC_SHOW_PYRAMID_LEVELS = (1 << 16), */  /* UNUSED */
        SC_LOCK_TIMECURSOR     = (1 << 17),
        SC_SHOW_SECONDS        = (1 << 18),
+       SC_SHOW_GRAPH_SEL_ONLY = (1 << 19),
+       SC_SHOW_GRAPH_HIDDEN   = (1 << 20),
 } eSpaceClip_Flag;
 
 /* SpaceClip->mode */
index 941e44e9f786a27693c87a8511e3bddbf3ca2823..50a682f56bde850374df33e4f4f1651611c2aebc 100644 (file)
@@ -3168,6 +3168,20 @@ static void rna_def_space_clip(BlenderRNA *brna)
                                 "for the selected tracks");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
 
+       /* show_only_selected */
+       prop = RNA_def_property(srna, "show_graph_only_selected", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_SEL_ONLY);
+       RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected objects and data");
+       RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
+
+       /* show_hidden */
+       prop = RNA_def_property(srna, "show_graph_hidden", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GRAPH_HIDDEN);
+       RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that aren't visible");
+       RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
+
        /* ** channels ** */
 
        /* show_red_channel */
index 337f13b5af824f0476da8f9a01603fc8839fb8ec..c74b55698571c323330cd90bd0012eedd13d11bf 100644 (file)
@@ -1438,14 +1438,14 @@ static void rna_def_trackingDopesheet(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_DOPE_SELECTED_ONLY);
        RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected objects and data");
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
-       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_trackingDopesheet_tagUpdate");
+       RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingDopesheet_tagUpdate");
 
        /* show_hidden */
        prop = RNA_def_property(srna, "show_hidden", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_DOPE_SHOW_HIDDEN);
        RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that aren't visible");
        RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
-       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_trackingDopesheet_tagUpdate");
+       RNA_def_property_update(prop, NC_MOVIECLIP | NA_EDITED, "rna_trackingDopesheet_tagUpdate");
 }
 
 static void rna_def_tracking(BlenderRNA *brna)