📄 analysis_utils.h
字号:
}
Return:
TRUE if correct layer is found and cuvResult is plotted successfully
*/
bool curve_update(curvebase& cuvResult, const curvebase& cuvInput, const TreeNode& trInput, int nColor, bool bRescale = false);
/** >Curve
It searches for the dataplot containing the given curve. If found, just refreshes the graph page,
otherwise it adds the curve to the first layer of the page.
Parameters:
cuv=[in] the input curve
nColor=[in] nthe color the curve should have.
gpg=[in] the graph page in which to look for the curve.
bRescale=[in] to rescale the layer with the curve or not.
Example:
//This example add curve Data1_B to Graph1.
//For this sample codes to run, Graph1 should exist in the current project.
void run_curve_update_in_page()
{
Curve crvPlotted( "Data1_B" );
GraphPage gp1( "Graph1" );
int nColor = 0; // Black
if(gp1 && crvPlotted)
{
curve_update_in_page(crvPlotted, nColor, gp1);
}
}
Returns:
TRUE if OK, otherwise FALSE.
*/
bool curve_update_in_page(curvebase& cuv, int nColor, GraphPage &gpg, bool bRescale = false);
/** >Curve
It looks for the curve in the graph page.
Parameters:
cuv=[in] the curve to look for
gpg=[in] the graph page to look in.
pnLayerIndex=[in] optional pointer to an integer to receive the index of the layer in which the curve was found
pnDataPlotIndex=[in] optional pointer to an integer to receive the index of the dataplot in the layer if found.
Example:
//This example use function curve_in_page_get_indices() to check whether Data1_B
//exists in Graph1. For this sample to work, Data1_B and Graph1 should exist.
void run_curve_in_page_get_indices()
{
Curve crvPlotted( "Data1_B" );
GraphPage gp1( "Graph1" );
if(crvPlotted && gp1)
{
bool bOK = curve_in_page_get_indices(crvPlotted, gp1);
if(bOK)
{
out_str("Data1_B exists in Graph1.");
}
else
{
out_str("Data1_B does not exist in Graph1.");
}
}
}
Returns:
TRUE if found, otherwise FALSE.
*/
BOOL curve_in_page_get_indices(const curvebase& cuv, const GraphPage &gpg, int *pnLayerIndex = NULL, int *pnDataPlotIndex = NULL);
/** >Curve
It adds the curve cuv to the layer grl.
Parameters:
cuv=[in] the input curve
grl=[in] the layer to add the curve to.
nColor=[in] nthe color the curve should have.
bRescale=[in] to rescale the layer with the curve or not.
nPlotType=[in] the plot type of the curve to add.
Example:
//This example add Data1_B to the first layer of Graph1.
//For this example to run, Graph1 should exist in the current project.
void run_add_curve_to_graph_layer()
{
Curve crvPlotted( "Data1_B" );
GraphLayer gl( "Graph1", 0 );
if(crvPlotted && gl)
{
bool bOK = add_curve_to_graph_layer(crvPlotted, gl);
if(bOK)
{
out_str("Success in adding Data1_B to Graph1.");
}
else
{
out_str("Fail to add Data1_B to Graph1.");
}
}
}
Returns:
TRUE if OK, otherwise FALSE.
*/
bool add_curve_to_graph_layer(curvebase& cuv, GraphLayer &grl, int nColor = 2, bool bRescale = false, int nPlotType = IDM_PLOT_LINE);
/** >Curve
check if Curve is in a graph layer and return its plot index if true
Parameters:
cuv = [in] Curve to test
gl = [in] graph layer to test
Example:
//This example return the index of Data1_B in Graph1.
//For this sample to work, Graph1 and Dataset Data1_B must exist in the project.
void run_curve_in_layer_get_index()
{
Curve crvPlotted( "Data1_B" );
GraphLayer gl( "Graph1", 0 );
if(crvPlotted && gl)
{
int nIndex = curve_in_layer_get_index(crvPlotted, gl);
out_int("The index of Data1_B in Graph1 is ", nIndex );
}
}
Return:
plot index if in layer, or -1 if not
*/
int curve_in_layer_get_index(const curvebase& cuv, const GraphLayer& gl);
/** >Curve
add to TreeNode the X and Y dataset names of the given curve
Parameters:
cuv = [in] Curve to get names from
trNode = [out] tree node to add the needed info
Example:
//This example show the info. of the curve.
//For this sample to work, dataset Data1_B should exist.
#include <tree_utils.h>
void run_set_curve()
{
Curve crvPlotted( "Data1_B" );
Tree trNode;
if(crvPlotted)
{
bool bOK = set_curve(crvPlotted, trNode);
if(bOK)
{
out_tree(trNode);
}
}
}
Return:
TRUE if success
See Also:
set_active_layer
*/
bool set_curve(const curvebase& cuv, TreeNode& trNode);
/** >Graph Window
add to TreeNode the name of the active graph page and the active layer number
Parameters:
trNode = [out] tree node to add the needed info
Return:
TRUE if the active layer is a graphic layer, FALSE if no active graph layer available
See Also:
get_graph_layer
*/
bool set_active_layer(TreeNode& trNode);
/** >Graph Window
retrive the graph layer from the tree node
Parameters:
trNode = [in] tree node that may contains the needed info prepared by set_active_layer
Example:
//This example get the active graph layer.
void run_get_graph_layer()
{
GraphPage gp;
gp.Create();
Tree trNode;
set_active_layer(trNode); //Get the Info. of the active layer
GraphLayer gl = get_graph_layer(trNode);
ASSERT(gp.GetName() == gl.GetPage().GetName());
out_str("The active graph layer is: " + gl.GetPage().GetName() + "(" + gl.GetIndex() + ")");
}
Return:
a valid graph layer if successful
See Also:
set_active_layer
*/
GraphLayer get_graph_layer(const TreeNode& trNode);
/** >Graph Window
set the given layer to be active layer, if page not open, will open it to be active page as well
Parameters:
layr = [in] typically a GraphLayer to be set as active
Example:
GraphLayer gl("Graph1",0);
set_active_layer(gl);
Return:
true if successful
See Also:
set_active_layer
*/
bool set_active_layer(Layer& layr);
/**# >Curve
prepare a treenode with proper info for the given curve
Parameters:
cuvInput = the data curve that we will be using
trInput = a tree branch that has a Range1 branch that we will need to initialize
i1 = beginning drawing range of the cuvInput
i2 = ending drawing range of the cuvInput, inclusive
hWndRet = only if bNeedInit = false, the graph window's handle where the cuvInput is activated
bNeedInit = true will init the trInput node, = false will make use the trInput to activate the graph layer
Example:
//This example prepare the plotting of Data1_B.
//For this sample to run, Data1_B should exist in the project.
void run_set_curve_input()
{
Curve crv("Data1_B");
Tree trInput;
int iBegin, iEnd;
HWND hWndRet;
set_curve_input(crv, trInput, iBegin, iEnd, hWndRet);
out_str("Data1_B will be plotted into "+trInput.Page.strVal);
}
Return:
true if the cuvInput is full range, false if cuvInput has selected subrange.
*/
bool set_curve_input(const curvebase& cuvInput, TreeNode& trInput, int& i1, int& i2, HWND& hWndRet, bool bNeedInit = true);
/** >Curve
duplicate the active curve in the active graph layer so that analysis routine like derivatives and smoothing can be performed on the copied curve
Parameters:
lpcszNewColName = name of the Y column for the copied curve
bReuseIfInWks = option to always create new copy of can reuse if named column is already in the same worksheet as the original
Example:
//This example copy the active curve Data1_B in Graph1.
//For this sample to run, Data1_B and Graph1 should exist.
void run_curve_duplicate_active()
{
Curve crv("Data1_B");
GraphLayer gl("Graph1", 0);
if(crv && gl)
{
add_curve_to_graph_layer(crv, gl); //Add the curve to the graphlayer
set_active_layer(gl); //Set the graphlayer to active
Curve crvCopy = curve_duplicate_active();
if(crvCopy)
{
out_str("Copy successfully.");
}
}
}
Return:
NULL if no active graph layer with active curve found, or if the operation failed
*/
curvebase& curve_duplicate_active(LPCSTR lpcszNewColName = NULL, bool bReuseIfInWks = false);
#endif //_ANALYSIS_UTILS_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -