| | |
| | | void CPageGraph2::OnDestroy() |
| | | { |
| | | CDialogEx::OnDestroy(); |
| | | SaveEqsGraphData(); |
| | | |
| | | if (m_hbrBkgnd != nullptr) { |
| | | ::DeleteObject(m_hbrBkgnd); |
| | |
| | | #define OUTPIN 2 |
| | | void CPageGraph2::AddEqToGraphWnd(SERVO::CEquipment* pEquipment) |
| | | { |
| | | int x, y; |
| | | GetItemDataFormIni(pEquipment->getName().c_str(), x, y); |
| | | |
| | | EQITEM* pItem = m_pEqsGraphWnd->AddItem(0, pEquipment->getName().c_str(), (DWORD_PTR)pEquipment); |
| | | m_pEqsGraphWnd->SetItemType(pItem, ITEM_SMALL); |
| | | if (x > 0 && y > 0) { |
| | | m_pEqsGraphWnd->SetItemPos(pItem, x, y); |
| | | } |
| | | |
| | | std::vector<SERVO::CPin*>& inPins = pEquipment->getInputPins(); |
| | | for (auto inPin : inPins) { |
| | | m_pEqsGraphWnd->AddPin(pItem, INPIN, inPin->getName().c_str(), (DWORD_PTR)inPin); |
| | |
| | | if (1 == nIDEvent) { |
| | | KillTimer(1); |
| | | std::list<SERVO::CEquipment*>& eqs = theApp.m_model.m_master.getEquipmentList(); |
| | | for (auto item : eqs) { |
| | | AddEqToGraphWnd(item); |
| | | for (auto eq : eqs) { |
| | | AddEqToGraphWnd(eq); |
| | | } |
| | | |
| | | for (auto eq : eqs) { |
| | | auto& pins = eq->getOutputPins(); |
| | | for (auto pin : pins) { |
| | | SERVO::CPin* pPin2 = pin->getConnectedPin(); |
| | | if (pPin2 != nullptr) { |
| | | m_pEqsGraphWnd->ConnectPin((DWORD_PTR)eq, (DWORD_PTR)pin, (DWORD_PTR)pPin2->getEquipment(), (DWORD_PTR)pPin2); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | CDialogEx::OnTimer(nIDEvent); |
| | | } |
| | | |
| | | void CPageGraph2::SaveEqsGraphData() |
| | | { |
| | | char szFilepath[MAX_PATH]; |
| | | CString strValue; |
| | | sprintf_s(szFilepath, MAX_PATH, "%s\\EqsGraph.ini", (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | std::list<SERVO::CEquipment*>& eqs = theApp.m_model.m_master.getEquipmentList(); |
| | | for (auto item : eqs) { |
| | | EQITEM* pEqItem = m_pEqsGraphWnd->GetItem((DWORD_PTR)item); |
| | | |
| | | strValue.Format(_T("%d"), pEqItem->rect.left); |
| | | WritePrivateProfileString(item->getName().c_str(), _T("Left"), |
| | | (LPTSTR)(LPCTSTR)strValue, szFilepath); |
| | | strValue.Format(_T("%d"), pEqItem->rect.top); |
| | | WritePrivateProfileString(item->getName().c_str(), _T("Top"), |
| | | (LPTSTR)(LPCTSTR)strValue, szFilepath); |
| | | } |
| | | } |
| | | |
| | | void CPageGraph2::GetItemDataFormIni(const char* pszItemName, int& left, int& top) |
| | | { |
| | | char szFilepath[MAX_PATH]; |
| | | CString strValue; |
| | | sprintf_s(szFilepath, MAX_PATH, "%s\\EqsGraph.ini", (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | left = GetPrivateProfileInt(pszItemName, _T("Left"), 0, szFilepath); |
| | | top = GetPrivateProfileInt(pszItemName, _T("Top"), 0, szFilepath); |
| | | } |