////////////////////////////////////////////////////////////////////////////// //文件 PublicFunction.h //主要功能: // //程序编写: 2005-12-07 ///////////////////////////////////////////////////////////////////////////// #pragma once #include "GlobalMark.h" #include "afxdb.h" #include "DrawModel/BaseFunction.h" #define PF_JUDGE_RANGE 0x00000001 //调用CXy的Draw(CXyDC& dc)函数时是否判断元素在显示范围内 #define PF_EMBELLISH_EDIT_CURVE_IN_NAME 0x00000002 //曲线内部上名字的编辑状态 #define PF_CALIBRATE_POINT_ANGLE 0x00000004 //校正点角度 #define PF_CALIBRATE_MARK_ANGLE 0x00000008 //校正符号角度 #define PF_EMBELLISH_EDIT_CURVE_CENTER_NAME 0x00000010 //曲线中心上名字,如圈闭名称等 #define PF_EMBELLISH_EDIT_ALL PF_EMBELLISH_EDIT_CURVE_IN_NAME|PF_EMBELLISH_EDIT_CURVE_CENTER_NAME //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //版本号定义 #define VERSION_2005 2005 #define VERSION_2007 2007 #define VERSION_2008 2008 //与2007相比,仅是在CText类中增加了角度的保存 #define VERSION_2009 2009 //与2008相比,仅是CColorBase中保存时增加了缩放及旋转因子 #define VERSION_2010 2010 //与2009相比,仅是CProjection中保存时增加了是否有带号的参数 #define VERSION_2011 2011 //与2010相比,修改了曲线修饰曲线上名字,增加了曲线中心上名字修饰 #define VERSION_2012 2012 //与2011相比,增加了文件打印模板的保存 #define VERSION_2013 2013 //与2012相比,增加了在曲线修饰中名字、曲线内部写名字、中心上名字增加了字体的读写 // 弧等保存格式进行了改变,增加了曲线宽度及其风格的保存 // 增加了散点类,散点的保存进行了改变 #define VERSION_2014 2014 //CColorBase中增加了m_nFlags的保存 #define VERSION_2015 2015 //增加了Crect矩形保存格式,其完全可以使用曲线的各种修饰 #define VERSION_2016 2016 //增加了波浪线的修饰保存格式、增加了CXy中的m_dScaleFactor变量保存 #define VERSION_2017 2017 //增加了元素类型十字点CrossPoint #define VERSION_2018 2018 //增加了将边框与网格合并到了一起,增加了FGrid与FNetting元素 #define VERSION_2019 2019 //增加剖面颜色的保存, V3.3 #define VERSION_2020 2020 //2010-7-13, V3.5 //增加了分数点、路径充填元素 //修改了字符串保存方式 //曲线符号(箭头)修饰中增加了偏移功能,调整了曲线上名字CCurveName及CCurveCenterName中的偏移保存格式 #define VERSION_2021 2021 // V3.51 //十字点CrossPoint中增加了风格的保存 #define VERSION_2022 2022 //2010-9-7, V3.6 //CMesh中增加了透明度的设置及读写,另外CImageInsert中也增加了透明度显示支持 //CColorBase中增加了透明度、偏移因子的设置及保存,为了对地震剖面颜色及曲面颜色可以设置不同的透明度 //CInserDraw、CInsertDrawRect中增加了对符号扩展风格的保存(除dfb格式外:dfb格式中之前就有) //CFunction2D中修改了逆断层网格的保存格式,增加了网格头及Z值范围的保存,为了与DGrid中的F(x,y)文件格式保存统一 //增加了块元素的读写、显示等 //增加了对CXy对象中制图人、名称、日期的保存 #define CUR_VERSION VERSION_2022//当前版本号 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class AFX_EXT_CLASS CPublicFunction : public CBaseFunction { public: CPublicFunction(void); virtual ~CPublicFunction(void); //#define _AREA_NORTH_LATITUDE 0 //北半球 北纬 //#define _AREA_SOUTH_LATITUDE 1 //南半球 南纬 //#define _AREA_EAST_LONGITUDE 0 //东经 //#define _AREA_WEST_LONGITUDE 1 //西经 //根据经纬度获得指定坐标处的角度 double GetAngleWithBL(CString projection, double x0, double y0, int longitudeSel=0, int latitudeSel=0); CString GetCurrentFile(CString type=_T("Open"), CString context=_T("Path")); CString GetProjectionFormatFile(); CString GetSaveFileName(CString strExt); //根据保存的文件获得指定扩展名的文件名,如图像名,dfg名等(.dfg,.f(x,y),.bmp格式) CString GetImageSaveFileName(CString strExt); CString GetMeshSaveFileName(CString strExt); void SetColorIdea(DWORD colorType); DWORD GetColorIdea(void); void SetColorLimit(int nLimit); int GetColorLimit(void); COLORREF GetColor(long color); int IsCalibratePointAngle(void); int IsCalibrateMarkAngle(void); void EnableCalibratePointAngle(BOOL bEnable); void EnableCalibrateMarkAngle(BOOL bEnable); void Calibrate(int type, void* pValue, double &x, double &y); void Calibrate(CRect8& rect, int type, void* pValue); //修饰曲线类型 BOOL IsCurveTransparent(DWORD type); BOOL IsCurveTransparentSolid(DWORD type); BOOL IsCurveSolid(DWORD type); BOOL IsCurveClose(DWORD type); BOOL IsCurveBezier(DWORD type); BOOL IsCurveBezierClose(DWORD type); BOOL IsCurveSpline(DWORD type); BOOL IsCurveSplineClose(DWORD type); BOOL IsCurveOffset(DWORD type); BOOL IsCurveOffsetSolid(DWORD type); BOOL IsCurveWave(DWORD type); //颜色显示方式(真彩色,灰度,C,M,Y,K,类型定义在CColor中) DWORD __ColorType__; //颜色显示类型 int __ColorLimit__; //黑白色门限值 //CString __CurrentOpenFilePath; //CString __CurrentSaveFilePath; //CString __ImageDefaultDir; //保存文件时的序号 int m_nImageSaveCounter; int m_nMeshSaveCounter; void InitSaveCounter(); CColorBase cd; int m_nExportModeDPI; //导出分辨率选择,0=显示分辨率,1=自定义分辨率 double m_dExportDPI; //自定义分辨率时每英寸显示的点数 void SetExportDPI(int nMode, double dDpi); protected: DWORD m_nFlags; CString m_strErrorInfo; public: //为了编辑曲线内部的名字、曲线中心名字 void* m_pXyCurveEmbellish; //CXy对象 BOOL IsCurveInNameEditState(void); void EnableCurveInNameEditState(BOOL bEnable); BOOL IsCurveCenterNameEditState(void); void EnableCurveCenterNameEditState(BOOL bEnable); BOOL IsJudgeRange(void); void EnableJudgeRange(BOOL bEnable); void PeekMessageLoop(void); //从消息队列中获取消息 void WaitForThreadToTerminate(HANDLE hThread); //等待线程 CString GetImageDefaultDir(void); //BOOL ExecuteSQL(CDatabase& db, LPCTSTR lpStrSQL); CString StringToHex(CString str); //将字符串转换为十六进制串 CString HexToString(CString strHex); //将十六进制串转换为字符串 CString StringToBase64(CString str); CString Base64ToString(CString strBase64); void ExchangeXY(double& x, double& y); //交换坐标 void ExchangeXY(void* pProjection, double& x, double &y); //为CProjection指针对象 void ExchangeXY(CRect8& rect, void* pProjection); //转换到指定投影坐标 void ScaleCoordinate(double& x, double& y, double sx, double sy, int mode); //mode=0:加,1:减,2:乘,3:除 int ReplaceVariable(CString &str, CString strVariableName, CString strVarlableValue); //替换变量值,不区别大小写 short GetVersion(void); void GetScaleSize(CSize8 objSize, CSize8& souSize, CSize8& offsetSize); //将souSize尺寸比例不变缩放到objSize中去 void WriteLine(CFile &fw, LPCTSTR lpstr, int nTabNum = 0); void WriteChar(CFile &fw, LPCTSTR lpstr, int nTimes=1); void WriteDML(CFile& fw, CRect8& rect, CString key=_T("")); void WriteDML_Head(CFile& fw, short ver); void WriteDML_Tail(CFile& fw, short ver); void WritePCG(CFile& fw, CRect8& rect, CString key=_T("")); void WritePCG_Head(CFile& fw, short ver); void WritePCG_Tail(CFile& fw, short ver); int DFD_WriteMemoryBlock(CFile& fw, BYTE* lpData, DWORD nDataLength, LPCTSTR strType); BYTE* DFD_ReadMemoryBlock(CFile& fr, DWORD& nOutDataLength, CString& strType); void SetErrorInfo(LPCTSTR lpszErrorInfo); CString GetErrorInfo(void); double GetLBStep(double stepMinute); //获得经纬度的步长,步长单位为分 // 获取显示小数位数,-1 表示不限制 int GetDisplayPrecision() const; // 设置显示小数位数,负数表示不限制 void SetDisplayPrecision(int precision); private: int m_displayPrecision = -1; }; AFX_INLINE void CPublicFunction::SetColorIdea(DWORD colorType) { __ColorType__=colorType; } AFX_INLINE DWORD CPublicFunction::GetColorIdea(void) { return __ColorType__; } AFX_INLINE void CPublicFunction::SetColorLimit(int nLimit) { __ColorLimit__=nLimit; } AFX_INLINE int CPublicFunction::GetColorLimit(void) { return __ColorLimit__; } AFX_INLINE COLORREF CPublicFunction::GetColor(long color) { return cd.GetColor(color,GetColorIdea(),GetColorLimit()); } extern thread_local CPublicFunction pf; extern "C" AFX_EXT_API bool WINAPI IsKeyDown(UINT nKey); extern "C" AFX_EXT_API CPublicFunction * WINAPI AfxGetPublicFunction();