OriginObject::GetSelection
GetSelection
Description
get current worksheet, matrix or graph layer selection as a DataRange object
Syntax
int GetSelection( DataRange & dr, int * pnMergeCounts = NULL )
Parameters
- dr
- [output] DataRange that is the combination of all the selection ranges in the active layer
- pnMergeCounts
- [output] optional argument to receive the number of ranges that have been combined as a result of this call
Return
if success, return window type EXIST_WKS, EXIST_GRAPH etc
Examples
EX1
// to test
// you can select some data in a graph, or a worksheet
void OriginObject_GetSelection_Ex2()
{
DataRange dr;
int nWinType = Project.GetSelection(dr);
if(nWinType == EXIST_GRAPH)
{
Tree tr;
dr.GetTree(tr, false);
// number of ranges depends on rule, if we assume the case of data plots, then
int nNumRanges = dr.GetNumData(DRR_GET_DEPENDENT | DRR_NO_FACTORS);
out_int("Number of selected dataset = ", nNumRanges);
out_tree(tr);
}
else if(nWinType == EXIST_WKS)
{
Tree tr;
dr.GetTree(tr, false);
// number of ranges depends on rule, if we assume the case of independent columns
int nNumRanges = dr.GetNumData(DRR_NO_FACTORS);
out_int("Number of selected dataset = ", nNumRanges);
out_tree(tr);
}
else
out_int("Project.GetSelection(dr) returns ", nWinType);
}
EX2
// DataRange can be saved into project, but you can destroy it with following code
// first select some data in the graph
// do
// list rng
// you will see the DataRange objects listed
// run this function
// do list rng again
// you should see those ranges deleted
void OriginObject_GetSelection_Ex3()
{
GraphLayer gl = Project.ActiveLayer();
if(!gl)
return;
DataRange dr;
int nWinType = Project.GetSelection(dr);
if(nWinType == EXIST_GRAPH)
{
dr.Destroy();
gl.GetPage().Refresh();
}
}
Remark
See Also
Project::GetDataRange, Project::RemoveDataRange, Project::AddDataRange, DataRange::AddInput
header to Include
origin.h
|