📄 project.h
字号:
Gets a MatrixPage object by name.
Parameters:
name = pointer to the name of the page.
Returns:
the MatrixPage object with the name name.
Example:
// For this example to run, create a matrix with the name "Matrix1".
void run_Project_MatrixPages()
{
// Get the page by name:
MatrixPage pg = Project.MatrixPages("Matrix1");
// Display the page name:
out_str(pg.GetName());
}
*/
MatrixPage MatrixPages(LPCSTR name);
/**
Gets a GraphPage object by name.
Parameters:
name = pointer to the name of the page.
Returns:
the GraphPage object with the name name.
Example:
// For this example to run, create a graph with the name "Graph1".
void run_Project_GraphPages()
{
// Get the page by name:
GraphPage pg = Project.GraphPages("Graph1");
// Display the page name:
out_str(pg.GetName());
}
*/
GraphPage GraphPages(LPCSTR name);
/**
Gets a LayoutPage object by name.
Parameters:
name = pointer to the name of the page.
Returns:
the LayoutPage object with the name name.
Example:
// For this example to run, create a layout with the name "Layout1".
void run_Project_LayoutPages()
{
// Get the page by name:
LayoutPage pg = Project.LayoutPages("Layout1");
// Display the page name:
out_str(pg.GetName());
}
*/
LayoutPage LayoutPages(LPCSTR name);
/**
The Active Curve in the active layer of the active page(window)
Remark:
Dataset, Curve and Matrix are different kinds of objects when compared with other
Origin objects. Layers and Pages etc are pure wrapper classes for internal Origin
objects so that you can make assignment between them and they will still be
referencing the same internal Origin object. For example, both gg1 and gg2 below
are the same thing
GraphLayer gg1 = Layer("Graph1");
GraphLayer gg2;
gg2 = gg1;// having two reference object to the same internal layer in Origin
On the other hand, Datasets and Curves and Matrix are wrapper for data objects inside
Origin and the assigment between them are interpreted as arithmetic assignments, so
Curve cc("data1_a", "data1_c");
Curve dd("data1_a", "data1_d");
dd = cc;// put all values from Y column of cc into Y column of dd
Due to this reason, you cannot do things like
Curve cc = Project.ActiveCurve();
but rather, you should use Project.ActiveCurve directly or use the "using" notation.
Parameters:
None.
Returns:
the active Curve object
Example:
// For this example to run, create a graph with at least one dataplot.
void run_Project_ActiveCurve()
{
using cc = Project.ActiveCurve();
if(cc.IsValid())
{
Dataset xd;
printf("Active dataset is %s",cc.GetName());
if(cc.AttachX(xd, FALSE))
printf(", its corresponding X dataset is %s",xd.GetName());
printf(".\n");
}
else
out_str("There is no active dataset");
}
*/
Curve ActiveCurve();
#ifdef _CURVE_BASE
/**
*/
curvebase& ActiveCurveBase();
#endif// _CURVE_BASE
/**
It returns the active Layer object. The active Layer object corresponds to the
active layer in the active window (graph, worksheet, matrix, or layout).
Parameters:
None.
Returns:
The active Layer object.
Example:
// For this example to run, create a graph window with one or more dataplots.
void run_Project_ActiveLayer()
{
GraphLayer gl = Project.ActiveLayer();
if(gl)
{
printf("The current layer has %d plots\n", gl.DataPlots.Count());
}
else
out_str("There is no active window or it is not a graph window");
}
*/
Layer ActiveLayer();
/**
the root folder of the project.
Example:
void run_Project_RootFolder()
{
// Get the root folder:
Folder fld = Project.RootFolder;
// Get the name:
string strRoot = fld.GetName();
// Display the name:
out_str(strRoot);
}
*/
Folder RootFolder;
/**
Gets the active folder in the project.
Parameters:
None.
Returns:
the active Folder object.
Example:
// For this example to run, create a few folder in the project
// using Project Explorer. Make one of the new folders active.
void run_Project_ActiveFolder()
{
// Get the active folder:
Folder fld = Project.ActiveFolder();
// Get the name:
string strName = fld.GetName();
// Display the name:
out_str(strName);
}
*/
Folder ActiveFolder();
/**
Find the folder that contains the page with the given name, and return the folder.
Paramaters:
lpcszWindowName = the name of the page.
Returns:
the Folder containing the page with the name lpcszWindowName.
Example:
// For this example to run, create a folder in the project and make
// sure that the folder contains a graph with the name "Graph1".
void run_Project_GetFolderWithPage()
{
Folder fld = Project.GetFolderWithPage("Graph1");
if (fld.IsValid()) // if the page was found
{
// Display the name of the folder containing the page (window) "Graph1".
out_str(fld.GetName());
}
else // the page was not found
out_str("The page was not found!");
}
*/
Folder GetFolderWithPage(LPCSTR lpcszWindowName);
/**
Find the folder that contains a given page.
Paramaters:
page = the page.
Returns:
the Folder containing the page.
Example:
// For this example to run, create a folder in the project and make
// sure that the folder contains a graph with the name "Graph1".
void run_Project_GetFolderWithPage()
{
Page pg("Graph1");
Folder fld = Project.GetFolderWithPage(pg);
if (fld.IsValid()) // if the page was found
{
// Display the name of the folder containing the page (window) "Graph1".
out_str(fld.GetName());
}
else // the page was not found
out_str("The page was not found!");
}
*/
Folder GetFolderWithPage(PageBase &page);
/**
Set the project's active folder. Specified path can be relative or absolute and is not case sensitive.
Parameters:
lpszPath = the path to the folder to be activated. The path can be absolute, in which
case it has to start with the '/' character denoting the root folder, and
each subfolder is separated by a '/' character (example: "/mysub/musubsub")
or it can be relative to the current active folder, in which case the path
must not start with '/' (example: "mysub/mysubsub" where "mysub" is the subdolder
within the current active folder).
Returns:
TRUE for success, otherwise FALSE.
Example:
// For this example to run, create a subfolder named "MySub" in the project's root folder.
// Make sure that the root folder is active.
// After the function executes, "MySub" will be the active folder.
void run_Project_ActivateFolder()
{
string strPath = "/MySub";
if (Project.ActivateFolder(strPath))
out_str("Folder activation succeeded.");
else
out_str("Folder activation failed!");
}
Return:
TRUE for success.
*/
BOOL ActivateFolder(LPCSTR lpszPath);
/**
Gets the name of the project.
Parameters:
None.
Returns:
the name of the project.
Example:
void run_Project_GetName()
{
printf("The name of the project is %s\n", Project.GetName());
}
*/
string GetName();
/**
Gets the path of the file corresponding to the project. If the project has never been saved
before, the path will be empty.
Parameters:
None.
Returns:
the path to the project file.
Example:
// For this example to run, make sure that you have saved the current project
// at least once, or that the current project has been loaded from a file.
void run_Project_GetPath()
{
printf("The path of the project is %s\n", Project.GetPath());
}
*/
string GetPath();
/**
Open a new project. Current project will be closed and replace with the new one if successful
Parameters:
lpcszFilename = Origin project name. OPJ extension must be included with full path, if lpcszFilename=NULL, an empty project will be open, so using NULL
has the same effect as creating a new project
bOpenReadOnly = TRUE to open project as ReadOnly. If lpcszFilename is a ReadOnly file, then project will be open as ReadOnly automatically.
Return:
TRUE for success, this method will check file existence before attempting to open, so will immediately return FALSE if file does not exist
Example:
// For this example to run, make sure that the variable strPathName inside
// the function is initialized to the pathname of an existing project file.
void run_Project_Open()
{
string strPathName = "c:\\myproject.opj";
if (Project.Open(strPathName))
out_str("Project opening succeeded.");
else
out_str("Project opening failed!");
}
*/
BOOL Open(LPCSTR lpcszFilename = NULL, BOOL bOpenReadOnly = FALSE);
/**
Save the active project.
Parameters:
lpcszFilename = The path and name of the file to save to. If NULL then save to the current path using the project's current name.
Returns:
TRUE for success, otherwise FALSE.
Example:
void run_Project_Save()
{
string strPathNameToSave = "c:\\myproj.opj";
if (Project.Save(strPathNameToSave))
out_str("Project saving succeeded.");
else
out_str("Project saving failed!");
}
*/
BOOL Save(LPCSTR lpcszFilename = NULL);
/**
Test if the active project has been modified since the last saving or loading.
Parameters:
None.
Return:
TRUE if the active project has been modified else FALSE.
Example:
// For this example to run, create a project, save it, and then modify it
// (for example by modifying the value in a worksheet cell).
void run_Project_IsModified()
{
if (Project.IsModified())
out_str("Project has been modified");
else
out_str("Project has NOT been modified");
// Now save the project:
Project.Save();
// Now it must be NOT modifed because we saved it above.
if (Project.IsModified())
out_str("Project has been modified");
else
out_str("Project has NOT been modified");
}
*/
BOOL IsModified();
/**
Mark the active project as not modified. This is usually done before exiting
or before loading another project in order to avoid the prompt asking the user
to save it.
Parameters:
None.
Returns:
void
Example:
// For this example to run, create a project, save it, and then modify it
// (for example by modifying the value in a worksheet cell).
void run_Project_ClearModified()
{
if (Project.IsModified())
out_str("Project has been modified");
else
out_str("Project has NOT been modified");
// Now clear the modified flag:
Project.ClearModified();
// Now it must be NOT modifed because we cleared it above.
if (Project.IsModified())
out_str("Project has been modified");
else
out_str("Project has NOT been modified");
}
*/
void ClearModified();
/**
Get Drag-and-Drop information for the last dropped file..
Parameters:
strWinName = The string that will receive the name of the window that the files were dropped on. If not dropped on a window then the string will be blank.
iWinLayer = The index of the window's layer that the files were dropped on.
iFileIndex = The index of the dropped file currently being handled.
iFileCount = The number of files that were dropped.
strFileName = The string that will receive the file name of the dropped file.
Example:
void OCTestDragDrop()
{
string strWinName, strFileName;
int iWinLayer, iFileIndex, iFileCount;
BOOL b = Project.GetDragDropInfo(strWinName, iWinLayer, iFileIndex, iFileCount, strFileName);
if( b )
{
printf("Project.DragDropInfo\n");
printf(" WinName = %s\n", strWinName);
printf(" Layer = %d\n", iWinLayer);
printf(" Index = %d\n", iFileIndex);
printf(" Count = %d\n", iFileCount);
printf(" FileName= %s\n", strFileName);
}
}
*/
BOOL GetDragDropInfo(string &strWinName, int &iWinLayer, int &iFileIndex, int &iFileCount, string &strFileName);
/**
Check a control window to see if it is currently shown.
Remarks:
Origin's control windows are those that you can access from the View menu, like Project Explorer, Script Window etc.
Parameters:
nWinID = Control window's ID, can be one of the followings
CWT_PROJECT_EXPLORER,
CWT_SCRIPT_WINDOW,
CWT_CODE_BUILDER,
CWT_RESULTS_LOG,
Examples:
BOOL bOK = Project.IsVisible(); // return TRUE if Project Explorer is Open.
*/
BOOL IsVisible(int nWinID=CWT_PROJECT_EXPLORER);
/**
Show/Hide the sepcified control window.
Parameters:
nWinID = Control window's ID, can be one of the followings
CWT_PROJECT_EXPLORER,
CWT_SCRIPT_WINDOW,
CWT_CODE_BUILDER,
CWT_RESULTS_LOG,
bShow = TRUE, show the window, otherwise, hide the window.
Examples:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -