📄 graph.h
字号:
can refer to the same internal Origin object. The Layout class is derived from the
Layer and OriginObject classes from which it inherits methods and properties.
Example:
// This example assumes Layout1 window with text object named Text
// is active window/layer in Origin
Layout lo; // Declare a Layout object
lo = (Layout) Project.ActiveLayer(); // Attach lo to active Layout (layer); must explicitly cast
GraphObject go ; // Declare a GraphObject
go = lo.GraphObjects("Text"); // Attach go to text object named Text
if(go.IsValid()) // If graph object exists...
printf("Name of GraphObject is %s\n", go.GetName()); // Display its name
*/
class Layout : public Layer
{
public:
/** >Internal Origin Objects
Constructor which constructs a Layout object given the name of a layout window.
The object will be valid if the layout window with the given name exists.
Parameters:
layoutname = the name of a layout window in Origin
Example:
// For this example to run, a layout window with the name "Layout1" must exist in the project.
void run_Layout_Constructor()
{
Layout la("Layout1");
// We can check if the object la is valid (attached to
// an internal Origin layout) by calling the method "IsValid)"
if (la.IsValid())
out_str("Object is valid"); // it should be valid
else
out_str("Object is not valid");
}
*/
Layout(LPCSTR layoutname);
/**
Copy constructor which constructs a Layout object from an existing
Layer object.
The member function IsValid() of the base class OriginObject
can be used to determine if the object is valid (attached to an internal
Origin layout object).
Parameters:
layer = the source Layer object in a layout window
Example:
// For this example to run, a layout window with the name "Layout1" must exist in the project.
void run_Layout_Constructor()
{
// Create an attach a source Layout object:
Layout lay("Layout1");
Layout la(lay);
// We can check if the object la is valid (attached to
// an internal Origin layout) by calling the method "IsValid)"
if (la.IsValid())
out_str("Object is valid");
else
out_str("Object is not valid"); // it should be invalid
}
*/
Layout(Layer & layer);
};
/** >Internal Origin Objects
The Scale class provides methods and properties common to all Origin axis scales.
Two scale objects (one X scale and one Y scale) are contained in each graph layer
on each graph page. An Origin C Scale object is a wrapper object that is a reference
to an internal Origin scale object. Origin C wrapper objects do not actually exist
in Origin and merely refer to the internal Origin object. Consequently, multiple
Origin C wrapper objects can refer to the same internal Origin object. The Scale
class is derived from the OriginObject class from which it inherits methods and
properties.
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Assumes Graph1 window is active.
GraphLayer gl = Project.ActiveLayer(); // Get active layer in project file
if(gl) // If valid graph layer...
{
Scale sc(gl.X); // Get X scale object from graph layer
sc.From = 0.01; // Assign scale from value
sc.To = 1000; // assign scale to value
sc.Type = LOG10_SPACE; // Set axis scale as Log10
sc.Inc = 1; // set axis scale increment to 1
}
*/
class Scale : public OriginObject
{
public:
/**
Default constructor which constructs an unattached Scale object.
The member function IsValid() of the base class OriginObject
can be used to determine if the object is valid (attached to an internal
Origin axis)
Parameters:
None
Example:
void run_Scale_Constructor()
{
// Create an unattached Scale object
Scale s;
if (!s.IsValid())
{
out_str("Invalid Scale object!"); // must be invalid
return;
}
}
*/
Scale();
/**
Copy constructor which constructs a Scale object from another
Scale object.
Parameters:
scale = the source scale object
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
void run_Scale_Constructor()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
if (!gl.IsValid())
{
out_str("No GraphLayer!");
return;
}
// Intialize a Scale object from the X-axis scale of the GraphLayer
// (gl.X is the X-axis scale for the layer attched to "gl").
Scale s(gl.X);
// Display the "From" property:
out_double("From = ", s.From);
}
*/
Scale(Scale & scale);
/**
The "From" property - the left limit of the axis
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
void run_Scale_From()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
if (!gl.IsValid())
{
out_str("No GraphLayer!");
return;
}
// Intialize a Scale object from the Y-axis scale of the GraphLayer
// (gl.Y is the Y-axis scale for the layer attched to "gl").
Scale s(gl.Y);
// Display the "From" property:
out_double("From = ", s.From);
}
*/
double From;
/**
The "To" property - the right limit of the axis
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
void run_Scale_To()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
if (!gl.IsValid())
{
out_str("No GraphLayer!");
return;
}
// Intialize a Scale object from the Y-axis scale of the GraphLayer
// (gl.Y is the Y-axis scale for the layer attched to "gl").
Scale s(gl.Y);
// Display the "To" property:
out_double("To = ", s.To);
}
*/
double To;
/**
The "Inc" property - the major tick increment of the axis
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
void run_Scale_Inc()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
if (!gl.IsValid())
{
out_str("No GraphLayer!");
return;
}
// Intialize a Scale object from the Y-axis scale of the GraphLayer
// (gl.Y is the Y-axis scale for the layer attched to "gl").
Scale s(gl.Y);
// Display the "Inc" property:
out_double("Inc = ", s.Inc);
}
*/
double Inc;
/**
The "Type" property - the axis type. Possible values are:
LINEAR_SPACE - linear
LOG10_SPACE - logarithm base 10
PROB_SPACE - probability
PROBIT_SPACE - probit
RECIPROCAL_SPACE - reciprocal
OFFSET_RECIP_SPACE - offset reciprocal
LOGIT_SPACE - logit
LOGE_SPACE - natural logarithm
LOG2_SPACE - logarithm base 2
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
void run_Scale_Type()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
if (!gl.IsValid())
{
out_str("No GraphLayer!");
return;
}
// Intialize a Scale object from the Y-axis scale of the GraphLayer
// (gl.Y is the Y-axis scale for the layer attched to "gl").
Scale s(gl.Y);
// Display the "Type" property:
out_double("Type = ", s.Type);
}
*/
int Type;
};
/** >Internal Origin Objects
The GraphLayer class provides methods and properties common to all Origin graph
layers. Internal Origin graph pages contain one or more graph layers thus the
Origin C GraphPage class contains a collection of one or more GraphLayer objects.
Origin graph layers may contain Origin data plots thus the Origin C GraphLayer
class contains a collection of DataPlot objects. An Origin C GraphLayer object
is a wrapper object that is a reference to an internal Origin graph layer object.
Origin C wrapper objects do not actually exist in Origin and merely refer to the
internal Origin object. Consequently, multiple Origin C wrapper objects can refer
to the same internal Origin object. The GraphLayer class is derived from the Layer
and OriginObject classes from which it inherits methods and properties.
Example:
// Assumes Graph1 window with one or more data plots is active in Origin
GraphLayer gl = Project.ActiveLayer(); // Get active layer in project file
if(gl) // If valid graph layer...
{
DataPlot dp = gl.DataPlots(0); // Get first data plot in graph layer
dp.SetColor(2); // Change color to green
}
*/
class GraphLayer : public Layer
{
public:
/**
Construct and attach a GraphLayer object based on the name of the graph window
and the layer index
Parameters:
lpcszWinName = the name of the graph window (page)
nLayerNum = (optional) 0-offset index of the layer (use -1
for the active layer)
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Make sure that the window has at least two layers.
// Make layer 2 active before running the function.
void run_GraphLayer_Constructor()
{
// Construct a GraphLayer object and attach it to the second layer of "Graph1" window.
// (note that in the constructor the layer index is 0-offset, so the
// first layer needs index 0)
GraphLayer gl("Graph1", 1);
// Display the index of the layer in graph page
// (note that the index returned from the "GetIndex" method
// is 0-offset, so the first layer will have index 0):
out_int("Layer index = ", gl.GetIndex() + 1);
}
*/
GraphLayer(LPCSTR lpcszWinName, int nLayerNum=-1);
/**
Copy constructor which constructs a GraphLayer object from an existing
Layer object. Note that the existing Layer object must also be in a garph page.
Parameters:
layer = the source Layer object
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Make sure that the window has at least two layers.
// Make layer 2 active before running the function.
void run_GraphLayer_Constructor()
{
// Construct a GraphLayer object and attach it to the second layer of "Graph1" window.
// (note that in the constructor the layer index is 0-offset, so the
// first layer needs index 0)
GraphLayer gl("Graph1", 1);
GraphLayer gl2(gl);
// Display the index of the layer in graph page
// (note that the index returned from the "GetIndex" method
// is 1-offset, so the first layer will have index 1):
out_int("Layer index = ", gl2.GetIndex());
}
*/
GraphLayer(Layer & layer);
/**
Attached a layer in an Origin graph window to the object based on the graph name
and the layer index.
Parameters:
lpcszWinName = the name of an existing Origin graph window
nLayerNum = (optional) the 0-offset index of the layer in the graph window to attach
or -1 for the active layer.
Returns:
TRUE for success, otherwise FALSE.
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Make sure that the window has at least two layers.
// Make layer 2 active before running the function.
void run_GraphLayer_Attach()
{
// Construct a GraphLayer object and attach it to the second layer of "Graph1" window.
// (note that in the constructor the layer index is 0-offset, so the
// first layer needs index 0)
GraphLayer gl("Graph1", 1);
// Display the index of the layer in graph page
// (note that the index returned from the "GetIndex" method
// is 1-offset, so the first layer will have index 1):
out_int("Layer index = ", gl.GetIndex());
// Now attach the first layer:
gl.Attach("Graph1", 0);
// Display the index of the layer in graph page.
// (note that the index returned from the "GetIndex" method
// is 1-offset, so the first layer will have index 1):
out_int("Layer index = ", gl.GetIndex());
}
*/
BOOL Attach(LPCSTR lpcszWinName, int nLayerNum=-1);
/**
Add one data plot to layer
Parameters:
cData = Data curve to add
nPlotID = the internal Origin plot type id..
wCntrl = (optional) not used
Return:
0-offset data plot index of the dataplot added or -1 for error
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Also, a workseet with the name "Data1" and with columns "A" and "B" must
// exist with some numeric data in them.
void run_AddPlot()
{
// Construct the Curve object specifying the x and y datasets to be used for
// the dataplot
Curve cc("Data1_a", "Data1_b");
// the graph layer needs to be initialized:
GraphLayer lay("Graph1");
// Add the dataplot to the graph:
int nIndex = lay.AddPlot(cc, IDM_PLOT_SCATTER);
// Display the index of the data plot just added:
out_int("Dataplot index = ", nIndex);
}
*/
int AddPlot(Curve& cData, int nPlotID = IDM_PLOT_UNKNOWN, int wCntrl = 0);
/**
The method retrieves the layer contents in form of a tree.
*/
#if _OC_VER > 0x0703
/**#
*/
BOOL GetLayerContents(TreeNode &tr, DWORD dwCtrl = 0);
/**#
*/
int AddPlots(TreeNode &tr, DWORD dwOptions = 0);
#endif // _OC_VER
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -