#include "StdAfx.h" #include "EditSectionDlg.h" CString CEditSectionDlg::m_strSectionNum = _T("1"); CString CEditSectionDlg::m_strStyle = GetTextStyleName(TS_SECTION); //获得默认剖切编号的文字样式 CString CEditSectionDlg::m_strHeight = _T("5.0"); int CEditSectionDlg::m_bCheck = FALSE; CString CEditSectionDlg::m_strDrawingNum = _T("1"); int CEditSectionDlg::m_iLocal = 0; int CEditSectionDlg::m_iDirect = 0; CString CEditSectionDlg::m_strDrawingHeight = _T("3.5"); CString CEditSectionDlg::m_strTextStyle = GetTextStyleName(TS_INDEXSCALE);//获得默认剖切图号文字样式 BOOL CEditSectionDlg::m_bSection = FALSE; IMPLEMENT_DYNAMIC(CEditSectionDlg, CModelessDialog) CEditSectionDlg::CEditSectionDlg(CWnd *pParent) :CModelessDialog(CEditSectionDlg::IDD, pParent) { } CEditSectionDlg::~CEditSectionDlg(void) { } BEGIN_MESSAGE_MAP(CEditSectionDlg, CModelessDialog) ON_BN_CLICKED(IDC_CHK_EDRAWING, OnBnClickDrawNum) ON_BN_CLICKED(IDC_BTN_EWORDHIGHT, OnBnClickedBtnWordhight) ON_BN_CLICKED(IDC_BTN_EDRAWINGHEIGHT, OnBnClickedBtnDrawingheight) END_MESSAGE_MAP() void CEditSectionDlg::DoDataExchange(CDataExchange* pDX) { CModelessDialog::DoDataExchange(pDX); DDX_CBString(pDX, IDC_CMB_ESECTIONNUM, m_strSectionNum); if(pDX->m_bSaveAndValidate) { DDX_CBString(pDX, IDC_CMB_ESECTIONTEXT, m_strStyle); } DDX_CBString(pDX, IDC_CMB_EWORDHEIGHT, m_strHeight); DDX_Text(pDX, IDC_EDT_EDRAWINGNUM, m_strDrawingNum); DDX_CBIndex(pDX, IDC_CMB_ESECTIONPOSITION, m_iLocal); DDX_CBIndex(pDX, IDC_CMB_ESECTIONDIRECT, m_iDirect); DDX_CBString(pDX, IDC_CMB_EDRAWINGHEIGHT, m_strDrawingHeight); if(pDX->m_bSaveAndValidate) { DDX_CBString(pDX, IDC_CMB_EDRAWTEXTSTYLE, m_strTextStyle); } DDX_Check(pDX, IDC_CHK_EDRAWING, m_bCheck); DDX_Control(pDX, IDC_CMB_EDRAWTEXTSTYLE, m_cmbDrawStyle); DDX_Control(pDX, IDC_CMB_ESECTIONTEXT, m_cmbStyleName); DDX_Radio(pDX, IDC_RAD_SECTION, m_bSection); } BOOL CEditSectionDlg::OnInitDialog() { CModelessDialog::OnInitDialog(); AddTip(IDC_STATIC_LOCAL, _T("设置剖面图号是标注在剖切符号的两端还是其中一端")); AddTip(IDC_STATIC_DIRECT, _T("设置剖面图号的文字方向是沿剖切方向还是剖视方向")); LoadTextStyle(); //加载文字样式 OnBnClickDrawNum(); UpdateData(FALSE); return TRUE; } void CEditSectionDlg::LoadTextStyle() { XSymbolList lstStyle(_T("STYLE")); for (int m =0; m < lstStyle.Length(); m++) //初始化文字样式 { m_cmbStyleName.AddString(lstStyle[m]); m_cmbDrawStyle.AddString(lstStyle[m]); } m_cmbStyleName.SetCurSel(m_cmbStyleName.FindStringExact(0, m_strStyle)); m_cmbDrawStyle.SetCurSel(m_cmbDrawStyle.FindStringExact(0, m_strTextStyle)); } CString CEditSectionDlg::GetSectionNum() { UpdateData(TRUE); return m_strSectionNum; } CString CEditSectionDlg::GetNumStyle() { UpdateData(TRUE); return m_strStyle; } double CEditSectionDlg::GetNumHeight() { UpdateData(TRUE); return _tstof(m_strHeight); } CString CEditSectionDlg::GetDrawNum() { UpdateData(TRUE); return m_strDrawingNum; } int CEditSectionDlg::GetLocal() { UpdateData(TRUE); return m_iLocal; } int CEditSectionDlg::GetDirect() { UpdateData(TRUE); return m_iDirect; } CString CEditSectionDlg::GetDrawingStyle() { UpdateData(TRUE); return m_strTextStyle; } double CEditSectionDlg::GetDrawHeight() { UpdateData(TRUE); return _tstof(m_strDrawingHeight); } void CEditSectionDlg::OnBnClickDrawNum() { UpdateData(TRUE); if (!m_bCheck) //是否编辑剖切图号 { GetDlgItem(IDC_CMB_EDRAWTEXTSTYLE)->EnableWindow(FALSE); GetDlgItem(IDC_EDT_EDRAWINGNUM)->EnableWindow(FALSE); GetDlgItem(IDC_CMB_ESECTIONPOSITION)->EnableWindow(FALSE); GetDlgItem(IDC_CMB_ESECTIONDIRECT)->EnableWindow(FALSE); GetDlgItem(IDC_CMB_EDRAWINGHEIGHT)->EnableWindow(FALSE); GetDlgItem(IDC_BTN_EDRAWINGHEIGHT)->EnableWindow(FALSE); } else { GetDlgItem(IDC_CMB_EDRAWTEXTSTYLE)->EnableWindow(TRUE); GetDlgItem(IDC_EDT_EDRAWINGNUM)->EnableWindow(TRUE); GetDlgItem(IDC_CMB_ESECTIONPOSITION)->EnableWindow(TRUE); GetDlgItem(IDC_CMB_ESECTIONDIRECT)->EnableWindow(TRUE); GetDlgItem(IDC_CMB_EDRAWINGHEIGHT)->EnableWindow(TRUE); GetDlgItem(IDC_BTN_EDRAWINGHEIGHT)->EnableWindow(TRUE); } UpdateData(FALSE); } BOOL CEditSectionDlg::GetIsShowDrawText() { return m_bCheck; } void CEditSectionDlg::Dlg2Obj(TDbSymbSection *pSection)//将对话框中内容设置到实体中 { pSection->SetText(m_strSectionNum); pSection->SetTextStyleId(InitTextStyle(m_strStyle));//设置剖切编号文字样式 pSection->SetTextHeight(_tstof(m_strHeight)); if (m_bCheck) { pSection->SetIndexStyleId(InitTextStyle(m_strTextStyle)); pSection->SetIndexHeight(_tstof(m_strDrawingHeight)); pSection->SetDrawingIndex(m_strDrawingNum); if (m_iDirect == 0)//沿剖切线 { pSection->SetDimDirection(0); } else { pSection->SetDimDirection(1); } if (m_iLocal == 0)//两端 { pSection->SetIsHasIndexS(TRUE); pSection->SetIsHasIndexE(TRUE); } else if (m_iLocal == 1)//始端 { pSection->SetIsHasIndexS(TRUE); pSection->SetIsHasIndexE(FALSE); } else if (m_iLocal == 2)//终端 { pSection->SetIsHasIndexS(FALSE); pSection->SetIsHasIndexE(TRUE); } } else { pSection->SetIsHasIndexE(FALSE); pSection->SetIsHasIndexS(FALSE); } pSection->SetViewLine(!m_bSection);//是否是断面剖切还是剖面剖切 } void CEditSectionDlg::Obj2Dlg(TDbSymbSection *pSection) { m_strSectionNum = pSection->GetText(); double dHeight = pSection->GetTextHeight(); m_strHeight.Format(_T("%0.1f"), dHeight); dHeight = pSection->GetIndexHeight(); m_strDrawingHeight.Format(_T("%0.1f"), dHeight); m_strStyle = GetSymbolName(pSection->GetTextStyleId()); if (!pSection->GetIsHasIndexS() && !pSection->GetIsHasIndexE())//判断是否编辑剖切图号 { m_bCheck = FALSE; } else { m_bCheck = TRUE; } // sg modify 120612,以下数据从“m_bCheck = TRUE”分支中移出,无论是否标注图号,数据都是要来自对象的 if (pSection->GetIsHasIndexS()&&pSection->GetIsHasIndexE()) { m_iLocal = 0; //两端标注 } if (pSection->GetIsHasIndexS()&&!pSection->GetIsHasIndexE()) { m_iLocal = 1; //首端标注 } if (!pSection->GetIsHasIndexS()&&pSection->GetIsHasIndexE()) { m_iLocal = 2; //尾端标注 } m_strTextStyle = GetSymbolName(pSection->GetIndexStyleId()); m_strDrawingNum = pSection->GetDrawingIndex(); m_iDirect = pSection->GetDimDirection(); m_bSection = !pSection->HasViewLine(); } void CEditSectionDlg::OnBnClickedBtnWordhight() { UpdateData(TRUE); XPushAutoHide noAutoHide(this); double dHeight = _tstof(m_strHeight); dHeight = dHeight*DocGetPScale(); BeginEditorCommand(); if(GetDist(_T("\n字高"), dHeight, RSG_NOZERO|RSG_NONEG) == RTNORM) { dHeight /= DocGetPScale();//获得的字高除以当前图纸比例 CString str; str.Format(_T("%.1f"), dHeight); m_strHeight = str; } CompleteEditorCommand(); UpdateData(FALSE); } void CEditSectionDlg::OnBnClickedBtnDrawingheight() { UpdateData(TRUE); XPushAutoHide noAutoHide(this); double dHeight = _tstof(m_strDrawingHeight); dHeight = dHeight*DocGetPScale(); BeginEditorCommand(); if(GetDist(_T("\n字高"), dHeight, RSG_NOZERO|RSG_NONEG) == RTNORM) { dHeight /= DocGetPScale(); CString str; str.Format(_T("%.1f"), dHeight); m_strDrawingHeight = str; } CompleteEditorCommand(); UpdateData(FALSE); }