Files
envi-code/SourceCode/Code2026/shsTK/BaseFunc.h
T
2026-09-28 15:28:50 +08:00

166 lines
6.1 KiB
C++

#pragma once
const double PI = 4*atan(1.0);
class LayerParam;
namespace BaseFuncs
{
void CAD_GetVarInt(CString sMode, int &nRet);
void CAD_SetvarInt(CString sMode, int nRet);
BOOL DeleteEnt(AcDbObjectId EntId);
BOOL ClearAcadCmdLine();
BOOL AddEntToDb(AcDbEntity *pEnt, AcDbObjectId &EntId, AcDbObjectId OwerId = NULL);
void CAD_SendStringToExecute(CString szCommand, bool bAutoReturn = TRUE);
void dist_ent_highlight(AcDbObjectId EntId);
void dist_ent_highlight(AcDbObjectIdArray EntIds);
void dist_ent_unhighlight(AcDbObjectId EntId);
void dist_ent_unhighlight(AcDbObjectIdArray EntIds);
void JxString(CString str, CString strFg, CStringArray &strArr);
BOOL FindStringInArr(CStringArray &strArr, CString str, int &nIndex);
void GetSubDir(CString sDirPath, CStringArray &sSubPathArr);
void GetFileNameByDir(CString sDirPath, CString sExt, CStringArray &sFileNameArray);
void DrawD(AcDbObjectId &PlineId, BOOL bAutoClose = False);
void GetBulge(AcGePoint3d pt1, AcGePoint3d pt2, AcGePoint3d pt3, double &dBulge);
void CAD_GetVarReal(CString sMode, double &dReal);
void CAD_SetvarReal(CString sMode, double dReal);
BOOL GetPlAngle(AcDbObjectId PlId, double &dAngle);
void ClosePline(AcDbObjectId PlineId);
Adesk::Boolean polyWindingNumber(AcDbObjectId polyId, int &winding);
Adesk::Boolean polyWindingNumber(AcDbPolyline *&pPoly, int &winding);
BOOL InSertBlockFromDwgToCurDb(CString sDwgPath, CString sBlockName, AcDbObjectId &BlockId);
void SSToIds(ads_name ssName, AcDbObjectIdArray &EnIds);
BOOL FindStringInArr(const CStringArray &strArr, CString str, int &nIndex);
void dist_blkrcd_getbyRef(AcDbObjectIdArray BlfIds, AcDbObjectIdArray &RcdIds, CStringArray &strArr);
BOOL dist_dwg_ReadDiction(CString &sXDList, CString sDicName, CString sRecName);
BOOL dist_dwg_WriteDiction(CString sXDList, CString sDicName, CString sRecName);
BOOL GetColorIndex(CString sColor, unsigned long &nColor);
void GetSoftPath(CString &sSoftPath);
void dist_blkrcd_insert(AcDbDatabase *pDb, AcDbObjectIdArray BlcokIds, AcDbDatabase *pOrgDb = NULL);
void dist_blkrcd_insert(CString strFilePath, AcDbObjectIdArray BlcokIds, AcDbDatabase *pOrgDb = NULL);
void dist_ent_getminmaxpt(AcDbObjectIdArray GroupIds, AcGePoint3d &ptMin, AcGePoint3d &ptMax);
BOOL GetEntExt(AcDbObjectId EntId, AcGePoint3d &ptMax, AcGePoint3d &ptMin);
void dist_ss_ToIds(ads_name ssName, AcDbObjectIdArray &EnIds);
BOOL GetEntExt(AcDbEntity *pEnt, AcGePoint3d &ptMax, AcGePoint3d &ptMin);
void GetPathName(CString &sSoftPath);
HBITMAP BitmapFromDib(HANDLE hdib, HPALETTE hpal);
HANDLE readDibFromMemory(LPVOID pDibSrc);
WORD PaletteSize(VOID FAR *pv);
WORD DibNumColors(VOID FAR *pv);
void makeHatch3(CString sHatchName, AcDbObjectIdArray ExtIds, AcDbObjectIdArray DftIds, int nColor, double dAngle = 0.0, double dScale = 1.0);
BOOL GetAttdefByBlockIdNew(AcDbObjectId BlockId, CStringArray &strTags, CStringArray &strPromts, CStringArray &strContents);
BOOL GetBlockCommand(CString sDwgPath, CString sBlockName, CString &sCommand);
BOOL GetColorIndex(CString sTextPath, CString sKey, int &nRcolor, int &nGcolor, int &nBcolor);
BOOL GetBlockId(CString sDwgFilePath, AcDbObjectId &BlockId);
BOOL RenameBlock(CString sDwgName, CString sOldName, CString sNewName);
BOOL RenameBlock(AcDbDatabase *&pDb, CString sOldName, CString sNewName);
void InsertBlockRef1(AcDbObjectId BlockId, AcDbObjectId &BlockRefId, AcGePoint3d ptInsert,
AcGeScale3d scale, double dAngle, BOOL bCreate = TRUE);
BOOL GetBlockCommand(CString sDwgPath, CString sBlockName, CString &sCommand);
BOOL GetJd(AcGePoint3d pt1, AcGePoint3d pt2, AcGeVector3d vt, AcGePoint3d ptOut, AcGePoint3d &ptJd);
void GetInIFolderAndIcon(CString sIniName, CStringArray &sFolderArr, CStringArray &sBigIconArr, CStringArray &sSmllIconArr);
void JxString(CString str, CStringArray &strArr);
BOOL GetJd(AcGePoint3d pt1, AcGePoint3d pt2, AcGeVector3d vt, AcGePoint3d ptOut, AcGePoint3d &ptJd);
void CAD_FlushAcadGraphicsQueue();
BOOL InSertBlockFromDwgToCurDb(CString sDwgPath, CString sBlockName, AcDbObjectId &BlockId);
void DrawBlockFun();
BOOL GetLayerParam(CString sAppName, CString sLayerName, LayerParam &pm);
void CreateLineType(CString sLineTypeName, AcDbObjectId &LineTypeId);
void GetLineTypeId(CString sLineTypeName, AcDbObjectId &LineTypeId);
AcDbObjectId CreateLayer(CString sAppName, CString sLayerName);
bool IsMMUnitForDwg();
void OpenTkAndSelectByName(LPCTSTR pszFolder, LPCTSTR pszDwg);
void updateBlockIcon();
}
namespace BaseFuncs
{
class LayerParam
{
public:
LayerParam()
{
CString strColor;
sKey = "";
sLayerName = "";
nColorIndex = 0;
dLineWidth = 0.0;//Ïß¿í¶È
sLineType = "";//ÏßÐÍ
bClose = FALSE;
bFreeze = FALSE; //¶³½á
bvpdflt = FALSE;
bLock = FALSE; //Ëø¶¨
}
~LayerParam()
{
}
LayerParam(const LayerParam &layer)
{
strColor = layer.strColor;
sKey = layer.sKey;
sLayerName = layer.sLayerName;
nColorIndex = layer.nColorIndex;
dLineWidth = layer.dLineWidth;//Ïß¿í¶È
sLineType = layer.sLineType;//ÏßÐÍ
bClose = layer.bClose;
bFreeze = layer.bFreeze; //¶³½á
bvpdflt = layer.bvpdflt;
bLock = layer.bLock; //Ëø¶¨
}
LayerParam &operator = (const LayerParam &layer)
{
strColor = layer.strColor;
sKey = layer.sKey;
sLayerName = layer.sLayerName;
nColorIndex = layer.nColorIndex;
dLineWidth = layer.dLineWidth;//Ïß¿í¶È
sLineType = layer.sLineType;//ÏßÐÍ
bClose = layer.bClose;
bFreeze = layer.bFreeze; //¶³½á
bvpdflt = layer.bvpdflt;
bLock = layer.bLock; //Ëø¶¨
return *this;
}
CString sKey;
CString sLayerName;
int nColorIndex;
double dLineWidth;//Ïß¿í¶È
CString sLineType;//ÏßÐÍ
BOOL bClose;
BOOL bFreeze; //¶³½á
BOOL bvpdflt;
BOOL bLock; //Ëø¶¨
CString strColor;
};
typedef CArray<LayerParam, LayerParam>CLayerParamArray;
class CLayer
{
public:
CLayer(CString sAppName, CString sLayerName, BOOL bRet = TRUE);
~CLayer();
AcDbObjectId m_OldId;
BOOL m_bRet;
};
class CDistOsMode
{
public:
CDistOsMode(int nVarInt)
{
CAD_GetVarInt("OSMODE", m_nOldMode);
CAD_SetvarInt("OSMODE", nVarInt);
}
~CDistOsMode()
{
CAD_SetvarInt("OSMODE", m_nOldMode);
}
public:
int m_nOldMode;
};
}