📄 page.h
字号:
Layer lyr;
lyr = pg.Layers(0); // Get first layer in page
if( pg.IsValid() )
{
GraphObject go;
go = lyr.GraphObjects(0); // Get first GraphObject in layer
printf("Name of GraphObject is %s\n", go.GetName());
}
}
*/
class Page : public PageBase
{
public:
/**
Default constructor for a Page object.
Examples:
Page pg;
pg = (Page) Project.Pages(); // Get the project's active page
if( pg.IsValid() )
printf("Active page is of type %d\n", pg.GetType());
else
printf("Active page is invalid\n");
SeeAlso:
Page::Create
*/
Page();
/**
Construct a Page object using the name of an existing page.
Parameters:
lpcszName = The name of an existing page.
Example:
void output_page_type(string strName)
{
Page pg(strName);
if( pg.IsValid() )
printf("Page %s is of type %d\n", strName, pg.GetType());
else
printf("Page %s is invalid\n", strName);
}
void test_output_page_type()
{
MatrixPage mp;
mp.Create("origin.otm");
if( mp.IsValid() )
output_page_type(mp.GetName());
}
SeeAlso:
Page::Create
*/
Page(LPCSTR lpcszName);
/**
Construct a Page object using another Page object.
Parameters:
page = An existing Page object.
Example:
void output_page_type(Page &pg)
{
Page pgTemp(pg);
if( pgTemp.IsValid() )
printf("Page is of type %d\n", pgTemp.GetType());
else
printf("Page is invalid\n");
}
void test_output_page_type()
{
MatrixPage mp;
mp.Create("origin.otm");
if( mp.IsValid() )
output_page_type(mp);
}
SeeAlso:
Page::Create
*/
Page(PageBase &page);
/**
Create a new page using the supplied template and attach it to the object.
The Create method should only be called from derived classes.
Example:
GraphPage gp;
if( gp.Create("origin.otp", CREATE_VISIBLE_SAME) )
printf("Created a graph named %s\n", gp.GetName());
else
printf("Failed to create graph page\n");
Parameters:
lpcszTemplate = The template file name to create the page from.
Pass an empty string or NULL to use the default template.
Pass "0" to create without a template.
iOption = How the window should be created.
Must be one of the following:
CREATE_TEMP = Create invisible and destroy on exit of scope.
CREATE_VISIBLE_SAME = Create with a visibility setting the same as what is stored in the template.
CREATE_VISIBLE = Create visible.
CREATE_HIDDEN = Create the page so it appears hidden in Proejct Explorer.
The following flags can be OR'ed with the above options:
CREATE_NO_REMOVE_TEMPLATEPICT = Do not remove template preview picture (graphic object) on loading.
CREATE_NO_GUI_ACCESS = Do not allow access from Project Explorer (only valid with CREATE_HIDDEN).
Return:
TRUE for success or FALSE for failure.
SeeAlso:
PageBase::PageBase
*/
BOOL Create(LPCSTR lpcszTemplate = NULL, int iOption = CREATE_VISIBLE);
/**
A Collection of all layers in a page
Example:
GraphPage gp;
gp.Create("origin.otp");
if( gp.IsValid() )
{
int iLayers;
foreach(GraphLayer gl in gp.Layers)
iLayers++;
printf("%s has %d layer(s)\n", gp.GetName(), iLayers);
}
*/
Collection<Layer> Layers;
/**
Get a layer object by index.
Parameters:
iIndex = The index of the layer requested to be accessed.
If -1 then the active layer is returned.
Return:
If iIndex is valid then the layer to which the index refers is returned otherwise an invalid layer object is returned.
Example:
// For this example to run, a Graph window must be the active window
// in the project.
void run_Layers()
{
GraphPage gp = Project.Pages();
if( gp)
{
GraphLayer gl = gp.Layers(); // Get active layer
printf("%s has %d layer(s) with active layer %d\n", gp.GetName(), gp.Layers.Count(), gl.GetIndex() + 1); // show LabTalk index
}
}
*/
Layer Layers(int iIndex = -1);
/**
Get a layer object by name.
Parameters:
lpcszName = The name of the Layer requested to be accessed.
Return:
If the name is valid then the layer to which the name refers is returned otherwise an invalid layer object is returned.
Example:
// Assume Book1 is an Excel workbook with a Sheet1
Page pg("Book1");
Worksheet wks;
wks = (Worksheet)pg.Layers("Sheet1");
*/
Layer Layers(LPCSTR lpcszName);
/**
Execute a LabTalk script temporarily setting this page as the active page.
This command is equivalent to LabTalk's "win -o" command.
The original active page is restored after the script completes execution.
Example:
// Output the template name for all the graphs in the project.
foreach(GraphPage gp in Project.GraphPages)
gp.LT_execute("win -g; type \"%h uses template %a\";");
Parameters:
lpcszScript = LabTalk script to execute.
wCtrl = This argument is currently ignored.
Retun:
TRUE for success or FALSE for failure.
*/
BOOL LT_execute(LPCSTR lpcszScript, int wCtrl = 0);
/**
Refresh the page.
Example:
Page pg = Project.Pages();
pg.Refresh(TRUE);// slow refresh, redraw everything from data
Parameters:
bRedraw = indicate if Origin will need to destroy all the internal drawing cache and recreate the graph.
FALSE will tell the page to simply repaint itself using existing cache.
*/
void Refresh(BOOL bRedraw = FALSE);
};
/** >Internal Origin Objects
The MatrixPage class provides methods and properties common to all internal Origin
matrix pages (windows). The Project class contains a collection of MatrixPage objects.
An Origin C MatrixPage object is a wrapper object that is a reference to an internal
Origin matrix page 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 MatrixPage class is derived
from the Page, PageBase, and OriginObject classes from which it inherits methods and
properties.
Example:
// Assumes Matrix1 window exists in Origin
MatrixPage mp;
MatrixLayer ml;
mp = Project.MatrixPages("Matrix1"); // Get Matrix1 page from MatrixPages collection
if(mp) // If mp IsValid...
{
ml = (MatrixLayer) mp.Layers(0); // Get Matrix1 Layer from Layers collection
if(ml) // If ml IsValid...
{
MatrixObject mo(ml,0); // Get first MatrixObject in Layer
if(mo) // If mo IsValid...
{
printf("%s is %d columns x %d rows\n", mp.GetName(), mo.GetNumCols(), mo.GetNumRows() );
}
}
}
*/
class MatrixPage : public Page
{
public:
/**
Construct a MatrixPage object using the name of an existing page.
Parameters:
lpcszName = The name of an existing page.
Example:
MatrixPage mp;
mp.Create("origin.otm");
if( mp.IsValid() )
{
MatrixPage mp2(mp.GetName());
if( mp2.IsValid() )
printf("mp and mp2 are both attached to '%s'\n", mp2.GetName());
}
SeeAlso:
Page::Create
*/
MatrixPage(LPCTSTR lpcszName);
/**
Construct a MatrixPage object using an existing page object.
Parameters:
page = An existing page object.
Example:
MatrixPage mp;
mp.Create("origin.otm");
if( mp.IsValid() )
{
MatrixPage mp2(mp);
if( mp2.IsValid() )
printf("mp and mp2 are both attached to '%s'\n", mp2.GetName());
}
SeeAlso:
Page::Create
*/
MatrixPage(PageBase &page);
};
/** >Internal Origin Objects
The GraphPage class provides methods and properties common to all internal Origin
graph pages (windows). The Project class contains a collection of GraphPage objects.
An Origin C GraphPage object is a wrapper object that is a reference to an internal
Origin graph page 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 GraphPage class is derived
from the Page, PageBase, and OriginObject classes from which it inherits methods and
properties.
Example:
// Assumes Graph1 window exists in Origin
GraphPage gp;
GraphLayer gl;
GraphObject go;
gp = Project.GraphPages("Graph1"); // Get Graph1 page from GraphPages collection
if(gp) // If gp IsValid...
{
gl = (GraphLayer) gp.Layers(0); // Get Graph1 Layer from Layers collection
if(gl) // If gl IsValid...
{
go = gl.GraphObjects(0); // Get first GraphObject in Layer
if(go) // If go IsValid...
{
printf("Name of first GraphObject is %s\n", go.GetName() );
}
}
}
*/
class GraphPage : public Page
{
public:
/**
Construct a GraphPage object using the name of an existing page.
Parameters:
lpcszName = The name of an existing page.
Example:
GraphPage gp;
gp.Create("origin.otm");
if( gp.IsValid() )
{
GraphPage gp2(gp.GetName());
if( gp2.IsValid() )
printf("gp and gp2 are both attached to '%s'\n", gp2.GetName());
}
SeeAlso:
Page::Create
*/
GraphPage(LPCTSTR lpcszName);
/**
Construct a GraphPage object using an existing page object.
Parameters:
page = An existing page object.
Example:
GraphPage gp;
gp.Create("origin.otm");
if( gp.IsValid() )
{
GraphPage gp2(gp);
if( gp2.IsValid() )
printf("gp and gp2 are both attached to '%s'\n", gp2.GetName());
}
SeeAlso:
Page::Create
*/
GraphPage(PageBase &page);
public:
/**
Removes the graph object which is used to store the picture of
what the graph created from the template will look like.
Return:
TRUE for success or FALSE for failure.
Example:
GraphPage gp;
gp.Create("origin.otm");
if( gp.IsValid() )
gp.RemoveTemplatePict();
*/
BOOL RemoveTemplatePict();
/**
Append layers from the supplied template to the page.
Parameters:
lpcszName = Template name
Return:
TRUE for success or FALSE for failure.
Example:
GraphPage gp;
gp.Create();
if( gp.IsValid() )
{
printf("%s has %d layers\n", gp.GetName(), gp.Layers.Count());
gp.AppendLayers("origin");
printf("Now %s has %d layers\n", gp.GetName(), gp.Layers.Count());
}
SeeAlso:
GraphPage::LoadTemplate
*/
BOOL AppendLayers(LPCSTR lpcszName);
/**
Load a template into the page.
Parameters:
lpcszName = Template name
Return:
TRUE for success or FALSE for failure.
Example:
GraphPage gp;
gp.Create();
if( gp.IsValid() )
{
printf("%s has %d layers\n", gp.GetName(), gp.Layers.Count());
gp.AppendLayers("origin");
printf("Now %s has %d layers\n", gp.GetName(), gp.Layers.Count());
gp.LoadTemplate("origin");
printf("Now %s has %d layers\n", gp.GetName(), gp.Layers.Count());
}
SeeAlso:
GraphPage::AppendLayers
*/
BOOL LoadTemplate(LPCSTR lpcszName);
/**
A Collection of all graph layers in a page.
Example:
GraphPage gp;
gp.Create("origin.otp");
if( gp.IsValid() )
{
int iLayers;
foreach(GraphLayer gl in gp.Layers)
iLayers++;
printf("%s has %d layer(s)\n", gp.GetName(), iLayers);
}
*/
Collection<GraphLayer> Layers;
/**
Get a GraphLayer object by index.
Parameters:
iIndex = The index of the layer requested to be accessed.
If -1 then the active layer is returned.
Return:
If iIndex is valid then the layer to which the index refers is returned otherwise an invalid layer object is returned.
Example:
// For this example to run, the graph window with the name "Graph1" must exist
// in the project.
void run_Layers()
{
GraphPage gp("Graph1");
if( gp.IsValid() )
{
GraphLayer gl = gp.Layers(); // Get active layer
printf("%s has %d layer(s)\n", gp.GetName(), gp.Layers.Count());
}
}
*/
GraphLayer Layers(int iIndex = -1);
/**
Get a GraphLayer object by name.
Parameters:
lpcszName = The name of the layer requested to be accessed.
Return:
If the name is valid then the layer to which the name refers is returned otherwise an invalid layer object is returned.
Example:
// For this example to run, the graph window with the name "Graph1" must exist
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -