633 lines
17 KiB
C++
633 lines
17 KiB
C++
// IndexDimDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "IndexDimDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CIndexDimDlg dialog
|
|
const int maxHisList = 10;
|
|
|
|
CString CIndexDimDlg::m_strInputUp = _T("");
|
|
CString CIndexDimDlg::m_strInputDown = _T("");
|
|
CString CIndexDimDlg::m_strDrawing = _T("-");
|
|
CString CIndexDimDlg::m_strIndex = _T("1");
|
|
int CIndexDimDlg::m_iIndexType=0;
|
|
// add by cwk on 060706
|
|
extern CString g_sIndexDimFixAngle = _T("90");// [11/12/2007 nsh]
|
|
extern BOOL g_bIndexDimFixAngle = FALSE;
|
|
|
|
BOOL CIndexDimDlg::m_bContinue=TRUE; // Add by lcf on 2005-06-29
|
|
BOOL CIndexDimDlg::m_bAddIndex = TRUE; // sg add 090122
|
|
int CIndexDimDlg::m_nTextAlign = 2; // sg add 090402
|
|
|
|
BOOL CIndexDimDlg::m_bDimOnExtent = FALSE; // lgh add 101216, 是否在延长线上标注文字
|
|
BOOL CIndexDimDlg::m_bMoreCut = FALSE; // lgh add 101216,是否绘制多段剖切线
|
|
BOOL CIndexDimDlg::m_bAddTurn = FALSE; // lgh add 101216, 是否添加一个转折点
|
|
|
|
// modify by lgy 20120111 标注文字样式要从文字管理中初始化
|
|
// CString CIndexDimDlg::m_strDimStyle = _T(""); // lgh add 101216, 标注文字样式。
|
|
CString CIndexDimDlg::m_strDimStyle = GetTextStyleName(TS_LABEL);// lgh add 101216, 圆圈文字样式。
|
|
|
|
IMPLEMENT_DYNAMIC(CIndexDimDlg, CBaseTextDlg)
|
|
CIndexDimDlg::CIndexDimDlg(BOOL bEdit, CWnd* pParent /*=NULL*/)
|
|
: CBaseTextDlg(CIndexDimDlg::IDD, pParent), m_bEditObj(bEdit)
|
|
{
|
|
//{{AFX_DATA_INIT(CIndexDimDlg)
|
|
// add by cwk on 060706
|
|
m_sFixAngle = g_sIndexDimFixAngle;
|
|
m_bFixAngle = g_bIndexDimFixAngle;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
CIndexDimDlg::CIndexDimDlg(BOOL bEdit, UINT Id, CWnd* pParent)
|
|
: CBaseTextDlg(Id, pParent), m_bEditObj(bEdit)
|
|
{
|
|
//{{AFX_DATA_INIT(CIndexDimDlg)
|
|
// add by cwk on 060706
|
|
m_sFixAngle = g_sIndexDimFixAngle;
|
|
m_bFixAngle = g_bIndexDimFixAngle;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
void CIndexDimDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CBaseTextDlg::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CIndexDimDlg)
|
|
// sg modify 090507,仿照图名标注,试着解决“对象编辑中,有时候文字显示有问题”的BUG
|
|
if (pDX->m_bSaveAndValidate)
|
|
{
|
|
DDX_CBString(pDX, IDC_COMBO_INPUTTEXT, m_strInputUp);
|
|
DDX_CBString(pDX, IDC_COMBO_INPUTTEXT1, m_strInputDown);
|
|
DDX_CBString(pDX, IDC_CMB_DIMTEXT_STYLE, m_strDimStyle); // add by lgh 101216
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_COMBO_INPUTTEXT)->SetWindowText(m_strInputUp);
|
|
GetDlgItem(IDC_COMBO_INPUTTEXT1)->SetWindowText(m_strInputDown);
|
|
GetDlgItem(IDC_CMB_DIMTEXT_STYLE)->SetWindowText(m_strDimStyle); // add by lgh 101216
|
|
}
|
|
DDX_Control(pDX, IDC_COMBO_INPUTTEXT, m_comboInputText);
|
|
DDX_Control(pDX, IDC_COMBO_INPUTTEXT1, m_comboInputText1);
|
|
|
|
// modify by cwk on 060706
|
|
if (!m_bEditObj)
|
|
{
|
|
// [11/12/2007 nsh]
|
|
/*DDX_Text(pDX, IDC_EDIT_ANGLE, m_sFixAngle);*/
|
|
DDX_Text(pDX,IDC_COMBO1,m_sFixAngle); // 对固定角度的combox映射
|
|
}
|
|
|
|
DDX_Text(pDX, IDC_DRAWING_LABEL, m_strDrawing);
|
|
DDX_CBString(pDX, IDC_INDEX_LABEL, m_strIndex);
|
|
//Modify by cwk on 060706
|
|
DDX_Check(pDX, IDC_CONTINUE, m_bContinue);
|
|
DDX_Radio(pDX,IDC_INDEX_RADIO,m_iIndexType);
|
|
if (!m_bEditObj)
|
|
DDX_Check(pDX, IDC_CHECK1, m_bFixAngle);
|
|
// sg add 090122
|
|
DDX_Check(pDX, IDC_ADD_INDEX, m_bAddIndex);
|
|
DDX_CBIndex(pDX, IDC_COMBO_TEXTALIGN, m_nTextAlign); // sg add 090402
|
|
|
|
// lgh add 101216
|
|
DDX_Check(pDX, IDC_CHK_EXTTEXT, m_bDimOnExtent);
|
|
DDX_Check(pDX, IDC_CHK_MORE_CUT, m_bMoreCut);
|
|
DDX_Check(pDX, IDC_CHK_ADD_TURN, m_bAddTurn);
|
|
DDX_Control(pDX, IDC_CMB_DIMTEXT_STYLE, m_cmbDimStyle);
|
|
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
// [11/12/2007 nsh]-------------------
|
|
void CIndexDimDlg::ShowFixAngle()
|
|
{
|
|
this->UpdateData(TRUE);
|
|
if(m_iIndexType==0)
|
|
{
|
|
this->GetDlgItem(IDC_COMBO1)->ShowWindow(SW_SHOW); // 固定角度
|
|
this->GetDlgItem(IDC_CHECK1)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_ADD_INDEX)->ShowWindow(SW_SHOW); // sg add 090122,索引范围
|
|
GetDlgItem(IDC_CHK_ADD_TURN)->ShowWindow(SW_HIDE); // lgh add 101216
|
|
GetDlgItem(IDC_CHK_MORE_CUT)->ShowWindow(SW_HIDE); // lgh ...
|
|
}
|
|
else if(m_iIndexType==1)
|
|
{
|
|
this->GetDlgItem(IDC_COMBO1)->ShowWindow(SW_HIDE);
|
|
this->GetDlgItem(IDC_CHECK1)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_ADD_INDEX)->ShowWindow(SW_HIDE); // sg add 090122
|
|
GetDlgItem(IDC_CHK_ADD_TURN)->ShowWindow(SW_SHOW); // lgh add 101216
|
|
GetDlgItem(IDC_CHK_MORE_CUT)->ShowWindow(SW_SHOW); // lgh ...
|
|
}
|
|
this->UpdateData(FALSE);
|
|
}//---------------------------------------
|
|
|
|
BEGIN_MESSAGE_MAP(CIndexDimDlg, CBaseTextDlg)
|
|
//{{AFX_MSG_MAP(CIndexDimDlg)
|
|
ON_BN_CLICKED(IDC_CHECK1, OnCheckAngle)
|
|
// [11/12/2007 nsh]
|
|
ON_BN_CLICKED(IDC_SECT_RADIO,ShowFixAngle)
|
|
ON_BN_CLICKED(IDC_INDEX_RADIO,ShowFixAngle)
|
|
//-----------------------
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CIndexDimDlg message handlers
|
|
BOOL CIndexDimDlg::OnInitDialog()
|
|
{
|
|
CBaseTextDlg::OnInitDialog();
|
|
// [11/12/2007 nsh]
|
|
if(m_bFixAngle)
|
|
{
|
|
this->GetDlgItem(IDC_COMBO1)->EnableWindow(m_bFixAngle);
|
|
this->UpdateData(FALSE);
|
|
}
|
|
else
|
|
{
|
|
this->GetDlgItem(IDC_COMBO1)->EnableWindow(m_bFixAngle);
|
|
this->UpdateData(FALSE);
|
|
}
|
|
if(m_iIndexType==0)
|
|
{
|
|
if (!m_bModeless)
|
|
{
|
|
this->GetDlgItem(IDC_COMBO1)->ShowWindow(SW_HIDE);
|
|
this->GetDlgItem(IDC_CHECK1)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_ADD_INDEX)->ShowWindow(SW_HIDE);
|
|
}
|
|
else
|
|
{
|
|
this->GetDlgItem(IDC_COMBO1)->ShowWindow(SW_SHOW);
|
|
this->GetDlgItem(IDC_CHECK1)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_ADD_INDEX)->ShowWindow(SW_SHOW);
|
|
}
|
|
GetDlgItem(IDC_CHK_ADD_TURN)->ShowWindow(SW_HIDE); // lgh add 101216
|
|
GetDlgItem(IDC_CHK_MORE_CUT)->ShowWindow(SW_HIDE); // lgh ...
|
|
}
|
|
else if(m_iIndexType==1)
|
|
{
|
|
this->GetDlgItem(IDC_COMBO1)->ShowWindow(SW_HIDE);
|
|
this->GetDlgItem(IDC_CHECK1)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_ADD_INDEX)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHK_ADD_TURN)->ShowWindow(SW_SHOW); // lgh add 101216
|
|
GetDlgItem(IDC_CHK_MORE_CUT)->ShowWindow(SW_SHOW); // lgh ...
|
|
}
|
|
//////////////////////////////////////////////////
|
|
LoadHisText();
|
|
LoadDimTextStyle(); // lgh add 101216,初始化标注文字样式。
|
|
|
|
// sg modify 120706,增加一个判断,如果当前记忆的样式没有的话,那么使用上华固定的文字样式
|
|
//m_cmbDimStyle.SetCurSel(m_cmbDimStyle.FindString(0, m_strDimStyle));
|
|
int nRet = m_cmbDimStyle.FindStringExact(0, m_strDimStyle);
|
|
if (nRet < 0) // 当前图纸没有此样式
|
|
{
|
|
nRet = m_cmbDimStyle.FindStringExact(0, _T("_TCH_LABEL"));
|
|
}
|
|
m_cmbDimStyle.SetCurSel(nRet);
|
|
|
|
m_comboInputText.SetFocus();
|
|
UpdateVisible(!m_bEditObj);
|
|
|
|
return FALSE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
// Modify by lcf On 2005-07-05
|
|
CWnd* CIndexDimDlg::GetCurWnd()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd = this->GetFocus();
|
|
CWnd *pWnd2 = NULL;
|
|
|
|
if(m_comboInputText.m_hWnd == pWnd->GetParent()->m_hWnd) {
|
|
pWnd2 = GetDlgItem(IDC_COMBO_INPUTTEXT); // 把CWnd 回传给基类
|
|
m_strInputText = m_strInputUp;
|
|
}
|
|
else if(m_comboInputText1.m_hWnd == pWnd->GetParent()->m_hWnd) {
|
|
pWnd2 = GetDlgItem(IDC_COMBO_INPUTTEXT1); // 把CWnd 回传给基类
|
|
m_strInputText = m_strInputDown;
|
|
}
|
|
else
|
|
{
|
|
int nSel = m_comboInputText.GetWindowTextLength();
|
|
m_comboInputText.SetEditSel(nSel, nSel);
|
|
pWnd2 = GetDlgItem(IDC_COMBO_INPUTTEXT);
|
|
}
|
|
return(pWnd2);
|
|
}
|
|
|
|
void CIndexDimDlg::UpdateInputText()
|
|
{
|
|
CWnd *pWnd = this->GetFocus();
|
|
|
|
if(m_comboInputText.m_hWnd == pWnd->GetParent()->m_hWnd) {
|
|
m_strInputUp = m_strInputText;
|
|
}
|
|
if(m_comboInputText1.m_hWnd == pWnd->GetParent()->m_hWnd) {
|
|
m_strInputDown = m_strInputText;
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CIndexDimDlg::LoadDimTextStyle()
|
|
{
|
|
XSymbolList lstStyle(_T("STYLE"));
|
|
|
|
for (int m =0; m < lstStyle.Length(); m++)
|
|
m_cmbDimStyle.AddString(lstStyle[m]);
|
|
}
|
|
|
|
void CIndexDimDlg::OnOK()
|
|
{
|
|
AddToRecent();
|
|
CBaseTextDlg::OnOK();
|
|
}
|
|
|
|
// Add by lcf on 20050708
|
|
void CIndexDimDlg::AddToRecent()
|
|
{
|
|
UpdateData(TRUE);
|
|
{
|
|
int len = m_lstHistory.Length();
|
|
TCHAR strTmpPath[256] = _T("");
|
|
GetTempPath(255, strTmpPath);
|
|
_tcscat(strTmpPath, _T("index.his"));
|
|
#if (ADS>15)
|
|
std::
|
|
#endif
|
|
ofstream out(strTmpPath);
|
|
if(m_strInputUp != _T("")) {
|
|
out << (const char *)_AS(m_strInputUp) << "\n";
|
|
int index = m_lstHistory.Index(m_strInputUp);
|
|
if(index >= 0) {
|
|
m_lstHistory.Remove(index);
|
|
len --;
|
|
}
|
|
if(len > maxHisList-1) len = maxHisList - 1;
|
|
}
|
|
for(int i=0; i < len; i++)
|
|
out << _AS(m_lstHistory[i]) << "\n";
|
|
}
|
|
|
|
{
|
|
int len1 = m_lstHistory1.Length();
|
|
TCHAR strTmpPath1[256] = _T("");
|
|
GetTempPath(255, strTmpPath1);
|
|
_tcscat(strTmpPath1, _T("index1.his"));
|
|
#if (ADS>15)
|
|
std::
|
|
#endif
|
|
ofstream out1(strTmpPath1);
|
|
if(m_strInputDown != _T("")) {
|
|
out1 << (const char *)_AS(m_strInputDown) << "\n";
|
|
int index = m_lstHistory1.Index(m_strInputDown);
|
|
if(index >= 0) {
|
|
m_lstHistory1.Remove(index);
|
|
len1 --;
|
|
}
|
|
if(len1 > maxHisList-1) len1 = maxHisList - 1;
|
|
}
|
|
for(int i=0; i < len1; i++)
|
|
out1 <<_AS(m_lstHistory1[i])<< "\n";
|
|
}
|
|
|
|
m_lstHistory.Reset();
|
|
m_lstHistory1.Reset();
|
|
m_comboInputText.ResetContent();
|
|
m_comboInputText1.ResetContent();
|
|
LoadHisText();
|
|
}
|
|
|
|
void CIndexDimDlg::LoadHisText()
|
|
{
|
|
{
|
|
TCHAR strTmpPath[256] = _T("");
|
|
GetTempPath(255, strTmpPath);
|
|
_tcscat(strTmpPath, _T("index.his"));
|
|
#if (ADS>15)
|
|
std::
|
|
#endif
|
|
ifstream in(strTmpPath);
|
|
while(!(!in)) {
|
|
char line[256];
|
|
in.getline(line, 255);
|
|
if(!in) break;
|
|
m_lstHistory.Append(tstrnew(TString(line)));
|
|
}
|
|
for (int m =0; m < m_lstHistory.Length(); m++)
|
|
m_comboInputText.AddString(m_lstHistory[m]);
|
|
}
|
|
{
|
|
TCHAR strTmpPath[256] = _T("");
|
|
GetTempPath(255, strTmpPath);
|
|
_tcscat(strTmpPath, _T("index1.his"));
|
|
#if (ADS>15)
|
|
std::
|
|
#endif
|
|
ifstream in(strTmpPath);
|
|
while(!(!in)) {
|
|
char line[256];
|
|
in.getline(line, 255);
|
|
if(!in) break;
|
|
m_lstHistory1.Append(tstrnew(TString(line)));
|
|
}
|
|
for (int m =0; m < m_lstHistory1.Length(); m++)
|
|
m_comboInputText1.AddString(m_lstHistory1[m]);
|
|
}
|
|
UpdateData(false);
|
|
|
|
}
|
|
|
|
// Add by lcf on 20050713,设置“指向索引”、“剖切索引”是否可见
|
|
void CIndexDimDlg::UpdateVisible(BOOL bVisible)
|
|
{
|
|
if (bVisible)
|
|
{
|
|
GetDlgItem(IDC_INDEX_RADIO)->ShowWindow(SW_SHOW); // 指向索引
|
|
GetDlgItem(IDC_SECT_RADIO)->ShowWindow(SW_SHOW); // 剖切索引
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_INDEX_RADIO)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_SECT_RADIO)->ShowWindow(SW_HIDE);
|
|
}
|
|
}
|
|
|
|
// sg add 090415,设置“添加索引范围”是否可见
|
|
void CIndexDimDlg::SetSourceExtentVisible(BOOL bVisible)
|
|
{
|
|
if (bVisible && m_iIndexType==0)
|
|
GetDlgItem(IDC_ADD_INDEX)->ShowWindow(SW_SHOW);
|
|
else
|
|
GetDlgItem(IDC_ADD_INDEX)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
void CIndexDimDlg::SetSectRunView(BOOL bVisible)
|
|
{
|
|
if (bVisible && m_iIndexType==1)
|
|
{
|
|
GetDlgItem(IDC_CHK_MORE_CUT)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_CHK_ADD_TURN)->ShowWindow(SW_SHOW);
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_CHK_MORE_CUT)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHK_ADD_TURN)->ShowWindow(SW_HIDE);
|
|
}
|
|
}
|
|
|
|
double CIndexDimDlg::GetUpDimLen()
|
|
{
|
|
AcDbObjectId textStyle = GetTextStyleId(m_strFontStyle);
|
|
if(!textStyle)
|
|
return 0.0;
|
|
double dHei = _tstof(m_strHeight);
|
|
|
|
// 初始化宽度,按照单字节计算
|
|
int iMoreText = m_strInputUp.IsEmpty() ? 0 : 1; // 如果为空则不计算多余长度,否则多计算一个字符的长度
|
|
return CalcTextLen(m_strInputUp, textStyle, dHei, iMoreText);
|
|
}
|
|
|
|
double CIndexDimDlg::GetDownDimLen()
|
|
{
|
|
AcDbObjectId textStyle = GetTextStyleId(m_strFontStyle);
|
|
if(!textStyle)
|
|
return 0.0;
|
|
double dHei = _tstof(m_strHeight);
|
|
|
|
// 初始化宽度,按照单字节计算
|
|
int iMoreText = m_strInputDown.IsEmpty() ? 0 : 1;
|
|
return CalcTextLen(m_strInputDown, textStyle, dHei, iMoreText);
|
|
}
|
|
|
|
BOOL CIndexDimDlg::GetExtendsProp(CString &strUp, CString &strDown, double &dHei, AcDbObjectId &textStyle)
|
|
{
|
|
UpdateData();
|
|
|
|
if (m_bDimOnExtent)
|
|
{
|
|
strUp = m_strInputUp;
|
|
strDown = m_strInputDown;
|
|
textStyle = GetTextStyleId(m_strFontStyle);
|
|
if(!textStyle)
|
|
return FALSE;
|
|
dHei = _tstof(m_strHeight);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
void CIndexDimDlg::Dlg2Obj(TDbSymbIndexPointer *pText)
|
|
{
|
|
/*
|
|
AcDbObjectId idTextStyle = GetTextStyleId(sTextStyle);
|
|
if (!idTextStyle)
|
|
return;
|
|
|
|
pText->SetTextStyleId(idTextStyle);
|
|
g_nHeight = _tstof(m_strHeight);
|
|
pText->SetTextHeight(g_nHeight);
|
|
*/
|
|
CBaseTextDlg::Dlg2Obj(pText);
|
|
pText->SetText1(m_strInputUp);
|
|
pText->SetText2(m_strInputDown);
|
|
pText->SetIndexLabel(m_strIndex);
|
|
pText->SetDrawingLabel(m_strDrawing);
|
|
if (m_bModeless) // add by whl on 060324,设置索引符号类型
|
|
pText->SetIndexPointer(m_iIndexType==0);
|
|
|
|
// sg add 090402,增加文字相对于基线的对齐方式
|
|
TDbSymbIndexPointer::TSymbIPTextAlign nAlign =
|
|
(TDbSymbIndexPointer::TSymbIPTextAlign)(m_nTextAlign + 1);
|
|
pText->SetTextAlign(nAlign);
|
|
|
|
AcDbObjectId idFontStyle = GetTextStyleId(m_strFontStyle);
|
|
if (!idFontStyle)
|
|
return;
|
|
pText->SetDimTextStyle(idFontStyle);
|
|
|
|
AcDbObjectId idCircleTextStyle = GetTextStyleId(m_strDimStyle);
|
|
if (!idCircleTextStyle)
|
|
return;
|
|
pText->SetTextStyleId(idCircleTextStyle);
|
|
}
|
|
|
|
void CIndexDimDlg::Obj2Dlg(TDbSymbIndexPointer *pText)
|
|
{
|
|
CBaseTextDlg::Obj2Dlg(pText);
|
|
m_strInputUp = pText->GetText1();
|
|
m_strInputDown = pText->GetText2();
|
|
m_strDrawing = pText->GetDrawingLabel();
|
|
m_strIndex = pText->GetIndexLabel();
|
|
|
|
// sg add 090402,增加文字相对于基线的对齐方式
|
|
m_nTextAlign = (int)(pText->GetTextAlign() - 1);
|
|
|
|
m_strDimStyle = m_strFontStyle;
|
|
|
|
// lgh add 101224,标注文字样式
|
|
AcDbObjectId idDimStyle = pText->GetDimTextStyle();
|
|
OPENOBJ_BEGIN(idDimStyle, AcDb::kForRead, AcDbTextStyleTableRecord, pStyle);
|
|
ASSERT(pStyle);
|
|
const TCHAR* pName = NULL;
|
|
if (pStyle->getName(pName) == Acad::eOk && pName != NULL)
|
|
m_strFontStyle = pName;
|
|
else
|
|
AfxMessageBox(_T("文字风格已删除!"));
|
|
OPENOBJ_END();
|
|
|
|
// lgh add 101224,是否在延长线上标注文字
|
|
if (pText->GetDimPos() == 1)
|
|
m_bDimOnExtent = TRUE;
|
|
else
|
|
m_bDimOnExtent = FALSE;
|
|
}
|
|
|
|
// add by cwk on 060705
|
|
void CIndexDimDlg::OnCheckAngle()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
if (m_bFixAngle)
|
|
{
|
|
m_bFixAngle = false;
|
|
/*GetDlgItem(IDC_EDIT_ANGLE)->EnableWindow(FALSE);*/
|
|
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);// [11/12/2007 nsh]
|
|
}
|
|
else
|
|
{
|
|
m_bFixAngle = true;
|
|
/*GetDlgItem(IDC_EDIT_ANGLE)->EnableWindow();*/
|
|
GetDlgItem(IDC_COMBO1)->EnableWindow();// [11/12/2007 nsh]
|
|
}
|
|
}
|
|
|
|
|
|
|
|
CEditIndexDimDlg::CEditIndexDimDlg(CWnd* pParent /*=NULL*/)
|
|
: CIndexDimDlg(TRUE,CEditIndexDimDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CEditIndexDimDlg)
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
void CEditIndexDimDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CIndexDimDlg::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CEditIndexDimDlg)
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CEditIndexDimDlg, CIndexDimDlg)
|
|
//{{AFX_MSG_MAP(CEditIndexDimDlg)
|
|
ON_BN_CLICKED(IDC_BTN_ADD_CUT, OnAddCut)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
void CEditIndexDimDlg::AttachObject(TDbSymbIndexPointer *pText)
|
|
{
|
|
m_pTextAttached = pText;
|
|
}
|
|
|
|
BOOL CEditIndexDimDlg::OnInitDialog()
|
|
{
|
|
ASSERT(m_pTextAttached != NULL);
|
|
|
|
CBaseTextDlg::OnInitDialog();
|
|
|
|
//////////////////////////////////////////////////
|
|
LoadHisText();
|
|
LoadDimTextStyle(); // lgh add 101216,初始化标注文字样式。
|
|
m_cmbDimStyle.SetCurSel(m_cmbDimStyle.FindString(0, m_strDimStyle));
|
|
m_comboInputText.SetFocus();
|
|
UpdateVisible(!m_bEditObj);
|
|
|
|
if (m_pTextAttached->IsIndexPointer())
|
|
{
|
|
GetDlgItem(IDC_BTN_ADD_CUT)->ShowWindow(SW_HIDE);
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_BTN_ADD_CUT)->ShowWindow(SW_NORMAL);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void AddCutLineForIndexPointer(TDbSymbIndexPointer *pText);
|
|
void CEditIndexDimDlg::OnAddCut()
|
|
{
|
|
GetParent()->EnableWindow(TRUE);
|
|
GetParent()->SetFocus();
|
|
GetParent()->SetActiveWindow();
|
|
ShowWindow(SW_HIDE);
|
|
|
|
// 动态绘制命令
|
|
AddCutLineForIndexPointer(m_pTextAttached);
|
|
|
|
m_pTextAttached->draw();
|
|
|
|
// 调用CAD窗口立即更新
|
|
acedGetAcadDwgView()->Invalidate();
|
|
acedGetAcadDwgView()->UpdateWindow();
|
|
|
|
// 显示对话框
|
|
GetParent()->EnableWindow(FALSE);
|
|
EnableWindow(TRUE);
|
|
SetActiveWindow();
|
|
ShowWindow(SW_SHOW);
|
|
}
|
|
|
|
void CEditIndexDimDlg::AdjustExtentProp()
|
|
{
|
|
TDbSymbIndexPointer *pText = m_pTextAttached;
|
|
|
|
// if (!pText->HasExtendLine() && m_bDimOnExtent)
|
|
if (m_bDimOnExtent)
|
|
{ // 原先没有延长线,现在需要表在延长线上,需要计算延长线的长度,其他不管
|
|
CString sUpDim = m_strInputUp, sDownDim = m_strInputDown;
|
|
AcDbObjectId idDim = GetTextStyleId(m_strDimStyle);
|
|
if (!idDim)
|
|
return;
|
|
double dHei = _tstof(m_strHeight);
|
|
|
|
double dUpLen = 0.0, dDownLen = 0.0;
|
|
if (pText->IsSingleLineText(true))
|
|
{
|
|
dUpLen = CalcTextLen(sUpDim, idDim, dHei, 1);
|
|
}
|
|
else
|
|
{
|
|
dUpLen = CalcMTextLen(sUpDim, idDim, dHei, pText->GetTextWidthUp(), 1);
|
|
}
|
|
|
|
if (pText->IsSingleLineText(false))
|
|
{
|
|
dDownLen = CalcTextLen(sDownDim, idDim, dHei, 1);
|
|
}
|
|
else
|
|
{
|
|
dDownLen = CalcMTextLen(sDownDim, idDim, dHei, pText->GetTextWidthDown(), 1);
|
|
}
|
|
|
|
double dLen = max(dUpLen, dDownLen)/pText->GetPScale();
|
|
const double dMinLen = TDbSymbIndexPointer::GetDefaultExtendLineLen();
|
|
|
|
if (dLen < dMinLen)
|
|
dLen = dMinLen;
|
|
if (pText->GetExtendLineLen() < dLen)
|
|
pText->SetExtendLineLen(dLen);
|
|
}
|
|
else
|
|
pText->SetExtendLineLen(0.0);
|
|
|
|
pText->SetDimPos(m_bDimOnExtent ? 1 : 0);
|
|
}
|