1.17.3 Picking Points from a Graph

The Origin C GetGraphPoints class is used to pick points from the curve on the Graph window. This class has virtual methods to allow the user to derive from it to overload methods.

The following example shows how to use the GetGraphPoints class to pick two points from a Graph.

GetGraphPoints mypts;

// Set as true , the cursor moves along the DataPlot and picks points from
// the curve.
// Set as false, the cursor does not move along the DataPlot, and picks
// points from the screen.
mypts.SetFollowData(true, dp.GetIndex());

// To pick point from the specified Graph by GraphLayer object(gl)
int nPts = 2; // the number of the points to pick
mypts.GetPoints(nPts, gl);

// Get the x/y data and indices from the picked points
vector vx, vy;
vector<int> vnPtsIndices, vnPlotIndices;
if( mypts.GetData(vx, vy, vnPtsIndices, vnPlotIndices) == nPts )
	for(int ii = 0; ii < vx.GetSize(); ii++)
		printf("point %d: index = %d, x = %g, y = %g, on plot %d\n", 
			ii+1, vnPtsIndices[ii], vx[ii], vy[ii], vnPlotIndices[ii]+1);