📄 mfctempl.cpp
字号:
switch(iType)
{
case 1:
rEndZH = rbSeek(rbSeek(pRb1, 1040), 1040)->resval.rreal;
break;
case 2:
rEndZH = rbSeek(rbSeek(pRb1, 1040), 1040)->resval.rreal;
break;
case 3:
for(int i = 0; i < 3; i++) pRb1 = pRb1->rbnext;
rEndZH = rbSeek(pRb1, 1041)->resval.rreal;
break;
return FALSE;
}
ads_printf("终点桩=%f\n 路线终点单元句柄=%s", rEndZH, strEndHandle);
//释放内存
ads_relrb(pRb);
ads_relrb(pRb1);
return TRUE;
}
//绘制柱形墩
void DrawCirCleQD(ads_point pt, double r)
{
MakeCircle(pt, r, 256, "桥墩位", NULL, true);
}
//绘制矩形墩
void DrawPlineQD(double rWidth, double rDeep, ads_point pt, double rFwj)
{
double rAngle = 0.0;
ads_point ppt[5];
rAngle = ConvertPolar(rFwj) + PI / 2.0;
ads_polar(pt, rAngle, rWidth / 2.0, ppt[0]);
ads_polar(ppt[0], rAngle - PI / 2.0, rDeep / 2.0, ppt[0]);
ads_polar(ppt[0], rAngle - PI, rWidth, ppt[1]);
ads_polar(ppt[1], rAngle + PI / 2.0, rDeep, ppt[2]);
ads_polar(ppt[2], rAngle, rWidth, ppt[3]);
Cpoint(ppt[4], ppt[0]);
MakePlineEx(5, "桥墩位", ppt, 0.0, 255, NULL, TRUE);
}
int CStrToFJ(CString strSource, CStringArray *rData, CString sc)
{
int pos, i = 0;
CString strSrc = strSource, strTemp;
rData->RemoveAll();
while ( !strSrc.IsEmpty() )
{
strSrc.TrimLeft(sc);
if ( (pos = strSrc.FindOneOf(sc)) == -1 )
{
strTemp = strSrc;
pos = strSrc.GetLength() - 1;
}
else
strTemp = strSrc.Left(pos);
if ( !strTemp.IsEmpty() )
{
rData->Add(strTemp);
i++;
}
strSrc = strSrc.Right( strSrc.GetLength() - pos - 1 );
}
return i;
}
double CovStrToZH(CString str, double rSTartST, CArray <double, double> &bnn)
{
int n = 0, i = 0, j = 0, k = 0;
double rLen = 0.0, rTemp = 0.0;
CStringArray strfd, strbl;
rTemp = rSTartST;
bnn.Add(rTemp);
n = CStrToFJ(str, &strfd, "+");
for (i = 0; i < n; i++)
{
j = CStrToFJ(strfd[i], &strbl, "*xX");
if (j == 1)
{
rTemp += atof(strbl[0]);
bnn.Add(rTemp);
}
else if (j == 2)
{
for (k = 0; k < atoi(strbl[1]); k++)
{
rTemp += atof(strbl[0]);
bnn.Add(rTemp);
}
}
}
return rTemp;
}
void MFCTest()
{
MakeNewLayer("桥墩位", 4, "acadiso.lin", "continuous");
CDiaTest Diatest(CWnd::FromHandle(hWndACAD));
Diatest.DoModal();
int j = 0, n = 0;
int i;
ads_point pt, ptt1, ptt2;
ads_name ent;
double xx, yy, zz;
CArray <double, double> array;
CString strTemp, filePath, strLine;
CStringArray strarray;
CStdioFile fileJgw;
double rs, re;
CString aa, strend;
char tt[30];
fileJgw.Open(Diatest.m_strFileName, CFile::modeRead|CFile::typeText);
ads_entsel("选择路线单元:", ent, pt);
if (false == GetRoadInf(ent, aa, strend, rs, re))
{
ads_printf("\n选择的道路没有桩号初始化!");
return;
}
BOOL bStart = false;
while(fileJgw.ReadString(strLine))
{
i = CStrToFJ(strLine, &strarray, " ,");
if (i != 1 && !bStart)
{
continue; //过滤空行
}
if (i == 1) bStart = true;
if (bStart && i != 1)
{
CovStrToZH(strarray[2], atof(strarray[0]), array);
n = array.GetSize();
if (n < 3)
{
continue;
}
switch(Diatest.m_iDx)
{
case 0:
for (j = 0; j < n; j++)
{
GetInfFromZH(aa, array[j], xx, yy, zz);
Spoint(pt, xx, yy, 0.0);
ads_polar(pt, ConvertPolar(zz) - PI / 2.0, Diatest.m_rDist, pt);
DrawCirCleQD(pt, Diatest.m_rR);
}
break;
case 1:
for (j = 0; j < n; j++)
{
GetInfFromZH(aa, array[j], xx, yy, zz);
Spoint(pt, xx, yy, 0.0);
ads_polar(pt, ConvertPolar(zz) - PI / 2.0, Diatest.m_rDist, pt);
DrawPlineQD(Diatest.m_rWidth, Diatest.m_rDeep, pt, zz);
}
break;
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CMFCTemplateApp
BEGIN_MESSAGE_MAP(CMFCTemplateApp, CWinApp)
//{{AFX_MSG_MAP(CMFCTemplateApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMFCTemplateApp construction
CMFCTemplateApp::CMFCTemplateApp()
{
}
CMFCTemplateApp::~CMFCTemplateApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMFCTemplateApp object
CMFCTemplateApp theApp;
BOOL CMFCTemplateApp::InitInstance()
{
TRACE("Init Instance MFCTemplate\n");
return CWinApp::InitInstance();
}
int CMFCTemplateApp::ExitInstance()
{
TRACE("Exit Instance MFCTemplate\n");
return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// CDiaTest dialog
/////////////////////////////////////////////////////////////////////////////
CDiaTest::CDiaTest(CWnd* pParent /*=NULL*/)
: CDialog(CDiaTest::IDD, pParent)
{
if (strlen(strFileName) < 2)
{
m_strFileName = _T("");
m_strMesage = _T("");
m_rDeep = 0.0;
m_rDist = 0.0;
m_rR = 0.0;
m_rWidth = 0.0;
m_iDx = 0;
}
else
{
m_strFileName = strFileName;
m_strMesage = strMesage;
m_rDeep = rDeep;
m_rDist = rDist;
m_rR = rR;
m_rWidth = rWidth;
m_iDx = iDx;
}
}
void CDiaTest::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDiaTest)
DDX_Control(pDX, IDC_BUTTON_INSERT, m_btnInstert);
DDX_Control(pDX, IDC_BUTTON_FIND, m_btnFind);
DDX_Control(pDX, IDC_BUTTON_EDIT, m_btnEdit);
DDX_Text(pDX, IDC_EDIT_FILENAEM, m_strFileName);
DDX_Text(pDX, IDC_EDIT_MSG, m_strMesage);
DDX_Text(pDX, IDC_EDIT_DEEP, m_rDeep);
DDX_Text(pDX, IDC_EDIT_DIST, m_rDist);
DDX_Text(pDX, IDC_EDIT_R, m_rR);
DDX_Text(pDX, IDC_EDIT_WIDTH, m_rWidth);
DDX_Radio(pDX, IDC_RADIO1, m_iDx);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDiaTest, CDialog)
//{{AFX_MSG_MAP(CDiaTest)
ON_BN_CLICKED(IDC_BUTTON_INSERT, OnButtonInsert)
ON_BN_CLICKED(IDC_BUTTON_FIND, OnButtonFind)
ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// END CODE APPEARING IN SDK DOCUMENT.
void CDiaTest::OnButtonInsert()
{
// TODO: Add your control notification handler code here
UpdateData(true);
strFileName = m_strFileName;
strMesage = m_strMesage;
rDeep = m_rDeep;
rDist = m_rDist;
rR = m_rR;
rWidth = m_rWidth;
iDx = m_iDx;
OnOK();
}
void CDiaTest::OnButtonFind()
{
// TODO: Add your control notification handler code here
CFileDialog FileDlg( TRUE, NULL, NULL,
OFN_HIDEREADONLY, "结构物文件 (*.jgw)|*.jgw|所有文件 (*.*)|*.*|" );
if( FileDlg.DoModal() == IDOK )
{
m_strFileName = FileDlg.GetPathName();
m_strFileName.MakeUpper();
}
UpdateData(false);
}
void CDiaTest::OnButtonEdit()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if (m_strFileName != _T(""))
{
ShellExecute(this->m_hWnd,"open","notepad.exe",m_strFileName,"",SW_SHOW );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -