LayerManager Class Reference

The LayerManager JavaScript class. Access the layers of a given panel. More...

Panel Layer Manipulation

int numberOfLayers (String &panelId)
 Return the number of layers in a panel. More...
 
bool addVectorLayer (String &panelId, QVariant &siblingLayerId, bool before, String &suggestedName)
 Add a vector layer. More...
 
bool addBitmapLayer (String &panelId, QVariant &siblingLayerId, bool before, String &suggestedName)
 Add a bitmap layer. More...
 
bool addGroupLayer (String &panelId, QVariant &siblingLayerId, bool before, String &suggestedName)
 Add a group layer. More...
 
bool moveLayerInGroup (String &panelId, QVariant &layerId, QVariant &groupId=QVariant())
 Move a layer at the end of a group layer. More...
 
bool moveLayerBeforeLayer (String &panelId, QVariant &layerId, QVariant &siblingLayerId)
 Move layer before the sibbling layer (in the same group) More...
 
int groupOfLayer (String &panelId, QVariant &layerId)
 Return the group index of a layer. More...
 
bool isVectorLayer (String &panelId, QVariant &layerId)
 Return true if a layer is a vector layer. More...
 
bool is3DLayer (String &panelId, QVariant &layerId)
 Return true if a layer is a 3D layer. More...
 
bool isBitmapLayer (String &panelId, QVariant &layerId)
 Return true if a layer is a bitmap. More...
 
bool isGroupLayer (String &panelId, QVariant &layerId)
 Return true if a layer is a group layer. More...
 
bool deleteLayer (String &panelId, QVariant &layerId)
 Delete a given layer. More...
 
bool renameLayer (String &panelId, QVariant &layerId, String &suggestedName)
 Rename a given layer. More...
 
String layerName (String &panelId, int index)
 Return the name of a layer. More...
 
int layerIndexFromName (String &panelId, String &layerName)
 Return the index of layer named layerName. More...
 
bool importImageAsLayer (String &panelId, String &fullPathAndFileName, String &multiLayerOption="AskUser")
 Import image and creates a new layer at index 0, returns if successful. More...
 
bool setLayerVisible (String &panelId, QVariant &layerId, bool visible)
 Set the visibility flag of the layers of a panel. More...
 
bool layerVisibility (String &panelId, QVariant &layerId)
 Get the visibility flag of the layers of a panel. More...
 
bool setLayerLock (String &panelId, QVariant &layerId, bool lock)
 Set the lock flag of the layers of a panel. More...
 
bool getLayerLock (String &panelId, QVariant &layerId)
 Get the lock flag of the layers of a panel. More...
 
bool setLayerOpacity (String &panelId, QVariant &layerId, double opacity, int frame=-1)
 Set a layer's opacity. More...
 
double layerOpacity (String &panelId, QVariant &layerId, int frame=-1)
 Get layers opacity value. More...
 
bool setLayerAlignment (String &panelId, QVariant &layerId, String &alignment)
 Set a layer's alignment value. More...
 
String layerAlignment (String &panelId, QVariant &layerId)
 Get a layer's alignment value. More...
 
String getLayerDrawingName (String &panelId, QVariant &layerId, bool fullPath)
 Get the path to a layer's drawing. More...
 
int getLayerElementId (String &panelId, QVariant &layerId)
 Return the element id of the layer. May be useful when using the element and Drawing global objects. More...
 
bool generateMatteLayer (String &panelId, QVariant &layerId, double radius, bool copyStrokes, bool replaceLayer)
 Generate a new drawing layer making a matte from the given layer. The matte will be of the current selected color. More...
 
bool generateMatteLayer (String &panelId, QVariant &layerId, double radius, bool copyStrokes, bool replaceLayer, unsigned int red, unsigned int green, unsigned int blue)
 Generate a new drawing layer making a matte from the given layer. The matte will be of the given color. More...
 
bool generateMatte (String &panelId, QVariant &layerId, QScriptValue options)
 Generate matte from a given layer to a new drawing layer or directly on the source layer. More...
 
bool isShared (String &panelId, QVariant &layerId)
 Look at the the given Layer and return if it is shared. More...
 
bool isShared (QScriptValue layer)
 Look at the the given Layer and return if it is shared. More...
 
int mergeLayers (String &panelId, QScriptValue &layers, String &newLayerName)
 Merge the given Layers into a single panel. More...
 
QScriptValue mergeLayers (QScriptValue layers, String &newLayerName)
 Merge the given Layers into a single panel. More...
 
bool isEmpty (String &panelId, QVariant &layerId)
 Look at the given layer and return if it is empty or not. A layer is empty if it has no drawing. More...
 
bool isEmpty (QScriptValue layer)
 Look at the given layer and return if it is empty or not. A layer is empty if it has no drawing. More...
 
void applyBlurToBitmap (String &panelId, QVariant &layerId, bool skipDialog=false)
 Apply a blur effect to the given bitmap layer. More...
 
void applyRadialZoomBlurToBitmap (String &panelId, QVariant &layerId, bool skipDialog=false)
 Apply a radial zoom blur effect to the given bitmap layer. More...
 
void applyDirectionalBlurToBitmap (String &panelId, QVariant &layerId, bool skipDialog=false)
 Apply a directional blur effect to the given bitmap layer. More...
 

Detailed Description

The LayerManager JavaScript class. Access the layers of a given panel.

var lm = new LayerManager();
var sb = new StoryboardManager();
// get the first panel in the project.
var panelId = sb.panelInProject(0);
// Add 2 blank vector layers and 1 blank bitmap layer. Set the last one to invisible
lm.addVectorLayer( panelId, 0, false, "V-A");
lm.addVectorLayer( panelId, 1, false, "V-B");
lm.addBitmapLayer( panelId, 2, false, "B-A");
lm.setLayerVisible( panelId, "B-A", false);
// prepend a new layer by importing an image.
lm.importImageAsLayer(panelId, "/fullPath/Image.tga");

Member Function Documentation

◆ addBitmapLayer

bool LayerManager::addBitmapLayer ( String &  panelId,
QVariant &  siblingLayerId,
bool  before,
String &  suggestedName 
)
slot

Add a bitmap layer.

Parameters
panelId- unique id of the panel
siblingLayerId- id (index or name) of sibling layer
before- whether new layer is before or after sibling layer
suggestedName- suggested Name

◆ addGroupLayer

bool LayerManager::addGroupLayer ( String &  panelId,
QVariant &  siblingLayerId,
bool  before,
String &  suggestedName 
)
slot

Add a group layer.

Parameters
panelId- unique id of the panel
siblingLayerId- id (index or name) of sibling layer
before- whether new layer is before or after sibling layer
suggestedName- suggested Name

◆ addVectorLayer

bool LayerManager::addVectorLayer ( String &  panelId,
QVariant &  siblingLayerId,
bool  before,
String &  suggestedName 
)
slot

Add a vector layer.

Parameters
panelId- unique id of the panel
siblingLayerId- id (index or name) of sibling layer
before- whether new layer is before or after sibling layer
suggestedName- suggested Name

◆ applyBlurToBitmap

void LayerManager::applyBlurToBitmap ( String &  panelId,
QVariant &  layerId,
bool  skipDialog = false 
)
slot

Apply a blur effect to the given bitmap layer.

Parameters
panelId- The unique id of the panel
layerId- id (index or name) of layer
skipDialog- Skip the blur dialog and use the previously used blur settings. By default this is false
Note
If the given layer is a vector layer, this will do nothing

◆ applyDirectionalBlurToBitmap

void LayerManager::applyDirectionalBlurToBitmap ( String &  panelId,
QVariant &  layerId,
bool  skipDialog = false 
)
slot

Apply a directional blur effect to the given bitmap layer.

Parameters
panelId- The unique id of the panel
layerId- id (index or name) of layer
skipDialog- Skip the blur dialog and use the previously used blur settings. By default this is false
Note
If the given layer is a vector layer, this will do nothing

◆ applyRadialZoomBlurToBitmap

void LayerManager::applyRadialZoomBlurToBitmap ( String &  panelId,
QVariant &  layerId,
bool  skipDialog = false 
)
slot

Apply a radial zoom blur effect to the given bitmap layer.

Parameters
panelId- The unique id of the panel
layerId- id (index or name) of layer
skipDialog- Skip the blur dialog and use the previously used blur settings. By default this is false
Note
If the given layer is a vector layer, this will do nothing

◆ deleteLayer

bool LayerManager::deleteLayer ( String &  panelId,
QVariant &  layerId 
)
slot

Delete a given layer.

Parameters
panelId- uniqueId of the panel
layerId- id (index or name) of layer

◆ generateMatte

bool LayerManager::generateMatte ( String &  panelId,
QVariant &  layerId,
QScriptValue  options 
)
slot

Generate matte from a given layer to a new drawing layer or directly on the source layer.

