889 lines
23 KiB
C++
889 lines
23 KiB
C++
#include "stdafx.h"
|
|
#include "OpenLayer.h"
|
|
#include "Resource.h"
|
|
#include "actrans.h"
|
|
|
|
// 获得层表管理器的记录,add xly 100617
|
|
void GetLayerDes(CStringArray &curLayerNameAry, CStringArray &layerCon);
|
|
|
|
// add by xly on 101229 判断图层是本地图层和外部参照图层,识别“|”“$”
|
|
bool IsExternalLayer(CString csLayerName);
|
|
|
|
COpenLayer::COpenLayer(CWnd* pParent /*=NULL*/)
|
|
: GlwCAcUiDialog(COpenLayer::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(COpenLayer)
|
|
//}}AFX_DATA_INIT
|
|
m_bHasOutLayer = false;
|
|
|
|
SPACE1 = -1;
|
|
}
|
|
|
|
COpenLayer::~COpenLayer()
|
|
{
|
|
}
|
|
|
|
void COpenLayer::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(COpenLayer)
|
|
DDX_Control(pDX, IDC_LIST_LAYER, m_wndLstLayer);
|
|
DDX_Control(pDX, IDC_LIST_REFER, m_wndLstOutLayer);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(COpenLayer, GlwCAcUiDialog)
|
|
ON_BN_CLICKED(IDC_BUT_ALLSEL, OnButtonAllSel)
|
|
ON_BN_CLICKED(IDC_BUT_CLEAR, OnButtonClear)
|
|
ON_BN_CLICKED(IDC_BUT_APPLIENCE, OnButtonApplication)
|
|
ON_WM_SIZE()
|
|
ON_WM_GETMINMAXINFO()
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// BOOL COpenLayer::OnInitDialog()
|
|
// {
|
|
// UpdateData(TRUE);
|
|
// CDialog::OnInitDialog();
|
|
//
|
|
// // 记录对话框的大小信息
|
|
// GetWindowRect(&m_Rect);
|
|
//
|
|
// // 解冻对话框设置
|
|
// if(!m_bOpenorFreeze)
|
|
// {
|
|
// this->SetWindowText(_T("解冻图层"));
|
|
// GetDlgItem(IDC_STATIC)->SetWindowText(_T("本图已冻结图层:"));
|
|
// GetDlgItem(IDC_STC_OUT)->SetWindowText(_T("外部参照已冻结图层:"));
|
|
// }
|
|
//
|
|
// // 普通图层列表初始化设置
|
|
// CRect rect;
|
|
// m_wndLstLayer.GetClientRect(&rect);
|
|
//
|
|
// // 获得列表框中的图层以及图层描述
|
|
// GetLockOrFrozLayer();
|
|
//
|
|
// // 设置列表控件的checkbox模式
|
|
// m_wndLstLayer.SetExtendedStyle(LVS_EX_CHECKBOXES);
|
|
//
|
|
// m_wndLstLayer.InsertColumn(0, _T("层名"), LVCFMT_LEFT, rect.Width()/2);
|
|
// m_wndLstLayer.InsertColumn(1, _T("描述"), LVCFMT_LEFT, rect.Width()*7/16);
|
|
//
|
|
// // 存储外部参照部分图层名
|
|
// CStringArray csLayerOut;
|
|
//
|
|
// // 初始化存储非外部参照图层的列表框
|
|
// int nSize = m_csAryLayerAll.GetSize(),
|
|
// nSize1 = m_csAryLayerCon.GetSize();
|
|
// for(int i = 0; i<nSize; i++)
|
|
// {
|
|
// bool bIsExt = IsExternalLayer(m_csAryLayerAll[i]);
|
|
// if(!bIsExt)// 非外部参照图层
|
|
// {
|
|
// // 添加第一列层名
|
|
// m_wndLstLayer.InsertItem(i, m_csAryLayerAll[i]);
|
|
//
|
|
// // 查找该层名是否有图层描述
|
|
// for(int j = 0; j<nSize1; j++)
|
|
// {
|
|
// if(m_csAryLayerAll[i] == m_csAryLayerCon[j]) // 层名有描述
|
|
// {
|
|
// // modify by xly on 110401 增加合法性判断判断
|
|
// //m_wndLstLayer.SetItemText(i, 1, m_csAryLayerCon[j-1]);
|
|
// if (j-1>-1&&j-1<nSize1&&(j-1)%2==0)
|
|
// {
|
|
// m_wndLstLayer.SetItemText(i, 1, m_csAryLayerCon[j-1]);
|
|
// }
|
|
//
|
|
// }
|
|
// }
|
|
// }
|
|
// else// 外部参照图层
|
|
// {
|
|
// csLayerOut.Add(m_csAryLayerAll[i]);
|
|
// }
|
|
// }
|
|
//
|
|
// // 存在外部参照的图层
|
|
// int nSize2 = csLayerOut.GetSize();
|
|
// if(nSize2>0)
|
|
// {
|
|
// m_bHasOutLayer = true;
|
|
//
|
|
// // 静态文本显示
|
|
// GetDlgItem(IDC_STC_OUT)->ShowWindow(SW_SHOW);
|
|
//
|
|
// // 使外部参照涂层对话框的大小是本图参照大小的某个倍数
|
|
//
|
|
// // GetDlgItem(IDC_STC_OUT)->SetWindowPos(NULL, rect2.right+nWidSpace, rect2.top, rect2.Width() * dScale, rect2.Height(),SWP_NOZORDER);
|
|
//
|
|
// // 恢复控件的大小
|
|
// // GetDlgItem(IDC_LIST_LAYER)->SetWindowPos(NULL, 8, 29, 168, 190,SWP_NOZORDER);
|
|
//
|
|
// // 设置保存外部图层列表,控件宽度为本图层列表的1.4倍
|
|
// m_wndLstOutLayer.ShowWindow(SW_SHOW);
|
|
//
|
|
// m_wndLstOutLayer.GetClientRect(rect);
|
|
// m_wndLstOutLayer.InsertColumn(0, _T("层名"), LVCFMT_LEFT, rect.Width()*5/8);
|
|
// m_wndLstOutLayer.InsertColumn(1, _T("描述"), LVCFMT_LEFT, rect.Width()*5/16);
|
|
//
|
|
// // 设置列表控件的checkbox模式
|
|
// m_wndLstOutLayer.SetExtendedStyle(LVS_EX_CHECKBOXES);
|
|
//
|
|
// // modify by xly on 110506 添加外部参照的描述
|
|
// //// 设置外部参照列表框的内容
|
|
// //for(i = 0; i< nSize2; i++)
|
|
// //{
|
|
// // m_wndLstOutLayer.InsertItem(i, csLayerOut[i]);
|
|
// //}
|
|
// CStringArray csExtAll;
|
|
// GetLockOrFrozLayerExt(csLayerOut, csExtAll);
|
|
//
|
|
// int nLen = csExtAll.GetSize();
|
|
// for(i = 0; i< nSize2; i++)
|
|
// {
|
|
// m_wndLstOutLayer.InsertItem(i, csLayerOut[i]);
|
|
// for(int n= 0; n< nLen; n++)
|
|
// {
|
|
// if(csLayerOut[i] == csExtAll[n]) // 层名有描述
|
|
// {
|
|
// if (n-1>-1&&n-1<nLen&&(n-1)%2==0)
|
|
// {
|
|
// m_wndLstOutLayer.SetItemText(i, 1, csExtAll[n-1]);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// // add by xly on 110314 设置对话框的图标
|
|
// HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON4);
|
|
// SetIcon(hIcon,FALSE);
|
|
//
|
|
// UpdateData(FALSE);
|
|
// return TRUE;
|
|
// }
|
|
|
|
BOOL COpenLayer::OnInitDialog()
|
|
{
|
|
UpdateData(TRUE);
|
|
CDialog::OnInitDialog();
|
|
InitSpaceSize();
|
|
|
|
// 存储外部参照部分图层名
|
|
CStringArray csLayerOut;
|
|
|
|
// 获得列表框中的图层以及图层描述
|
|
GetLockOrFrozLayer();
|
|
|
|
// 普通图层列表初始化设置
|
|
CRect rect;
|
|
m_wndLstLayer.GetClientRect(&rect);
|
|
|
|
// 设置列表控件的checkbox模式
|
|
m_wndLstLayer.SetExtendedStyle(LVS_EX_CHECKBOXES);
|
|
m_wndLstLayer.InsertColumn(0, _T("层名"), LVCFMT_LEFT, rect.Width()/2);
|
|
m_wndLstLayer.InsertColumn(1, _T("描述"), LVCFMT_LEFT, rect.Width()*7/16);
|
|
|
|
// 初始化存储非外部参照图层的列表框
|
|
int nSize = m_csAryLayerAll.GetSize(),
|
|
nSize1 = m_csAryLayerCon.GetSize();
|
|
for(int i = 0; i<nSize; i++)
|
|
{
|
|
bool bIsExt = IsExternalLayer(m_csAryLayerAll[i]);
|
|
if(!bIsExt)// 非外部参照图层
|
|
{
|
|
// 添加第一列层名
|
|
m_wndLstLayer.InsertItem(i, m_csAryLayerAll[i]);
|
|
|
|
// 查找该层名是否有图层描述
|
|
for(int j = 0; j<nSize1; j++)
|
|
{
|
|
if(m_csAryLayerAll[i] == m_csAryLayerCon[j]) // 层名有描述
|
|
{
|
|
// modify by xly on 110401 增加合法性判断判断
|
|
//m_wndLstLayer.SetItemText(i, 1, m_csAryLayerCon[j-1]);
|
|
if (j-1>-1&&j-1<nSize1&&(j-1)%2==0)
|
|
{
|
|
m_wndLstLayer.SetItemText(i, 1, m_csAryLayerCon[j-1]);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
else// 外部参照图层
|
|
{
|
|
csLayerOut.Add(m_csAryLayerAll[i]);
|
|
}
|
|
}
|
|
|
|
// 存在外部参照的图层
|
|
int nSize2 = csLayerOut.GetSize();
|
|
if(nSize2>0)
|
|
{
|
|
m_bHasOutLayer = true;
|
|
}
|
|
|
|
CRect rectDlg, rectDump;
|
|
GetWindowRect(&rectDlg);
|
|
rectDump = rectDlg;
|
|
|
|
if (m_bHasOutLayer)
|
|
{
|
|
BigDlgRect(rectDump, rectDlg);
|
|
SetWindowPos(NULL, rectDlg.left, rectDlg.top, rectDlg.Width(), rectDlg.Height(),SWP_NOZORDER);
|
|
}
|
|
|
|
GetClientRect(&rectDlg); // 不包括标题栏
|
|
Layout(rectDlg.Width(), rectDlg.Height()); // 布置按钮
|
|
|
|
// 解冻对话框设置
|
|
if(!m_bOpenorFreeze)
|
|
{
|
|
this->SetWindowText(_T("解冻图层"));
|
|
GetDlgItem(IDC_STATIC1)->SetWindowText(_T("本图已冻结图层:"));
|
|
GetDlgItem(IDC_STC_OUT)->SetWindowText(_T("外部参照已冻结图层:"));
|
|
}
|
|
//
|
|
// // 普通图层列表初始化设置
|
|
// CRect rect;
|
|
// m_wndLstLayer.GetClientRect(&rect);
|
|
//
|
|
// // 设置列表控件的checkbox模式
|
|
// m_wndLstLayer.SetExtendedStyle(LVS_EX_CHECKBOXES);
|
|
// m_wndLstLayer.InsertColumn(0, _T("层名"), LVCFMT_LEFT, rect.Width()/2);
|
|
// m_wndLstLayer.InsertColumn(1, _T("描述"), LVCFMT_LEFT, rect.Width()*7/16);
|
|
//
|
|
|
|
if (m_bHasOutLayer)
|
|
{ // 静态文本显示
|
|
GetDlgItem(IDC_STC_OUT)->ShowWindow(SW_SHOW);
|
|
m_wndLstOutLayer.ShowWindow(SW_SHOW);
|
|
|
|
m_wndLstOutLayer.GetClientRect(rect);
|
|
m_wndLstOutLayer.InsertColumn(0, _T("层名"), LVCFMT_LEFT, rect.Width()*5/8);
|
|
m_wndLstOutLayer.InsertColumn(1, _T("描述"), LVCFMT_LEFT, rect.Width()*5/16);
|
|
|
|
// 设置列表控件的checkbox模式
|
|
m_wndLstOutLayer.SetExtendedStyle(LVS_EX_CHECKBOXES);
|
|
|
|
CStringArray csExtAll;
|
|
GetLockOrFrozLayerExt(csLayerOut, csExtAll);
|
|
|
|
int nLen = csExtAll.GetSize();
|
|
for(i = 0; i< nSize2; i++)
|
|
{
|
|
m_wndLstOutLayer.InsertItem(i, csLayerOut[i]);
|
|
for(int n= 0; n< nLen; n++)
|
|
{
|
|
if(csLayerOut[i] == csExtAll[n]) // 层名有描述
|
|
{
|
|
if (n-1>-1&&n-1<nLen&&(n-1)%2==0)
|
|
{
|
|
m_wndLstOutLayer.SetItemText(i, 1, csExtAll[n-1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// add by xly on 110314 设置对话框的图标
|
|
HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON4);
|
|
SetIcon(hIcon,FALSE);
|
|
|
|
UpdateData(FALSE);
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
// 支持对话框大小变化
|
|
void COpenLayer::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CDialog::OnSize(nType, cx, cy);
|
|
if (IsInitSizeData())
|
|
Layout(cx, cy);
|
|
// static RECT LastWindowRect = {0, 0, 0, 0};
|
|
// int ux = cx - LastWindowRect.right;
|
|
// int uy = cy - LastWindowRect.bottom;
|
|
//
|
|
// CWnd *pWnd, *pWndOut;
|
|
// CRect rect;
|
|
// pWnd = GetDlgItem(IDC_LIST_LAYER);
|
|
// if(pWnd)
|
|
// {
|
|
// // 获取控件变化前大小
|
|
// pWnd->GetWindowRect(&rect);
|
|
//
|
|
// // 将控件大小转换为在对话框中的区域坐标
|
|
// ScreenToClient(&rect);
|
|
//
|
|
// if (m_bHasOutLayer)// 有外部参照
|
|
// {
|
|
// int iX = ux *5/12;
|
|
// rect.right += iX;
|
|
// rect.bottom += uy;
|
|
// // 设置控件大小
|
|
// pWnd->MoveWindow(rect);
|
|
// pWndOut = GetDlgItem(IDC_LIST_REFER);
|
|
// if(pWndOut)
|
|
// {
|
|
// CRect rectNew;
|
|
// // 获取控件变化前大小
|
|
// pWndOut->GetWindowRect(&rectNew);
|
|
//
|
|
// // 将控件大小转换为在对话框中的区域坐标
|
|
// ScreenToClient(&rectNew);
|
|
//
|
|
// rectNew.right += ux;
|
|
// rectNew.bottom += uy;
|
|
//
|
|
// rectNew.left = rect.right+10;
|
|
// pWndOut->MoveWindow(rectNew);
|
|
// }
|
|
// pWndOut = GetDlgItem(IDC_STC_OUT);
|
|
// if(pWndOut)
|
|
// {
|
|
// CRect rectNew;
|
|
// // 获取控件变化前大小
|
|
// pWndOut->GetWindowRect(&rectNew);
|
|
//
|
|
// // 将控件大小转换为在对话框中的区域坐标
|
|
// ScreenToClient(&rectNew);
|
|
//
|
|
// rectNew.left = rect.right+10;
|
|
// pWndOut->MoveWindow(rectNew);
|
|
// }
|
|
// }
|
|
// else // 没有外部参照
|
|
// {
|
|
// rect.right += ux;
|
|
// rect.bottom += uy;
|
|
//
|
|
// // 设置控件大小
|
|
// pWnd->MoveWindow(rect);
|
|
// }
|
|
// }
|
|
// // 设置按钮控件的位置变化
|
|
// ChangeSize(IDC_BUT_ALLSEL, ux,uy);
|
|
// ChangeSize(IDC_BUT_CLEAR, ux,uy);
|
|
// ChangeSize(IDC_BUT_APPLIENCE, ux,uy);
|
|
// ChangeSize(IDOK, ux,uy);
|
|
// ChangeSize(IDCANCEL, ux,uy);
|
|
//
|
|
// LastWindowRect.right = cx;
|
|
// LastWindowRect.bottom = cy;
|
|
|
|
}
|
|
|
|
// 改变控件的大小
|
|
void COpenLayer::ChangeSize(UINT nType, int ux, int uy)
|
|
{
|
|
CWnd *pWnd;
|
|
pWnd = GetDlgItem(nType);
|
|
if(pWnd)
|
|
{
|
|
//获取控件变化前大小
|
|
CRect rect;
|
|
pWnd->GetWindowRect(&rect);
|
|
|
|
//将控件大小转换为在对话框中的区域坐标
|
|
ScreenToClient(&rect);
|
|
rect.right += ux;
|
|
rect.bottom += uy;
|
|
rect.left += ux;
|
|
rect.top += uy;
|
|
|
|
//设置控件大小
|
|
pWnd->MoveWindow(rect);
|
|
}
|
|
}
|
|
|
|
// 全部选中按钮实现
|
|
void COpenLayer::OnButtonAllSel()
|
|
{
|
|
UpdateData(TRUE);
|
|
int iTaskCount = m_wndLstLayer.GetItemCount();
|
|
int i = 0;
|
|
|
|
// 本图列表框设置全部选择
|
|
for (i = 0; i < iTaskCount; i++)
|
|
{
|
|
m_wndLstLayer.SetCheck(i, TRUE);
|
|
}
|
|
if(m_wndLstOutLayer)// 外部参照的图层所有列设置全部选择
|
|
{
|
|
iTaskCount = m_wndLstOutLayer.GetItemCount();
|
|
for (i = 0; i < iTaskCount; i++)
|
|
{
|
|
m_wndLstOutLayer.SetCheck(i, TRUE);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 全部清除按钮实现
|
|
void COpenLayer::OnButtonClear()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
// 清空本图列表的选择
|
|
int iTaskCount = m_wndLstLayer.GetItemCount();
|
|
for (int i = 0; i < iTaskCount; i++)
|
|
{
|
|
m_wndLstLayer.SetCheck(i, FALSE);
|
|
}
|
|
if(m_wndLstOutLayer)// 清空外部参照的图层的选择
|
|
{
|
|
iTaskCount = m_wndLstOutLayer.GetItemCount();
|
|
for (i = 0; i < iTaskCount; i++)
|
|
{
|
|
m_wndLstOutLayer.SetCheck(i, FALSE);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// 应用按钮实现
|
|
void COpenLayer::OnButtonApplication()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
// 存储图层名
|
|
CString csName;
|
|
|
|
// 遍历本层列表的checkbox按钮,查找被选择的项
|
|
int nItemCount = m_wndLstLayer.GetItemCount();
|
|
int i = 0;
|
|
BOOL bFlag;
|
|
|
|
// 遍历所有的checkbox按钮,查找被选择的按钮
|
|
for(i = 0; i < nItemCount ;i++)
|
|
{
|
|
bFlag = m_wndLstLayer.GetCheck(i);
|
|
if(bFlag)// 按钮被选择
|
|
{
|
|
// 设置选择到的图层被打开或者被解冻
|
|
csName = m_wndLstLayer.GetItemText(i,0);
|
|
UnLockLayer(csName, m_bOpenorFreeze);
|
|
}
|
|
}
|
|
if(m_wndLstOutLayer) // 遍历外部参照列表的checkbox按钮,查找被选择的项
|
|
{
|
|
nItemCount = m_wndLstOutLayer.GetItemCount();
|
|
for (i = 0; i < nItemCount; i++)
|
|
{
|
|
bFlag = m_wndLstOutLayer.GetCheck(i);
|
|
if(bFlag)// 按钮被选择
|
|
{
|
|
csName = m_wndLstOutLayer.GetItemText(i,0);
|
|
UnLockLayer(csName,m_bOpenorFreeze);
|
|
}
|
|
}
|
|
}
|
|
|
|
// flush的速度比regen要快。
|
|
// 但是在图层解冻的时候,flush没有执行重新绘制,因此此处对该问题做了两种不同的处理。
|
|
// lgh Add
|
|
if (m_bOpenorFreeze)
|
|
{
|
|
// 此处如果使用redraw也达不到重新绘制的效果。
|
|
actrTransactionManager->flushGraphics();
|
|
acedUpdateDisplay();
|
|
}
|
|
else
|
|
{
|
|
acedCommand(RTSTR, _T("REGEN"), RTNONE);
|
|
}
|
|
|
|
// actrTransactionManager->flushGraphics();
|
|
// acedUpdateDisplay();
|
|
}
|
|
|
|
// 确定按钮实现
|
|
void COpenLayer::OnOK()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
// 遍历本层列表的checkbox按钮,查找被选择的项
|
|
CString csName;
|
|
int nItemCount = m_wndLstLayer.GetItemCount();
|
|
int i = 0;
|
|
BOOL bFlag;
|
|
for(i = 0; i < nItemCount ;i++)
|
|
{
|
|
bFlag = m_wndLstLayer.GetCheck(i);
|
|
if(bFlag)// 按钮被选择
|
|
{
|
|
csName = m_wndLstLayer.GetItemText(i,0);
|
|
UnLockLayer(csName, m_bOpenorFreeze);
|
|
}
|
|
}
|
|
if(m_wndLstOutLayer)// 遍历外部参照列表的checkbox按钮,查找被选择的项
|
|
{
|
|
nItemCount = m_wndLstOutLayer.GetItemCount();
|
|
for (i = 0; i < nItemCount; i++)
|
|
{
|
|
bFlag = m_wndLstOutLayer.GetCheck(i);
|
|
if(bFlag)// 按钮被选择
|
|
{
|
|
csName = m_wndLstOutLayer.GetItemText(i,0);
|
|
UnLockLayer(csName,m_bOpenorFreeze);
|
|
}
|
|
}
|
|
}
|
|
|
|
// add by xly on 110505 更新图形显示
|
|
// acedCommand(RTSTR, _T("REGEN"), RTNONE);
|
|
// acedRedraw(NULL, 1);
|
|
// redraw的速度比regen要快。
|
|
// 但是在图层解冻的时候,redraw没有执行重新绘制,因此此处对该问题做了两种不同的处理。
|
|
// lgh Add
|
|
if (m_bOpenorFreeze)
|
|
{
|
|
acedRedraw(NULL, 1);
|
|
}
|
|
else
|
|
{
|
|
acedCommand(RTSTR, _T("REGEN"), RTNONE);
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
// 获得列表框中的图层以及图层描述
|
|
void COpenLayer::GetLockOrFrozLayer()
|
|
{
|
|
// 获得层表
|
|
AcDbLayerTable *pLayertable = NULL;
|
|
acdbCurDwg()->getLayerTable(pLayertable, AcDb::kForRead);
|
|
|
|
// 定义层表遍历器
|
|
AcDbLayerTableIterator *pLayerItor = NULL;
|
|
pLayertable->newIterator(pLayerItor);
|
|
|
|
// 获得层表记录
|
|
AcDbLayerTableRecord *pLayerTblRcd = NULL;
|
|
const TCHAR* csLayer;
|
|
bool bIsState;
|
|
|
|
// 存储层表中图层
|
|
CStringArray csAry;
|
|
// 遍历层表记录,查找冻结图层
|
|
for(; !pLayerItor->done(); pLayerItor->step())
|
|
{
|
|
pLayerItor->getRecord(pLayerTblRcd, AcDb::kForRead);
|
|
if (m_bOpenorFreeze)// 打开
|
|
{
|
|
bIsState = pLayerTblRcd->isOff();
|
|
if(bIsState)
|
|
{
|
|
pLayerTblRcd->getName(csLayer);
|
|
m_csAryLayerAll.Add(csLayer);
|
|
}
|
|
}
|
|
else//解冻
|
|
{
|
|
bIsState = pLayerTblRcd->isFrozen();
|
|
if(bIsState)
|
|
{
|
|
pLayerTblRcd->getName(csLayer);
|
|
m_csAryLayerAll.Add(csLayer);
|
|
}
|
|
}
|
|
|
|
pLayerTblRcd->close();
|
|
}
|
|
delete pLayerItor;
|
|
pLayertable->close();
|
|
|
|
// 存储层表在层表管理器中的描述
|
|
GetLayerDes(m_csAryLayerAll, m_csAryLayerCon);
|
|
}
|
|
|
|
// add by xly on 110506 获得外部参照中的图层描述
|
|
void COpenLayer::GetLockOrFrozLayerExt(CStringArray& csLayerExt, CStringArray& csLayerExtAll)
|
|
{
|
|
|
|
// 寻找层表管理器的路径
|
|
CString csFileName = _T("layerdef.dat");
|
|
|
|
CString szFullPath = g_sDwbPath;
|
|
if (_tcscmp(csFileName, _T("")) == 0)
|
|
{
|
|
szFullPath = szFullPath.Left(szFullPath.GetLength() - 5) + _T("\\sys\\");
|
|
}
|
|
else
|
|
{
|
|
szFullPath = szFullPath.Left(szFullPath.GetLength() - 5) + _T("\\sys\\") + csFileName;
|
|
if (csFileName.Find(_T(".")) == -1)
|
|
{
|
|
szFullPath += _T(".lay");
|
|
}
|
|
}
|
|
|
|
// 打开层表管理器文件
|
|
CStdioFile file;
|
|
if (!file.Open(szFullPath, CFile::modeRead))
|
|
{
|
|
AfxMessageBox(CString(_T("打开文件 \"")) + szFullPath + _T("\" 失败"));
|
|
return;
|
|
}
|
|
|
|
// 读取图层管理其中的信息
|
|
int iFind = -1;
|
|
|
|
CString sString;
|
|
while (file.ReadString(sString))
|
|
{
|
|
// 图层关键字
|
|
TCHAR sKey[256] = _T("");
|
|
|
|
// 图层名
|
|
TCHAR sName[256] = _T("");
|
|
|
|
int nColor = 0;
|
|
TCHAR sLineType[256] = _T("");
|
|
TCHAR sNote[256] = _T("");
|
|
|
|
_stscanf(sString, _T("%s%s%d%s%s"), sKey, sName, &nColor, sLineType, sNote);
|
|
|
|
// 当前图形中存在的图层
|
|
int nLength = (int)csLayerExt.GetSize();
|
|
for (int i = 0; i<nLength; i++)
|
|
{
|
|
if (iFind == i) // 记录图层是否被找到过
|
|
{
|
|
continue;
|
|
}
|
|
int nPos = csLayerExt[i].Find(_T('|'));
|
|
CString csCon = csLayerExt[i].Right(csLayerExt[i].GetLength()-nPos-1);
|
|
if (_tcscmp(sName, csCon) == 0&&_tcscmp(sName,_T("0"))) // 找到当前图层的名
|
|
{
|
|
csLayerExtAll.Add(sKey);
|
|
csLayerExtAll.Add(csLayerExt[i]);
|
|
|
|
// 记录被找到过的层的索引
|
|
iFind = i;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
file.Close();
|
|
|
|
//// 存储层表在层表管理器中的描述
|
|
//GetLayerDes(m_csAryLayerAll, m_csAryLayerCon);
|
|
}
|
|
|
|
// 打开、解冻制定的图层,打开:bOpenOrFree=true;解冻:bOpenOrFree=false
|
|
void COpenLayer::UnLockLayer(CString &csCurLayer, bool bOpenOrFree)
|
|
{
|
|
// 获得层表
|
|
AcDbLayerTable *pLayertable = NULL;
|
|
if(acdbCurDwg()->getLayerTable(pLayertable, AcDb::kForRead) != Acad::eOk)
|
|
return ;
|
|
|
|
// 获得层表记录
|
|
AcDbLayerTableRecord *pLayerTblRcd = NULL;
|
|
Acad::ErrorStatus es = pLayertable->getAt(csCurLayer, pLayerTblRcd, AcDb::kForWrite);
|
|
if (es != Acad::eOk)
|
|
{
|
|
pLayertable->close();
|
|
return ;
|
|
}
|
|
|
|
if(bOpenOrFree)// 层表记录的设置打开状态
|
|
{
|
|
pLayerTblRcd->setIsOff(false);
|
|
}
|
|
else // 层表记录的设置解冻结状态
|
|
{
|
|
pLayerTblRcd->setIsFrozen(false);
|
|
}
|
|
pLayerTblRcd->close();
|
|
pLayertable->close();
|
|
|
|
// modify by xly on 110330 更新时闪烁,速度比较慢
|
|
// 更新显示
|
|
//acedCommand(RTSTR, _T("REGEN"), RTNONE);
|
|
//acedRedraw(NULL,1); // 这里不需要刷新,执行完毕这个函数之后会有一次统一的刷新lgh rem
|
|
}
|
|
|
|
// 设置拖动对话框时,最小不应该小于最初值
|
|
void COpenLayer::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
|
|
{
|
|
// delete by xly on 110311 解决有些平台不可用
|
|
//if ( m_Rect.left == 0
|
|
// && m_Rect.top == 0
|
|
// && m_Rect.right == 0
|
|
// && m_Rect.bottom == 0 )
|
|
//{
|
|
// GetWindowRect(m_Rect);
|
|
//}
|
|
|
|
lpMMI->ptMinTrackSize.x = 281;
|
|
lpMMI->ptMinTrackSize.y = 264;
|
|
|
|
CDialog::OnGetMinMaxInfo(lpMMI);
|
|
}
|
|
|
|
void COpenLayer::InitSpaceSize()
|
|
{
|
|
CRect rectBtn, rectLable2, rectDummi;
|
|
|
|
GetDlgItem(IDC_BUT_ALLSEL)->GetWindowRect(&rectBtn);
|
|
ScreenToClient(&rectBtn);
|
|
|
|
GetDlgItem(IDC_STC_OUT)->GetWindowRect(&rectLable2);
|
|
ScreenToClient(&rectLable2);
|
|
LABELHEI = rectLable2.Height();
|
|
LABEL2Wid = rectLable2.Width();
|
|
|
|
BTNWID = rectBtn.Width();
|
|
BTNHEI = rectBtn.Height();
|
|
|
|
GetDlgItem(IDC_STATIC1)->GetWindowRect(&rectDummi);
|
|
ScreenToClient(&rectDummi);
|
|
SPACE1 = rectDummi.left;
|
|
SPACE2 = (int)(BTNHEI * 0.3);
|
|
SPACE3 = (int)(BTNHEI * 0.6);
|
|
SPACE4 = SPACE1;
|
|
|
|
PSPACE1 = rectLable2.top;
|
|
PSPACE2 = (int)(BTNHEI * 0.2);
|
|
PSPACE3 = (int)(BTNHEI * 0.5);
|
|
|
|
SPACEBTN = (int)(BTNHEI * 0.5);
|
|
|
|
SCALE_FOR_LIST = 1.4; // 两个对话框的比例。
|
|
}
|
|
|
|
void COpenLayer::LstLayerRect(CRect &rect, int dlgCx, int dlgCy)
|
|
{
|
|
int nLastWid = dlgCx - SPACE1 - (m_bHasOutLayer ? SPACE2 : 0) - SPACE3 - SPACE4 - BTNWID;
|
|
|
|
int nWid = 0, nHei = 0;
|
|
if (m_bHasOutLayer)
|
|
{
|
|
nWid = (int)(nLastWid/(1+SCALE_FOR_LIST));
|
|
}
|
|
else
|
|
{
|
|
nWid = nLastWid;
|
|
}
|
|
|
|
nHei = dlgCy - PSPACE1 - PSPACE2 - PSPACE3 - LABELHEI;
|
|
rect.left = SPACE1;
|
|
rect.right = rect.left + nWid;
|
|
rect.top = PSPACE1 + PSPACE2 + LABELHEI;
|
|
rect.bottom = rect.top + nHei;
|
|
}
|
|
|
|
void COpenLayer::LstRefLayerRect(CRect &rect, int dlgCx, int dlgCy)
|
|
{
|
|
LstLayerRect(rect, dlgCx, dlgCy);
|
|
|
|
if (!m_bHasOutLayer)
|
|
return; //
|
|
|
|
int nLastWid = dlgCx - SPACE1 - (m_bHasOutLayer ? SPACE2 : 0) - SPACE3 - SPACE4 - BTNWID;
|
|
int nWid = nLastWid - rect.Width();
|
|
|
|
rect.left = rect.right + SPACE2;
|
|
rect.right = rect.left + nWid;
|
|
}
|
|
|
|
void COpenLayer::BtnAllSelRect(CRect &rect, int dlgCx, int dlgCy)
|
|
{
|
|
CRect rectLstRef;
|
|
LstRefLayerRect(rectLstRef, dlgCx, dlgCy);
|
|
|
|
rect.left = rectLstRef.right + SPACE3;
|
|
rect.right = rect.left + BTNWID;
|
|
rect.top = rectLstRef.top;
|
|
rect.bottom = rect.top + BTNHEI;
|
|
}
|
|
|
|
void COpenLayer::BtnClearRect(CRect &rect, int dlgCx, int dlgCy)
|
|
{
|
|
BtnAllSelRect(rect, dlgCx, dlgCy);
|
|
|
|
rect.top = rect.bottom + SPACEBTN;
|
|
rect.bottom = rect.top + BTNHEI;
|
|
}
|
|
|
|
void COpenLayer::BtnApplyRect(CRect &rect, int dlgCx, int dlgCy)
|
|
{
|
|
BtnOkRect(rect, dlgCx, dlgCy);
|
|
|
|
rect.bottom = rect.top - SPACEBTN;
|
|
rect.top = rect.bottom - BTNHEI;
|
|
}
|
|
|
|
void COpenLayer::BtnOkRect(CRect &rect, int dlgCx, int dlgCy)
|
|
{
|
|
BtnCancelRect(rect, dlgCx, dlgCy);
|
|
|
|
rect.bottom = rect.top - SPACEBTN;
|
|
rect.top = rect.bottom - BTNHEI;
|
|
}
|
|
|
|
void COpenLayer::BtnCancelRect(CRect &rect, int dlgCx, int dlgCy)
|
|
{
|
|
CRect rectRef;
|
|
LstRefLayerRect(rectRef, dlgCx, dlgCy);
|
|
|
|
rect.left = rectRef.right + SPACE3;
|
|
rect.right = rect.left + BTNWID;
|
|
rect.bottom = dlgCy - PSPACE3;
|
|
rect.top = rect.bottom - BTNHEI;
|
|
}
|
|
|
|
void COpenLayer::Label2Rect(CRect &rect, int dlgCx, int dlgCy)
|
|
{
|
|
LstRefLayerRect(rect, dlgCx, dlgCy);
|
|
|
|
rect.right = rect.left + LABEL2Wid;
|
|
rect.bottom = rect.top - PSPACE2;
|
|
rect.top = rect.bottom - LABELHEI;
|
|
}
|
|
|
|
void COpenLayer::BigDlgRect(const CRect &smallRect, CRect &bigRect)
|
|
{
|
|
bigRect = smallRect;
|
|
|
|
int layWid = smallRect.Width() - SPACE1 - SPACE3 - BTNWID - SPACE4;
|
|
bigRect.right = bigRect.right + (int)(layWid*SCALE_FOR_LIST + SPACE2);
|
|
}
|
|
|
|
void COpenLayer::Layout(int cx, int cy)
|
|
{
|
|
CRect rectDummi;
|
|
if (m_bHasOutLayer)
|
|
{
|
|
Label2Rect(rectDummi, cx, cy);
|
|
GetDlgItem(IDC_STC_OUT)->SetWindowPos(NULL, rectDummi.left, rectDummi.top, rectDummi.Width(), rectDummi.Height(), SWP_NOZORDER);
|
|
LstRefLayerRect(rectDummi, cx, cy);
|
|
GetDlgItem(IDC_LIST_REFER)->SetWindowPos(NULL, rectDummi.left, rectDummi.top, rectDummi.Width(), rectDummi.Height(), SWP_NOZORDER);
|
|
}
|
|
|
|
LstLayerRect(rectDummi, cx, cy);
|
|
GetDlgItem(IDC_LIST_LAYER)->SetWindowPos(NULL, rectDummi.left, rectDummi.top, rectDummi.Width(), rectDummi.Height(), SWP_NOZORDER);
|
|
|
|
BtnAllSelRect(rectDummi, cx, cy);
|
|
GetDlgItem(IDC_BUT_ALLSEL)->SetWindowPos(NULL, rectDummi.left, rectDummi.top, rectDummi.Width(), rectDummi.Height(), SWP_NOZORDER);
|
|
|
|
BtnClearRect(rectDummi, cx, cy);
|
|
GetDlgItem(IDC_BUT_CLEAR)->SetWindowPos(NULL, rectDummi.left, rectDummi.top, rectDummi.Width(), rectDummi.Height(), SWP_NOZORDER);
|
|
|
|
BtnApplyRect(rectDummi, cx, cy);
|
|
GetDlgItem(IDC_BUT_APPLIENCE)->SetWindowPos(NULL, rectDummi.left, rectDummi.top, rectDummi.Width(), rectDummi.Height(), SWP_NOZORDER);
|
|
|
|
BtnOkRect(rectDummi, cx, cy);
|
|
GetDlgItem(IDOK)->SetWindowPos(NULL, rectDummi.left, rectDummi.top, rectDummi.Width(), rectDummi.Height(), SWP_NOZORDER);
|
|
|
|
BtnCancelRect(rectDummi, cx, cy);
|
|
GetDlgItem(IDCANCEL)->SetWindowPos(NULL, rectDummi.left, rectDummi.top, rectDummi.Width(), rectDummi.Height(), SWP_NOZORDER);
|
|
}
|