Files
envi-code/SourceCode/Code2026/tg_shs/shs_annotate/RoadGradeDlg.cpp
T
2026-09-28 15:28:50 +08:00

705 lines
19 KiB
C++

// RoadGradeDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "RoadGradeDlg.h"
#include "DataLoadAndSave.h"
#include <math.h>
namespace
{
#define TARCH20_SYMBOL_KEY_ROADGRADE_CSTRING _T("RoadGrade_CString") //注册表项
#define TARCH20_SYMBOL_TERMNAME _T("AllControlWndData\\SymbolWndData") //键
#define DIVSTRING _T("^@^") //分割符号
#define NUM 3.5
#if ADS <= 18
double _ttof(LPCTSTR psz)
{
if (!psz) return .0;
USES_CONVERSION;
return atof(W2A(psz));
}
#endif
// 读取路径
CString GetFullPath(const TCHAR *szFileName)
{
CString szFullPath = g_sDwbPath;
if (_tcscmp(szFileName, _T("")) == 0)
{
szFullPath = szFullPath.Left(szFullPath.GetLength() - 5) + _T("\\sys\\");
}
else
{
szFullPath = szFullPath.Left(szFullPath.GetLength() - 5) + _T("\\sys\\") + szFileName;
// 用于动态添加文字样式文件时使用
CString csTmp = szFileName;
if (csTmp.Find(_T(".")) == -1)
{
szFullPath += _T(".tts");
}
}
return szFullPath;
}
CString format(int i)
{
CString str;
str.Format(L"%d", i);
return str;
}
CString format(bool bValue)
{
CString str;
str.Format(L"%d", (int)bValue);
return str;
}
CString MergeStr(const std::vector<CString>& subStr)
{
CString str = _T("");
CString strTemp = _T("");
std::vector<CString>::const_iterator iter = subStr.begin();
if (iter == subStr.end())
return str;
strTemp = *iter;
if (strTemp.IsEmpty()) strTemp = _T(" ");
str += strTemp;
++iter;
for (iter; iter != subStr.end(); ++iter)
{
strTemp = *iter;
if (strTemp.IsEmpty()) strTemp = _T(" ");
str += DIVSTRING + strTemp;
}
return str;
}
int SplitString(const LPCTSTR pszOri, const LPCTSTR pszSplit, std::vector<CString> &vec)
{
do
{
if (!pszOri) break;
vec.clear();
if (!pszSplit)
{
vec.push_back(pszOri);
return 1;
}
CString sOri(pszOri), sSplit(pszSplit), sRel(_T(""));
int nSplitLen(sSplit.GetLength()), nFindPos(0), nRel(0);
while ((nFindPos = sOri.Find(sSplit, 0)) != -1)
{
sRel = sOri.Mid(0, nFindPos);
vec.push_back(sRel);
sOri = sOri.Right(sOri.GetLength() - nFindPos - nSplitLen);
++nRel;
}
if (!sOri.IsEmpty())
{
vec.push_back(sOri);
++nRel;
}
return nRel;
} while (false);
return 0;
}
}
IMPLEMENT_DYNAMIC(CRoadGradeDlg, CModelessDialog)
CRoadGradeDlg::CRoadGradeDlg(CWnd* pParent /*=NULL*/)
: CModelessDialog(CRoadGradeDlg::IDD, pParent)
{
//文字样式”和“字高”的默认值受TextStyleDef.DAT文件控制,读取的是其中“其他符号”的参数;
m_strTextStyle = _T("");
m_strTextHigh = _T("");
SetDefalutTextStyleAndTextHight();
if (m_strTextStyle.IsEmpty())
m_strTextStyle = _T("_TCH_DIM");
if (m_strTextHigh.IsEmpty())
m_strTextHigh = _T("3.0");
m_strArrowSize = _T("3.0");
m_iArrowStyle = TDbSymbArrow::kHalfArrow ;
m_iAccuracyGrade = 2;
m_iAccuracyLength = 2;
m_bDis = TRUE;
m_bEqu = FALSE;
m_bPercent = TRUE;
m_bGrade = TRUE;
LoadDefaultRoadGradeData();
}
CRoadGradeDlg::~CRoadGradeDlg()
{
}
void CRoadGradeDlg::Dlg2Obj(TDbSymbArrow *pSymbArrow)
{
if (!pSymbArrow)
return;
pSymbArrow->SetArrowType(m_iArrowStyle == 0 ? TDbSymbArrow::kArrow : TDbSymbArrow::kHalfArrow);
double nSize = _tstof(m_strArrowSize);
if (nSize > 1.0E-3)
pSymbArrow->SetArrowSize(nSize);
pSymbArrow->SetText(_T(""));
pSymbArrow->SetText2(_T(""));
pSymbArrow->SetTextLocation(pSymbArrow->GetDefaultTextLocation());
pSymbArrow->SetText2Location(pSymbArrow->GetDefaultText2Location());
pSymbArrow->setLayer(InitLayer(LAY_OTHER_DIM));
pSymbArrow->SetTextAlign(TDbSymbArrow::kAlignMid);
pSymbArrow->SetTextStyleId(InitTextStyle(m_strTextStyle));
pSymbArrow->SetTextHeight(_tstof(m_strTextHigh));
// pSymbArrow->SetTextLayerId(InitLayer(LAY_TEXT, TRUE));
pSymbArrow->SetShowText2(TRUE);
pSymbArrow->SetLayoutRotation(Ucs2Wcs(0.0));
}
double CRoadGradeDlg::GetArrowSize()
{
return _tstof(m_strArrowSize);
}
BOOL CRoadGradeDlg::SetDisFormatData(TDbSymbArrow *pSymbArrow, double dDis, double dGrade)
{
if (pSymbArrow == NULL)
return FALSE;
pSymbArrow->SetArrowType(m_iArrowStyle == 0 ? TDbSymbArrow::kArrow : TDbSymbArrow::kHalfArrow);
pSymbArrow->SetTextHeight(_ttof(m_strTextHigh));
pSymbArrow->SetTextLocation(pSymbArrow->GetDefaultTextLocation());
pSymbArrow->SetText2Location(pSymbArrow->GetDefaultText2Location());
pSymbArrow->SetText(Double2StrByFormat(dGrade, FALSE));
pSymbArrow->SetText2(Double2StrByFormat(dDis));
pSymbArrow->setLayer(InitLayer(LAY_OTHER_DIM));
pSymbArrow->SetTextAlign(TDbSymbArrow::kAlignMid);
pSymbArrow->SetTextStyleId(InitTextStyle(m_strTextStyle));
// pSymbArrow->SetTextLayerId(InitLayer(LAY_TEXT, TRUE));
pSymbArrow->SetShowText2(TRUE);
pSymbArrow->SetLayoutRotation(Ucs2Wcs(0.0));
return TRUE;
}
int CRoadGradeDlg::GetArrowLineLength()
{
int iLen(0);
double dScale = DocGetPScale();
double dTmp = _ttof(m_strTextHigh);
if (m_bEqu)
{
iLen = 18 * dScale*((dTmp / 3.5) + (dTmp - (dTmp / 3.5)*3.5));
}
else
{
iLen = 15 * dScale*((dTmp / 3.5) + (dTmp - (dTmp / 3.5)*3.5));
}
return iLen;
}
CString CRoadGradeDlg::Double2StrByFormat(double dNums, BOOL bDis)
{
CString strTemp(_T(""));
if (bDis)//距离
{
if (!m_bDis)
return strTemp;
if (m_iAccuracyLength == 0)//0
{
strTemp.Format(_T("%d"), (int)dNums);
}
else if (m_iAccuracyLength == 1)//0.0
{
strTemp.Format(_T("%.1f"), dNums);
}
else if (m_iAccuracyLength == 2)//0.00
{
strTemp.Format(_T("%.2f"), dNums);
}
else if (m_iAccuracyLength == 3)//0.000
{
strTemp.Format(_T("%.3f"), dNums);
}
strTemp = m_bEqu == FALSE ? strTemp : (_T("L=") + strTemp);
}
else//坡度
{
if (!m_bGrade)
return strTemp;
if (m_iAccuracyGrade == 0)//0
{
strTemp.Format(_T("%d"), (int)dNums);
}
else if (m_iAccuracyGrade == 1)//0.0
{
strTemp.Format(_T("%.1f"), dNums);
}
else if (m_iAccuracyGrade == 2)//0.00
{
strTemp.Format(_T("%.2f"), dNums);
}
else if (m_iAccuracyGrade == 3)//0.000
{
strTemp.Format(_T("%.3f"), dNums);
}
strTemp = m_bPercent == FALSE ? strTemp : (strTemp + _T("%"));
strTemp = m_bEqu == FALSE ? strTemp : (_T("i=") + strTemp);
}
return strTemp;
}
void CRoadGradeDlg::DoDataExchange(CDataExchange* pDX)
{
CModelessDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CMB_TEXTSTYLE, m_CmbTextStyle);
DDX_CBString(pDX, IDC_CMB_TEXTHEIGHT, m_strTextHigh);
DDX_CBString(pDX, IDC_CMB_ARROWSIZE, m_strArrowSize);
}
BEGIN_MESSAGE_MAP(CRoadGradeDlg, CModelessDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
ON_BN_CLICKED(IDC_CHK_GRADE, OnBnClickedChkGrade)
ON_BN_CLICKED(IDC_CHK_LENGTH, OnBnClickedChkLength)
ON_BN_CLICKED(IDC_BTN_TEXTHEIGHT, OnBnClickedBtnTextheight)
ON_BN_CLICKED(IDC_CHK_EQNSTYLE, OnBnClickedChkEqnstyle)
ON_BN_CLICKED(IDC_CHK_GRADE_PERCENT, OnBnClickedChkGradePercent)
ON_CBN_SELCHANGE(IDC_CMB_ARROWSIZE, OnCbnSelchangeCmbArrowsize)
ON_CBN_SELCHANGE(IDC_CMB_TEXTHEIGHT, OnCbnSelchangeCmbTextheight)
ON_CBN_EDITCHANGE(IDC_CMB_ARROWSIZE, OnCbnEditchangeCmbArrowsize)
//ON_CBN_SELCHANGE(IDC_CMB_UNITS, OnCbnSelchangeCmbUnits)
ON_CBN_EDITCHANGE(IDC_CMB_TEXTHEIGHT, OnCbnEditchangeCmbTextheight)
ON_CBN_SELCHANGE(IDC_CMB_ARROWSTYLE, OnCbnSelchangeCmbArrowstyle)
ON_CBN_SELCHANGE(IDC_CMB_GRADE, OnCbnSelchangeCmbGrade)
ON_CBN_SELCHANGE(IDC_CMB_LENGTH, OnCbnSelchangeCmbLength)
ON_CBN_SELCHANGE(IDC_CMB_TEXTSTYLE, OnCbnSelchangeCmbTextstyle)
END_MESSAGE_MAP()
BOOL CRoadGradeDlg::OnInitDialog()
{
CModelessDialog::OnInitDialog();
LoadDefaultRoadGradeData();
if (m_bDis)
{
((CStatic*)GetDlgItem(IDC_STC_LENGTH))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CMB_LENGTH))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CHK_LENGTH))->SetCheck(1);
m_cmbStatus.push_back(1);
}
if (m_bGrade)
{
((CStatic*)GetDlgItem(IDC_STC_GRADE))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CMB_GRADE))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CHK_GRADE_PERCENT))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CHK_GRADE))->SetCheck(1);
m_cmbStatus.push_back(1);
}
if (!m_bDis)
{
((CStatic*)GetDlgItem(IDC_STC_LENGTH))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_CMB_LENGTH))->EnableWindow(FALSE);
}
if (!m_bGrade)
{
((CStatic*)GetDlgItem(IDC_STC_GRADE))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_CMB_GRADE))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_CHK_GRADE_PERCENT))->EnableWindow(FALSE);
}
if (!m_bGrade && !m_bDis)
{
((CStatic*)GetDlgItem(IDC_STC_LENGTH))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CMB_LENGTH))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CHK_LENGTH))->SetCheck(1);
m_cmbStatus.push_back(1);
m_bGrade = TRUE;
((CStatic*)GetDlgItem(IDC_STC_LENGTH))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CMB_LENGTH))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CHK_LENGTH))->SetCheck(1);
m_cmbStatus.push_back(1);
m_bDis = TRUE;
}
if (m_bEqu)
{
((CButton*)GetDlgItem(IDC_CHK_EQNSTYLE))->SetCheck(1);
}
if (m_bPercent)
{
((CButton*)GetDlgItem(IDC_CHK_GRADE_PERCENT))->SetCheck(1);
}
((CComboBox*)GetDlgItem(IDC_CMB_ARROWSTYLE))->InsertString(0, _T("箭头")); //0
((CComboBox*)GetDlgItem(IDC_CMB_ARROWSTYLE))->InsertString(1, _T("半箭头")); //1
((CComboBox*)GetDlgItem(IDC_CMB_ARROWSTYLE))->SetCurSel(m_iArrowStyle);
//int i = ((CComboBox*)GetDlgItem(IDC_CMB_UNITS))->InsertString(0, L"mm M");//单位 0
//int x = ((CComboBox*)GetDlgItem(IDC_CMB_UNITS))->InsertString(1, L"M M"); //1
//if (DocGetMeterUnitDraw())//获取当前单位
// ((CComboBox*)GetDlgItem(IDC_CMB_UNITS))->SetCurSel(1);
//else
// ((CComboBox*)GetDlgItem(IDC_CMB_UNITS))->SetCurSel(0);
LoadAccuracyStyle(IDC_CMB_LENGTH); //距离精度
LoadAccuracyStyle(IDC_CMB_GRADE); //坡度精度
((CComboBox*)GetDlgItem(IDC_CMB_LENGTH))->SetCurSel(m_iAccuracyLength);
((CComboBox*)GetDlgItem(IDC_CMB_GRADE))->SetCurSel(m_iAccuracyGrade);
LoadTextStyle();//加载文字样式
LoadSize(IDC_CMB_ARROWSIZE);
LoadSize(IDC_CMB_TEXTHEIGHT);
int nRet = ((CComboBox*)GetDlgItem(IDC_CMB_TEXTHEIGHT))->FindStringExact(0, m_strTextHigh);
if (nRet < 0) // 当前图纸没有此文字高度
{
((CComboBox*)GetDlgItem(IDC_CMB_TEXTHEIGHT))->InsertString(0, m_strTextHigh);
((CComboBox*)GetDlgItem(IDC_CMB_TEXTHEIGHT))->SetCurSel(0);
UpdateData(FALSE);
}
else
((CComboBox*)GetDlgItem(IDC_CMB_TEXTHEIGHT))->SetCurSel(nRet);
nRet = ((CComboBox*)GetDlgItem(IDC_CMB_ARROWSIZE))->FindStringExact(0, m_strArrowSize);
if (nRet < 0) // 当前图纸没有此箭头大小
{
((CComboBox*)GetDlgItem(IDC_CMB_ARROWSIZE))->InsertString(0, m_strArrowSize);
((CComboBox*)GetDlgItem(IDC_CMB_ARROWSIZE))->SetCurSel(0);
UpdateData(FALSE);
}
else
((CComboBox*)GetDlgItem(IDC_CMB_ARROWSIZE))->SetCurSel(nRet);
return TRUE;
}
//获取默认的文字样式和文字字高
void CRoadGradeDlg::SetDefalutTextStyleAndTextHight()
{
//判断TextStyleDef.DAT文件路径是否存在
CString szTextStyleDefFile(_T(""));
szTextStyleDefFile = GetFullPath(_T("TextStyleDef.DAT"));
if (_taccess(szTextStyleDefFile, 0) == -1)
return;
//读取文件内容
CStdioFile file;
if (!file.Open(szTextStyleDefFile, CFile::modeRead))
{
AfxMessageBox(CString(_T("打开文件 \"")) + szTextStyleDefFile + _T("\" 失败"));
return;
}
CString sReadString(_T(""));
while (file.ReadString(sReadString))
{
TCHAR sKey[256] = _T(""); // 关键字
TCHAR sName[256] = _T(""); // 样式名称
TCHAR sChinese[265] = _T(""); // 中文字体
TCHAR sEnglish[256] = _T(""); // 西文字体
TCHAR sWindows[256] = _T(""); // Windows字体
float dHeigh(0.0), // 字高
dChineseScale(0.0), // 中文宽高比
dHeighScale(0.0), // 高度比例
dWideScale(0.0); // 宽度比例
//int nColor = 0; // 颜色
TCHAR sNote[256] = _T(""); // 备注
// 读出数据
_stscanf(sReadString, _T("%s%s%s%s%s%f%f%f%f%s"), sKey, sName, sWindows, sChinese, sEnglish,
&dChineseScale, &dHeighScale, &dWideScale, &dHeigh, sNote);
if (_tcscmp(sKey, _T("其他符号")) == 0)
{
if (m_strTextHigh.IsEmpty())
m_strTextHigh.Format(_T("%.1f"), dHeigh);
if (m_strTextStyle.IsEmpty())
m_strTextStyle = sName;
break;
}
}
file.Close();
}
BOOL CRoadGradeDlg::LoadTextStyle()
{
XSymbolList lstStyle(_T("STYLE"));//控件初始化
for (int m = 0; m < lstStyle.Length(); m++)
m_CmbTextStyle.AddString(lstStyle[m]);
int nRet = m_CmbTextStyle.FindStringExact(0, m_strTextStyle);
if (nRet < 0) // 当前图纸没有此文字样式
{
m_strTextStyle = GetTextStyleName(TS_SYMBOL); // 默认文字样式
nRet = m_CmbTextStyle.FindStringExact(0, m_strTextStyle);//默认值
}
m_CmbTextStyle.SetCurSel(nRet);
return TRUE;
}
void CRoadGradeDlg::LoadAccuracyStyle(int iID)
{
((CComboBox*)GetDlgItem(iID))->InsertString(0, _T("0")); //精度 0
((CComboBox*)GetDlgItem(iID))->InsertString(1, _T("0.0")); // 1
((CComboBox*)GetDlgItem(iID))->InsertString(2, _T("0.00")); // 2
((CComboBox*)GetDlgItem(iID))->InsertString(3, _T("0.000")); // 3
}
void CRoadGradeDlg::LoadSize(int iID)
{
((CComboBox*)GetDlgItem(iID))->InsertString(0, _T("1.0")); //0
((CComboBox*)GetDlgItem(iID))->InsertString(1, _T("1.5")); //1
((CComboBox*)GetDlgItem(iID))->InsertString(2, _T("2.0")); //2
((CComboBox*)GetDlgItem(iID))->InsertString(3, _T("2.5")); //3
((CComboBox*)GetDlgItem(iID))->InsertString(4, _T("3.0")); //4
((CComboBox*)GetDlgItem(iID))->InsertString(5, _T("3.5")); //5
((CComboBox*)GetDlgItem(iID))->InsertString(6, _T("5.0")); //6
((CComboBox*)GetDlgItem(iID))->InsertString(7, _T("7.0")); //7
((CComboBox*)GetDlgItem(iID))->InsertString(8, _T("10.0")); //8
((CComboBox*)GetDlgItem(iID))->InsertString(9, _T("14.0")); //9
((CComboBox*)GetDlgItem(iID))->InsertString(10, _T("20.0")); //10
}
//点击确定
void CRoadGradeDlg::OnBnClickedOk()
{
SetDefaultRoadGradeData();
CModelessDialog::OnOK();
}
//点击取消
void CRoadGradeDlg::OnBnClickedCancel()
{
LoadDefaultRoadGradeData();
CModelessDialog::OnCancel();
}
//点击字高
void CRoadGradeDlg::OnBnClickedBtnTextheight()
{
OnButtonTextHeight();
}
//点击坡度
void CRoadGradeDlg::OnBnClickedChkGrade()
{
int iType(1);
if (((CButton*)GetDlgItem(IDC_CHK_GRADE))->GetCheck())
{
m_cmbStatus.push_back(iType);
((CButton*)GetDlgItem(IDC_CHK_GRADE))->SetCheck(1);
m_bGrade = TRUE;
}
else
{
m_cmbStatus.pop_back();
if (m_cmbStatus.size() < 1)
{
((CButton*)GetDlgItem(IDC_CHK_GRADE))->SetCheck(1);
m_cmbStatus.push_back(iType);
m_bGrade = TRUE;
}
else
{
((CButton*)GetDlgItem(IDC_CHK_GRADE))->SetCheck(0);
m_bGrade = FALSE;
}
}
if (m_cmbStatus.size() == 1 && m_bGrade == FALSE)
{
((CButton*)GetDlgItem(IDC_CMB_GRADE))->EnableWindow(FALSE);
((CStatic*)GetDlgItem(IDC_STC_GRADE))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_CHK_GRADE_PERCENT))->EnableWindow(FALSE);
}
if (m_bGrade)
{
((CButton*)GetDlgItem(IDC_CMB_GRADE))->EnableWindow(TRUE);
((CStatic*)GetDlgItem(IDC_STC_GRADE))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_CHK_GRADE_PERCENT))->EnableWindow(TRUE);
}
}
//点击距离
void CRoadGradeDlg::OnBnClickedChkLength()
{
int iType = 1;
if (((CButton*)GetDlgItem(IDC_CHK_LENGTH))->GetCheck())
{
m_cmbStatus.push_back(iType);
((CButton*)GetDlgItem(IDC_CHK_GRADE))->SetCheck(1);
m_bDis = TRUE;
}
else
{
m_cmbStatus.pop_back();
if (m_cmbStatus.size() < 1)
{
((CButton*)GetDlgItem(IDC_CHK_LENGTH))->SetCheck(1);
m_cmbStatus.push_back(iType);
m_bDis = TRUE;
}
else
{
((CButton*)GetDlgItem(IDC_CHK_LENGTH))->SetCheck(0);
m_bDis = FALSE;
}
}
if (m_cmbStatus.size() == 1 && m_bDis == FALSE)
{
((CButton*)GetDlgItem(IDC_CMB_LENGTH))->EnableWindow(FALSE);
((CStatic*)GetDlgItem(IDC_STC_LENGTH))->EnableWindow(FALSE);
}
if (m_bDis)
{
((CButton*)GetDlgItem(IDC_CMB_LENGTH))->EnableWindow(TRUE);
((CStatic*)GetDlgItem(IDC_STC_LENGTH))->EnableWindow(TRUE);
}
}
void CRoadGradeDlg::OnButtonTextHeight()
{
GetTextHeight();
acedGetAcadDwgView()->SetFocus();
}
void CRoadGradeDlg::GetTextHeight()
{
UpdateData(TRUE);
double nHeight = _tstof(m_strTextHigh)*DocGetPScale();
BeginEditorCommand();
if (GetDist(_T("\n字高"), nHeight, RSG_NOZERO | RSG_NONEG) == RTNORM) {
nHeight /= DocGetPScale();
m_strTextHigh.Format(_T("%.1f"), nHeight);
}
CompleteEditorCommand();
UpdateData(FALSE);
}
//点击等式表示
void CRoadGradeDlg::OnBnClickedChkEqnstyle()
{
if (((CButton*)GetDlgItem(IDC_CHK_EQNSTYLE))->GetCheck())
m_bEqu = TRUE;
else
m_bEqu = FALSE;
}
//点击 %表示
void CRoadGradeDlg::OnBnClickedChkGradePercent()
{
if (((CButton*)GetDlgItem(IDC_CHK_GRADE_PERCENT))->GetCheck())
m_bPercent = TRUE;
else
m_bPercent = FALSE;
}
void CRoadGradeDlg::OnCbnSelchangeCmbArrowsize()
{
int index = ((CComboBox*)GetDlgItem(IDC_CMB_ARROWSIZE))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_CMB_ARROWSIZE))->GetLBText(index, m_strArrowSize);
}
void CRoadGradeDlg::OnCbnSelchangeCmbGrade()
{
m_iAccuracyGrade = ((CComboBox*)GetDlgItem(IDC_CMB_GRADE))->GetCurSel();
}
void CRoadGradeDlg::OnCbnSelchangeCmbLength()
{
m_iAccuracyLength = ((CComboBox*)GetDlgItem(IDC_CMB_LENGTH))->GetCurSel();
}
void CRoadGradeDlg::OnCbnSelchangeCmbTextstyle()
{
int index = ((CComboBox*)GetDlgItem(IDC_CMB_TEXTSTYLE))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_CMB_TEXTSTYLE))->GetLBText(index, m_strTextStyle);
}
void CRoadGradeDlg::OnCbnSelchangeCmbTextheight()
{
int index = ((CComboBox*)GetDlgItem(IDC_CMB_TEXTHEIGHT))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_CMB_TEXTHEIGHT))->GetLBText(index, m_strTextHigh);
}
void CRoadGradeDlg::OnCbnEditchangeCmbArrowsize()
{
UpdateData(TRUE);
}
//void CRoadGradeDlg::OnCbnSelchangeCmbUnits()
//{
// int i = ((CComboBox*)GetDlgItem(IDC_CMB_UNITS))->GetCurSel();
// if (i)//M
// {
// DocSetMeterUnitDraw(TRUE);
// DocSetPScale(1);
// }
// else//mm
// {
// DocSetMeterUnitDraw(FALSE);
// DocSetPScale(100);
// }
// DocStatus();
//}
void CRoadGradeDlg::OnCbnEditchangeCmbTextheight()
{
UpdateData(TRUE);
}
void CRoadGradeDlg::OnCbnSelchangeCmbArrowstyle()
{
m_iArrowStyle = ((CComboBox*)GetDlgItem(IDC_CMB_ARROWSTYLE))->GetCurSel();
}
//写入数据到注册表中
void CRoadGradeDlg::SetDefaultRoadGradeData()
{
std::vector<CString> strWndData;
CString str(_T(""));
strWndData.clear();
strWndData.push_back(m_strTextStyle);
strWndData.push_back(m_strTextHigh);
strWndData.push_back(m_strArrowSize);
strWndData.push_back(format(m_iAccuracyGrade));
strWndData.push_back(format(m_iAccuracyLength));
strWndData.push_back(format(m_iArrowStyle));
strWndData.push_back(format(m_bDis));
strWndData.push_back(format(m_bEqu));
strWndData.push_back(format(m_bPercent));
strWndData.push_back(format(m_bGrade));
CString strTmp = MergeStr(strWndData);//组合字符串
DataLoadAndSave::writeRecordDataCString(TARCH20_SYMBOL_KEY_ROADGRADE_CSTRING, strTmp, TARCH20_SYMBOL_TERMNAME);
}
//读取注册表数据
void CRoadGradeDlg::LoadDefaultRoadGradeData()
{
CString strTmp;
DataLoadAndSave::readRecordDataCString(TARCH20_SYMBOL_KEY_ROADGRADE_CSTRING, strTmp, TARCH20_SYMBOL_TERMNAME);
if (strTmp.IsEmpty())
return;
//将str划分为vector<CString>使用 DIVSTRING 为分隔符
std::vector<CString> strWndData;
SplitString(strTmp, DIVSTRING, strWndData);
if (strWndData.size() < 10)
{
return;
}
m_strTextStyle = strWndData[0];
m_strTextHigh = strWndData[1];
m_strArrowSize = strWndData[2];
m_iAccuracyGrade = _ttoi(strWndData[3]);
m_iAccuracyLength = _ttoi(strWndData[4]);
m_iArrowStyle = _ttoi(strWndData[5]);
m_bDis = _ttoi(strWndData[6]);
m_bEqu = _ttoi(strWndData[7]);
m_bPercent = _ttoi(strWndData[8]);
m_bGrade = _ttoi(strWndData[9]);
}