a
This commit is contained in:
@@ -0,0 +1,228 @@
|
||||
// MediumCustom2D.cpp: implementation of the CMediumCustom2D class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "MediumCustom2D.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
extern int g_iUILanguage;
|
||||
extern CGeoMativeApp theApp;
|
||||
CMediumCustom2D::CMediumCustom2D(int iAR): CMedium(iAR)
|
||||
{
|
||||
|
||||
}
|
||||
CMediumCustom2D::~CMediumCustom2D()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CMediumCustom2D::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
|
||||
{
|
||||
if (NULL == pSptRecArray)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("pSptRecArray不能为空!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("pSptRecArray can't be NULL!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
pSptRecArray->RemoveAll();
|
||||
CSptRecord* pSptRec = NULL;
|
||||
CString strVal = _T("");
|
||||
CString strText = _T("");
|
||||
int iTsn = 0;
|
||||
CDialCustomSptInput* pCustomSptDlg = new CDialCustomSptInput();
|
||||
pCustomSptDlg->Create(IDD_DIALOG_CUSTOMSPT_MANUAL_INPUT, AfxGetMainWnd());
|
||||
pCustomSptDlg->ShowWindow(SW_SHOW);
|
||||
int iRet = pCustomSptDlg->RunModalLoop(MLF_SHOWONIDLE); // 开始非模态窗口模态循环
|
||||
int iMaxLevel = 0;
|
||||
if (RET_OK == iRet)
|
||||
{
|
||||
map<int, map<int, map<int, STDatabaseABMNInfo>>> mapDatabaseABMNInfo; //存放多通道,写入数据库ABMN信息,用于多通道,第一个int用于存放A,第二个int用于存放B,第三个int对应M
|
||||
STDatabaseABMNInfo stDatabaseABMNInfo;
|
||||
map<int, STDatabaseABMNInfo> mapM;
|
||||
map<int, map<int, STDatabaseABMNInfo>> mapB;
|
||||
map<int, map<int, map<int, STDatabaseABMNInfo>>>::iterator iterFindA;
|
||||
map<int, map<int, STDatabaseABMNInfo>>::iterator iterFindB;
|
||||
map<int, STDatabaseABMNInfo>::iterator iterFindM;
|
||||
|
||||
int iCnt = pCustomSptDlg->GetListCount();
|
||||
for (int i = 0; i < iCnt; i++)
|
||||
{
|
||||
pSptRec = new CSptRecord();
|
||||
strVal.Empty();
|
||||
strVal = pCustomSptDlg->GetListItemText(i, 1);
|
||||
if (strVal.IsEmpty())
|
||||
{
|
||||
strText.Empty();
|
||||
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 1"), i);
|
||||
AfxMessageBox(strText);
|
||||
return false;
|
||||
}
|
||||
pSptRec->m_iC1 = atoi(strVal);
|
||||
stDatabaseABMNInfo.uiAElecID = pSptRec->m_iC1;
|
||||
|
||||
strVal.Empty();
|
||||
strVal = pCustomSptDlg->GetListItemText(i, 2);
|
||||
if (strVal.IsEmpty())
|
||||
{
|
||||
strText.Empty();
|
||||
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 2"), i);
|
||||
AfxMessageBox(strText);
|
||||
return false;
|
||||
}
|
||||
pSptRec->m_iC2 = atoi(strVal);
|
||||
stDatabaseABMNInfo.uiBElecID = pSptRec->m_iC2;
|
||||
|
||||
strVal.Empty();
|
||||
strVal = pCustomSptDlg->GetListItemText(i, 3);
|
||||
if (strVal.IsEmpty())
|
||||
{
|
||||
strText.Empty();
|
||||
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 3"), i);
|
||||
AfxMessageBox(strText);
|
||||
return false;
|
||||
}
|
||||
pSptRec->m_iP1 = atoi(strVal);
|
||||
stDatabaseABMNInfo.uiMElecID = pSptRec->m_iP1;
|
||||
|
||||
strVal.Empty();
|
||||
strVal = pCustomSptDlg->GetListItemText(i, 4);
|
||||
if (strVal.IsEmpty())
|
||||
{
|
||||
strText.Empty();
|
||||
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 4"), i);
|
||||
AfxMessageBox(strText);
|
||||
return false;
|
||||
}
|
||||
pSptRec->m_iP2 = atoi(strVal);
|
||||
stDatabaseABMNInfo.uiNElecID = pSptRec->m_iP2;
|
||||
|
||||
strVal.Empty();
|
||||
strVal = pCustomSptDlg->GetListItemText(i, 5);
|
||||
if (strVal.IsEmpty())
|
||||
{
|
||||
strText.Empty();
|
||||
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 5"), i);
|
||||
AfxMessageBox(strText);
|
||||
return false;
|
||||
}
|
||||
pSptRec->m_fK = atof(strVal);
|
||||
stDatabaseABMNInfo.fK = pSptRec->m_fK;
|
||||
|
||||
strVal.Empty();
|
||||
strVal = pCustomSptDlg->GetListItemText(i, 6);
|
||||
if (strVal.IsEmpty())
|
||||
{
|
||||
strText.Empty();
|
||||
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 6"), i);
|
||||
AfxMessageBox(strText);
|
||||
return false;
|
||||
}
|
||||
pSptRec->m_iN = atoi(strVal);
|
||||
stDatabaseABMNInfo.iTrace = pSptRec->m_iN;
|
||||
|
||||
strVal.Empty();
|
||||
strVal = pCustomSptDlg->GetListItemText(i, 7);
|
||||
if (strVal.IsEmpty())
|
||||
{
|
||||
strText.Empty();
|
||||
strText.Format(_T("Get script-data error, iItem = %d, iSubItem = 7"), i);
|
||||
AfxMessageBox(strText);
|
||||
return false;
|
||||
}
|
||||
pSptRec->m_iLevel = atoi(strVal);
|
||||
stDatabaseABMNInfo.iLayer = pSptRec->m_iLevel;
|
||||
|
||||
if (iMaxLevel < pSptRec->m_iLevel)
|
||||
{
|
||||
iMaxLevel = pSptRec->m_iLevel;
|
||||
}
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
//pSptRec->m_iPtNum = 0;
|
||||
pSptRec->m_iTsn = ++iTsn;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
|
||||
//多通道模式对ABMN进行排序
|
||||
if (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel)
|
||||
{
|
||||
iterFindA = mapDatabaseABMNInfo.find(stDatabaseABMNInfo.uiAElecID);
|
||||
mapB.clear();
|
||||
mapM.clear();
|
||||
if (iterFindA != mapDatabaseABMNInfo.end())
|
||||
{
|
||||
iterFindB = iterFindA->second.find(stDatabaseABMNInfo.uiBElecID);
|
||||
if (iterFindB != iterFindA->second.end())
|
||||
{
|
||||
iterFindM = iterFindB->second.find(stDatabaseABMNInfo.uiMElecID);
|
||||
if (iterFindM != iterFindB->second.end())
|
||||
{
|
||||
AfxMessageBox(_T("生成测点AB相同,存在M值相同\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
iterFindB->second.insert(make_pair(stDatabaseABMNInfo.uiMElecID, stDatabaseABMNInfo));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mapM[stDatabaseABMNInfo.uiMElecID] = stDatabaseABMNInfo;
|
||||
iterFindA->second.insert(make_pair(stDatabaseABMNInfo.uiBElecID, mapM));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mapM[stDatabaseABMNInfo.uiMElecID] = stDatabaseABMNInfo;
|
||||
mapB[stDatabaseABMNInfo.uiBElecID] = mapM;
|
||||
mapDatabaseABMNInfo[stDatabaseABMNInfo.uiAElecID] = mapB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//多通道模式,清空pSptRecArray,重新赋值
|
||||
if (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel)
|
||||
{
|
||||
iTsn = 0;
|
||||
pSptRecArray->RemoveAll();
|
||||
map<int, map<int, map<int, STDatabaseABMNInfo>>>::iterator iterA = mapDatabaseABMNInfo.begin();
|
||||
map<int, map<int, STDatabaseABMNInfo>>::iterator iterB;
|
||||
map<int, STDatabaseABMNInfo>::iterator iterM;
|
||||
for (; iterA != mapDatabaseABMNInfo.end(); iterA++)
|
||||
{
|
||||
for (iterB = iterA->second.begin(); iterB != iterA->second.end(); iterB++)
|
||||
{
|
||||
for (iterM = iterB->second.begin(); iterM != iterB->second.end(); iterM++)
|
||||
{
|
||||
pSptRec = new CSptRecord();
|
||||
pSptRec->m_iC1 = iterM->second.uiAElecID;
|
||||
pSptRec->m_iC2 = iterM->second.uiBElecID;
|
||||
pSptRec->m_iP1 = iterM->second.uiMElecID;
|
||||
pSptRec->m_iP2 = iterM->second.uiNElecID;
|
||||
pSptRec->m_fK = iterM->second.fK;
|
||||
pSptRec->m_iN = iterM->second.iTrace;
|
||||
pSptRec->m_iLevel = iterM->second.iLayer;
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
pSptRec->m_iTsn = ++iTsn;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pCustomSptDlg->DestroyWindow();
|
||||
delete pCustomSptDlg;
|
||||
*pMaxLevel = iMaxLevel;
|
||||
*pPtAmount = pSptRecArray->GetSize();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user