2.1.26.50 tree_get_values_with_ids
Description
Walk all nodes, if .ID exists, then add the ID and the value to two vectors vnIDs & vsValues
Syntax
int tree_get_values_with_ids( const TreeNode & trSetting, vector<int> & vnIDs, vector<string> & vsValues, bool bIncludeSub = true, bool bCheckChange = false, int nRepeatBranchID = 0 )
Parameters
- trSetting
- [input] a source tree
- vnIDs
- [output]vector of IDs from tr.
- vsValues
- [output]vector of strVals from tr.
- bIncludeSub
- [input]TRUE or FALSE, if bIncludeSub == TRUE, this function will go through all tree node;
- if not, will just go through the first level.
- bCheckChange
- [input] if true, will check the treenode change or not.
- nRepeatBranchID
- [input] DataID of parent or itself, must > 0 and < MAX_REPEAT_ID_VALUE.
Return
the number of the node have ID
-1 mean the treenode invalid,
-2 when nRepeatBranchID out of range or when nRepeatBranchID is valid and subbranch node dataid out of range.
Examples
EX1
//This example reads values of nodes from TreeNode.ini, and saves user's modifications to this file.
#include <GetNBox.h>
enum{ID_NUMEXP, ID_B, ID_B_T1, ID_B_T2, ID_B_T3, ID_DATARANGE, ID_CURVECOLOR};
void tree_get_values_with_ids_ex1()
{
GETN_TREE(myTree)
GETN_COMBO(numExp, "Number of Terms", 1, "1|2|3") GETN_ID(ID_NUMEXP)
GETN_BEGIN_BRANCH(DecayTime, "Decay Times") GETN_ID_BRANCH(ID_B)
GETN_NUM(decayT1, "1st Decay Time (t1)", 0.0) GETN_ID(ID_B_T1)
GETN_NUM(decayT2, "2nd Decay Time (t2)", 0.0) GETN_ID(ID_B_T2)
GETN_NUM(decayT3, "3rd Decay Time (t3)", 0.0) GETN_ID(ID_B_T3)
GETN_END_BRANCH(DecayTime)
GETN_RANGE(DataRange, "Data Range", 0, 99, 1, 30) GETN_ID(ID_DATARANGE)
GETN_COLOR(FitCurveColor, "Fit Curve color", 1) GETN_ID(ID_CURVECOLOR)
string strFileName = "TreeNode.ini";
vector<int> vnIDs;
vector<string> vsValues;
if( tree_read_values_with_ids(strFileName, vnIDs, vsValues) )
tree_set_values_by_ids(myTree, vnIDs, vsValues);
if(GetNBox(myTree, "Fit Exp Decay", "Fit Exponential Decay 1,2,3"))
{
out_tree(myTree);
tree_get_values_with_ids(myTree, vnIDs, vsValues);
tree_save_values_with_ids(strFileName, vnIDs, vsValues, NULL);
}
}
Remark
See Also
tree_get_values
Header to Include
origin.h
Reference
|