408 lines
9.8 KiB
C++
408 lines
9.8 KiB
C++
|
|
#include "stdafx.h"
|
|
#include "DrawingIndexDlg.h"
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CDrawingIndexDlg, CModelessDialog)
|
|
|
|
CString CDrawingIndexDlg::s_sIndexLabel = _T("1"); //索引编号
|
|
CString CDrawingIndexDlg::s_sDrawingLabel = _T("-"); //索引图号
|
|
|
|
//modify by lgy 20120110 文字样式应有程序自动获得
|
|
//CString CDrawingIndexDlg::s_sTextStyle = _T("_TCH_LABEL"); //文字样式
|
|
CString CDrawingIndexDlg::s_sTextStyle = GetTextStyleName(TS_LABEL);//文字样式
|
|
|
|
//modify by lgy 20120206 索引图名中比例应该设置成为1:的形式
|
|
//int CDrawingIndexDlg:: s_iScale = 20; //比例值
|
|
CString CDrawingIndexDlg:: s_strScale = _T("1:20"); //比例值
|
|
|
|
int CDrawingIndexDlg::s_iCheck = 1;
|
|
|
|
//double CDrawingIndexDlg::s_dTextHight = 3.5; //字高
|
|
double CDrawingIndexDlg::s_dTextHight = GetTextHeightByTs(TS_INDEXSCALE);//字高
|
|
|
|
//add by lgy 20120110 新添加的文字样式
|
|
CString CDrawingIndexDlg::s_sWorldStyle = GetTextStyleName(TS_INDEXSCALE);
|
|
|
|
CDrawingIndexDlg::CDrawingIndexDlg(CWnd* pParent)
|
|
: CModelessDialog(CDrawingIndexDlg::IDD, pParent),
|
|
m_bScale(TRUE),
|
|
m_bClose(false),
|
|
m_bTextHeight(FALSE)
|
|
{
|
|
}
|
|
|
|
CDrawingIndexDlg::~CDrawingIndexDlg()
|
|
{
|
|
}
|
|
|
|
void CDrawingIndexDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
DDX_Text(pDX,IDC_EDT_INDEX,s_sIndexLabel);
|
|
DDX_Text(pDX,IDC_EDT_LAYNUM,s_sDrawingLabel);
|
|
DDX_Text(pDX,IDC_CMB_FONTSTYLE,s_sTextStyle);
|
|
//modify by lgy 20120206 索引图名中比例应该设置成为1:的形式
|
|
//DDX_Text(pDX,IDC_CMB_SCALE,s_iScale);
|
|
DDX_Text(pDX,IDC_CMB_SCALE,s_strScale);
|
|
|
|
DDX_Text(pDX,IDC_CMB_FONTHIGHT,s_dTextHight);
|
|
DDX_Check(pDX,IDC_CHK_SCALE,s_iCheck);
|
|
//add by lgy 20120110 将原来的索引编号变量与组合框关联起来
|
|
DDX_Text(pDX, IDC_CMB_INDEX, s_sIndexLabel);
|
|
DDX_Text(pDX, IDC_CMB_WORLDSTYLE, s_sWorldStyle);
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
|
|
// sg add 120706,增加与文字样式相关联的控制变量
|
|
DDX_Control(pDX, IDC_CMB_FONTSTYLE, m_cmbFontStyle);
|
|
DDX_Control(pDX, IDC_CMB_WORLDSTYLE, m_cmbWordStyle);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CDrawingIndexDlg, CModelessDialog)
|
|
ON_BN_CLICKED(IDC_CHK_SCALE, OnBnClickedChkScale)
|
|
ON_BN_CLICKED(IDC_BTN_FONTHIGHT, OnBnClickedBtnFonthight)
|
|
ON_BN_CLICKED(IDOK, OnBnClickedOk)
|
|
ON_WM_ACTIVATE()
|
|
ON_WM_CLOSE()
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CDrawingIndexDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
|
|
//add by lgy 20120110 索引图名对话框中索引编号控件变为组合框
|
|
GetDlgItem(IDC_EDT_INDEX)->ShowWindow(SW_HIDE);
|
|
|
|
if (m_bModeless)
|
|
{
|
|
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
LoadTextStyle();
|
|
|
|
// sg modify 120706,增加一个判断,如果当前记忆的样式没有的话,那么使用上华固定的文字样式
|
|
int nRet = m_cmbFontStyle.FindStringExact(0, s_sTextStyle);
|
|
if (nRet < 0) // 当前图纸没有此样式
|
|
{
|
|
nRet = m_cmbFontStyle.FindStringExact(0, _T("_TCH_LABEL"));
|
|
}
|
|
m_cmbFontStyle.SetCurSel(nRet);
|
|
|
|
nRet = m_cmbWordStyle.FindStringExact(0, s_sWorldStyle);
|
|
if (nRet < 0) // 当前图纸没有此样式
|
|
{
|
|
nRet = m_cmbWordStyle.FindStringExact(0, _T("_TCH_DIM"));
|
|
}
|
|
m_cmbWordStyle.SetCurSel(nRet);
|
|
|
|
//add by lgy 20120110 第二次显示对话框是不能记忆是否显示比例
|
|
OnBnClickedChkScale();
|
|
|
|
//add by lgy 20120110 根据是模式对话框还是非模式对话框调整对话框大小
|
|
AdjustDlgRect();
|
|
|
|
//模态对话框显示时,检查对象是否包含比例属性
|
|
if (!m_bScale)
|
|
{
|
|
GetDlgItem(IDC_CMB_SCALE)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_CMB_FONTHIGHT)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_BTN_FONTHIGHT)->EnableWindow(FALSE);
|
|
//add by lgy 20120110 文字样式静态文本和组合框需要灰显
|
|
GetDlgItem(IDC_STATIC_STYLE)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_CMB_WORLDSTYLE)->EnableWindow(FALSE);
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
return TRUE;
|
|
}
|
|
|
|
//把对象属性显示在对话框上
|
|
void CDrawingIndexDlg::Obj2Dlg(TDbSymbDrawingIndex *pEnt)
|
|
{
|
|
if (!pEnt)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// 图号
|
|
s_sDrawingLabel = pEnt->GetDrawingLabel();
|
|
if (s_sDrawingLabel == _T(""))
|
|
{
|
|
s_sDrawingLabel = _T("-");
|
|
}
|
|
|
|
// 编号
|
|
s_sIndexLabel = pEnt->GetIndexLabel();
|
|
|
|
// 比例
|
|
CString sScaleText = pEnt->GetScaleText().cs();
|
|
// sg add 120612,只要是对象编辑对话框,无论是否显示比例,对话框上的值,应该从对象中读取,而不是使用最后一次对话框中记忆值
|
|
s_strScale = sScaleText;
|
|
m_bScale = pEnt->IsDrawScale();
|
|
//if (m_bScale)
|
|
//{
|
|
// CString csTmp = sScaleText;
|
|
// int nFind = csTmp.Find(_T("1:"), 0);
|
|
// if (nFind < 0)
|
|
// {
|
|
//注释 by lgy 20120206 索引图名中对象编辑时指出文字
|
|
//m_bScale = FALSE;
|
|
//}
|
|
//else
|
|
//{
|
|
//modify by lgy 20120206 索引图名中比例应该设置成为1:的形式
|
|
//int nNum = csTmp.GetLength() - (nFind + 2);
|
|
//csTmp = csTmp.Right(nNum);
|
|
//s_iScale = _ttoi(csTmp);
|
|
// s_strScale = csTmp;
|
|
// }
|
|
//}
|
|
|
|
// sg modify 120612,从对象中获取比例文字样式
|
|
s_sWorldStyle = GetSymbolName(pEnt->GetScaleStyleId());
|
|
|
|
//比例选框
|
|
if(m_bScale)
|
|
{
|
|
s_iCheck = 1;
|
|
}
|
|
else
|
|
{
|
|
s_iCheck = 0;
|
|
}
|
|
|
|
//文字样式
|
|
s_sTextStyle = GetSymbolName(pEnt->GetTextStyleId());
|
|
//字高
|
|
s_dTextHight = pEnt->GetScaleTextHeight();
|
|
}
|
|
|
|
//把对话框上的数据与对象属性关联
|
|
void CDrawingIndexDlg::Dlg2Obj(TDbSymbDrawingIndex* pEnt)
|
|
{
|
|
if (!pEnt)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcDbObjectId idTextStyle = InitTextStyle(s_sTextStyle);
|
|
|
|
//add by lgy 20120111 增加比例文字样式
|
|
AcDbObjectId idScaleStyle = InitTextStyle(s_sWorldStyle);
|
|
|
|
//修改属性
|
|
if ((s_sDrawingLabel == _T("-")))
|
|
{
|
|
s_sDrawingLabel = _T("");
|
|
}
|
|
pEnt->SetDrawingLabel(s_sDrawingLabel); //图号
|
|
pEnt->SetIndexLabel(s_sIndexLabel); //编号
|
|
pEnt->SetTextStyleId(idTextStyle); //文字样式
|
|
|
|
//modify by lgy 20120111 修改比例文字样式
|
|
//pEnt->SetScaleStyleId(idTextStyle);
|
|
pEnt->SetScaleStyleId(idScaleStyle);
|
|
|
|
pEnt->SetScaleTextHeight(s_dTextHight); //字高
|
|
pEnt->SetDrawScale(IsDrawScale()); //是否画比例
|
|
pEnt->SetScaleText(GetScaleText()); //比例内容
|
|
|
|
//add by lgy 20120110 将s_sDrawingLabel改变之后要记得还原
|
|
if ((s_sDrawingLabel == _T("")))
|
|
{
|
|
s_sDrawingLabel = _T("-");
|
|
}
|
|
}
|
|
|
|
//加载现有的字体样式
|
|
void CDrawingIndexDlg::LoadTextStyle()
|
|
{
|
|
XSymbolList lstStyle(_T("STYLE"));
|
|
for (int i =0; i < lstStyle.Length(); i++)
|
|
{
|
|
m_cmbFontStyle.AddString(lstStyle[i]);
|
|
// add by lgy 20120110 增加索引图名比例的文字样式
|
|
m_cmbWordStyle.AddString(lstStyle[i]);
|
|
}
|
|
}
|
|
|
|
bool CDrawingIndexDlg::IsDrawScale()
|
|
{
|
|
bool bRe = (s_iCheck == BST_CHECKED);
|
|
return bRe;
|
|
}
|
|
|
|
void CDrawingIndexDlg::UpdateDataEx()
|
|
{
|
|
UpdateData();
|
|
}
|
|
|
|
CString CDrawingIndexDlg::GetDrawingLabel()
|
|
{
|
|
return s_sDrawingLabel;
|
|
}
|
|
|
|
CString CDrawingIndexDlg::GetIndexLabel()
|
|
{
|
|
return s_sIndexLabel;
|
|
}
|
|
|
|
CString CDrawingIndexDlg::GetTextStyle()
|
|
{
|
|
return s_sTextStyle;
|
|
}
|
|
|
|
CString CDrawingIndexDlg::GetScaleText()
|
|
{
|
|
//modify by lgy 20120206 比例已经改成cstring类型
|
|
// CString sScale;
|
|
// sScale.Format(_T("1:%d"), s_iScale);
|
|
// return sScale;
|
|
return s_strScale;
|
|
}
|
|
|
|
double CDrawingIndexDlg::GetTextHight()
|
|
{
|
|
return s_dTextHight;
|
|
}
|
|
|
|
void CDrawingIndexDlg::OnBnClickedChkScale()
|
|
{
|
|
if ((((CButton*)GetDlgItem(IDC_CHK_SCALE))->GetCheck()) == BST_CHECKED)
|
|
{
|
|
GetDlgItem(IDC_CMB_SCALE)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_CMB_FONTHIGHT)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_BTN_FONTHIGHT)->EnableWindow(TRUE);
|
|
|
|
//add by lgy 20120110 新增文字样式受单选框控制
|
|
GetDlgItem(IDC_STATIC_STYLE)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_CMB_WORLDSTYLE)->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_CMB_SCALE)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_CMB_FONTHIGHT)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_BTN_FONTHIGHT)->EnableWindow(FALSE);
|
|
|
|
//add by lgy 20120110 新增文字样式受单选框控制
|
|
GetDlgItem(IDC_STATIC_STYLE)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_CMB_WORLDSTYLE)->EnableWindow(FALSE);
|
|
}
|
|
|
|
UpdateDataEx();
|
|
}
|
|
|
|
void CDrawingIndexDlg::OnBnClickedBtnFonthight()
|
|
{
|
|
if (m_bModeless)
|
|
{
|
|
m_bTextHeight = TRUE;
|
|
PostCommand(_T("` "), false);
|
|
}
|
|
else
|
|
{
|
|
TextHight();
|
|
acedGetAcadDwgView()->SetFocus();
|
|
}
|
|
}
|
|
|
|
void CDrawingIndexDlg::TextHight()
|
|
{
|
|
XPushAutoHide noAutoHide(this);
|
|
|
|
double dHeight = s_dTextHight*DocGetPScale();
|
|
BeginEditorCommand();
|
|
if(GetDist(_T("\n字高"), dHeight, RSG_NOZERO|RSG_NONEG) == RTNORM)
|
|
{
|
|
dHeight /= DocGetPScale();
|
|
CString str;
|
|
str.Format(_T("%.1f"), dHeight);
|
|
s_dTextHight = _tstof(str);
|
|
}
|
|
CompleteEditorCommand();
|
|
|
|
m_bTextHeight = FALSE;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CDrawingIndexDlg::OnBnClickedOk()
|
|
{
|
|
UpdateDataEx();
|
|
OnOK();
|
|
}
|
|
|
|
void CDrawingIndexDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
|
|
{
|
|
CModelessDialog::OnActivate(nState, pWndOther, bMinimized);
|
|
|
|
if(!m_bModeless)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(nState == WA_CLICKACTIVE)
|
|
{
|
|
}
|
|
else if(nState == WA_INACTIVE)
|
|
{
|
|
UpdateDataEx();
|
|
|
|
if(!m_bClose && !m_bTextHeight)
|
|
{
|
|
PostCommand(_T("` "), false);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CDrawingIndexDlg::OnClose()
|
|
{
|
|
if(m_bModeless)
|
|
{
|
|
m_bClose = true;
|
|
PostCommand(_T(" "), false);
|
|
}
|
|
CModelessDialog::OnClose();
|
|
}
|
|
|
|
BOOL CDrawingIndexDlg::IsOpTextHeight()
|
|
{
|
|
return m_bTextHeight;
|
|
}
|
|
|
|
//add by lgy 20120110 根据是模式对话框还是非模式对话框调整对话框大小
|
|
void CDrawingIndexDlg::AdjustDlgRect()
|
|
{
|
|
if (!m_bModeless)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CRect rcExpansion;
|
|
GetWindowRect(&rcExpansion);
|
|
|
|
CWnd *pWnd = GetDlgItem(IDOK);
|
|
if (pWnd)
|
|
{
|
|
CRect rect;
|
|
pWnd->GetWindowRect(&rect);
|
|
|
|
rcExpansion.bottom -= rect.Height()*1.3;
|
|
MoveWindow(rcExpansion);
|
|
}
|
|
}
|
|
|
|
//add by lgy 20120111 返回比例文字样式
|
|
CString CDrawingIndexDlg::GetScaleStyle()
|
|
{
|
|
//if (BST_CHECKED == s_iCheck)
|
|
//{
|
|
// return s_sWorldStyle;
|
|
//}
|
|
//else
|
|
//{
|
|
// return _T("");
|
|
//}
|
|
// sg modify 120612,文字样式不允许是空的
|
|
return s_sWorldStyle;
|
|
}
|