📄 project.h
字号:
// test if Script Window open, hide it if yes
if(Project.IsVisible(CWT_SCRIPT_WINDOW))
Project.ShowWindow(CWT_SCRIPT_WINDOW, FALSE);
*/
void ShowWindow(int nWinID=CWT_PROJECT_EXPLORER, BOOL bShow=TRUE);
/**
Creates a DataObject& from DataObject name
Parameters:
name = name of the DataObject
Returns:
A refernce to DataObject (A MatrixObject or Column), if invalid name -- the object is invalid
Examples:
void test_Project_GetDataObject()
{
foreach (string strDatasetName in Project.DatasetNames)
{
DataObject& obj = Project.GetDataObject(strDatasetName);
if(obj.IsValid())
{
printf("Dataset is in some wks/matrix\n", strDatasetName);
}
else
{
printf("Dataset %s is not in any wks/matrix\n", strDatasetName);
}
}
}
*/
DataObject& GetDataObject(LPCSTR name);
/**
Get Dataset information
Parameters:
lpcszDatasetName = name of the Dataset object
bNeedFolderInfo = get folder info, otherwise not
Return:
return value defined in oc_const.h, can be one of the followings
PGDN_PLOTTABLE = 0x0001,
PGDN_IN_WKS = 0x0002,
PGDN_IN_MATRIX = 0x0004,
PGDN_IS_DATASET = 0x0008,
PGDN_LOOSE = 0x0010,
PGDN_FOLDER = 0x0020,
PGDN_FOLDER_SUB = 0x0040
Example:
void test_Project_GetDatasetInfo()
{
DWORD dwInfo;
foreach (string strDatasetName in Project.DatasetNames)
{
dwInfo = Project.GetDatasetInfo(strDatasetName);
printf("Info(Dataset %s) = %d\n", strDatasetName, dwInfo);
}
}
Remarks:
SeeAlso:
*/
DWORD GetDatasetInfo(LPCTSTR lpcszDatasetName, BOOL bNeedFolderInfo = FALSE);
#if _OC_VER > 0x0703
/**#
Finds function in the project by function name, compile and link the file if not ready to be called
Parameters:
lpcszFunctionName = name of function to find
lpcszFileName = Optional, name of file
bCompileDependents = used only if lpcszFileName is supplied; search dependent files and compile and link them as well
Remarks:
If lpcszFileName is NULL FindFunction looks for function in entire workspace
Returns:
Found function
Examples:
// this code demonstrates how FindFunction may be used
// to make function call by means of function pointer
void AddColumns(Worksheet& wks, int nn)
{
if( wks )
{
for( int ii = 0; ii < nn; ii++ )
{
wks.AddCol();
}
}
}
typedef void (*FUNCTYPE)(Worksheet& wks, int nn);
void myFunction()
{
Function fn = Project.FindFunction("AddColumns");
FUNCTYPE pfn = fn;
// it also can be done in one line:
// FUNCTYPE pfn = Project.FindFunction("AddColumns");
if( pfn )
{
Worksheet wks;
wks.Create();
pfn(wks, 5);
}
}
*/
Function FindFunction(LPCSTR lpcszFunctionName, LPCSTR lpcszFileName = NULL, BOOL bCompileDependents = FALSE);
/**#
*/
OriginSettings Settings;
/**#
Loads and compile OriginC file
Parameters:
lpcszFileName = name of file to load and compile
Remarks:
Possible values for result:
0, Compiled successfully
1, File not found
2, Compilation failed
3, File is found but can not be loaded
4, Unable to load and compile internal.c
5, File is already loaded and compiled
7, Unknown error
Returns:
TRUE if compilation either successful or not needed
FALSE otherwise
Example:
Project.Compile("c:\test.c");
*/
BOOL Compile(LPCSTR lpcszFileName, int* lpResult = NULL);
/**#
Loop over all wks and matrix and call its Reset method.
Parameters:
bReduceWksSize = if True, will reset worksheets to 30 rows
bReduceMatrices = if True, will reduce all matrices to 2x2
Returns:
TRUE if reset successful
FALSE otherwise
Example:
Project.Reset();
*/
BOOL Reset( BOOL bReduceWksSize = TRUE, BOOL bReduceMatrices = TRUE );
/**#
Do the same as LabTalk: run -p au; wait for autoupdate to finish
Parameters:
Returns:
TRUE if successful, FALSE otherwise
Example:
Project.Run();
*/
bool Run();
/**
Retrieves Origin object given the object unique ID
Paramteres:
uid - ID of object
Return:
OriginObject if object with unique ID equal to uid passed to function exists
Example:
void run_GetObject()
{
WorksheetPage wks("Data1");
UINT uID = wks.GetUID(TRUE);
Page pg;
pg = (Page)Project.GetObject(uID);
out_str(pg.GetName());
}
*/
OriginObject GetObject(UINT uid);
/**
Begin undo block. After this call any undoable action belongs to the same block.
Do not call it directly, use UndoBlock class instead.
Parameters:
None.
Returns:
None.
*/
void UndoBlockBegin();
/**
End undo block.
Do not call it directly, use UndoBlock class instead.
Parameters:
None.
Returns:
None.
*/
void UndoBlockEnd();
/**
Gets current undo block identifier (ID).
Parameters:
None.
Returns:
Current undo block ID.
*/
int UndoBlockId();
/**
Undo the last block.
Parameters:
None.
Returns:
None.
*/
int Undo();
/**
Create new theme.
Parameters:
None.
Returns:
Tree.
*/
Tree CreateNewTheme();
/**
Updates data plot limits.
Parameters:
tn - tree node as input/output
Returns:
TRUE if success, FALSE if failure
*/
BOOL UpdateDataPlotLimits(TreeNode& tn);
/**
Updates layer rescale.
Parameters:
tnDP - tree node as input which has dataplots
tnLayer - tree node as input/ouput has layer settings and rescale property
Returns:
TRUE if success, FALSE if failure
*/
BOOL UpdateLayerRescale(TreeNode& tnDP, TreeNode& tnLayer);
/**
It provides all the columns (by names or prefixes) that are common between the worksheets whose names are supplied.
If only one worksheet is supplied, all its columns are returned.
Parameters:
worksheets = [in] the names of all the worksheets to consider. They are in the form WksPageName or WksPageName!WksLayerName
columnNames = [out] the names of all the common columns. There are certain restriction on which columns should be considered "common enough" to be included.
columnLabels = [out] the labels from the 1st worksheet for the corresponding columns
bKeepOrder = TRUE if common columns must follow same order as in the first worksheet, FALSE if the order of columns are not important
Returns:
TRUE if successful, FALSE otherwise
Example:
void run_GetCommonColumns()
{
vector<string> wksNames = {"Data1","Data2"};
vector<string> colNames;
vector<string> colLabels;
BOOL bRet = Project.GetCommonColumns(wksNames, colNames, colLabels, FALSE);
}
*/
BOOL GetCommonColumns(const vector<string> &worksheets, vector<string> &columnNames, vector<string> &columnLabels, BOOL bKeepOrder = FALSE);
/**#
Given a plot type, like IDM_PLOT_LINE, return an array of integers containing all possible column plot designations.
Parameters:
nPlotType = [in] the plot type, general plot ID, can be more then the internal basic plot type id
dwAuxTypeInfo = [in] cntrl info about the internal details of the plot type
lpcszColPattern = [in] internal pattern to represent the col designations
vplotdesig= [out] the array integers from the following enumeration:
enum {
COLDESIG_X = 1,
COLDESIG_Y,
COLDESIG_Z,
COLDESIG_LABEL,
COLDESIG_XERROR,
COLDESIG_YERROR,
COLDESIG_YPLUSERROR,
COLDESIG_YMINUSERROR,
COLDESIG_SIZE, // for symbol size in bubble plots
COLDESIG_COLOR, // for symbol color in scatter color plots
COLDESIG_VECTOR_ANGLE, // for vector XYAM plots
COLDESIG_VECTOR_MAGNITUDE // for vector XYAM plots
};
Return:
TURE if success, FALSE if nPlotType is invalid or inconsistent with other arguments
Example:
void run_GetPlotDesignations()
{
DWORD dwAuxTypeInfo;
DWORD dwAuxPlotInfo;
string strColPattern;
int nPlotID = IDM_PLOT_LINE;
int nRet = Project.GetPlotTypeInfo(nPlotID,dwAuxTypeInfo,dwAuxPlotInfo,strColPattern);
vector<uint> vplotdesig;
BOOL bRet = Project.GetPlotDesignations(nPlotID, dwAuxTypeInfo, strColPattern, vplotdesig);
nRet = Project.CheckPlotDesignations(nPlotID,dwAuxTypeInfo,strColPattern,vplotdesig);
}
*/
BOOL GetPlotDesignations(int nPlotType, DWORD dwAuxTypeInfo, LPCTSTR lpcszColPattern, vector<uint> &vplotdesig);
/**#
Given a plot id, like ID_PLOT_DOUBLEY, return the internal plot type like IDM_PLOT_LINE.
Parameters:
nPlotID = [in] typically resource ID in menu
dwAuxTypeInfo = [out] this is internal flags that is needed for other functions like GetPlotDesignations
dwAuxPlotInfo = [out] this is internal flags that is usful when making the plot
strColPattern = [out] string in the form of "XY" to indicate the typical plot designation combinations
SeeAlso:
GetPlotDesignations
*/
int GetPlotTypeInfo(int nPlotID, DWORD& dwAuxTypeInfo, DWORD& dwAuxPlotInfo, string& strColPattern);
/**#
Given a plot type (one of IDM_PLOT_* values), the auxiliary plot type info, a string with col desigs, an array of integers representing plot designations of columns (for those plot types for which the order of columns is important, see #4658, the array of integers will be in the order of columns in worksheet), the arrays of wks. page and layer names, and an array of column names, generate the above tree.
Parameters:
tr = [out] the tree to be generated.
nPlotType = [in] the plot type
dwAuxTypeInfo= [in] auxiliary plot type info
lpcszColPattern = [in] string in the form of "XY" to indicate the typical plot designation combinations
nExVal = [in] extra control info that is used in making a new plot, like to connect data points using spline
vpdesig= [in] the array of plot designations (see #4658)
vsWksPages = [in] the array of wks. page names.
vsLayers = [in] the array of wks. layer names.
vsCols = [in] the array of column names corresponding to vpdesig.
bNoLimits = [in] prevents calculation of data plot limits
Returns:
one of the values from the following enumeration:
enum {
MDPT_SUCCESS = 0,
MDPT_INCOMPLETE, // column designations are not finished for the specified plot type. typically when X or Y is missing
MDPT_WRONG_ORDER // Example: for bubble plots the column that determines the size of symbols must be after the y-column.
};
*/
int MakeDataplotsTree(TreeNode &tr, int nPlotType, DWORD dwAuxTypeInfo, DWORD dwLTPlotInfo, LPCTSTR lpcszColPattern, uint nExVal, const vector<uint> &vpdesig, const vector<string> &vsWksPages, const vector<string> &vsLayers, const vector<string> &vsCols, BOOL bNoLimits);
#endif // _OC_VER > 0x0703
#ifdef _OPERATION_H
/**
*/
OperationBase* NewOperation(LPCSTR lpcszClassName, LPCSTR lpcszPath, BOOL bAddToOperationList = TRUE);
/**
*/
BOOL DeleteOperation(OperationBase* op, BOOL bRemoveFromOperationList = FALSE);
/**
*/
OperationBase & GetOperationObject(UINT uid);
/**
*/
OperationManager Operations;
#endif // #ifdef _OPERATION_H
/**
Turn on/off profiling
Parameters:
bStart = set internal flag to enable/disable profiling for functions.
bResetAll = TRUE, to walk all functions to reset profiling info
Return:
flag value before call.
*/
BOOL Profile(BOOL bStart, BOOL bResetAll = TRUE);
/**
Get internal profiling info
Parameters:
vsFuncNames = internal mangled function names
vnNumCalls = number of times corresponding function was called
vdTimes = total amount of time in seconds the corresponding function was called
Return:
FALSE if no profiling info available
*/
BOOL GetProfileData(vector<string>& vsFuncNames, vector<uint>& vnNumCalls, vector<double>& vdTimes);
};
#if _OC_VER > 0x0703
/** >Internal Origin Objects
The UndoBlock class provides safe access to project functions UndoBlockBegin() and
UndoBlockEnd().
Example:
// get format from Graph1 page
GraphPage pageSrc("Graph1");
Tree tree;
tree = pageSrc.GetFormat();
if( tree )
{
// get undo block ID before any changes
int nIDbefore = Project.UndoBlockId();
// better to limit scope of undo block
{
// start new undo block and save all changes there
UndoBlock block;
// apply format to Graph2 page
GraphPage pageDst1("Graph2");
BOOL bb = pageDst1.ApplyFormat(tree);
// apply format to Graph3 page
GraphPage pageDst2("Graph3");
bb = pageDst2.ApplyFormat(tree);
}
// get undo block ID after all changes
int nIDafter = Project.UndoBlockId();
// undo all changes from the added undo block
Project.Undo();
}
*/
class UndoBlock
{
private:
UndoBlock() {Project.UndoBlockBegin();}
~UndoBlock() {Project.UndoBlockEnd();}
};
#endif // _OC_VER > 0x0703
#endif //_PROJECT_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -