2.2.4.8.10 DataPlot::GetDataPoints

Description

Given DataPlot data index range and get corresponding data point values.

Get data points that are inside the enclosed graphic object.

Syntax

int GetDataPoints( int nrFrom, int nrTo, vector& vx, vector& vy, vector& vz = NULL, vector& vErr = NULL, DWORD dwCntrl = 0, int nPts = 800 )

int GetDataPoints( OriginObject & obj, vector & vx, vector & vy, vector<int> * pIndeces = NULL, DWORD dwCtrl = 0 )

Parameters

nrFrom
[input] 0 offset begin index to the data in the data plot.
nrTo
[input] 0 offset end index to the data in the data plot.
vx
[output] if not NULL, to receive the X values.
vy
[output] if not NULL, to receive the Y values.
vz
[output] if not NULL, to receive the Z values if DataPlot has Z values, or NANUM.
vErr
[output] reserved parameter, for later use.
dwCntrl
[input] to control the internal details, can be bits in GETDATAPTSCTRL.
nPts
[input] number points of speed mode, only used when bit GETDATAPTS_SPEED_MODE is specified.

obj
[input] a graph object like a rectangle or a polygon
vx
[output] x coordinates of the found points
vy
[output] y coordinates of the found points
pIndeces
[output] indexes of the found points
dwCtrl
[input] enum as GDPS_*. If set as GDPS_AFTER_MASK, can get masked points as missing values, if set as GDPS_CHECK_EDGE, will include boundary points.

Return

Number of non-NANUM values if success. NANUM values are stored in the various vectors. Negative error codes are returned if error.

number of data points found or < 0 for error codes

Examples

EX1

void DataPlot_GetDataPoints_Ex1()
{
	//make sure there exists a graph with dataplots on it before running this code.
	GraphLayer gl = Project.ActiveLayer();
	if ( gl )
	{
		DataPlot dp = gl.DataPlots(0); //get the first dataplot on graphlayer
		if ( dp )
		{
			vector vX, vY;
			dp.GetDataPoints(0, -1, vX, vY);
			vector<string> vsX, vsY;
			convert_double_vector_to_string_vector(vX, vsX, vX.GetSize());
			convert_double_vector_to_string_vector(vY, vsY, vY.GetSize());
			string strXData, strYData;
			strXData.SetTokens(vsX, ',');
			strYData.SetTokens(vsY, ',');
			printf("All X points in dataplot is : %s\n", strXData);
			printf("All Y points in dataplot is : %s\n", strYData);
		}
	}
	
}

EX2

// For this example to run, a graph window must exist in the project.
// Also, the active layer in the Graph should have a graphic object (such as rectangle) with
// the name "Rect" which covers some data points
void    DataPlot_GetDataPoints_ex2()
{
    // Create and attach a graph layer from current Graph:
    GraphLayer        gl = Project.ActiveLayer();
    

    DataPlot dp = gl.DataPlots(0); //get the first dataplot on graphlayer
    if ( dp )
    {
        GraphObject grobj = gl.GraphObjects("Rect");
        vector vX, vY;
        vector<int> vnIndeces;
        dp.GetDataPoints(grobj, vX, vY, &vnIndeces);
        
        vector<string> vsX, vsY;
        convert_double_vector_to_string_vector(vX, vsX, vX.GetSize());
        convert_double_vector_to_string_vector(vY, vsY, vY.GetSize());
        string strXData, strYData;
        strXData.SetTokens(vsX, ',');
        strYData.SetTokens(vsY, ',');
        printf("All X points in dataplot is : %s\n", strXData);
        printf("All Y points in dataplot is : %s\n", strYData);
    }
 
}

Remark

See Also

DataPlot::GetDataPoint

Header to Include

origin.h