Specify a datarange from a tree
BOOL SetTree( TreeNode & tr, int nOption = DRTREE_DEFAULT )
TRUE if successful.
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); } } }
origin.h