Blender V4.3
graph_select.cc File Reference
#include <cfloat>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_lasso_2d.hh"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "BKE_fcurve.hh"
#include "BKE_nla.hh"
#include "UI_interface_c.hh"
#include "UI_resources.hh"
#include "UI_view2d.hh"
#include "ED_anim_api.hh"
#include "ED_keyframes_edit.hh"
#include "ED_markers.hh"
#include "ED_select_utils.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "graph_intern.hh"

Go to the source code of this file.

Classes

struct  tNearestVertInfo
 

Functions

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...

void deselect_graph_keys (bAnimContext *ac, bool test, eEditKeyframes_Select sel, bool do_channels)
 
static int graphkeys_deselectall_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_select_all (wmOperatorType *ot)
 
Select Linked Operator
static int graphkeys_select_linked_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_select_linked (wmOperatorType *ot)
 
Select More/Less Operators
static void select_moreless_graph_keys (bAnimContext *ac, short mode)
 
static int graphkeys_select_more_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_select_more (wmOperatorType *ot)
 
static int graphkeys_select_less_exec (bContext *C, wmOperator *)
 
void GRAPH_OT_select_less (wmOperatorType *ot)
 
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).

static int mouse_graph_keys (bAnimContext *ac, const int mval[2], eEditKeyframes_Select select_mode, const bool deselect_all, const bool curves_only, bool wait_to_deselect_others)
 
static int graphkeys_mselect_column (bAnimContext *ac, const int mval[2], eEditKeyframes_Select select_mode, bool wait_to_deselect_others)
 
Click Select Operator
static int graphkeys_clickselect_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_clickselect (wmOperatorType *ot)
 

Internal Keyframe Utilities

#define GVERTSEL_TOL   (10 * U.pixelsize)
 
enum  eGraphVertIndex { NEAREST_HANDLE_LEFT = -1 , NEAREST_HANDLE_KEY , NEAREST_HANDLE_RIGHT }
 
static bool fcurve_handle_sel_check (SpaceGraph *sipo, BezTriple *bezt)
 
static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *fcu, eAnim_ChannelType ctype, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2], float unit_scale, float offset)
 
static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], ListBase *matches)
 
static tNearestVertInfoget_best_nearest_fcurve_vert (ListBase *matches)
 
static tNearestVertInfofind_nearest_fcurve_vert (bAnimContext *ac, const int mval[2])
 

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) -> 3) y-axis, so select all frames within channels that region included (validation with BEZT_OK_VALUERANGE).

The selection backend is also reused for the Lasso and Circle select operators.

#define ABOVE   1
 
#define INSIDE   0
 
#define BELOW   -1
 
static rctf initialize_box_select_coords (const bAnimContext *ac, const rctf *rectf_view)
 
static int initialize_animdata_selection_filter ()
 
static ListBase initialize_box_select_anim_data (const int filter, bAnimContext *ac)
 
static void initialize_box_select_key_editing_data (const bool incl_handles, const short mode, bAnimContext *ac, void *data, rctf *scaled_rectf, KeyframeEditData *r_ked, int *r_mapping_flag)
 
static bool box_select_graphkeys (bAnimContext *ac, const rctf *rectf_view, short mode, eEditKeyframes_Select selectmode, bool incl_handles, void *data)
 
static short ok_bezier_always_ok (KeyframeEditData *, BezTriple *)
 
static int rectf_curve_zone_y (const FCurve *fcu, const rctf *rectf, const float offset, const float unit_scale, const float eval_x)
 
static bool rectf_curve_intersection (const float offset, const float unit_scale, const rctf *rectf, AnimData *adt, const FCurve *fcu)
 
static void box_select_graphcurves (bAnimContext *ac, const rctf *rectf_view, const short mode, const eEditKeyframes_Select selectmode, const bool incl_handles, void *data)
 
static int graphkeys_box_select_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
static int graphkeys_box_select_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_select_box (wmOperatorType *ot)
 
static int graphkeys_lassoselect_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_select_lasso (wmOperatorType *ot)
 
static int graph_circle_select_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_select_circle (wmOperatorType *ot)
 

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)
static const EnumPropertyItem prop_column_select_types []
 
static void markers_selectkeys_between (bAnimContext *ac)
 
static void columnselect_graph_keys (bAnimContext *ac, short mode)
 
static int graphkeys_columnselect_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_select_column (wmOperatorType *ot)
 

Select Left/Right Operator

Select keyframes left/right of the current frame indicator.

static const EnumPropertyItem prop_graphkeys_leftright_select_types []
 
static void graphkeys_select_leftright (bAnimContext *ac, short leftright, eEditKeyframes_Select select_mode)
 
static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op)
 
static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void GRAPH_OT_select_leftright (wmOperatorType *ot)
 

Key/handles Selection Operator

static const EnumPropertyItem prop_graphkeys_select_key_handles_actions []
 
static void graphkeys_select_key_handles (bAnimContext *ac, const enum eGraphKey_SelectKeyHandles_Action left_handle_action, const enum eGraphKey_SelectKeyHandles_Action key_action, const enum eGraphKey_SelectKeyHandles_Action right_handle_action)
 
static int graphkeys_select_key_handles_exec (bContext *C, wmOperator *op)
 
void GRAPH_OT_select_key_handles (wmOperatorType *ot)
 

Macro Definition Documentation

◆ ABOVE

#define ABOVE   1

Definition at line 689 of file graph_select.cc.

Referenced by rectf_curve_zone_y().

◆ BELOW

#define BELOW   -1

Definition at line 691 of file graph_select.cc.

Referenced by rectf_curve_zone_y().

◆ GVERTSEL_TOL

#define GVERTSEL_TOL   (10 * U.pixelsize)

Definition at line 76 of file graph_select.cc.

Referenced by nearest_fcurve_vert_store().

◆ INSIDE

#define INSIDE   0

Definition at line 690 of file graph_select.cc.

Referenced by rectf_curve_intersection(), and rectf_curve_zone_y().

Enumeration Type Documentation

◆ eGraphVertIndex

Enumerator
NEAREST_HANDLE_LEFT 
NEAREST_HANDLE_KEY 
NEAREST_HANDLE_RIGHT 

Definition at line 68 of file graph_select.cc.

Function Documentation

◆ box_select_graphcurves()

static void box_select_graphcurves ( bAnimContext * ac,
const rctf * rectf_view,
const short mode,
const eEditKeyframes_Select selectmode,
const bool incl_handles,
void * data )
static

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.

Definition at line 759 of file graph_select.cc.

References ANIM_animdata_freelist(), ANIM_editkeyframes_select(), ANIM_fcurve_keyframes_loop(), ANIM_nla_mapping_get(), ANIM_set_active_channel(), ANIM_unit_mapping_get_factor(), ANIMTYPE_FCURVE, bAnimContext::data, bAnimContext::datatype, FCURVE_SELECTED, FCurve::flag, Scene::id, initialize_animdata_selection_filter(), initialize_box_select_anim_data(), initialize_box_select_coords(), initialize_box_select_key_editing_data(), LISTBASE_FOREACH, ok_bezier_always_ok(), rectf_curve_intersection(), bAnimContext::scene, SELECT_ADD, SELECT_REPLACE, rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.

Referenced by graph_circle_select_exec(), graphkeys_box_select_exec(), and graphkeys_lassoselect_exec().

◆ box_select_graphkeys()

static bool box_select_graphkeys ( bAnimContext * ac,
const rctf * rectf_view,
short mode,
eEditKeyframes_Select selectmode,
bool incl_handles,
void * data )
static

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

This function returns true if there was any change in the selection of a key (selecting or deselecting any key returns true, otherwise it returns false).

Definition at line 595 of file graph_select.cc.

References ANIM_animdata_freelist(), ANIM_editkeyframes_ok(), ANIM_editkeyframes_select(), ANIM_fcurve_keyframes_loop(), ANIM_nla_mapping_apply_fcurve(), ANIM_nla_mapping_get(), ANIM_unit_mapping_get_factor(), BEZT_OK_VALUERANGE, KeyframeEditData::f1, KeyframeEditData::f2, FCURVE_SELECTED, FCurve::flag, Scene::id, initialize_animdata_selection_filter(), initialize_box_select_anim_data(), initialize_box_select_coords(), initialize_box_select_key_editing_data(), LISTBASE_FOREACH, bAnimContext::scene, SELECT_ADD, USER_ANIM_ONLY_SHOW_SELECTED_CURVE_KEYS, rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.

Referenced by graph_circle_select_exec(), graphkeys_box_select_exec(), and graphkeys_lassoselect_exec().

◆ columnselect_graph_keys()

◆ deselect_graph_keys()

void deselect_graph_keys ( bAnimContext * ac,
bool test,
eEditKeyframes_Select sel,
bool do_channels )

◆ fcurve_handle_sel_check()

static bool fcurve_handle_sel_check ( SpaceGraph * sipo,
BezTriple * bezt )
static

◆ find_nearest_fcurve_vert()

static tNearestVertInfo * find_nearest_fcurve_vert ( bAnimContext * ac,
const int mval[2] )
static

Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates)

Note
the match info found must still be freed.

Definition at line 329 of file graph_select.cc.

References BLI_freelistN(), get_best_nearest_fcurve_vert(), and get_nearest_fcurve_verts_list().

Referenced by graphkeys_box_select_invoke(), graphkeys_mselect_column(), and mouse_graph_keys().

◆ get_best_nearest_fcurve_vert()

◆ get_nearest_fcurve_verts_list()

◆ graph_circle_select_exec()

◆ GRAPH_OT_clickselect()

◆ GRAPH_OT_select_all()

◆ GRAPH_OT_select_box()

◆ GRAPH_OT_select_circle()

◆ GRAPH_OT_select_column()

◆ GRAPH_OT_select_key_handles()

◆ GRAPH_OT_select_lasso()

◆ GRAPH_OT_select_leftright()

◆ GRAPH_OT_select_less()

◆ GRAPH_OT_select_linked()

◆ GRAPH_OT_select_more()

◆ graphkeys_box_select_exec()

◆ graphkeys_box_select_invoke()

◆ graphkeys_clickselect_exec()

◆ graphkeys_columnselect_exec()

◆ graphkeys_deselectall_exec()

◆ graphkeys_lassoselect_exec()

◆ graphkeys_mselect_column()

◆ graphkeys_select_key_handles()

static void graphkeys_select_key_handles ( bAnimContext * ac,
const enum eGraphKey_SelectKeyHandles_Action left_handle_action,
const enum eGraphKey_SelectKeyHandles_Action key_action,
const enum eGraphKey_SelectKeyHandles_Action right_handle_action )
static

Select/deselect different parts (e.g. left/right handles) of already-selected keys.

The *_action parameters determine what action to take on each part of a key: select, deselect, or keep (do nothing).

Parameters
left_handle_actionselection action to perform on left handles.
key_actionselection action to perform on the keys themselves.
right_handle_actionselection action to perform on right handles.

Definition at line 2097 of file graph_select.cc.

References ANIM_animdata_filter(), ANIM_animdata_freelist(), ANIMFILTER_CURVE_VISIBLE, ANIMFILTER_DATA_VISIBLE, ANIMFILTER_FCURVESONLY, ANIMFILTER_NODUPLIS, ANIMTYPE_FCURVE, FCurve::bezt, BEZT_DESEL_IDX, BEZT_ISSEL_ANY, BEZT_SEL_IDX, BLI_assert, bAnimContext::data, bAnimContext::datatype, GRAPHKEYS_KEYHANDLESSEL_DESELECT, GRAPHKEYS_KEYHANDLESSEL_KEEP, GRAPHKEYS_KEYHANDLESSEL_SELECT, LISTBASE_FOREACH, and FCurve::totvert.

Referenced by graphkeys_select_key_handles_exec().

◆ graphkeys_select_key_handles_exec()

◆ graphkeys_select_leftright()

