2.2.4.37.1 PolyPolylineGraphObject::AddPolyline
Description
Add one polyline object.
Syntax
int AddPolyline( vector & vX, vector & vY )
Parameters
- vX
- [input] X coordinates in world units (axis units)
- vY
- [input] Y coordinates
Return
Number of points or -1 for error
Examples
EX1
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);
}
}
void AddPolyline_ex1(int nRegNum = 10)
{
GraphPage gp;
gp.Create("origin");
GraphLayer gl = gp.Layers(0);
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;
// Set Label for polypolygon
go.SetDrawOption(POLYPOLYLINE_DRAW_OPTION_NEED_TEXT);
vector<double> vx, vy;
for(int ii = 0; ii < nRegNum ; ii ++)
{
x0 = x1 + (x2-x1) * rnd();
y0 = y1 + (y2-y1) *rnd();
rr = (x2-x1)/50 + rnd() * (x2-x1)/100;
make_circle(vx, vy, 40, x0, y0, rr);
int nn = go.AddPolyline(vx, vy);
}
Tree tr;
tr.Root.Fill.Color.nVal = INDEX_COLOR_TRANSPARENT;
tr.Root.Border.Color.nVal = SYSCOLOR_BLUE;
tr.Root.Border.Width.dVal = 0.2;
if(go.UpdateThemeIDs(tr.Root) == 0)
go.ApplyFormat(tr, true, true);
}
Remark
See Also
PolyPolylineGraphObject::RemovePolyline
Header to Included
origin.h
|