Blender V5.0
gpencil_utils.cc File Reference
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "BKE_context.hh"
#include "BKE_paint.hh"
#include "BKE_tracking.h"
#include "WM_api.hh"
#include "WM_toolsystem.hh"
#include "WM_types.hh"
#include "RNA_access.hh"
#include "RNA_enum_types.hh"
#include "RNA_prototypes.hh"
#include "UI_view2d.hh"
#include "ED_clip.hh"
#include "ED_gpencil_legacy.hh"
#include "ED_object.hh"
#include "ED_select_utils.hh"
#include "ED_view3d.hh"
#include "DEG_depsgraph_query.hh"
#include "gpencil_intern.hh"

Go to the source code of this file.

Functions

bGPdata ** ED_annotation_data_get_pointers_direct (ID *screen_id, ScrArea *area, Scene *scene, PointerRNA *r_ptr)
bGPdata ** ED_annotation_data_get_pointers (const bContext *C, PointerRNA *r_ptr)
bGPdataED_annotation_data_get_active_direct (ID *screen_id, ScrArea *area, Scene *scene)
bGPdataED_annotation_data_get_active (const bContext *C)
bool gpencil_stroke_inside_circle (const float mval[2], int rad, int x0, int y0, int x1, int y1)
bool ED_gpencil_stroke_can_use_direct (const ScrArea *area, const bGPDstroke *gps)
void gpencil_point_to_xy (const GP_SpaceConversion *gsc, const bGPDstroke *gps, const bGPDspoint *pt, int *r_x, int *r_y)
tGPspointED_gpencil_sbuffer_ensure (tGPspoint *buffer_array, int *buffer_size, int *buffer_used, const bool clear)

Function Documentation

◆ ED_annotation_data_get_active()

bGPdata * ED_annotation_data_get_active ( const bContext * C)

Get the active Grease Pencil data-block

Note
This is the original (#G.main) copy of the data-block, stored in files. Do not use for reading evaluated copies of GP Objects data.

Definition at line 167 of file gpencil_utils.cc.

References C, and ED_annotation_data_get_pointers().

Referenced by annotation_actframe_delete_poll(), ED_annotation_draw_2dimage(), ED_annotation_draw_view2d(), gpencil_actframe_delete_exec(), gpencil_active_layer_annotation_poll(), gpencil_layer_move_exec(), and gpencil_layer_remove_exec().

◆ ED_annotation_data_get_active_direct()

bGPdata * ED_annotation_data_get_active_direct ( ID * screen_id,
ScrArea * area,
Scene * scene )

Get the active Grease Pencil data-block, when context is not available.

Definition at line 161 of file gpencil_utils.cc.

References ED_annotation_data_get_pointers_direct().

Referenced by screen_ctx_active_annotation_layer(), and screen_ctx_annotation_data().

◆ ED_annotation_data_get_pointers()

◆ ED_annotation_data_get_pointers_direct()

◆ ED_gpencil_sbuffer_ensure()

tGPspoint * ED_gpencil_sbuffer_ensure ( tGPspoint * buffer_array,
int * buffer_size,
int * buffer_used,
bool clear )

Ensure the tGPspoint buffer (while drawing stroke) size is enough to save all points of the stroke.

Definition at line 262 of file gpencil_utils.cc.

References clear(), GP_STROKE_BUFFER_CHUNK, MEM_calloc_arrayN(), and MEM_recallocN.

Referenced by annotation_session_validatebuffer(), and annotation_stroke_addpoint().

◆ ED_gpencil_stroke_can_use_direct()

bool ED_gpencil_stroke_can_use_direct ( const ScrArea * area,
const bGPDstroke * gps )

Check whether given stroke can be edited given the supplied context. TODO: do we need additional flags for screen-space vs data-space?.

Definition at line 193 of file gpencil_utils.cc.

References ELEM, bGPDstroke::flag, GP_STROKE_2DIMAGE, GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, SPACE_IMAGE, SPACE_PROPERTIES, SPACE_VIEW3D, and ScrArea::spacetype.

Referenced by annotation_stroke_doeraser().

◆ gpencil_point_to_xy()

void gpencil_point_to_xy ( const GP_SpaceConversion * gsc,
const bGPDstroke * gps,
const bGPDspoint * pt,
int * r_x,
int * r_y )

Convert a Grease Pencil coordinate (i.e. can be 2D or 3D) to screen-space (2D)

Parameters
[out]r_xThe screen-space x-coordinate of the point
[out]r_yThe screen-space y-coordinate of the point
Warning
This assumes that the caller has already checked whether the stroke in question can be drawn.

Definition at line 220 of file gpencil_utils.cc.

References GP_SpaceConversion::area, BLI_assert, BLI_rctf_size_x(), BLI_rctf_size_y(), ED_view3d_project_int_global(), bGPDstroke::flag, GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, GP_SpaceConversion::mat, mul_m4_v3(), GP_SpaceConversion::region, SPACE_VIEW3D, ScrArea::spacetype, GP_SpaceConversion::subrect, UI_view2d_view_to_region_clip(), GP_SpaceConversion::v2d, V2D_IS_CLIPPED, V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, ARegion::winx, ARegion::winy, bGPDspoint::x, rctf::xmin, bGPDspoint::y, and rctf::ymin.

Referenced by annotation_stroke_eraser_dostroke().

◆ gpencil_stroke_inside_circle()

bool gpencil_stroke_inside_circle ( const float mval[2],
int rad,
int x0,
int y0,
int x1,
int y1 )

Check whether a given stroke segment is inside a circular brush

Parameters
mvalThe current screen-space coordinates (midpoint) of the brush
radThe radius of the brush
x0,y0The screen-space x and y coordinates of the start of the stroke segment
x1,y1The screen-space x and y coordinates of the end of the stroke segment

Definition at line 176 of file gpencil_utils.cc.

References edge_inside_circle(), and float.

Referenced by annotation_stroke_eraser_dostroke().