Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_intern.h
| Context not available. | |||||
| #include "DNA_vec_types.h" | #include "DNA_vec_types.h" | ||||
| #include "ED_numinput.h" | |||||
| /* internal exports only */ | /* internal exports only */ | ||||
| struct bGPdata; | struct bGPdata; | ||||
| struct bGPDstroke; | struct bGPDstroke; | ||||
| struct bGPDspoint; | struct bGPDspoint; | ||||
| struct tGPspoint; | |||||
| struct GHash; | struct GHash; | ||||
| struct Brush; | |||||
| struct Scene; | |||||
| struct ARegion; | struct ARegion; | ||||
| struct View3D; | |||||
| struct View2D; | struct View2D; | ||||
| struct wmOperatorType; | struct wmOperatorType; | ||||
| Context not available. | |||||
| struct EnumPropertyItem; | struct EnumPropertyItem; | ||||
| /* ***************************************************** */ | |||||
| /* Modal Operator Geometry Preview | |||||
| * | |||||
| * Several modal operators (Fill, Interpolate, Primitive) | |||||
| * need to run some drawing code to display previews, or | |||||
| * to perform screen-space/image-based analysis routines. | |||||
| * The following structs + function prototypes are used | |||||
| * by these operators so that the operator code | |||||
| * (in gpencil_<opname>.c) can communicate with the drawing | |||||
| * code (in drawgpencil.c). | |||||
| * | |||||
| * NOTE: All this is within the gpencil module, so nothing needs | |||||
| * to be exported to other modules. | |||||
| */ | |||||
| /* Internal Operator-State Data ------------------------ */ | |||||
| /* Temporary draw data (no draw manager mode) */ | |||||
| typedef struct tGPDdraw { | |||||
| struct RegionView3D *rv3d; /* region to draw */ | |||||
| struct Object *ob; /* GP object */ | |||||
| struct bGPdata *gpd; /* current GP datablock */ | |||||
| struct bGPDlayer *gpl; /* layer */ | |||||
| struct bGPDframe *gpf; /* frame */ | |||||
| struct bGPDframe *t_gpf; /* temporal frame */ | |||||
| struct bGPDstroke *gps; /* stroke */ | |||||
| int disable_fill; /* disable fill */ | |||||
| int offsx; /* windows offset x */ | |||||
| int offsy; /* windows offset y */ | |||||
| int winx; /* windows width */ | |||||
| int winy; /* windows height */ | |||||
| int dflag; /* flags datablock */ | |||||
| short lthick; /* layer thickness */ | |||||
| float opacity; /* opacity */ | |||||
| float tintcolor[4]; /* tint color */ | |||||
| bool onion; /* onion flag */ | |||||
| bool custonion; /* use custom onion colors */ | |||||
| float diff_mat[4][4]; /* matrix */ | |||||
| } tGPDdraw; | |||||
| /* Temporary interpolate operation data */ | |||||
| typedef struct tGPDinterpolate_layer { | |||||
| struct tGPDinterpolate_layer *next, *prev; | |||||
| struct bGPDlayer *gpl; /* layer */ | |||||
| struct bGPDframe *prevFrame; /* frame before current frame (interpolate-from) */ | |||||
| struct bGPDframe *nextFrame; /* frame after current frame (interpolate-to) */ | |||||
| struct bGPDframe *interFrame; /* interpolated frame */ | |||||
| float factor; /* interpolate factor */ | |||||
| } tGPDinterpolate_layer; | |||||
| typedef struct tGPDinterpolate { | |||||
| struct Scene *scene; /* current scene from context */ | |||||
| struct ScrArea *sa; /* area where painting originated */ | |||||
| struct ARegion *ar; /* region where painting originated */ | |||||
| struct bGPdata *gpd; /* current GP datablock */ | |||||
| struct Palette *palette; /* current palette */ | |||||
| int cframe; /* current frame number */ | |||||
| ListBase ilayers; /* (tGPDinterpolate_layer) layers to be interpolated */ | |||||
| float shift; /* value for determining the displacement influence */ | |||||
| float init_factor; /* initial interpolation factor for active layer */ | |||||
| float low_limit; /* shift low limit (-100%) */ | |||||
| float high_limit; /* shift upper limit (200%) */ | |||||
| int flag; /* flag from toolsettings */ | |||||
| NumInput num; /* numeric input */ | |||||
| void *draw_handle_3d; /* handle for drawing strokes while operator is running 3d stuff */ | |||||
| void *draw_handle_screen; /* handle for drawing strokes while operator is running screen stuff */ | |||||
| } tGPDinterpolate; | |||||
| /* Temporary primitive operation data */ | |||||
| typedef struct tGPDprimitive { | |||||
| struct Depsgraph *graph; | |||||
| struct wmWindow *win; /* window where painting originated */ | |||||
| struct Scene *scene; /* current scene from context */ | |||||
| struct Object *ob; /* current active gp object */ | |||||
| struct ScrArea *sa; /* area where painting originated */ | |||||
| struct RegionView3D *rv3d; /* region where painting originated */ | |||||
| struct View3D *v3d; /* view3d where painting originated */ | |||||
| struct ARegion *ar; /* region where painting originated */ | |||||
| struct bGPdata *gpd; /* current GP datablock */ | |||||
| struct Palette *palette; /* current palette */ | |||||
| struct PaletteColor *palcolor; /* current palette color */ | |||||
| struct Brush *brush; /* current brush */ | |||||
| int cframe; /* current frame number */ | |||||
| struct bGPDlayer *gpl; /* layer */ | |||||
| struct bGPDframe *gpf; /* frame */ | |||||
| int type; /* type of primitive */ | |||||
| int tot_edges; /* number of polygon edges */ | |||||
| int top[2]; /* first box corner */ | |||||
| int bottom[2]; /* last box corner */ | |||||
| int flag; /* flag to determine operations in progress */ | |||||
| int lock_axis; /* lock to viewport axis */ | |||||
| NumInput num; /* numeric input */ | |||||
| void *draw_handle_3d; /* handle for drawing strokes while operator is running 3d stuff */ | |||||
| } tGPDprimitive; | |||||
| /* Modal Operator Drawing Callbacks ------------------------ */ | |||||
| void ED_gp_draw_interpolation(const struct bContext *C, struct tGPDinterpolate *tgpi, const int type); | |||||
| void ED_gp_draw_primitives(const struct bContext *C, struct tGPDprimitive *tgpi, const int type); | |||||
| void ED_gp_draw_fill(struct tGPDdraw *tgpw); | |||||
| /* ***************************************************** */ | /* ***************************************************** */ | ||||
| /* Internal API */ | /* Internal API */ | ||||
| Context not available. | |||||
| float *r_x, float *r_y); | float *r_x, float *r_y); | ||||
| void gp_point_to_parent_space(bGPDspoint *pt, float diff_mat[4][4], bGPDspoint *r_pt); | void gp_point_to_parent_space(bGPDspoint *pt, float diff_mat[4][4], bGPDspoint *r_pt); | ||||
| /** | |||||
| void gp_apply_parent(bGPDlayer *gpl, bGPDstroke *gps); | * Change points position relative to parent object | ||||
| */ | |||||
| void gp_apply_parent_point(bGPDlayer *gpl, bGPDspoint *pt); | void gp_apply_parent(struct Object *obact, bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps); | ||||
| /** | |||||
| * Change point position relative to parent object | |||||
| */ | |||||
| void gp_apply_parent_point(struct Object *obact, bGPdata *gpd, bGPDlayer *gpl, bGPDspoint *pt); | |||||
| bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, struct Scene *scene, const float screen_co[2], float r_out[3]); | bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, struct Scene *scene, const float screen_co[2], float r_out[3]); | ||||
| /* helper to convert 2d to 3d */ | |||||
| void gp_stroke_convertcoords_tpoint(struct Scene *scene, struct ARegion *ar, | |||||
| struct View3D *v3d, struct Object *ob, | |||||
| bGPDlayer *gpl, const struct tGPspoint *point2D, | |||||
| float *depth, float out[3]); | |||||
| /* Poll Callbacks ------------------------------------ */ | /* Poll Callbacks ------------------------------------ */ | ||||
| /* gpencil_utils.c */ | /* gpencil_utils.c */ | ||||
| int gp_add_poll(struct bContext *C); | int gp_add_poll(struct bContext *C); | ||||
| int gp_active_layer_poll(struct bContext *C); | int gp_active_layer_poll(struct bContext *C); | ||||
| int gp_active_brush_poll(struct bContext *C); | int gp_active_brush_poll(struct bContext *C); | ||||
| int gp_active_palette_poll(struct bContext *C); | |||||
| int gp_active_palettecolor_poll(struct bContext *C); | |||||
| int gp_brush_crt_presets_poll(bContext *C); | int gp_brush_crt_presets_poll(bContext *C); | ||||
| /* Copy/Paste Buffer --------------------------------- */ | /* Copy/Paste Buffer --------------------------------- */ | ||||
| Context not available. | |||||
| extern ListBase gp_strokes_copypastebuf; | extern ListBase gp_strokes_copypastebuf; | ||||
| /* Build a map for converting between old colornames and destination-color-refs */ | /* Build a map for converting between old colornames and destination-color-refs */ | ||||
| struct GHash *gp_copybuf_validate_colormap(bGPdata *gpd); | struct GHash *gp_copybuf_validate_colormap(struct bContext *C); | ||||
| /* Stroke Editing ------------------------------------ */ | /* Stroke Editing ------------------------------------ */ | ||||
| void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke *next_stroke, int tag_flags); | void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke *next_stroke, | ||||
| int tag_flags, bool select); | |||||
| int gp_delete_selected_point_wrap(bContext *C); | |||||
| bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure); | bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure); | ||||
| bool gp_smooth_stroke_strength(bGPDstroke *gps, int i, float inf); | bool gp_smooth_stroke_strength(bGPDstroke *gps, int i, float inf); | ||||
| bool gp_smooth_stroke_thickness(bGPDstroke *gps, int i, float inf); | bool gp_smooth_stroke_thickness(bGPDstroke *gps, int i, float inf); | ||||
| void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints); | void gp_subdivide_stroke(bGPDstroke *gps, const int subdivide); | ||||
| void gp_randomize_stroke(bGPDstroke *gps, bGPDbrush *brush); | void gp_randomize_stroke(bGPDstroke *gps, Brush *brush); | ||||
| /* Layers Enums -------------------------------------- */ | /* Layers Enums -------------------------------------- */ | ||||
| Context not available. | |||||
| struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, | struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, | ||||
| bool *r_free); | bool *r_free); | ||||
| /* Enums of GP Brushes */ | |||||
| const EnumPropertyItem *ED_gpencil_brushes_enum_itemf( | |||||
| bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), | |||||
| bool *r_free); | |||||
| /* Enums of GP palettes */ | |||||
| const EnumPropertyItem *ED_gpencil_palettes_enum_itemf( | |||||
| bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), | |||||
| bool *r_free); | |||||
| /* ***************************************************** */ | /* ***************************************************** */ | ||||
| /* Operator Defines */ | /* Operator Defines */ | ||||
| /* drawing ---------- */ | /* drawing ---------- */ | ||||
| void GPENCIL_OT_draw(struct wmOperatorType *ot); | void GPENCIL_OT_draw(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_fill(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_colorpick(struct wmOperatorType *ot); | |||||
| /* Paint Modes for operator */ | /* Paint Modes for operator */ | ||||
| typedef enum eGPencil_PaintModes { | typedef enum eGPencil_PaintModes { | ||||
| Context not available. | |||||
| /* stroke editing ----- */ | /* stroke editing ----- */ | ||||
| void GPENCIL_OT_editmode_toggle(struct wmOperatorType *ot); | void GPENCIL_OT_editmode_toggle(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_paintmode_toggle(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_sculptmode_toggle(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_weightmode_toggle(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_selection_opacity_toggle(struct wmOperatorType *ot); | void GPENCIL_OT_selection_opacity_toggle(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_multiedit_toggle(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_select(struct wmOperatorType *ot); | void GPENCIL_OT_select(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_select_all(struct wmOperatorType *ot); | void GPENCIL_OT_select_all(struct wmOperatorType *ot); | ||||
| Context not available. | |||||
| void GPENCIL_OT_select_less(struct wmOperatorType *ot); | void GPENCIL_OT_select_less(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_select_first(struct wmOperatorType *ot); | void GPENCIL_OT_select_first(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_select_last(struct wmOperatorType *ot); | void GPENCIL_OT_select_last(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_select_alternate(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_duplicate(struct wmOperatorType *ot); | void GPENCIL_OT_duplicate(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_delete(struct wmOperatorType *ot); | void GPENCIL_OT_delete(struct wmOperatorType *ot); | ||||
| Context not available. | |||||
| void GPENCIL_OT_active_frame_delete(struct wmOperatorType *ot); | void GPENCIL_OT_active_frame_delete(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_active_frames_delete_all(struct wmOperatorType *ot); | void GPENCIL_OT_active_frames_delete_all(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_frame_duplicate(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_frame_clean_fill(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_convert(struct wmOperatorType *ot); | void GPENCIL_OT_convert(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_convert_scene_to_object(struct wmOperatorType *ot); | |||||
| enum { | enum { | ||||
| GP_STROKE_JOIN = -1, | GP_STROKE_JOIN = -1, | ||||
| GP_STROKE_JOINCOPY = 1 | GP_STROKE_JOINCOPY = 1 | ||||
| }; | }; | ||||
| /* move strokes to new palette */ | |||||
| enum { | |||||
| GP_MOVE_PALETTE_SELECT = -1, | |||||
| GP_MOVE_PALETTE_ALL = 1, | |||||
| GP_MOVE_PALETTE_BEFORE = 2, | |||||
| GP_MOVE_PALETTE_AFTER = 3, | |||||
| GP_MOVE_PALETTE_CURRENT = 4 | |||||
| }; | |||||
| enum { | |||||
| GP_STROKE_BOX = -1, | |||||
| GP_STROKE_CIRCLE = 1 | |||||
| }; | |||||
| void GPENCIL_OT_stroke_arrange(struct wmOperatorType *ot); | void GPENCIL_OT_stroke_arrange(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_stroke_change_palette(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_stroke_change_color(struct wmOperatorType *ot); | void GPENCIL_OT_stroke_change_color(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_stroke_lock_color(struct wmOperatorType *ot); | void GPENCIL_OT_stroke_lock_color(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_stroke_apply_thickness(struct wmOperatorType *ot); | void GPENCIL_OT_stroke_apply_thickness(struct wmOperatorType *ot); | ||||
| Context not available. | |||||
| void GPENCIL_OT_stroke_join(struct wmOperatorType *ot); | void GPENCIL_OT_stroke_join(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_stroke_flip(struct wmOperatorType *ot); | void GPENCIL_OT_stroke_flip(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_stroke_subdivide(struct wmOperatorType *ot); | void GPENCIL_OT_stroke_subdivide(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_stroke_simplify(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_stroke_simplify_fixed(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_stroke_separate(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_stroke_split(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_brush_add(struct wmOperatorType *ot); | void GPENCIL_OT_brush_add(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_brush_remove(struct wmOperatorType *ot); | void GPENCIL_OT_brush_remove(struct wmOperatorType *ot); | ||||
| Context not available. | |||||
| void GPENCIL_OT_brush_copy(struct wmOperatorType *ot); | void GPENCIL_OT_brush_copy(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_brush_select(struct wmOperatorType *ot); | void GPENCIL_OT_brush_select(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_palette_add(struct wmOperatorType *ot); | void GPENCIL_OT_sculpt_select(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_palette_remove(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palette_change(struct wmOperatorType *ot); | void GPENCIL_OT_palette_slot_add(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_palette_lock_layer(struct wmOperatorType *ot); | void GPENCIL_OT_palette_slot_remove(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_palettecolor_add(struct wmOperatorType *ot); | void GPENCIL_OT_convert_old_palettes(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_palettecolor_remove(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palettecolor_isolate(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palettecolor_hide(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palettecolor_reveal(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palettecolor_lock_all(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palettecolor_unlock_all(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palettecolor_move(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palettecolor_select(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_palettecolor_copy(struct wmOperatorType *ot); | |||||
| /* undo stack ---------- */ | /* undo stack ---------- */ | ||||
| Context not available. | |||||
| void GPENCIL_OT_interpolate_sequence(struct wmOperatorType *ot); | void GPENCIL_OT_interpolate_sequence(struct wmOperatorType *ot); | ||||
| void GPENCIL_OT_interpolate_reverse(struct wmOperatorType *ot); | void GPENCIL_OT_interpolate_reverse(struct wmOperatorType *ot); | ||||
| /* primitives ---------- */ | |||||
| void GPENCIL_OT_primitive(struct wmOperatorType *ot); | |||||
| /* vertex groups ------------ */ | |||||
| void GPENCIL_OT_vertex_group_assign(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_vertex_group_remove_from(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_vertex_group_select(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_vertex_group_deselect(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_vertex_group_invert(struct wmOperatorType *ot); | |||||
| void GPENCIL_OT_vertex_group_smooth(struct wmOperatorType *ot); | |||||
| /* ****************************************************** */ | /* ****************************************************** */ | ||||
| /* FILTERED ACTION DATA - TYPES ---> XXX DEPRECEATED OLD ANIM SYSTEM CODE! */ | /* FILTERED ACTION DATA - TYPES ---> XXX DEPRECEATED OLD ANIM SYSTEM CODE! */ | ||||
| Context not available. | |||||
| */ | */ | ||||
| #define GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) \ | #define GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) \ | ||||
| { \ | { \ | ||||
| Object *obact_ = CTX_data_active_object(C); \ | |||||
| bGPdata *gpd_ = CTX_data_gpencil_data(C); \ | |||||
| bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_); \ | |||||
| CTX_DATA_BEGIN(C, bGPDlayer*, gpl, editable_gpencil_layers) \ | CTX_DATA_BEGIN(C, bGPDlayer*, gpl, editable_gpencil_layers) \ | ||||
| { \ | { \ | ||||
| if (gpl->actframe == NULL) \ | bGPDframe *init_gpf = gpl->actframe; \ | ||||
| continue; \ | if (is_multiedit) { \ | ||||
| /* calculate difference matrix if parent object */ \ | init_gpf = gpl->frames.first; \ | ||||
| float diff_mat[4][4]; \ | } \ | ||||
| ED_gpencil_parent_location(gpl, diff_mat); \ | for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { \ | ||||
| /* loop over strokes */ \ | if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { \ | ||||
| for (bGPDstroke *gps = gpl->actframe->strokes.first; gps; gps = gps->next) { \ | /* calculate difference matrix */ \ | ||||
| /* skip strokes that are invalid for current view */ \ | float diff_mat[4][4]; \ | ||||
| if (ED_gpencil_stroke_can_use(C, gps) == false) \ | ED_gpencil_parent_location(obact_, gpd_, gpl, diff_mat); \ | ||||
| continue; \ | /* loop over strokes */ \ | ||||
| /* check if the color is editable */ \ | for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { \ | ||||
| if (ED_gpencil_stroke_color_use(gpl, gps) == false) \ | /* skip strokes that are invalid for current view */ \ | ||||
| continue; \ | if (ED_gpencil_stroke_can_use(C, gps) == false) \ | ||||
| /* ... Do Stuff With Strokes ... */ | continue; \ | ||||
| /* check if the color is editable */ \ | |||||
| if (ED_gpencil_stroke_color_use(gpl, gps) == false) \ | |||||
| continue; \ | |||||
| /* ... Do Stuff With Strokes ... */ | |||||
| #define GP_EDITABLE_STROKES_END \ | #define GP_EDITABLE_STROKES_END \ | ||||
| } \ | |||||
| } \ | |||||
| if (!is_multiedit) { \ | |||||
| break; \ | |||||
| } \ | |||||
| } \ | } \ | ||||
| } \ | } \ | ||||
| CTX_DATA_END; \ | CTX_DATA_END; \ | ||||
| Context not available. | |||||