|
Blender V4.3
|
#include <algorithm>#include <cmath>#include <cstddef>#include <cstdio>#include <cstdlib>#include <cstring>#include "MEM_guardedalloc.h"#include "BLI_blenlib.h"#include "BLI_ghash.h"#include "BLI_hash.h"#include "BLI_lasso_2d.hh"#include "BLI_math_color.h"#include "BLI_math_matrix.h"#include "BLI_math_vector.hh"#include "BLI_time.h"#include "BLI_utildefines.h"#include "BLT_translation.hh"#include "DNA_brush_types.h"#include "DNA_gpencil_legacy_types.h"#include "DNA_material_types.h"#include "DNA_meshdata_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_action.hh"#include "BKE_brush.hh"#include "BKE_collection.hh"#include "BKE_colortools.hh"#include "BKE_context.hh"#include "BKE_deform.hh"#include "BKE_gpencil_curve_legacy.h"#include "BKE_gpencil_geom_legacy.h"#include "BKE_gpencil_legacy.h"#include "BKE_main.hh"#include "BKE_material.h"#include "BKE_object.hh"#include "BKE_paint.hh"#include "BKE_preview_image.hh"#include "BKE_tracking.h"#include "WM_api.hh"#include "WM_toolsystem.hh"#include "WM_types.hh"#include "RNA_access.hh"#include "RNA_define.hh"#include "RNA_enum_types.hh"#include "RNA_prototypes.hh"#include "UI_resources.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_transform_snap_object_context.hh"#include "ED_view3d.hh"#include "GPU_immediate.hh"#include "GPU_immediate_util.hh"#include "GPU_state.hh"#include "DEG_depsgraph.hh"#include "DEG_depsgraph_query.hh"#include "gpencil_intern.hh"Go to the source code of this file.
Get the active Grease Pencil data-block
Definition at line 247 of file gpencil_utils.cc.
References 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().
Get the active Grease Pencil data-block, when context is not available.
Definition at line 232 of file gpencil_utils.cc.
References ED_annotation_data_get_pointers_direct().
Referenced by screen_ctx_active_annotation_layer(), and screen_ctx_annotation_data().
| bGPdata ** ED_annotation_data_get_pointers | ( | const bContext * | C, |
| PointerRNA * | r_ptr ) |
Get pointer to active Grease Pencil data-block, and an RNA-pointer to trace back to whatever owns it.
Definition at line 222 of file gpencil_utils.cc.
References CTX_data_scene(), CTX_wm_area(), CTX_wm_screen(), and ED_annotation_data_get_pointers_direct().
Referenced by annotation_draw_poll(), annotation_session_initdata(), ED_annotation_data_get_active(), gpencil_add_annotation_poll(), gpencil_data_add_exec(), gpencil_data_add_poll(), gpencil_data_unlink_exec(), gpencil_data_unlink_poll(), gpencil_layer_add_exec(), and gpencil_layer_remove_exec().
| bGPdata ** ED_annotation_data_get_pointers_direct | ( | ID * | screen_id, |
| ScrArea * | area, | ||
| Scene * | scene, | ||
| PointerRNA * | r_ptr ) |
Get pointer to active Grease Pencil data-block for annotations, and an RNA-pointer to trace back to whatever owns it, when context info is not available.
Definition at line 116 of file gpencil_utils.cc.
References MovieTrackingObject::active_track, BKE_tracking_object_get_active(), ED_space_clip_get_clip(), bNodeTree::gpd, MovieTrackingTrack::gpd, SpaceImage::gpd, SpaceSeq::gpd, SpaceClip::gpencil_src, bNodeTree::id, SpaceNode::nodetree, RNA_id_pointer_create(), RNA_pointer_create(), SC_GPENCIL_SRC_TRACK, SPACE_CLIP, SPACE_IMAGE, SPACE_INFO, SPACE_NODE, SPACE_PROPERTIES, SPACE_SEQ, SPACE_TOPBAR, and SPACE_VIEW3D.
Referenced by ED_annotation_data_get_active_direct(), ED_annotation_data_get_pointers(), and screen_ctx_annotation_data_owner().
Get the active Grease Pencil data-block
Definition at line 238 of file gpencil_utils.cc.
References CTX_data_active_object(), Object::data, OB_GPENCIL_LEGACY, and Object::type.
Referenced by gpencil_actframe_delete_exec(), gpencil_layer_move_exec(), gpencil_layer_remove_exec(), and viewRedrawForce().
| bGPdata ** ED_gpencil_data_get_pointers | ( | const bContext * | C, |
| PointerRNA * | r_ptr ) |
Get pointer to active Grease Pencil data-block, and an RNA-pointer to trace back to whatever owns it.
Definition at line 214 of file gpencil_utils.cc.
References CTX_data_active_object(), CTX_wm_area(), and ED_gpencil_data_get_pointers_direct().
Referenced by ED_undo_gpencil_step().
| bGPdata ** ED_gpencil_data_get_pointers_direct | ( | ScrArea * | area, |
| Object * | ob, | ||
| PointerRNA * | r_ptr ) |
Context independent (i.e. each required part is passed in instead).
Get pointer to active Grease Pencil data-block, and an RNA-pointer to trace back to whatever owns it, when context info is not available.
Definition at line 87 of file gpencil_utils.cc.
References Object::data, Object::id, OB_GPENCIL_LEGACY, RNA_id_pointer_create(), SPACE_INFO, SPACE_PROPERTIES, SPACE_TOPBAR, SPACE_VIEW3D, and Object::type.
Referenced by ED_gpencil_data_get_pointers().
| bool ED_gpencil_data_owner_is_annotation | ( | PointerRNA * | owner_ptr | ) |
Utility to check whether the r_ptr output of ED_gpencil_data_get_pointers() is for annotation usage.
Definition at line 255 of file gpencil_utils.cc.
References PointerRNA::type.
Referenced by annotation_session_initdata().
| void ED_gpencil_drawing_reference_get | ( | const Scene * | scene, |
| const Object * | ob, | ||
| char | align_flag, | ||
| float | r_vec[3] ) |
Get drawing reference point for conversion or projection of the stroke
| r_vec | Reference point found |
Definition at line 374 of file gpencil_utils.cc.
References add_v3_v3(), BKE_gpencil_layer_active_get(), copy_v3_v3(), Object::data, GP_PROJECT_CURSOR, GP_PROJECT_VIEWSPACE, bGPDlayer::layer_mat, OB_GPENCIL_LEGACY, and Object::type.
| 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 453 of file gpencil_utils.cc.
References clear(), GP_STROKE_BUFFER_CHUNK, MEM_callocN, and MEM_recallocN.
Referenced by annotation_session_validatebuffer(), and annotation_stroke_addpoint().
| bool ED_gpencil_stroke_can_use | ( | const bContext * | C, |
| const bGPDstroke * | gps ) |
Check whether given stroke can be edited in the current context
Definition at line 306 of file gpencil_utils.cc.
References CTX_wm_area(), and ED_gpencil_stroke_can_use_direct().
Referenced by createTransGPencil_curves(), and createTransGPencil_strokes().
| 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 282 of file gpencil_utils.cc.
References ELEM, bGPDstroke::flag, GP_STROKE_2DIMAGE, GP_STROKE_2DSPACE, GP_STROKE_3DSPACE, SPACE_IMAGE, SPACE_PROPERTIES, and SPACE_VIEW3D.
Referenced by annotation_stroke_doeraser(), and ED_gpencil_stroke_can_use().
| bool ED_gpencil_stroke_material_editable | ( | Object * | ob, |
| const bGPDlayer * | gpl, | ||
| const bGPDstroke * | gps ) |
Check whether given stroke can be edited for the current color
Definition at line 312 of file gpencil_utils.cc.
References BKE_gpencil_material_settings(), bGPDlayer::flag, MaterialGPencilStyle::flag, GP_LAYER_UNLOCK_COLOR, GP_MATERIAL_HIDE, GP_MATERIAL_LOCKED, and bGPDstroke::mat_nr.
Referenced by createTransGPencil_curves(), and createTransGPencil_strokes().
| void ED_gpencil_tpoint_to_point | ( | ARegion * | region, |
| float | origin[3], | ||
| const tGPspoint * | tpt, | ||
| bGPDspoint * | pt ) |
Convert 2d tGPspoint to 3d bGPDspoint.
Definition at line 436 of file gpencil_utils.cc.
References copy_v3_v3(), gpencil_stroke_convertcoords(), bGPDspoint::pressure, tGPspoint::pressure, bGPDspoint::strength, tGPspoint::strength, bGPDspoint::uv_fac, tGPspoint::uv_fac, bGPDspoint::uv_rot, tGPspoint::uv_rot, bGPDspoint::vert_color, bGPDspoint::x, and zero_v4().
| 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)
| [out] | r_x | The screen-space x-coordinate of the point |
| [out] | r_y | The screen-space y-coordinate of the point |
Definition at line 332 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, int, 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, bGPDspoint::x, rctf::xmin, bGPDspoint::y, and rctf::ymin.
Referenced by annotation_stroke_eraser_dostroke().
|
static |
Helper to convert 2d to 3d for simple drawing buffer.
Definition at line 410 of file gpencil_utils.cc.
References copy_v3_v3(), ED_view3d_calc_zfac(), ED_view3d_project_float_global(), ED_view3d_win_to_delta(), tGPspoint::m_xy, sub_v2_v2v2(), sub_v3_v3v3(), V3D_PROJ_RET_OK, V3D_PROJ_TEST_NOP, and zero_v3().
Referenced by ED_gpencil_tpoint_to_point().
Check whether a given stroke segment is inside a circular brush
| mval | The current screen-space coordinates (midpoint) of the brush |
| rad | The radius of the brush |
| x0,y0 | The screen-space x and y coordinates of the start of the stroke segment |
| x1,y1 | The screen-space x and y coordinates of the end of the stroke segment |
Definition at line 265 of file gpencil_utils.cc.
References edge_inside_circle(), and float.
Referenced by annotation_stroke_eraser_dostroke().