Blender V5.0
graph_edit.cc File Reference
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_fileops.h"
#include "BLI_listbase.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.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 wmOperatorStatus graphkeys_click_insert_exec (bContext *C, wmOperator *op)
static wmOperatorStatus 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 bool 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, const bool flip)
static wmOperatorStatus graphkeys_copy_exec (bContext *C, wmOperator *op)
void GRAPH_OT_copy (wmOperatorType *ot)
static wmOperatorStatus 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 wmOperatorStatus graphkeys_duplicate_exec (bContext *C, wmOperator *)
void GRAPH_OT_duplicate (wmOperatorType *ot)
Delete Keyframes Operator
static bool delete_graph_keys (bAnimContext *ac)
static wmOperatorStatus graphkeys_delete_exec (bContext *C, wmOperator *)
static wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus graphkeys_samples_to_keys_exec (bContext *C, wmOperator *)
void GRAPH_OT_samples_to_keys (wmOperatorType *ot)
static wmOperatorStatus graphkeys_sound_to_samples_exec (bContext *, wmOperator *op)
static wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus graphkeys_framejump_exec (bContext *C, wmOperator *)
void GRAPH_OT_frame_jump (wmOperatorType *ot)
static wmOperatorStatus keyframe_jump_exec (bContext *C, wmOperator *op)
void GRAPH_OT_keyframe_jump (wmOperatorType *ot)
static wmOperatorStatus graphkeys_snap_cursor_value_exec (bContext *C, wmOperator *)
void GRAPH_OT_snap_cursor_value (wmOperatorType *ot)
Smooth Keyframes Operator
static wmOperatorStatus 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 wmOperatorStatus graph_fmodifier_add_exec (bContext *C, wmOperator *op)
void GRAPH_OT_fmodifier_add (wmOperatorType *ot)
Copy F-Modifiers Operator
static wmOperatorStatus graph_fmodifier_copy_exec (bContext *C, wmOperator *op)
void GRAPH_OT_fmodifier_copy (wmOperatorType *ot)
Paste F-Modifiers Operator
static wmOperatorStatus graph_fmodifier_paste_exec (bContext *C, wmOperator *op)
void GRAPH_OT_fmodifier_paste (wmOperatorType *ot)
Copy Driver Variables Operator
static wmOperatorStatus graph_driver_vars_copy_exec (bContext *C, wmOperator *op)
void GRAPH_OT_driver_variables_copy (wmOperatorType *ot)
Paste Driver Variables Operator
static wmOperatorStatus graph_driver_vars_paste_exec (bContext *C, wmOperator *op)
void GRAPH_OT_driver_variables_paste (wmOperatorType *ot)
Delete Invalid Drivers Operator
static wmOperatorStatus graph_driver_delete_invalid_exec (bContext *C, wmOperator *op)
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 wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus graphkeys_snap_exec (bContext *C, wmOperator *op)
static bool graph_has_selected_control_points (bContext *C)
static wmOperatorStatus 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 wmOperatorStatus 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 wmOperatorStatus 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 1407 of file graph_edit.cc.

◆ MAKE_CYCLIC_EXPO

#define MAKE_CYCLIC_EXPO   -1

Definition at line 1406 of file graph_edit.cc.

Enumeration Type Documentation

◆ eGraphKeys_InsertKey_Types

Enumerator
GRAPHKEYS_INSERTKEY_ALL 
GRAPHKEYS_INSERTKEY_SEL 
GRAPHKEYS_INSERTKEY_CURSOR 
GRAPHKEYS_INSERTKEY_ACTIVE 

Definition at line 71 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()

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

◆ euler_filter_multi_channel()

◆ euler_filter_perform_filter()

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

◆ euler_filter_single_channel()

bool euler_filter_single_channel ( FCurve * fcu)
static

Definition at line 1939 of file graph_edit.cc.

References FCurve::bezt, float, i, M_PI, sign(), FCurve::totvert, and BezTriple::vec.

Referenced by euler_filter_perform_filter().

◆ graph_driver_delete_invalid_exec()

◆ graph_driver_delete_invalid_poll()

bool graph_driver_delete_invalid_poll ( bContext * C)
static

◆ graph_driver_vars_copy_exec()

