2.2.4.24.14 Layer::GraphObjects

Description

Collection of all GraphObjects in the layer.


Get the graph object contained in the graph layer by index.


Get the graph object contained in the graph layer by name.

Syntax

Collection<GraphObject> GraphObjects


GraphObject	GraphObjects(int index)


GraphObject	GraphObjects(LPCSTR lpcszName)

Parameters

index
[input] index of the GraphObject to be returned.


lpcszName
[input] pointer to the string containing the name of the GraphObject.

Return

GraphObject in the layer whose index was specified.


GraphObject with the specified name from the layer.

Examples

EX1

//Output the collection of all GraphObjects in the active graph layer. 
void Layer_GraphObjects_Collection_ex1()
{
    // Call this function with a graph layer active
    GraphLayer    gly = Project.ActiveLayer();
    if( gly.IsValid() )
    {
        // Get the collection of graph objects in the layer
        Collection<GraphObject> grobjcollection;            
        grobjcollection = gly.GraphObjects;
        // Loop thru the collection and report name of each object            
        GraphObject grobj;
        foreach ( grobj in grobjcollection )
            out_str( grobj.GetName() );
    }
    else
        out_str( "No graph layer is active" );
}

EX2

// By index. Call this function with a graph layer active
void Layer_GraphObject_ex2()
{

	// Create a Layer object and attach it to the active layer of the graph
	GraphLayer	gly	= Project.ActiveLayer();
	if( gly.IsValid() )
	{
		// Get the first graph object contained in the graph layer
		GraphObject grobj;
		grobj = gly.GraphObjects( 0 );
		if( grobj.IsValid() )
		{
			// Get name of the graph object and report
			printf( "Name of the first graph object in layer is: %s\n", grobj.GetName() );
		}
		else
			out_str( "No graph objects found in graph layer" );
	}
	else
		out_str( "No active graph layer found" );
}

EX3

// By name. Call this function with a graph layer active
void Layer_GraphObject_ex3()
{
	GraphLayer	gly = Project.ActiveLayer();
	if( gly.IsValid() )
	{
		// Get the GraphObject named "YL" which is the Y axis title
		// in a default graph layer
		GraphObject grobj;
		grobj = gly.GraphObjects( "YL" );
		if( grobj.IsValid() )
		{
			// Report the object type
			printf("GraphObject is of type: %s\n", grobj.GetObjectType() );
		}
		else
			out_str( "Could not find Y axis title object" );
	}
	else
		out_str( "No graph layer active" )
}

Remark

Header to Include

origin.h

See Also

Layer::CreateGraphObject Layer::CreateShapeGraphObjects Layer::RemoveGraphObject

Reference