diff options
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r-- | source/blender/editors/space_graph/graph_buttons.c | 49 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_edit.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_ops.c | 28 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_select.c | 89 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_slider_ops.c | 266 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_utils.c | 21 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_view.c | 47 |
7 files changed, 319 insertions, 186 deletions
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 26a056ce1fb..41f74b6ade9 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -19,6 +19,8 @@ /** \file * \ingroup spgraph + * + * Graph editor space & buttons. */ #include <float.h> @@ -66,11 +68,11 @@ #include "graph_intern.h" /* own include */ -/* ******************* graph editor space & buttons ************** */ - #define B_REDR 1 -/* -------------- */ +/* -------------------------------------------------------------------- */ +/** \name Internal Utilities + * \{ */ static bool graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu) { @@ -120,7 +122,11 @@ static bool graph_panel_poll(const bContext *C, PanelType *UNUSED(pt)) return graph_panel_context(C, NULL, NULL); } -/* -------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Cursor Header + * \{ */ static void graph_panel_cursor_header(const bContext *C, Panel *panel) { @@ -174,7 +180,11 @@ static void graph_panel_cursor(const bContext *C, Panel *panel) uiItemO(sub, IFACE_("Cursor Value to Selection"), ICON_NONE, "GRAPH_OT_snap_cursor_value"); } -/* ******************* active F-Curve ************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Active F-Curve + * \{ */ static void graph_panel_properties(const bContext *C, Panel *panel) { @@ -243,7 +253,11 @@ static void graph_panel_properties(const bContext *C, Panel *panel) MEM_freeN(ale); } -/* ******************* active Keyframe ************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Active Keyframe + * \{ */ /* get 'active' keyframe for panel editing */ static bool get_active_fcurve_keyframe_edit(const FCurve *fcu, @@ -610,7 +624,11 @@ static void graph_panel_key_properties(const bContext *C, Panel *panel) MEM_freeN(ale); } -/* ******************* drivers ******************************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Drivers + * \{ */ #define B_IPO_DEPCHANGE 10 @@ -1320,8 +1338,13 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *panel) uiItemO(layout, IFACE_("Show in Drivers Editor"), ICON_DRIVER, "SCREEN_OT_drivers_editor_show"); } -/* ******************* F-Modifiers ******************************** */ -/* All the drawing code is in editors/animation/fmodifier_ui.c */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name F-Curve Modifiers + * + * \note All the drawing code is in `editors/animation/fmodifier_ui.c` + * \{ */ #define B_FMODIFIER_REDRAW 20 /** The start of FModifier panels registered for the graph editor. */ @@ -1380,7 +1403,11 @@ static void graph_panel_modifiers(const bContext *C, Panel *panel) MEM_freeN(ale); } -/* ******************* general ******************************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Registration + * \{ */ void graph_buttons_register(ARegionType *art) { @@ -1456,3 +1483,5 @@ void graph_buttons_register(ARegionType *art) pt->draw_header = graph_panel_cursor_header; BLI_addtail(&art->paneltypes, pt); } + +/** \} */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 1967dfabd21..2afee277847 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -19,6 +19,8 @@ /** \file * \ingroup spgraph + * + * Insert duplicate and bake keyframes. */ #include <float.h> @@ -69,9 +71,6 @@ #include "graph_intern.h" -/* ************************************************************************** */ -/* INSERT DUPLICATE AND BAKE KEYFRAMES */ - /* -------------------------------------------------------------------- */ /** \name Insert Keyframes Operator * \{ */ diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 32396a70cce..ecafc75fc06 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -52,11 +52,13 @@ /* ************************** view-based operators **********************************/ /* XXX should these really be here? */ -/* Set Cursor --------------------------------------------------------------------- */ -/* The 'cursor' in the Graph Editor consists of two parts: +/* -------------------------------------------------------------------- */ +/** \name Set Cursor + * + * The 'cursor' in the Graph Editor consists of two parts: * 1) Current Frame Indicator (as per ANIM_OT_change_frame) * 2) Value Indicator (stored per Graph Editor instance) - */ + * \{ */ static bool graphview_cursor_poll(bContext *C) { @@ -225,7 +227,11 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot) RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Value", "", -100.0f, 100.0f); } -/* Hide/Reveal ------------------------------------------------------------ */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Hide/Reveal + * \{ */ static int graphview_curves_hide_exec(bContext *C, wmOperator *op) { @@ -413,7 +419,11 @@ static void GRAPH_OT_reveal(wmOperatorType *ot) RNA_def_boolean(ot->srna, "select", true, "Select", ""); } -/* ************************** registration - operator types **********************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Registration: operator types + * \{ */ void graphedit_operatortypes(void) { @@ -496,7 +506,11 @@ void ED_operatormacros_graph(void) RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false); } -/* ************************** registration - keymaps **********************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Registration: Key-Maps + * \{ */ void graphedit_keymap(wmKeyConfig *keyconf) { @@ -514,3 +528,5 @@ void graphedit_keymap(wmKeyConfig *keyconf) /* keyframes */ WM_keymap_ensure(keyconf, "Graph Editor", SPACE_GRAPH, 0); } + +/** \} */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index ffe74e20bdf..03bfd1092c6 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -56,8 +56,9 @@ #include "graph_intern.h" -/* ************************************************************************** */ -/* KEYFRAMES STUFF */ +/* -------------------------------------------------------------------- */ +/** \name Internal Keyframe Utilities + * \{ */ /* temp info for caching handle vertices close */ typedef struct tNearestVertInfo { @@ -334,14 +335,19 @@ static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mv return nvi; } -/* ******************** Deselect All Operator ***************************** */ -/* This operator works in one of three ways: +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Deselect All Operator + * + * This operator works in one of three ways: * 1) (de)select all (AKEY) - test if select all or deselect all * 2) invert all (CTRL-IKEY) - invert selection of all keyframes * 3) (de)select all - no testing is done; only for use internal tools as normal function... - */ + * \{ */ -/* Deselects keyframes in the Graph Editor +/** + * Deselects keyframes in the Graph Editor * - This is called by the deselect all operator, as well as other ones! * * - test: check if select or deselect all @@ -490,8 +496,12 @@ void GRAPH_OT_select_all(wmOperatorType *ot) WM_operator_properties_select_all(ot); } -/* ******************** Box Select Operator **************************** */ -/* This operator currently works in one of three ways: +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Box Select Operator + * + * This operator currently works in one of three ways: * -> BKEY - 1) all keyframes within region are selected (validation with BEZT_OK_REGION) * -> ALT-BKEY - depending on which axis of the region was larger... * -> 2) x-axis, so select all frames within frame range (validation with BEZT_OK_FRAMERANGE) @@ -499,7 +509,7 @@ void GRAPH_OT_select_all(wmOperatorType *ot) * (validation with BEZT_OK_VALUERANGE). * * The selection backend is also reused for the Lasso and Circle select operators. - */ + * \{ */ static rctf initialize_box_select_coords(const bAnimContext *ac, const rctf *rectf_view) { @@ -572,7 +582,8 @@ static void initialize_box_select_key_editing_data(const SpaceGraph *sipo, *r_mapping_flag |= ANIM_get_normalization_flags(ac); } -/* Box Select only selects keyframes, as overshooting handles often get caught too, +/** + * Box Select only selects keyframes, as overshooting handles often get caught too, * which means that they may be inadvertently moved as well. However, incl_handles overrides * this, and allow handles to be considered independently too. * Also, for convenience, handles should get same status as keyframe (if it was within bounds). @@ -667,7 +678,8 @@ static bool box_select_graphkeys(bAnimContext *ac, return any_key_selection_changed; } -/* This function is used to set all the keyframes of a given curve as selectable +/** + * This function is used to set all the keyframes of a given curve as selectable * by the "select_cb" function inside of "box_select_graphcurves". */ static short ok_bezier_always_ok(KeyframeEditData *UNUSED(ked), BezTriple *UNUSED(bezt)) @@ -732,11 +744,12 @@ static bool rectf_curve_intersection( #undef INSIDE #undef BELOW -/* Perform a box selection of the curves themselves. This means this function tries +/** + * Perform a box selection of the curves themselves. This means this function tries * to select a curve by sampling it at various points instead of trying to select the * keyframes directly. * The selection actions done to a curve are actually done on all the keyframes of the curve. - * NOTE: This function is only called if no keyframe is in the selection area. + * \note This function is only called if no keyframe is in the selection area. */ static void box_select_graphcurves(bAnimContext *ac, const rctf *rectf_view, @@ -1107,13 +1120,17 @@ void GRAPH_OT_select_circle(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/* ******************** Column Select Operator **************************** */ -/* This operator works in one of four ways: +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Column Select Operator + * + * This operator works in one of four ways: * - 1) select all keyframes in the same frame as a selected one (KKEY) * - 2) select all keyframes in the same frame as the current frame marker (CTRL-KKEY) * - 3) select all keyframes in the same frame as a selected markers (SHIFT-KKEY) * - 4) select all keyframes that occur between selected markers (ALT-KKEY) - */ + * \{ */ /* defines for column-select mode */ static const EnumPropertyItem prop_column_select_types[] = { @@ -1297,7 +1314,11 @@ void GRAPH_OT_select_column(wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); } -/* ******************** Select Linked Operator *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Linked Operator + * \{ */ static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -1353,7 +1374,11 @@ void GRAPH_OT_select_linked(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ******************** Select More/Less Operators *********************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select More/Less Operators + * \{ */ /* Common code to perform selection */ static void select_moreless_graph_keys(bAnimContext *ac, short mode) @@ -1467,8 +1492,13 @@ void GRAPH_OT_select_less(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ******************** Select Left/Right Operator ************************* */ -/* Select keyframes left/right of the current frame indicator */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Select Left/Right Operator + * + * Select keyframes left/right of the current frame indicator. + * \{ */ /* defines for left-right select tool */ static const EnumPropertyItem prop_graphkeys_leftright_select_types[] = { @@ -1628,15 +1658,19 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/* ******************** Mouse-Click Select Operator *********************** */ -/* This operator works in one of three ways: +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Mouse-Click Select Operator + * + * This operator works in one of three ways: * - 1) keyframe under mouse - no special modifiers * - 2) all keyframes on the same side of current frame indicator as mouse - ALT modifier * - 3) column select all keyframes in frame under mouse - CTRL modifier * * In addition to these basic options, the SHIFT modifier can be used to toggle the * selection mode between replacing the selection (without) and inverting the selection (with). - */ + * \{ */ /* option 1) select keyframe directly under mouse */ static int mouse_graph_keys(bAnimContext *ac, @@ -1888,9 +1922,12 @@ static int graphkeys_mselect_column(bAnimContext *ac, return run_modal ? OPERATOR_RUNNING_MODAL : OPERATOR_FINISHED; } -/* ------------------- */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Click Select Operator + * \{ */ -/* handle clicking */ static int graphkeys_clickselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1988,4 +2025,4 @@ void GRAPH_OT_clickselect(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -/* ************************************************************************** */ +/** \} */ diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index f04336cab84..4e62ab2df2d 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -17,6 +17,16 @@ * All rights reserved. */ +/** \file + * \ingroup spgraph + * + * Graph Slider Operators + * + * This file contains a collection of operators to modify keyframes in the graph editor. + * All operators are modal and use a slider that allows the user to define a percentage + * to modify the operator. + */ + #include <float.h> #include <string.h> @@ -48,42 +58,17 @@ #include "graph_intern.h" -/* ******************** GRAPH SLIDER OPERATORS ************************* */ -/* This file contains a collection of operators to modify keyframes in the graph editor. All - * operators are modal and use a slider that allows the user to define a percentage to modify the - * operator. */ - -/* ******************** Decimate Keyframes Operator ************************* */ - -static void decimate_graph_keys(bAnimContext *ac, float remove_ratio, float error_sq_max) -{ - ListBase anim_data = {NULL, NULL}; - bAnimListElem *ale; - int filter; - - /* Filter data. */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | - ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - /* Loop through filtered data and clean curves. */ - for (ale = anim_data.first; ale; ale = ale->next) { - if (!decimate_fcurve(ale, remove_ratio, error_sq_max)) { - /* The selection contains unsupported keyframe types! */ - WM_report(RPT_WARNING, "Decimate: Skipping non linear/bezier keyframes!"); - } - - ale->update |= ANIM_UPDATE_DEFAULT; - } - - ANIM_animdata_update(ac, &anim_data); - ANIM_animdata_freelist(&anim_data); -} +/* -------------------------------------------------------------------- */ +/** \name Internal Struct & Defines + * \{ */ -/* ------------------- */ +/* Used to obtain a list of animation channels for the operators to work on. */ +#define OPERATOR_DATA_FILTER \ + (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | \ + ANIMFILTER_NODUPLIS) /* This data type is only used for modal operation. */ -typedef struct tDecimateGraphOp { +typedef struct tGraphSliderOp { bAnimContext ac; Scene *scene; ScrArea *area; @@ -98,35 +83,73 @@ typedef struct tDecimateGraphOp { struct tSlider *slider; NumInput num; -} tDecimateGraphOp; +} tGraphSliderOp; typedef struct tBeztCopyData { int tot_vert; BezTriple *bezt; } tBeztCopyData; -typedef enum tDecimModes { - DECIM_RATIO = 1, - DECIM_ERROR, -} tDecimModes; +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Utility Functions + * \{ */ + +/* Construct a list with the original bezt arrays so we can restore them during modal operation. + * The data is stored on the struct that is passed.*/ +static void store_original_bezt_arrays(tGraphSliderOp *gso) +{ + ListBase anim_data = {NULL, NULL}; + bAnimContext *ac = &gso->ac; + bAnimListElem *ale; + + ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype); + + /* Loop through filtered data and copy the curves. */ + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + + if (fcu->bezt == NULL) { + /* This curve is baked, skip it. */ + continue; + } + + const int arr_size = sizeof(BezTriple) * fcu->totvert; + + tBeztCopyData *copy = MEM_mallocN(sizeof(tBeztCopyData), "bezts_copy"); + BezTriple *bezts_copy = MEM_mallocN(arr_size, "bezts_copy_array"); + + copy->tot_vert = fcu->totvert; + memcpy(bezts_copy, fcu->bezt, arr_size); + + copy->bezt = bezts_copy; + + LinkData *link = NULL; + + link = MEM_callocN(sizeof(LinkData), "Bezt Link"); + link->data = copy; + + BLI_addtail(&gso->bezt_arr_list, link); + } + + ANIM_animdata_freelist(&anim_data); +} /* Overwrite the current bezts arrays with the original data. */ -static void decimate_reset_bezts(tDecimateGraphOp *dgo) +static void reset_bezts(tGraphSliderOp *gso) { ListBase anim_data = {NULL, NULL}; LinkData *link_bezt; bAnimListElem *ale; - int filter; - bAnimContext *ac = &dgo->ac; + bAnimContext *ac = &gso->ac; /* Filter data. */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | - ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype); /* Loop through filtered data and reset bezts. */ - for (ale = anim_data.first, link_bezt = dgo->bezt_arr_list.first; ale; ale = ale->next) { + for (ale = anim_data.first, link_bezt = gso->bezt_arr_list.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; if (fcu->bezt == NULL) { @@ -151,29 +174,62 @@ static void decimate_reset_bezts(tDecimateGraphOp *dgo) ANIM_animdata_freelist(&anim_data); } +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Decimate Keyframes Operator + * \{ */ + +typedef enum tDecimModes { + DECIM_RATIO = 1, + DECIM_ERROR, +} tDecimModes; + +static void decimate_graph_keys(bAnimContext *ac, float remove_ratio, float error_sq_max) +{ + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + + /* Filter data. */ + ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype); + + /* Loop through filtered data and clean curves. */ + for (ale = anim_data.first; ale; ale = ale->next) { + if (!decimate_fcurve(ale, remove_ratio, error_sq_max)) { + /* The selection contains unsupported keyframe types! */ + WM_report(RPT_WARNING, "Decimate: Skipping non linear/bezier keyframes!"); + } + + ale->update |= ANIM_UPDATE_DEFAULT; + } + + ANIM_animdata_update(ac, &anim_data); + ANIM_animdata_freelist(&anim_data); +} + static void decimate_exit(bContext *C, wmOperator *op) { - tDecimateGraphOp *dgo = op->customdata; + tGraphSliderOp *gso = op->customdata; wmWindow *win = CTX_wm_window(C); /* If data exists, clear its data and exit. */ - if (dgo == NULL) { + if (gso == NULL) { return; } - ScrArea *area = dgo->area; + ScrArea *area = gso->area; LinkData *link; - ED_slider_destroy(C, dgo->slider); + ED_slider_destroy(C, gso->slider); - for (link = dgo->bezt_arr_list.first; link != NULL; link = link->next) { + for (link = gso->bezt_arr_list.first; link != NULL; link = link->next) { tBeztCopyData *copy = link->data; MEM_freeN(copy->bezt); MEM_freeN(link->data); } - BLI_freelistN(&dgo->bezt_arr_list); - MEM_freeN(dgo); + BLI_freelistN(&gso->bezt_arr_list); + MEM_freeN(gso); /* Return to normal cursor and header status. */ WM_cursor_modal_restore(win); @@ -184,20 +240,20 @@ static void decimate_exit(bContext *C, wmOperator *op) } /* Draw a percentage indicator in workspace footer. */ -static void decimate_draw_status(bContext *C, tDecimateGraphOp *dgo) +static void decimate_draw_status(bContext *C, tGraphSliderOp *gso) { char status_str[UI_MAX_DRAW_STR]; char mode_str[32]; char slider_string[UI_MAX_DRAW_STR]; - ED_slider_status_string_get(dgo->slider, slider_string, UI_MAX_DRAW_STR); + ED_slider_status_string_get(gso->slider, slider_string, UI_MAX_DRAW_STR); strcpy(mode_str, TIP_("Decimate Keyframes")); - if (hasNumInput(&dgo->num)) { + if (hasNumInput(&gso->num)) { char str_ofs[NUM_STR_REP_LEN]; - outputNumInput(&dgo->num, str_ofs, &dgo->scene->unit); + outputNumInput(&gso->num, str_ofs, &gso->scene->unit); BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, str_ofs); } @@ -210,76 +266,34 @@ static void decimate_draw_status(bContext *C, tDecimateGraphOp *dgo) static int graphkeys_decimate_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - tDecimateGraphOp *dgo; + tGraphSliderOp *gso; WM_cursor_modal_set(CTX_wm_window(C), WM_CURSOR_EW_SCROLL); /* Init slide-op data. */ - dgo = op->customdata = MEM_callocN(sizeof(tDecimateGraphOp), "tDecimateGraphOp"); + gso = op->customdata = MEM_callocN(sizeof(tGraphSliderOp), "tGraphSliderOp"); /* Get editor data. */ - if (ANIM_animdata_get_context(C, &dgo->ac) == 0) { + if (ANIM_animdata_get_context(C, &gso->ac) == 0) { decimate_exit(C, op); return OPERATOR_CANCELLED; } - dgo->percentage_prop = RNA_struct_find_property(op->ptr, "remove_ratio"); - - dgo->scene = CTX_data_scene(C); - dgo->area = CTX_wm_area(C); - dgo->region = CTX_wm_region(C); - - dgo->slider = ED_slider_create(C); - ED_slider_init(dgo->slider, event); - ED_slider_allow_overshoot_set(dgo->slider, false); - - decimate_draw_status(C, dgo); - - /* Construct a list with the original bezt arrays so we can restore them during modal operation. - */ - { - ListBase anim_data = {NULL, NULL}; - bAnimContext *ac = &dgo->ac; - bAnimListElem *ale; + gso->percentage_prop = RNA_struct_find_property(op->ptr, "remove_ratio"); - int filter; + gso->scene = CTX_data_scene(C); + gso->area = CTX_wm_area(C); + gso->region = CTX_wm_region(C); - /* Filter data. */ - filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | - ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + store_original_bezt_arrays(gso); - /* Loop through filtered data and copy the curves. */ - for (ale = anim_data.first; ale; ale = ale->next) { - FCurve *fcu = (FCurve *)ale->key_data; + gso->slider = ED_slider_create(C); + ED_slider_init(gso->slider, event); + ED_slider_allow_overshoot_set(gso->slider, false); - if (fcu->bezt == NULL) { - /* This curve is baked, skip it. */ - continue; - } - - const int arr_size = sizeof(BezTriple) * fcu->totvert; - - tBeztCopyData *copy = MEM_mallocN(sizeof(tBeztCopyData), "bezts_copy"); - BezTriple *bezts_copy = MEM_mallocN(arr_size, "bezts_copy_array"); - - copy->tot_vert = fcu->totvert; - memcpy(bezts_copy, fcu->bezt, arr_size); - - copy->bezt = bezts_copy; - - LinkData *link = NULL; + decimate_draw_status(C, gso); - link = MEM_callocN(sizeof(LinkData), "Bezt Link"); - link->data = copy; - - BLI_addtail(&dgo->bezt_arr_list, link); - } - - ANIM_animdata_freelist(&anim_data); - } - - if (dgo->bezt_arr_list.first == NULL) { + if (gso->bezt_arr_list.first == NULL) { WM_report(RPT_WARNING, "Fcurve Decimate: Can't decimate baked channels. Unbake them and try again."); decimate_exit(C, op); @@ -294,19 +308,19 @@ static void graphkeys_decimate_modal_update(bContext *C, wmOperator *op) { /* Perform decimate updates - in response to some user action * (e.g. pressing a key or moving the mouse). */ - tDecimateGraphOp *dgo = op->customdata; + tGraphSliderOp *gso = op->customdata; - decimate_draw_status(C, dgo); + decimate_draw_status(C, gso); /* Reset keyframe data (so we get back to the original state). */ - decimate_reset_bezts(dgo); + reset_bezts(gso); /* Apply... */ - float remove_ratio = ED_slider_factor_get(dgo->slider); - RNA_property_float_set(op->ptr, dgo->percentage_prop, remove_ratio); + float remove_ratio = ED_slider_factor_get(gso->slider); + RNA_property_float_set(op->ptr, gso->percentage_prop, remove_ratio); /* We don't want to limit the decimation to a certain error margin. */ const float error_sq_max = FLT_MAX; - decimate_graph_keys(&dgo->ac, remove_ratio, error_sq_max); + decimate_graph_keys(&gso->ac, remove_ratio, error_sq_max); WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } @@ -316,11 +330,11 @@ static int graphkeys_decimate_modal(bContext *C, wmOperator *op, const wmEvent * * and finicky to control with this modal mouse grab method. Therefore, it is expected that the * error margin mode is not adjusted by the modal operator but instead tweaked via the redo * panel. */ - tDecimateGraphOp *dgo = op->customdata; + tGraphSliderOp *gso = op->customdata; - const bool has_numinput = hasNumInput(&dgo->num); + const bool has_numinput = hasNumInput(&gso->num); - ED_slider_modal(dgo->slider, event); + ED_slider_modal(gso->slider, event); switch (event->type) { case LEFTMOUSE: /* Confirm */ @@ -337,7 +351,7 @@ static int graphkeys_decimate_modal(bContext *C, wmOperator *op, const wmEvent * case EVT_ESCKEY: /* Cancel */ case RIGHTMOUSE: { if (event->val == KM_PRESS) { - decimate_reset_bezts(dgo); + reset_bezts(gso); WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); @@ -358,18 +372,18 @@ static int graphkeys_decimate_modal(bContext *C, wmOperator *op, const wmEvent * break; } default: { - if ((event->val == KM_PRESS) && handleNumInput(C, &dgo->num, event)) { + if ((event->val == KM_PRESS) && handleNumInput(C, &gso->num, event)) { float value; - float percentage = RNA_property_float_get(op->ptr, dgo->percentage_prop); + float percentage = RNA_property_float_get(op->ptr, gso->percentage_prop); /* Grab percentage from numeric input, and store this new value for redo * NOTE: users see ints, while internally we use a 0-1 float. */ value = percentage * 100.0f; - applyNumInput(&dgo->num, &value); + applyNumInput(&gso->num, &value); percentage = value / 100.0f; - RNA_property_float_set(op->ptr, dgo->percentage_prop, percentage); + RNA_property_float_set(op->ptr, gso->percentage_prop, percentage); /* Update decimate output to reflect the new values. */ graphkeys_decimate_modal_update(C, op); @@ -520,3 +534,5 @@ void GRAPH_OT_decimate(wmOperatorType *ot) 0.0f, 10.0f); } + +/** \} */ diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index c37d9f42c12..89e7fefd9ac 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -46,8 +46,9 @@ #include "graph_intern.h" /* own include */ -/* ************************************************************** */ -/* Set Up Drivers Editor */ +/* -------------------------------------------------------------------- */ +/** \name Set Up Drivers Editor + * \{ */ /* Set up UI configuration for Drivers Editor */ /* NOTE: Currently called from window-manager @@ -89,8 +90,11 @@ void ED_drivers_editor_init(bContext *C, ScrArea *area) } } -/* ************************************************************** */ -/* Active F-Curve */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Active F-Curve + * \{ */ /** * Find 'active' F-Curve. @@ -124,8 +128,11 @@ bAnimListElem *get_active_fcurve_channel(bAnimContext *ac) return NULL; } -/* ************************************************************** */ -/* Operator Polling Callbacks */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Operator Polling Callbacks + * \{ */ /* Check if there are any visible keyframes (for selection tools) */ bool graphop_visible_keyframes_poll(bContext *C) @@ -321,4 +328,4 @@ bool graphop_selected_fcurve_poll(bContext *C) return true; } -/* ************************************************************** */ +/** \} */ diff --git a/source/blender/editors/space_graph/graph_view.c b/source/blender/editors/space_graph/graph_view.c index 56649c50cfd..a12c6053877 100644 --- a/source/blender/editors/space_graph/graph_view.c +++ b/source/blender/editors/space_graph/graph_view.c @@ -17,6 +17,10 @@ * All rights reserved. */ +/** \file + * \ingroup spgraph + */ + #include <math.h> #include "MEM_guardedalloc.h" @@ -48,7 +52,9 @@ #include "graph_intern.h" -/* *************************** Calculate Range ************************** */ +/* -------------------------------------------------------------------- */ +/** \name Calculate Range + * \{ */ /* Get the min/max keyframes. */ /* NOTE: it should return total boundbox, filter for selection only can be argument... */ @@ -194,7 +200,11 @@ void get_graph_keyframe_extents(bAnimContext *ac, } } -/* ****************** Automatic Preview-Range Operator ****************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Automatic Preview-Range Operator + * \{ */ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -241,7 +251,11 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/* ****************** View-All Operator ****************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name View-All Operator + * \{ */ static int graphkeys_viewall(bContext *C, const bool do_sel_only, @@ -347,7 +361,11 @@ void GRAPH_OT_view_selected(wmOperatorType *ot) "Include handles of keyframes when calculating extents"); } -/* ********************** View Frame Operator ****************************** */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name View Frame Operator + * \{ */ static int graphkeys_view_frame_exec(bContext *C, wmOperator *op) { @@ -371,10 +389,14 @@ void GRAPH_OT_view_frame(wmOperatorType *ot) ot->flag = 0; } -/* ******************** Create Ghost-Curves Operator *********************** */ -/* This operator samples the data of the selected F-Curves to F-Points, storing them +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Create Ghost-Curves Operator + * + * This operator samples the data of the selected F-Curves to F-Points, storing them * as 'ghost curves' in the active Graph Editor. - */ + * \{ */ /* Bake each F-Curve into a set of samples, and store as a ghost curve. */ static void create_ghost_curves(bAnimContext *ac, int start, int end) @@ -493,8 +515,13 @@ void GRAPH_OT_ghost_curves_create(wmOperatorType *ot) /* TODO: add props for start/end frames */ } -/* ******************** Clear Ghost-Curves Operator *********************** */ -/* This operator clears the 'ghost curves' for the active Graph Editor */ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Clear Ghost-Curves Operator + * + * This operator clears the 'ghost curves' for the active Graph Editor. + * \{ */ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -534,3 +561,5 @@ void GRAPH_OT_ghost_curves_clear(wmOperatorType *ot) /* Flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + +/** \} */ |