2.1.5.2 curve_both_in_layer


Description

Search the layer where two curves are both plotted. glayerFound can be set to a layer to search first, or it can be let uninitialized

Syntax

bool curve_both_in_layer( const curvebase & cuv1, const curvebase & cuv2, GraphLayer & glayerFound )

Parameters

cuv1
[input] Curve that is plotted
cuv2
[input] Curve that is likely already plotted in some layer
glayerFound
[output] Graph that cuv2 is currently plotted

Return

FALSE if not in same layer, or cuv2 not plotted at all

Examples

EX1

void curve_both_in_layer_ex1()
{
    //Get the active GraphLayer of current project
    GraphLayer glActive = Project.ActiveLayer(); 
    if(!glActive.IsValid())
        return;
    
    //get active page
    GraphPage pg;
    glActive.GetParent(pg);
    
    //get 1st layer
    int nLayers = pg.Layers.Count();
    GraphLayer glFirst = pg.Layers(0);

    // Get 1st data plot in glFirst
    DataPlot dp1 = glFirst.DataPlots(0);      
    if(!dp1)                          
        return;
        
    Curve cuv1(dp1);     
    
    //get last layer
    GraphLayer glLast = pg.Layers(nLayers - 1);
    
    //get 1st plot in glLast
    DataPlot dp2 = glLast.DataPlots(0);      
    if(!dp2)                          
        return;
    
    Curve cuv2(dp2);
    
    //check if in same layer
    GraphLayer gl;
    if(!curve_both_in_layer(cuv1, cuv2, gl)) 
    {
        // cuv2 plotted in gl but cuv1 not, so we will make the plot
        int nPlot = gl.AddPlot(cuv1, IDM_PLOT_LINE);
        DataPlot dptemp = gl.DataPlots(nPlot);
        dptemp.SetColor(SYSCOLOR_RED); // set to red
        gl.Rescale();
    }
}

Remark

See Also

Header to Include

origin.h

Reference