Blender  V3.3
Classes
graph_select.c File Reference
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_lasso_2d.h"
#include "BLI_math.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.h"
#include "RNA_define.h"
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_nla.h"
#include "UI_view2d.h"
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
#include "ED_markers.h"
#include "ED_select_utils.h"
#include "WM_api.h"
#include "WM_types.h"
#include "graph_intern.h"

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, short 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 *UNUSED(op))
 
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 *UNUSED(op))
 
void GRAPH_OT_select_more (wmOperatorType *ot)
 
static int graphkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op))
 
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 }
 
typedef struct tNearestVertInfo tNearestVertInfo
 
typedef enum eGraphVertIndex eGraphVertIndex
 
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 (const SpaceGraph *sipo)
 
static ListBase initialize_box_select_anim_data (const int filter, bAnimContext *ac)
 
static void initialize_box_select_key_editing_data (const SpaceGraph *sipo, 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, short selectmode, bool incl_handles, void *data)
 
static short ok_bezier_always_ok (KeyframeEditData *UNUSED(ked), BezTriple *UNUSED(bezt))
 
static int rectf_curve_zone_y (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, FCurve *fcu)
 
static void box_select_graphcurves (bAnimContext *ac, const rctf *rectf_view, const short mode, const short 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, short 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)
 

Macro Definition Documentation

◆ ABOVE

#define ABOVE   1

Definition at line 667 of file graph_select.c.

◆ BELOW

#define BELOW   -1

Definition at line 669 of file graph_select.c.

◆ GVERTSEL_TOL

#define GVERTSEL_TOL   (10 * U.pixelsize)

Definition at line 75 of file graph_select.c.

◆ INSIDE

#define INSIDE   0

Definition at line 668 of file graph_select.c.

Typedef Documentation

◆ eGraphVertIndex

◆ tNearestVertInfo

Enumeration Type Documentation

◆ eGraphVertIndex

Enumerator
NEAREST_HANDLE_LEFT 
NEAREST_HANDLE_KEY 
NEAREST_HANDLE_RIGHT 

Definition at line 67 of file graph_select.c.

Function Documentation

◆ box_select_graphcurves()

