| | |
| | | label.UpdateWindow(); // 立即刷新 |
| | | } |
| | | |
| | | int CAxisSettingsDlg::getCurrentSelectedAxisID() |
| | | { |
| | | int currentIndex = m_comboAxisNO.GetCurSel(); |
| | | if (currentIndex == CB_ERR) { |
| | | AfxMessageBox(_T("请选择一个有效的轴编号!")); |
| | | return -1; |
| | | } |
| | | |
| | | CString axisIDStr; |
| | | m_comboAxisNO.GetLBText(currentIndex, axisIDStr); |
| | | return _ttoi(axisIDStr); |
| | | } |
| | | |
| | | void CAxisSettingsDlg::initializeAxisIDCombo() |
| | | { |
| | | // 获取所有轴的轴NO |
| | |
| | | void CAxisSettingsDlg::refreshAxisDetails() |
| | | { |
| | | // 获取当前选中的轴ID |
| | | int currentIndex = m_comboAxisNO.GetCurSel(); |
| | | if (currentIndex == CB_ERR) { |
| | | AfxMessageBox(_T("请选择一个有效的轴编号!")); |
| | | return; |
| | | } |
| | | |
| | | CString axisIDStr; |
| | | m_comboAxisNO.GetLBText(currentIndex, axisIDStr); |
| | | int axisId = _ttoi(axisIDStr); |
| | | int axisId = getCurrentSelectedAxisID(); |
| | | |
| | | // 获取轴信息 |
| | | auto axisDetails = AxisManager::getInstance().getAxis(axisId); |
| | |
| | | const int pageSize = 5; |
| | | |
| | | // 获取当前选中的轴ID |
| | | int currentIndex = m_comboAxisNO.GetCurSel(); |
| | | if (currentIndex == CB_ERR) { |
| | | AfxMessageBox(_T("请选择一个有效的轴编号!")); |
| | | return; |
| | | } |
| | | |
| | | CString axisIDStr; |
| | | m_comboAxisNO.GetLBText(currentIndex, axisIDStr); |
| | | int axisId = _ttoi(axisIDStr); |
| | | int axisId = getCurrentSelectedAxisID(); |
| | | |
| | | // 获取定位点数据 |
| | | auto positions = AxisManager::getInstance().getPositions(axisId, pageNumber, pageSize); |
| | |
| | | if (pPosition) pPosition->SetWindowText(_T("")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void CAxisSettingsDlg::updateAxisSelection(int offset) |
| | | { |
| | | int currentIndex = m_comboAxisNO.GetCurSel(); |
| | | if (currentIndex == CB_ERR) { |
| | | AfxMessageBox(_T("请选择一个有效的轴编号!")); |
| | | return; |
| | | } |
| | | |
| | | int newIndex = currentIndex + offset; |
| | | if (newIndex < 0 || newIndex >= m_comboAxisNO.GetCount()) { |
| | | CString error; |
| | | error.Format(_T("已经到达%s一个轴!"), offset < 0 ? _T("上") : _T("下")); |
| | | AfxMessageBox(error); |
| | | return; |
| | | } |
| | | |
| | | m_comboAxisNO.SetCurSel(newIndex); |
| | | refreshAxisDetails(); |
| | | refreshPositionDetails(1); |
| | | } |
| | | |
| | | BEGIN_MESSAGE_MAP(CAxisSettingsDlg, CDialogEx) |
| | |
| | | void CAxisSettingsDlg::OnBnClickedButtonAxisLast() |
| | | { |
| | | // TODO: 在此添加控件通知处理程序代码 |
| | | try { |
| | | updateAxisSelection(-1); |
| | | } |
| | | catch (const std::exception& ex) { |
| | | CString errorMsg; |
| | | errorMsg.Format(_T("获取下一个轴失败:%s"), CString(ex.what())); |
| | | AfxMessageBox(errorMsg, MB_ICONERROR); |
| | | } |
| | | } |
| | | |
| | | void CAxisSettingsDlg::OnBnClickedButtonAxisNext() |
| | | { |
| | | // TODO: 在此添加控件通知处理程序代码 |
| | | try { |
| | | updateAxisSelection(1); |
| | | } |
| | | catch (const std::exception& ex) { |
| | | CString errorMsg; |
| | | errorMsg.Format(_T("获取上一个轴失败:%s"), CString(ex.what())); |
| | | AfxMessageBox(errorMsg, MB_ICONERROR); |
| | | } |
| | | } |
| | | |
| | | void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup1() |