Blender V4.3
graph_edit.cc File Reference
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math_rotation.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_enum_types.hh"
#include "RNA_prototypes.hh"
#include "BLT_translation.hh"
#include "BKE_animsys.h"
#include "BKE_context.hh"
#include "BKE_fcurve.hh"
#include "BKE_global.hh"
#include "BKE_nla.hh"
#include "BKE_report.hh"
#include "BKE_scene.hh"
#include "DEG_depsgraph_build.hh"
#include "UI_interface_icons.hh"
#include "UI_view2d.hh"
#include "ANIM_animdata.hh"
#include "ANIM_fcurve.hh"
#include "ANIM_keyframing.hh"
#include "ED_anim_api.hh"
#include "ED_keyframes_edit.hh"
#include "ED_keyframing.hh"
#include "ED_markers.hh"
#include "ED_screen.hh"
#include "ED_transform.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "graph_intern.hh"

Go to the source code of this file.

Classes

struct  tEulerFilter
 

Functions

Click-Insert Keyframes Operator
static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
 
static int graphkeys_click_insert_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void GRAPH_OT_click_insert (wmOperatorType *ot)
 
Copy/Paste Keyframes Operator
Note
the back-end code for this is shared with the dope-sheet editor.
static short copy_graph_keys (bAnimContext *ac)
 
static eKeyPasteError paste_graph_keys (bAnimContext *ac, const eKeyPasteOffset offset_mode, const eKeyPasteValueOffset value_offset_mode, const eKeyMergeMode merge_mode, bool flip)
 
static int graphkeys_copy_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_copy (wmOperatorType *ot)
 
static int graphkeys_paste_exec (bContext *C, wmOperator *op)
 
static std::string graphkeys_paste_get_description (bContext *, wmOperatorType *, PointerRNA *ptr)
 
void GRAPH_OT_paste (wmOperatorType *ot)
 
Duplicate Keyframes Operator
static bool duplicate_graph_keys (bAnimContext *ac)
 
static int graphkeys_duplicate_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_duplicate (wmOperatorType *ot)
 
Delete Keyframes Operator
static bool delete_graph_keys (bAnimContext *ac)
 
static int graphkeys_delete_exec (bContext *C, wmOperator *)
 
static int graphkeys_delete_invoke (bContext *C, wmOperator *op, const wmEvent *)
 
void GRAPH_OT_delete (wmOperatorType *ot)
 
Clean Keyframes Operator
static void clean_graph_keys (bAnimContext *ac, float thresh, bool clean_chan)
 
static int graphkeys_clean_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_clean (wmOperatorType *ot)
 
Keys to Samples Operator

This operator bakes the data of the selected F-Curves to F-Points.

static void convert_keys_to_samples (bAnimContext *ac, int start, int end)
 
static int graphkeys_keys_to_samples_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_keys_to_samples (wmOperatorType *ot)
 
Samples to Keys Operator

This operator converts the data of the selected F-Points to F-Curves.

static void convert_samples_to_keys (bAnimContext *ac, int start, int end)
 
static int graphkeys_samples_to_keys_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_samples_to_keys (wmOperatorType *ot)
 
static int graphkeys_sound_to_samples_exec (bContext *, wmOperator *op)
 
static int graphkeys_sound_to_samples_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void GRAPH_OT_sound_to_samples (wmOperatorType *ot)
 
Sample Keyframes Operator

This operator 'bakes' the values of the curve into new keyframes between pairs of selected keyframes. It is useful for creating keyframes for tweaking overlap.

static void bake_graph_keys (bAnimContext *ac)
 
static int graphkeys_bake_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_bake_keys (wmOperatorType *ot)
 
Set Interpolation-Type Operator
static void setipo_graph_keys (bAnimContext *ac, short mode)
 
static int graphkeys_ipo_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_interpolation_type (wmOperatorType *ot)
 
Set Easing Operator
static void seteasing_graph_keys (bAnimContext *ac, short mode)
 
static int graphkeys_easing_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_easing_type (wmOperatorType *ot)
 
Set Handle-Type Operator
static void sethandles_graph_keys (bAnimContext *ac, short mode)
 
static int graphkeys_handletype_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_handle_type (wmOperatorType *ot)
 
