|
Blender
V2.59
|
00001 /* 00002 * $Id: ED_keyframes_edit.h 35016 2011-02-21 07:25:24Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2008 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * 00024 * Contributor(s): Joshua Leung 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00033 #ifndef ED_KEYFRAMES_EDIT_H 00034 #define ED_KEYFRAMES_EDIT_H 00035 00036 struct bAnimContext; 00037 struct bAnimListElem; 00038 struct FCurve; 00039 struct BezTriple; 00040 struct Scene; 00041 00042 /* ************************************************ */ 00043 /* Common Macros and Defines */ 00044 00045 /* --------- BezTriple Selection ------------- */ 00046 00047 #define BEZ_SEL(bezt) { (bezt)->f1 |= SELECT; (bezt)->f2 |= SELECT; (bezt)->f3 |= SELECT; } 00048 #define BEZ_DESEL(bezt) { (bezt)->f1 &= ~SELECT; (bezt)->f2 &= ~SELECT; (bezt)->f3 &= ~SELECT; } 00049 #define BEZ_INVSEL(bezt) { (bezt)->f1 ^= SELECT; (bezt)->f2 ^= SELECT; (bezt)->f3 ^= SELECT; } 00050 00051 /* --------- Tool Flags ------------ */ 00052 00053 /* bezt validation */ 00054 typedef enum eEditKeyframes_Validate { 00055 BEZT_OK_FRAME = 1, 00056 BEZT_OK_FRAMERANGE, 00057 BEZT_OK_SELECTED, 00058 BEZT_OK_VALUE, 00059 BEZT_OK_VALUERANGE, 00060 BEZT_OK_REGION 00061 } eEditKeyframes_Validate; 00062 00063 /* ------------ */ 00064 00065 /* select modes */ 00066 typedef enum eEditKeyframes_Select { 00067 /* SELECT_SUBTRACT for all, followed by SELECT_ADD for some */ 00068 SELECT_REPLACE = (1<<0), 00069 /* add ok keyframes to selection */ 00070 SELECT_ADD = (1<<1), 00071 /* remove ok keyframes from selection */ 00072 SELECT_SUBTRACT = (1<<2), 00073 /* flip ok status of keyframes based on key status */ 00074 SELECT_INVERT = (1<<3) 00075 } eEditKeyframes_Select; 00076 00077 /* "selection map" building modes */ 00078 typedef enum eEditKeyframes_SelMap { 00079 SELMAP_MORE = 0, 00080 SELMAP_LESS 00081 } eEditKeyframes_SelMap; 00082 00083 /* snapping tools */ 00084 typedef enum eEditKeyframes_Snap { 00085 SNAP_KEYS_CURFRAME = 1, 00086 SNAP_KEYS_NEARFRAME, 00087 SNAP_KEYS_NEARSEC, 00088 SNAP_KEYS_NEARMARKER, 00089 SNAP_KEYS_HORIZONTAL, 00090 SNAP_KEYS_VALUE 00091 } eEditKeyframes_Snap; 00092 00093 /* mirroring tools */ 00094 typedef enum eEditKeyframes_Mirror { 00095 MIRROR_KEYS_CURFRAME = 1, 00096 MIRROR_KEYS_YAXIS, 00097 MIRROR_KEYS_XAXIS, 00098 MIRROR_KEYS_MARKER, 00099 MIRROR_KEYS_VALUE 00100 } eEditKeyframes_Mirror; 00101 00102 /* ************************************************ */ 00103 /* Non-Destuctive Editing API (keyframes_edit.c) */ 00104 00105 /* --- Generic Properties for Keyframe Edit Tools ----- */ 00106 00107 typedef struct KeyframeEditData { 00108 /* generic properties/data access */ 00109 ListBase list; /* temp list for storing custom list of data to check */ 00110 struct Scene *scene; /* pointer to current scene - many tools need access to cfra/etc. */ 00111 void *data; /* pointer to custom data - usually 'Object' but also 'rectf', but could be other types too */ 00112 float f1, f2; /* storage of times/values as 'decimals' */ 00113 int i1, i2; /* storage of times/values/flags as 'whole' numbers */ 00114 00115 /* current iteration data */ 00116 struct FCurve *fcu; /* F-Curve that is being iterated over */ 00117 int curIndex; /* index of current keyframe being iterated over */ 00118 00119 /* flags */ 00120 short curflags; /* current flags for the keyframe we're reached in the iteration process */ 00121 short iterflags; /* settings for iteration process */ // XXX: unused... 00122 } KeyframeEditData; 00123 00124 /* ------- Function Pointer Typedefs ---------------- */ 00125 00126 /* callback function that refreshes the F-Curve after use */ 00127 typedef void (*FcuEditFunc)(struct FCurve *fcu); 00128 /* callback function that operates on the given BezTriple */ 00129 typedef short (*KeyframeEditFunc)(KeyframeEditData *ked, struct BezTriple *bezt); 00130 00131 /* ---------- Defines for 'OK' polls ----------------- */ 00132 00133 /* which verts of a keyframe is active (after polling) */ 00134 typedef enum eKeyframeVertOk { 00135 /* 'key' itself is ok */ 00136 KEYFRAME_OK_KEY = (1<<0), 00137 /* 'handle 1' is ok */ 00138 KEYFRAME_OK_H1 = (1<<1), 00139 /* 'handle 2' is ok */ 00140 KEYFRAME_OK_H2 = (1<<2), 00141 /* all flags */ 00142 KEYFRAME_OK_ALL = (KEYFRAME_OK_KEY|KEYFRAME_OK_H1|KEYFRAME_OK_H2) 00143 } eKeyframeVertOk; 00144 00145 /* Flags for use during iteration */ 00146 typedef enum eKeyframeIterFlags { 00147 /* consider handles in addition to key itself */ 00148 KEYFRAME_ITER_INCL_HANDLES = (1<<0), 00149 } eKeyframeIterFlags; 00150 00151 /* ------- Custom Data Type Defines ------------------ */ 00152 00153 /* Custom data for remapping one range to another in a fixed way */ 00154 typedef struct KeyframeEditCD_Remap { 00155 float oldMin, oldMax; /* old range */ 00156 float newMin, newMax; /* new range */ 00157 } KeyframeEditCD_Remap; 00158 00159 /* Paste options */ 00160 typedef enum eKeyPasteOffset { 00161 /* paste keys starting at current frame */ 00162 KEYFRAME_PASTE_OFFSET_CFRA_START, 00163 /* paste keys ending at current frame */ 00164 KEYFRAME_PASTE_OFFSET_CFRA_END, 00165 /* paste keys relative to the current frame when copying */ 00166 KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE, 00167 /* paste keys from original time */ 00168 KEYFRAME_PASTE_OFFSET_NONE 00169 } eKeyPasteOffset; 00170 00171 typedef enum eKeyMergeMode { 00172 /* overlay existing with new keys */ 00173 KEYFRAME_PASTE_MERGE_MIX, 00174 /* replace entire fcurve */ 00175 KEYFRAME_PASTE_MERGE_OVER, 00176 /* overwrite keys in pasted range */ 00177 KEYFRAME_PASTE_MERGE_OVER_RANGE, 00178 /* overwrite keys in pasted range (use all keyframe start & end for range) */ 00179 KEYFRAME_PASTE_MERGE_OVER_RANGE_ALL 00180 } eKeyMergeMode; 00181 00182 /* ---------------- Looping API --------------------- */ 00183 00184 /* functions for looping over keyframes */ 00185 /* function for working with F-Curve data only (i.e. when filters have been chosen to explicitly use this) */ 00186 short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, struct FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb); 00187 /* function for working with any type (i.e. one of the known types) of animation channel 00188 * - filterflag is bDopeSheet->flag (DOPESHEET_FILTERFLAG) 00189 */ 00190 short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, struct bAnimListElem *ale, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag); 00191 /* same as above, except bAnimListElem wrapper is not needed... 00192 * - keytype is eAnim_KeyType 00193 */ 00194 short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, void *data, int keytype, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb, int filterflag); 00195 00196 /* functions for making sure all keyframes are in good order */ 00197 void ANIM_editkeyframes_refresh(struct bAnimContext *ac); 00198 00199 /* ----------- BezTriple Callback Getters ---------- */ 00200 00201 /* accessories */ 00202 KeyframeEditFunc ANIM_editkeyframes_ok(short mode); 00203 00204 /* edit */ 00205 KeyframeEditFunc ANIM_editkeyframes_snap(short mode); 00206 KeyframeEditFunc ANIM_editkeyframes_mirror(short mode); 00207 KeyframeEditFunc ANIM_editkeyframes_select(short mode); 00208 KeyframeEditFunc ANIM_editkeyframes_handles(short mode); 00209 KeyframeEditFunc ANIM_editkeyframes_ipo(short mode); 00210 KeyframeEditFunc ANIM_editkeyframes_keytype(short mode); 00211 00212 /* -------- BezTriple Callbacks (Selection Map) ---------- */ 00213 00214 /* Get a callback to populate the selection settings map 00215 * requires: ked->custom = char[] of length fcurve->totvert 00216 */ 00217 KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode); 00218 00219 /* Change the selection status of the keyframe based on the map entry for this vert 00220 * requires: ked->custom = char[] of length fcurve->totvert 00221 */ 00222 short bezt_selmap_flush(KeyframeEditData *ked, struct BezTriple *bezt); 00223 00224 /* ----------- BezTriple Callback (Assorted Utilities) ---------- */ 00225 00226 /* used to calculate the the average location of all relevant BezTriples by summing their locations */ 00227 short bezt_calc_average(KeyframeEditData *ked, struct BezTriple *bezt); 00228 00229 /* used to extract a set of cfra-elems from the keyframes */ 00230 short bezt_to_cfraelem(KeyframeEditData *ked, struct BezTriple *bezt); 00231 00232 /* used to remap times from one range to another 00233 * requires: ked->custom = KeyframeEditCD_Remap 00234 */ 00235 void bezt_remap_times(KeyframeEditData *ked, struct BezTriple *bezt); 00236 00237 /* ************************************************ */ 00238 /* Destructive Editing API (keyframes_general.c) */ 00239 00240 void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc); 00241 void delete_fcurve_keys(struct FCurve *fcu); 00242 void clear_fcurve_keys(struct FCurve *fcu); 00243 void duplicate_fcurve_keys(struct FCurve *fcu); 00244 00245 void clean_fcurve(struct FCurve *fcu, float thresh); 00246 void smooth_fcurve(struct FCurve *fcu); 00247 void sample_fcurve(struct FCurve *fcu); 00248 00249 /* ----------- */ 00250 00251 void free_anim_copybuf(void); 00252 short copy_animedit_keys(struct bAnimContext *ac, ListBase *anim_data); 00253 short paste_animedit_keys(struct bAnimContext *ac, ListBase *anim_data, 00254 const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode); 00255 00256 /* ************************************************ */ 00257 00258 #endif /* ED_KEYFRAMES_EDIT_H */