|
Blender
V2.59
|
#include <stdio.h>#include <stddef.h>#include <stdlib.h>#include <string.h>#include <math.h>#include "MEM_guardedalloc.h"#include "BLI_blenlib.h"#include "BLI_math.h"#include "BLI_utildefines.h"#include "BKE_gpencil.h"#include "BKE_context.h"#include "BKE_global.h"#include "BKE_report.h"#include "DNA_object_types.h"#include "DNA_scene_types.h"#include "DNA_gpencil_types.h"#include "DNA_windowmanager_types.h"#include "UI_view2d.h"#include "ED_gpencil.h"#include "ED_screen.h"#include "ED_view3d.h"#include "RNA_access.h"#include "RNA_define.h"#include "WM_api.h"#include "WM_types.h"#include "gpencil_intern.h"Go to the source code of this file.
Definition in file gpencil_paint.c.
| #define GP_SIMPLIFY_AVPOINT | ( | offs, | |
| sfac | |||
| ) |
{ \
co[0] += (float)(old_points[offs].x * sfac); \
co[1] += (float)(old_points[offs].y * sfac); \
pressure += old_points[offs].pressure * sfac; \
}
Referenced by gp_stroke_simplify().
| #define GP_STROKE_BUFFER_MAX 5000 |
Definition at line 134 of file gpencil_paint.c.
Referenced by gp_session_validatebuffer(), and gp_stroke_addpoint().
| #define MIN_EUCLIDEAN_PX (U.gp_euclideandist) |
Definition at line 140 of file gpencil_paint.c.
Referenced by gp_stroke_filtermval().
| #define MIN_MANHATTEN_PX (U.gp_manhattendist) |
Definition at line 138 of file gpencil_paint.c.
Referenced by gp_stroke_filtermval().
| typedef struct tGpSmoothCo tGpSmoothCo |
| anonymous enum |
Definition at line 111 of file gpencil_paint.c.
| anonymous enum |
Definition at line 119 of file gpencil_paint.c.
| anonymous enum |
Definition at line 127 of file gpencil_paint.c.
| static void gp_get_3d_reference | ( | tGPsdata * | p, |
| float * | vec | ||
| ) | [static] |
Definition at line 186 of file gpencil_paint.c.
References copy_v3_v3(), PointerRNA::data, ListBase::first, give_cursor(), Object::loc, tGPsdata::ownerPtr, RNA_Object, tGPsdata::sa, tGPsdata::scene, ScrArea::spacedata, sub_v3_v3v3(), and PointerRNA::type.
Referenced by gp_paint_initstroke(), and gp_stroke_convertcoords().
| static void gp_paint_cleanup | ( | tGPsdata * | p | ) | [static] |
Definition at line 1249 of file gpencil_paint.c.
References bGPDframe::flag, GP_FRAME_PAINT, gp_paint_strokeend(), and tGPsdata::gpf.
Referenced by gpencil_draw_exit(), and gpencil_draw_modal().
| static void gp_paint_initstroke | ( | tGPsdata * | p, |
| short | paintmode | ||
| ) | [static] |
Definition at line 1093 of file gpencil_paint.c.
References tGPsdata::ar, RenderData::cfra, ED_view3d_calc_camera_border(), ELEM, Global::f, ListBase::first, bGPDframe::flag, bGPDlayer::flag, bGPdata::flag, tGPsdata::flags, G, G_DEBUG, GP_DATA_VIEWALIGN, GP_FRAME_PAINT, gp_get_3d_reference(), GP_LAYER_LOCKED, GP_PAINTFLAG_FIRSTRUN, GP_PAINTMODE_ERASER, GP_STATUS_ERROR, GP_STROKE_2DIMAGE, GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, GP_STROKE_ERASER, tGPsdata::gpd, gpencil_layer_addnew(), gpencil_layer_getactive(), gpencil_layer_getframe(), tGPsdata::gpf, tGPsdata::gpl, SpaceImage::image, initgrabz(), SpaceSeq::mainb, NULL, tGPsdata::paintmode, RegionView3D::persp, Scene::r, ARegion::regiondata, RV3D_CAMOB, tGPsdata::sa, bGPdata::sbuffer_sflag, tGPsdata::scene, SEQ_DRAW_IMG_IMBUF, SEQ_ZOOM_FAC, RenderData::size, SPACE_IMAGE, SPACE_NODE, SPACE_SEQ, SPACE_VIEW3D, ScrArea::spacedata, ScrArea::spacetype, tGPsdata::status, tGPsdata::subrect, tGPsdata::subrect_data, ScrArea::winx, ScrArea::winy, RenderData::xasp, SpaceSeq::xof, RenderData::xsch, RenderData::yasp, SpaceSeq::yof, RenderData::ysch, and SpaceSeq::zoom.
Referenced by gpencil_draw_exec(), gpencil_draw_init(), and gpencil_draw_modal().
| static void gp_paint_strokeend | ( | tGPsdata * | p | ) | [static] |
Definition at line 1219 of file gpencil_paint.c.
References tGPsdata::ar, ED_view3d_autodist_init(), ListBase::first, bGPdata::flag, GP_DATA_DEPTH_STROKE, gp_session_validatebuffer(), GP_STROKE_ERASER, gp_stroke_newfrombuffer(), gp_stroke_simplify(), gp_stroke_smooth(), tGPsdata::gpd, gpencil_project_check(), tGPsdata::sa, bGPdata::sbuffer_sflag, tGPsdata::scene, ScrArea::spacedata, view3d_region_operator_needs_opengl(), and tGPsdata::win.
Referenced by gp_paint_cleanup(), gpencil_draw_apply(), and gpencil_draw_exec().
| static void gp_session_cleanup | ( | tGPsdata * | p | ) | [static] |
Definition at line 1073 of file gpencil_paint.c.
References tGPsdata::gpd, if(), MEM_freeN(), NULL, p, bGPdata::sbuffer, bGPdata::sbuffer_sflag, and bGPdata::sbuffer_size.
Referenced by gpencil_draw_exit().
Definition at line 909 of file gpencil_paint.c.
References tGPsdata::ar, CTX_data_scene(), CTX_wm_area(), CTX_wm_region(), CTX_wm_window(), Global::f, ListBase::first, SpaceSeq::flag, G, G_DEBUG, G_GREASEPENCIL, gp_session_validatebuffer(), GP_STATUS_ERROR, tGPsdata::gpd, gpencil_data_addnew(), gpencil_data_get_pointers(), SpaceSeq::mainb, MEM_callocN(), NULL, tGPsdata::ownerPtr, p, ARegion::regiondata, tGPsdata::sa, tGPsdata::scene, SEQ_DRAW_GPENCIL, SEQ_DRAW_SEQUENCE, SI_DISPGP, SNODE_DISPGP, SPACE_IMAGE, SPACE_NODE, SPACE_SEQ, SPACE_VIEW3D, ScrArea::spacedata, ScrArea::spacetype, tGPsdata::status, tGPsdata::v2d, ARegion::v2d, V3D_DISPGP, and tGPsdata::win.
Referenced by gpencil_draw_init().
| static void gp_session_validatebuffer | ( | tGPsdata * | p | ) | [static] |
Definition at line 891 of file gpencil_paint.c.
References GP_STROKE_BUFFER_MAX, tGPsdata::gpd, MEM_callocN(), bGPdata::sbuffer, bGPdata::sbuffer_sflag, and bGPdata::sbuffer_size.
Referenced by gp_paint_strokeend(), gp_session_initpaint(), and gp_stroke_simplify().
| static short gp_stroke_addpoint | ( | tGPsdata * | p, |
| const int | mval[2], | ||
| float | pressure | ||
| ) | [static] |
Definition at line 316 of file gpencil_paint.c.
References GP_PAINTMODE_DRAW, GP_PAINTMODE_DRAW_STRAIGHT, GP_STROKE_BUFFER_MAX, GP_STROKEADD_FULL, GP_STROKEADD_INVALID, GP_STROKEADD_NORMAL, GP_STROKEADD_OVERFLOW, tGPsdata::gpd, tGPsdata::paintmode, tGPspoint::pressure, bGPdata::sbuffer, bGPdata::sbuffer_size, tGPspoint::x, and tGPspoint::y.
Referenced by gp_stroke_simplify(), and gpencil_draw_apply().
| static void gp_stroke_convertcoords | ( | tGPsdata * | p, |
| const int | mval[2], | ||
| float | out[3], | ||
| float * | depth | ||
| ) | [static] |
Definition at line 242 of file gpencil_paint.c.
References tGPsdata::ar, ED_view3d_autodist_simple(), ED_view3d_win_to_delta(), gp_get_3d_reference(), GP_STROKE_2DIMAGE, GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, tGPsdata::gpd, gpencil_project_check(), NULL, project_int_noclip(), bGPdata::sbuffer_sflag, sub_v3_v3v3(), tGPsdata::subrect, UI_view2d_region_to_view(), tGPsdata::v2d, VECSUB2D, ARegion::winx, ARegion::winy, rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.
Referenced by gp_stroke_newfrombuffer().
| static void gp_stroke_doeraser | ( | tGPsdata * | p | ) | [static] |
Definition at line 868 of file gpencil_paint.c.
References ListBase::first, gp_stroke_eraser_dostroke(), tGPsdata::gpf, tGPsdata::mval, tGPsdata::mvalo, bGPDstroke::next, tGPsdata::radius, bGPDframe::strokes, rcti::xmax, rcti::xmin, rcti::ymax, and rcti::ymin.
Referenced by gpencil_draw_apply().
| static void gp_stroke_eraser_dostroke | ( | tGPsdata * | p, |
| int | mval[], | ||
| int | mvalo[], | ||
| short | rad, | ||
| rcti * | rect, | ||
| bGPDframe * | gpf, | ||
| bGPDstroke * | gps | ||
| ) | [static] |
Definition at line 735 of file gpencil_paint.c.
References tGPsdata::ar, BLI_freelinkN(), BLI_in_rcti(), bGPDstroke::flag, GP_STROKE_2DIMAGE, GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, gp_stroke_eraser_splitdel(), gp_stroke_eraser_strokeinside(), i, MEM_freeN(), NULL, bGPDstroke::points, project_int(), bGPDframe::strokes, tGPsdata::subrect, bGPDstroke::totpoints, UI_view2d_view_to_region(), tGPsdata::v2d, ARegion::winx, ARegion::winy, bGPDspoint::x, rctf::xmax, rctf::xmin, bGPDspoint::y, rctf::ymax, and rctf::ymin.
Referenced by gp_stroke_doeraser().
| static short gp_stroke_eraser_splitdel | ( | bGPDframe * | gpf, |
| bGPDstroke * | gps, | ||
| int | i | ||
| ) | [static] |
Definition at line 655 of file gpencil_paint.c.
References BLI_freelinkN(), BLI_insertlinkafter(), i, MEM_callocN(), MEM_dupallocN(), MEM_freeN(), bGPDstroke::next, NULL, bGPDstroke::points, bGPDstroke::prev, bGPDframe::strokes, and bGPDstroke::totpoints.
Referenced by gp_stroke_eraser_dostroke().
| static short gp_stroke_eraser_strokeinside | ( | int | mval[], |
| int | UNUSEDmvalo[], | ||
| short | rad, | ||
| short | x0, | ||
| short | y0, | ||
| short | x1, | ||
| short | y1 | ||
| ) | [static] |
Definition at line 723 of file gpencil_paint.c.
References edge_inside_circle().
Referenced by gp_stroke_eraser_dostroke().
| static short gp_stroke_filtermval | ( | tGPsdata * | p, |
| const int | mval[2], | ||
| int | pmval[2] | ||
| ) | [static] |
Definition at line 213 of file gpencil_paint.c.
References TNT::abs(), tGPsdata::gpd, MIN_EUCLIDEAN_PX, MIN_MANHATTEN_PX, and bGPdata::sbuffer_size.
Referenced by gpencil_draw_apply().
| static void gp_stroke_newfrombuffer | ( | tGPsdata * | p | ) | [static] |
Definition at line 507 of file gpencil_paint.c.
References tGPsdata::ar, BLI_addtail(), ED_view3d_autodist_depth(), ED_view3d_autodist_depth_seg(), Global::f, FALSE, bGPDstroke::flag, bGPdata::flag, FLT_MAX, G, G_DEBUG, GP_DATA_DEPTH_STROKE, GP_DATA_DEPTH_STROKE_ENDPOINTS, GP_PAINTMODE_DRAW_STRAIGHT, gp_stroke_convertcoords(), tGPsdata::gpd, gpencil_project_check(), tGPsdata::gpf, tGPsdata::gpl, i, if(), interp_sparse_array(), MEM_callocN(), MEM_freeN(), MEM_mallocN(), NULL, tGPsdata::paintmode, bGPDstroke::points, bGPDspoint::pressure, tGPspoint::pressure, bGPdata::sbuffer, bGPdata::sbuffer_sflag, bGPdata::sbuffer_size, bGPDframe::strokes, bGPDstroke::thickness, bGPDlayer::thickness, totelem, bGPDstroke::totpoints, TRUE, VECCOPY2D, bGPDspoint::x, tGPspoint::x, and tGPspoint::y.
Referenced by gp_paint_strokeend().
| static void gp_stroke_simplify | ( | tGPsdata * | p | ) | [static] |
Definition at line 438 of file gpencil_paint.c.
References co, GP_PAINT_DOSIMPLIFY, GP_PAINTMODE_DRAW_STRAIGHT, gp_session_validatebuffer(), GP_SIMPLIFY_AVPOINT, gp_stroke_addpoint(), tGPsdata::gpd, i, if(), MEM_freeN(), NULL, tGPsdata::paintmode, bGPdata::sbuffer, bGPdata::sbuffer_sflag, and bGPdata::sbuffer_size.
Referenced by gp_paint_strokeend().
| static void gp_stroke_smooth | ( | tGPsdata * | p | ) | [static] |
Definition at line 393 of file gpencil_paint.c.
References GP_PAINT_DOSMOOTH, GP_PAINTMODE_DRAW_STRAIGHT, tGPsdata::gpd, i, MEM_callocN(), MEM_freeN(), NULL, tGPsdata::paintmode, bGPdata::sbuffer, bGPdata::sbuffer_size, tGPspoint::x, tGpSmoothCo::x, tGPspoint::y, and tGpSmoothCo::y.
Referenced by gp_paint_strokeend().
Definition at line 1603 of file gpencil_paint.c.
References bScreen::areabase, CTX_wm_screen(), ListBase::first, and ScrArea::next.
Referenced by gpencil_draw_modal().
| static void gpencil_draw_apply | ( | wmOperator * | op, |
| tGPsdata * | p | ||
| ) | [static] |
Definition at line 1370 of file gpencil_paint.c.
References BKE_report(), Global::f, G, G_DEBUG, gp_paint_strokeend(), GP_PAINTMODE_ERASER, GP_STATUS_ERROR, gp_stroke_addpoint(), gp_stroke_doeraser(), gp_stroke_filtermval(), GP_STROKEADD_FULL, GP_STROKEADD_INVALID, GP_STROKEADD_OVERFLOW, tGPsdata::mval, tGPsdata::mvalo, tGPsdata::opressure, tGPsdata::paintmode, tGPsdata::pressure, wmOperator::reports, RPT_ERROR, and tGPsdata::status.
Referenced by gpencil_draw_apply_event(), and gpencil_draw_exec().
| static void gpencil_draw_apply_event | ( | wmOperator * | op, |
| wmEvent * | event | ||
| ) | [static] |
Definition at line 1414 of file gpencil_paint.c.
References wmTabletData::Active, tGPsdata::ar, wmEvent::custom, wmOperator::customdata, ED_region_tag_redraw(), EVT_DATA_TABLET, EVT_TABLET_NONE, tGPsdata::flags, GP_PAINTFLAG_FIRSTRUN, gpencil_draw_apply(), tGPsdata::mval, tGPsdata::mvalo, tGPsdata::opressure, p, tGPsdata::pressure, wmTabletData::Pressure, wmOperator::ptr, RNA_boolean_set(), RNA_collection_add(), RNA_float_set(), and RNA_float_set_array().
Referenced by gpencil_draw_invoke(), and gpencil_draw_modal().
| static int gpencil_draw_cancel | ( | bContext * | C, |
| wmOperator * | op | ||
| ) | [static] |
Definition at line 1290 of file gpencil_paint.c.
References gpencil_draw_exit(), and OPERATOR_CANCELLED.
Referenced by GPENCIL_OT_draw().
| static int gpencil_draw_exec | ( | bContext * | C, |
| wmOperator * | op | ||
| ) | [static] |
Definition at line 1473 of file gpencil_paint.c.
References wmOperator::customdata, tGPsdata::flags, gp_paint_initstroke(), gp_paint_strokeend(), GP_PAINTFLAG_FIRSTRUN, gpencil_draw_apply(), gpencil_draw_exit(), gpencil_draw_init(), MEM_freeN(), tGPsdata::mval, tGPsdata::mvalo, NA_EDITED, NC_SCREEN, ND_GPENCIL, NULL, OPERATOR_CANCELLED, OPERATOR_FINISHED, tGPsdata::opressure, p, tGPsdata::paintmode, tGPsdata::pressure, wmOperator::ptr, RNA_BEGIN, RNA_boolean_get(), RNA_END, RNA_float_get(), RNA_float_get_array(), and WM_event_add_notifier().
Referenced by GPENCIL_OT_draw().
| static void gpencil_draw_exit | ( | bContext * | C, |
| wmOperator * | op | ||
| ) | [static] |
Definition at line 1261 of file gpencil_paint.c.
References CTX_wm_window(), wmOperator::customdata, Global::f, G, G_GREASEPENCIL, gp_paint_cleanup(), GP_PAINTMODE_ERASER, gp_session_cleanup(), MEM_freeN(), NULL, p, tGPsdata::paintmode, and WM_cursor_restore().
Referenced by gpencil_draw_cancel(), gpencil_draw_exec(), gpencil_draw_init(), and gpencil_draw_modal().
| static int gpencil_draw_init | ( | bContext * | C, |
| wmOperator * | op | ||
| ) | [static] |
Definition at line 1300 of file gpencil_paint.c.
References wmOperator::customdata, gp_paint_initstroke(), gp_session_initpaint(), GP_STATUS_ERROR, gpencil_draw_exit(), NULL, p, wmOperator::ptr, tGPsdata::radius, RNA_enum_get(), and tGPsdata::status.
Referenced by gpencil_draw_exec(), and gpencil_draw_invoke().
| static int gpencil_draw_invoke | ( | bContext * | C, |
| wmOperator * | op, | ||
| wmEvent * | event | ||
| ) | [static] |
Definition at line 1545 of file gpencil_paint.c.
References BC_CROSSCURSOR, BC_PAINTBRUSHCURSOR, CTX_wm_window(), wmOperator::customdata, Global::f, G, G_DEBUG, GP_PAINTMODE_ERASER, GP_STATUS_PAINTING, gpencil_draw_apply_event(), gpencil_draw_init(), MEM_freeN(), NULL, OPERATOR_CANCELLED, OPERATOR_RUNNING_MODAL, p, tGPsdata::paintmode, tGPsdata::status, wmEvent::type, WM_cursor_modal(), and WM_event_add_modal_handler().
Referenced by GPENCIL_OT_draw().
| static int gpencil_draw_modal | ( | bContext * | C, |
| wmOperator * | op, | ||
| wmEvent * | event | ||
| ) | [static] |
Definition at line 1615 of file gpencil_paint.c.
References tGPsdata::ar, BLI_findindex(), wmEvent::ctrl, CTX_wm_area(), wmOperator::customdata, ED_region_tag_redraw(), ELEM, ELEM4, ESCKEY, tGPsdata::flags, bGPDlayer::frames, gp_paint_cleanup(), gp_paint_initstroke(), GP_PAINTFLAG_FIRSTRUN, GP_STATUS_DONE, GP_STATUS_ERROR, GP_STATUS_IDLING, GP_STATUS_PAINTING, gpencil_area_exists(), gpencil_draw_apply_event(), gpencil_draw_exit(), gpencil_draw_status_indicators(), gpencil_frame_delete_laststroke(), GPENCIL_SKETCH_SESSIONS_ON, tGPsdata::gpf, tGPsdata::gpl, INBETWEEN_MOUSEMOVE, KM_RELEASE, LEFTMOUSE, MOUSEMOVE, NA_EDITED, NC_SCREEN, ND_GPENCIL, NULL, OPERATOR_CANCELLED, OPERATOR_FINISHED, OPERATOR_PASS_THROUGH, OPERATOR_RUNNING_MODAL, wmEvent::oskey, p, PADENTER, tGPsdata::paintmode, RETKEY, RIGHTMOUSE, tGPsdata::sa, tGPsdata::scene, SPACEKEY, tGPsdata::status, wmEvent::type, wmEvent::val, WM_event_add_notifier(), and ZKEY.
Referenced by GPENCIL_OT_draw().
| static int gpencil_draw_poll | ( | bContext * | C | ) | [static] |
Definition at line 151 of file gpencil_paint.c.
References CTX_wm_operator_poll_msg_set(), ED_operator_regionactive(), Global::f, G, G_GREASEPENCIL, gpencil_data_get_pointers(), and NULL.
Referenced by GPENCIL_OT_draw().
| static void gpencil_draw_status_indicators | ( | tGPsdata * | p | ) | [static] |
Definition at line 1330 of file gpencil_paint.c.
References ED_area_headerprint(), GP_PAINTMODE_DRAW, GP_PAINTMODE_DRAW_STRAIGHT, GP_PAINTMODE_ERASER, GP_STATUS_DONE, GP_STATUS_ERROR, GP_STATUS_IDLING, GP_STATUS_PAINTING, GPENCIL_SKETCH_SESSIONS_ON, NULL, tGPsdata::paintmode, tGPsdata::sa, tGPsdata::scene, and tGPsdata::status.
Referenced by gpencil_draw_modal().
| void GPENCIL_OT_draw | ( | wmOperatorType * | ot | ) |
Definition at line 1787 of file gpencil_paint.c.
References wmOperatorType::cancel, wmOperatorType::description, wmOperatorType::exec, wmOperatorType::flag, gpencil_draw_cancel(), gpencil_draw_exec(), gpencil_draw_invoke(), gpencil_draw_modal(), gpencil_draw_poll(), wmOperatorType::idname, wmOperatorType::invoke, wmOperatorType::modal, wmOperatorType::name, OPTYPE_BLOCKING, OPTYPE_REGISTER, OPTYPE_UNDO, wmOperatorType::poll, RNA_def_collection_runtime(), RNA_def_enum(), RNA_OperatorStrokeElement, and wmOperatorType::srna.
Referenced by ED_operatortypes_gpencil().
| static int gpencil_project_check | ( | tGPsdata * | p | ) | [static] |
Definition at line 174 of file gpencil_paint.c.
References bGPdata::flag, GP_DATA_DEPTH_STROKE, GP_DATA_DEPTH_VIEW, GP_STROKE_3DSPACE, tGPsdata::gpd, and bGPdata::sbuffer_sflag.
Referenced by gp_paint_strokeend(), gp_stroke_convertcoords(), and gp_stroke_newfrombuffer().
EnumPropertyItem prop_gpencil_drawmodes[] [static] |
{
{GP_PAINTMODE_DRAW, "DRAW", 0, "Draw Freehand", ""},
{GP_PAINTMODE_DRAW_STRAIGHT, "DRAW_STRAIGHT", 0, "Draw Straight Lines", ""},
{GP_PAINTMODE_ERASER, "ERASER", 0, "Eraser", ""},
{0, NULL, 0, NULL, NULL}
}
Definition at line 1780 of file gpencil_paint.c.