'Euler Filter' Operator

Euler filter tools (as seen in Maya), are necessary for working with 'baked' rotation curves (with Euler rotations). The main purpose of such tools is to resolve any discontinuities that may arise in the curves due to the clamping of values to -180 degrees to 180 degrees.

static bool keyframe_time_differs (BezTriple *keyframes[3])
 
static ListBase euler_filter_group_channels (const ListBase *anim_data, ReportList *reports, int *r_num_groups)
 
static bool euler_filter_multi_channel (tEulerFilter *euf, ReportList *reports)
 
static bool euler_filter_single_channel (FCurve *fcu)
 
static void euler_filter_perform_filter (ListBase *eulers, ReportList *reports, int *r_curves_filtered, int *r_curves_seen)
 
static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_euler_filter (wmOperatorType *ot)
 
Jump to Selected Frames Operator
static bool graphkeys_framejump_poll (bContext *C)
 
static KeyframeEditData sum_selected_keyframes (bAnimContext *ac)
 
static int graphkeys_framejump_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_frame_jump (wmOperatorType *ot)
 
static bool find_closest_frame (const FCurve *fcu, const float frame, const bool next, float *r_closest_frame)
 
static int keyframe_jump_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_keyframe_jump (wmOperatorType *ot)
 
static int graphkeys_snap_cursor_value_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_snap_cursor_value (wmOperatorType *ot)
 
Smooth Keyframes Operator
static int graphkeys_smooth_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_smooth (wmOperatorType *ot)
 
