242 lines
4.7 KiB
C++
242 lines
4.7 KiB
C++
#include "StdAfx.h"
|
|
#include "BatchDimDlg.h"
|
|
#include "LayerSiftDlg.h"
|
|
|
|
BOOL CBatchDimDlg::m_bPolyVertex = TRUE; // 多段线端点
|
|
BOOL CBatchDimDlg::m_bLineVertex = FALSE; // 直线、弧线端点
|
|
BOOL CBatchDimDlg::m_bElevLoc = FALSE; // 标高符号插入点
|
|
|
|
BOOL CBatchDimDlg::m_bIntersectPt = FALSE; // 交点
|
|
BOOL CBatchDimDlg::m_bPoint = FALSE; // 点
|
|
BOOL CBatchDimDlg::m_bCirclePt = FALSE; // 圆心
|
|
|
|
CString CBatchDimDlg::m_strDimlayers = _T(""); // 图层
|
|
BOOL CBatchDimDlg::m_bAppoint = FALSE;
|
|
|
|
Adesk::Boolean acedPostCommand( const TCHAR * );
|
|
|
|
IMPLEMENT_DYNAMIC(CBatchDimDlg, CModelessDialog)
|
|
CBatchDimDlg::CBatchDimDlg(CWnd* pParent) : CModelessDialog(CBatchDimDlg::IDD, pParent)
|
|
{
|
|
m_bPost = FALSE;
|
|
}
|
|
|
|
CBatchDimDlg::~CBatchDimDlg()
|
|
{
|
|
}
|
|
|
|
void CBatchDimDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
DDX_Check(pDX, IDC_CHK_POLYVERTEX, m_bPolyVertex);
|
|
DDX_Check(pDX, IDC_CHK_LINEVERTEX, m_bLineVertex);
|
|
DDX_Check(pDX, IDC_CHK_ELEVLOC, m_bElevLoc);
|
|
DDX_Check(pDX, IDC_CHK_INTERSECTPT, m_bIntersectPt);
|
|
DDX_Check(pDX, IDC_CHK_POINT, m_bPoint);
|
|
DDX_Check(pDX, IDC_CHK_CIRCLEPT, m_bCirclePt);
|
|
DDX_Check(pDX, IDC_CHK_APPOINTLAYER, m_bAppoint);
|
|
}
|
|
|
|
BOOL CBatchDimDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
|
|
if (m_bAppoint) //是否指定图层
|
|
{
|
|
GetDlgItem(IDC_BTN_SELECTINDRAW)->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_BTN_SELECTINDRAW)->EnableWindow(FALSE);
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
return TRUE;
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CBatchDimDlg, CModelessDialog)
|
|
ON_BN_CLICKED(IDC_BTN_ALLSELECT, OnClickAllSelect)
|
|
ON_BN_CLICKED(IDC_BTN_ALLCLERA, OnClickAllClear)
|
|
ON_BN_CLICKED(IDC_BTN_SELECTINDRAW, OnClickSelectInDraw)
|
|
ON_BN_CLICKED(IDC_CHK_APPOINTLAYER, OnBnClickAppointlayer)
|
|
ON_WM_CLOSE()
|
|
END_MESSAGE_MAP()
|
|
|
|
void CBatchDimDlg::OnClickAllSelect() // 全选
|
|
{
|
|
m_bPolyVertex = TRUE;
|
|
m_bLineVertex = TRUE;
|
|
m_bElevLoc = TRUE;
|
|
|
|
m_bIntersectPt = TRUE;
|
|
m_bPoint = TRUE;
|
|
m_bCirclePt = TRUE;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CBatchDimDlg::OnClickAllClear() // 清空
|
|
{
|
|
m_bPolyVertex = FALSE;
|
|
m_bLineVertex = FALSE;
|
|
m_bElevLoc = FALSE;
|
|
|
|
m_bIntersectPt = FALSE;
|
|
m_bPoint = FALSE;
|
|
m_bCirclePt = FALSE;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CBatchDimDlg::OnClose()
|
|
{
|
|
m_bPost = FALSE;
|
|
if (m_bModeless)
|
|
{
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
else
|
|
{
|
|
CModelessDialog::OnClose();
|
|
}
|
|
}
|
|
|
|
void CBatchDimDlg::OnClickSelectInDraw()
|
|
{
|
|
CLayerSiftDlg dlg;
|
|
dlg.SetLayerName(m_aryAddLayer); // 专门用于屏幕拾取对象
|
|
if (dlg.DoModal() == IDOK)
|
|
{
|
|
if (dlg.m_bSelectEnt) // 当前是在屏幕提取对象
|
|
{
|
|
m_bPost = TRUE;
|
|
if (m_bModeless)
|
|
{
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_bPost = FALSE;
|
|
m_aryAddLayer.RemoveAll(); // 添加成功
|
|
|
|
m_strDimlayers = dlg.GetLayerName();
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_bPost = FALSE;
|
|
m_aryAddLayer.RemoveAll(); // 不需要添加
|
|
}
|
|
}
|
|
|
|
void CBatchDimDlg::SelectEntInDraw()
|
|
{
|
|
XPushAutoHide noAutoHide(this);
|
|
|
|
BeginEditorCommand();
|
|
PickSet entSetInDraw;
|
|
if (SelectEntities(_T("\n请选择对象<返回>: "), entSetInDraw, RBList()) == RTNORM)
|
|
{
|
|
CStringArray aryLayers;
|
|
for (long i = 0; i < entSetInDraw.Length(); i++)
|
|
{
|
|
OPENOBJ_BEGIN(entSetInDraw[i], AcDb::kForRead, AcDbEntity, pEntity);
|
|
if (!pEntity)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
bool bFind = false;
|
|
CString csLayText = pEntity->layer();
|
|
for (int j=0; j<aryLayers.GetSize(); j++)
|
|
{
|
|
if (csLayText == aryLayers[j])
|
|
{
|
|
bFind = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!bFind) // 没有找到,添加
|
|
aryLayers.Add(csLayText);
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
if (aryLayers.GetSize() > 0)
|
|
m_aryAddLayer.Append(aryLayers);
|
|
}
|
|
CompleteEditorCommand();
|
|
}
|
|
|
|
BOOL CBatchDimDlg::GetIsPolyVertex()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bPolyVertex;
|
|
}
|
|
|
|
BOOL CBatchDimDlg::GetIsLineVertex()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bLineVertex;
|
|
}
|
|
|
|
BOOL CBatchDimDlg::GetIsElevLoc()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bElevLoc;
|
|
}
|
|
|
|
BOOL CBatchDimDlg::GetIsIntersectPt()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bIntersectPt;
|
|
}
|
|
|
|
BOOL CBatchDimDlg::GetIsPoint()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bPoint;
|
|
}
|
|
|
|
BOOL CBatchDimDlg::GetIsCirclePt()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bCirclePt;
|
|
}
|
|
|
|
void CBatchDimDlg::OnBnClickAppointlayer()
|
|
{
|
|
UpdateData(TRUE);
|
|
if (m_bAppoint) // 指定图层过滤
|
|
{
|
|
GetDlgItem(IDC_BTN_SELECTINDRAW)->EnableWindow(TRUE);
|
|
|
|
if (m_strDimlayers.IsEmpty()) // 如果图层过滤表为空,那么就判断一下是否有文件
|
|
{
|
|
CLayerSiftDlg dlg;
|
|
dlg.GetLayerInIniFiles();
|
|
m_strDimlayers = dlg.GetLayerName();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_BTN_SELECTINDRAW)->EnableWindow(FALSE);
|
|
}
|
|
}
|
|
|
|
BOOL CBatchDimDlg::GetIsAppointLayer()
|
|
{
|
|
UpdateData(TRUE);
|
|
BOOL bAppoint = m_bAppoint;
|
|
if (m_strDimlayers.IsEmpty())
|
|
{
|
|
bAppoint = FALSE;
|
|
}
|
|
return bAppoint;
|
|
}
|
|
|
|
CString CBatchDimDlg::GetStrLayerName()
|
|
{
|
|
return m_strDimlayers;
|
|
}
|