static void box_select_graphcurves ( bAnimContext ac,
const rctf rectf_view,
const short  mode,
const short  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 731 of file graph_select.c.

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, data, bAnimContext::data, bAnimContext::datatype, FCURVE_SELECTED, filter(), 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, NULL, offset, ok_bezier_always_ok(), rectf_curve_intersection(), bAnimContext::scene, SELECT_ADD, SELECT_REPLACE, bAnimContext::sl, 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,
short  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 571 of file graph_select.c.

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, data, KeyframeEditData::f1, KeyframeEditData::f2, tNearestVertInfo::fcu, FCURVE_SELECTED, filter(), ListBase::first, FCurve::flag, SpaceGraph::flag, bAnimListElem::id, initialize_animdata_selection_filter(), initialize_box_select_anim_data(), initialize_box_select_coords(), initialize_box_select_key_editing_data(), bAnimListElem::key_data, bAnimListElem::next, NULL, offset, bAnimContext::scene, SELECT_ADD, SIPO_SELCUVERTSONLY, bAnimContext::sl, 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()

static void columnselect_graph_keys ( bAnimContext ac,
short  mode 
)
static

◆ deselect_graph_keys()

void deselect_graph_keys ( struct bAnimContext ac,
bool  test,
short  sel,
bool  do_channels 
)

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
  • sel: how to select keyframes 0 = deselect 1 = select 2 = invert
  • do_channels: whether to affect selection status of channels

Definition at line 335 of file graph_select.c.

References filter(), NULL, and bAnimContext::sl.

Referenced by graph_circle_select_exec(), graphkeys_box_select_exec(), graphkeys_click_insert_exec(), graphkeys_deselectall_exec(), graphkeys_lassoselect_exec(), graphkeys_mselect_column(), graphkeys_select_leftright(), and mouse_graph_keys().

◆ 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 307 of file graph_select.c.

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

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

◆ get_best_nearest_fcurve_vert()

static tNearestVertInfo* get_best_nearest_fcurve_vert ( ListBase matches)
static

◆ get_nearest_fcurve_verts_list()

static void get_nearest_fcurve_verts_list ( bAnimContext ac,
const int  mval[2],
ListBase matches 
)
static

◆ graph_circle_select_exec()

static int graph_circle_select_exec ( bContext C,
wmOperator op 
)
static

◆ GRAPH_OT_clickselect()

void GRAPH_OT_clickselect ( wmOperatorType ot)

◆ GRAPH_OT_select_all()

void GRAPH_OT_select_all ( wmOperatorType ot)

◆ GRAPH_OT_select_box()

void GRAPH_OT_select_box ( wmOperatorType ot)

◆ GRAPH_OT_select_circle()

void GRAPH_OT_select_circle ( wmOperatorType ot)

◆ GRAPH_OT_select_column()

void GRAPH_OT_select_column ( wmOperatorType ot)

◆ GRAPH_OT_select_lasso()

void GRAPH_OT_select_lasso ( wmOperatorType ot)

◆ GRAPH_OT_select_leftright()

void GRAPH_OT_select_leftright ( wmOperatorType ot)

◆ GRAPH_OT_select_less()

void GRAPH_OT_select_less ( wmOperatorType ot)

◆ GRAPH_OT_select_linked()

void GRAPH_OT_select_linked ( wmOperatorType ot)

◆ GRAPH_OT_select_more()

void GRAPH_OT_select_more ( wmOperatorType ot)

◆ graphkeys_box_select_exec()

static int graphkeys_box_select_exec ( bContext C,
wmOperator op 
)
static

◆ graphkeys_box_select_invoke()

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

◆ graphkeys_clickselect_exec()

static int graphkeys_clickselect_exec ( bContext C,
wmOperator op 
)
static

◆ graphkeys_columnselect_exec()

static int graphkeys_columnselect_exec ( bContext C,
wmOperator op 
)
static

◆ graphkeys_deselectall_exec()

static int graphkeys_deselectall_exec ( bContext C,
wmOperator op 
)
static

◆ graphkeys_lassoselect_exec()

static int graphkeys_lassoselect_exec ( bContext C,
wmOperator op 
)
static

◆ graphkeys_mselect_column()

static int graphkeys_mselect_column ( bAnimContext ac,
const int  mval[2],
eEditKeyframes_Select  select_mode,
bool  wait_to_deselect_others 
)
static

◆ graphkeys_select_leftright()

static void graphkeys_select_leftright ( bAnimContext ac,
short  leftright,
short  select_mode 
)
static

◆ graphkeys_select_leftright_exec()

static int graphkeys_select_leftright_exec ( bContext C,
wmOperator op 
)
static

◆ graphkeys_select_leftright_invoke()

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

◆ graphkeys_select_less_exec()

static int graphkeys_select_less_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ graphkeys_select_linked_exec()

static int graphkeys_select_linked_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ graphkeys_select_more_exec()

static int graphkeys_select_more_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ initialize_animdata_selection_filter()

static int initialize_animdata_selection_filter ( const SpaceGraph sipo)
static

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

static void initialize_box_select_key_editing_data ( const SpaceGraph sipo,
const bool  incl_handles,
const short  mode,
bAnimContext ac,
void data,
rctf scaled_rectf,
KeyframeEditData r_ked,
int *  r_mapping_flag 
)
static

◆ markers_selectkeys_between()

static void markers_selectkeys_between ( bAnimContext ac)
static

◆ mouse_graph_keys()

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

◆ nearest_fcurve_vert_store()

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

◆ ok_bezier_always_ok()

static short ok_bezier_always_ok ( KeyframeEditData UNUSEDked,
BezTriple UNUSEDbezt 
)
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 662 of file graph_select.c.

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,
FCurve fcu 
)
static

◆ rectf_curve_zone_y()

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

◆ select_moreless_graph_keys()

static void select_moreless_graph_keys ( bAnimContext ac,
short  mode 
)
static

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, NULL, 0, NULL, NULL},
}
@ GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN
Definition: graph_intern.h:82
@ GRAPHKEYS_COLUMNSEL_KEYS
Definition: graph_intern.h:79
@ GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN
Definition: graph_intern.h:81
@ GRAPHKEYS_COLUMNSEL_CFRA
Definition: graph_intern.h:80

Definition at line 1116 of file graph_select.c.

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, NULL, 0, NULL, NULL},
}
@ GRAPHKEYS_LRSEL_TEST
Definition: graph_intern.h:72
@ GRAPHKEYS_LRSEL_RIGHT
Definition: graph_intern.h:74
@ GRAPHKEYS_LRSEL_LEFT
Definition: graph_intern.h:73

Definition at line 1489 of file graph_select.c.

Referenced by GRAPH_OT_select_leftright().