Add F-Modifier Operator
static const EnumPropertyItemgraph_fmodifier_itemf (bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
 
static int graph_fmodifier_add_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_fmodifier_add (wmOperatorType *ot)
 
Copy F-Modifiers Operator
static int graph_fmodifier_copy_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_fmodifier_copy (wmOperatorType *ot)
 
Paste F-Modifiers Operator
static int graph_fmodifier_paste_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_fmodifier_paste (wmOperatorType *ot)
 
Copy Driver Variables Operator
static int graph_driver_vars_copy_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_driver_variables_copy (wmOperatorType *ot)
 
Paste Driver Variables Operator
static int graph_driver_vars_paste_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_driver_variables_paste (wmOperatorType *ot)
 
Delete Invalid Drivers Operator
static int graph_driver_delete_invalid_exec (bContext *C, wmOperator *)
 
static bool graph_driver_delete_invalid_poll (bContext *C)
 
void GRAPH_OT_driver_delete_invalid (wmOperatorType *ot)
 

Set Extrapolation-Type Operator

#define MAKE_CYCLIC_EXPO   -1
 
#define CLEAR_CYCLIC_EXPO   -2
 
static const EnumPropertyItem prop_graphkeys_expo_types []
 
static void setexpo_graph_keys (bAnimContext *ac, short mode)
 
static int graphkeys_expo_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_extrapolation_type (wmOperatorType *ot)
 

Insert Keyframes Operator

enum  eGraphKeys_InsertKey_Types { GRAPHKEYS_INSERTKEY_ALL = (1 << 0) , GRAPHKEYS_INSERTKEY_SEL = (1 << 1) , GRAPHKEYS_INSERTKEY_CURSOR = (1 << 2) , GRAPHKEYS_INSERTKEY_ACTIVE = (1 << 3) }
 
static const EnumPropertyItem prop_graphkeys_insertkey_types []
 
static void insert_graph_keys (bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
 
static int graphkeys_insertkey_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_keyframe_insert (wmOperatorType *ot)
 

Snap Keyframes Operator

static const EnumPropertyItem prop_graphkeys_snap_types []
 
static void snap_graph_keys (bAnimContext *ac, short mode)
 
static int graphkeys_snap_exec (bContext *C, wmOperator *op)
 
static bool graph_has_selected_control_points (bContext *C)
 
static int graphkeys_selected_control_points_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void GRAPH_OT_snap (wmOperatorType *ot)
 

Equalize Handles Operator

static const EnumPropertyItem prop_graphkeys_equalize_handles_sides []
 
static void equalize_graph_keys (bAnimContext *ac, int mode, float handle_length, bool flatten)
 
static int graphkeys_equalize_handles_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_equalize_handles (wmOperatorType *ot)
 

Mirror Keyframes Operator

static const EnumPropertyItem prop_graphkeys_mirror_types []
 
static void mirror_graph_keys (bAnimContext *ac, short mode)
 
static int graphkeys_mirror_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_mirror (wmOperatorType *ot)
 

Detailed Description

Insert duplicate and bake keyframes.

Definition in file graph_edit.cc.

Macro Definition Documentation

◆ CLEAR_CYCLIC_EXPO

#define CLEAR_CYCLIC_EXPO   -2

Definition at line 1401 of file graph_edit.cc.

Referenced by setexpo_graph_keys().

◆ MAKE_CYCLIC_EXPO

#define MAKE_CYCLIC_EXPO   -1

Definition at line 1400 of file graph_edit.cc.

Referenced by setexpo_graph_keys().

Enumeration Type Documentation

◆ eGraphKeys_InsertKey_Types

Enumerator
GRAPHKEYS_INSERTKEY_ALL 
GRAPHKEYS_INSERTKEY_SEL 
GRAPHKEYS_INSERTKEY_CURSOR 
GRAPHKEYS_INSERTKEY_ACTIVE 

Definition at line 69 of file graph_edit.cc.

Function Documentation

◆ bake_graph_keys()

◆ clean_graph_keys()

◆ convert_keys_to_samples()

◆ convert_samples_to_keys()

◆ copy_graph_keys()

◆ delete_graph_keys()

◆ duplicate_graph_keys()

◆ equalize_graph_keys()

◆ euler_filter_group_channels()

static ListBase euler_filter_group_channels ( const ListBase * anim_data,
ReportList * reports,
int * r_num_groups )
static

◆ euler_filter_multi_channel()

◆ euler_filter_perform_filter()

static void euler_filter_perform_filter ( ListBase * eulers,
ReportList * reports,
int * r_curves_filtered,
int * r_curves_seen )
static

◆ euler_filter_single_channel()

static bool euler_filter_single_channel ( FCurve * fcu)
static

Definition at line 1933 of file graph_edit.cc.

References FCurve::bezt, float, M_PI, FCurve::totvert, and BezTriple::vec.

Referenced by euler_filter_perform_filter().

◆ find_closest_frame()

static bool find_closest_frame ( const FCurve * fcu,
const float frame,
const bool next,
float * r_closest_frame )
static

◆ graph_driver_delete_invalid_exec()

◆ graph_driver_delete_invalid_poll()

static bool graph_driver_delete_invalid_poll ( bContext * C)
static

Definition at line 3367 of file graph_edit.cc.

References ANIM_animdata_get_context(), CTX_wm_area(), and SPACE_GRAPH.

Referenced by GRAPH_OT_driver_delete_invalid().

◆ graph_driver_vars_copy_exec()

static int graph_driver_vars_copy_exec ( bContext * C,
wmOperator * op )
static

◆ graph_driver_vars_paste_exec()

◆ graph_fmodifier_add_exec()

◆ graph_fmodifier_copy_exec()

◆ graph_fmodifier_itemf()

◆ graph_fmodifier_paste_exec()

◆ graph_has_selected_control_points()

◆ GRAPH_OT_bake_keys()

◆ GRAPH_OT_clean()

◆ GRAPH_OT_click_insert()

◆ GRAPH_OT_copy()

◆ GRAPH_OT_delete()

◆ GRAPH_OT_driver_delete_invalid()

◆ GRAPH_OT_driver_variables_copy()

◆ GRAPH_OT_driver_variables_paste()

◆ GRAPH_OT_duplicate()

◆ GRAPH_OT_easing_type()

◆ GRAPH_OT_equalize_handles()

◆ GRAPH_OT_euler_filter()

◆ GRAPH_OT_extrapolation_type()

◆ GRAPH_OT_fmodifier_add()

◆ GRAPH_OT_fmodifier_copy()

◆ GRAPH_OT_fmodifier_paste()

◆ GRAPH_OT_frame_jump()

◆ GRAPH_OT_handle_type()

◆ GRAPH_OT_interpolation_type()

◆ GRAPH_OT_keyframe_insert()

◆ GRAPH_OT_keyframe_jump()

◆ GRAPH_OT_keys_to_samples()

◆ GRAPH_OT_mirror()

◆ GRAPH_OT_paste()

◆ GRAPH_OT_samples_to_keys()

◆ GRAPH_OT_smooth()

◆ GRAPH_OT_snap()

◆ GRAPH_OT_snap_cursor_value()

◆ GRAPH_OT_sound_to_samples()

◆ graphkeys_bake_exec()

static int graphkeys_bake_exec ( bContext * C,
wmOperator *  )
static

◆ graphkeys_clean_exec()

◆ graphkeys_click_insert_exec()

◆ graphkeys_click_insert_invoke()

static int graphkeys_click_insert_invoke ( bContext * C,
wmOperator * op,
const wmEvent * event )
static

◆ graphkeys_copy_exec()

static int graphkeys_copy_exec ( bContext * C,
wmOperator * op )
static

◆ graphkeys_delete_exec()

◆ graphkeys_delete_invoke()

static int graphkeys_delete_invoke ( bContext * C,
wmOperator * op,
const wmEvent *  )
static

◆ graphkeys_duplicate_exec()

static int graphkeys_duplicate_exec ( bContext * C,
wmOperator *  )
static

◆ graphkeys_easing_exec()

◆ graphkeys_equalize_handles_exec()

◆ graphkeys_euler_filter_exec()

◆ graphkeys_expo_exec()

◆ graphkeys_framejump_exec()

◆ graphkeys_framejump_poll()

static bool graphkeys_framejump_poll ( bContext * C)
static

◆ graphkeys_handletype_exec()

◆ graphkeys_insertkey_exec()

◆ graphkeys_ipo_exec()

◆ graphkeys_keys_to_samples_exec()

◆ graphkeys_mirror_exec()

◆ graphkeys_paste_exec()

◆ graphkeys_paste_get_description()

static std::string graphkeys_paste_get_description ( bContext * ,
wmOperatorType * ,
PointerRNA * ptr )
static

Definition at line 614 of file graph_edit.cc.

References ptr, RNA_boolean_get(), and TIP_.

Referenced by GRAPH_OT_paste().

◆ graphkeys_samples_to_keys_exec()

◆ graphkeys_selected_control_points_invoke()

static int graphkeys_selected_control_points_invoke ( bContext * C,
wmOperator * op,
const wmEvent * event )
static

◆ graphkeys_smooth_exec()

◆ graphkeys_snap_cursor_value_exec()

◆ graphkeys_snap_exec()

◆ graphkeys_sound_to_samples_exec()

static int graphkeys_sound_to_samples_exec ( bContext * ,
wmOperator * op )
static

Definition at line 1203 of file graph_edit.cc.

References BKE_report(), OPERATOR_CANCELLED, wmOperator::reports, and RPT_ERROR.

Referenced by GRAPH_OT_sound_to_samples().

◆ graphkeys_sound_to_samples_invoke()

static int graphkeys_sound_to_samples_invoke ( bContext * C,
wmOperator * op,
const wmEvent * event )
static

◆ insert_graph_keys()

◆ keyframe_jump_exec()

◆ keyframe_time_differs()

static bool keyframe_time_differs ( BezTriple * keyframes[3])
static

Definition at line 1792 of file graph_edit.cc.

References e, and fabs().

Referenced by euler_filter_multi_channel().

◆ mirror_graph_keys()

◆ paste_graph_keys()

◆ seteasing_graph_keys()

◆ setexpo_graph_keys()

◆ sethandles_graph_keys()

◆ setipo_graph_keys()

◆ snap_graph_keys()

◆ sum_selected_keyframes()

Variable Documentation

◆ prop_graphkeys_equalize_handles_sides

const EnumPropertyItem prop_graphkeys_equalize_handles_sides[]
static
Initial value:
= {
{GRAPHKEYS_EQUALIZE_LEFT, "LEFT", 0, "Left", "Equalize selected keyframes' left handles"},
{GRAPHKEYS_EQUALIZE_RIGHT, "RIGHT", 0, "Right", "Equalize selected keyframes' right handles"},
{GRAPHKEYS_EQUALIZE_BOTH, "BOTH", 0, "Both", "Equalize both of a keyframe's handles"},
{0, nullptr, 0, nullptr, nullptr},
}
@ GRAPHKEYS_EQUALIZE_RIGHT
@ GRAPHKEYS_EQUALIZE_BOTH
@ GRAPHKEYS_EQUALIZE_LEFT

Definition at line 2598 of file graph_edit.cc.

Referenced by GRAPH_OT_equalize_handles().

◆ prop_graphkeys_expo_types

const EnumPropertyItem prop_graphkeys_expo_types[]
static
Initial value:
= {
"CONSTANT",
0,
"Constant Extrapolation",
"Values on endpoint keyframes are held"},
"LINEAR",
0,
"Linear Extrapolation",
"Straight-line slope of end segments are extended past the endpoint keyframes"},
"MAKE_CYCLIC",
0,
"Make Cyclic (F-Modifier)",
"Add Cycles F-Modifier if one doesn't exist already"},
"CLEAR_CYCLIC",
0,
"Clear Cyclic (F-Modifier)",
"Remove Cycles F-Modifier if not needed anymore"},
{0, nullptr, 0, nullptr, nullptr},
}
@ FCURVE_EXTRAPOLATE_CONSTANT
@ FCURVE_EXTRAPOLATE_LINEAR
#define MAKE_CYCLIC_EXPO
#define CLEAR_CYCLIC_EXPO

