Blender V4.5
drivers.cc File Reference
#include <cctype>
#include <cstdio>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
#include "BKE_anim_data.hh"
#include "BKE_context.hh"
#include "BKE_fcurve.hh"
#include "BKE_fcurve_driver.h"
#include "BKE_report.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_build.hh"
#include "ED_keyframing.hh"
#include "UI_interface.hh"
#include "UI_resources.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_path.hh"
#include "RNA_prototypes.hh"
#include "ANIM_fcurve.hh"
#include "anim_intern.hh"

Go to the source code of this file.

Functions

FCurveverify_driver_fcurve (ID *id, const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
FCurvealloc_driver_fcurve (const char rna_path[], const int array_index, eDriverFCurveCreationMode creation_mode)
static int add_driver_with_target (ReportList *, ID *dst_id, const char dst_path[], int dst_index, ID *src_id, const char src_path[], int src_index, PointerRNA *dst_ptr, PropertyRNA *dst_prop, PointerRNA *src_ptr, PropertyRNA *src_prop, short flag, int driver_type)
int ANIM_add_driver_with_target (ReportList *reports, ID *dst_id, const char dst_path[], int dst_index, ID *src_id, const char src_path[], int src_index, short flag, int driver_type, short mapping_type)
 Main Driver Management API calls.
int ANIM_add_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type)
 Main Driver Management API calls.
bool ANIM_remove_driver (ID *id, const char rna_path[], int array_index)
 Main Driver Management API calls.
void ANIM_drivers_copybuf_free ()
bool ANIM_driver_can_paste ()
bool ANIM_copy_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short)
 Main Driver Management API calls.
bool ANIM_paste_driver (ReportList *reports, ID *id, const char rna_path[], int array_index, short)
 Main Driver Management API calls.