Note
This method only works on vector layers.
Parameters
panelId- The unique id of the panel
layerId- id (index or name) of layer
options- Options used to generate the matte. The option object has the following properties:
Property Type Description
onNewLayer bool When true, the matte is created on a new layer.
radius double The number of the frame.
copyStrokes bool (Optional) Set to true to copy source strokes on the new layer. Can only be used if onNewLayer is set to true as well.
replaceLayer bool (Optional) Set to true to replace a previously generated matte layer. Can only be used if onNewLayer is set to true as well.
color int or String (Optional) Colour used to create the matte. Can be an hex RGB value or a standard W3C colour keyword name in a string. If not specified, the current colour will be used.

◆ generateMatteLayer [1/2]

bool LayerManager::generateMatteLayer ( String &  panelId,
QVariant &  layerId,
double  radius,
bool  copyStrokes,
bool  replaceLayer 
)
slot

Generate a new drawing layer making a matte from the given layer. The matte will be of the current selected color.

Note
This method only works on vector layers.
Parameters
panelId- The unique id of the panel
layerId- id (index or name) of layer
radius- The matte radius
copyStrokes- Set to true to copy the strokes
replaceLayer- Set to true to replace the existing layer by one with the same name, false to keep both
Returns
True if a matte layer is created.

◆ generateMatteLayer [2/2]

bool LayerManager::generateMatteLayer ( String &  panelId,
QVariant &  layerId,
double  radius,
bool  copyStrokes,
bool  replaceLayer,
unsigned int  red,
unsigned int  green,
unsigned int  blue 
)
slot

Generate a new drawing layer making a matte from the given layer. The matte will be of the given color.

Note
This method only works on vector layers.
Parameters
panelId- The unique id of the panel
layerId- id (index or name) of layer
radius- The matte radius
copyStrokes- Set to true to copy the strokes
replaceLayer- Set to true to replace the existing layer by one with the same name, false to keep both
red- The red channel value (0..255) for the matte. A value higher than 255 will be clamped.
green- The green channel value (0..255) for the matte. A value higher than 255 will be clamped.
blue- The blue channel value (0..255) for the matte. A value higher than 255 will be clamped.
Returns
True if a matte layer is created.

◆ getLayerDrawingName

String LayerManager::getLayerDrawingName ( String &  panelId,
QVariant &  layerId,
bool  fullPath 
)
slot

Get the path to a layer's drawing.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
fullPath- boolean to determine if the returned path is the full path or the file name

◆ getLayerElementId

int LayerManager::getLayerElementId ( String &  panelId,
QVariant &  layerId 
)
slot

Return the element id of the layer. May be useful when using the element and Drawing global objects.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer

◆ getLayerLock

bool LayerManager::getLayerLock ( String &  panelId,
QVariant &  layerId 
)
slot

Get the lock flag of the layers of a panel.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer

◆ groupOfLayer

int LayerManager::groupOfLayer ( String &  panelId,
QVariant &  layerId 
)
slot

Return the group index of a layer.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
Returns
group layer index or -1 if the layer is not in a group

◆ importImageAsLayer

bool LayerManager::importImageAsLayer ( String &  panelId,
String &  fullPathAndFileName,
String &  multiLayerOption = "AskUser" 
)
slot

Import image and creates a new layer at index 0, returns if successful.

Parameters
panelId- unique id of the panel
fullPathAndFileName- absolute path to image file
multiLayerOption- how to handle multi layer image

1 of these 3 values:

  • "AskUser" - Ask user
  • "Composite" - Import as one image
  • "Separate" - Import an image for each layer

◆ is3DLayer

bool LayerManager::is3DLayer ( String &  panelId,
QVariant &  layerId 
)
slot

Return true if a layer is a 3D layer.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer

◆ isBitmapLayer

bool LayerManager::isBitmapLayer ( String &  panelId,
QVariant &  layerId 
)
slot

Return true if a layer is a bitmap.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer

◆ isEmpty [1/2]

bool LayerManager::isEmpty ( String &  panelId,
QVariant &  layerId 
)
slot

Look at the given layer and return if it is empty or not. A layer is empty if it has no drawing.

Parameters
panelId- The unique id of the panel
layerId- id (index or name) of layer
Returns
True if the layer is empty, false if it isn't.

◆ isEmpty [2/2]

bool LayerManager::isEmpty ( QScriptValue  layer)
slot

Look at the given layer and return if it is empty or not. A layer is empty if it has no drawing.

Deprecated:
This method variant is kept for compatibility with the old version
Parameters
layer- an object with the name [String] and panelId properties [String].
Returns
True if the layer is empty, false if it isn't.

◆ isGroupLayer

bool LayerManager::isGroupLayer ( String &  panelId,
QVariant &  layerId 
)
slot

Return true if a layer is a group layer.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer

◆ isShared [1/2]

bool LayerManager::isShared ( String &  panelId,
QVariant &  layerId 
)
slot

Look at the the given Layer and return if it is shared.

Parameters
panelId- The unique id of the panel
layerId- id (index or name) of layer
Returns
True if the given layer is shared.

◆ isShared [2/2]

bool LayerManager::isShared ( QScriptValue  layer)
slot

Look at the the given Layer and return if it is shared.

Deprecated:
This method variant is kept for compatibility with the old version
Parameters
layera layer is defined by those properties: frame, panelId, name.
Returns
True if the given layer is shared.

◆ isVectorLayer

bool LayerManager::isVectorLayer ( String &  panelId,
QVariant &  layerId 
)
slot

Return true if a layer is a vector layer.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer

◆ layerAlignment

String LayerManager::layerAlignment ( String &  panelId,
QVariant &  layerId 
)
slot

Get a layer's alignment value.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer

◆ layerIndexFromName

int LayerManager::layerIndexFromName ( String &  panelId,
String &  layerName 
)
slot

Return the index of layer named layerName.

Parameters
panelId- unique id of the panel
layerName- name of the layer
Returns
layer index or -1 if there is no layer named layerName

◆ layerName

String LayerManager::layerName ( String &  panelId,
int  index 
)
slot

Return the name of a layer.

Parameters
panelId- unique id of the panel
index- index of the layer

◆ layerOpacity

double LayerManager::layerOpacity ( String &  panelId,
QVariant &  layerId,
int  frame = -1 
)
slot

Get layers opacity value.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
frame- specify frame (-1 will use current frame)
Note
Current frame isn't available in batch mode, so you will get an exception

◆ layerVisibility

bool LayerManager::layerVisibility ( String &  panelId,
QVariant &  layerId 
)
slot

Get the visibility flag of the layers of a panel.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer

◆ mergeLayers [1/2]

int LayerManager::mergeLayers ( String &  panelId,
QScriptValue &  layers,
String &  newLayerName 
)
slot

Merge the given Layers into a single panel.

Parameters
panelId- The unique id of the panel
layers- an array of layer's id (index or name)
newLayerName- new name of the layer created from the merge.
Returns
The index of the new layer (merge result).

◆ mergeLayers [2/2]

QScriptValue LayerManager::mergeLayers ( QScriptValue  layers,
String &  newLayerName 
)
slot

Merge the given Layers into a single panel.

Deprecated:
This method variant is kept for compatibility with the old version
Parameters
layers- an array of objects with the name [String] and panelId properties [String].
newLayerName- new name of the layer created from the merge.
Returns
A single layer from the merge.

◆ moveLayerBeforeLayer

bool LayerManager::moveLayerBeforeLayer ( String &  panelId,
QVariant &  layerId,
QVariant &  siblingLayerId 
)
slot

Move layer before the sibbling layer (in the same group)

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
siblingLayerId- id (index or name) of sibling layer

◆ moveLayerInGroup

bool LayerManager::moveLayerInGroup ( String &  panelId,
QVariant &  layerId,
QVariant &  groupId = QVariant() 
)
slot

Move a layer at the end of a group layer.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
groupId- id (index or name) of group layer
Note
If groupId is undefined or -1, layer will be move at the top

◆ numberOfLayers

int LayerManager::numberOfLayers ( String &  panelId)
slot

Return the number of layers in a panel.

Parameters
panelId- unique id of the panel

◆ renameLayer

bool LayerManager::renameLayer ( String &  panelId,
QVariant &  layerId,
String &  suggestedName 
)
slot

Rename a given layer.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
suggestedName- suggested name

◆ setLayerAlignment

bool LayerManager::setLayerAlignment ( String &  panelId,
QVariant &  layerId,
String &  alignment 
)
slot

Set a layer's alignment value.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
alignment- The alignment options are: "No Alignment", "Face Camera" and "Pin to Camera".

◆ setLayerLock

bool LayerManager::setLayerLock ( String &  panelId,
QVariant &  layerId,
bool  lock 
)
slot

Set the lock flag of the layers of a panel.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
lock- boolean flag

◆ setLayerOpacity

bool LayerManager::setLayerOpacity ( String &  panelId,
QVariant &  layerId,
double  opacity,
int  frame = -1 
)
slot

Set a layer's opacity.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
opacity- value between 0 and 100
frame- specify frame (-1 will use current frame)
Note
Current frame isn't available in batch mode, so you will get an exception

◆ setLayerVisible

bool LayerManager::setLayerVisible ( String &  panelId,
QVariant &  layerId,
bool  visible 
)
slot

Set the visibility flag of the layers of a panel.

Parameters
panelId- unique id of the panel
layerId- id (index or name) of layer
visible- boolean flag