1.9.5 Accessing Operations


List All Operations

Many recalculating analysis tools, such as the Statistics on Columns dialog, the Nonlinear Curve Fitting dialog, etc., are based on the Operation class. After finishing the whole operation, there will be a lock on the result sheet or result graph. We can list all operations via Project::Operations. The following code is used to get all operations objects and print out the operation names.

OperationManager opManager;
opManager = Project.Operations;

int count = opManager.GetCount();
for(int index=0; index < count; index++)
{		
	OperationBase& op = opManager.GetOperation(index);
	string strName = op.GetName();
	out_str(strName);
}

Check Worksheet if Hierarchy

If you want to check whether a worksheet is a result table sheet, you can check with layer system parameters, as in the following code.

Worksheet wks = Project.ActiveLayer();

bool bHierarchySheet = (wks.GetSystemParam(GLI_PCD_BITS) & WP_SHEET_HIERARCHY);
if( bHierarchySheet )
	out_str("This is a report table sheet");
else
	out_str("This is not a report table sheet");

Accessing Report Sheet

The following code shows how to get a report tree from a report sheet, convert the result gotten from the report tree into a cell linking format string, and put it into a new worksheet.

This is how to get a report tree from a report sheet. To run this code you need keep a report sheet active.

Worksheet wks = Project.ActiveLayer();

Tree trResult;
wks.GetReportTree(trResult);

The following code shows how to get the needed results from the report tree, convert them to a cell linking format string, and put it into a newly created worksheet.

// Add a new sheet for summary table
WorksheetPage wksPage = wks.GetPage();
int index = wksPage.AddLayer();
Worksheet wksSummary = wksPage.Layers(index);	

string strCellPrefix;
strCellPrefix.Format("cell://%s!", wks.GetName());
	
vector<string> vsLabels, vsValues;
// Parameters
vsLabels.Add(strCellPrefix + "Parameters.Intercept.row_label2");
vsValues.Add(strCellPrefix + "Parameters.Intercept.Value");
vsLabels.Add(strCellPrefix + "Parameters.Slope.row_label2");
vsValues.Add(strCellPrefix + "Parameters.Slope.Value");

// Statistics
vsLabels.Add(strCellPrefix + "RegStats.DOF.row_label");
vsValues.Add(strCellPrefix + "RegStats.C1.DOF");
vsLabels.Add(strCellPrefix + "RegStats.SSR.row_label");
vsValues.Add(strCellPrefix + "RegStats.C1.SSR");
	
// put to columns
Column colLabel(wksSummary, 0);
Column colValue(wksSummary, 1);	
colLabel.PutStringArray(vsLabels);
colValue.PutStringArray(vsValues);