From bc7f1c4e028e69be51079b59dae4ae5c4d43f5bb Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期六, 31 一月 2026 21:54:56 +0800
Subject: [PATCH] 1.状态指示图,目前灰色表示掉线,绿色表示在线。增加Slot的小点表示有没有料,及加工状态 。 2.增加图示

---
 SourceCode/Bond/Servo/ServoGraph.cpp |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/Servo/ServoGraph.cpp b/SourceCode/Bond/Servo/ServoGraph.cpp
index 9925dcb..b14ed32 100644
--- a/SourceCode/Bond/Servo/ServoGraph.cpp
+++ b/SourceCode/Bond/Servo/ServoGraph.cpp
@@ -21,6 +21,7 @@
 	m_crBkgnd = RGB(255,255,255);
 	m_pHighItem = nullptr;
 	m_hWndTooltip = nullptr;
+	m_slotBarSize = 0;
 }
 
 CServoGraph::~CServoGraph()
@@ -361,6 +362,37 @@
 		// text
 		::DrawText(hMemDC, item.szText, static_cast<int>(strlen(item.szText)),
 			&rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
+
+		// slot bar
+		if (item.slotBarPos != SlotBarPos::None && !item.slotColors.empty()) {
+			const int slotCount = static_cast<int>(item.slotColors.size());
+			const int gap = 1;
+			int slotSize = 4;
+			if (slotCount > 0) {
+				const int maxSize = (item.box1Width - gap * (slotCount - 1)) / slotCount;
+				slotSize = (m_slotBarSize > 0) ? m_slotBarSize : maxSize;
+				if (slotSize < 2) slotSize = 2;
+			}
+			const int barWidth = slotCount * slotSize + gap * (slotCount - 1);
+			const int startX = item.x - barWidth / 2;
+			const int baseTop = (item.slotBarPos == SlotBarPos::Top)
+				? (item.y - item.box1Width / 2 - slotSize - 2)
+				: (item.y + item.box1Width / 2 + 2);
+
+			HBRUSH hbrBorder = CreateSolidBrush(RGB(100, 100, 100));
+			for (int i = 0; i < slotCount; ++i) {
+				RECT rcSlot;
+				rcSlot.left = startX + i * (slotSize + gap);
+				rcSlot.top = baseTop;
+				rcSlot.right = rcSlot.left + slotSize;
+				rcSlot.bottom = rcSlot.top + slotSize;
+				HBRUSH hbrSlot = CreateSolidBrush(item.slotColors[i]);
+				::FillRect(hMemDC, &rcSlot, hbrSlot);
+				::FrameRect(hMemDC, &rcSlot, hbrBorder);
+				::DeleteObject(hbrSlot);
+			}
+			::DeleteObject(hbrBorder);
+		}
 	}
 
 
@@ -664,6 +696,31 @@
 	}
 }
 
+void CServoGraph::SetIndicateBoxSlotBarPosition(int id, SlotBarPos pos)
+{
+	INDICATEBOX* pIndicateBox = GetIndicateBox(id);
+	if (pIndicateBox != nullptr) {
+		pIndicateBox->slotBarPos = pos;
+		InvalidateRect(m_hWnd, nullptr, TRUE);
+	}
+}
+
+void CServoGraph::SetIndicateBoxSlotColors(int id, const std::vector<COLORREF>& colors)
+{
+	INDICATEBOX* pIndicateBox = GetIndicateBox(id);
+	if (pIndicateBox != nullptr) {
+		pIndicateBox->slotColors = colors;
+		InvalidateRect(m_hWnd, nullptr, TRUE);
+	}
+}
+
+void CServoGraph::SetSlotBarSize(int size)
+{
+	if (size < 0) size = 0;
+	m_slotBarSize = size;
+	InvalidateRect(m_hWnd, nullptr, TRUE);
+}
+
 void CServoGraph::DrawImage(HDC hMemDC, IMAGE& item)
 {
 	// 载入BMP

--
Gitblit v1.9.3