#pragma once #include "acgi.h" #ifdef EARTHWORM_EXPORT #define DLLIMPEXP __declspec(dllexport) #else #define DLLIMPEXP __declspec(dllimport) #endif #define WM_CELL_SELECT_CHANGE WM_USER + 0x01 class CGsPreviewCtrl; class DLLIMPEXP CBlkRecsPreviewCtrl : public CWnd { public: CBlkRecsPreviewCtrl(); virtual ~CBlkRecsPreviewCtrl(); public: BOOL Create(const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff); void SetLogFont(LOGFONT* plf); // 初始化 nCount 为Add方法使用 BOOL Init(int nRows,int nCols,int nCount = -1,AcDbDatabase* pDb = NULL); // 为3D实体初始化(单个控件) bool InitSingleCtrlFor3D(AcDbEntity *pEnt, LPCTSTR sName,BOOL bExtDef = TRUE); // 为2D实体初始化(单个控件) bool InitSingleCtrlFor2D(AcDbEntity *pEnt, LPCTSTR sName); // 为AcdbDatabase初始化 bool InitDBCtrlFor2D(LPCTSTR pszDWG, LPCTSTR sName); // 擦除视口 -1 : ALL void Clear(int nIndex = -1); // 添加实体到view BOOL Add(AcDbEntity* pEnt,int nIndex,AcDbExtents* pExtAll = NULL); BOOL Add(AcDbEntity* pEnt,int nIndex,LPCTSTR pszName,AcDbExtents* pExtAll = NULL); BOOL Add(LPCTSTR pszDwgFile,LPCTSTR pszName); BOOL Add(LPCTSTR pszDwgFile,LPCTSTR pszShowRc,LPCTSTR pszName); BOOL Add(AcDbDatabase* pDb,LPCTSTR pszName); // 预览db的特定以 特定字符串 开头的块 BOOL PreViewNamedRecs(LPCTSTR pszDwgFile,LPCTSTR pszHead = NULL); // 获取选择的索引 rec 名称 BOOL GetCurSelRec(CString& sRecName); // 获取选择的索引 rec 名称 BOOL GetCurSelRec(CString& sDwgFile,CString& sRecName); // 获取选择的索引 int GetCurSelIndex(); void Redraw(AcDbExtents* pExtAll = NULL,int nGsViewIndex = -1); void ZoomExtent(AcGsView* pView,AcDbExtents* pExtAll); void ZoomExtent(int nGsViewIndex,AcDbExtents* pExtAll); void SetRow(const int &n) { m_nRows = n; }; void SetCol(const int &n) { m_nCols = n; }; int GetRow() { return m_nRows; }; int GetCol() { return m_nCols; }; // 计算或画单元 void DrawGridCell(CDC* pDC,CArray& arCells); protected: afx_msg void OnPaint(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnDestroy(); afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); DECLARE_MESSAGE_MAP() protected: // 销毁所有的gs对象 void DestroyAll(); int HitViewCell(CPoint point); void SetShowViewPort(CDC* pDC,CArray& arCells); void DrawCurselCell(CDC* pDC); //nIndex 为 DC 的坐标的 cell 索引 CRect GetCellIndexRect(int nIndex); bool GetActiveViewPortInfo (AcDbDatabase *pDb, ads_real &height, ads_real &width, AcGePoint3d &target, AcGeVector3d &viewDir, ads_real &viewTwist, bool getViewCenter); Acad::ErrorStatus InitDrawingControl (CGsPreviewCtrl* pPreViewCtrl,AcDbDatabase *pDb, const TCHAR *space = ACDB_MODEL_SPACE); void SetViewTo(AcGsView *pView, AcDbDatabase *pDb, AcGeMatrix3d& viewMat); void RefreshView(AcGsView *pView); protected: CPtrArray m_arPreViewCtrls; CStringArray m_arDwgFiles; CStringArray m_arRecNames; CPtrArray m_arDbPtrs; int m_nRows; int m_nCols; int m_nCurSel; int m_nIDAdd; static int s_nSpace; BOOL m_bInit; LOGFONT m_lfFont; BOOL m_bLfFont; CMapStringToString m_mapEntPtr2Name; };