void ANIM_driver_vars_copybuf_free ()
bool ANIM_driver_vars_can_paste ()
bool ANIM_driver_vars_copy (ReportList *reports, FCurve *fcu)
bool ANIM_driver_vars_paste (ReportList *reports, FCurve *fcu, bool replace)
void ANIM_copy_as_driver (ID *target_id, const char *target_path, const char *var_name)
static const EnumPropertyItemdriver_mapping_type_itemf (bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static bool add_driver_button_poll (bContext *C)
static wmOperatorStatus add_driver_button_none (bContext *C, wmOperator *op, short mapping_type)
static wmOperatorStatus add_driver_button_menu_exec (bContext *C, wmOperator *op)
static wmOperatorStatus add_driver_button_menu_invoke (bContext *C, wmOperator *op, const wmEvent *)
static void UNUSED_FUNCTION ANIM_OT_driver_button_add_menu (wmOperatorType *ot)
static wmOperatorStatus add_driver_button_invoke (bContext *C, wmOperator *op, const wmEvent *)
void ANIM_OT_driver_button_add (wmOperatorType *ot)
static wmOperatorStatus remove_driver_button_exec (bContext *C, wmOperator *op)
void ANIM_OT_driver_button_remove (wmOperatorType *ot)
static wmOperatorStatus edit_driver_button_exec (bContext *C, wmOperator *op)
void ANIM_OT_driver_button_edit (wmOperatorType *ot)
static wmOperatorStatus copy_driver_button_exec (bContext *C, wmOperator *op)
void ANIM_OT_copy_driver_button (wmOperatorType *ot)
static wmOperatorStatus paste_driver_button_exec (bContext *C, wmOperator *op)
void ANIM_OT_paste_driver_button (wmOperatorType *ot)

Variables

static FCurvechanneldriver_copypaste_buf = nullptr
static ListBase driver_vars_copybuf = {nullptr, nullptr}
const EnumPropertyItem prop_driver_create_mapping_types []

Function Documentation

◆ add_driver_button_invoke()

◆ add_driver_button_menu_exec()

◆ add_driver_button_menu_invoke()

◆ add_driver_button_none()

◆ add_driver_button_poll()

◆ add_driver_with_target()

◆ alloc_driver_fcurve()

◆ ANIM_add_driver()

◆ ANIM_add_driver_with_target()

int ANIM_add_driver_with_target ( ReportList * reports,
ID * dst_id,
const char dst_path[],
int dst_index,
ID * src_id,
const char src_path[],
int src_index,
short flag,
int driver_type,
short mapping_type )

Main Driver Management API calls.

Add a new driver for the specified property on the given ID block, and make it be driven by the specified target.

This is intended to be used in conjunction with a modal "eyedropper" for picking the variable that is going to be used to drive this one.

Parameters
flageCreateDriverFlags
driver_typeeDriver_Types
mapping_typeeCreateDriver_MappingTypes

Definition at line 284 of file drivers.cc.

References add_driver_with_target(), ANIM_add_driver(), ANIM_add_driver_with_target(), BKE_reportf(), CREATEDRIVER_MAPPING_1_1, CREATEDRIVER_MAPPING_1_N, CREATEDRIVER_MAPPING_N_N, CREATEDRIVER_MAPPING_NONE, CREATEDRIVER_WITH_DEFAULT_DVAR, i, len(), ID::name, reports, RNA_id_pointer_create(), RNA_path_resolve_property(), RNA_property_array_check(), RNA_property_array_length(), and RPT_ERROR.

Referenced by ANIM_add_driver_with_target(), and driverdropper_sample().

◆ ANIM_copy_as_driver()

void ANIM_copy_as_driver ( ID * target_id,
const char * target_path,
const char * var_name )

◆ ANIM_copy_driver()

bool ANIM_copy_driver ( ReportList * reports,
ID * id,
const char rna_path[],
int array_index,
short flag )

◆ ANIM_driver_can_paste()

bool ANIM_driver_can_paste ( )

Returns whether there is a driver in the copy/paste buffer to paste.

Definition at line 572 of file drivers.cc.

References ANIM_driver_can_paste(), and channeldriver_copypaste_buf.

Referenced by ANIM_driver_can_paste(), and ui_popup_context_menu_for_button().

◆ ANIM_driver_vars_can_paste()

bool ANIM_driver_vars_can_paste ( )

Checks if there are driver variables in the copy/paste buffer.

Definition at line 700 of file drivers.cc.

References ANIM_driver_vars_can_paste(), BLI_listbase_is_empty(), and driver_vars_copybuf.

Referenced by ANIM_driver_vars_can_paste().

◆ ANIM_driver_vars_copy()

bool ANIM_driver_vars_copy ( ReportList * reports,
FCurve * fcu )

◆ ANIM_driver_vars_copybuf_free()

void ANIM_driver_vars_copybuf_free ( )

Clear copy-paste buffer for driver variable sets.

Note
This function frees any MEM_calloc'ed copy/paste buffer data.

Definition at line 684 of file drivers.cc.

References ANIM_driver_vars_copybuf_free(), BLI_listbase_clear(), driver_free_variable(), driver_vars_copybuf, ListBase::first, and DriverVar::next.

Referenced by ANIM_copy_as_driver(), ANIM_driver_vars_copy(), ANIM_driver_vars_copybuf_free(), and WM_exit_ex().

◆ ANIM_driver_vars_paste()

◆ ANIM_drivers_copybuf_free()

void ANIM_drivers_copybuf_free ( )

Clear copy-paste buffer for drivers.

Note
This function frees any MEM_calloc'ed copy/paste buffer data.

Definition at line 563 of file drivers.cc.

References ANIM_drivers_copybuf_free(), BKE_fcurve_free(), and channeldriver_copypaste_buf.

Referenced by ANIM_copy_as_driver(), ANIM_copy_driver(), ANIM_drivers_copybuf_free(), and WM_exit_ex().

◆ ANIM_OT_copy_driver_button()

◆ ANIM_OT_driver_button_add()

◆ ANIM_OT_driver_button_add_menu()

◆ ANIM_OT_driver_button_edit()

◆ ANIM_OT_driver_button_remove()

◆ ANIM_OT_paste_driver_button()

◆ ANIM_paste_driver()

bool ANIM_paste_driver ( ReportList * reports,
ID * id,
const char rna_path[],
int array_index,
short flag )

Main Driver Management API calls.

Add a new driver for the specified property on the given ID block or replace an existing one with the driver + driver-curve data from the buffer.

Definition at line 627 of file drivers.cc.

References ANIM_paste_driver(), FCurve::bezt, BKE_report(), BKE_reportf(), channeldriver_copypaste_buf, copy_fmodifiers(), FCurve::driver, DRIVER_FCURVE_EMPTY, FCurve::extend, fcurve_copy_driver(), FCurve::fpt, MEM_dupallocN(), FCurve::modifiers, ID::name, reports, RNA_id_pointer_create(), RNA_path_resolve_property(), RPT_ERROR, FCurve::totvert, and verify_driver_fcurve().

Referenced by ANIM_paste_driver(), and paste_driver_button_exec().

◆ ANIM_remove_driver()

bool ANIM_remove_driver ( ID * id,
const char rna_path[],
int array_index )

◆ copy_driver_button_exec()

◆ driver_mapping_type_itemf()

◆ edit_driver_button_exec()

◆ paste_driver_button_exec()

◆ remove_driver_button_exec()

◆ verify_driver_fcurve()

FCurve * verify_driver_fcurve ( ID * id,
const char rna_path[],
int array_index,
eDriverFCurveCreationMode creation_mode )

Get (or add relevant data to be able to do so) F-Curve from the driver stack, for the given Animation Data block. This assumes that all the destinations are valid.

Note
This low-level function shouldn't be used directly for most tools, although there are special cases where this approach is preferable.

Definition at line 50 of file drivers.cc.

References alloc_driver_fcurve(), BKE_animdata_ensure_id(), BKE_animdata_from_id(), BKE_fcurve_find(), BLI_addtail(), DRIVER_FCURVE_LOOKUP_ONLY, AnimData::drivers, ELEM, and verify_driver_fcurve().

Referenced by add_driver_with_target(), ANIM_add_driver(), ANIM_copy_driver(), ANIM_paste_driver(), ANIM_remove_driver(), ui_but_anim_expression_create(), and verify_driver_fcurve().

Variable Documentation

◆ channeldriver_copypaste_buf

FCurve* channeldriver_copypaste_buf = nullptr
static

◆ driver_vars_copybuf

◆ prop_driver_create_mapping_types

const EnumPropertyItem prop_driver_create_mapping_types[]

Mapping Types enum for operators.

Note
Used by ANIM_OT_driver_button_add and UI_OT_eyedropper_driver.

Definition at line 827 of file drivers.cc.

Referenced by ANIM_OT_driver_button_add_menu(), driver_mapping_type_itemf(), and UI_OT_eyedropper_driver().