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

285 lines
7.5 KiB
C++

#pragma once
#include "resource.h"
#include "singleton.h"
#include "GsPreviewCtrl.h"
#include "xlistctrl.h"
#include "ListBoxST.h"
#include "UIISQLiteServer.h"
class AecDbEwEquipment;
class CModelLibDlgBase : public CDialog
{
public:
DECLARE_DYNAMIC(CModelLibDlgBase)
public:
CModelLibDlgBase(LPCTSTR pszTitle, LPCTSTR pszDir = NULL, LPCTSTR pszFile = NULL, CWnd* pParent = NULL);
virtual ~CModelLibDlgBase();
enum { IDD = IDD_MODEL_LIB_DLG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// 内部初始化了 bim属性列表,本地目录树,共享服务器目录树,预览控件,imagelist,数据库
// 子类通过响应的重载函数来实现各自的初始化逻辑
// 。如果搜索内容不为空,还会直接执行搜索操作
virtual BOOL OnInitDialog();
virtual BOOL DestroyWindow();
DECLARE_MESSAGE_MAP()
#pragma region override method
// 下面定义的是子类可能重载的函数
protected:
// 目录区按钮的响应函数
virtual void BnClickedDirAdd() = 0;
virtual void BnClickedDirRename() = 0;
virtual void BnClickedDirDel() = 0;
virtual void BnClickedDirOut() = 0;
virtual void BnClickedDirIn() = 0;
// 文件区按钮的响应函数
virtual void BnClickedFileIn() = 0;
virtual void BnClickedFileNew() = 0;
virtual void BnClickedFileCopy() = 0;
virtual void BnClickedFileRename() = 0;
virtual void BnClickedFileDel() = 0;
virtual void BnClickedFileOut() = 0;
// bim属性区按钮的响应函数
virtual void BnClickedBimAdd() = 0;
virtual void BnClickedBimModi() = 0;
virtual void BnClickedBimDel() = 0;
// 确定和插入按钮
virtual void BnClickedOk() = 0;
virtual void BnClickedInsert() = 0;
// 目录树选择变化
virtual void TvnSelchangedLocalDirTree(NMHDR *pNMHDR, LRESULT *pResult) = 0;
// 文件列表选择变化
virtual void LbnSelchangeFileList() = 0;
// checked 搜索框
virtual void CheckSearch();
// 搜索框内容变化
virtual void EnChangeSearch() = 0;
// 文件列表双击事件
virtual void LbnDblClkFileList() = 0;
// 初始化数据库
virtual bool initSqliteDB() = 0;
// 初始化目录树
virtual void initLocalDirTree() = 0;
// 初始化服务器目录树
virtual void initServerDirTree() = 0;
// 初始化预览控件
virtual void initPreviewCtrl() = 0;
// 刷新文件列表
virtual void refreshLocalFileList(HTREEITEM hItem) = 0;
// 刷新BIM信息列表
virtual void refreshBimPropertyList(int idx) = 0;
// 初始化bim属性列表
virtual void initBimPropertyList() { helper_initBIMList(); };
// 初始化两个tree控件的imagelist
virtual void initImageListForLocalDirTree() { helper_initImageList(m_imageListLocalDir, IDB_BITMAPDIR); };
virtual void initImageListForServerDirTree() { helper_initImageList(m_imageListServerDir, IDB_BITMAPDIR); }
// 右键菜单,及其处理函数
virtual void PopMenuForLocalDirTree(const CPoint &pt) = 0;
virtual void PopMenuForServerDirTree(const CPoint &pt) = 0;
virtual void PopMenuForLocalFileList(const CPoint &pt) = 0;
// 扩展/收起服务器目录按钮
virtual void ExpandServerDirTree(bool bExpand);
#pragma endregion
protected:
void getBimDatasByList(std::map<CString, CString> &bims);
void getSelectedFiles(std::vector<int> &files);
bool isFolderItem(HTREEITEM hItem);
bool isRootItem(HTREEITEM hItem);
bool isClassItem(HTREEITEM hItem);
HTREEITEM getParentFolder(const HTREEITEM &hItem);
CString getClassName(const HTREEITEM &hItem);
// 初始化时,如果有需要,可以打开指定的目录
void anchorDir();
// 沿X方向,按照指定距离移动控件 +向右,-向左
void moveCtrlX(int ctrlID, int offset);
void moveCtrlX(int offset);
void ShowHideWindow(int ctrlID, bool bShow);
// 过滤选择集中的 AecDbX3dPartEntity 实体
void filterX3dPartEntity(ads_name ss, AcDbObjectIdArray &ids);
// 选择块的对齐点
bool getAlignPoint(AcGePoint3d &ptOrg);
public:
CUIISQLiteServer& getSqliteDB() { return m_sqlDB; }
AecDbEwEquipment* getEquipment(int fid);
// 工具函数
public:
// 从一个数据库复制表到另一个数据库
// 注意:两表结构必须相同
static bool helper_CopyTable(LPCTSTR pszDbFrom
, LPCTSTR pszDbTo
, LPCTSTR pszTableFrom
, LPCTSTR pszTableTo);
static void helper_initLocalDirTree(CTreeCtrl &tree
, CImageList &imglist
, CUIISQLiteServer &db
, LPCTSTR pszRoot
, LPCTSTR pszTablePrefix);
static bool helper_putEquFileToDb(CUIISQLiteServer &db
, LPCTSTR pszFile
, int idClass);
static int helper_getLastInserId(CUIISQLiteServer &db, LPCTSTR pszTable);
static bool helper_selectPath(LPCTSTR pszTitle, CString &strPath);
static CString helper_checkFileName(LPCTSTR sfile);
static CString helper_getLastErrorMsg();
static void helper_insertEqu(AecDbEwEquipment *pEqu);
static void helper_ShowWindow(UINT id, CWnd *pParent, const bool &bShow);
void helper_initLocalDirTree(LPCTSTR pszRoot, LPCTSTR pszTablePrefix);
void helper_initServerDirTree(LPCTSTR pszRoot);
void helper_initImageList(CImageList &imglist, UINT imgListID);
void helper_initBIMList();
void helper_ClickedLocalDirAdd(LPCTSTR pszTablePrefix);
void helper_ClickedLocalDirRename(LPCTSTR pszTablePrefix);
void helper_ClickedLocalDirDel(LPCTSTR pszTablePrefix);
void helper_ClickedLocalDirOut(LPCTSTR pszTablePrefix, LPCTSTR pszFileSuffix);
void helper_ClickedLocalDirIn(LPCTSTR pszTablePrefix, const std::vector<CString> &filetypes);
void helper_ClickedFileIn(LPCTSTR fileTypeFilter);
void helper_ClickedFileCopy(LPCTSTR pszRoot, LPCTSTR pszTablePrefix);
void helper_ClickedFileRename(LPCTSTR pszTablePrefix);
void helper_ClickedFileAnchor();
void helper_ClickedFileDel(LPCTSTR pszTablePrefix);
bool helper_hasSameFileName(LPCTSTR name);
void helper_refreshLocalFileList(HTREEITEM hItem, LPCTSTR pszTablePrefix);
void helper_EnChangeSearch(LPCTSTR pszTablePrefix);
void helper_PopMenuForLocalDirTree(const CPoint &pt);
void helper_CurrentSelectFilePosition();
public:
afx_msg LONG_PTR onAcadKeepFocus(UINT_PTR, LONG_PTR);
afx_msg void OnBnClickedDirAdd();
afx_msg void OnBnClickedDirRename();
afx_msg void OnBnClickedDirDel();
afx_msg void OnBnClickedDirOut();
afx_msg void OnBnClickedDirIn();
afx_msg void OnBnClickedFileIn();
afx_msg void OnBnClickedFileNew();
afx_msg void OnBnClickedFileCopy();
afx_msg void OnBnClickedFileRename();
afx_msg void OnBnClickedFileDel();
afx_msg void OnBnClickedFileOut();
afx_msg void OnBnClickedBimAdd();
afx_msg void OnBnClickedBimModi();
afx_msg void OnBnClickedBimDel();
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedInsert();
afx_msg void OnTvnSelchangedLocalDirTree(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLbnSelchangeFileList();
afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
afx_msg void OnCheckSearch();
afx_msg void OnEnChangeSearch();
afx_msg void OnLbnDblClkFileList();
afx_msg void OnBnClickedBtnExpandServerDirTree();
protected:
CImageList m_imageListLocalDir, m_imageListServerDir;
// 目录树
CTreeCtrl m_ctrlLocalDirTree;
// 共享文件树
CTreeCtrl m_ctrlServerDirTree;
// 文件列表
CListBoxST m_ctrlLocalFileList;
// bim属性列表
CXListCtrl m_ctrlBimPropertyList;
// 预览控件
CGsPreviewCtrl m_wndPreviewCtrl;
// 两个静态文本,一个是目录列表,一个是文件列表
CStatic m_ctrlStaticDir, m_ctrlStaticFile;
// 两个分隔条
CStatic m_ctrlStaticSepMid, m_ctrlStaticSepLeft;
// 搜索编辑框
CEdit m_ctrlSearchEdit;
CUIISQLiteServer m_sqlDB;
HBITMAP m_hBitmap;
// 展开/收起共享目录树按钮
CButton m_btnExpandServerDirTree;
// 目录定位点
CString m_strDirAnchor;
// 文件定位点
CString m_strFileAnchor;
// 主窗口title
CString m_sTitle;
// 主窗口全幅宽度
int m_nDlgExpandedWidth;
int m_nDlgCollapsedWidth;
public:
int m_iSelectFileID;
// 是否开启搜索
BOOL m_bSearch;
// 搜索内容
CString m_sSearch;
std::vector<std::shared_ptr<AcDbDatabase>> m_dbs;
};