2.2.4.24.30 Layer::RemoveGraphObject

Description

Remove specified GraphObject from layer. The object is referred to by index.


Remove specified GraphObject from layer. The object is referred to by its name.

Syntax

BOOL RemoveGraphObject( int index )


BOOL RemoveGraphObject( LPCSTR lpcszName )

Parameters

index
[input] index of the GraphObject to be removed


lpcszName
[input] Name of the GraphObject to be removed

Return

TRUE for success, otherwise FALSE

Examples

EX1

//Output all graph objects after removing first object.
void Layer_RemoveGraphObject_ex1()
{
    // Call this function with a graph window active
    // NOTE: This function removes the first graph object from layer!
    // So first save the project if you want to reload the graph later.
    //
    // Create a Layer object and attach it to the currently active graph layer
    GraphLayer    gly = Project.ActiveLayer();
    if( gly.IsValid() )
    {
        // List all graph objects in layer by their index and name
        GraphObject grobj;
        out_str( "List of all graph objects currently in layer:" );
        foreach( grobj in gly.GraphObjects )
            printf( "   GraphObject index, name: %d, %s\n", grobj.GetIndex(), grobj.GetName() );
        // Now remove the first graph object from the layer and list again
        gly.RemoveGraphObject( 0 );
        out_str( "List of all graph objects after removing first object:" );
        foreach( grobj in gly.GraphObjects )
            printf( "   GraphObject index, name: %d, %s\n", grobj.GetIndex(), grobj.GetName() );        
        // Refresh the graph page
        Page pg = gly.GetPage();
        pg.Refresh();
    }
    else
        out_str( "No graph layer is active" )
}


EX2

 // This function removes the Y-axis title object from layer.
void Layer_RemoveGraphObject_ex2()
{
    // Call this function with a graph window active
   
    // So first save the project if you want to reload the graph later.
    //
    // Create a Layer object and attach it to the currently active graph layer
    GraphLayer    gly = Project.ActiveLayer();
    if( gly.IsValid() )
    {
        // Remove the Y-axis title object 
        gly.RemoveGraphObject( "YL" );
        Page pg = gly.GetPage();
        pg.Refresh();
    }
    else
        out_str( "No graph layer active" );
}

Remark

See Also

Layer::GraphObjects Layer::CreateGraphObject Layer::CreateShapeGraphObjects

Header to Include

origin.h