Definition at line 1404 of file graph_edit.cc.

Referenced by GRAPH_OT_extrapolation_type().

◆ prop_graphkeys_insertkey_types

const EnumPropertyItem prop_graphkeys_insertkey_types[]
static
Initial value:
= {
"ALL",
0,
"All Channels",
"Insert a keyframe on all visible and editable F-Curves using each curve's current value"},
"SEL",
0,
"Only Selected Channels",
"Insert a keyframe on selected F-Curves using each curve's current value"},
"ACTIVE",
0,
"Only Active F-Curve",
"Insert a keyframe on the active F-Curve using the curve's current value"},
"CURSOR_ACTIVE",
0,
"Active Channels at Cursor",
"Insert a keyframe for the active F-Curve at the cursor point"},
"CURSOR_SEL",
0,
"Selected Channels at Cursor",
"Insert a keyframe for selected F-Curves at the cursor point"},
{0, nullptr, 0, nullptr, nullptr},
}
@ GRAPHKEYS_INSERTKEY_CURSOR
Definition graph_edit.cc:72
@ GRAPHKEYS_INSERTKEY_ACTIVE
Definition graph_edit.cc:73
@ GRAPHKEYS_INSERTKEY_ALL
Definition graph_edit.cc:70
@ GRAPHKEYS_INSERTKEY_SEL
Definition graph_edit.cc:71