◆ graphkeys_select_leftright_exec()

◆ graphkeys_select_leftright_invoke()

◆ graphkeys_select_less_exec()

◆ graphkeys_select_linked_exec()

◆ graphkeys_select_more_exec()

◆ initialize_animdata_selection_filter()

◆ initialize_box_select_anim_data()

static ListBase initialize_box_select_anim_data ( const int filter,
bAnimContext * ac )
static

◆ initialize_box_select_coords()

static rctf initialize_box_select_coords ( const bAnimContext * ac,
const rctf * rectf_view )
static

◆ initialize_box_select_key_editing_data()

◆ markers_selectkeys_between()

◆ mouse_graph_keys()

◆ nearest_fcurve_vert_store()

◆ ok_bezier_always_ok()

static short ok_bezier_always_ok ( KeyframeEditData * ,
BezTriple *  )
static

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".

Definition at line 684 of file graph_select.cc.

References KEYFRAME_OK_H1, KEYFRAME_OK_H2, and KEYFRAME_OK_KEY.

Referenced by box_select_graphcurves().

◆ rectf_curve_intersection()

static bool rectf_curve_intersection ( const float offset,
const float unit_scale,
const rctf * rectf,
AnimData * adt,
const FCurve * fcu )
static

◆ rectf_curve_zone_y()

static int rectf_curve_zone_y ( const FCurve * fcu,
const rctf * rectf,
const float offset,
const float unit_scale,
const float eval_x )
static

Definition at line 692 of file graph_select.cc.

References ABOVE, BELOW, evaluate_fcurve(), INSIDE, rctf::ymax, and rctf::ymin.

Referenced by rectf_curve_intersection().

◆ select_moreless_graph_keys()

Variable Documentation

◆ prop_column_select_types

const EnumPropertyItem prop_column_select_types[]
static
Initial value:
= {
{GRAPHKEYS_COLUMNSEL_KEYS, "KEYS", 0, "On Selected Keyframes", ""},
{GRAPHKEYS_COLUMNSEL_CFRA, "CFRA", 0, "On Current Frame", ""},
{GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", 0, "On Selected Markers", ""},
"MARKERS_BETWEEN",
0,
"Between Min/Max Selected Markers",
""},
{0, nullptr, 0, nullptr, nullptr},
}
@ GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN
@ GRAPHKEYS_COLUMNSEL_KEYS
@ GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN
@ GRAPHKEYS_COLUMNSEL_CFRA

Definition at line 1152 of file graph_select.cc.

Referenced by GRAPH_OT_select_column().

◆ prop_graphkeys_leftright_select_types

const EnumPropertyItem prop_graphkeys_leftright_select_types[]
static
Initial value:
= {
{GRAPHKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""},
{GRAPHKEYS_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""},
{GRAPHKEYS_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""},
{0, nullptr, 0, nullptr, nullptr},
}
@ GRAPHKEYS_LRSEL_TEST
@ GRAPHKEYS_LRSEL_RIGHT
@ GRAPHKEYS_LRSEL_LEFT

Definition at line 1531 of file graph_select.cc.

Referenced by GRAPH_OT_select_leftright().

◆ prop_graphkeys_select_key_handles_actions

const EnumPropertyItem prop_graphkeys_select_key_handles_actions[]
static
Initial value:
= {
{GRAPHKEYS_KEYHANDLESSEL_SELECT, "SELECT", 0, "Select", ""},
{GRAPHKEYS_KEYHANDLESSEL_DESELECT, "DESELECT", 0, "Deselect", ""},
{GRAPHKEYS_KEYHANDLESSEL_KEEP, "KEEP", 0, "Keep", "Leave as is"},
{0, nullptr, 0, nullptr, nullptr},
}
@ GRAPHKEYS_KEYHANDLESSEL_KEEP
@ GRAPHKEYS_KEYHANDLESSEL_SELECT
@ GRAPHKEYS_KEYHANDLESSEL_DESELECT

Definition at line 2080 of file graph_select.cc.

Referenced by GRAPH_OT_select_key_handles().