wmOperatorStatus 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()

void GRAPH_OT_bake_keys ( wmOperatorType * ot)

◆ GRAPH_OT_clean()

◆ GRAPH_OT_click_insert()

◆ GRAPH_OT_copy()

void GRAPH_OT_copy ( wmOperatorType * ot)

◆ GRAPH_OT_delete()

◆ GRAPH_OT_driver_delete_invalid()

void GRAPH_OT_driver_delete_invalid ( wmOperatorType * ot)

◆ GRAPH_OT_driver_variables_copy()

void GRAPH_OT_driver_variables_copy ( wmOperatorType * ot)

◆ GRAPH_OT_driver_variables_paste()

void GRAPH_OT_driver_variables_paste ( wmOperatorType * ot)

◆ GRAPH_OT_duplicate()

◆ GRAPH_OT_easing_type()

◆ GRAPH_OT_equalize_handles()

◆ GRAPH_OT_euler_filter()

void GRAPH_OT_euler_filter ( wmOperatorType * ot)

◆ GRAPH_OT_extrapolation_type()

◆ GRAPH_OT_fmodifier_add()

◆ GRAPH_OT_fmodifier_copy()

void GRAPH_OT_fmodifier_copy ( wmOperatorType * ot)

◆ GRAPH_OT_fmodifier_paste()

void GRAPH_OT_fmodifier_paste ( wmOperatorType * ot)

◆ GRAPH_OT_frame_jump()

void GRAPH_OT_frame_jump ( wmOperatorType * ot)

◆ GRAPH_OT_handle_type()

◆ GRAPH_OT_interpolation_type()

◆ GRAPH_OT_keyframe_insert()

◆ GRAPH_OT_keyframe_jump()

void GRAPH_OT_keyframe_jump ( wmOperatorType * ot)

◆ GRAPH_OT_keys_to_samples()

void GRAPH_OT_keys_to_samples ( wmOperatorType * ot)

◆ GRAPH_OT_mirror()

◆ GRAPH_OT_paste()

◆ GRAPH_OT_samples_to_keys()

void GRAPH_OT_samples_to_keys ( wmOperatorType * ot)

◆ GRAPH_OT_smooth()

void GRAPH_OT_smooth ( wmOperatorType * ot)

◆ GRAPH_OT_snap()

◆ GRAPH_OT_snap_cursor_value()

void GRAPH_OT_snap_cursor_value ( wmOperatorType * ot)

◆ GRAPH_OT_sound_to_samples()

◆ graphkeys_bake_exec()

◆ graphkeys_clean_exec()

◆ graphkeys_click_insert_exec()

◆ graphkeys_click_insert_invoke()

◆ graphkeys_copy_exec()

◆ graphkeys_delete_exec()

◆ graphkeys_delete_invoke()

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

◆ graphkeys_duplicate_exec()

◆ graphkeys_easing_exec()

◆ graphkeys_equalize_handles_exec()

◆ graphkeys_euler_filter_exec()

◆ graphkeys_expo_exec()

◆ graphkeys_framejump_exec()

◆ graphkeys_framejump_poll()

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()

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

Definition at line 612 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()

wmOperatorStatus 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()

wmOperatorStatus graphkeys_sound_to_samples_exec ( bContext * ,
wmOperator * op )
static

Definition at line 1207 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()

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

◆ insert_graph_keys()

◆ keyframe_jump_exec()

◆ keyframe_time_differs()

bool keyframe_time_differs ( BezTriple * keyframes[3])
static

Definition at line 1798 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 2505 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 does not 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 1410 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:74
@ GRAPHKEYS_INSERTKEY_ACTIVE
Definition graph_edit.cc:75
@ GRAPHKEYS_INSERTKEY_ALL
Definition graph_edit.cc:72
@ GRAPHKEYS_INSERTKEY_SEL
Definition graph_edit.cc:73

Definition at line 79 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 2606 of file graph_edit.cc.

Referenced by GRAPH_OT_mirror().

◆ prop_graphkeys_snap_types

const EnumPropertyItem prop_graphkeys_snap_types[]
static

Definition at line 2307 of file graph_edit.cc.

Referenced by GRAPH_OT_snap().