Definition at line 77 of file graph_edit.cc.

Referenced by GRAPH_OT_keyframe_insert().

◆ prop_graphkeys_mirror_types

const EnumPropertyItem prop_graphkeys_mirror_types[]
static
Initial value:
= {
"CFRA",
0,
"By Times Over Current Frame",
"Flip times of selected keyframes using the current frame as the mirror line"},
"VALUE",
0,
"By Values Over Cursor Value",
"Flip values of selected keyframes using the cursor value (Y/Horizontal component) as the "
"mirror line"},
"YAXIS",
0,
"By Times Over Zero Time",
"Flip times of selected keyframes, effectively reversing the order they appear in"},
"XAXIS",
0,
"By Values Over Zero Value",
"Flip values of selected keyframes (i.e. negative values become positive, and vice versa)"},
"MARKER",
0,
"By Times Over First Selected Marker",
"Flip times of selected keyframes using the first selected marker as the reference point"},
{0, nullptr, 0, nullptr, nullptr},
}
@ GRAPHKEYS_MIRROR_XAXIS
@ GRAPHKEYS_MIRROR_CFRA
@ GRAPHKEYS_MIRROR_VALUE
@ GRAPHKEYS_MIRROR_YAXIS
@ GRAPHKEYS_MIRROR_MARKER

Definition at line 2699 of file graph_edit.cc.

Referenced by GRAPH_OT_mirror().

◆ prop_graphkeys_snap_types

const EnumPropertyItem prop_graphkeys_snap_types[]
static

Definition at line 2392 of file graph_edit.cc.

Referenced by GRAPH_OT_snap().