2.2.4.37.8 PolyPolylineGraphObject::SetPoints


Description

Set points to a drawn shape

Syntax

int SetPoints( vector & vX, vector & vY, int nIndex )

Parameters

vX
[input] X coordinates in world units (axis units)
vY
[input] Y coordinates
nIndex
[input] for poly polygon, index of the polygon

Return

Number of points or -1 for error

Examples

EX1

void SetPoints_ex1()
{
// Assumes the active layer is graph
    GraphLayer gl = Project.ActiveLayer();
    double x1, x2, y1, y2, x0, y0, rr;
    x1 = gl.X.From, x2 = gl.X.To;
    y1 = gl.Y.From, y2 = gl.Y.To;

    PolyPolylineGraphObject go;
    go = gl.CreateGraphObject(GROT_POLYPOLYGON, "PP");
    go.Attach = ATTACH_TO_SCALE;
    
    vector<double> vx, vy; 
    x0 = x1 + (x2-x1) * 0.5;
    y0 = y1 + (y2-y1) * 0.5;
    rr = (x2-x1)/20;
    make_circle(vx, vy, 40, x0, y0, rr);
    int nRet = go.SetPoints(vx, vy, 0);
    
    Tree tr;
    tr.Root.Border.Color.nVal = SYSCOLOR_RED;
    tr.Root.Border.Width.dVal = 0.2;
    
    if(go.UpdateThemeIDs(tr.Root) == 0)
        go.ApplyFormat(tr, true, true);
}
static void make_circle(vector& vx, vector& vy, int nSize, double x0, double y0, double rr)
{
    vx.SetSize(nSize);
    vy.SetSize(nSize);

    double inc = 2.* pi/nSize;
    double ang=0;
    for(int ii = 0; ii <nSize; ii++, ang+= inc)
    {
        vx[ii] = x0 + rr* sin(ang);
        vy[ii] = y0 + rr* cos(ang);
    }
}

Remark

See Also

PolyPolylineGraphObject::GetPoints

Header to Included

origin.h