2.1.5.5 curve_in_layer_get_index


Description

check if Curve is in a graph layer and return its plot index if true

Syntax

int curve_in_layer_get_index( const curvebase & cuv, const GraphLayer & gl )

Parameters

cuv
[input] Curve to test
gl
[input] graph layer to test

Return

plot index if in layer, or -1 if not

Examples

EX1

//This example return the index of the specified column in all Graphs in current folder.
void curve_in_layer_get_index_ex1()
{
    Worksheet wks = Project.ActiveLayer();
    if(!wks)
        return;
    Curve crv(wks, 1);
    Folder fld = wks.GetPage().GetFolder();
    //go through all pages in folder to check GraphPage
    foreach(PageBase page in fld.Pages) 
    {
        if(EXIST_PLOT == page.GetType())
        {
            GraphPage gp = page;
            GraphLayer gl = gp.Layers(0);
            
            int nIndex = curve_in_layer_get_index(crv, gl);
            //if curve is in the layer, output some information such as:curve name, graph name, and index.
            if( nIndex >= 0 )
            {
                string strCurve = crv.GetName();
                string strGraph = page.GetName();               
                printf("The index of %s curve in %s window is %d\n", strCurve, strGraph, nIndex);
            }
        }
    }    
}

Remark

See Also

Header to Include

origin.h

Reference