Blender V5.0
Layer Class Reference

#include <BKE_grease_pencil.hh>

Inherits GreasePencilLayer.

Public Types

using SortedKeysIterator = const int *

Public Member Functions

 Layer ()
 Layer (StringRef name)
 Layer (const Layer &other)
 ~Layer ()
const TreeNodeas_node () const
TreeNodeas_node ()
const LayerGroup & parent_group () const
LayerGroup & parent_group ()
const Map< FramesMapKeyT, GreasePencilFrame > & frames () const
Map< FramesMapKeyT, GreasePencilFrame > & frames_for_write ()
bool is_empty () const
GreasePencilFrameadd_frame (FramesMapKeyT key, int duration=0)
bool remove_frame (FramesMapKeyT key)
Span< FramesMapKeyT > sorted_keys () const
int drawing_index_at (const int frame_number) const
bool has_drawing_at (const int frame_number) const
std::optional< int > start_frame_at (int frame_number) const
int sorted_keys_index_at (int frame_number) const
SortedKeysIterator sorted_keys_iterator_at (int frame_number) const
const GreasePencilFrameframe_at (const int frame_number) const
GreasePencilFrameframe_at (const int frame_number)
int get_frame_duration_at (const int frame_number) const
void tag_frames_map_changed ()
void tag_frames_map_keys_changed ()
void prepare_for_dna_write ()
void update_from_dna_read ()
float4x4 parent_inverse () const
float4x4 local_transform () const
void set_local_transform (const float4x4 &transform)
float4x4 to_object_space (const Object &object) const
float4x4 to_world_space (const Object &object) const
StringRefNull parent_bone_name () const
void set_parent_bone_name (StringRef new_name)
StringRefNull view_layer_name () const
void set_view_layer_name (StringRef new_name)

Public Attributes

 TREENODE_COMMON_METHODS
Public Attributes inherited from GreasePencilLayer
GreasePencilLayerTreeNode base
GreasePencilLayerFramesMapStorage frames_storage
int8_t blend_mode
char _pad [3]
float opacity
ListBase masks
int active_mask_index
char _pad2 [4]
struct Objectparent
char * parsubstr
float parentinv [4][4]
float translation [3]
float rotation [3]
float scale [3]
char _pad3 [4]
char * viewlayername
GreasePencilLayerRuntimeHandleruntime

Detailed Description

A layer maps drawings to scene frames. It can be thought of as one independent channel in the timeline.

Definition at line 456 of file BKE_grease_pencil.hh.

Member Typedef Documentation

◆ SortedKeysIterator

Definition at line 458 of file BKE_grease_pencil.hh.

Constructor & Destructor Documentation

◆ Layer() [1/3]

◆ Layer() [2/3]

Definition at line 1179 of file grease_pencil.cc.

◆ Layer() [3/3]

Definition at line 1184 of file grease_pencil.cc.

◆ ~Layer()

Member Function Documentation

◆ add_frame()

GreasePencilFrame * blender::bke::greasepencil::Layer::add_frame ( FramesMapKeyT key,
int duration = 0 )

Adds a new frame into the layer frames map. Fails if there already exists a frame at key that is not an end-frame. End-frame at key and subsequent end-frames are removed.

If duration is 0, the frame is marked as an implicit hold (see GP_FRAME_IMPLICIT_HOLD). Otherwise adds an additional end-frame at key + duration, if necessary, to indicate the end of the added frame.

Returns
a pointer to the added frame on success, otherwise nullptr.

Definition at line 1275 of file grease_pencil.cc.

◆ as_node() [1/2]

◆ as_node() [2/2]

Returns
the layer as a TreeNode.

Definition at line 889 of file BKE_grease_pencil.hh.

Referenced by rearrange_grease_pencil_channels().

◆ drawing_index_at()

int blender::bke::greasepencil::Layer::drawing_index_at ( const int frame_number) const
Returns
the index of the active drawing at frame frame_number or -1 if there is no drawing. TODO: This should be a private API!

Definition at line 1448 of file grease_pencil.cc.

◆ frame_at() [1/2]

Definition at line 1428 of file grease_pencil.cc.

◆ frame_at() [2/2]

const GreasePencilFrame * blender::bke::greasepencil::Layer::frame_at ( const int frame_number) const
Returns
a pointer to the active frame at frame_number or nullptr if there is no frame.

