From b25ce186da97a1a774ddf89504f97d8c244fda66 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期四, 29 一月 2026 09:25:06 +0800
Subject: [PATCH] 1.移除 SubEqpStart/End(CEID 10015/10016) 2.UnitStart/UnitEnd 增加 PanelID(5006/5007) 3.Report/CEID 两个表都同步了对应 VIDs/备注
---
SourceCode/Bond/Servo/EqsGraphWnd.cpp | 334 +++++++++++++++++++++++++++++++++----------------------
1 files changed, 198 insertions(+), 136 deletions(-)
diff --git a/SourceCode/Bond/Servo/EqsGraphWnd.cpp b/SourceCode/Bond/Servo/EqsGraphWnd.cpp
index 9c0af84..9e68a4c 100644
--- a/SourceCode/Bond/Servo/EqsGraphWnd.cpp
+++ b/SourceCode/Bond/Servo/EqsGraphWnd.cpp
@@ -1,4 +1,4 @@
-#include "stdafx.h"
+锘�#include "stdafx.h"
#include "EqsGraphWnd.h"
#include "ColorTransfer.h"
#include "MapPosWnd.h"
@@ -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);
@@ -70,6 +64,8 @@
m_nMagneticLinHoz = 0;
m_nMagneticLinVer = 0;
m_hFontTitle = nullptr;
+ m_nIndicatorSize = 10;
+ m_nIndicatorMargin = 3;
}
@@ -92,7 +88,7 @@
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- // 注册窗口类
+ // 娉ㄥ唽绐楀彛绫�
return (::RegisterClass(&wc) != 0);
}
@@ -163,6 +159,20 @@
m_crItemIdText[0] = CColorTransfer::ApproximateColor(m_crItemNameText[0], -0.3f);
m_crItemIdText[1] = CColorTransfer::ApproximateColor(m_crItemNameText[1], -0.3f);
+}
+
+void CEqsGraphWnd::SetIndicatorSize(int nSize)
+{
+ if (nSize > 0) {
+ m_nIndicatorSize = nSize;
+ }
+}
+
+void CEqsGraphWnd::SetIndicatorMargin(int nMargin)
+{
+ if (nMargin >= 0) {
+ m_nIndicatorMargin = nMargin;
+ }
}
void CEqsGraphWnd::EnableScroll(BOOL bEnable)
@@ -241,7 +251,7 @@
}
/*
- * 计算磁力线位置
+ * 璁$畻纾佸姏绾夸綅缃�
*/
void CEqsGraphWnd::CalculateMagneticLine(EQITEM* pItem, LPRECT lprcItemRect, int &hoz, int &ver)
{
@@ -249,7 +259,7 @@
ver = 0;
#define MAGNETIC_DIS 10
- // 检测是否接近或对齐
+ // 妫�娴嬫槸鍚︽帴杩戞垨瀵归綈
for (int i = 0; i < m_arItem.GetSize(); i++) {
EQITEM *pTemp = (EQITEM*)m_arItem.GetAt(i);
if (pTemp != pItem) {
@@ -293,10 +303,10 @@
}
/*
- * 取得In Pin的区域
+ * 鍙栧緱In Pin鐨勫尯鍩�
* pItem -- EQITEM
- * lpRect -- 得到的Rect
- * 返回是否成功
+ * lpRect -- 寰楀埌鐨凴ect
+ * 杩斿洖鏄惁鎴愬姛
*/
BOOL CEqsGraphWnd::GetItemRect(EQITEM* pItem, LPRECT lpRect)
{
@@ -327,11 +337,11 @@
}
/*
- * 取得In Pin的区域
+ * 鍙栧緱In Pin鐨勫尯鍩�
* pItem -- EQITEM
- * nPinIndex -- in pin索引
- * lpRect -- 得到的Rect
- * 返回是否成功
+ * nPinIndex -- in pin绱㈠紩
+ * lpRect -- 寰楀埌鐨凴ect
+ * 杩斿洖鏄惁鎴愬姛
*/
BOOL CEqsGraphWnd::GetInPinRect(EQITEM* pItem, int nPinIndex, LPRECT lpRect)
{
@@ -351,11 +361,11 @@
}
/*
- * 取得Out Pin的区域
+ * 鍙栧緱Out Pin鐨勫尯鍩�
* pItem -- EQITEM
- * nPinIndex -- in pin索引
- * lpRect -- 得到的Rect
- * 返回是否成功
+ * nPinIndex -- in pin绱㈠紩
+ * lpRect -- 寰楀埌鐨凴ect
+ * 杩斿洖鏄惁鎴愬姛
*/
BOOL CEqsGraphWnd::GetOutPinRect(EQITEM* pItem, int nPinIndex, LPRECT lpRect)
{
@@ -374,11 +384,11 @@
}
/*
- * 取得Pin的Point
+ * 鍙栧緱Pin鐨凱oint
* pItem -- EQITEM
- * nPinIndex -- in pin索引
- * lpRect -- 得到的Rect
- * 返回是否成功
+ * nPinIndex -- in pin绱㈠紩
+ * lpRect -- 寰楀埌鐨凴ect
+ * 杩斿洖鏄惁鎴愬姛
*/
BOOL CEqsGraphWnd::GetPinPoint(PIN *pPin, LPPOINT lpPoint)
{
@@ -459,7 +469,7 @@
}
/*
- * 清空PIN连接线缓存点,以便重新计算和绘制
+ * 娓呯┖PIN杩炴帴绾跨紦瀛樼偣锛屼互渚块噸鏂拌绠楀拰缁樺埗
*/
void CEqsGraphWnd::ClearConnectedLinePoint(EQITEM*& pItem)
{
@@ -485,13 +495,7 @@
void CEqsGraphWnd::SetOnListener(EqsGraphListener& listener)
{
- m_listener.onConnectPin = listener.onConnectPin;
- m_listener.onCheckConnectPin = listener.onCheckConnectPin;
- m_listener.onDisconnectPin = listener.onDisconnectPin;
- m_listener.onDeleteEqItem = listener.onDeleteEqItem;
- m_listener.onEqItemPosChanged = listener.onEqItemPosChanged;
- m_listener.onDblckEqItem = listener.onDblckEqItem;
- m_listener.onRclickEqItem = listener.onRclickEqItem;
+ m_listener = listener;
}
BOOL CEqsGraphWnd::SetCurSel(int nSel)
@@ -560,7 +564,7 @@
*/
EQITEM* CEqsGraphWnd::AddItem(int id, CString strText, DWORD_PTR dwData, int nType/* = ITEM_NORMAL*/)
{
- // 需要计算一个新位置,不然全部重叠在一起
+ // 闇�瑕佽绠椾竴涓柊浣嶇疆锛屼笉鐒跺叏閮ㄩ噸鍙犲湪涓�璧�
int x, y;
x = (m_arItem.GetCount() % 4) * 218;
y = (m_arItem.GetCount() / 4) * 168;
@@ -760,7 +764,7 @@
return 0;
}
-// 删除Item, 如果pin有连接,注意先断开
+// 鍒犻櫎Item, 濡傛灉pin鏈夎繛鎺ワ紝娉ㄦ剰鍏堟柇寮�
int CEqsGraphWnd::DeleteItem(EQITEM* pItem)
{
for (int i = 0; i < m_arItem.GetSize(); i++) {
@@ -800,7 +804,7 @@
}
/*
- * 设置子项的选中状态
+ * 璁剧疆瀛愰」鐨勯�変腑鐘舵��
*/
void CEqsGraphWnd::SetItemSelectState(int nIndex, BOOL bSelect)
{
@@ -833,14 +837,14 @@
}
/*
- * 检测坐标点所在的项
- * 返回项类型, 如HT_ITEM, HT_PIN, HT_LINE
- * pItem - 所在的EQITEM
- * pPin --所在的pin, 如果在连线上,表示所属pin, out pin;
+ * 妫�娴嬪潗鏍囩偣鎵�鍦ㄧ殑椤�
+ * 杩斿洖椤圭被鍨�, 濡侶T_ITEM, HT_PIN, HT_LINE
+ * pItem - 鎵�鍦ㄧ殑EQITEM
+ * pPin --鎵�鍦ㄧ殑pin, 濡傛灉鍦ㄨ繛绾夸笂锛岃〃绀烘墍灞瀙in, out pin锛�
*/
int CEqsGraphWnd::HighTest(POINT pt, OUT EQITEM*& pItem, OUT PIN *& pPin)
{
- // 检测是否在某个子项
+ // 妫�娴嬫槸鍚﹀湪鏌愪釜瀛愰」
int nRet = HT_NOWHERE;
pItem = NULL;
pPin = NULL;
@@ -849,7 +853,7 @@
EQITEM *pTempItem = (EQITEM*)m_arItem.GetAt(i);
GetItemRect(pTempItem, &rcItem);
if (::PtInRect(&rcItem, pt)) {
- // 在Item
+ // 鍦↖tem
pItem = pTempItem;
nRet = HT_ITEM;
break;
@@ -859,7 +863,7 @@
CPtrArray * pPins = (CPtrArray *)pTempItem->pInPins;
for (int j = 0; j < pPins->GetSize(); j++) {
if (GetInPinRect(pTempItem, j, &rcPin) && ::PtInRect(&rcPin, pt)) {
- // 在in pin上
+ // 鍦╥n pin涓�
pPin = (PIN *)pPins->GetAt(j);
pItem = pTempItem;
nRet = HT_PIN;
@@ -871,15 +875,15 @@
pPins = (CPtrArray *)pTempItem->pOutPins;
for (int j = 0; j < pPins->GetSize(); j++) {
if (GetOutPinRect(pTempItem, j, &rcPin) && ::PtInRect(&rcPin, pt)) {
- // 在out pin
+ // 鍦╫ut pin
pPin = (PIN *)pPins->GetAt(j);
pItem = pTempItem;
nRet = HT_PIN;
break;
}
else {
- // 是否在pin连接线上,即判断点是否在线上
- // 点到直线的距离公式(先通过p1,p2用两点式求出直线的表达式,再套距离公式);abs()为取绝对值函数,sqrt()为开根号函数
+ // 鏄惁鍦╬in杩炴帴绾夸笂,鍗冲垽鏂偣鏄惁鍦ㄧ嚎涓�
+ // 鐐瑰埌鐩寸嚎鐨勮窛绂诲叕寮忥紙鍏堥�氳繃p1,p2鐢ㄤ袱鐐瑰紡姹傚嚭鐩寸嚎鐨勮〃杈惧紡锛屽啀濂楄窛绂诲叕寮忥級锛沘bs()涓哄彇缁濆鍊煎嚱鏁帮紝sqrt()涓哄紑鏍瑰彿鍑芥暟
PIN *pTempPin = (PIN *)pPins->GetAt(j);
if (pTempPin->pConnectedPin != NULL && pTempPin->nLinePtCount > 1) {
for (int i = 0; i < pTempPin->nLinePtCount - 1; i++) {
@@ -912,7 +916,7 @@
}
/*
- * 绘制虚线框,代表正在拖动的item
+ * 缁樺埗铏氱嚎妗嗭紝浠h〃姝e湪鎷栧姩鐨刬tem
*/
void CEqsGraphWnd::DrawDropItemRectangle(LPRECT lpRect1, LPRECT lpRect2)
{
@@ -940,7 +944,7 @@
}
/*
- * 绘制磁吸线
+ * 缁樺埗纾佸惛绾�
*/
void CEqsGraphWnd::DrawMagneticLine(LPRECT lprcClient, int nHozLine1, int nHozLine2, int nVerLine1, int nVerLine2)
{
@@ -974,16 +978,16 @@
}
/*
- * 缓制Pin连接线
- * pBrush -- 画刷
- * pPen - 画笔
- * lpPt1, lpPt2 -- Pin脚的位置
- * lpRect1, lpRect2 -- 两个Item的Rect
+ * 缂撳埗Pin杩炴帴绾�
+ * pBrush -- 鐢诲埛
+ * pPen - 鐢荤瑪
+ * lpPt1, lpPt2 -- Pin鑴氱殑浣嶇疆
+ * lpRect1, lpRect2 -- 涓や釜Item鐨凴ect
*/
void CEqsGraphWnd::DrawPinConnectedLine(Gdiplus::Graphics *pGraphics, Gdiplus::Brush *pBrush, Gdiplus::Pen *pPen, LPPOINT lpPt1, LPPOINT lpPt2,
LPRECT lpRect1, LPRECT lpRect2, PIN *pOwnerPin)
{
- // 如果没有缓存线条的POINT,则先计算并缓存
+ // 濡傛灉娌℃湁缂撳瓨绾挎潯鐨凱OINT锛屽垯鍏堣绠楀苟缂撳瓨
ASSERT(pOwnerPin);
int nPinCount = ((CPtrArray*)pOwnerPin->pItem->pOutPins)->GetSize();
@@ -992,10 +996,10 @@
int nMargin = 12;
int x1, x2, y1;
- if (pOwnerPin->nLinePtCount == 0) { // 第一个点的最小折线长
+ if (pOwnerPin->nLinePtCount == 0) { // 绗竴涓偣鐨勬渶灏忔姌绾块暱
::OffsetRect(lpRect1, +m_nOffsetX, +m_nOffsetY);
::OffsetRect(lpRect2, +m_nOffsetX, +m_nOffsetY);
- lpPt1->x += m_nOffsetX; // 消除偏移
+ lpPt1->x += m_nOffsetX; // 娑堥櫎鍋忕Щ
lpPt1->y += m_nOffsetY;
lpPt2->x += m_nOffsetX;
lpPt2->y += m_nOffsetY;
@@ -1104,7 +1108,7 @@
}
/*
- * WindowProc,窗口过程
+ * WindowProc锛岀獥鍙h繃绋�
*/
LRESULT CALLBACK CEqsGraphWnd::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@@ -1115,7 +1119,7 @@
}
- // 处理窗口消息
+ // 澶勭悊绐楀彛娑堟伅
ASSERT(hWnd);
switch (uMsg)
{
@@ -1179,7 +1183,7 @@
/*
* WM_NCCREATE
- * 窗口创建
+ * 绐楀彛鍒涘缓
*/
LRESULT CEqsGraphWnd::OnNcCreate(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
@@ -1192,7 +1196,7 @@
/*
* WM_DESTROY
- * 窗口销毁
+ * 绐楀彛閿�姣�
*/
LRESULT CEqsGraphWnd::OnDestroy(WPARAM wParam, LPARAM lParam)
{
@@ -1255,7 +1259,7 @@
/*
* WM_MOUSEMOVE
- * 鼠标滚动
+ * 榧犳爣婊氬姩
*/
LRESULT CEqsGraphWnd::OnMouseMove(WPARAM wParam, LPARAM lParam)
{
@@ -1264,7 +1268,7 @@
/*
* WM_LBUTTONDOWN
- * 鼠标左键按下
+ * 榧犳爣宸﹂敭鎸変笅
*/
LRESULT CEqsGraphWnd::OnLButtonDown(WPARAM wParam, LPARAM lParam)
{
@@ -1281,11 +1285,12 @@
int nLastVerLine = 0;
- // 检测点击坐标是否在某一子项上,如是,则高亮显示
+ // 妫�娴嬬偣鍑诲潗鏍囨槸鍚﹀湪鏌愪竴瀛愰」涓婏紝濡傛槸锛屽垯楂樹寒鏄剧ず
EQITEM* pLastItem = m_pCurItem;
PIN *pLastPin = m_pCurPin;
PIN *pLastSelLineOutPin = m_pSelLineOutPin;
BOOL bChanged = FALSE;
+ BOOL bSelectChanged = FALSE;
EQITEM* pHitItem = NULL;
PIN *pHitPin = NULL;
PIN *pPin2 = NULL;
@@ -1309,8 +1314,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;
@@ -1324,14 +1332,14 @@
bChanged = pLastItem != m_pCurItem || pLastPin != m_pCurPin || pLastSelLineOutPin != m_pSelLineOutPin;
- // 刷新
+ // 鍒锋柊
SetFocus(m_hWnd);
if (bChanged) {
::InvalidateRect(m_hWnd, &rcClient, TRUE);
}
- // 捕捉鼠标消息,检测是否拖动
+ // 鎹曟崏榧犳爣娑堟伅锛屾娴嬫槸鍚︽嫋鍔�
if (nRet == HT_ITEM && m_pCurItem != NULL) {
GetItemRect(m_pCurItem, &rcItem);
@@ -1394,12 +1402,14 @@
ReleaseCapture();
ExitLoop:
+ m_nMagneticLinHoz = 0;
+ m_nMagneticLinVer = 0;
AfxUnlockTempMaps(FALSE);
}
}
- // 捕捉鼠标消息,检测是否连接引脚
+ // 鎹曟崏榧犳爣娑堟伅锛屾娴嬫槸鍚﹁繛鎺ュ紩鑴�
else if (nRet == HT_PIN && m_pCurPin != NULL) {
if (::GetCapture() == NULL) {
BOOL bLast = FALSE;
@@ -1426,12 +1436,12 @@
ptNew = msg.pt;
::ScreenToClient(m_hWnd, &ptNew);
- // 擦除上一次
+ // 鎿﹂櫎涓婁竴娆�
if (bLast) {
DrawPinWillConnectLine(lineColor, &ptPin, &ptLast);
}
- // 检测是否可以连接
+ // 妫�娴嬫槸鍚﹀彲浠ヨ繛鎺�
bCanConnect = false;
nRet = HighTest(ptNew, pHitItem, pHitPin);
if (nRet == HT_PIN) {
@@ -1457,12 +1467,12 @@
ptNew = msg.pt;
::ScreenToClient(m_hWnd, &ptNew);
- // 擦除上一次
+ // 鎿﹂櫎涓婁竴娆�
if (bLast) {
DrawPinWillConnectLine(lineColor, &ptPin, &ptLast);
}
- // 检测是否可以连接
+ // 妫�娴嬫槸鍚﹀彲浠ヨ繛鎺�
bCanConnect = false;
nRet = HighTest(ptNew, pHitItem, pHitPin);
if (nRet == HT_PIN) {
@@ -1497,7 +1507,7 @@
}
- // 检测鼠标消息,检测是否移动画布
+ // 妫�娴嬮紶鏍囨秷鎭紝妫�娴嬫槸鍚︾Щ鍔ㄧ敾甯�
else if (nRet == HT_NOWHERE) {
if (::GetCapture() == NULL) {
int nLastOffsetX = m_nOffsetX;
@@ -1556,12 +1566,19 @@
}
+ if (bSelectChanged) {
+ if (m_listener.onSelectEqItem != nullptr) {
+ m_listener.onSelectEqItem(m_pCurItem);
+ }
+ }
+
+
return ::DefWindowProc(m_hWnd, WM_LBUTTONDOWN, wParam, lParam);
}
/*
* WM_LBUTTONDBLCLK
- * 鼠标左键双击
+ * 榧犳爣宸﹂敭鍙屽嚮
*/
LRESULT CEqsGraphWnd::OnLButtonDblclk(WPARAM wParam, LPARAM lParam)
{
@@ -1573,7 +1590,7 @@
GetClientRect(m_hWnd, &rcClient);
rcLast = { 0, 0, 0, 0 };
- // 检测点击坐标是否在某一子项上,如是,则高亮显示
+ // 妫�娴嬬偣鍑诲潗鏍囨槸鍚﹀湪鏌愪竴瀛愰」涓婏紝濡傛槸锛屽垯楂樹寒鏄剧ず
EQITEM* pLastItem = m_pCurItem;
BOOL bChanged = FALSE;
EQITEM* pHitItem = NULL;
@@ -1593,7 +1610,7 @@
/*
* WM_MOUSEWHEEL
- * 鼠标滚动
+ * 榧犳爣婊氬姩
*/
LRESULT CEqsGraphWnd::OnMouseWheel(WPARAM wParam, LPARAM lParam)
{
@@ -1620,7 +1637,7 @@
/*
* WM_MOUSEHWHEEL
-* 鼠标滚动
+* 榧犳爣婊氬姩
*/
LRESULT CEqsGraphWnd::OnMouseHWheel(WPARAM wParam, LPARAM lParam)
{
@@ -1647,7 +1664,7 @@
/*
* WM_RBUTTONDOWN
- * 鼠标左键按下
+ * 榧犳爣宸﹂敭鎸変笅
*/
LRESULT CEqsGraphWnd::OnRButtonDown(WPARAM wParam, LPARAM lParam)
{
@@ -1659,7 +1676,7 @@
GetClientRect(m_hWnd, &rcClient);
rcLast = { 0, 0, 0, 0 };
- // 检测点击坐标是否在某一子项上,如是,则高亮显示
+ // 妫�娴嬬偣鍑诲潗鏍囨槸鍚﹀湪鏌愪竴瀛愰」涓婏紝濡傛槸锛屽垯楂樹寒鏄剧ず
EQITEM* pLastItem = m_pCurItem;
PIN *pLastPin = m_pCurPin;
PIN *pLastSelLineOutPin = m_pSelLineOutPin;
@@ -1702,14 +1719,14 @@
bChanged = pLastItem != m_pCurItem || pLastPin != m_pCurPin || pLastSelLineOutPin != m_pSelLineOutPin;
- // 刷新
+ // 鍒锋柊
SetFocus(m_hWnd);
if (bChanged) {
::InvalidateRect(m_hWnd, &rcClient, TRUE);
}
- // 捕捉鼠标消息,检测是否拖动
+ // 鎹曟崏榧犳爣娑堟伅锛屾娴嬫槸鍚︽嫋鍔�
if (nRet == HT_ITEM && m_pCurItem != NULL) {
CopyRect(&rcItem, &m_pCurItem->rect);
@@ -1762,13 +1779,13 @@
/*
* WM_KEYDOWN
- * 键盘消息,按下按键
+ * 閿洏娑堟伅锛屾寜涓嬫寜閿�
*/
LRESULT CEqsGraphWnd::OnKeyDown(WPARAM wParam, LPARAM lParam)
{
BOOL bChanged = FALSE;
if (wParam == VK_DELETE) {
- // 如果当前选择为线,则断开连接
+ // 濡傛灉褰撳墠閫夋嫨涓虹嚎锛屽垯鏂紑杩炴帴
if (m_pSelLineOutPin != NULL) {
if (m_listener.onDisconnectPin != nullptr) {
if (m_listener.onDisconnectPin(m_pSelLineOutPin)) {
@@ -1858,7 +1875,6 @@
CString strText;
HBRUSH hBrushBK;
-
// BeginPaint
PAINTSTRUCT ps;
hDC = BeginPaint(m_hWnd, &ps);
@@ -1869,14 +1885,12 @@
rcClient.bottom - rcClient.top);
::SelectObject(hMemDC, hBitmap);
-
- // 背景颜色
+ // 鑳屾櫙棰滆壊
hBrushBK = CreateSolidBrush(m_crBkgnd);
::FillRect(hMemDC, &rcClient, hBrushBK);
DeleteObject(hBrushBK);
-
- // 标题
+ // 鏍囬瀛椾綋
if (m_hFontTitle == nullptr) {
LOGFONT lf;
HFONT hFontDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
@@ -1886,8 +1900,9 @@
m_hFontTitle = CreateFontIndirect(&lf);
}
+ // 缁樺埗鏍囬鏂囨湰
{
- char szTitle[256];
+ char szTitle[256] = { 0 };
GetWindowText(m_hWnd, szTitle, 256);
RECT rcTitle;
rcTitle.left = rcClient.left + 5;
@@ -1898,19 +1913,23 @@
::DrawText(hMemDC, szTitle, (int)strlen(szTitle), &rcTitle, DT_LEFT | DT_TOP);
}
-
- // 绘制子项
+ // 缁樺埗瀛愰」
HBRUSH hbrItemBackground[2];
HBRUSH hbrItemFrame[2];
HBRUSH hbrPinBackground[3];
+ HBRUSH hbrIndicator;
+ HBRUSH hbrIndicatorGray;
+
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)); // 缁胯壊
+ hbrIndicatorGray = CreateSolidBrush(RGB(192, 192, 192)); // 鐏拌壊
+
for (int i = 0; i < 3; i++) {
hbrPinBackground[i] = CreateSolidBrush(m_crPinBkgnd[i]);
}
-
// gdi+
Gdiplus::Graphics graphics(hMemDC);
@@ -1921,21 +1940,22 @@
graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
}
-
SetBkMode(hMemDC, TRANSPARENT);
{
RECT rcItem;
int nPinState;
int nItemCount = (int)m_arItem.GetCount();
+
+ // 鍏堢敾 item銆佹枃鏈�乸in 鍜屾寚绀虹伅
for (int i = 0; i < nItemCount; i++) {
EQITEM* pItem = (EQITEM*)m_arItem.GetAt(i);
if (pItem->nFlashFlag == 1) {
continue;
}
+
GetItemRect(pItem, &rcItem);
-
- // 子项背景和边框
+ // 瀛愰」鑳屾櫙鍜岃竟妗�
if (m_nItemRound == 0) {
::FillRect(hMemDC, &rcItem, pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0]);
::FrameRect(hMemDC, &rcItem, pItem->bHighlight ? hbrItemFrame[1] : hbrItemFrame[0]);
@@ -1947,12 +1967,37 @@
::DeleteObject(hRgn);
}
-
- // name和id
+ // name
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);
+ ::DrawText(hMemDC, pItem->text, (int)strlen(pItem->text), &rcItem,
+ DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
+ // indicators vertical column layout
+ const int indicatorSize = m_nIndicatorSize;
+ const int indicatorMargin = m_nIndicatorMargin;
+ const int indicatorX = rcItem.left + 5;
+
+ for (int k = 0; k < EQITEM_INDICATOR_COUNT; ++k) {
+ BYTE indicatorState = pItem->nIndicatorState[k];
+ if (indicatorState == INDICATOR_STATE_HIDDEN) {
+ continue;
+ }
+
+ RECT rcIndicator;
+ rcIndicator.left = indicatorX;
+ rcIndicator.top = rcItem.top + 5 + k * (indicatorSize + indicatorMargin);
+ rcIndicator.right = rcIndicator.left + indicatorSize;
+ rcIndicator.bottom = rcIndicator.top + indicatorSize;
+
+ RECT rcInner = rcIndicator;
+ ::InflateRect(&rcInner, -1, -1);
+ ::FillRect(hMemDC, &rcInner, indicatorState == INDICATOR_STATE_HIGHLIGHT
+ ? hbrIndicator : hbrIndicatorGray);
+ ::FrameRect(hMemDC, &rcIndicator, hbrItemFrame[0]);
+ }
+
+ // ID 鏂囨湰锛堥潪灏忓彿 item锛�
if (pItem->nShowType != ITEM_SMALL) {
RECT rcId = rcItem;
rcId.left += 5;
@@ -1961,29 +2006,28 @@
strId.Format(_T("ID:%d"), pItem->id);
::SelectObject(hMemDC, m_hFontId);
::SetTextColor(hMemDC, pItem->bHighlight ? m_crItemIdText[1] : m_crItemIdText[0]);
- ::DrawText(hMemDC, strId, (int)strId.GetLength(), &rcId, DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS);
+ ::DrawText(hMemDC, strId, (int)strId.GetLength(), &rcId,
+ DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS);
}
-
- // 动画效果不绘pin
+ // 鍔ㄧ敾鏁堟灉鏃朵笉缁樺埗 pin
if (m_pAnimationItem == pItem) {
+ ::SelectObject(hMemDC, hFontOld);
continue;
}
-
- // 绘制pin
+ // 缁樺埗 pin
RECT rcPin, rcPin2, rcPinText;
- CPtrArray *pPins;
+ CPtrArray* pPins;
rcPinText.left = rcItem.left + 8;
rcPinText.right = rcItem.right - 8;
-
// in pins
- PIN *pPin = NULL;
- pPins = (CPtrArray *)pItem->pInPins;
+ PIN* pPin = NULL;
+ pPins = (CPtrArray*)pItem->pInPins;
for (int j = 0; j < pPins->GetSize(); j++) {
if (GetInPinRect(pItem, j, &rcPin)) {
- pPin = (PIN *)pPins->GetAt(j);
+ pPin = (PIN*)pPins->GetAt(j);
::FrameRect(hMemDC, &rcPin, pItem->bHighlight ? hbrItemFrame[1] : hbrItemFrame[0]);
rcPin2.left = rcPin.left + 1;
@@ -1991,22 +2035,25 @@
rcPin2.top = rcPin.top + 1;
rcPin2.bottom = rcPin.bottom - 1;
nPinState = GetPinState(pPin);
- ::FillRect(hMemDC, &rcPin2, nPinState == 0 ? (pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0]) : hbrPinBackground[nPinState]);
+ ::FillRect(hMemDC, &rcPin2,
+ nPinState == 0
+ ? (pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0])
+ : hbrPinBackground[nPinState]);
if (pItem->nShowType != ITEM_SMALL) {
rcPinText.top = rcPin.top - 12;
rcPinText.bottom = rcPin.bottom + 12;
::SetTextColor(hMemDC, pItem->bHighlight ? m_crItemIdText[1] : m_crItemIdText[0]);
- ::DrawText(hMemDC, pPin->text, (int)strlen(pPin->text), &rcPinText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
+ ::DrawText(hMemDC, pPin->text, (int)strlen(pPin->text), &rcPinText,
+ DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
}
}
}
-
// out pins
- pPins = (CPtrArray *)pItem->pOutPins;
+ pPins = (CPtrArray*)pItem->pOutPins;
for (int j = 0; j < pPins->GetSize(); j++) {
- pPin = (PIN *)pPins->GetAt(j);
+ pPin = (PIN*)pPins->GetAt(j);
if (GetOutPinRect(pItem, j, &rcPin)) {
::FrameRect(hMemDC, &rcPin, pItem->bHighlight ? hbrItemFrame[1] : hbrItemFrame[0]);
@@ -2015,50 +2062,53 @@
rcPin2.top = rcPin.top + 1;
rcPin2.bottom = rcPin.bottom - 1;
nPinState = GetPinState(pPin);
- ::FillRect(hMemDC, &rcPin2, nPinState == 0 ? (pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0]) : hbrPinBackground[nPinState]);
+ ::FillRect(hMemDC, &rcPin2,
+ nPinState == 0
+ ? (pItem->bHighlight ? hbrItemBackground[1] : hbrItemBackground[0])
+ : hbrPinBackground[nPinState]);
if (pItem->nShowType != ITEM_SMALL) {
rcPinText.top = rcPin.top - 12;
rcPinText.bottom = rcPin.bottom + 12;
::SetTextColor(hMemDC, pItem->bHighlight ? m_crItemIdText[1] : m_crItemIdText[0]);
- ::DrawText(hMemDC, pPin->text, (int)strlen(pPin->text), &rcPinText, DT_RIGHT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
+ ::DrawText(hMemDC, pPin->text, (int)strlen(pPin->text), &rcPinText,
+ DT_RIGHT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
}
}
}
- ::DeleteObject(hbrItemFrame);
::SelectObject(hMemDC, hFontOld);
}
-
- // 绘制连接线,保存线条在最后绘制
+ // 鍐嶇粯鍒惰繛鎺ョ嚎
for (int i = 0; i < nItemCount; i++) {
- EQITEM *pItem = (EQITEM*)m_arItem.GetAt(i);
+ EQITEM* pItem = (EQITEM*)m_arItem.GetAt(i);
if (pItem->nFlashFlag == 1) {
continue;
}
- PIN *pPin = NULL;
- CPtrArray *pPins;
-
- // out pins边线
+ PIN* pPin = NULL;
+ CPtrArray* pPins;
RECT rcItem1, rcItem2;
- pPins = (CPtrArray *)pItem->pOutPins;
+
+ // out pins 杈圭嚎
+ pPins = (CPtrArray*)pItem->pOutPins;
for (int j = 0; j < pPins->GetSize(); j++) {
- pPin = (PIN *)pPins->GetAt(j);
+ pPin = (PIN*)pPins->GetAt(j);
if (pPin->pConnectedPin != NULL) {
POINT pt1, pt2;
if (GetPinPoint(pPin, &pt1) && GetPinPoint(pPin->pConnectedPin, &pt2)) {
GetItemRect(pItem, &rcItem1);
GetItemRect(pPin->pConnectedPin->pItem, &rcItem2);
- DrawPinConnectedLine(&graphics, &brush1, pPin == m_pSelLineOutPin ? &pen2 : &pen1,
+ DrawPinConnectedLine(&graphics, &brush1,
+ pPin == m_pSelLineOutPin ? &pen2 : &pen1,
&pt1, &pt2, &rcItem1, &rcItem2, pPin);
}
}
}
}
-
+ // 鍒犻櫎 brush
for (int i = 0; i < 3; i++) {
::DeleteObject(hbrPinBackground[i]);
}
@@ -2066,10 +2116,9 @@
::DeleteObject(hbrItemBackground[1]);
::DeleteObject(hbrItemFrame[0]);
::DeleteObject(hbrItemFrame[1]);
+ ::DeleteObject(hbrIndicator);
+ ::DeleteObject(hbrIndicatorGray);
}
-
-
-
// EndPaint
::BitBlt(hDC, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
@@ -2078,9 +2127,9 @@
::DeleteObject(hBitmap);
::DeleteDC(hMemDC);
-
return 1;
}
+
/*
* WM_SIZE
@@ -2328,8 +2377,8 @@
/*
- * 设置背景颜色
- * color -- 背景色
+ * 璁剧疆鑳屾櫙棰滆壊
+ * color -- 鑳屾櫙鑹�
*/
void CEqsGraphWnd::SetBkgndColor(COLORREF color)
{
@@ -2337,8 +2386,8 @@
}
/*
- * 边框颜色
- * color -- 边框色
+ * 杈规棰滆壊
+ * color -- 杈规鑹�
*/
void CEqsGraphWnd::SetFrameColor(COLORREF color)
{
@@ -2382,6 +2431,19 @@
SetTimer(m_hWnd, TIMER_ANIMATION_RECT, uElpase, NULL);
}
+void CEqsGraphWnd::ShowItemIndicator(DWORD_PTR dwItemData, int state, int nIndex)
+{
+ if (nIndex < 0 || nIndex >= EQITEM_INDICATOR_COUNT) {
+ return;
+ }
+
+ EQITEM* pItem = GetItem(dwItemData);
+ if (pItem != nullptr) {
+ pItem->nIndicatorState[nIndex] = (BYTE)state;
+ ::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);
--
Gitblit v1.9.3