LAPTOP-SNT8I5JK\Boounion
2025-08-27 38f2ff1e5bc6c4434875e03b8cadc8f3f4e39bf6
SourceCode/Bond/Servo/EqsGraphWnd.cpp
@@ -35,13 +35,7 @@
   m_hWnd = NULL;
   m_crFrame = GetSysColor(COLOR_WINDOWFRAME);
   m_crBkgnd = RGB(255, 255, 255);
   m_listener.onConnectPin = nullptr;
   m_listener.onCheckConnectPin = nullptr;
   m_listener.onDisconnectPin = nullptr;
   m_listener.onDeleteEqItem = nullptr;
   m_listener.onEqItemPosChanged = nullptr;
   m_listener.onDblckEqItem = nullptr;
   m_listener.onRclickEqItem = nullptr;
   m_listener = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
   m_crItemBackground[0] = RGB(218, 218, 218);
   m_crItemBackground[1] = RGB(193, 208, 227);
   m_crItemFrame[0] = RGB(128, 128, 128);
@@ -492,6 +486,7 @@
   m_listener.onEqItemPosChanged = listener.onEqItemPosChanged;
   m_listener.onDblckEqItem = listener.onDblckEqItem;
   m_listener.onRclickEqItem = listener.onRclickEqItem;
   m_listener.onSelectEqItem = listener.onSelectEqItem;
}
BOOL CEqsGraphWnd::SetCurSel(int nSel)
@@ -633,6 +628,27 @@
void CEqsGraphWnd::SetItemType(EQITEM* pItem, int nType)
{
   pItem->nShowType = nType;
   if (pItem->nShowType == ITEM_SMALL) {
      pItem->rect.right = pItem->rect.left + ITEM_CX_SMALL;
      pItem->rect.bottom = pItem->rect.top + ITEM_CY_SMALL;
   }
   else if (pItem->nShowType == ITEM_LARGE) {
      pItem->rect.right = pItem->rect.left + ITEM_CX_LARGE;
      pItem->rect.bottom = pItem->rect.top + ITEM_CY_LARGE;
   }
   else {
      pItem->rect.right = pItem->rect.left + ITEM_CX_NORMAL;
      pItem->rect.bottom = pItem->rect.top + ITEM_CY_NORMAL;
   }
   ::InvalidateRect(m_hWnd, &pItem->rect, TRUE);
}
void CEqsGraphWnd::SetItemPos(EQITEM* pItem, int x, int y)
{
   ASSERT(pItem);
   pItem->rect.left = x;
   pItem->rect.top = y;
   if (pItem->nShowType == ITEM_SMALL) {
      pItem->rect.right = pItem->rect.left + ITEM_CX_SMALL;
      pItem->rect.bottom = pItem->rect.top + ITEM_CY_SMALL;
@@ -1265,6 +1281,7 @@
   PIN *pLastPin = m_pCurPin;
   PIN *pLastSelLineOutPin = m_pSelLineOutPin;
   BOOL bChanged = FALSE;
   BOOL bSelectChanged = FALSE;
   EQITEM* pHitItem = NULL;
   PIN *pHitPin = NULL;
   PIN *pPin2 = NULL;
@@ -1288,8 +1305,11 @@
   }
   if (nRet == HT_ITEM) {
      m_pCurItem = pHitItem;
      m_pCurItem->bHighlight = TRUE;
      if (m_pCurItem != pHitItem) {
         m_pCurItem = pHitItem;
         m_pCurItem->bHighlight = TRUE;
         bSelectChanged = TRUE;
      }
   }
   else if (nRet == HT_PIN) {
      m_pCurPin = pHitPin;
@@ -1373,6 +1393,8 @@
         ReleaseCapture();
      ExitLoop:
         m_nMagneticLinHoz = 0;
         m_nMagneticLinVer = 0;
         AfxUnlockTempMaps(FALSE);
      }
   }
@@ -1531,6 +1553,13 @@
         ReleaseCapture();
      ExitLoop3:
         AfxUnlockTempMaps(FALSE);
      }
   }
   if (bSelectChanged) {
      if (m_listener.onSelectEqItem != nullptr) {
         m_listener.onSelectEqItem(m_pCurItem);
      }
   }
@@ -1882,10 +1911,12 @@
   HBRUSH hbrItemBackground[2];
   HBRUSH hbrItemFrame[2];
   HBRUSH hbrPinBackground[3];
   HBRUSH hbrIndicator;
   hbrItemBackground[0] = CreateSolidBrush(m_crItemBackground[0]);
   hbrItemBackground[1] = CreateSolidBrush(m_crItemBackground[1]);
   hbrItemFrame[0] = CreateSolidBrush(m_crItemFrame[0]);
   hbrItemFrame[1] = CreateSolidBrush(m_crItemFrame[1]);
   hbrIndicator = CreateSolidBrush(RGB(34, 177, 76));
   for (int i = 0; i < 3; i++) {
      hbrPinBackground[i] = CreateSolidBrush(m_crPinBkgnd[i]);
   }
@@ -1931,6 +1962,21 @@
         HFONT hFontOld = (HFONT)::SelectObject(hMemDC, m_hFontName);
         ::SetTextColor(hMemDC, pItem->bHighlight ? m_crItemNameText[1] : m_crItemNameText[0]);
         ::DrawText(hMemDC, pItem->text, (int)strlen(pItem->text), &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
         // 添加一个小绿点指示器
         if(pItem->bShowIndicator[0]){
            RECT rcIndicator;
            rcIndicator.left = rcItem.left + 5;
            rcIndicator.top = rcItem.top + 5;
            rcIndicator.right = rcIndicator.left + 12;
            rcIndicator.bottom = rcIndicator.top + 12;
            HRGN hRgn = CreateRoundRectRgn(rcIndicator.left, rcIndicator.top, rcIndicator.right, rcIndicator.bottom, 2, 2);
            ::FillRgn(hMemDC, hRgn, hbrIndicator);
            ::FrameRgn(hMemDC, hRgn, hbrItemFrame[0], 1, 1);
            ::DeleteObject(hRgn);
         }
         if (pItem->nShowType != ITEM_SMALL) {
            RECT rcId = rcItem;
@@ -2045,6 +2091,7 @@
      ::DeleteObject(hbrItemBackground[1]);
      ::DeleteObject(hbrItemFrame[0]);
      ::DeleteObject(hbrItemFrame[1]);
      ::DeleteObject(hbrIndicator);
   }
@@ -2361,6 +2408,15 @@
   SetTimer(m_hWnd, TIMER_ANIMATION_RECT, uElpase, NULL);
}
void CEqsGraphWnd::ShowItemIndicator(DWORD_PTR dwItemData, BOOL bShow)
{
   EQITEM* pItem = GetItem(dwItemData);
   if (pItem != nullptr) {
      pItem->bShowIndicator[0] = bShow;
      ::InvalidateRect(m_hWnd, nullptr, TRUE);
   }
}
double CEqsGraphWnd::PointToSegDist(double x, double y, double x1, double y1, double x2, double y2)
{
   double cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1);