a
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
// MediumAMN.cpp: implementation of the CMediumAMN class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "MediumAMN.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
extern int g_iUILanguage;
|
||||
CMediumAMN::CMediumAMN(int iAR): CMedium(iAR)
|
||||
{
|
||||
m_fEOffsetR = 0.5;
|
||||
m_fLOffsetR = 0;
|
||||
}
|
||||
|
||||
CMediumAMN::~CMediumAMN()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CMediumAMN::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
|
||||
{
|
||||
if (iEAmount < 1)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("AMN-Array中EA_MOUNT的数目为错误!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("The number of EA_MOUNT in AMN-Array is error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
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 iC1Pos,iC2Pos,iP1Pos,iP2Pos;
|
||||
int iTsn = 0;
|
||||
CSptRecord *pSptRec = NULL;
|
||||
int iLayer = 0;
|
||||
iC2Pos = -1;
|
||||
while(TRUE)
|
||||
{
|
||||
iLayer++;
|
||||
iC1Pos = 1;
|
||||
iP1Pos = iC1Pos + iLayer;
|
||||
iP2Pos = iP1Pos + 1;
|
||||
//变化的规律就是B在无穷远,而AMN在同一层中依次右移,可以认为AM的值就是层数
|
||||
//同时,当每层的其实位置时,A都是从1开始的,MN的值
|
||||
//祝工明确说AM的距离最多到20
|
||||
if ((iP2Pos > iEAmount) || (iLayer > 20))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//确定好每一层的电极初始位置之后,开始横向往右测量,此时每测一次,电极向右平移1
|
||||
while(iP2Pos <= iEAmount)
|
||||
{
|
||||
pSptRec = new CSptRecord();
|
||||
pSptRec->m_iC1 = iC1Pos;
|
||||
pSptRec->m_iC2 = iC2Pos;
|
||||
pSptRec->m_iP1 = iP1Pos;
|
||||
pSptRec->m_iP2 = iP2Pos;
|
||||
pSptRec->m_fK = CalculateCESptKVal(iC1Pos, iC2Pos, iP1Pos, iP2Pos);
|
||||
pSptRec->m_iPtNum = iC1Pos;
|
||||
pSptRec->m_iLevel = GenSptRecLevel(iC1Pos, iC2Pos, iP1Pos, iP2Pos);
|
||||
pSptRec->m_colorREF = RGB(0, 255, 0);
|
||||
pSptRec->m_iN = 1;
|
||||
pSptRec->m_bIsSel = TRUE;
|
||||
pSptRec->m_iTsn = ++iTsn;
|
||||
pSptRecArray->Add(pSptRec);
|
||||
|
||||
iC1Pos++;
|
||||
iP1Pos++;
|
||||
iP2Pos++;
|
||||
}
|
||||
}
|
||||
|
||||
*pPtAmount = pSptRecArray->GetSize();
|
||||
*pMaxLevel = iLayer-1;
|
||||
return true;
|
||||
}
|
||||
|
||||
float CMediumAMN::CalculateCESptKVal(float fA, float fB, float fX, float fY)
|
||||
{
|
||||
//这里K值的计算公式为: k = 2*pai*n*(n+1)*a
|
||||
//n:即AM
|
||||
//a:即MN
|
||||
float fNParam = fX - fA;
|
||||
float fAParam = fY - fX;
|
||||
return (2 * VAL_PI * fNParam * (fNParam+1) * fAParam);
|
||||
|
||||
}
|
||||
|
||||
void CMediumAMN::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;
|
||||
|
||||
//此时的中点为MN的中点,
|
||||
iOffsetL = 46 + iMul*(6+2)*iLevel + iMul*((6+2) * (pSptRecord->m_iP2-pSptRecord->m_iP1) / 2 - 3);
|
||||
iOffsetR = iOffsetL+6*iMul;
|
||||
|
||||
//矩形的X轴的位置有OFFSETL 再加上向右的偏移距离组成,向右的偏移距离即是全部电极每测一次向右偏移的距离
|
||||
//举例来说,此时OFFSETL相当于此时的中心点的起始位置,iPtNum-1则相当于此时向右偏移的次数
|
||||
//其中圆点的半径为3
|
||||
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 CMediumAMN::GetMaxLevelByEAmount(int iEAmount)
|
||||
{
|
||||
if (iEAmount > 2)
|
||||
{
|
||||
int iMaxLayer = iEAmount - 2;
|
||||
return (iMaxLayer > 20) ? 20 : iMaxLayer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user