Definition at line 1408 of file grease_pencil.cc.

Referenced by blender::io::grease_pencil::GreasePencilExporter::is_selected_frame().

◆ frames()

Returns
the frames mapping.

Definition at line 1235 of file grease_pencil.cc.

Referenced by actkeys_framejump_exec(), and insert_grease_pencil_key().

◆ frames_for_write()

◆ get_frame_duration_at()

int blender::bke::greasepencil::Layer::get_frame_duration_at ( const int frame_number) const
Returns
the frame duration of the keyframe at frame_number. If there is no keyframe at frame_number
-1. If the keyframe is an implicit hold,
0.

Definition at line 1459 of file grease_pencil.cc.

◆ has_drawing_at()

bool blender::bke::greasepencil::Layer::has_drawing_at ( const int frame_number) const
Returns
true if there is a drawing on this layer at frame_number.

Definition at line 1454 of file grease_pencil.cc.

◆ is_empty()

Returns
true, if the layer contains no keyframes.

Definition at line 899 of file BKE_grease_pencil.hh.

◆ local_transform()

The local transform of the layer (in layer space, not object space).

Definition at line 1585 of file grease_pencil.cc.

◆ parent_bone_name()

Returns the name of the parent bone. Should only be used in case the parent object is an armature.

Definition at line 1551 of file grease_pencil.cc.

◆ parent_group() [1/2]

Definition at line 907 of file BKE_grease_pencil.hh.

◆ parent_group() [2/2]

const LayerGroup & blender::bke::greasepencil::Layer::parent_group ( ) const
inline
Returns
the parent #LayerGroup of this layer.

Definition at line 903 of file BKE_grease_pencil.hh.

◆ parent_inverse()

◆ prepare_for_dna_write()

Prepare the DNA GreasePencilLayer data before blend-file writing.

Definition at line 1491 of file grease_pencil.cc.

◆ remove_frame()

Removes a frame with key from the frames map.

Fails if the map does not contain a frame with key or in the specific case where the previous frame has a fixed duration (is not marked as an implicit hold) and the frame to remove is an end frame.

Will remove end frame(s) after the frame to remove.

Returns
true on success.

Definition at line 1305 of file grease_pencil.cc.

◆ set_local_transform()

Updates the local transform of the layer based on the matrix.

Note
The matrix is decomposed into location, rotation and scale, so any skew is lost.

Definition at line 1591 of file grease_pencil.cc.

◆ set_parent_bone_name()

◆ set_view_layer_name()

◆ sorted_keys()

Returns the sorted keys (start frame numbers) of the frames of this layer.

Note
This will cache the keys lazily.

Definition at line 1344 of file grease_pencil.cc.

Referenced by get_grease_pencil_layer_bounds().

◆ sorted_keys_index_at()

Returns
the index of the key of the active frame in sorted_keys or -1 if no such frame exists.

Definition at line 1399 of file grease_pencil.cc.

◆ sorted_keys_iterator_at()

Returns
an iterator into the sorted_keys span to the frame at frame_number or nullptr if no such frame exists.

Definition at line 1357 of file grease_pencil.cc.

◆ start_frame_at()

std::optional< int > blender::bke::greasepencil::Layer::start_frame_at ( int frame_number) const
Returns
the start frame number of the active frame at frame_number or #std::nullopt if no such frame exists.

Definition at line 1389 of file grease_pencil.cc.

Referenced by insert_grease_pencil_key().

◆ tag_frames_map_changed()

◆ tag_frames_map_keys_changed()

Should be called whenever the keys in the frames map have changed. E.g. when new keys were added, removed or updated.

Definition at line 1485 of file grease_pencil.cc.

◆ to_object_space()

Returns the transformation from layer space to object space.

Definition at line 1541 of file grease_pencil.cc.

◆ to_world_space()

Returns the transformation from layer space to world space.

Definition at line 1532 of file grease_pencil.cc.

◆ update_from_dna_read()

Update from DNA GreasePencilLayer data after blend-file reading.

Definition at line 1515 of file grease_pencil.cc.

◆ view_layer_name()

Returns the view layer name that this layer should be rendered in or an empty StringRefNull if no such name is set.

Definition at line 1599 of file grease_pencil.cc.

Member Data Documentation

◆ TREENODE_COMMON_METHODS


The documentation for this class was generated from the following files: