2.2.4.24.3 Layer::CreateShapeGraphObjects

Description

Create multiple shape graphic objects such as polyline, polygon or polypolygon in the layer and put them into different blocks. All the newly created shape graphic objects should be set to attach to Layer and Scale since the coordinates provided are in axes scales.

Syntax

int CreateShapeGraphObjects(
    const vector<double>& vxPos,
    const vector<double>& vyPos,
    const vector<uint>& vShapeIndex = NULL,
    const vector<uint>& vBlockIndex = NULL,
    LPCSTR lpcszBasename = NULL,
    DWORD dwState = GOC_NO_SELECT | GOC_NO_DEL_SEL_PT  | GOC_NO_CONTEXT | GOC_NO_STATE,
    DWORD dwCntrl = CPO_GROUP
    );

Parameters

vxPos
[input] X coordinates of each polygons, appended one after another.
vyPos
[input] Y coordinates of each polygons.
vShapeIndex
[input] indices of datasets vxPos and vyPos, used to indicate the start of a polygon/polyline shape object beginning from 0.
vBlockIndex
[input] indices of dataset vShapeIndex, used to indicate the starting index of shape object in a block beginning from 0. The ending index of shape object in a block is the index of next block minus 1. Eg, if the starting index of current block is 2 and the index of next block is 5, the current block will consists of the 2nd, 3rd, 4th shape graphic objects.
lpcszBasename
[input] if NULL, "poly" will be used as the name base of a shape graphic object. Objects will be created using this namebase plus the index of the object as indicated by vIndex. For example the name of first shape object will be "poly0"
dwState
[input] Graph Object states bits: 1 = GOC_NO_RESIZE, 2 = GOC_NO_ROTATE, 4 = GOC_NO_SKEW, 8 = GOC_NO_EDIT, etc, see more GOC_* in oc_const.h file.
dwCntrl
[input] additional control bits: 1 = CPO_GROUP will group all of the newly created objects. 2 = CPO_POLYLINE to indicate polyline or polypolyline. See more CPO_* in oc_const.h file.

Return

<0 for error codes, otherwise the total number of objects created.

Examples

EX1

//Create 2 polypolygon objects in the active graph.

void Layer_CreateShapeGraphObjects_ex1()
{
    vector<double> vX = {1,1,3,1,1,1,3,1,1,3,5,3,1,3,5,5,3,5,3,5,5};
    vector<double> vY = {1,4,1,1,6,9,9,6,5,8,5,2,5,9,9,6,9,4,1,1,4};
    vector<uint> vShapeIndex = {0,4,8,13,17}; // Create 5 polygons
    vector<uint> vBlockIndex = {0,2}; // Polygon 0,1 in first block and 2,3,4 in second block
 
    GraphPage gp;
    gp.Create();
    GraphLayer gl(gp.GetName(),0);
    int nRet = gl.CreateShapeGraphObjects(vX,vY,vShapeIndex,vBlockIndex,NULL,0,0);
 
    gl.X.From = 0;
    gl.X.To = 6;
    gl.Y.From = 0;
    gl.Y.To = 10;
}

Remark

See Also

Layer::GraphObjects Layer::CreateGraphObject Layer::RemoveGraphObject

Header to Include

origin.h