⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utilities.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 3 页
字号:
*/
string InputBox(LPCSTR lpcszMsg, DWORD dwOption = 0);

/** >Character/String Manipulation
		GetDecimalChar is used to return the character used inside Origin for decimal in numbers
	Returns:
		numeric decimal character, typically period('.') or comma(',').
	Example:
		void	run_GetDecimalChar()
		{
			char	chDecimalCharacter = GetDecimalChar();
			
			printf("Decimal character is %c\n", chDecimalCharacter);
		}
*/
char GetDecimalChar();

/** >Memory Management
		Convert the given memory into a hex string with every byte represented by two hexidecimal characters.
	Returns:
		the string for the hex dump.
	Parameters:
		lpcMemory = a memory pointer
		nSize = size of the memory in bytes to convert
		bAddGap = TRUE will add a space character between the hex characters
	Example:
		char szTemp[10] = "A\t\r\n";
		string strDump = GetHexDump(szTemp, 4);
		out_str(strDump);
*/
string GetHexDump(const LPVOID lpcMemory, int nSize, BOOL bAddGap=TRUE);

/** >Origin System
		Get Origin's software path including the last '\\' character.
	Parameter:
		bServerPath = TRUE to get the Origin's program path and to FALSE to get the User Files path.
	Returns:
		A string containing the requested path.
	Example:
		void	run_GetAppPath()
		{
			string strFile = GetAppPath(true) + "originc\\system\\wksheet.h";
			ASSERT(strFile.IsFile());  // system header should be installed only in program path
			strFile = GetAppPath(false) + "originc\\system\\wksheet.h";
			ASSERT(!strFile.IsFile()); // should not have this in user files path
			strFile = GetAppPath() + "origin.ini";
			ASSERT(strFile.IsFile());
		}
	Remarks:
		Origin's program path is typically where Origin's EXE and DLL files are located. In a network version, this is typically
		a remove path on a server computer where the server version of Origin is installed. In a single user installation, this
		is always the location where Origin's EXE and DLL files are installed. Origin C system files are always installed inside
		the program path.
		Origin's User Files path is typically assigned by the user when running Origin for the first time. This is where all the
		files related to a particular customization of Origin is located. You will find origin.ini and other templates and CNF files
		in this location.
*/
string GetAppPath(BOOL bServerPath = FALSE);

/** >User Interface Controls
		Set the text in the Data Display control. The Data Display is usually used for display
		Screen Reader coordinates. This function will also show the Data Display control if it is not already shown
	Parameter:
		lpcszText = text string to set, use NULL to close the Data Display if not docked.
	Returns:
		void
	Example:
		// test hide;// to hide the Data Display control
		// test "what ever";// to put text into Data Display control
		void	test(string str)
		{
			if(str.CompareNoCase("hide")==0)
				SetDataDisplayText(NULL);
			else	
				SetDataDisplayText(str);
		}
*/
BOOL SetDataDisplayText(LPCTSTR lpcszText);

/** >File Management
		Find a file in a given path. 
		If lpSubFolder1st is given (not NULL), then
		A. if bExcluded = FALSE, then find this subfolder first, 
		B. if bExcluded = TRUE, skip this subfolder
	Parameters:
		lpcszName = File name to search for.
		lpPath = on input, the starting path to search for a file. Output, to receive the full path of the file if found.
		lpSubPath = Optional subfolder of the given path(lpPath) to search in.
		bExcluded = whether to skip searching the subfolder (lpSubFolder1st) (FALSE to search it first) 
	Returns:
		If the file is found then TRUE else FALSE.
	Example:
		void	run_FindFile()
		{
			char		szTemp[MAXFULLPATH];
			lstrcpy(szTemp, GetAppPath());
			if(FindFile("APP_UTILS.c", szTemp, "Originlab", FALSE))
			{
				out_str("ok, found it");
				out_str(szTemp);
			}
			else
				out_str("Not found!");
		}
*/
BOOL FindFile(LPCTSTR lpcszName, LPSTR lpPath, LPCTSTR lpSubFolder1st = NULL, BOOL bExcluded = TRUE);

/** >Origin System
		Seach Origin's client and then server path to return the full path name of the specified file
		This function will separately look for server and client path only if Origin is a network version. For single user version,
		this function will simply return the full path from Origin's software path
	Parameters:
		lpcszFileName = File name to search for.
		lpSubPath = Optional subfolder of the Origin software path to search in.
		bLocalized = TRUE if the given file can be localized so that we will need to first try the localization location first
	Returns:
		If the file was found then a string containing the full path file name is returned else an empty string is returned.
	Example:
		void	run_GetFullPath()
		{
			string strFile = "origin.ini";
			string strFullPath = GetFullPath(strFile);
			if( !strFullPath.IsEmpty() )
			{
				string strPath = GetFilePath(strFullPath);
				printf("File %s was found in %s folder.\n", strFile, strPath);
			}
		}
*/
string GetFullPath(LPCSTR lpcszFileName, LPCSTR lpSubPath = NULL, BOOL bLocalized=FALSE);

/** >File Management
		Extracts the path from a full path file name string.
	Parameters:
		lpcszFullPathFileName = Pointer to a string containing a files full path name.
	Returns:
		A string containing only the path portion, including the last '\' character.
		If no path is present then the returned string is empty.
	Example:
		void	run_GetFilePath()
		{
			string	str = "c:\\c\\test.dat";
			string	strFilePath = GetFilePath(str);
			out_str(strFilePath);
		}
*/
string GetFilePath(LPCSTR lpcszFullPathFileName);

/** >File Management
		Extracts the file name from a full path file name string.
	Parameters:
		lpcszFullPathFileName=Pointer to a string containing a files full path name.
		bRemoveExt=TRUE will remove file extension so only the file name part will be returned
	Returns:
		A string containing only the file name with extension or not depending on bRemoveExt.
	Example:
		void	run_GetFileName()
		{
			string	str = "c:\\c\\test.dat";
			string	strFileName = GetFileName(str);
			out_str(strFileName);
		}
*/
string GetFileName(LPCSTR lpcszFullPathFileName, BOOL bRemoveExt=FALSE);

/**	>File Management
		Check the given path to see if is existed, if not, then create all the needed folders
	Parameters:
		lpcszFullPath= full path string to check for making folders
	Returns:
		TRUE if either the path already existed (can call string::IsPath if don't want to waste time).
		FALSE if error occurs when attempting to create the needed folders
	Example:
		void	test_CheckMakePath()
		{
			string	str = GetAppPath() + "junk\\some more junk";
			ASSERT(!str.IsPath());
			if(CheckMakePath(str))
			{
				ASSERT(str.IsPath());
			}
			else
				out_str("err in creating path");
		}
*/
BOOL CheckMakePath(LPCSTR lpcszFullPath);

/**	>File Management
		Rename a file with full path specified for both old and new file names
	Parameters:
		lpcszNewFilename= full path file name to rename to
		lpcszOldFilename = full path file name of the existing file to rename
	Returns:
		TRUE if success
	Remarks:
		The old file name must point to a valid file that can be renamed and the new file name specified 
		must be a full path in the same folder as the original.
	Example:
		void	test_RenameFile()
		{
			string	str = GetAppPath() + "origin.ini";
			CopyFile(str, GetAppPath() + "junk1.ini");
			string strNewName = GetAppPath() + "junk2.ini";
			ASSERT(!strNewName.IsFile());
			RenameFile(strNewName, GetAppPath() + "junk1.ini");
			ASSERT(strNewName.IsFile());
		}
*/
BOOL RenameFile(LPCSTR lpcszNewFilename, LPCSTR lpcszOldFilename);

#if  _OC_VER > 0x0703
/**	>Font
		Get font name.
	Parameters:
		nID = OEM_FIXED_FONT, ANSI_FIXED_FONT, ANSI_VAR_FONT, SYSTEM_FONT, etc
		plfHeight = if not NULL, to receive LOGFONT.lfHeight
	Returns:
		A string containing the font name.
	Remarks:
	Example:
		void	test_GetFontName()
		{
			string	str;
			str = GetFontName(SYSTEM_FONT);
			out_str(str);
		}
*/
string GetFontName(int nID, int* plfHeight);


