2.2.4.17.21 GraphLayer::GetLayerContents

Description

get the contents of a graph layer into a tree

Syntax

BOOL GetLayerContents( TreeNode & tr, DWORD dwCtrl = 0 )

Parameters

tr
[output] a TreeNode to receive the layer contents
dwCtrl
[input] bits to control what to get into the tree, supported bits include
GETLC_STYLE_HOLDERS to get style holders that are in the layer
GETLC_DATAPLOTS to get data plots
GETLC_NO_LIMITS to when GETLC_DATAPLOTS is specified, plot XY limits are also obtain, which is time consuming, so use this to speed things up if the limits are not used

Return

Examples

EX1

//Get the contents of the graph layer into a tree. Then use the tree to draw a new graph.
void GraphLayer_GetLayerContents_ex1()
{
    GraphLayer gl = Project.ActiveLayer();
    if(!gl)
        return;
 
    Tree tr;
    bool bWasGroup = gl.UngroupPlots();
    //get the contents of a graph layer into a tree 
    gl.GetLayerContents(tr, GETLC_DATAPLOTS | GETLC_NO_LIMITS);    
 
    GraphPage gp;
    gp.Create();
    GraphLayer glNew = gp.Layers(0);
 
    // add plots by the settings of tr, the plots should be ungrouped
    int nn = glNew.AddPlots(tr.FirstNode, ADDPLOTSFROMTREE_NEW | ADDPLOTSFROMTREE_IMPLICIT_STYLEHOLDERS);
    glNew.LT_execute("legend -s");// this will force the legend to update
    glNew.Rescale();
}

Remark

See Also

GraphLayer::AddPlots

Header to Include

origin.h