2.2.4.9.39 DataRange::SetTreeSetTree
Description
Specify a datarange from a tree
Syntax
BOOL SetTree( TreeNode & tr, int nOption = DRTREE_DEFAULT )
Parameters
- tr
- [input]the TreeNode containing the range data
- nOption
- [input]one of the values from the enumeration:
- enum {
- DRTREE_DEFAULT = 0, // multiple ranges are added such that node name is used for the corresponding range name
- DRTREE_ONE_DATA, // like DRTREE_DEFAULT, except that only one data node is considered
- DRTREE_ANOVA_ONE_WAY_RAW, // the tree node passed is appropriate for one-way ANOVA data in raw form
- DRTREE_ANOVA_ONE_WAY_INDEXED, // the tree node passed is appropriate for one-way ANOVA data in indexed form
- DRTREE_ANOVA_TWO_WAY_RAW, // the tree node passed is appropriate for two-way ANOVA data in raw form
- DRTREE_ANOVA_TWO_WAY_INDEXED, // the tree node passed is appropriate for two-way ANOVA data in indexed form
- };
Return
TRUE if successful.
Examples
EX1
//This example need active one or multiple selected xy subranges. Will
//print out the minimum and maximum X and Y values of active worksheet.
void DataRange_Create_Ex2(BOOL bOneData = FALSE)//TRUE means only one range is added to tree. FALSE means add multiple ranges.
{
Worksheet wks = Project.ActiveLayer();
if( wks )
{
Tree trXYSelection;
DWORD dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
init_input_data_branch_from_selection(trXYSelection, dwRules);
out_tree(trXYSelection);
DataRange dr,drSub;
string strRange;
dr.Create();
dr.SetTree(trXYSelection, bOneData);
DWORD dwPlotID; // This is to retrieve DataPlot UID if present
vector vX, vY;
double xmin, xmax, ymin, ymax;
int nNumDatasets = dr.GetNumData(dwRules);
for( int nIndex = 0; nIndex < nNumDatasets; nIndex++ )
{
// Copy data associated with nIndex of dr into vectors using DataRange::GetData
dr.GetData(dwRules, nIndex, &dwPlotID, NULL, &vY, &vX);
// Now we have made a copy of XY data into vectors vX and vY
// so we can do analysis on the data...for example:
vX.GetMinMax(xmin, xmax);
vY.GetMinMax(ymin, ymax);
dr.GetSubRange(drSub, dwRules, nIndex);
strRange = drSub.GetDescription();
printf("%s\nxmin = %g\nxmax = %g\nymin = %g\nymax = %g\n", strRange, xmin, xmax, ymin, ymax);
}
}
}
Remark
See Also
DataRange::GetTree
Header to Include
origin.h
|