/**# >Origin System
*/
uint GetOriginClipboardFormat(int nType = 0);

/**# >Origin System
*/
BOOL CopyThemeFromClipboard(LPCSTR lpcszFilename);

/**# >Origin System
*/
BOOL	ApplyFilterToTheme(LPCSTR lpcszSourceThemePathName, LPCSTR lpcszDestinationPathName, DWORD dwPropertiesFilter, DWORD dwObjectsFilter);

/** >Date Time
	convert a Julian date value into a string
	Parameters:
		dDateTime = A Julian date time value, where the integral part represent the Julian Days while the fractional part as fraction of a Day
		wFormat = must be the enumeration LDF_SHORT, LDF_LONG, LDF_ALPHAMONTH_NUMERICDAY, etc
	Returns:
		A string containing the converted date/time.
	Remarks:
	Example:
		void	test_get_date_str()
		{
			SYSTEMTIME st;
			GetSystemTime(&st);              // gets current time
			double dDate;
			SystemTimeToJulianDate(&dDate, &st);
			out_str(get_date_str(dDate, LDF_LONG));
		}	
*/
string	get_date_str(double dDateTime, WORD wFormat = LDF_SHORT_AND_HHMMSS_SEPARCOLON);

/** >System
	get the registry key in the general area for the Origin software
	Parameters:
		bLanguage = TRUE if to get to the subpath for language specific users, which is most typically the case

	Returns:
		A string containing the full path (key) that can be used in the Registry class

	Example:
		#include <settings.h>
		void test()
		{
			Registry reg(HKEY_CURRENT_USER);
			string strUserPath;
			if(reg.GetValue(GetRegKey(), "Path", strUserPath))
				printf("User path is stored as %s\n", strUserPath);
		}
*/
string GetRegKey(BOOL bLanguage = TRUE); 

/** >User Interface Controls
		Display message box.
	Parameters:
		lpcszMessage = Keyword for the text of the message to display.
		iBtnOpts = Message box style; can be one of: OM_RETURN_NOT_PRESENT, OM_RETURN_YNC_CANCEL, OM_RETURN_OK, OM_RETURN_CANCEL, OM_RETURN_YES, OM_RETURN_NO		
		lpcszAuxStr = Optional string - reserved.

	Example:
		BOOL bDelete = FALSE;
  		if ( OM_RETURN_OK == OptionalMessage( "DestroyOperationWithSource", MB_YESNO ) )
			bDelete = TRUE;

	Returns:
		User choice; can be one of: MB_OK, MB_OKCANCEL, MB_YESNO, MB_YESNOCANCEL.

*/
int	OptionalMessage(LPCSTR lpcszMessage, int iBtnOpts, LPCSTR lpcszAuxStr = NULL);

/** >Origin System
	get the path of the temp folder in which the OPJ attached files are placed.		
	Returns:
		empty string is no such path

	Example:
		#include <origin.h>
		
		void test()
		{
			string strPath;
			strPath = GetProjectAttachedFilesPath();
			if(strPath.IsEmpty())
				out_str("Not files attached to project");
			else
				out_str(strPath);
		}
*/
string GetProjectAttachedFilesPath();

/** >System
	launch an application
	Parameters:
		lpApp = module name
		lpArg = Command line.
		bTransferControl = if FALSE and if lpApp is not NULL, this function will not return until the application is terminated 
		bTryWinExec = try the older WinExec function from Windows if the standard method failed.
		
	Returns:
		TRUE if sucess, FALSE if failed

*/
BOOL ExecuteApp(LPCSTR lpApp, LPCSTR lpArg, BOOL bTransferControl = TRUE, BOOL bTryWinExec = FALSE);


/**#
		get name of a data plot from Origin's internal plot ID
	Parameters:
		nPlotType = plot type
		dwAuxPlotInfo = auxiliary plot info.
	Returns:
		plot type name
	Example:
*/
string  GetPlotTypeName(int nPlotType, DWORD dwAuxPlotInfo = 0, DWORD dwLTPlotInfo = 0);
/**#
	Parameters:
		lpcsz = english string
		
	Returns:
		original string if running in English OS, otherwised return localized string
	Example:
*/
string  GetLocalized(LPCSTR lpcsz, LPCSTR lpcszCategory = NULL);
#define _L(_STR)	GetLocalized(_STR) // use this for all literal strings that should be localized	
#define _LC(_STR, _CAT)	GetLocalized(_STR, _CAT)	// must define _CATEGORY at the beginning of the file


/**#
	It handles '|'-separated string.
*/
string  GetLocalizedEx(LPCSTR lpcsz, LPCSTR lpcszCategory = NULL, DWORD dwCtrl = 0);
#define _LB(_STR)	GetLocalizedEx(_STR)		// for bitwise-separated string


/**#
	Parameters:
		lpcszInOut = intput/output theme file 
		lpcszIn = second intput theme file 
		
	Returns:
		TRUE if successfully combined themes, otherwise FALSE
	Example:
*/
BOOL	CombineThemes(LPCSTR lpcszInOut, LPCSTR lpcszIn);

/** >Origin System
	Parameters:
		lpBuffer = Pointer to a string buffer that receives the null-terminated string specifying the temporary file path. 
				   The returned string ends with a backslash, for example, C:\TEMP\.  
		nBufferSize = Specifies the size of the string buffer identified by lpBuffer 
		
	Returns:
		0 = return by WinAPI GetTempPath
		1 = return TEMP folder in Origin ini path
		2 = failure
	Example:
		char szTemp[MAXFULLPATH];
		int nTempPathType = get_temp_path(szTemp, MAXFULLPATH);
		if(0 == nTempPathType)
		{
			printf("Temp path is %s\n which is the standard location and is writable.\n", szTemp);
		}
		else if(1 == nTempPathType)
		{
			printf("For some reason the standard windows temp path is not writable, so we have to use Origin's user files path as the temp path\n%s\n", szTemp);
		}
		else 
			out_str("Error getting a valid temp path");

*/
int get_temp_path(LPSTR lpBuffer, int nBufferSize);

/** >Mathematical
		Similar to LabTalk limit -r command, to round a set of min, max and increment values
	Parameters:
		pmin = pointer to the min value
		pmax = pointer to the max value
		pinc = pointer the the increment value
		nSteps = number of steps to divide the given range roughly defined by pmin and pmax. If you know the increment and do not want it to be changed, pass 0 for steps
		bLogScale = TRUE if the rounding should be done in log scale, otherwise it is rounded in linear scale
	Returns:
		If this function success, the return value is the number of steps determined after the rounding, otherwise a negative value will be returned.
	Example:
		double x1 = -23.4;
		double x2 = 235.89;
		double xinc;
		int nSteps = RoundLimits(&x1, &x2, &xinc);
		printf("After rounding, the result is %d divisions, from %f to %f with an increment of %f\n", nSteps, x1, x2, xinc);
		// we next force increment to a particular value to redo rounding
		xinc = 50;
		nSteps =RoundLimits(&x1, &x2, &xinc, 0);
		printf("Forcing increment to be 50, the result is %d divisions, from %f to %f with an increment of %f\n", nSteps, x1, x2, xinc);
*/
int RoundLimits(double* pmin, double* pmax, double* pinc, int nSteps = 8, BOOL bLogScale = FALSE);

/** >Character/String Manipulation
		Similar to LabTalk $(x) notation, convert a double value into a string using LabTalk formating notation
	Parameters:
		dbVal = value to convert
		lpszOutput = buffer to receive the output
		nOutputSize = size of the buffer
		lpcszFormat = LabTalk formatting string, "*", or "*5*" etc
	Returns:
		None

	Example:
		char szTemp[30];
		DoubleToStr(Pi, szTemp, 30, "*3");
		printf("Pi is %s for only 3 significant digits\n", szTemp);
*/
void DoubleToStr(double dbVal, LPSTR lpszOutput, int nOutputSize, LPCTSTR lpcszFormat);

#endif //_OC_VER > 0x0703

////////////////////////////////////////////////////////////////////
#endif //_UTILITIES_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -