📄 graph.h
字号:
GraphObject grobj;
// Get the graphic object:
grobj = gl.GraphObjects("Rect");
// Display the height:
out_double("DY = ", grobj.DY);
}
*/
double DY;
/**
Width in layer coordinate units of the object
Read access.
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Also, the active layer in the Graph should have a graphic object (such as rectangle) with
// the name "Rect".
void run_GraphObject_Width()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
GraphObject grobj;
// Get the graphic object:
grobj = gl.GraphObjects("Rect");
// Display the width:
out_int("Width = ", grobj.Width);
}
*/
int Width;
/**
Height in layer coordinate units of the object
Read access.
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Also, the active layer in the Graph should have a graphic object (such as rectangle) with
// the name "Rect".
void run_GraphObject_Height()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
GraphObject grobj;
// Get the graphic object:
grobj = gl.GraphObjects("Rect");
// Display the width:
out_int("Height = ", grobj.Height);
}
*/
int Height;
/**
The left coordinate of the object in physical coordinates
Read and Set access
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Also, the active layer in the Graph should have a graphic object (such as rectangle) with
// the name "Rect".
void run_GraphObject_Left()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
GraphObject grobj;
// Get the graphic object:
grobj = gl.GraphObjects("Rect");
// Display the Left property:
out_int("Left = ", grobj.Left);
}
*/
int Left;
/**
The top coordinate of the object in physical coordinates
Read and Set access
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Also, the active layer in the Graph should have a graphic object (such as rectangle) with
// the name "Rect".
void run_GraphObject_Top()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
GraphObject grobj;
// Get the graphic object:
grobj = gl.GraphObjects("Rect");
// Display the Left property:
out_int("Top = ", grobj.Top);
}
*/
int Top;
/**
The attach mode of the object. Possible values are
0 - to Layer
1 - to Page
2 - to axes
Read and Set access
*/
int Attach;
/**
The text of a text label.
Read and Set access
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
void run_GraphObject_Text()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
GraphObject grobj;
// Get the graphic object "YL", which is the
// the left Y-axis title:
grobj = gl.GraphObjects("YL");
// Display its text:
out_str(grobj.Text);
}
*/
string Text;
#if _OC_VER < 0x0750
/**
The name of the graphic object. The name of each object can be seen by
opening the "Label Control" dialog box (using the context menu on the object).
Parameters:
None.
Returns:
the name of the GraphObject.
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
void run_GraphObject_GetName()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
GraphObject grobj;
// Loop over all the graphic objects in the layer and for each of them
// display its name:
foreach (grobj in gl.GraphObjects)
{
out_str(grobj.GetName());
}
}
*/
string GetName();
#endif //_OC_VER < 0x0750
/**#
It extracts into a file an enhanced metafile or device independent bitmap depending on the type of GraphObj.
(which could have been generated, e.g,, by pasting a picture)
Parameters:
lpcszPathName = the path to the file to be created which will contain the enhanced metafile
Return:
TRUE for success
Example:
GraphLayer lay("Graph1");
GraphObject grEMF;
grEMF = lay.GraphObjects("EMF");
BOOL bRet = grEMF.ExtractImageToFile("c:\\myfiles\\myemf.emf");
*/
BOOL ExtractImageToFile(LPCSTR lpcszPathName);
/**#
Get number of nodes of a graph object in graph layer
Parameters:
Return:
Number of Nodes
Example:
GraphLayer gl("Graph1");
foreach(GraphObject gr in gl.GraphObjects)
{
fpoint ptNode;
int iNodes = gr.GetNumOfNodes();
if (iNodes > 1 )
{
printf("Name = %s\n", gr.GetName());
printf("Number of nodes = %d\n", iNodes);
for (int ii = 0; ii < iNodes; ii ++)
{
gr.GetNode(ii,ptNode);
printf("Point %d: X= %f Y = %f\n", ii, ptNode.x, ptNode.y);
}
}
}
*/
int GetNumOfNodes();
#ifdef _POST_ORIGIN7_
/**#
Get each node's coordinate by index
Parameters:
nIndex = the node index
ptNode = return point value of the coordinate
Return:
TRUE for success
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project
// and have a rectangle object in it.
void test1()
{
GraphLayer gl("Graph1");
foreach(GraphObject gr in gl.GraphObjects)
{
fpoint ptNode;
int iNodes = gr.GetNumOfNodes();
if (iNodes > 1 )
{
printf("Name = %s\n", gr.GetName());
printf("Number of nodes = %d\n", iNodes);
for (int ii = 0; ii < iNodes; ii ++)
{
gr.GetNode(ii, ptNode);
printf("Point %d: X= %f Y = %f\n", ii, ptNode.x, ptNode.y);
}
}
}
}
*/
BOOL GetNode(int nIndex, fpoint& ptNode);
#endif //_POST_ORIGIN7_
/**
The type of the graphic object as a string.
Paramaters:
None.
Returns:
the string representing the type of the graphic object.
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
void run_GraphObject_GetObjectType()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
GraphObject grobj;
// Loop over all the graphic objects in the layer and for each of them
// display its type as string:
foreach (grobj in gl.GraphObjects)
{
out_str(grobj.GetObjectType());
}
}
*/
string GetObjectType();
/**#
*/
int GetRegionPoints(vectorbase& vValue);
/**#
*/
int GetRegionPoints(vectorbase& vValue, vector<int>& vI, vector<int>& vJ);
};
/** >Internal Origin Objects
The StyleHolder class provides methods and properties common to all data plot
style holders. An internal Origin data plot style holder is an object used to
store plot type information for a data plot contained in an Origin graph layer.
An Origin C StyleHolder is a wrapper object that is a reference to an internal
Origin StyleHolder 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
StyleHolder class is derived from the GraphObject and OriginObject classes from
which it inherits methods and properties.
Example:
// Assumes Graph1 is active window in Origin
GraphLayer gl = Project.ActiveLayer(); // Get active Origin layer
if(gl) // If layer is valid...
{
StyleHolder sh = gl.StyleHolders(0); // Get first style holder in layer
out_int("Plot type is ", sh.GetPlotId()); // Get plot id
}
*/
class StyleHolder : public GraphObject
{
public:
/**
Example:
// Assumes Graph1 is active window in Origin
GraphLayer gl = Project.ActiveLayer(); // Get active Origin layer
if(gl) // If layer is valid...
{
StyleHolder sh = gl.StyleHolders(0); // Get first style holder in layer
out_int("Plot type is ", sh.GetPlotId()); // Get plot id
}
*/
StyleHolder();
/**
Copy Constructor: The new StyleHolder object created is attached to the internal graphic object
shOriginal was attached to. If shOriginal was invalid (not attached) so will be the new object.
Example:
// Assumes Graph1 exist in Origin
void test_StyleHolder()
{
GraphLayer glMyLayer("Graph1");
StyleHolder shOriginal;
shOriginal = glMyLayer.StyleHolders(0);
StyleHolder shNew(shOriginal);
if (shNew.IsValid())
{
out_str(shNew.GetName());
}
}
*/
StyleHolder(StyleHolder &shOriginal);
/**
*/
string GetDescription();
/**
get the Origin internal plot id.
Parameter:
bBaseID = TRUE if we only care about the graph category, such than line,scatter and line symbol plots will all return IDM_PLOT_LINESYMB
Example:
GraphLayer gl = Application.ActiveLayer();
if(gl)
{
StyleHolder sh = gl.StyleHolders(0);
out_int("plot type is ", sh.GetPlotId());
}
*/
int GetPlotId(BOOL bBaseID = FALSE);
/**
*/
string GetPlotDesignations(DWORD *pdwFlags = NULL);
};
/** >Internal Origin Objects
The DataObjectBase class provides methods and properties common to all data objects. The
Origin C DataObjectBase class is an abstract base class used for polymorphic handling
of DataObject and DataPlot related class types. Consequently, Origin C objects of type
DataObjectBase can not be constructed. Derived classes such as DataObject, Column,
MatrixObject, and DataPlot inherit DataObjectBase class methods and should be used instead.
*/
class DataObjectBase : public OriginObject
{
protected:
/**#
Default constructor which constructs an uninitialized (unattached) DataObject.
The object cannot be used until it is initialized.
Parameters:
None.
Example:
See examples for the methods of this class.
*/
DataObjectBase();
public:
/**
It sets the data (display) range for the object. Not that this range can be smaller than the total range
of data of the underlying dataset if not all data values are shown. For example, in case of a data plot
in a graph, some data points may not have been plotted. Predefined values for i1 and i2 are
SETRANGE_UNCHANGED - leaves corresponding value unchanged
SETRANGE_FULL - use full dataset range. Use this value to turn Autorange on for DataPlots.
Parameters:
i1 = the lower bound of the desired range, zero offset.
i2 = the upper bound of the desired range, zero offset.
bRepaint = TRUE to repaint the object after changing the range, FALSE not to repaint.
Returns:
TRUE for success, FALSE for failure.
Example:
// For this example to run, a graph window with the name "Graph1" must exist in the project.
// Make sure that the graph has at least one data plot and that there are at least ten
// data points in the plot.
// After the function executes, the data plot will show
// only the data points from 5 to 10.
void run_SetRange()
{
// Create and attach a graph layer from "Graph1":
GraphLayer gl("Graph1");
// Get the first data plot in the layer:
DataPlot dp = gl.DataPlots(0);
// Change the display range of the data plot to
// show only points from 5 to 10: (1 offset)
dp.SetRange(4, 9);
}
*/
BOOL SetRange(int i1 = SETRANGE_FULL, int i2 = SETRANGE_FULL, BOOL bRepaint=TRUE);// i2=-1 to indicate the full range at the end
/**
it retrieves the data (display) range for the object
Parameter:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -