Files
envi-code/SourceCode/Code2026/Dimension/EditPipeDnGradientDlg.cpp
T
2026-09-28 15:28:50 +08:00

1148 lines
25 KiB
C++

#include "stdafx.h"
#include "AcDbObjectPtr.h"
#include "globalFunc.h"
#include "EditPipeDnGradientDlg.h"
#include "layerdef.h"
#include <stack>
#include "PickEntSet.h"
#include "DbPipe.h"
void CEditPipeDnGradientDlg::ModifyPipe()
{
// 根据管径设置管道系统中各管段的颜色
if (m_pLstAll != NULL)
{
PickSet ssPipe(SS_FREE);
std::stack<SSearchPipeList *> data;
data.push(m_pLstAll);
while (!data.empty())
{
SSearchPipeList *pList = data.top();
data.pop();
if (pList->m_iType == 0) // 管
{
ssPipe += pList->m_ID;
}
for (int i = 0; i < pList->m_lstNode.Length(); i++)
{
data.push(pList->m_lstNode[i]);
}
}
GetPipeOriginColor(ssPipe);
ChangePipeColor(ssPipe);
}
while (TRUE)
{
RBList rbMask = ads_buildlist(-4, _T("<or"),
-4, _T("<and"), RTDXF0, _T("AEC_ZT_PIPE"), 8, LAY_PIPE_RAIN, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("AEC_ZT_PIPE"), 8, LAY_PIPE_DIRT, -4, _T("and>"),
-4, _T("<and"), RTDXF0, _T("AEC_ZT_PIPE"), 8, LAY_PIPE_USELESS, -4, _T("and>"),
-4, _T("or>"), NULL);
PickSet ss(SS_FREE);
if (GlobalFunc::SelectEntities(_T("请选择需要设置管径坡度的管段<退出>:"), ss, rbMask) != RTNORM)
{
break;
}
GetPipeOriginColor(ss);
ChangePipeColorDnGradient(ss);
}
RecoverPipeOriginColor();
actrTransactionManager->flushGraphics(); //acad 刷新
DestroyWindow();
}
IMPLEMENT_DYNAMIC(CEditPipeDnGradientDlg, CModelessDialog)
CEditPipeDnGradientDlg::CEditPipeDnGradientDlg(int iType, CWnd* pParent /*=NULL*/)
: CModelessDialog(CEditPipeDnGradientDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEditPipeDnGradientDlg)
m_nPipeDnIndex = 0; // 默认管径 200
//}}AFX_DATA_INIT
m_dPipeDn = 200;
m_dPipeGradient = 0.0;
}
void CEditPipeDnGradientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEditPipeDnGradientDlg)
DDX_Radio(pDX, IDC_RADIO_PIPEDN1, m_nPipeDnIndex);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEditPipeDnGradientDlg, CModelessDialog)
//{{AFX_MSG_MAP(CEditPipeDnGradientDlg)
ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus)
ON_BN_CLICKED(IDC_RADIO_PIPEDN1, OnRadioPipedn1)
ON_BN_CLICKED(IDC_RADIO_PIPEDN2, OnRadioPipedn2)
ON_BN_CLICKED(IDC_RADIO_PIPEDN3, OnRadioPipedn3)
ON_BN_CLICKED(IDC_RADIO_PIPEDN4, OnRadioPipedn4)
ON_BN_CLICKED(IDC_RADIO_PIPEDN5, OnRadioPipedn5)
ON_BN_CLICKED(IDC_RADIO_PIPEDN6, OnRadioPipedn6)
ON_BN_CLICKED(IDC_RADIO_PIPEDN7, OnRadioPipedn7)
ON_BN_CLICKED(IDC_RADIO_PIPEDN8, OnRadioPipedn8)
ON_BN_CLICKED(IDC_RADIO_PIPEDN9, OnRadioPipedn9)
ON_BN_CLICKED(IDC_RADIO_PIPEDN10, OnRadioPipedn10)
ON_BN_CLICKED(IDC_RADIO_PIPEDN11, OnRadioPipedn11)
ON_BN_CLICKED(IDC_RADIO_PIPEDN12, OnRadioPipedn12)
ON_BN_CLICKED(IDC_RADIO_PIPEDN13, OnRadioPipedn13)
ON_BN_CLICKED(IDC_RADIO_PIPEDN14, OnRadioPipedn14)
ON_BN_CLICKED(IDC_RADIO_PIPEDN15, OnRadioPipedn15)
ON_BN_CLICKED(IDC_RADIO_PIPEDN16, OnRadioPipedn16)
ON_BN_CLICKED(IDC_RADIO_PIPEDN17, OnRadioPipedn17)
ON_BN_CLICKED(IDC_RADIO_PIPEDN18, OnRadioPipedn18)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT1, OnButtonGradient1)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT2, OnButtonGradient2)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT3, OnButtonGradient3)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT4, OnButtonGradient4)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT5, OnButtonGradient5)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT6, OnButtonGradient6)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT7, OnButtonGradient7)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT8, OnButtonGradient8)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT9, OnButtonGradient9)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT10, OnButtonGradient10)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT11, OnButtonGradient11)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT12, OnButtonGradient12)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT13, OnButtonGradient13)
ON_BN_CLICKED(IDC_BUTTON_GRADIENT14, OnButtonGradient14)
ON_EN_CHANGE(IDC_EDIT_GRADIENT, OnChangeEditGradient)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
LONG_PTR CEditPipeDnGradientDlg::onAcadKeepFocus(UINT_PTR, LONG_PTR)
{
CPoint pt;
GetCursorPos(&pt);
CRect rc;
GetWindowRect(&rc);
return (rc.PtInRect(pt) ? TRUE : FALSE);
}
BOOL CEditPipeDnGradientDlg::OnInitDialog()
{
CModelessDialog::OnInitDialog();
InitDnGradient();
InitPipeColor();
UpdateGradient();
SetEditGradient();
SetGradientFocus();
// 设置按钮颜色
//将按钮修改为BS_OWNERDRAW风格,其他风格无效
GetDlgItem(IDC_RADIO_PIPEDN1)->ModifyStyle(0, BS_OWNERDRAW, 0);
//绑定控件IDC_RADIO1与类CColorButton,响应重载函数DrawItem()
m_wndBtn1.Attach(IDC_RADIO_PIPEDN1, this);
m_wndBtn1.SetBackgroundColor(RGB(255, 0, 0));
GetDlgItem(IDC_RADIO_PIPEDN2)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn2.Attach(IDC_RADIO_PIPEDN2, this);
m_wndBtn2.SetBackgroundColor(RGB(0, 255, 0));
GetDlgItem(IDC_RADIO_PIPEDN3)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn3.Attach(IDC_RADIO_PIPEDN3, this);
m_wndBtn3.SetBackgroundColor(RGB(0, 0, 255));
GetDlgItem(IDC_RADIO_PIPEDN4)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn4.Attach(IDC_RADIO_PIPEDN4, this);
m_wndBtn4.SetBackgroundColor(RGB(255, 0, 255));
GetDlgItem(IDC_RADIO_PIPEDN5)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn5.Attach(IDC_RADIO_PIPEDN5, this);
m_wndBtn5.SetBackgroundColor(RGB(255, 255, 255));
GetDlgItem(IDC_RADIO_PIPEDN6)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn6.Attach(IDC_RADIO_PIPEDN6, this);
m_wndBtn6.SetBackgroundColor(RGB(204, 102, 102));
GetDlgItem(IDC_RADIO_PIPEDN7)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn7.Attach(IDC_RADIO_PIPEDN7, this);
m_wndBtn7.SetBackgroundColor(RGB(255, 191, 0));
GetDlgItem(IDC_RADIO_PIPEDN8)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn8.Attach(IDC_RADIO_PIPEDN8, this);
m_wndBtn8.SetBackgroundColor(RGB(0, 127, 127));
GetDlgItem(IDC_RADIO_PIPEDN9)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn9.Attach(IDC_RADIO_PIPEDN9, this);
m_wndBtn9.SetBackgroundColor(RGB(76, 95, 153));
GetDlgItem(IDC_RADIO_PIPEDN10)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn10.Attach(IDC_RADIO_PIPEDN10, this);
m_wndBtn10.SetBackgroundColor(RGB(255, 0, 0));
GetDlgItem(IDC_RADIO_PIPEDN11)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn11.Attach(IDC_RADIO_PIPEDN11, this);
m_wndBtn11.SetBackgroundColor(RGB(0, 255, 0));
GetDlgItem(IDC_RADIO_PIPEDN12)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn12.Attach(IDC_RADIO_PIPEDN12, this);
m_wndBtn12.SetBackgroundColor(RGB(0, 0, 255));
GetDlgItem(IDC_RADIO_PIPEDN13)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn13.Attach(IDC_RADIO_PIPEDN13, this);
m_wndBtn13.SetBackgroundColor(RGB(255, 0, 255));
GetDlgItem(IDC_RADIO_PIPEDN14)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn14.Attach(IDC_RADIO_PIPEDN14, this);
m_wndBtn14.SetBackgroundColor(RGB(255, 255, 255));
GetDlgItem(IDC_RADIO_PIPEDN15)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn15.Attach(IDC_RADIO_PIPEDN15, this);
m_wndBtn15.SetBackgroundColor(RGB(204, 102, 102));
GetDlgItem(IDC_RADIO_PIPEDN16)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn16.Attach(IDC_RADIO_PIPEDN16, this);
m_wndBtn16.SetBackgroundColor(RGB(255, 191, 0));
GetDlgItem(IDC_RADIO_PIPEDN17)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn17.Attach(IDC_RADIO_PIPEDN17, this);
m_wndBtn17.SetBackgroundColor(RGB(0, 127, 127));
GetDlgItem(IDC_RADIO_PIPEDN18)->ModifyStyle(0, BS_OWNERDRAW, 0);
m_wndBtn18.Attach(IDC_RADIO_PIPEDN18, this);
m_wndBtn18.SetBackgroundColor(RGB(76, 95, 153));
SetBtnText();
return TRUE;
}
void CEditPipeDnGradientDlg::OnRadioPipedn1()
{
m_dPipeDn = 200;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn2()
{
m_dPipeDn = 300;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn3()
{
m_dPipeDn = 400;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn4()
{
m_dPipeDn = 500;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn5()
{
m_dPipeDn = 600;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn6()
{
m_dPipeDn = 700;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn7()
{
m_dPipeDn = 800;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn8()
{
m_dPipeDn = 900;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn9()
{
m_dPipeDn = 1000;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn10()
{
m_dPipeDn = 1100;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn11()
{
m_dPipeDn = 1200;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn12()
{
m_dPipeDn = 1300;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn13()
{
m_dPipeDn = 1400;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn14()
{
m_dPipeDn = 1500;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn15()
{
m_dPipeDn = 1600;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn16()
{
m_dPipeDn = 1700;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn17()
{
m_dPipeDn = 1800;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::OnRadioPipedn18()
{
m_dPipeDn = 2000;
UpdateGradient();
SetEditGradient();
SetGradientFocus();
SetBtnText();
}
void CEditPipeDnGradientDlg::SetEditGradient()
{
CWnd *pWnd = GetDlgItem(IDC_EDIT_GRADIENT);
if (pWnd != NULL)
{
CString strTemp;
strTemp.Format(_T("%.1f"), m_dPipeGradient);
pWnd->SetWindowText(strTemp);
}
}
void CEditPipeDnGradientDlg::OnButtonGradient1()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT1);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 5;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient2()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT2);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 4;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient3()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT3);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 3;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient4()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT4);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 2.5;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient5()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT5);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 2.2;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient6()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT6);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 2;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient7()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT7);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 1.8;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient8()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT8);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 1.6;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient9()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT9);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 1.4;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient10()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT10);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 1;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient11()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT11);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 0.9;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient12()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT12);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 0.8;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient13()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT13);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 0.7;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::OnButtonGradient14()
{
if (m_dPipeDn < 1e-3)
{
CWnd *pWnd = GetDlgItem(IDC_BUTTON_GRADIENT14);
if (pWnd != NULL)
{
pWnd->SendMessage(WM_KILLFOCUS);
}
return;
}
m_dPipeGradient = 0.6;
SetEditGradient();
UpdateDnGradient();
}
void CEditPipeDnGradientDlg::SetGradientFocus()
{
INT_PTR nID = -1;
if (fabs(m_dPipeGradient - 5) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT1;
}
else if (fabs(m_dPipeGradient - 4) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT2;
}
else if (fabs(m_dPipeGradient - 3) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT3;
}
else if (fabs(m_dPipeGradient - 2.5) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT4;
}
else if (fabs(m_dPipeGradient - 2.2) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT5;
}
else if (fabs(m_dPipeGradient - 2) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT6;
}
else if (fabs(m_dPipeGradient - 1.8) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT7;
}
else if (fabs(m_dPipeGradient - 1.6) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT8;
}
else if (fabs(m_dPipeGradient - 1.4) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT9;
}
else if (fabs(m_dPipeGradient - 1) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT10;
}
else if (fabs(m_dPipeGradient - 0.9) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT11;
}
else if (fabs(m_dPipeGradient - 0.8) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT12;
}
else if (fabs(m_dPipeGradient - 0.7) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT13;
}
else if (fabs(m_dPipeGradient - 0.6) < 1e-3)
{
nID = IDC_BUTTON_GRADIENT14;
}
CWnd *pWnd = GetDlgItem(nID);
if (pWnd != NULL)
{
pWnd->SetFocus();
}
}
void CEditPipeDnGradientDlg::UpdateDnGradient()
{
std::map<double, double>::iterator it;
it = m_mapData.find(m_dPipeDn);
if (it != m_mapData.end())
{
(*it).second = m_dPipeGradient;
}
}
void CEditPipeDnGradientDlg::UpdateGradient()
{
std::map<double, double>::iterator it;
it = m_mapData.find(m_dPipeDn);
if (it != m_mapData.end())
{
m_dPipeGradient = (*it).second;
}
}
void CEditPipeDnGradientDlg::InitDnGradient()
{
//CRegProperty regProp(GetRegLocation(), _T("EleClac"));
//regProp.SetTopRootKey(HKEY_CURRENT_USER);
CString strVal(_T(""));
//regProp.GetValue(_T("PipeDnGradient"), strVal);
if (strVal.IsEmpty())
{
m_mapData.insert(std::make_pair(200, 4));
m_mapData.insert(std::make_pair(300, 3));
m_mapData.insert(std::make_pair(400, 2.5));
m_mapData.insert(std::make_pair(500, 2.2));
m_mapData.insert(std::make_pair(600, 2));
m_mapData.insert(std::make_pair(700, 1.8));
m_mapData.insert(std::make_pair(800, 1.6));
m_mapData.insert(std::make_pair(900, 1.4));
m_mapData.insert(std::make_pair(1000, 1));
m_mapData.insert(std::make_pair(1100, 0.9));
m_mapData.insert(std::make_pair(1200, 0.9));
m_mapData.insert(std::make_pair(1300, 0.8));
m_mapData.insert(std::make_pair(1400, 0.7));
m_mapData.insert(std::make_pair(1500, 0.7));
m_mapData.insert(std::make_pair(1600, 0.6));
m_mapData.insert(std::make_pair(1700, 0.6));
m_mapData.insert(std::make_pair(1800, 0.6));
m_mapData.insert(std::make_pair(2000, 0.6));
}
else
{
while (!strVal.IsEmpty())
{
int nIndex = strVal.Find(_T("@"), 0);
if (nIndex == -1)
{
break;
}
else
{
CString strText = strVal.Left(nIndex);
int nSpace = strText.Find(_T(" "), 0);
if (nSpace != -1)
{
CString strDn = strText.Left(nSpace);
CString strGradient = strText.Right(strText.GetLength() - nSpace - 1);
m_mapData.insert(std::make_pair(_tstof(strDn), _tstof(strGradient)));
}
strVal = strVal.Right(strVal.GetLength() - nIndex - 1);
}
}
}
}
void CEditPipeDnGradientDlg::InitPipeColor()
{
m_mapColor.insert(std::make_pair(200, 1));
m_mapColor.insert(std::make_pair(300, 3));
m_mapColor.insert(std::make_pair(400, 5));
m_mapColor.insert(std::make_pair(500, 6));
m_mapColor.insert(std::make_pair(600, 7));
m_mapColor.insert(std::make_pair(700, 13));
m_mapColor.insert(std::make_pair(800, 40));
m_mapColor.insert(std::make_pair(900, 136));
m_mapColor.insert(std::make_pair(1000, 165));
m_mapColor.insert(std::make_pair(1100, 1));
m_mapColor.insert(std::make_pair(1200, 3));
m_mapColor.insert(std::make_pair(1300, 5));
m_mapColor.insert(std::make_pair(1400, 6));
m_mapColor.insert(std::make_pair(1500, 7));
m_mapColor.insert(std::make_pair(1600, 13));
m_mapColor.insert(std::make_pair(1700, 40));
m_mapColor.insert(std::make_pair(1800, 136));
m_mapColor.insert(std::make_pair(2000, 165));
}
void CEditPipeDnGradientDlg::OnChangeEditGradient()
{
CWnd *pWnd = GetDlgItem(IDC_EDIT_GRADIENT);
if (pWnd != NULL)
{
CString strGradient;
pWnd->GetWindowText(strGradient);
m_dPipeGradient = _tstof(strGradient);
UpdateDnGradient();
}
}
BOOL CEditPipeDnGradientDlg::GetPipeColor(int &nColor, double dDn)
{
BOOL bRet = FALSE;
std::map<double, int>::iterator it;
it = m_mapColor.find(dDn);
if (it != m_mapColor.end())
{
bRet = TRUE;
nColor = (*it).second;
}
return bRet;
}
BOOL CEditPipeDnGradientDlg::DestroyWindow()
{
//CRegProperty regProp(GetRegLocation(), _T("EleClac"));
//regProp.SetTopRootKey(HKEY_CURRENT_USER);
CString strText, strDn, strGradient;
std::map<double, double>::iterator it;
for (it = m_mapData.begin(); it != m_mapData.end(); it++)
{
strDn.Format(_T("%.3f"), (*it).first);
strGradient.Format(_T("%.3f"), (*it).second);
strText += strDn + _T(" ") + strGradient + _T("@");
}
//regProp.SetValue(_T("PipeDnGradient"), strText);
return CModelessDialog::DestroyWindow();
}
void CEditPipeDnGradientDlg::OnClose()
{
CModelessDialog::OnClose();
DestroyWindow();
GlobalFunc::PostCommand(_T("\33"), false);
}
void CEditPipeDnGradientDlg::GetPipeOriginColor(PickSet &ss)
{
for (long i = 0; i < ss.Length(); i++)
{
AcDbObjectId id;
acdbGetObjectId(id, ss[i]);
CDbPipe *pPipe = NULL;
acdbOpenObject(pPipe, id, AcDb::kForRead);
if (pPipe != NULL)
{
int nColor = pPipe->colorIndex();
if (m_mapOriginColor.find(id) == m_mapOriginColor.end())
{
m_mapOriginColor.insert(std::make_pair(id, nColor));
}
pPipe->close();
}
}
}
void CEditPipeDnGradientDlg::RecoverPipeOriginColor()
{
std::map<AcDbObjectId, int>::iterator it;
for (it = m_mapOriginColor.begin(); it != m_mapOriginColor.end(); it++)
{
CDbPipe *pPipe = NULL;
acdbOpenObject(pPipe, (*it).first, AcDb::kForWrite);
if (pPipe != NULL)
{
pPipe->setColorIndex((*it).second);
pPipe->close();
}
}
}
void CEditPipeDnGradientDlg::ChangePipeColorDnGradient(PickSet &ss)
{
for (long i = 0; i < ss.Length(); i++)
{
OPENOBJ_BEGIN(ss[i], AcDb::kForWrite, CDbPipe, pPipe);
if (pPipe != NULL)
{
pPipe->SetDnDiameter(m_dPipeDn);
pPipe->SetPipeGradient(m_dPipeGradient / 1000);
int nColor;
if (GetPipeColor(nColor, m_dPipeDn))
{
pPipe->setColorIndex(nColor);
}
}
OPENOBJ_END();
}
}
void CEditPipeDnGradientDlg::ChangePipeColor(PickSet &ss)
{
for (long i = 0; i < ss.Length(); i++)
{
OPENOBJ_BEGIN(ss[i], AcDb::kForWrite, CDbPipe, pPipe);
if (pPipe != NULL)
{
int nColor;
if (GetPipeColor(nColor, pPipe->GetDnDiameter()))
{
pPipe->setColorIndex(nColor);
}
}
OPENOBJ_END();
}
}
void CEditPipeDnGradientDlg::SetBtnText()
{
CString strText;
if (m_dPipeDn == 200)
{
m_wndBtn1.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn1.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn1.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn1.SetWindowText(strText);
}
if (m_dPipeDn == 300)
{
m_wndBtn2.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn2.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn2.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn2.SetWindowText(strText);
}
if (m_dPipeDn == 400)
{
m_wndBtn3.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn3.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn3.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn3.SetWindowText(strText);
}
if (m_dPipeDn == 500)
{
m_wndBtn4.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn4.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn4.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn4.SetWindowText(strText);
}
if (m_dPipeDn == 600)
{
m_wndBtn5.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn5.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn5.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn5.SetWindowText(strText);
}
if (m_dPipeDn == 700)
{
m_wndBtn6.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn6.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn6.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn6.SetWindowText(strText);
}
if (m_dPipeDn == 800)
{
m_wndBtn7.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn7.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn7.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn7.SetWindowText(strText);
}
if (m_dPipeDn == 900)
{
m_wndBtn8.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn8.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn8.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn8.SetWindowText(strText);
}
if (m_dPipeDn == 1000)
{
m_wndBtn9.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn9.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn9.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn9.SetWindowText(strText);
}
if (m_dPipeDn == 1100)
{
m_wndBtn10.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn10.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn10.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn10.SetWindowText(strText);
}
if (m_dPipeDn == 1200)
{
m_wndBtn11.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn11.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn11.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn11.SetWindowText(strText);
}
if (m_dPipeDn == 1300)
{
m_wndBtn12.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn12.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn12.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn12.SetWindowText(strText);
}
if (m_dPipeDn == 1400)
{
m_wndBtn13.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn13.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn13.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn13.SetWindowText(strText);
}
if (m_dPipeDn == 1500)
{
m_wndBtn14.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn14.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn14.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn14.SetWindowText(strText);
}
if (m_dPipeDn == 1600)
{
m_wndBtn15.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn15.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn15.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn15.SetWindowText(strText);
}
if (m_dPipeDn == 1700)
{
m_wndBtn16.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn16.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn16.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn16.SetWindowText(strText);
}
if (m_dPipeDn == 1800)
{
m_wndBtn17.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn17.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn17.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn17.SetWindowText(strText);
}
if (m_dPipeDn == 2000)
{
m_wndBtn18.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn18.SetWindowText(_T("▲") + strText);
}
else
{
m_wndBtn18.GetWindowText(strText);
strText.Replace(_T("▲"), _T(""));
m_wndBtn18.SetWindowText(strText);
}
}
void CEditPipeDnGradientDlg::SetPipeList(SSearchPipeList *pList)
{
m_pLstAll = pList;
}