390 lines
14 KiB
C++
390 lines
14 KiB
C++
// TAPI.h : main header file for the TAPI DLL
|
|
//
|
|
|
|
#if !defined(AFX_TAPI_H__FAB3C123_6BDF_4ED8_9080_B6AD7ACFBE07__INCLUDED_)
|
|
#define AFX_TAPI_H__FAB3C123_6BDF_4ED8_9080_B6AD7ACFBE07__INCLUDED_
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
|
|
|
|
#define IDC_USER_SHEET_EDIT 1090
|
|
#define MM 10
|
|
#define ZOOME SHads_command(RTSTR, _T("ZOOM"), RTSTR, _T("E"), RTNONE)
|
|
#define ZOOMP SHads_command(RTSTR, _T("ZOOM"), RTSTR, _T("P"), RTNONE)
|
|
#define UNDOB SHads_command(RTSTR, _T(".UNDO"), RTSTR, _T("BE"),RTNONE)
|
|
#define UNDOE SHads_command(RTSTR, _T(".UNDO"), RTSTR, _T("E"), RTNONE)
|
|
|
|
static XStringList g_lstWinfont;
|
|
static DList<int> g_lstCharset, g_lstPitch;
|
|
|
|
|
|
extern TARCH_IMPEXP AcDbObjectId InitLayer(const TCHAR *szLayer, BOOL bApplyChange);
|
|
extern int SelectEntity1(double nPrec, const TCHAR *szPrompt, Entity &entResult, XPoint &ptPick, const RBList &rbBaseMask);
|
|
|
|
|
|
//**********************************************************************
|
|
// 全局变量
|
|
//**********************************************************************
|
|
|
|
extern TELAPI int g_iToolbarPos;
|
|
extern TELAPI BOOL g_bToolbar;
|
|
extern TELAPI CString g_csDwbPath, g_csSysPath, g_csLineTypeStyle;
|
|
|
|
|
|
//**********************************************************************
|
|
// 线形函数
|
|
//**********************************************************************
|
|
|
|
extern TELAPI CString g_csLineTypeStyle, g_csLineTypeChnShx, g_csLineTypeEngShx;
|
|
extern TELAPI double g_dLineTypeHeight, g_dLineTypeScale;
|
|
|
|
|
|
TELAPI AcDbObjectId LoadTgLineType(const TCHAR* szLineType);
|
|
TELAPI void GetAllTgLineType(XStringList &lstLineTypeName, XStringList &lstLineTypeComment);
|
|
TELAPI BOOL AddLineType(const TCHAR*szLineType); //acad.line
|
|
TELAPI BOOL AddLineType(CString csText, double nLen, double nDist, double nDist2, double nDist3, double nScale, double nRotate);
|
|
TELAPI BOOL CreateGroundLineType(CString csText);
|
|
|
|
//**********************************************************************
|
|
// 图层函数
|
|
//**********************************************************************
|
|
|
|
TELAPI BOOL AddLayer(const TCHAR*szLayer, int iColor);
|
|
TELAPI BOOL SetLayerOnOff(const TCHAR*szLayerName, BOOL bOpen);
|
|
TELAPI void SetLayerColor(const TCHAR *szLayer, int iColor);
|
|
TELAPI CString GetLayerLineType(const TCHAR* szLayer);
|
|
TELAPI CString GetPipeWireLayLineType(const TCHAR* szLayer);
|
|
TELAPI void SetLayerLineType(const TCHAR* szLayer, const TCHAR* szLineType);
|
|
TELAPI BOOL IsLayerOn(const TCHAR*szLayerName);
|
|
TELAPI BOOL SetLayerLocked(const TCHAR* szLayerName, BOOL bLock);
|
|
TELAPI BOOL SetLayer0UnLocked();
|
|
TELAPI int GetLayerColorByDwg(const TCHAR*szLayer);
|
|
TELAPI int GetLayerColorIdx(const TCHAR *szLayer);
|
|
TELAPI void SetLayerColorIdx(const TCHAR *szLayer, int iColor);
|
|
TELAPI void SetLayerEngName(const TCHAR *szChnLayer, const TCHAR *szEngLayer);
|
|
TELAPI AcDbObjectId InitDoteLayer(const TCHAR* szLay);
|
|
TELAPI AcDbObjectId InitDashLayer(const TCHAR* szLay);
|
|
TELAPI AcDbObjectId InitGridLayer(const TCHAR* szLay);
|
|
|
|
//**********************************************************************
|
|
// 图库函数
|
|
//**********************************************************************
|
|
struct CBlockStruct {
|
|
CString m_csTKName;
|
|
CString m_csRecord;
|
|
CString m_csDesName;
|
|
};
|
|
|
|
struct TContextOpen
|
|
{
|
|
TCHAR szFileName[256];
|
|
BOOL bClose;
|
|
};
|
|
|
|
class CTempStruct
|
|
{
|
|
public:
|
|
int m_iTmp;
|
|
double m_dTmp;
|
|
CString m_csTmp;
|
|
|
|
static int SortByInt(const CTempStruct *p1, const CTempStruct *p2)
|
|
{
|
|
CTempStruct *pp1 = (CTempStruct*)p1,
|
|
*pp2 = (CTempStruct*)p2;
|
|
|
|
if (pp1->m_iTmp > pp2->m_iTmp)
|
|
return 1;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
};
|
|
|
|
TELAPI BOOL IsTgBlkExist(const TCHAR* szBlkName);
|
|
TELAPI CString GetTgBlkTypeInTk(const TCHAR* szBlkName);
|
|
TELAPI CString RebuildDwgInDwb(const TCHAR* szTKName, const TCHAR* szDwgName, const TCHAR* szSldName, const TCHAR* szDesName, const TCHAR* szRecord);
|
|
TELAPI CString AddNewDwg2Dwb(const TCHAR* szTKName, const TCHAR* szDwgName, const TCHAR* szSldName, const TCHAR* szType, const TCHAR* szDesName);
|
|
TELAPI BOOL GetTKType(const TCHAR* szFileName, CStringList &lstType);
|
|
TELAPI CString GetBlkDesName(const TCHAR* szRecord,const TCHAR* szTKName);
|
|
TELAPI BOOL GetTypeRecord(const TCHAR* szFileName, const TCHAR* szBlkType, CList<CBlockStruct, CBlockStruct&> &lstBlock);
|
|
TELAPI BOOL GetTypeAllRecord(const TCHAR* szFileName, const TCHAR* szBlkType, CList<CBlockStruct, CBlockStruct&> &lstBlock, BOOL bOnlyCurType = FALSE);
|
|
TELAPI void SplitBlkStr(const TCHAR *szInput, CString &csTK, CString &csRecord);
|
|
TELAPI BOOL GetRectInsPt(XPoint ptS, XPoint ptE, double nAngle, int row_num, int col_num, XPointList &lstInsPt, int iDist2Wall);
|
|
|
|
//**********************************************************************
|
|
// 几何图形
|
|
//**********************************************************************
|
|
|
|
//将一段线均分N个点 mode == 0 居中对齐,两端留一定距离 mode == 1 两端对齐
|
|
TELAPI void GetPointList(XCurveSegment seg, int iNum, XPointList &lstPt, int mode = 0);
|
|
//将一段线以间距nDist均分N个点
|
|
TELAPI void GetPointList(XCurveSegment seg, double dDist, XPointList &lstPt);
|
|
//将一段线均分N个点, 但间距是50倍数(喷淋系统)
|
|
TELAPI void GetPointList(XCurveSegment seg, int iNum, XPointList &lstPt, double nShortDist, double nDist2Wall);
|
|
|
|
|
|
TELAPI BOOL IsPtOnLine(XPoint pt, XLine line, double nSnap=0);
|
|
TELAPI BOOL IsPtOnCircle(XPoint pt, XCircle circle, double nSnap=0);
|
|
TELAPI BOOL IsPtOnArc(XPoint pt, XArc arc, double nSnap=0);
|
|
TELAPI BOOL Is2LineOnLine(XLine line1, XLine line2); //两直线是否共线
|
|
TELAPI BOOL Is2ArcOnArc(XArc arc1, XArc arc2); //两弧线是否共弧
|
|
TELAPI int get_line_angle(ads_real& line_angle); //得到直线的角度
|
|
TELAPI double GetLineAngle(Entity ent);
|
|
TELAPI XCurveSegment GetSegByPt(XPoly2D poly, XPoint pt, double &dAngle);
|
|
TELAPI AcDbPolyline* GetNextPloyLine(Entity ent, Entity ent2, XPoint ptPick, XPoint ptPick2);
|
|
TELAPI AcDbCurve* GetOffsetCurve(AcDbCurve *pCurve, double dOffsetDist, XPoint ptPick);
|
|
TELAPI AcDbCurve* GetCurveBy2Pt(AcDbCurve *pCurve, XPoint ptOnCurve1, XPoint ptOnCurve2);
|
|
TELAPI void GetLoopPLineBySeg(Entity ent, AcDbPolyline *pPolyLine);
|
|
TELAPI XCurveSegment GetBlkPickSegment(Entity entBlk, XPoint ptPick);
|
|
|
|
//**********************************************************************
|
|
// ARX 核心函数
|
|
//**********************************************************************
|
|
TELAPI BOOL StringAnalysis(const TCHAR *src, XString &sPrefix, int *num, int *numWidth);
|
|
TELAPI void HideDialog(CWnd *pWnd, BOOL Flag);
|
|
|
|
//TELAPI void MakeVisible(PickSet &ss, bool bTrue);
|
|
|
|
TELAPI void SetBlkAttrText(Entity entBlk, const TCHAR*szText, const TCHAR*szTag, double nHeight, BOOL bVisible = TRUE, BOOL bDown = FALSE);
|
|
TELAPI void GetAttPos(Entity entBlk, const TCHAR* szTag, AcGePoint3d& pt);
|
|
|
|
TELAPI BOOL CreateTextStyle(const TCHAR*szTextStyle, const TCHAR*szEngShape, const TCHAR*szChnShape);
|
|
TELAPI BOOL ModifyTextStyle(const TCHAR*szTextStyle, const TCHAR*szEngShape, const TCHAR*szChnShape);
|
|
|
|
TELAPI Acad::ErrorStatus PostToDb(AcDbEntity* ent, BOOL bClose = FALSE);
|
|
TELAPI AcDbObjectId InsertBlock(const TCHAR*szBlkName, AcGePoint3d pt, double XScale, double YScale, double Rotation = 0.0, const TCHAR* szLayer = NULL);
|
|
TELAPI BOOL IsExternalBlock(Entity entBlk);
|
|
|
|
|
|
TELAPI void GetPointPickSet(XPoint pt, PickSet &ss, const RBList &rbMask = RBList(), int len = 1);
|
|
TELAPI BOOL IsPointLinkNull(XPoint pt);
|
|
|
|
inline double Radian2Angle(double Radian){
|
|
return Radian * 180 / PI;
|
|
}
|
|
|
|
|
|
TELAPI int DragRotate(PickSet &ss, XPoint ptBase, const TCHAR* szPmt);
|
|
TELAPI int DragMove(PickSet &ss, XPoint Pt, const TCHAR* szPmt);
|
|
|
|
|
|
inline void BreakEntity(Entity ent, XPoint ptBreak1, XPoint ptBreak2)
|
|
{
|
|
SHads_command(RTSTR, _T(".BREAK"), RTLB, RTENAME, (TLong_ptr*)ent, RT3DPOINT, &ptBreak1, RTLE, RTSTR, _T("F"), RT3DPOINT, &ptBreak1, RT3DPOINT, &ptBreak2, RTNONE);
|
|
}
|
|
|
|
TELAPI void Get2PtFLinePick(PickSet &ss, XPoint ptStart, XPoint ptEnd, RBList &rbMask, int n = MM);
|
|
|
|
TELAPI XCurveSegment GetBlkPickSeg(Entity entBlk, XPoint ptPick);
|
|
|
|
TELAPI void DrawSlide(const TCHAR*szPath, CWnd* pWnd);
|
|
TELAPI void DrawSlide(const TCHAR*szPath, CDC* pDC, CRect rc);
|
|
|
|
|
|
TELAPI AcDbObjectId GetHitSheet(XPoint ptHit);
|
|
extern TELAPI int g_nKey;
|
|
TELAPI void InitSheetHook(BOOL bTrue);
|
|
TELAPI void CreateToolbars(); // 创建工具条
|
|
TELAPI BOOL SetToolbarVisible(BOOL bOpen);
|
|
|
|
TELAPI void FilletEntity(Entity ent1, Entity ent2, double nRad);
|
|
TELAPI int GetOpenPoly2D(const TCHAR *pMsg, XPoly2D &poly2d);
|
|
TELAPI CString ReadXdata(Entity ent, const TCHAR*szName);
|
|
TELAPI BOOL WriteXdata(Entity ent, const TCHAR*szName, const TCHAR*szValue);
|
|
TELAPI CString PlusString(const TCHAR* szRes, int step, BOOL bIsPlus);
|
|
|
|
TELAPI int GetSnapPoint(double *ptFrom, const TCHAR *prompt, XPoint &pt, int nFlag = 0, double dAngle = 0.0,const TCHAR *pKeyWord = NULL, int *pNKeyIndex = NULL, bool bCloseSnap = true);
|
|
TELAPI int SelRectByWall(double dAngle,double& dLength,double& dWidth);
|
|
extern TELAPI bool g_bAssisitantSnap; // 是否使用辅助捕捉
|
|
TELAPI int AutoSnapPoint(XPoint &ptWcs, XPoint *ptBase);
|
|
TELAPI int AsOsnapMask(int nOsShape);
|
|
|
|
TELAPI Acad::ErrorStatus AssureInCurrentView_New(const XPoint &ptLow, const XPoint &ptUp);
|
|
|
|
//*****************************************************************************
|
|
// 李夫银
|
|
//*****************************************************************************
|
|
TELAPI void SortPoints(AcGePoint3dArray& points, AcDbCurve * pCurve, BOOL bModifyArray=TRUE);
|
|
TELAPI void DeleteRepeateWall(AcDbObjectIdArray * pIDWalls);
|
|
|
|
//*****************************************************************************
|
|
// 其它
|
|
//*****************************************************************************
|
|
|
|
TELAPI int DoubleCmp(const double *i, const double *j);
|
|
TELAPI int DoubleCmp2(const double *i, const double *j);
|
|
|
|
|
|
inline void Callme()
|
|
{
|
|
AfxMessageBox(_T("ok!"));
|
|
}
|
|
|
|
inline void Callme(const TCHAR* msg)
|
|
{
|
|
AfxMessageBox(msg);
|
|
}
|
|
|
|
inline void Callme(int i)
|
|
{
|
|
CString str;
|
|
str.Format(_T("Value = %d"), i);
|
|
AfxMessageBox(str);
|
|
}
|
|
|
|
inline void Callme(double f)
|
|
{
|
|
CString str;
|
|
str.Format(_T("Value = %f"), f);
|
|
AfxMessageBox(str);
|
|
}
|
|
|
|
inline CString Itoa(int val)
|
|
{
|
|
CString csRet;
|
|
csRet.Format(_T("%d"), val);
|
|
return csRet;
|
|
}
|
|
|
|
inline CString Ftoa(double val, int dotnum = 2)
|
|
{
|
|
CString csRet;
|
|
if(dotnum == 2)
|
|
csRet.Format(_T("%.2f"), val);
|
|
else if(dotnum == 1)
|
|
csRet.Format(_T("%.1f"), val);
|
|
else if(dotnum == 0)
|
|
csRet.Format(_T("%.0f"), val);
|
|
else if(dotnum == 3)
|
|
csRet.Format(_T("%.3f"), val);
|
|
else
|
|
csRet.Format(_T("%.4f"), val);
|
|
return csRet;
|
|
}
|
|
|
|
inline void DrawLine(XPoint pt1, XPoint pt2)
|
|
{
|
|
XLine line(pt1, pt2, 1);
|
|
line.Make();
|
|
}
|
|
|
|
class CLayerData {
|
|
public:
|
|
CString m_csEName, m_csCName,m_csLinetype,m_csDes;
|
|
int m_iColor;
|
|
public:
|
|
CLayerData(const TCHAR* szEName, const TCHAR* szCName, int iCol=0)
|
|
: m_csEName(szEName)
|
|
, m_csCName(szCName)
|
|
, m_csLinetype(_T(""))
|
|
, m_csDes(_T(""))
|
|
, m_iColor(iCol)
|
|
{
|
|
}
|
|
CLayerData(const TCHAR* szEName, const TCHAR* szCName,const TCHAR* szLinetype,const TCHAR* szDes, int iCol=0)
|
|
: m_csEName(szEName)
|
|
, m_csCName(szCName)
|
|
, m_csLinetype(szLinetype)
|
|
, m_csDes(szDes)
|
|
, m_iColor(iCol)
|
|
{
|
|
}
|
|
};
|
|
|
|
|
|
|
|
#ifdef ST_USE_MEMDC
|
|
//////////////////////////////////////////////////
|
|
// CMemDC - memory DC
|
|
//
|
|
// Author: Keith Rule
|
|
// Email: keithr@europa.com
|
|
// Copyright 1996-1997, Keith Rule
|
|
//
|
|
// You may freely use or modify this code provided this
|
|
// Copyright is included in all derived versions.
|
|
//
|
|
// History - 10/3/97 Fixed scrolling bug.
|
|
// Added print support.
|
|
// 25 feb 98 - fixed minor assertion bug
|
|
//
|
|
// This class implements a memory Device Context
|
|
|
|
class CMemDC : public CDC
|
|
{
|
|
public:
|
|
|
|
// constructor sets up the memory DC
|
|
CMemDC(CDC* pDC) : CDC()
|
|
{
|
|
ASSERT(pDC != NULL);
|
|
|
|
m_pDC = pDC;
|
|
m_pOldBitmap = NULL;
|
|
m_bMemDC = !pDC->IsPrinting();
|
|
|
|
if (m_bMemDC) // Create a Memory DC
|
|
{
|
|
pDC->GetClipBox(&m_rect);
|
|
CreateCompatibleDC(pDC);
|
|
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
|
|
m_pOldBitmap = SelectObject(&m_bitmap);
|
|
SetWindowOrg(m_rect.left, m_rect.top);
|
|
}
|
|
else // Make a copy of the relevent parts of the current DC for printing
|
|
{
|
|
m_bPrinting = pDC->m_bPrinting;
|
|
m_hDC = pDC->m_hDC;
|
|
m_hAttribDC = pDC->m_hAttribDC;
|
|
}
|
|
}
|
|
|
|
// Destructor copies the contents of the mem DC to the original DC
|
|
~CMemDC()
|
|
{
|
|
if (m_bMemDC)
|
|
{
|
|
// Copy the offscreen bitmap onto the screen.
|
|
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
|
|
this, m_rect.left, m_rect.top, SRCCOPY);
|
|
|
|
//Swap back the original bitmap.
|
|
SelectObject(m_pOldBitmap);
|
|
} else {
|
|
// All we need to do is replace the DC with an illegal value,
|
|
// this keeps us from accidently deleting the handles associated with
|
|
// the CDC that was passed to the constructor.
|
|
m_hDC = m_hAttribDC = NULL;
|
|
}
|
|
}
|
|
|
|
// Allow usage as a pointer
|
|
CMemDC* operator->() {return this;}
|
|
|
|
// Allow usage as a pointer
|
|
operator CMemDC*() {return this;}
|
|
|
|
private:
|
|
CBitmap m_bitmap; // Offscreen bitmap
|
|
CBitmap* m_pOldBitmap; // bitmap originally found in CMemDC
|
|
CDC* m_pDC; // Saves CDC passed in constructor
|
|
CRect m_rect; // Rectangle of drawing area.
|
|
BOOL m_bMemDC; // TRUE if CDC really is a Memory DC.
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
//{{AFX_INSERT_LOCATION}}
|
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
|
|
|
#endif // !defined(AFX_TAPI_H__FAB3C123_6BDF_4ED8_9080_B6AD7ACFBE07__INCLUDED_)
|