148 lines
4.5 KiB
C++
148 lines
4.5 KiB
C++
// MediumLogging.cpp: implementation of the CMediumLogging class.
|
||
//
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
#include "geomative.h"
|
||
#include "MediumLogging.h"
|
||
#include <math.h>
|
||
#ifdef _DEBUG
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[]=__FILE__;
|
||
#define new DEBUG_NEW
|
||
#endif
|
||
|
||
extern int g_iUILanguage;
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Construction/Destruction
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
CMediumLogging::CMediumLogging(int iAR): CMedium(iAR)
|
||
{
|
||
m_fSeprate = 0;
|
||
|
||
}
|
||
|
||
CMediumLogging::~CMediumLogging()
|
||
{
|
||
|
||
}
|
||
|
||
//K值的计算公式为k = pai / (1/AM - 1/sqrt(AM*AM +AB*AB))
|
||
float CMediumLogging::CalculateCESptKVal(float fA, float fB, float fX, float fY)
|
||
{
|
||
if ((fA == fX) || (0 == m_fSeprate))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("AM或间隔系数不能为零!"));
|
||
else
|
||
MessageBoxEx(NULL, _T("AM or Interval coefficient can't be zero!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return 0;
|
||
}
|
||
float fAM = fA - fX;
|
||
float fTmp = 1.0 / fAM - 1.0/sqrt(pow(fAM,2) + pow(m_fSeprate,2));
|
||
return VAL_PI / fTmp;
|
||
|
||
}
|
||
|
||
bool CMediumLogging::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();
|
||
int nTsn = 0;
|
||
int nMid = iEAmount/2;
|
||
int nApos, nBpos, nMpos, nNpos;
|
||
CSptRecord *pSptRec = NULL;
|
||
int iLayer = 0;
|
||
///////////////////////////////////modify by lsq 20160509///////////////////////////////////////
|
||
//根据郑挺新的跨孔方案,电极顺序(以24个电极为例子)从1-12(下到上),13-24(上到下),并且C1P1 = C2P2 始终成立
|
||
//C1P1的距离就是层数,一次增大,每一层的跑极方法为:
|
||
//C1和P1不动,C2P2依次向下运动,每次下移的时候的距离都为2个电极间距,
|
||
//当C2P2到底的时候,C1和P1下移2个电极间距,此时C2和P2再从最高往下移,直到底,这一直重复知道C1和P1到底为止
|
||
//然后层数加1,在继续重复上述步骤
|
||
while(TRUE)
|
||
{
|
||
iLayer++;
|
||
nApos = nMid;
|
||
nMpos = nApos - iLayer;
|
||
if (nMpos < 1)
|
||
{
|
||
break;
|
||
}
|
||
for (; nMpos > 0; )
|
||
{
|
||
nBpos = nMid + 1;
|
||
for (nNpos = nBpos+iLayer; nNpos <= iEAmount; )
|
||
{
|
||
pSptRec = new CSptRecord();
|
||
// memset(pSptRec, 0, sizeof(CSptRecord));
|
||
pSptRec->m_iC1 = nApos;
|
||
pSptRec->m_iC2 = nBpos;
|
||
pSptRec->m_iP1 = nMpos;
|
||
pSptRec->m_iP2 = nNpos;
|
||
pSptRec->m_fK = CalculateCESptKVal(nApos, nBpos, nMpos, nNpos);
|
||
pSptRec->m_iPtNum = (nApos+nBpos+nMpos+nNpos)/4;
|
||
pSptRec->m_iLevel = GenSptRecLevel(nApos, nBpos, nMpos,nNpos);
|
||
pSptRec->m_colorREF = RGB(0, 255, 0);
|
||
pSptRec->m_iN = 1;
|
||
pSptRec->m_bIsSel = TRUE;
|
||
pSptRec->m_iTsn = ++nTsn;
|
||
|
||
pSptRecArray->Add(pSptRec);
|
||
nBpos += 2;
|
||
nNpos += 2;
|
||
}
|
||
nApos -= 2;
|
||
nMpos -= 2;
|
||
|
||
}
|
||
|
||
}
|
||
//////////////////////////////////////////////////////////////////////////
|
||
*pPtAmount = pSptRecArray->GetSize();
|
||
*pMaxLevel = iEAmount/2 -1;
|
||
return true;
|
||
}
|
||
|
||
void CMediumLogging::CalculateSptPtLoc(int iMul, CSptRecord* pSptRecord)
|
||
{
|
||
int iOffsetL = (int)VAL_ZERO;
|
||
int iOffsetR = (int)VAL_ZERO;
|
||
|
||
int iLevel = pSptRecord->m_iLevel;
|
||
int iPtNum = pSptRecord->m_iPtNum;
|
||
|
||
//iOffsetL = (6+2)*iMul+50+4*iMul*(iLevel-1)*3+(iMul-2);
|
||
iOffsetL = (6+2)*iMul+50+(iMul-2);
|
||
// iOffsetR = (6+2)*iMul+(50+6*iMul)+4*iMul*(iLevel-1)*3+(iMul-2);
|
||
iOffsetR = iOffsetL+6*iMul;
|
||
|
||
pSptRecord->m_recPtArea.left = iOffsetL+(6+2)*iMul*(iPtNum-1);
|
||
pSptRecord->m_recPtArea.top = 50+(6+2)*iMul*(iLevel-1);
|
||
pSptRecord->m_recPtArea.right = iOffsetR+(6+2)*iMul*(iPtNum-1);
|
||
pSptRecord->m_recPtArea.bottom = (50+6*iMul)+(6+2)*iMul*(iLevel-1);
|
||
|
||
pSptRecord->m_fPtCenterX = (float)(iOffsetL+(6+2)*iMul*(iPtNum-1) + ((iOffsetR+(6+2)*iMul*(iPtNum-1)) - (iOffsetL+(6+2)*iMul*(iPtNum-1))) / 2);
|
||
pSptRecord->m_fPtCenterY = (float)(50+(6+2)*iMul*(iLevel-1) + (((50+6*iMul)+(6+2)*iMul*(iLevel-1)) - (50+(6+2)*iMul*(iLevel-1))) / 2);
|
||
pSptRecord->m_fPtRadius = (float)(abs((int)(pSptRecord->m_fPtCenterX) - pSptRecord->m_recPtArea.left));
|
||
}
|
||
|
||
int CMediumLogging::GenSptRecLevel(int iA, int iB, int iM, int iN)
|
||
{
|
||
return iA - iM ;
|
||
}
|
||
int CMediumLogging::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
|
||
{
|
||
return 0;
|
||
}
|
||
int CMediumLogging::GetMaxLevelByEAmount(int iEAmount)
|
||
{
|
||
return 0;
|
||
} |