This commit is contained in:
coco
2026-07-03 16:05:30 +08:00
commit df489d5640
1101 changed files with 779140 additions and 0 deletions
@@ -0,0 +1,47 @@
// Channel.cpp: implementation of the CChannel class.
//
//////////////////////////////////////////////////////////////////////
#include "Channel.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CChannel::CChannel()
{
m_iMaxLevel = (int)VAL_ZERO;
m_iPtAmount = (int)VAL_ZERO;
m_iChNumber = (int)VAL_ZERO;
m_iEAmount = (int)VAL_ZERO;
m_pMedium = NULL;
}
CChannel::~CChannel()
{
}
void CChannel::ClearSptRecList()
{
int iRecIndex = (int)VAL_ZERO;
int iRecCount = (int)VAL_ZERO;
POSITION pos = NULL;
iRecCount = m_sptRecArray.GetSize();
CSptRecord* pSptRecord = NULL;
while (iRecIndex < iRecCount)
{
pSptRecord = (CSptRecord*)(m_sptRecArray.GetAt(iRecIndex));
if (pSptRecord != NULL)
{
delete pSptRecord;
pSptRecord = NULL;
}
iRecIndex++;
}
m_sptRecArray.RemoveAll();
}
@@ -0,0 +1,31 @@
// DataMngStruct.cpp: implementation of the CDataMngStruct class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "DataMngStruct.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDataMngStruct::CDataMngStruct()
{
}
CDataMngStruct::~CDataMngStruct()
{
}
bool CDataMngStruct::ShowDetailInfo(CListCtrl& dmsListCtrl)
{
return true;
}
@@ -0,0 +1,27 @@
// DevLinkRecord.cpp: implementation of the CDevLinkRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "DevLinkRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDevLinkRecord::CDevLinkRecord()
{
memset(aDevSN, 0, 128);
memset(aDevCom, 0, 32);
}
CDevLinkRecord::~CDevLinkRecord()
{
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,26 @@
// Electrode.cpp: implementation of the CElectrode class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Electrode.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CElectrode::CElectrode()
{
}
CElectrode::~CElectrode()
{
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,101 @@
// Ipsp2DTdRecord.cpp: implementation of the CIpsp2DTdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Ipsp2DTdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CIpsp2DTdRecord::CIpsp2DTdRecord(DWORD dwChID, _ConnectionPtr& pConnection):CTdRecord(pConnection)
{
m_dwChID = dwChID;
m_iTsn = (int)VAL_ZERO;
m_iC1 = (int)VAL_ZERO;
m_iC2 = (int)VAL_ZERO;
m_iP1 = (int)VAL_ZERO;
m_iP2 = (int)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_iLevel = (int)VAL_ZERO;
m_iPosInLevel = (int)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
m_recPtArea.SetRectEmpty();
}
CIpsp2DTdRecord::~CIpsp2DTdRecord()
{
}
void CIpsp2DTdRecord::ClearAll()
{
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
}
BOOL CIpsp2DTdRecord::SaveData(DWORD dwChID)
{
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
m_dwChID = dwChID;
szSql.Empty();
szSql.Format(_T("insert into td2dcon(TCHID,TSN,C1,C2,P1,P2,N,K,I,V,R0,SP) values(%u,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f)"),
m_dwChID,
this->m_iTsn,
this->m_iC1,
this->m_iC2,
this->m_iP1,
this->m_iP2,
this->m_iN,
this->m_fK,
this->m_fI,
this->m_fV,
this->m_fR0,
this->m_fSP);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
BOOL CIpsp2DTdRecord::LoadOrgData()
{
this->Load2DOrgData();
return TRUE;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,100 @@
// Ipsp3DTdRecord.cpp: implementation of the CIpsp3DTdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Ipsp3DTdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CIpsp3DTdRecord::CIpsp3DTdRecord(DWORD dwChID, _ConnectionPtr& pConnection):CTdRecord(pConnection)
{
m_dwChID = dwChID;
m_iTsn = (int)VAL_ZERO;
m_iC1 = (int)VAL_ZERO;
m_iC2 = (int)VAL_ZERO;
m_iP1 = (int)VAL_ZERO;
m_iP2 = (int)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_iLevel = (int)VAL_ZERO;
m_iPosInLevel = (int)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
m_recPtArea.SetRectEmpty();
}
CIpsp3DTdRecord::~CIpsp3DTdRecord()
{
}
void CIpsp3DTdRecord::ClearAll()
{
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
}
BOOL CIpsp3DTdRecord::SaveData(DWORD dwChID)
{
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
m_dwChID = dwChID;
szSql.Empty();
szSql.Format(_T("insert into td3dcon(TCHID,TSN,C1,C2,P1,P2,N,K,I,V,R0,SP) values(%u,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f)"),
m_dwChID,
this->m_iTsn,
this->m_iC1,
this->m_iC2,
this->m_iP1,
this->m_iP2,
this->m_iN,
this->m_fK,
this->m_fI,
this->m_fV,
this->m_fR0,
this->m_fSP);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
BOOL CIpsp3DTdRecord::LoadOrgData()
{
this->Load3DOrgData();
return TRUE;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,102 @@
// IpspCETdRecord.cpp: implementation of the CIpspCETdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "IpspCETdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CIpspCETdRecord::CIpspCETdRecord(DWORD dwChID, _ConnectionPtr& pConnection):CTdRecord(pConnection)
{
m_dwChID = dwChID;
m_iTsn = (int)VAL_ZERO;
m_fA = (float)VAL_ZERO;
m_fB = (float)VAL_ZERO;
m_fX = (float)VAL_ZERO;
m_fY = (float)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_fDepth = (float)VAL_ZERO;
m_iPosInLevel = (int)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
m_recPtArea.SetRectEmpty();
}
CIpspCETdRecord::~CIpspCETdRecord()
{
}
BOOL CIpspCETdRecord::SaveData(DWORD dwChID)
{
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
m_dwChID = dwChID;
szSql.Empty();
szSql.Format(_T("insert into td1dcon(TCHID,TSN,a,b,x,y,N,K,I,V,R0,SP) values(%u,%d,%.1f,%.1f,%.1f,%.1f,%d,%f,%f,%f,%f,%f)"),
m_dwChID,
this->m_iTsn,
this->m_fA,
this->m_fB,
this->m_fX,
this->m_fY,
this->m_iN,
this->m_fK,
this->m_fI,
this->m_fV,
this->m_fR0,
this->m_fSP);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
void CIpspCETdRecord::ClearAll()
{
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
}
BOOL CIpspCETdRecord::LoadOrgData()
{
// AfxMessageBox(_T("CIpspCETdRecord::LoadOrgData"));
this->LoadCEOrgData();
return TRUE;
}
+657
View File
@@ -0,0 +1,657 @@
// Medium.cpp: implementation of the CMedium class.
//
//////////////////////////////////////////////////////////////////////
#include "Medium.h"
#include <map>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern int g_iUILanguage;
CMedium::CMedium()
{
m_iStartPole = 1;
m_iEndPole = 1;
m_mapUniversalLayer.clear();
}
CMedium::CMedium(int iAR)
{
m_iAR = iAR;
m_iStartPole = 1;
m_iEndPole = 1;
m_mapUniversalLayer.clear();
}
CMedium::~CMedium()
{
}
void CMedium::CalculateTdPtLoc(const CRect& vRect, const int& iEAmount, int& iMaxLevel, CRect& lRect, int& iSmWidth, int& iSmHeight, CPtrArray* pTdRecArray)
{
int iTop = 0;
int iBottom = 0;
int iLeft = 0;
int iRight = 0;
int iRectWidth = 0;
int iRectHeight = 0;
iSmWidth = 0;
iSmHeight = 0;
int iLevel = 0;
int iPos = 0;
int iIndex = 0;
int iEOffset = 0;
int iLOffset = 0;
int iNewEAmount = iEAmount;
if (iEAmount%ELECTRODE_AMOUNT_PERCABLE != 0)
{
iNewEAmount =ELECTRODE_AMOUNT_PERCABLE * (1 + iEAmount/ELECTRODE_AMOUNT_PERCABLE);
}
iMaxLevel = this->GetMaxLevelByEAmount(iNewEAmount);
int iXEAmount = (m_iEndPole > m_iStartPole) ? m_iEndPole - m_iStartPole +1 : iEAmount;
lRect = vRect;
//已此时的CRect的中心移动边来缩小输入的rect的大小
lRect.DeflateRect(141, 40, 61, 40);
//返回大于或者等于指定表达式的最小整数,value 如果有小数部分则进一位
//iEAmount为电极的个数,非测点总数,第一层的测点数是最接近电极数的,在倒三角的剖面中
iSmWidth = (int)ceil(lRect.Width()*1.0/iXEAmount);
iSmHeight = (int)ceil(lRect.Height()*1.0/iMaxLevel);
//将iSmWidth变成奇数,那么iSmWidth-1此时将成为偶数,再用它去乘以任何数也都将是偶数
if (fmod((double)iSmWidth, 2.0) == 0.0)
{
iSmWidth++;
}
//由于极端的AM装置中,那么在第一层的最后一个位置,此时AM的点的坐标将会超过X轴的坐标系,
//所以此时要留有一个装置的余量
iRectWidth = iSmWidth+(iSmWidth-1)*(iXEAmount-1);
//iRectWidth = iSmWidth+(iSmWidth-1)*(iEAmount-2);
if (fmod((double)iSmHeight, 2.0) == 0.0)
{
iSmHeight++;
}
//iRectHeight代表所有层数所占用的总的高度
iRectHeight = iSmHeight+(iSmHeight-1)*(iMaxLevel-1);
if (fmod(lRect.Width()-iRectWidth, 2.0) == 0.0)
{
iLeft = (lRect.Width()-iRectWidth)/2;
iRight = (lRect.Width()-iRectWidth)/2;
}
else
{
iLeft = (lRect.Width()-iRectWidth)/2+1;
iRight = (lRect.Width()-iRectWidth)/2;
}
if (fmod(lRect.Height()-iRectHeight, 2.0) == 0.0)
{
iTop = (lRect.Height()-iRectHeight)/2;
iBottom = (lRect.Height()-iRectHeight)/2;
}
else
{
iTop = (lRect.Height()-iRectHeight)/2+1;
iBottom = (lRect.Height()-iRectHeight)/2;
}
lRect.DeflateRect(iLeft, iTop, iRight, iBottom);
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
//iLOffset和iEOffset用来计算中间点和测点之间的偏差
//比如AMN模式中,点在MN的中点位置,此时m_iPosInLevel取得是M点的位置,
//那么iLOffset和iEOffset则用来计算M和中点位置之间的偏差
iEOffset = (int)((iSmWidth-1)*m_fEOffsetR);
iLOffset = (int)((iSmWidth-1)*m_fLOffsetR);
while (iIndex < pTdRecArray->GetSize())
{
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
iLevel = pRsp2DTdRecord->m_iLevel-1;
iPos = pRsp2DTdRecord->m_iPosInLevel-1 - m_iStartPole + 1;
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
pRsp2DTdRecord->m_recPtArea.SetRect(lRect.left+iEOffset+iLOffset*iLevel+(iSmWidth-1)*iPos, lRect.top+(iSmHeight-1)*iLevel,
lRect.left+iEOffset+iLOffset*iLevel+(iSmWidth-1)*iPos+iSmWidth, lRect.top+(iSmHeight-1)*iLevel+iSmHeight-1);
iIndex++;
}
}
void CMedium::SetValidPoleInfo(int iStartPole,int iEndPole)
{
if (iStartPole < 1 || iEndPole <= iStartPole)
{
CString str = _T("");
if (LANG_ZHCN == g_iUILanguage)
{
str.Format(_T("设置开始电极错误.开始电极 = %d, 结束电极 = %d"), iStartPole, iEndPole);
AfxMessageBox(str);
}
else
{
str.Format(_T("Set start pole error.start_pole = %d, end_pole = %d"), iStartPole, iEndPole);
MessageBoxEx(NULL, str, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
m_iStartPole = 1;
m_iEndPole = 1;
return;
}
m_iStartPole = iStartPole;
m_iEndPole = iEndPole;
}
float CMedium::CalculateDepth(float fA, float fFactor)
{
// return (float)(fabs(fB)+fabs(fA))*fFactor;
return 0.0;
}
void CMedium::ReSortPoint(CPtrArray *f_ptr)
{
CSptRecord* pSptRecord = NULL;
int nMidPos = 0; //第一层中点的起始位置
int nWidth = 0; //用于统计第一层有多少个测点
int *nPos = new int[f_ptr->GetSize()];
for (int n = 0;n < f_ptr->GetSize(); n++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(n);
if (pSptRecord->m_iLevel == 1)
{
nPos[nWidth] = pSptRecord->m_iTsn; //把对应的TSN保存在数组中方便取出
nWidth++;
}
}
nMidPos = ( nWidth / 2 ) - 1; //将测点分成2个部分进行测试,从上一个斜线方向开始测
int FirStart = 0;
int SecStart = 0;
int Sum = 1; //tsn从1开始
FirStart = 0; //第一部分的起点位置
SecStart = nPos[nMidPos] + 1; //第二部分的起点位置
while(Sum < f_ptr->GetSize())
{
for (FirStart; FirStart < nPos[nMidPos]; )
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(FirStart);
pSptRecord->m_iTsn = Sum;
Sum++;
FirStart++;
if (pSptRecord->m_iLevel == 1)
break;
}
for (SecStart; SecStart < f_ptr->GetSize(); )
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(SecStart - 1); //索引要减1
pSptRecord->m_iTsn = Sum;
Sum++;
SecStart++;
if (pSptRecord->m_iLevel == 1)
break;
}
}
//对数组中的元素全部重新进行排序
int sortTsn = 1;
for (int k = 0; k < f_ptr->GetSize(); k++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(k);
if (pSptRecord->m_iTsn != k + 1)
{
for (int n = k + 1; n < f_ptr->GetSize(); n++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(n);
if (pSptRecord->m_iTsn == k + 1)
{
f_ptr->InsertAt(k, pSptRecord);
f_ptr->RemoveAt(n + 1); //上一行代码插入一个元素,故 + 1;
break;
}
}
}
}
}
void CMedium::ReSortPoint(CPtrArray *f_ptr, int iRunMethod)
{
if (iRunMethod < 0 || iRunMethod > 2 )
{
CString str = _T("");
if (LANG_ZHCN == g_iUILanguage)
{
str.Format(_T("输入run_method参数错误.value = %d"), iRunMethod);
AfxMessageBox(str);
}
else
{
str.Format(_T("Input run_method parameter error.value = %d"), iRunMethod);
MessageBoxEx(NULL, str, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return;
}
if (EnSptRunByDisorder == iRunMethod)
{
ReSortPoint(f_ptr);
return;
}
CSptRecord* pSptRecord = NULL;
std::map<STInt2KeyInfo,int> mapOrderInfo;
mapOrderInfo.clear();
STInt2KeyInfo stIntKey;
int i = 0;
int iPtTotalNum = f_ptr->GetSize();
for (i = 0; i < iPtTotalNum; i++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(i);
int iMinElecID = 100000;
if (pSptRecord->m_iC1 > 0)
{
iMinElecID = pSptRecord->m_iC1;
}
if (pSptRecord->m_iC2 > 0 && pSptRecord->m_iC2 < iMinElecID)
{
iMinElecID = pSptRecord->m_iC2;
}
if (pSptRecord->m_iP1 > 0 && pSptRecord->m_iP1 < iMinElecID)
{
iMinElecID = pSptRecord->m_iP1;
}
if (pSptRecord->m_iP2 > 0 && pSptRecord->m_iP2 < iMinElecID)
{
iMinElecID = pSptRecord->m_iP2;
}
//如果是滚动的,则取出电极里最小的电极序号作为KEY1,层数作为KEY2
if (EnSptRunByRoll == iRunMethod)
{
stIntKey.iKey1 = iMinElecID;
stIntKey.iKey2 = pSptRecord->m_iLevel;
}
//如果是分层式跑极,则取出层数作为KEY1,电极里最小的电极序号作为KEY2,
//因为在同一层里,最小电极也是在一直从做向右滚动的
else
{
stIntKey.iKey1 = pSptRecord->m_iLevel;
stIntKey.iKey2 = iMinElecID;
}
mapOrderInfo[stIntKey] = i;
}
if (iPtTotalNum != mapOrderInfo.size())
{
CString str = _T("");
if (LANG_ZHCN == g_iUILanguage)
{
str.Format(_T("由于重叠点的存在,对点误差进行排序.总电极数 = %d,排序电极数 = %d."), iPtTotalNum, mapOrderInfo.size());
AfxMessageBox(str);
}
else
{
str.Format(_T("Sort point error because of overlap point.TotalPtNum = %d,SortPtNum = %d."), iPtTotalNum, mapOrderInfo.size());
MessageBoxEx(NULL, str, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return;
}
CPtrArray NewPtArr;
NewPtArr.RemoveAll();
std::map<STInt2KeyInfo,int>::iterator iter = mapOrderInfo.begin();
int iTsn = 0;
for (; iter != mapOrderInfo.end(); iter++)
{
iTsn++;
pSptRecord = (CSptRecord*)f_ptr->GetAt(iter->second);
pSptRecord->m_iTsn = iTsn;
NewPtArr.Add(pSptRecord);
}
f_ptr->RemoveAll();
for (i = 0; i < NewPtArr.GetSize(); i++)
{
f_ptr->Add(NewPtArr.GetAt(i));
}
if (EnSptRunByLayer == iRunMethod)
{
ResirtPointAgainByLevel(f_ptr);
}
}
void CMedium::ResirtPointAgainByLevel(CPtrArray *f_ptr)
{
//如果是AM装置或者偶极-偶极装置,则不用进行再排序
if (6 == m_iAR || 9 == m_iAR || 4 == m_iAR || 16 == m_iAR || m_iAR > 39)
{
return;
}
int iACoffient = 3;
int iSepCoffient = 0;
CString strErr = _T("");
if (m_iAR >= 1 && m_iAR <= 3)
{
iSepCoffient = 3;
}
else if (11 == m_iAR || 39 == m_iAR || AR_WENNER_SCH_BASIC == m_iAR)
{
iSepCoffient = 2;
}
else if (5 == m_iAR)
{
iACoffient = 2;
iSepCoffient = 2;
}
else
{
if (LANG_ZHCN == g_iUILanguage)
{
strErr.Format(_T("未知装置类型(%d)"), m_iAR);
AfxMessageBox(strErr);
}
else
{
strErr.Format(_T("Unknow medium type(%d) for resort point by lever."), m_iAR);
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return;
}
CPtrArray OrderArr;
OrderArr.RemoveAll();
//此时的f_ptr已经是按照层数来进行排序的
int iTsn = 0;
for (int iLayer = 1; iLayer <= 3; iLayer++)
{
//在这里加1是因为iSepVal指的是中间间隔的点,而不包括起点在内
int iSepVal = iACoffient + (iLayer-1)*iSepCoffient +1;
int iStartIndex = OrderArr.GetSize()+1;
for (int i = 1; i <= iSepVal; i++)
{
int iIndex = iStartIndex + (i-1);
while(TRUE)
{
if (iIndex > f_ptr->GetSize())
{
// strErr.Empty();
// strErr.Format(_T("Resort point by lever overflow.currenr_index = %d, max_point_number = %d"), iIndex, f_ptr->GetSize());
// AfxMessageBox(strErr);
// return;
break;
}
CSptRecord *pt = (CSptRecord*)f_ptr->GetAt(iIndex-1);
if (pt->m_iLevel != iLayer)
{
break;
}
pt->m_iTsn = ++iTsn;
OrderArr.Add(pt);
iIndex += iSepVal;
}
}
}
//此时将排序后前三层的节点的节点进行重新的赋值到原来的链表当中去
for (int n =0; n < OrderArr.GetSize(); n++)
{
f_ptr->SetAt(n, OrderArr.GetAt(n));
}
}
bool CMedium::AddSptToUniLayer(int iA, int iB, int iM, int iN)
{
int iMin = 100000, iMax = 0;
int iDataArr[4] = {iA, iB, iM, iN};
for (int i = 0; i < 4; i++)
{
if (iDataArr[i] > 0)
{
if (iDataArr[i] > iMax)
{
iMax = iDataArr[i];
}
if (iDataArr[i] < iMin)
{
iMin = iDataArr[i];
}
}
}
int iLayer = iMax - iMin;
if (iLayer < 1 || iMin < 1 || iMax < 1)
{
CString strErr = _T("");
if (LANG_ZHCN == g_iUILanguage)
{
strErr.Format(_T("脚本层信息错误.最小值 = %d,最大值 = %d, ABMN = %d,%d,%d,%d"), iMin, iMax, iA, iB, iM, iN);
AfxMessageBox(strErr);
}
else
{
strErr.Format(_T("Script layer information error.MinVal = %d,MaxVal = %d, Index = %d,%d,%d,%d"), iMin, iMax, iA, iB, iM, iN);
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return false;
}
m_mapUniversalLayer[iLayer] = 1;
return true;
}
void CMedium::AddSptToUniLayerFinish()
{
int i = 0;
std::map<int,int>::iterator iter = m_mapUniversalLayer.begin();
for (; iter != m_mapUniversalLayer.end(); iter++)
{
iter->second = ++i;
}
}
int CMedium::QuerySptLayerFromUni(int iA, int iB, int iM, int iN)
{
int iMin = 100000, iMax = 0;
int iDataArr[4] = {iA, iB, iM, iN};
for (int i = 0; i < 4; i++)
{
if (iDataArr[i] > 0)
{
if (iDataArr[i] > iMax)
{
iMax = iDataArr[i];
}
if (iDataArr[i] < iMin)
{
iMin = iDataArr[i];
}
}
}
int iLayer = iMax - iMin;
if (iLayer < 1 || iMin < 1 || iMax < 1)
{
CString strErr = _T("");
if (LANG_ZHCN == g_iUILanguage)
{
strErr.Format(_T("查询脚本层信息错误.最小值 = %d,最大值 = %d, ABMN = %d,%d,%d,%d"), iMin, iMax, iA, iB, iM, iN);
AfxMessageBox(strErr);
}
else
{
strErr.Format(_T("Query Spt layer information error.MinVal = %d,MaxVal = %d, Index = %d,%d,%d,%d"), iMin, iMax, iA, iB, iM, iN);
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return 0;
}
std::map<int,int>::iterator iter = m_mapUniversalLayer.find(iLayer);
if (iter == m_mapUniversalLayer.end())
{
return 0;
}
return iter->second;
}
float CMedium::GetUniSptXPos(int iA, int iB, int iM, int iN)
{
//16-39的区间为1维脚本和3维脚本,不支持
//在这里只支持2维脚本
// if (m_iAR > 16 && m_iAR < 39) //2D脚本装置类型
// {
// AfxMessageBox(_T("Universal script only supprot 2D script."));
// return -1;
// }
int iMin = 100000, iMax = 0, iTotalVal = 0;
int iDataArr[4] = {iA, iB, iM, iN};
int iNegativeCnt = 0;//非正整数的个数
for (int i = 0; i < 4; i++)
{
if (iDataArr[i] > 0)
{
if (iDataArr[i] > iMax)
{
iMax = iDataArr[i];
}
if (iDataArr[i] < iMin)
{
iMin = iDataArr[i];
}
iTotalVal += iDataArr[i];
}
else
iNegativeCnt++;
}
//如果全部是正整数(四级装置),则此时iTotalVal表示的是四个数的总和,那么需要剪掉最大的和最小的
if (0 == iNegativeCnt)
return (iTotalVal-iMin-iMax)*1.0/2;
//如果此时是三级装置,那么此时只需要减掉最小值即可
if (1 == iNegativeCnt)
return (iA < 0 ? (iB + iN) : (iA + iN))*1.0/2;
//如果是二级装置,则不需进行再处理
if (2 == iNegativeCnt)
return iTotalVal*1.0/2;
CString strErr;
if (LANG_ZHCN == g_iUILanguage)
{
strErr.Format(_T("GetUniSptXPos错误,负值%d"), iNegativeCnt);
AfxMessageBox(strErr);
}
else
{
strErr.Format(_T("GetUniSptXPos error,number of negative is %d"), iNegativeCnt);
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return -1;
}
bool CMedium::GeneralUniSptInfo(int& iMaxLevel,CPtrArray* pSptRecArr)
{//louis, here how to modify ?
if (m_iAR > 16 && m_iAR < 39) //2D脚本装置类型
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("通用脚本只支持2D脚本"));
else
MessageBoxEx(NULL, _T("Universal script only supprot 2D script"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
//自定义装置不需要计算通用脚本
if (m_iAR == 40)
{
return true;
}
CSptRecord *pSptRecord = NULL;
int iSize = pSptRecArr->GetSize();
int i = 0;
//跨孔和井地井装置都不能进行剖面图的绘画
//根据育杰的要求,跨孔的层数依然要进行保留(added by 20170120)
if (AR_CROSS_HOLE_TYPE == m_iAR || AR_BIPOLE_HOLE_SPT == m_iAR)
{
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord *)pSptRecArr->GetAt(i);
pSptRecord->m_fSptXPos = 0;
// pSptRecord->m_iLevel = 0;
}
// iMaxLevel = 0;
}
//在这里这些装置由于没有层数信息,所以采用新的通用脚本信息算脚本的层数
else if (m_iAR > 39 && m_iAR < AR_WENNER_SCH_BASIC)//louis ,here is right?
{
ClearUniversalLayer();
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord *)pSptRecArr->GetAt(i);
pSptRecord->m_fSptXPos = GetUniSptXPos(pSptRecord->m_iC1, pSptRecord->m_iC2, pSptRecord->m_iP1, pSptRecord->m_iP2);
if (!AddSptToUniLayer(pSptRecord->m_iC1, pSptRecord->m_iC2, pSptRecord->m_iP1, pSptRecord->m_iP2))
{
ClearUniversalLayer();
return false;
}
}
AddSptToUniLayerFinish();
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord *)pSptRecArr->GetAt(i);
pSptRecord->m_iLevel = QuerySptLayerFromUni(pSptRecord->m_iC1, pSptRecord->m_iC2, pSptRecord->m_iP1, pSptRecord->m_iP2);
}
iMaxLevel = QueryMaxLayerFromUni();
}
//如果是之前已经计算了层数,和郑挺确认过层数信息依然沿用原来的所以在这里只需要单独计算X轴的信息即可
//最大层数也沿用之前的最大层数,不做修改
else
{
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord *)pSptRecArr->GetAt(i);
pSptRecord->m_fSptXPos = GetUniSptXPos(pSptRecord->m_iC1, pSptRecord->m_iC2, pSptRecord->m_iP1, pSptRecord->m_iP2);
}
}
}
bool CMedium::SortMulChannelSpt(CPtrArray* pSptRecArr)
{
if (AR_DIPOLE_POLE_MNB == m_iAR)
return m_sortMulChannelSpt.MultiChannlePtSortForMNB(pSptRecArr);
return m_sortMulChannelSpt.MultiChannlePtSort(pSptRecArr);
}
@@ -0,0 +1,346 @@
// Medium3D.cpp: implementation of the CMedium3D class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Medium3D.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMedium3D::CMedium3D()
{
m_uiStackNumber = 1;
}
CMedium3D::CMedium3D(int iAR)
{
m_uiStackNumber = 1;
}
CMedium3D::~CMedium3D()
{
}
void CMedium3D::CalculateTdPtLoc(const CRect& vRect, const int& iEAmount, int& iMaxLevel, CRect& lRect, int& iSmWidth, int& iSmHeight, CPtrArray* pTdRecArray)
{
int iTop = 0;
int iBottom = 0;
int iLeft = 0;
int iRight = 0;
int iRectWidth = 0;
int iRectHeight = 0;
iSmWidth = 0;
iSmHeight = 0;
int iLevel = 0;
int iPos = 0;
int iIndex = 0;
int iEOffset = 0;
int iLOffset = 0;
iMaxLevel = this->GetMaxLevelByEAmount(iEAmount);
lRect = vRect;
lRect.DeflateRect(141, 30, 35, 30);
iSmWidth = (int)ceil(lRect.Width()*1.0/iEAmount);
iSmHeight = (int)ceil(lRect.Height()*1.0/iMaxLevel);
if (fmod((double)iSmWidth, 2.0) == 0.0)
{
iSmWidth++;
}
iRectWidth = iSmWidth+(iSmWidth-1)*(iEAmount-2);
if (fmod((double)iSmHeight, 2.0) == 0.0)
{
iSmHeight++;
}
iRectHeight = iSmHeight+(iSmHeight-1)*(iMaxLevel-1);
if (fmod(lRect.Width()-iRectWidth, 2.0) == 0.0)
{
iLeft = (lRect.Width()-iRectWidth)/2;
iRight = (lRect.Width()-iRectWidth)/2;
}
else
{
iLeft = (lRect.Width()-iRectWidth)/2+1;
iRight = (lRect.Width()-iRectWidth)/2;
}
if (fmod(lRect.Height()-iRectHeight, 2.0) == 0.0)
{
iTop = (lRect.Height()-iRectHeight)/2;
iBottom = (lRect.Height()-iRectHeight)/2;
}
else
{
iTop = (lRect.Height()-iRectHeight)/2+1;
iBottom = (lRect.Height()-iRectHeight)/2;
}
lRect.DeflateRect(iLeft, iTop, iRight, iBottom);
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
iEOffset = (int)((iSmWidth-1)*m_fEOffsetR);
iLOffset = (int)((iSmWidth-1)*m_fLOffsetR);
while (iIndex < pTdRecArray->GetSize())
{
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
iLevel = pRsp2DTdRecord->m_iLevel-1;
iPos = pRsp2DTdRecord->m_iPosInLevel-1;
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
pRsp2DTdRecord->m_recPtArea.SetRect(lRect.left+iEOffset+iLOffset*iLevel+(iSmWidth-1)*iPos, lRect.top+(iSmHeight-1)*iLevel, lRect.left+iEOffset+iLOffset*iLevel+(iSmWidth-1)*iPos+iSmWidth, lRect.top+(iSmHeight-1)*iLevel+iSmHeight);
iIndex++;
}
}
float CMedium3D::CalculateDepth(float fA, float fFactor)
{
// return (float)(fabs(fB)+fabs(fA))*fFactor;
return 0.0;
}
void CMedium3D::Destroy()
{
if(m_scr)
scr_destroy(m_scr);
}
//将scr中的标记设置为ONLY_45DIAGONAL,并且将该标记对应的状态设置为使能状态
void CMedium3D::SetFlags(BOOL Flags)
{
if(m_scr)
{
if (Flags)
{
scr_set_flags(m_scr,ONLY_45DIAGONAL,TRUE);
}
else
{
scr_set_flags(m_scr,ONLY_45DIAGONAL,FALSE);
}
}
}
void CMedium3D::SetPoleStep(int f_step_x, int f_step_y)
{
scr_set_pole_step(m_scr, f_step_x, f_step_y);
}
bool CMedium3D::GenerateSptRecElecVal3D(int nSplittedNum, CScript3D *pScript, int* pPtAmount, CPtrArray* pSptRecArray)
{
//*pMaxLevel = 0;
_pos pos;
//m_PointNum的大小是128,可查看其定义
memset(pScript->m_PointNum, 0, sizeof(pScript->m_PointNum));
CSptRecord* pSptRecord = NULL;
struct _point *node, *head = NULL;
head = scr_get_points(m_scr);
// int iAmount = 0; //记录测点总数
int Id = 0;
for (node = head; node;)
{
//这个函数对脚本进行分割,nId返回值表示该节点应属于哪个子脚本
if( CheckPointVailed(node,nSplittedNum, &Id) == FALSE)
{
if (node->next == head)
break;
node = node->next;
continue;
}
pSptRecord = new CSptRecord();
pSptRecord->m_iC1 = node->A;
pSptRecord->m_iC2 = node->B;
pSptRecord->m_iP1 = node->M;
pSptRecord->m_iP2 = node->N;
pSptRecord->m_SubScriptIndex = Id;//记录这个测点属于哪个子脚本
pSptRecord->m_fK = node->KS;
// pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)m_uiStackNumber;
pSptRecArray->Add(pSptRecord);
if (node->next == head)
{
(pScript->m_PointNum[Id])++;
break;
}
node = node->next;
(pScript->m_PointNum[Id])++;
// iAmount++;
}
// *pPtAmount = iAmount;
return true;
}
BOOL CMedium3D::CheckPointVailed(_point *point, int SplittedId, int *result)
{
int Aid = 0, Bid = 0, Cid = 0, Did = 0;
if (point->A == -1 && point->B == -1 && point->M == -1 && point->N == -1)
return FALSE;
//取得步长
int xStep = 0, yStep = 0;
scr_get_pole_step(m_scr, &xStep, &yStep);
//取得矩形大小
_rect *rect;
rect = scr_get_rect(m_scr);
//将ABMN电极转换为坐标
_pos *posA, *posB, *posM, *posN;
posA = new _pos();
posB = new _pos();
posM = new _pos();
posN = new _pos();
//将传进来的point(测点)转换成坐标
pole_to_pos(rect, 1, xStep, yStep, posA, point->A);
pole_to_pos(rect, 1, xStep, yStep, posB, point->B);
pole_to_pos(rect, 1, xStep, yStep, posM, point->M);
pole_to_pos(rect, 1, xStep, yStep, posN, point->N);
//计算ABMN的横坐标的位置
int locA = 0, locB = 0, locM = 0, locN = 0;
locA = posA->x - rect->x0;
locB = posB->x - rect->x0;
locM = posM->x - rect->x0;
locN = posN->x - rect->x0;
//-1代表无穷远,即该点无效,locA % SplitterId,A的横坐标取余脚本分割数,结果为该测点所属的子脚本序列
if (point->A != -1)
Aid = locA % SplittedId;
else
Aid = -1;
if (point->B != -1)
Bid = locB % SplittedId;
else
Bid = -1;
if (point->M != -1)
Cid = locM % SplittedId;
else
Cid = -1;
if (point->N != -1)
Did = locN % SplittedId;
else
Did = -1;
//将4个测点所属的子脚本序列放入数据,方便后面运算
int nArray[4] = {Aid, Bid, Cid, Did};
int i = 0;
BOOL bResult = FALSE;
//判断ABMN测点是否属于同一个子脚本序列(即Did,Aid,Bid,Cid是否相等,-1除外)
if (Aid != -1)
{
for (i = 1; i < 4; i++)
{
if (nArray[i] != -1)
{
if (Aid != nArray[i])
{
bResult = FALSE;
goto _exit;
}
}
}
*result = Aid;
}
else if (Bid != -1)
{
//进入该条件,则表明Aid==-1,故不需要再判断
for (i = 2; i < 4; i++)
{
if (nArray[i] != -1)
{
if (Bid != nArray[i])
{
bResult = FALSE;
goto _exit;
}
}
}
*result = Bid;
}
else if (Cid != -1)
{
//进入该条件,则表明Aid==-1且Bid == -1,故不需要再判断
if (Did != -1)
{
if (Cid != Did)
{
bResult = FALSE;
goto _exit;
}
else
*result = Cid;
}
else
*result = Cid;
}
bResult = TRUE;
//三维dipole_dipole装置去掉因子系数大于6的点
if (24 == scr_get_type(m_scr))
{
float fInterval = (1.0*abs(point->M - point->A)) / abs(point->N - point->M);
if ((fInterval > 6.0) || (point->B > point->N))
{
bResult = FALSE;
goto _exit;
}
}
_exit:
delete posA;
delete posB;
delete posM;
delete posN;
return bResult;
}
void CMedium3D::SetPoleDistance(DOUBLE f_dis_x, DOUBLE f_dis_y)
{
scr_set_spacing(m_scr, f_dis_x, f_dis_y);
}
+239
View File
@@ -0,0 +1,239 @@
// MediumA.cpp: implementation of the CMediumA class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumA.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern BOOL DoEvent(HWND hWnd);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumA::CMediumA(int iAR): CMedium(iAR)
{
m_fEOffsetR = 1.0;
m_fLOffsetR = 1.5;
}
CMediumA::~CMediumA()
{
}
bool CMediumA::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
int iEqualValMove = (int)VAL_ZERO;
int iMaxSpace = (int)VAL_ZERO;
int iSpace = (int)VAL_ZERO;
int iTsn = (int)VAL_ZERO;
int iAVal = (int)VAL_ZERO;
int iBVal = (int)VAL_ZERO;
int iMVal = (int)VAL_ZERO;
int iNVal = (int)VAL_ZERO;
int iMAVal = (int)VAL_ZERO;
int iMMVal = (int)VAL_ZERO;
int iMNVal = (int)VAL_ZERO;
int iMBVal = (int)VAL_ZERO;
int iMMove = (int)VAL_ZERO;
int iAMove = (int)VAL_ZERO;
int iTotalMove = (int)VAL_ZERO;
int iMaxLevel = (int)VAL_ZERO;
CSptRecord* pSptRecord = NULL;
CString str = _T("");
while ((iEAmount-iEqualValMove-1) % 3)
{
iEqualValMove++;
}
iMaxSpace = (iEAmount-iEqualValMove-1) / 3;
iTotalMove = iEAmount - 4;
for (iMMVal = 2; iMMVal <= 2+iTotalMove; iMMVal++)
{
if (iMMVal <= (iMaxSpace + 1))
{
iMAVal = 1;
iSpace++;
}
else if ((iMMVal > (iMaxSpace + 1)) && (iMMVal <= ((iMaxSpace + 1)+iEqualValMove)))
{
iSpace = iMaxSpace;
iMAVal = iMMVal-iSpace;
}
else if (iMMVal > ((iMaxSpace + 1)+iEqualValMove))
{
if (iMBVal == iEAmount)
{
iSpace--;
}
iMAVal = iMMVal-iSpace;
}
iMNVal = iMMVal+iSpace;
iMBVal = iMMVal+2*iSpace;
iAVal = iMAVal;
iMVal = iMMVal;
iNVal = iMNVal;
iBVal = iMBVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
iAMove = iMVal - iAVal;
while (iAMove > 1)
{
iAVal++;
iNVal--;
iBVal = iBVal-2;
iAMove--;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
return true;
}
float CMediumA::CalculateSptKVal(int iM, int iN)
{
float fK = (float)VAL_ZERO;
fK = (float)(2*VAL_PI*(iN-iM));
return fK;
}
float CMediumA::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return 0.0;
}
int CMediumA::CalculateSptLevel(int iM, int iN)
{
return iN-iM;
}
void CMediumA::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
)
{
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);
// 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 CMediumA::CalculateRecPosInlevel(int iA)
{
return iA;
}
int CMediumA::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return CalculateSptLevel(iM, iN);
}
int CMediumA::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return CalculateRecPosInlevel(iA);
}
int CMediumA::GetMaxLevelByEAmount(int iEAmount)
{
// if (((iEAmount%12) == 0) && (0 != iEAmount))
// {
// return 3+(iEAmount/12-1)*4;
// }
// return 0;
//跟进排列来推算,假设最大层数为x,那么此时收个1+3x = iEAmount时,x即为最大层数
//由于x为整数,所以对此表达式取整即为最大层数
if (iEAmount > 0)
return (int)((iEAmount-1)/3);
else
return 0;
}
@@ -0,0 +1,135 @@
// MediumAM.cpp: implementation of the CMediumAM class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumAM.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern int g_iUILanguage;
CMediumAM::CMediumAM(int iAR): CMedium(iAR)
{
m_fEOffsetR = 0.5;
m_fLOffsetR = 0.5;
}
CMediumAM::~CMediumAM()
{
}
bool CMediumAM::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
{
if (iEAmount < 1)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("AM-Array中的EA_MOUNT数目为错误!"));
else
MessageBoxEx(NULL, _T("The number of EA_MOUNT in AM-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;
iP2Pos = -1;
while(TRUE)
{
iLayer++;
iC1Pos = 1;
iP1Pos = iC1Pos + iLayer;
//变化的规律就是B,N都在无穷远,而AM在同一层中依次右移,可以认为AM的值就是层数
//同时,当每层的其实位置时,A都是从1开始的
if (iP1Pos > iEAmount)
{
break;
}
//确定好每一层的电极初始位置之后,开始横向往右测量,此时每测一次,电极向右平移1
while(iP1Pos <= 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++;
}
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = iLayer-1;
return true;
}
float CMediumAM::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
//这里K值的计算公式为: k = 2*pai*AM
//n:指的是AM之间的间隔系数(即AM=n*a)
//x:指的是MN之间的间隔系数(即MN=x*a)
return (2*VAL_PI*(fX - fA));
}
void CMediumAM::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;
//此时的中点为AM的中点
iOffsetL = 46 + iMul*((6+2)*iLevel/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 CMediumAM::GetMaxLevelByEAmount(int iEAmount)
{
if (iEAmount < 2)
{
return 0;
}
return iEAmount-1;
}
@@ -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;
}
+237
View File
@@ -0,0 +1,237 @@
// MediumB.cpp: implementation of the CMediumB class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumB.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern BOOL DoEvent(HWND hWnd);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumB::CMediumB(int iAR): CMedium(iAR)
{
m_fEOffsetR = 1.0;
m_fLOffsetR = 1.5;
}
CMediumB::~CMediumB()
{
}
bool CMediumB::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
int iEqualValMove = (int)VAL_ZERO;
int iMaxSpace = (int)VAL_ZERO;
int iSpace = (int)VAL_ZERO; //电极间的距离
int iTsn = (int)VAL_ZERO;
int iAVal = (int)VAL_ZERO;
int iBVal = (int)VAL_ZERO;
int iMVal = (int)VAL_ZERO;
int iNVal = (int)VAL_ZERO;
int iMAVal = (int)VAL_ZERO;
int iMMVal = (int)VAL_ZERO;
int iMNVal = (int)VAL_ZERO;
int iMBVal = (int)VAL_ZERO;
int iMMove = (int)VAL_ZERO;
int iAMove = (int)VAL_ZERO;
int iTotalMove = (int)VAL_ZERO;
int iMaxLevel = (int)VAL_ZERO;
CSptRecord* pSptRecord = NULL;
CString str = _T("");
while ((iEAmount - iEqualValMove - 1) % 3)
{
iEqualValMove++;
}
iMaxSpace = (iEAmount - iEqualValMove -1) / 3;
iTotalMove = iEAmount - 4;
for (iMBVal = 2; iMBVal <= 2+iTotalMove; iMBVal++)
{
if (iMBVal <= (iMaxSpace + 1))
{
iMAVal = 1;
iSpace++;
}
else if ((iMBVal > (iMaxSpace + 1)) && (iMBVal <= ((iMaxSpace + 1)+iEqualValMove)))
{
iSpace = iMaxSpace;
iMAVal = iMBVal-iSpace;
}
else if (iMBVal > ((iMaxSpace + 1)+iEqualValMove))
{
if (iMNVal == iEAmount)
{
iSpace--;
}
iMAVal = iMBVal-iSpace;
}
iMMVal = iMBVal+iSpace;
iMNVal = iMBVal+2*iSpace;
iAVal = iMAVal;
iBVal = iMBVal;
iMVal = iMMVal;
iNVal = iMNVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC2 = iAVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iC1 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
iAMove = iBVal - iAVal;
while (iAMove > 1)
{
iAVal++;
iMVal--;
iNVal = iNVal-2;
iAMove--;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC2 = iAVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iC1 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
return true;
}
float CMediumB::CalculateSptKVal(int iM, int iN)
{
float fK = (float)VAL_ZERO;
fK = (float)(6*VAL_PI*(iN-iM));
return fK;
}
float CMediumB::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return 0.0;
}
int CMediumB::CalculateSptLevel(int iM, int iN)
{
return iN-iM;
}
void CMediumB::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
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);
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 CMediumB::CalculateRecPosInlevel(int iA)
{
return iA;
}
int CMediumB::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return CalculateSptLevel(iM, iN);
}
int CMediumB::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return CalculateRecPosInlevel(iA);
}
int CMediumB::GetMaxLevelByEAmount(int iEAmount)
{
// if (((iEAmount%12) == 0) && (0 != iEAmount))
// {
// return 3+(iEAmount/12-1)*4;
// }
//跟进排列来推算,假设最大层数为x,那么此时收个1+3x = iEAmount时,x即为最大层数
//由于x为整数,所以对此表达式取整即为最大层数
if (iEAmount > 0)
return (int)((iEAmount-1)/3);
else
return 0;
}
@@ -0,0 +1,385 @@
// MediumWenAndSch.cpp: implementation of the CMediumBasicWenAndSch class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumBasicWenAndSch.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
typedef struct ST_LAYER_ORDER_INDEX
{
int iLayer;
std::vector<int> vtIndex;
ST_LAYER_ORDER_INDEX()
{
iLayer = 0;
vtIndex.clear();
}
}STlayerOrderIndex;
extern int g_iUILanguage;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumBasicWenAndSch::CMediumBasicWenAndSch(int iAR): CMedium(iAR)
{
m_fEOffsetR = 0.5;
m_fLOffsetR = 0;
}
CMediumBasicWenAndSch::~CMediumBasicWenAndSch()
{
}
bool CMediumBasicWenAndSch::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
{
if (iEAmount < 1)
{
AfxMessageBox(_T("The number of EA_MOUNT in Wenner_Schlumberger is error!"));
return false;
}
if (NULL == pSptRecArray)
{
AfxMessageBox(_T("pSptRecArray can't be NULL!"));
return false;
}
pSptRecArray->RemoveAll();
int iC1Pos,iC2Pos,iP1Pos,iP2Pos;
int iXParam = 1;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
int iLayer = 0,iTailorLayer = 0;
////////////////////modifyed by lsq 20160510//////////////////////////////////////////////////////
//AM=BN,当AM间隔选择为5或者5的倍数时,此时的下一层点的MN间间距每隔五层增加2个电极点距(MN间间距按1、3、5、7…等间隔增加),
//并且AM的间隔会暂停增加一次,测量时,AM,NB间电极间距按隔离系数由小到大的顺序等间隔增加,
// 第一层时,A=#1M=#2 N=#3 B=#4 … → … A=#57M=#58N=#59B=#60
// 第二层时,A=#1M=#3 N=#4 B=#6 … → … A=#55M=#57N=#58B=#60
// 第三层时,A=#1M=#4 N=#5 B=#8 … → … A=#53M=#56N=#57B=#60
// 第四层时,A=#1M=#5 N=#6 B=#10 … → … A=#51M=#55N=#56B=#60
// 第五层时,A=#1M=#6 N=#7 B=#12 … → … A=#49M=#54N=#55B=#60
// 第六层时,A=#1 M=#6 N=#9 B=#14 … → … A=#47M=#52N=#55B=#60
// 第七层时,A=#1M=#7 N=#10B=#16 … → … A=#45M=#51N=#54B=#60
// 第八层时,A=#1M=#8 N=#11B=#18 … → … A=#43M=#50N=#53B=#60
// 第九层时,A=#1M=#9 N=#12B=#20 … → … A=#41M=#49N=#52B=#60
// 第十层时,A=#1M=#10N=#13B=#22 … → … A=#39M=#48N=#51B=#60
// 第十一层时,A=#1 M=#10N=#15B=#24 … → … A=#37M=#46N=#51B=#60
while(TRUE)
{
iLayer++;
iTailorLayer = (iLayer-1)/5;
iC1Pos = 1;
iP1Pos = iC1Pos + iLayer - iTailorLayer;
iXParam = 1 + iTailorLayer*2;
iP2Pos = iP1Pos + iXParam;
iC2Pos = iP2Pos + iLayer - iTailorLayer;;
if (iC2Pos > iEAmount)
{
break;
}
//确定好每一层的电极初始位置之后,开始横向往右测量,此时每测一次,电极向右平移1
while(iC2Pos <= 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);
//在这里这么计算是因为在修改规则之后,无法通过层数判断MN之间的间距,用这种计算方法,
//由于iXParam为奇数,所以m_iPtNum的位置距离MN真实中点的位置只差0.5个电极间距
pSptRec->m_iPtNum = iP1Pos + iXParam/2;
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++;
iC2Pos++;
iP1Pos++;
iP2Pos++;
}
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = iLayer-1;
return true;
}
float CMediumBasicWenAndSch::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
//这里K值的计算公式为: k = n(n+x)*pai*a/x
//其中a为最小电极间距,我们默认为1,由GD10主机设置
//n:指的是AM之间的间隔系数(即AM=n*a)
//x:指的是MN之间的间隔系数(即MN=x*a)
if (fX == fY)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("MN的距离不能为零!"));
else
AfxMessageBox(_T("The distance between M and N can not be zero,please check!"));
return 0;
}
float fNparam = fX - fA;
float fXParam = fY - fX;
return (VAL_PI*fNparam*(fNparam+fXParam)) / fXParam;
}
void CMediumBasicWenAndSch::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;
//此时的OFFSETL相当于每一层第一次ABMN中的点的矩形初始位置,其中X轴的坐标间距为8
//46为坐标轴起始点在X方向的距离
//其中46+ (6+2)*iMul+ 4*iMul*(iLevel-1)*2就是M的起始位置
//iOffsetL = (6+2)*iMul+50+4*iMul*(iLevel-1)*2+(iMul-2);
// iOffsetL = 46+ (6+2)*iMul+ 4*iMul*(iLevel-1)*2 + iMul* ((pSptRecord->m_iP2 - pSptRecord->m_iP1)*(6+2)/2 - 3) ;
// iOffsetR = iOffsetL+6*iMul;
iOffsetL = 46;
iOffsetR = iOffsetL+6*iMul;
//矩形的X轴的位置有OFFSETL 再加上向右的偏移距离组成,向右的偏移距离即是全部电极每测一次向右偏移的距离
//举例来说,此时OFFSETL相当于此时的中心点的起始位置,iPtNum-1则相当于此时向右偏移的次数
//其中圆点的半径为3,在这里加4是因为iPtNum距离真正中心点的位置差半个电极间距,
pSptRecord->m_recPtArea.left = iOffsetL+(6+2)*iMul*(iPtNum-1) + (4-3)*iMul;
pSptRecord->m_recPtArea.top = 50+(6+2)*iMul*(iLevel-1);
pSptRecord->m_recPtArea.right = iOffsetR+(6+2)*iMul*(iPtNum-1)+ (4-3)*iMul;
pSptRecord->m_recPtArea.bottom = (50+6*iMul)+(6+2)*iMul*(iLevel-1);
pSptRecord->m_fPtCenterX = (float)(pSptRecord->m_recPtArea.left + pSptRecord->m_recPtArea.right)/2;
pSptRecord->m_fPtCenterY = (float)(pSptRecord->m_recPtArea.top + pSptRecord->m_recPtArea.bottom )/2;
pSptRecord->m_fPtRadius = (float)(abs((int)(pSptRecord->m_fPtCenterX) - pSptRecord->m_recPtArea.left));
}
int CMediumBasicWenAndSch::GetMaxLevelByEAmount(int iEAmount)
{
if (iEAmount < 4)
{
return 0;
}
int iC1Pos,iC2Pos,iP1Pos,iP2Pos;
int iXParam = 1;
int iLayer = 0,iTailorLayer = 0;
while(TRUE)
{
iLayer++;
iTailorLayer = (iLayer-1)/5;
iC1Pos = 1;
iP1Pos = iC1Pos + iLayer - iTailorLayer;
iXParam = 1 + iTailorLayer*2;
iP2Pos = iP1Pos + iXParam;
iC2Pos = iP2Pos + iLayer -iTailorLayer;
if (iC2Pos > iEAmount)
{
break;
}
}
return iLayer-1;
}
void CMediumBasicWenAndSch::CalculateTdPtLoc(const CRect& vRect, const int& iEAmount, int& iMaxLevel, CRect& lRect, int& iSmWidth, int& iSmHeight, CPtrArray* pTdRecArray)
{
int iTop = 0;
int iBottom = 0;
int iLeft = 0;
int iRight = 0;
int iRectWidth = 0;
int iRectHeight = 0;
iSmWidth = 0;
iSmHeight = 0;
int iLevel = 0;
int iPos = 0;
int iIndex = 0;
int iEOffset = 0;
int iLOffset = 0;
int iNewEAmount = iEAmount;
if (iEAmount%ELECTRODE_AMOUNT_PERCABLE != 0)
{
iNewEAmount =ELECTRODE_AMOUNT_PERCABLE * (1 + iEAmount/ELECTRODE_AMOUNT_PERCABLE);
}
iMaxLevel = this->GetMaxLevelByEAmount(iNewEAmount);
int iXEAmount = (m_iEndPole > m_iStartPole) ? m_iEndPole - m_iStartPole +1 : iEAmount;
lRect = vRect;
//已此时的CRect的中心移动边来缩小输入的rect的大小
lRect.DeflateRect(141, 40, 61, 40);
//返回大于或者等于指定表达式的最小整数,value 如果有小数部分则进一位
//iEAmount为电极的个数,非测点总数,第一层的测点数是最接近电极数的,在倒三角的剖面中
iSmWidth = (int)ceil(lRect.Width()*1.0/iXEAmount);
iSmHeight = (int)ceil(lRect.Height()*1.0/iMaxLevel);
//将iSmWidth变成奇数,那么iSmWidth-1此时将成为偶数,再用它去乘以任何数也都将是偶数
if (fmod((double)iSmWidth, 2.0) == 0.0)
{
iSmWidth++;
}
//由于极端的AM装置中,那么在第一层的最后一个位置,此时AM的点的坐标将会超过X轴的坐标系,
//所以此时要留有一个装置的余量
iRectWidth = iSmWidth+(iSmWidth-1)*(iXEAmount-1);
//iRectWidth = iSmWidth+(iSmWidth-1)*(iEAmount-2);
if (fmod((double)iSmHeight, 2.0) == 0.0)
{
iSmHeight++;
}
iRectHeight = iSmHeight+(iSmHeight-1)*(iMaxLevel-1);
if (fmod(lRect.Width()-iRectWidth, 2.0) == 0.0)
{
iLeft = (lRect.Width()-iRectWidth)/2;
iRight = (lRect.Width()-iRectWidth)/2;
}
else
{
iLeft = (lRect.Width()-iRectWidth)/2+1;
iRight = (lRect.Width()-iRectWidth)/2;
}
if (fmod(lRect.Height()-iRectHeight, 2.0) == 0.0)
{
iTop = (lRect.Height()-iRectHeight)/2;
iBottom = (lRect.Height()-iRectHeight)/2;
}
else
{
iTop = (lRect.Height()-iRectHeight)/2+1;
iBottom = (lRect.Height()-iRectHeight)/2;
}
lRect.DeflateRect(iLeft, iTop, iRight, iBottom);
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
//iLOffset和iEOffset用来计算中间点和测点之间的偏差
//比如AMN模式中,点在MN的中点位置,此时m_iPosInLevel取得是M点的位置,
//那么iLOffset和iEOffset则用来计算M和中点位置之间的偏差
iEOffset = (int)((iSmWidth-1)*m_fEOffsetR);
iLOffset = (int)((iSmWidth-1)*m_fLOffsetR);
while (iIndex < pTdRecArray->GetSize())
{
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
iLevel = pRsp2DTdRecord->m_iLevel-1;
iPos = pRsp2DTdRecord->m_iPosInLevel-1 - m_iStartPole + 1;
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
pRsp2DTdRecord->m_recPtArea.SetRect(lRect.left+iEOffset+iLOffset*(int)(iLevel/3)+(iSmWidth-1)*iPos, lRect.top+(iSmHeight-1)*iLevel,
lRect.left+iEOffset+iLOffset*(int)(iLevel/3)+(iSmWidth-1)*iPos+iSmWidth, lRect.top+(iSmHeight-1)*iLevel+iSmHeight);
iIndex++;
}
}
void CMediumBasicWenAndSch::ReSortPoint(CPtrArray *f_ptr)
{
//在同一层内,取中点作为间隔点,左右两边分别跑跑,跑完后在取中间点
//例如总共有5个点时,序号分别为1-5,此时的跑极顺序为1,4,2,5,3
//在不同层时,按照层数的从小到大进行跑极
CSptRecord *pSptRecord = NULL;
CSptRecord *pTmp = NULL;
int iMaxLevel = ((CSptRecord *)(f_ptr->GetAt(f_ptr->GetSize()-1)))->m_iLevel;
if (0 == iMaxLevel)
{
return;
}
int nPreCnt = 0;
std::vector<STlayerOrderIndex> vtLayerOrderInfo;
vtLayerOrderInfo.clear();
int i = 1;
for (; i <= iMaxLevel; i++)
{
int nCurLayerCnt = 0;
for (int j = nPreCnt; j < f_ptr->GetSize(); j++)
{
pTmp = (CSptRecord*)(f_ptr->GetAt(j));
if (i == pTmp->m_iLevel)
{
nCurLayerCnt++;
}
else
break;
}
STlayerOrderIndex stLayerOrder;
stLayerOrder.iLayer = 1;
stLayerOrder.vtIndex.clear();
bool bIsOdd = (nCurLayerCnt %2 == 0) ? false : true;
int iMidIndex = 0;
if (bIsOdd)
{
iMidIndex = (nCurLayerCnt+1)/2;
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-1);
for (int iIndex = 1; iIndex <iMidIndex; iIndex++)
{
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-iIndex-1);
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex+iIndex-1);
}
}
else
{
iMidIndex = nCurLayerCnt/2;
for (int iIndex = 1; iIndex <=iMidIndex; iIndex++)
{
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-(iIndex-1)-1);
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex+iIndex-1);
}
}
vtLayerOrderInfo.push_back(stLayerOrder);
nPreCnt += nCurLayerCnt;
}
CPtrArray newPtArr;
newPtArr.RemoveAll();
int iMaxIndex = vtLayerOrderInfo[0].vtIndex.size();
for (int iIndex = 0; iIndex < iMaxIndex; iIndex++)
{
for (i = 1; i <= iMaxLevel; i++)
{
if (iIndex > vtLayerOrderInfo[i-1].vtIndex.size()-1)
{
continue;
}
int iOrderIndex = vtLayerOrderInfo[i-1].vtIndex[iIndex];
pSptRecord = (CSptRecord*)f_ptr->GetAt(iOrderIndex);
newPtArr.Add(pSptRecord);
}
}
if (newPtArr.GetSize() != f_ptr->GetSize())
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("数据重排错误!"));
else
AfxMessageBox(_T("resort data error!"));
return;
}
f_ptr->RemoveAll();
int iTsn = 0;
for (int k = 0; k < newPtArr.GetSize(); k++)
{
pSptRecord = (CSptRecord*)newPtArr.GetAt(k);
pSptRecord->m_iTsn = ++iTsn;
f_ptr->Add(pSptRecord);
}
}
+240
View File
@@ -0,0 +1,240 @@
// MediumC.cpp: implementation of the CMediumC class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumC.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern BOOL DoEvent(HWND hWnd);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumC::CMediumC(int iAR): CMedium(iAR)
{
m_fEOffsetR = 1.0;
m_fLOffsetR = 1.5;
}
CMediumC::~CMediumC()
{
}
bool CMediumC::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
int iEqualValMove = (int)VAL_ZERO;
int iMaxSpace = (int)VAL_ZERO;
int iSpace = (int)VAL_ZERO;
int iTsn = (int)VAL_ZERO;
int iAVal = (int)VAL_ZERO;
int iBVal = (int)VAL_ZERO;
int iMVal = (int)VAL_ZERO;
int iNVal = (int)VAL_ZERO;
int iMAVal = (int)VAL_ZERO;
int iMMVal = (int)VAL_ZERO;
int iMNVal = (int)VAL_ZERO;
int iMBVal = (int)VAL_ZERO;
int iMMove = (int)VAL_ZERO;
int iAMove = (int)VAL_ZERO;
int iTotalMove = (int)VAL_ZERO;
int iMaxLevel = (int)VAL_ZERO;
CSptRecord* pSptRecord = NULL;
CString str = _T("");
while ((iEAmount - iEqualValMove - 1) % 3)
{
iEqualValMove++;
}
iMaxSpace = (iEAmount - iEqualValMove -1) / 3;
iTotalMove = iEAmount - 4;
for (iMMVal = 2; iMMVal <= 2+iTotalMove; iMMVal++)
{
if (iMMVal <= (iMaxSpace + 1))
{
iMAVal = 1;
iSpace++;
}
else if ((iMMVal > (iMaxSpace + 1)) && (iMMVal <= ((iMaxSpace + 1)+iEqualValMove)))
{
iSpace = iMaxSpace;
iMAVal = iMMVal-iSpace;
}
else if (iMMVal > ((iMaxSpace + 1)+iEqualValMove))
{
if (iMNVal == iEAmount)
{
iSpace--;
}
iMAVal = iMMVal-iSpace;
}
iMBVal = iMMVal+iSpace;
iMNVal = iMMVal+2*iSpace;
iAVal = iMAVal;
iMVal = iMMVal;
iBVal = iMBVal;
iNVal = iMNVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iAVal, iMVal);
pSptRecord->m_iLevel = CalculateSptLevel(iBVal, iMVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
iAMove = iMVal - iAVal;
while (iAMove > 1)
{
iAVal++;
iBVal--;
iNVal = iNVal-2;
iAMove--;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iAVal, iMVal);
pSptRecord->m_iLevel = CalculateSptLevel(iBVal, iMVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
return true;
}
float CMediumC::CalculateSptKVal(int iA, int iM)
{
float fK = (float)VAL_ZERO;
fK = (float)(3*VAL_PI*(iM-iA));
return fK;
}
float CMediumC::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return 0.0;
}
int CMediumC::CalculateSptLevel(int iB, int iM)
{
return iB-iM;
}
void CMediumC::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
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);
// 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 CMediumC::CalculateRecPosInlevel(int iA)
{
return iA;
}
int CMediumC::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return CalculateSptLevel(iB, iM);
}
int CMediumC::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return CalculateRecPosInlevel(iA);
}
int CMediumC::GetMaxLevelByEAmount(int iEAmount)
{
// if (((iEAmount%12) == 0) && (0 != iEAmount))
// {
// return 3+(iEAmount/12-1)*4;
// }
// return 0;
//跟进排列来推算,假设最大层数为x,那么此时收个1+3x = iEAmount时,x即为最大层数
//由于x为整数,所以对此表达式取整即为最大层数
if (iEAmount > 0)
return (int)((iEAmount-1)/3);
else
return 0;
}
@@ -0,0 +1,148 @@
// MediumLogging.cpp: implementation of the CMediumLogging class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumCrossHoleGeomative.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
//////////////////////////////////////////////////////////////////////
CMediumCrossHoleGeomative::CMediumCrossHoleGeomative(int iAR) : CMedium(iAR)
{
m_fSeprate = 0;
}
CMediumCrossHoleGeomative::~CMediumCrossHoleGeomative()
{
}
//K值的计算公式为k = pai / (1/AM - 1/sqrt(AM*AM +AB*AB))
float CMediumCrossHoleGeomative::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 CMediumCrossHoleGeomative::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 CMediumCrossHoleGeomative::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 CMediumCrossHoleGeomative::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return iA - iM ;
}
int CMediumCrossHoleGeomative::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return 0;
}
int CMediumCrossHoleGeomative::GetMaxLevelByEAmount(int iEAmount)
{
return 0;
}
@@ -0,0 +1,148 @@
// MediumLogging.cpp: implementation of the CMediumLogging class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumCrossHoleGeomativeAM.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
//////////////////////////////////////////////////////////////////////
CMediumCrossHoleGeomativeAM::CMediumCrossHoleGeomativeAM(int iAR) : CMedium(iAR)
{
m_fSeprate = 0;
}
CMediumCrossHoleGeomativeAM::~CMediumCrossHoleGeomativeAM()
{
}
//K值的计算公式为k = pai / (1/AM - 1/sqrt(AM*AM +AB*AB))
float CMediumCrossHoleGeomativeAM::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 CMediumCrossHoleGeomativeAM::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 CMediumCrossHoleGeomativeAM::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 CMediumCrossHoleGeomativeAM::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return iA - iM ;
}
int CMediumCrossHoleGeomativeAM::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return 0;
}
int CMediumCrossHoleGeomativeAM::GetMaxLevelByEAmount(int iEAmount)
{
return 0;
}
@@ -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;
}
+362
View File
@@ -0,0 +1,362 @@
// MediumD.cpp: implementation of the CMediumD class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumD.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern BOOL DoEvent(HWND hWnd);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumD::CMediumD(int iAR): CMedium(iAR)
{
m_fEOffsetR = 0.5;
m_fLOffsetR = 0.5;
m_iParamIma = -1;
m_iParamImn = -1;
}
CMediumD::~CMediumD()
{
}
void CMediumD::SetParamVal(const void* pVal)
{
int* iParam = (int*)pVal;
if (iParam != NULL)
{
m_iParamIma = *iParam;
m_iParamImn = *(iParam + 1);
}
}
bool CMediumD::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
int iEqualValMove = (int)VAL_ZERO;
int iMaxSpace = (int)VAL_ZERO;
int iSpace = (int)VAL_ZERO;
int iTsn = (int)VAL_ZERO;
int iAVal = (int)VAL_ZERO;
int iMVal = (int)VAL_ZERO;
int iNVal = (int)VAL_ZERO;
int iMAVal = (int)VAL_ZERO;
int iMMVal = (int)VAL_ZERO;
int iMNVal = (int)VAL_ZERO;
int iMMove = (int)VAL_ZERO;
int iAMove = (int)VAL_ZERO;
int iTotalMove = (int)VAL_ZERO;
int iMaxLevel = (int)VAL_ZERO;
CSptRecord* pSptRecord = NULL;
CString str = _T("");
while ((iEAmount - iEqualValMove - 1) % 2)
{
iEqualValMove++;
}
//最大间距倍数imn,界面输入参数
iMaxSpace = m_iParamImn;
//iMaxSpace = (iEAmount - iEqualValMove -1) / 2;
iTotalMove = iEAmount - 2;
int a = 1;
int iMa = 0;
if (iTotalMove > m_iParamIma)
{
iMa = m_iParamIma;
}
else
{
iMa = iTotalMove;
}
//AMN装置
CString strLog;
int iTempMNVal = -1;
int iTempImn = -1;
int iLevel = 0;
strLog.Format(_T("AMN装置测点: A B M N level\n"));
OutputDebugString(strLog);
stLevel stlevel;
for (iMAVal = 1; iMAVal <= iTotalMove; iMAVal++)
{
iTempMNVal = -1;
for (a = 1; a <= m_iParamIma; a++)
{
for (iMMVal = iMAVal + 1; iMMVal <= 1 + iTotalMove; iMMVal++)
{
if (iTempMNVal != -1)
{
iMMVal = iTempMNVal;
}
iMNVal = iMMVal+a;
iTempImn = abs(iMAVal - iMMVal) / abs(iMMVal - iMNVal);
if ((iTempImn >m_iParamImn) || (iMNVal > iEAmount))
{
break;
}
iAVal = iMAVal;
iMVal = iMMVal;
iNVal = iMNVal;
iTempMNVal = iMNVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = -1;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iMVal - iAVal, iNVal - iAVal);
//计算层次
if (iAVal == 1)
{
iLevel++;
//层次
stlevel.level = iLevel;
//第几大层
stlevel.a = abs(iMVal - iNVal);
//第几小层
stlevel.n = 1.0*abs(iAVal - iMVal) / abs(iMVal - iNVal);
m_mapLevel[iLevel] = stlevel;
}
else
{
float n = 1.0*abs(iAVal - iMVal) / abs(iMVal - iNVal);
std::map<int, stLevel>::iterator iter = m_mapLevel.begin();
for (; iter != m_mapLevel.end(); iter++)
{
if (iter->second.n == n && iter->second.a == abs(iMVal - iNVal))
{
iLevel = iter->second.level;
break;
}
}
}
pSptRecord->m_iLevel = iLevel;//CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
strLog.Format(_T("AMN装置测点: %d %d %d %d %d\n"), iAVal, -1, iMVal, iNVal, pSptRecord->m_iLevel);
OutputDebugString(strLog);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
/*for (iMMVal = 2; iMMVal <= 1+iTotalMove; iMMVal++)
{
if (iMMVal <= (iMaxSpace + 1))
{
iMAVal = 1;
iSpace++;
}
else if ((iMMVal > (iMaxSpace + 1)) && (iMMVal <= ((iMaxSpace + 1)+iEqualValMove)))
{
iSpace = iMaxSpace;
iMAVal = iMMVal-iSpace;
}
else if (iMMVal > ((iMaxSpace + 1)+iEqualValMove))
{
if (iMNVal == iEAmount)
{
iSpace--;
}
iMAVal = iMMVal-iSpace;
}
iMNVal = iMMVal+iSpace;
iMBVal = -1;
iAVal = iMAVal;
iMVal = iMMVal;
iNVal = iMNVal;
iBVal = iMBVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iAVal, iMVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
iAMove = iMVal - iAVal;
while (iAMove > 1)
{
iAVal++;
iNVal--;
iBVal = -1;
iAMove--;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = -1;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iAVal, iMVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();*/
return true;
}
float CMediumD::CalculateSptKVal(int iAM, int iAN)
{
float fK = (float)VAL_ZERO;
fK = (float)(2*VAL_PI/(1.0/iAM-1.0/iAN));
return fK;
}
float CMediumD::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return 0.0;
}
int CMediumD::CalculateSptLevel(int iM, int iN)
{
return iN-iM;
}
void CMediumD::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
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);
if (iLevel > 1)
{
iOffsetL = (6 + 2)*iMul + 50 + 4 * iMul*(iLevel - 1) * 3 + (iMul - 2)-(iLevel-1)*8;
}
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));
iOffsetL = 46 + (6 + 2) * iMul * (pSptRecord->m_fSptXPos - 1) - 3 * iMul;
iOffsetR = iOffsetL + 6 * iMul;
pSptRecord->m_recPtArea.left = iOffsetL;
pSptRecord->m_recPtArea.right = iOffsetR;
pSptRecord->m_fPtCenterX = (float)(iOffsetL + iOffsetR) / 2;
}
int CMediumD::CalculateRecPosInlevel(int iA)
{
return iA;
}
int CMediumD::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return CalculateSptLevel(iM, iN);
}
int CMediumD::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
//AMN的点的位置选取的是MN的中点
return CalculateRecPosInlevel(iM);
}
int CMediumD::GetMaxLevelByEAmount(int iEAmount)
{
// if (((iEAmount%12) == 0) && (0 != iEAmount))
// {
// return 5+(iEAmount/12-1)*6;
// }
// return 0;
//根据排列来推算,假设最大层数为x,那么此时收个1+2x = iEAmount时,x即为最大层数
//由于x为整数,所以对此表达式取整即为最大层数
if (iEAmount > 0)
return (int)((iEAmount-1)/2);
else
return 0;
}
+484
View File
@@ -0,0 +1,484 @@
// MediumE.cpp: implementation of the CMediumE class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumE.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern BOOL DoEvent(HWND hWnd);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumE::CMediumE(int iAR): CMedium(iAR)
{
m_fEOffsetR = 0.5;
m_fLOffsetR = 0.5;
m_iParamIma = -1;
m_iParamImn = -1;
}
CMediumE::~CMediumE()
{
}
void CMediumE::SetParamVal(const void* pVal)
{
int* iParam = (int*)pVal;
if (iParam != NULL)
{
m_iParamIma = *iParam;
m_iParamImn = *(iParam + 1);
}
}
bool CMediumE::GenerateSptRecElecVal(int iEAmount, //锟界极锟斤拷锟斤拷---in
int* pMaxLevel, //锟斤拷锟斤拷---out
int* pPtAmount, //锟斤拷锟斤拷锟斤拷锟?--out
CPtrArray* pSptRecArray //锟脚憋拷锟斤拷录锟斤拷---out
) //锟斤拷锟斤拷锟杰o拷锟斤拷山疟锟斤拷缂拷锟铰硷拷锟斤拷锟?
{
int iEqualValMove = (int)VAL_ZERO;
int iMaxSpace = (int)VAL_ZERO;
int iSpace = (int)VAL_ZERO;
int iTsn = (int)VAL_ZERO;
int iAVal = (int)VAL_ZERO;
int iBVal = (int)VAL_ZERO;
int iMVal = (int)VAL_ZERO;
int iNVal = (int)VAL_ZERO;
int iMAVal = (int)VAL_ZERO;
int iMMVal = (int)VAL_ZERO;
int iMNVal = (int)VAL_ZERO;
int iMBVal = (int)VAL_ZERO;
int iMMove = (int)VAL_ZERO;
int iAMove = (int)VAL_ZERO;
int iTotalMove = (int)VAL_ZERO;
int iMaxLevel = (int)VAL_ZERO;
CSptRecord* pSptRecord = NULL;
CString str = _T("");
while ((iEAmount - iEqualValMove - 1) % 2)
{
iEqualValMove++;
}
//锟斤拷锟斤拷啾讹拷锟絠mn,锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟?
iMaxSpace = m_iParamImn;
//iMaxSpace = (iEAmount - iEqualValMove -1) / 2;
iTotalMove = iEAmount - 2;
int a = 1;
int iMa = 0;
if (iTotalMove > m_iParamIma)
{
iMa = m_iParamIma;
}
else
{
iMa = iTotalMove;
}
//AMN装锟斤拷
CString strLog;
iMBVal = -1;
int iTempMNVal = -1;
int iTempImn = -1;
int iLevel = 0;
int iLastA = 0;
int iCurA = 0;
int iMinLevel = 0;
stLevel_BMN stlevel;
strLog.Format(_T("MNB装置测点: A M N B level a n\n"));
OutputDebugString(strLog);
for (iMAVal = 1; iMAVal <= iTotalMove; iMAVal++)
{
iTempMNVal = -1;
for (a = 1; a <= m_iParamIma; a++)
{
for (iMMVal = iMAVal + 1; iMMVal <= 1 + iTotalMove; iMMVal++)
{
if (iTempMNVal != -1)
{
iMMVal = iTempMNVal;
}
iMNVal = iMMVal + a;
iTempImn = abs(iMAVal - iMMVal) / abs(iMMVal - iMNVal);
if ((iTempImn > m_iParamImn) || (iMNVal > iEAmount))
{
break;
}
iAVal = iMBVal;
iMVal = iEAmount + 1 - iMMVal;
iNVal = iEAmount + 1 - iMNVal;
iBVal = iEAmount + 1 - iMAVal;
iTempMNVal = iMNVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iBVal - iMVal, iBVal - iNVal);
//计算层次
if (iBVal == iEAmount)
{
iMinLevel++;
iLevel++;
//层次
stlevel.level = iLevel;
//第几大层
stlevel.a = abs(iMVal - iNVal);
if (iLastA == 0)
{
iLastA = stlevel.a;
}
//第几小层
stlevel.n = iMinLevel;
if (stlevel.a != iLastA)
{
iMinLevel = 1;
stlevel.n = iMinLevel;
iLastA = stlevel.a;
}
stlevel.fNValue = 1.0*abs(iBVal - iNVal) / abs(iMVal - iNVal);
m_mapLevel[iLevel] = stlevel;
}
else
{
float n = 1.0*abs(iBVal - iNVal) / abs(iMVal - iNVal);
std::map<int, stLevel_BMN>::iterator iter = m_mapLevel.begin();
for (; iter != m_mapLevel.end(); iter++)
{
if (iter->second.fNValue == n && iter->second.a == abs(iMVal - iNVal))
{
stlevel.a = iter->second.a;
stlevel.n = iter->second.n;
stlevel.level = iter->second.level;
break;
}
}
}
pSptRecord->m_a = stlevel.a;
pSptRecord->m_n = stlevel.n;
pSptRecord->m_iLevel = stlevel.level;
pSptRecord->m_iPtNum = iMVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
strLog.Format(_T("BMN装置测点: %d %d %d %d %d %d %d\n"), iAVal, iBVal, iMVal, iNVal, pSptRecord->m_iLevel, pSptRecord->m_a, pSptRecord->m_n);
OutputDebugString(strLog);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
/*for (iMNVal = 2; iMNVal <= 1+iTotalMove; iMNVal++)
{
iMMVal = iMNVal-1;
iMBVal = iMNVal+1;
iMAVal = -1;
iMVal = iMMVal;
iNVal = iMNVal;
iBVal = iMBVal;
iAVal = iMAVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iMVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
if (iMNVal < (iMaxSpace+1))
{
iAMove = iMNVal-1;
}
else
{
iAMove = iEAmount-iMNVal;
}
while (iAMove > 1)
{
iAVal = -1;
iBVal++;
iMVal--;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
pSptRecord->m_iPtNum = iMVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
if (iMVal == 1 || iBVal == iEAmount)
{
break;
}
iAMove--;
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();*/
return true;
}
float CMediumE::CalculateSptKVal(int iBM, int iBN)
{
float fK = (float)VAL_ZERO;
fK = (float)(2*VAL_PI/(1.0/iBN-1.0/iBM));
return fK;
}
float CMediumE::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return 0.0;
}
int CMediumE::CalculateSptLevel(int iM, int iN)
{
return iN-iM;
}
void CMediumE::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
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 - 3) + (iMul - 2);
if (pSptRecord->m_a == 1)
{
if (iLevel > 1 )
{
iOffsetL = (6 + 2)*iMul + 50 + 4 * iMul*(pSptRecord->m_n - 3) + (iMul - 2) - (pSptRecord->m_n - 1) * 8;
}
}
else
{
if (pSptRecord->m_n == 1)
{
iOffsetL = (6 + 2)*iMul + 50 + 4 * iMul*(pSptRecord->m_n - 3) + (iMul - 2);
}
else
{
iOffsetL = (6 + 2)*iMul + 50 + 4 * iMul*(pSptRecord->m_n - 3) + (iMul - 2) + (pSptRecord->m_n - 1) * 8;
}
}
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));
iOffsetL = 46 + (6 + 2) * iMul * (pSptRecord->m_fSptXPos - 1) - 3 * iMul;
iOffsetR = iOffsetL + 6 * iMul;
pSptRecord->m_recPtArea.left = iOffsetL;
pSptRecord->m_recPtArea.right = iOffsetR;
pSptRecord->m_fPtCenterX = (float)(iOffsetL + iOffsetR) / 2;
}
int CMediumE::CalculateRecPosInlevel(int iM)
{
return iM;
}
int CMediumE::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return CalculateSptLevel(iM, iN);
}
int CMediumE::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return CalculateRecPosInlevel(iM);
}
int CMediumE::GetMaxLevelByEAmount(int iEAmount)
{
// if (((iEAmount%12) == 0) && (0 != iEAmount))
// {
// return 5+(iEAmount/12-1)*6;
// }
// return 0;
//根据排列来推算,假设最大层数为x,那么此时收个1+2x = iEAmount时,x即为最大层数
//由于x为整数,所以对此表达式取整即为最大层数
if (iEAmount > 0)
return (int)((iEAmount-1)/2);
else
return 0;
}
void CMediumE::ReSortPoint(CPtrArray *f_ptr)
{
CSptRecord* pSptRecord = NULL;
int nMidPos = 0; //第一层中点的起始位置
int nWidth = 0; //用于统计第一层有多少个测点
int *nPos = new int[f_ptr->GetSize()];
for (int n = 0;n < f_ptr->GetSize(); n++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(n);
if (pSptRecord->m_iLevel == 1)
{
nPos[nWidth] = pSptRecord->m_iTsn; //把对应的TSN保存在数组中方便取出
nWidth++;
}
}
nMidPos = ( nWidth / 2 ); //将测点分成2个部分进行测试,从上一个斜线方向开始测
int FirStart = 0;
int SecStart = 0;
int Sum = 1; //tsn从1开始
FirStart = 0; //第一部分的起点位置
SecStart = nPos[nMidPos]; //第二部分的起点位置
CSptRecord *pTmp;
while(Sum < f_ptr->GetSize())
{
for (FirStart; FirStart < nPos[nMidPos] - 1; )
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(FirStart);
pTmp = (CSptRecord *)f_ptr->GetAt(FirStart + 1);
pSptRecord->m_iTsn = Sum;
Sum++;
FirStart++;
if (pSptRecord->m_iLevel >= pTmp->m_iLevel)
break;
}
for (SecStart; SecStart < f_ptr->GetSize(); )
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(SecStart - 1); //索引要减1
pTmp = (CSptRecord *)f_ptr->GetAt(SecStart);
pSptRecord->m_iTsn = Sum;
Sum++;
SecStart++;
if (pSptRecord->m_iLevel >= pTmp->m_iLevel)
break;
}
}
//对数组中的元素全部重新进行排序
for (int k = 0; k < f_ptr->GetSize(); k++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(k);
if (pSptRecord->m_iTsn != k + 1)
{
for (int n = k + 1; n < f_ptr->GetSize(); n++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(n);
if (pSptRecord->m_iTsn == k + 1)
{
f_ptr->InsertAt(k, pSptRecord);
f_ptr->RemoveAt(n + 1); //上一行代码插入一个元素,故 + 1;
break;
}
}
}
}
}
@@ -0,0 +1,181 @@
// MediumEdgeGradient.cpp: implementation of the CMediumEdgeGradient class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumEdgeGradient.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern int g_iUILanguage;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumEdgeGradient::CMediumEdgeGradient(int iAR): CMedium(iAR)
{
}
CMediumEdgeGradient::~CMediumEdgeGradient()
{
}
bool CMediumEdgeGradient::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
{
if (iEAmount < 4)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("Edge Gradient中EA_MOUNT的个数是错误的!"));
else
MessageBoxEx(NULL, _T("The number of EA_MOUNT in Edge Gradient 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();
//装置的位置顺序为AMNB
int iC1Pos = 1, iC2Pos = 4,iP1Pos = 2,iP2Pos = 3;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
//此时固定A的位置不动,B点向右移动,然后M从2开始往右移动,MN的间距始终为1
while(iC2Pos <= iEAmount)
{
iP1Pos = 2;
iP2Pos = iP1Pos + 1;
while(iP2Pos <= iC2Pos-1)
{
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);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// 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);
iP1Pos++;
iP2Pos = iP1Pos+1;
}
iC2Pos++;
}
//此时将B不动,A开始移动
iC2Pos = iEAmount;
iC1Pos = 2;
while(TRUE)
{
iP1Pos = iC1Pos + 1;
iP2Pos = iP1Pos + 1;
if (iP2Pos >= iC2Pos)
{
break;
}
//开始将M,N循环向右移动
while(iP2Pos <= iC2Pos-1)
{
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);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// 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);
iP1Pos++;
iP2Pos = iP1Pos+1;
}
iC1Pos++;
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = iEAmount-1;
return true;
}
float CMediumEdgeGradient::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fAM = fabs(fX - fA);
float fAN = fabs(fY - fA);
float fBM = fabs(fB - fX);
float fBN = fabs(fB - fY);
if (0 == fAM || 0 ==fAN || 0 == fBM || 0 == fBN)
{
return 0;
// AfxMessageBox(_T("Calcualte K value error.value = "))
}
return fabs(2*VAL_PI/(1.0/fAM - 1.0/fAN - 1.0/fBM + 1.0/fBN));
}
int CMediumEdgeGradient::GetMaxLevelByEAmount(int iEAmount)
{
if (iEAmount < 4)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("Edge Gradient中EA_MOUNT的个数是错误的!"));
else
MessageBoxEx(NULL, _T("The number of EA_MOUNT in Edge Gradient is error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return 0;
}
int iC1Pos = 1, iC2Pos = 4,iP1Pos = 2,iP2Pos = 3;
int iCnt = 0;
//此时固定A的位置不动,B点向右移动,然后M从2开始往右移动,MN的间距始终为1
while(iC2Pos <= iEAmount)
{
iP1Pos = 2;
iP2Pos = iP1Pos + 1;
while(iP2Pos <= iC2Pos-1)
{
iCnt++;
iP1Pos++;
iP2Pos = iP1Pos+1;
}
iC2Pos++;
}
//此时将B不动,A开始移动
iC2Pos = iEAmount;
iC1Pos = 2;
while(TRUE)
{
iP1Pos = iC1Pos + 1;
iP2Pos = iP1Pos + 1;
if (iP2Pos >= iC2Pos)
{
break;
}
//开始将M,N循环向右移动
while(iP2Pos <= iC2Pos-1)
{
iCnt++;
iP1Pos++;
iP2Pos = iP1Pos+1;
}
iC1Pos++;
}
return iCnt;
}
+807
View File
@@ -0,0 +1,807 @@
// MediumK.cpp: implementation of the CMediumK class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumK.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
typedef struct ST_LAYER_ORDER_INDEX
{
int iLayer;
std::vector<int> vtIndex;
ST_LAYER_ORDER_INDEX()
{
iLayer = 0;
vtIndex.clear();
}
}STlayerOrderIndex;
extern int g_iUILanguage;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumK::CMediumK(int iAR): CMedium(iAR)
{
m_fEOffsetR = 1;
m_fLOffsetR = 1;
m_iMNCtrlMethod = 0;
m_iMNSpace = 1;
}
CMediumK::~CMediumK()
{
}
bool CMediumK::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
if (iEAmount < 1)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("Schlumberger中EA_MOUNT的数目为错误!"));
else
MessageBoxEx(NULL, _T("The number of EA_MOUNT in Schlumberger 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;
}
if (1 == m_iMNCtrlMethod)
{
return GenerateSptRecElecVal_New(iEAmount, pMaxLevel, pPtAmount, pSptRecArray);
}
int iEqualValMove = (int)VAL_ZERO;
int iMaxSpace = (int)VAL_ZERO;
int iSpace = (int)VAL_ZERO;
int iTsn = (int)VAL_ZERO;
int iAVal = (int)VAL_ZERO;
int iBVal = (int)VAL_ZERO;
int iMVal = (int)VAL_ZERO;
int iNVal = (int)VAL_ZERO;
int iMAVal = (int)VAL_ZERO;
int iMMVal = (int)VAL_ZERO;
int iMNVal = (int)VAL_ZERO;
int iMBVal = (int)VAL_ZERO;
int iMMove = (int)VAL_ZERO;
int iAMove = (int)VAL_ZERO;
int iTotalMove = (int)VAL_ZERO;
int iMaxLevel = (int)VAL_ZERO;
CSptRecord* pSptRecord = NULL;
CString str = _T("");
iTotalMove = iEAmount / 2;
for (iMMVal = 2; iMMVal <= iTotalMove; iMMVal++)
{
iMAVal = 1;
iMNVal= iMMVal + m_iMNSpace;
iMBVal = iMNVal + iMMVal - iMAVal;
if (iMBVal > iEAmount)
{
break;
}
iAVal = iMAVal;
iMVal = iMMVal;
iNVal = iMNVal;
iBVal = iMBVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iAVal, iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iAVal, iMVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
while (iBVal < iEAmount)
{
iAVal++;
iNVal++;
iBVal++;
iMVal++;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iAVal;
pSptRecord->m_iC2 = iBVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iAVal, iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iAVal, iMVal);
pSptRecord->m_iPtNum = iAVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
return true;
}
float CMediumK::CalculateSptKVal(int iA, int iM, int iN)
{
float fK = (float)VAL_ZERO;
float fSpace = (float)VAL_ZERO;
fSpace = (iM-iA)*1.0/(iN-iM);
fK = (float)VAL_PI*fSpace*(fSpace+1)*(iN-iM);
return fK;
}
float CMediumK::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return 0.0;
}
int CMediumK::CalculateSptLevel(int iA, int iM)
{
return iM-iA;
}
void CMediumK::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
int iOffsetL = (int)VAL_ZERO;
int iOffsetR = (int)VAL_ZERO;
int iLevel = pSptRecord->m_iLevel;
int iPtNum = pSptRecord->m_iPtNum;
int iMN = pSptRecord->m_iP2 - pSptRecord->m_iP1;
//Auto模式
if (m_iIsolationLayers > 0)
iOffsetL = (6 + 2)*iMul + 50 + 4 * iMul*(iLevel - 1 - (iLevel-1)/m_iIsolationLayers) * 2 + (iMul - 2) + ((iMN - 1) / 2)*(6 + 2)*iMul;
//Fixed模式
else
iOffsetL = (6 + 2)*iMul + 50 + 4 * iMul*(iLevel - 1) * 2 + (iMul - 2) + ((iMN - 1) / 2)*(6 + 2)*iMul;
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 CMediumK::CalculateRecPosInlevel(int iA)
{
return iA;
}
int CMediumK::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return CalculateSptLevel(iA, iM);
}
int CMediumK::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return CalculateRecPosInlevel(iA);
}
int CMediumK::GetMaxLevelByEAmount(int iEAmount)
{
if (1 == m_iMNCtrlMethod)
{
int iC1Pos,iC2Pos,iP1Pos,iP2Pos;
int iLayer = 0;
//AM的距离就是层数,MN的距离每隔6层增加 2个电极间距
while(TRUE)
{
iLayer++;
iC1Pos = 1;
iP1Pos = iC1Pos + iLayer;
iP2Pos = iP1Pos + 1 + ((iLayer-1)/6)*2;
iC2Pos = iP2Pos + iLayer ;
if (iC2Pos > iEAmount)
{
break;
}
}
return iLayer - 1;
}
// if (((iEAmount%12) == 0) && (0 != iEAmount))
// {
// return 5+(iEAmount/12-1)*6;
// }
// return 0;
//根据排列来推算,假设最大层数为x,那么此时收个1+x+1+x = iEAmount时,x即为最大层数
//由于x为整数,所以对此表达式取整即为最大层数
if (iEAmount > 0)
return (int)((iEAmount-2)/2);
else
return 0;
}
void CMediumK::ReSortPoint(CPtrArray *f_ptr)
{
//在同一层内,取中点作为间隔点,左右两边分别跑跑,跑完后在取中间点
//例如总共有5个点时,序号分别为1-5,此时的跑极顺序为1,4,2,5,3
//在不同层时,按照层数的从小到大进行跑极
CSptRecord *pSptRecord = NULL;
CSptRecord *pTmp = NULL;
int iMaxLevel = ((CSptRecord *)(f_ptr->GetAt(f_ptr->GetSize()-1)))->m_iLevel;
if (0 == iMaxLevel)
{
return;
}
int nPreCnt = 0;
std::vector<STlayerOrderIndex> vtLayerOrderInfo;
vtLayerOrderInfo.clear();
int i = 1;
for (; i <= iMaxLevel; i++)
{
int nCurLayerCnt = 0;
for (int j = nPreCnt; j < f_ptr->GetSize(); j++)
{
pTmp = (CSptRecord*)(f_ptr->GetAt(j));
if (i == pTmp->m_iLevel)
{
nCurLayerCnt++;
}
else
break;
}
//首先进行每一层的从中间依次往左右的排序
STlayerOrderIndex stLayerOrder;
stLayerOrder.iLayer = 1;
stLayerOrder.vtIndex.clear();
bool bIsOdd = (nCurLayerCnt %2 == 0) ? false : true;
int iMidIndex = 0;
if (bIsOdd)
{
iMidIndex = (nCurLayerCnt+1)/2;
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-1);
for (int iIndex = 1; iIndex <iMidIndex; iIndex++)
{
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-iIndex-1);
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex+iIndex-1);
}
}
else
{
iMidIndex = nCurLayerCnt/2;
for (int iIndex = 1; iIndex <= iMidIndex; iIndex++)
{
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex-(iIndex-1)-1);
stLayerOrder.vtIndex.push_back(nPreCnt+iMidIndex+iIndex-1);
}
}
vtLayerOrderInfo.push_back(stLayerOrder);
nPreCnt += nCurLayerCnt;
}
CPtrArray newPtArr;
newPtArr.RemoveAll();
int iMaxIndex = vtLayerOrderInfo[0].vtIndex.size();
//然后将每次排好序的序号根据层从小到大从每层选取一个排好序的点加入到新的链表中,直到取完每层所有的点
for (int iIndex = 0; iIndex < iMaxIndex; iIndex++)
{
for (i = 1; i <= iMaxLevel; i++)
{
int iSize = vtLayerOrderInfo[i-1].vtIndex.size()-1;
if (iIndex > iSize)
{
continue;
}
int iOrderIndex = vtLayerOrderInfo[i-1].vtIndex[iIndex];
pSptRecord = (CSptRecord*)f_ptr->GetAt(iOrderIndex);
newPtArr.Add(pSptRecord);
}
}
if (newPtArr.GetSize() != f_ptr->GetSize())
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("数据重排错误!"));
else
MessageBoxEx(NULL, _T("Resort data error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
f_ptr->RemoveAll();
int iTsn = 0;
for (int k = 0; k < newPtArr.GetSize(); k++)
{
pSptRecord = (CSptRecord*)newPtArr.GetAt(k);
pSptRecord->m_iTsn = ++iTsn;
f_ptr->Add(pSptRecord);
}
}
/*
void CMediumK::ReSortPoint(CPtrArray *f_ptr)
{
//在同一层内,取中点作为间隔点,左右两边分别跑跑,跑完后在取中间点
//例如总共有5个点时,序号分别为1-5,此时的跑极顺序为1,4,2,5,3
//在不同层时,按照层数的从小到大进行跑极
CSptRecord *pSptRecord = NULL;
CSptRecord *pTmp = NULL;
CPtrArray newPtArr;
newPtArr.RemoveAll();
int iMaxLevel = ((CSptRecord *)(f_ptr->GetAt(f_ptr->GetSize()-1)))->m_iLevel;
if (0 == iMaxLevel)
{
return;
}
int nPreCnt = 0;
for (int i = 1; i <= iMaxLevel; i++)
{
int nCurLayerCnt = 0;
for (int j = nPreCnt; j < f_ptr->GetSize(); j++)
{
pTmp = (CSptRecord*)(f_ptr->GetAt(j));
if (i == pTmp->m_iLevel)
{
nCurLayerCnt++;
}
else
break;
}
bool bIsOdd = (nCurLayerCnt %2 == 0) ? false : true;
int iMidIndex = (nCurLayerCnt+1)/2;
int iMidDataCnt = (bIsOdd == true) ? iMidIndex : iMidIndex+1;
for (int iIndex = 1; iIndex <iMidDataCnt; iIndex++)
{
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iIndex-1));
newPtArr.Add(pSptRecord);
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iIndex+iMidIndex-1));
newPtArr.Add(pSptRecord);
}
//如果是奇数的话,则需要加上中间的点
if (bIsOdd)
{
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iMidIndex-1));
newPtArr.Add(pSptRecord);
}
nPreCnt += nCurLayerCnt;
}
if (newPtArr.GetSize() != f_ptr->GetSize())
{
AfxMessageBox(_T("resort data error!"));
return;
}
f_ptr->RemoveAll();
for (int k = 0; k < newPtArr.GetSize(); k++)
{
pSptRecord = (CSptRecord*)newPtArr.GetAt(k);
pSptRecord->m_iTsn = k+1;
f_ptr->Add(pSptRecord);
}
}
void CMediumK::ReSortPoint(CPtrArray *f_ptr)
{
// 1、每层,间隔3个点进行测试,测试完成后返回到前面未测试的点,再继续间隔三个点进行测试。本层测试完成后,再测试下一层。
// 2、当某层的点数,少于7个点时。先测两边的点,再测试中间的点。逐渐往中间靠拢。
CSptRecord *pSptRecord = NULL;
CSptRecord *pTmp = NULL;
CPtrArray newPtArr;
newPtArr.RemoveAll();
int iMaxLevel = ((CSptRecord *)(f_ptr->GetAt(f_ptr->GetSize()-1)))->m_iLevel;
if (0 == iMaxLevel)
{
return;
}
int nPreCnt = 0;
for (int i = 1; i <= iMaxLevel; i++)
{
int nCurLayerCnt = 0;
for (int j = nPreCnt; j < f_ptr->GetSize(); j++)
{
pTmp = (CSptRecord*)(f_ptr->GetAt(j));
if (i == pTmp->m_iLevel)
{
nCurLayerCnt++;
}
else
break;
}
//如果小于7个点,则从两端靠近
//int nTmpTsn = 0;
if (nCurLayerCnt < 7)
{
int nCnt = (nCurLayerCnt+1)/2;
for (int iIndex = 1; iIndex <= nCnt; iIndex++)
{
if (iIndex == nCnt)
{
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iIndex-1));
newPtArr.Add(pSptRecord);
//pSptRecord->m_iTsn = nPreCnt + (++nTmpTsn);
break;
}
else
{
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iIndex-1));
newPtArr.Add(pSptRecord);
//pSptRecord->m_iTsn = nPreCnt + (++nTmpTsn);
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+nCurLayerCnt-iIndex));
newPtArr.Add(pSptRecord);
//pSptRecord->m_iTsn = nPreCnt + (++nTmpTsn);
}
}
}
else
{
for (int iIndex = 1; iIndex <= 4; iIndex++)
{
int iTmpIndex = iIndex;
while(iTmpIndex <= nCurLayerCnt)
{
pSptRecord = (CSptRecord*)(f_ptr->GetAt(nPreCnt+iTmpIndex-1));
newPtArr.Add(pSptRecord);
// pSptRecord->m_iTsn = nPreCnt + (++nTmpTsn);
iTmpIndex += 4;
}
}
}
nPreCnt += nCurLayerCnt;
}
if (newPtArr.GetSize() != f_ptr->GetSize())
{
AfxMessageBox(_T("resort data error!"));
return;
}
f_ptr->RemoveAll();
for (int k = 0; k < newPtArr.GetSize(); k++)
{
pSptRecord = (CSptRecord*)newPtArr.GetAt(k);
pSptRecord->m_iTsn = k+1;
f_ptr->Add(pSptRecord);
}
}
void CMediumK::ReSortPoint(CPtrArray *f_ptr)
{
CSptRecord *pSptRecord = NULL;
CSptRecord *pTmp = NULL;
int nTsn = 1;
int nStart = 0;
int nWidth = 0;
int nId = 0; //取得每一个元素
int nId_two = 0; //记录算法需要取得的测点序号
int nId_thr = 0; //记录算法循环的次数
for (nId = 0; nId < f_ptr->GetSize(); nId++)
{
pSptRecord = (CSptRecord*)f_ptr->GetAt(nId);
if (nId + 1 < f_ptr->GetSize())
{
pTmp = (CSptRecord*)f_ptr->GetAt(nId + 1);
}
else
{
//最后一个点不处理
continue;
}
nWidth++; //记录每行测点的数量
if (pSptRecord->m_iLevel != pTmp->m_iLevel)
{
nStart = nId - ( nWidth - 1 );//每一行的起点,nid索引为0起始
nTsn = nStart + 1; //TSN从每一行起点算起,nStart是索引
for (int n = 0; n < 3; n++)
{
nId_two = 0;
nId_thr = 0;
while(TRUE)
{
nId_two = n + 3 * nId_thr;
if (nId_two + 1 > nWidth) //索引跟宽度比较应该增加1
break;
pSptRecord = (CSptRecord*)f_ptr->GetAt(nId_two + nStart);
pSptRecord->m_iTsn = nTsn++;
nId_thr++;
}
}
//对数组中的元素全部重新进行排序
for (nStart; nStart < nId; nStart++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(nStart);
if (pSptRecord->m_iTsn != nStart + 1)
{
for (int n = nStart + 1; n < f_ptr->GetSize(); n++)
{
pSptRecord = (CSptRecord *)f_ptr->GetAt(n);
if (pSptRecord->m_iTsn == nStart + 1)
{
f_ptr->InsertAt(nStart, pSptRecord);
f_ptr->RemoveAt(n + 1); //上一行代码插入一个元素,故 + 1;
break;
}
}
}
}
nWidth = 0; //置0,记录下一行测点的数量
}
}
return;
}
*/
bool CMediumK::GenerateSptRecElecVal_New(int iEAmount,
int* pMaxLevel,
int* pPtAmount,
CPtrArray* pSptRecArray)
{
pSptRecArray->RemoveAll();
int iC1Pos,iC2Pos,iP1Pos,iP2Pos;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
int iLayer = 0;
int iSaveLastP1Pos = 0;
int iLayerGrowth = 0;
////////////////////modifyed by lsq 20160510//////////////////////////////////////////////////////
//AM的距离就是层数,MN的距离每隔6层增加 2个电极间距
CString strLog;
while(TRUE)
{
iLayer++;
//下一次开始计算
if ((iLayer > m_iIsolationLayers)
&& ((iLayer - 1) / m_iIsolationLayers != 0)
&& ((iLayer - 1) % m_iIsolationLayers == 0))//跳层
{
iC1Pos = 1;
iP1Pos = iSaveLastP1Pos;//当满足跳层时,AM等于上一个值.
}
else
{
iC1Pos = 1;
iLayerGrowth++;
iSaveLastP1Pos = iP1Pos = iC1Pos + iLayerGrowth;
}
iP2Pos = iP1Pos + 1 + ((iLayer - 1) / m_iIsolationLayers) * 2;
iC2Pos = iP2Pos + abs(iC1Pos - iP1Pos);//B = AM+N
if (iC2Pos > iEAmount)
{
break;
}
strLog.Format(_T("zm:Layer=%d,第一个点数据 A=%d,M=%d,N=%d,B=%d,\n"), iLayer, iC1Pos, iP1Pos, iP2Pos, iC2Pos);
OutputDebugString(strLog);
//确定好每一层的电极初始位置之后,开始横向往右测量,此时每测一次,电极向右平移1
while(iC2Pos <= iEAmount)
{
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1Pos;
pSptRec->m_iC2 = iC2Pos;
pSptRec->m_iP1 = iP1Pos;
pSptRec->m_iP2 = iP2Pos;
pSptRec->m_fK = CalculateSptKVal(iC1Pos, iP1Pos, iP2Pos);
pSptRec->m_iPtNum = iC1Pos;
pSptRec->m_iLevel = iLayer;//GenSptRecLevel(iC1Pos, iC2Pos, iP1Pos, iP2Pos);
pSptRec->m_colorREF = RGB(0, 255, 0);
pSptRec->m_iN = 1;
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = ++iTsn;
CalculateSptPtLoc(2, pSptRec);
pSptRecArray->Add(pSptRec);
//strLog.Format(_T("zm:TSN=%d,Layer=%d数据 A=%d,M=%d,N=%d,B=%d,\n"), iTsn, iLayer, iC1Pos, iP1Pos, iP2Pos, iC2Pos);
//OutputDebugString(strLog);
iC1Pos++;
iC2Pos++;
iP1Pos++;
iP2Pos++;
}
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = iLayer-1;
return true;
}
void CMediumK::CalculateTdPtLoc(const CRect& vRect, const int& iEAmount, int& iMaxLevel, CRect& lRect, int& iSmWidth, int& iSmHeight, CPtrArray* pTdRecArray)
{
int iTop = 0;
int iBottom = 0;
int iLeft = 0;
int iRight = 0;
int iRectWidth = 0;
int iRectHeight = 0;
iSmWidth = 0;
iSmHeight = 0;
int iLevel = 0;
int iPos = 0;
int iIndex = 0;
int iEOffset = 0;
int iLOffset = 0;
m_iMNCtrlMethod = 0;
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
while (iIndex < pTdRecArray->GetSize())
{
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
if (1 < abs(pRsp2DTdRecord->m_iP2 - pRsp2DTdRecord->m_iP1))
{
m_iMNCtrlMethod = 1;
break;
}
iIndex++;
}
int iNewEAmount = iEAmount;
if (iEAmount%ELECTRODE_AMOUNT_PERCABLE != 0)
{
iNewEAmount =ELECTRODE_AMOUNT_PERCABLE * (1 + iEAmount/ELECTRODE_AMOUNT_PERCABLE);
}
iMaxLevel = this->GetMaxLevelByEAmount(iNewEAmount);
int iXEAmount = (m_iEndPole > m_iStartPole) ? m_iEndPole - m_iStartPole +1 : iEAmount;
lRect = vRect;
//已此时的CRect的中心移动边来缩小输入的rect的大小
lRect.DeflateRect(141, 40, 61, 40);
//返回大于或者等于指定表达式的最小整数,value 如果有小数部分则进一位
//iEAmount为电极的个数,非测点总数,第一层的测点数是最接近电极数的,在倒三角的剖面中
iSmWidth = (int)ceil(lRect.Width()*1.0/iXEAmount);
// float fCellHeight = lRect.Height()*1.0/iMaxLevel;
// iSmHeight = lRect.Height()/iMaxLevel;
// if (fCellHeight - iSmHeight > 0.8)
// {
// iSmHeight++;
// }
iSmHeight = (int)ceil(lRect.Height()*1.0/iMaxLevel);
//将iSmWidth变成奇数,那么iSmWidth-1此时将成为偶数,再用它去乘以任何数也都将是偶数
if (fmod((double)iSmWidth, 2.0) == 0.0)
{
iSmWidth++;
}
//由于极端的AM装置中,那么在第一层的最后一个位置,此时AM的点的坐标将会超过X轴的坐标系,
//所以此时要留有一个装置的余量
iRectWidth = iSmWidth+(iSmWidth-1)*(iXEAmount-1);
//iRectWidth = iSmWidth+(iSmWidth-1)*(iEAmount-2);
if (fmod((double)iSmHeight, 2.0) == 0.0)
{
iSmHeight++;
}
iRectHeight = iSmHeight+(iSmHeight-1)*(iMaxLevel-1);
if (fmod(lRect.Width()-iRectWidth, 2.0) == 0.0)
{
iLeft = (lRect.Width()-iRectWidth)/2;
iRight = (lRect.Width()-iRectWidth)/2;
}
else
{
iLeft = (lRect.Width()-iRectWidth)/2+1;
iRight = (lRect.Width()-iRectWidth)/2;
}
if (fmod(lRect.Height()-iRectHeight, 2.0) == 0.0)
{
iTop = (lRect.Height()-iRectHeight)/2;
iBottom = (lRect.Height()-iRectHeight)/2;
}
else
{
iTop = (lRect.Height()-iRectHeight)/2+1;
iBottom = (lRect.Height()-iRectHeight)/2;
}
lRect.DeflateRect(iLeft, iTop, iRight, iBottom);
pRsp2DTdRecord = NULL;
//iLOffset和iEOffset用来计算中间点和测点之间的偏差
//比如AMN模式中,点在MN的中点位置,此时m_iPosInLevel取得是M点的位置,
//那么iLOffset和iEOffset则用来计算M和中点位置之间的偏差
iEOffset = (int)((iSmWidth-1)*m_fEOffsetR);
iLOffset = (int)((iSmWidth-1)*m_fLOffsetR);
iIndex = 0;
while (iIndex < pTdRecArray->GetSize())
{
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
iLevel = pRsp2DTdRecord->m_iLevel-1;
int iMN = abs(pRsp2DTdRecord->m_iP2 - pRsp2DTdRecord->m_iP1);
iPos = pRsp2DTdRecord->m_iPosInLevel-1 -m_iStartPole + 1;
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
pRsp2DTdRecord->m_recPtArea.SetRect(lRect.left+iEOffset+iLOffset*iLevel+(iSmWidth-1)*(iPos+(iMN-1)/2), lRect.top+(iSmHeight-1)*iLevel,
lRect.left+iEOffset+iLOffset*iLevel+(iSmWidth-1)*(iPos+(iMN-1)/2)+iSmWidth, lRect.top+(iSmHeight-1)*iLevel+iSmHeight-1);
iIndex++;
}
}
@@ -0,0 +1,182 @@
// MediumLogging.cpp: implementation of the CMediumLogging class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumLandfillAdjacent.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
//////////////////////////////////////////////////////////////////////
CMediumLandfillAdjacent::CMediumLandfillAdjacent(int iAR) : CMedium3D(iAR)
{
}
CMediumLandfillAdjacent::~CMediumLandfillAdjacent()
{
}
void CMediumLandfillAdjacent::SetParamVal(const void* pVal)
{
}
float CMediumLandfillAdjacent::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fAM = fabs(fX - fA);
float fAN = fabs(fY - fA);
float fBM = fabs(fB - fX);
float fBN = fabs(fB - fY);
if (0 == fAM || 0 == fAN || 0 == fBM || 0 == fBN)
{
return 0;
// AfxMessageBox(_T("Calcualte K value error.value = "))
}
return fabs(2 * VAL_PI / (1.0 / fAM - 1.0 / fAN - 1.0 / fBM + 1.0 / fBN));
}
bool CMediumLandfillAdjacent::GenerateSptRecElecVal3D(int nSplittedNum, CScript3D *pScript, 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;
}
int Id = 0;
//m_PointNum的大小是128,可查看其定义
memset(pScript->m_PointNum, 0, sizeof(pScript->m_PointNum));
pSptRecArray->RemoveAll();
m_iXGridSzie = m_rect.x1 - m_rect.x0 + 1;
m_iYGridSize = m_rect.y1 - m_rect.y0 + 1;
int iStartIndex = 0;
int iChangeParam = 0;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
//按照Y轴进行X轴的跑极
CString strLog;
int i, j, k;
vector<vector<int>> vecElecNum;
vector<int> vecX, vecLastX, vecNextX;
for (i = 0; i < m_iYGridSize; i++)
{
vecX.clear();
for (j = i*m_iXGridSzie + 1; j <= (i + 1)*m_iXGridSzie; j++)
{
strLog.Format(_T("j=%d,"), j);
OutputDebugString(strLog);
vecX.push_back(j);
}
OutputDebugString(_T("\n"));
vecElecNum.push_back(vecX);
}
int iC1 = 1, iC2 = m_iXGridSzie*m_iYGridSize + 1, iP1 = 0, iP2 = m_iXGridSzie*m_iYGridSize;
strLog.Format(_T("C2(B)=%d\n"), iC2);
OutputDebugString(strLog);
vecX.clear();
vecX = vecElecNum.at(0);
int iRawCount = vecElecNum.size();
int iColCount = vecX.size();
//根据AB两点依次上下组合MN点
for (j = 0; j < iRawCount; j = j++)
{
//strLog.Format(_T("\n\nC1(A)=%d\n"), iC1);
//OutputDebugString(strLog);
//第一行和最后一行,找到A的几个取值,根据A点找到N点,再依次遍历生成M点
//取偶数行
if (j % 2 == 1)
{
k = 0;
if (j == 1)
{
k = 1;
}
vecLastX = vecElecNum[j - 1];
vecX = vecElecNum[j];
vecNextX = vecElecNum[j + 1];
if (j + 1 >= iRawCount)
{
vecNextX.clear();
}
iColCount = vecX.size();
for (; k < iColCount - 1; k++)
{
iC1 = vecX[k];
iC2 = vecX[k + 1];
iP1 = vecLastX[k];
iP2 = vecLastX[k + 1];
strLog.Format(_T("C1=%d,C2=%d,P1=%d,P2=%d\n"), iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_fK = CalculateCESptKVal(iC1, iC2, iP1, iP2);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// pSptRec->m_iPtNum = iC1Pos;
pSptRec->m_iLevel = GenSptRecLevel(iC1, iC2, iP1, iP2);
pSptRec->m_colorREF = RGB(0, 255, 0);
pSptRec->m_iN = 1;
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = ++iTsn;
pSptRec->m_SubScriptIndex = Id;
pSptRecArray->Add(pSptRec);
(pScript->m_PointNum[Id])++;
//过滤最后一行的MN取值
if (vecNextX.size() > 0)
{
iC1 = vecX[k];
iC2 = vecX[k + 1];
iP1 = vecNextX[k];
iP2 = vecNextX[k + 1];
strLog.Format(_T("C1=%d,C2=%d,P1=%d,P2=%d\n"), iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_fK = CalculateCESptKVal(iC1, iC2, iP1, iP2);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// pSptRec->m_iPtNum = iC1Pos;
pSptRec->m_iLevel = GenSptRecLevel(iC1, iC2, iP1, iP2);
pSptRec->m_colorREF = RGB(0, 255, 0);
pSptRec->m_iN = 1;
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = ++iTsn;
pSptRec->m_SubScriptIndex = Id;
pSptRecArray->Add(pSptRec);
(pScript->m_PointNum[Id])++;
}
}
}
}
*pPtAmount = pSptRecArray->GetSize();
return true;
}
@@ -0,0 +1,172 @@
// MediumLogging.cpp: implementation of the CMediumLogging class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumLandfillDiagonally.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
//////////////////////////////////////////////////////////////////////
CMediumLandfillDiagonally::CMediumLandfillDiagonally(int iAR) : CMedium3D(iAR)
{
}
CMediumLandfillDiagonally::~CMediumLandfillDiagonally()
{
}
void CMediumLandfillDiagonally::SetParamVal(const void* pVal)
{
}
float CMediumLandfillDiagonally::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fAM = fabs(fX - fA);
float fAN = fabs(fY - fA);
float fBM = fabs(fB - fX);
float fBN = fabs(fB - fY);
if (0 == fAM || 0 == fAN || 0 == fBM || 0 == fBN)
{
return 0;
// AfxMessageBox(_T("Calcualte K value error.value = "))
}
return fabs(2 * VAL_PI / (1.0 / fAM - 1.0 / fAN - 1.0 / fBM + 1.0 / fBN));
}
bool CMediumLandfillDiagonally::GenerateSptRecElecVal3D(int nSplittedNum, CScript3D *pScript, 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;
}
int Id = 0;
//m_PointNum的大小是128,可查看其定义
memset(pScript->m_PointNum, 0, sizeof(pScript->m_PointNum));
pSptRecArray->RemoveAll();
m_iXGridSzie = m_rect.x1 - m_rect.x0 + 1;
m_iYGridSize = m_rect.y1 - m_rect.y0 + 1;
int iStartIndex = 0;
int iChangeParam = 0;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
//按照Y轴进行X轴的跑极
CString strLog;
int i, j, k;
vector<vector<int>> vecElecNum;
vector<int> vecX, vecLastX, vecNextX;
for (i = 0; i < m_iYGridSize; i++)
{
vecX.clear();
for (j = i*m_iXGridSzie + 1; j <= (i + 1)*m_iXGridSzie; j++)
{
strLog.Format(_T("j=%d,"), j);
OutputDebugString(strLog);
vecX.push_back(j);
}
OutputDebugString(_T("\n"));
vecElecNum.push_back(vecX);
}
int iC1 = 1, iC2 = m_iXGridSzie*m_iYGridSize + 1, iP1 = 0, iP2 = m_iXGridSzie*m_iYGridSize;
strLog.Format(_T("C2(B)=%d\n"), iC2);
OutputDebugString(strLog);
vecX.clear();
vecX = vecElecNum.at(0);
int iRawCount = vecElecNum.size();
int iColCount = vecX.size();
//大于24个电极,需要取中点
int iMidPoint = -1;
if (pScript->m_iEAmount > 24)
{
iMidPoint = m_iXGridSzie / 2;
}
//C1(A)取值
for (j = 0; j < iRawCount; j = j + iRawCount - 1)
{
strLog.Format(_T("\n\nC1(A)=%d\n"), iC1);
OutputDebugString(strLog);
//第一行和最后一行,找到A的几个取值,根据A点找到N点,再依次遍历生成M点
if (j == 0 || j == iRawCount - 1)
{
for (k = 0; k < iColCount; k++)
{
if (k == 0 || k == iColCount - 1 || k == iMidPoint)
{
if (k == iMidPoint)
{
vecX.clear();
vecX = vecElecNum[j];
iC1 = vecX[k - 1];
vecX.clear();
vecX = vecElecNum[iRawCount - 1 - j];
iP2 = vecX[k - 1];
}
else
{
vecX.clear();
vecX = vecElecNum[j];
iC1 = vecX[k];
vecX.clear();
vecX = vecElecNum[iRawCount - 1 - j];
iP2 = vecX[iColCount - 1 - k];
}
//P1(M)取值
for (i = 1; i < iC2; i++)
{
if (i == iC1 || i == iP2)
{
continue;
}
iP1 = i;
strLog.Format(_T("C1=%d,C2=%d,P1=%d,P2=%d\n"), iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_fK = CalculateCESptKVal(iC1, iC2, iP1, iP2);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// pSptRec->m_iPtNum = iC1Pos;
pSptRec->m_iLevel = GenSptRecLevel(iC1, iC2, iP1, iP2);
pSptRec->m_colorREF = RGB(0, 255, 0);
pSptRec->m_iN = 1;
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = ++iTsn;
pSptRec->m_SubScriptIndex = Id;
pSptRecArray->Add(pSptRec);
(pScript->m_PointNum[Id])++;
}
}
}
}
}
*pPtAmount = pSptRecArray->GetSize();
return true;
}
@@ -0,0 +1,148 @@
// 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;
}
@@ -0,0 +1,252 @@
// MediumMidGardientScan.cpp: implementation of the CMediumMidGardientScan class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumMidGardientScan.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern int g_iUILanguage;
CMediumMidGardientScan::CMediumMidGardientScan(int iAR)
{
m_scr = NULL;
m_fXPoleSpace = 0;
m_fYPoleSpace = 0;
m_iAR = iAR;
m_iStartPole = 1;
m_iEndPole = 1;
m_iXGridSzie = 0;
m_iYGridSize = 0;
}
CMediumMidGardientScan::~CMediumMidGardientScan()
{
}
bool CMediumMidGardientScan::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 iStartIndex = 0;
int iChangeParam = 0;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
m_iXGridSzie = m_rect.x1 - m_rect.x0 + 1;
m_iYGridSize = m_rect.y1 - m_rect.y0 + 1;
//按照Y轴进行X轴的跑极
for (int i = 0; i < m_iYGridSize; i++)
{
iStartIndex = i * m_iXGridSzie;
//奇数列和偶数列的电极编号是反序的
if (0 == i%2)
iChangeParam = 0;
else
iChangeParam = 1;
int iM = 0,iN = 0;
int iAdd = 0;
//按照从左到右将那些跑极,MN之间的距离最小从1开始
while(1)
{
iAdd++;
iM = iStartIndex + iAdd + iChangeParam*(m_iXGridSzie-2*iAdd+1);
if (0 == iChangeParam)
{
if (iM + 1 > iStartIndex + m_iXGridSzie)
break;
}
else
{
if (iM -1 <= iStartIndex)
break;
}
int iTmp = 0;
while(1)
{
iTmp++;
iN = iM + iTmp - 2 * iTmp * iChangeParam;
if (0 == iChangeParam)
{
if (iN > iStartIndex + m_iXGridSzie)
break;
}
else
{
if (iN <= iStartIndex)
break;
}
pSptRec = new CSptRecord();
pSptRec->m_iC1 = -1;
pSptRec->m_iC2 = -1;
pSptRec->m_iP1 = iM;
pSptRec->m_iP2 = iN;
pSptRec->m_fK = CalculateCESptKVal(i+1, i+1, iM, iN);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// pSptRec->m_iPtNum = iC1Pos;
pSptRec->m_iLevel = GenSptRecLevel(-1, -1, iM, iN);
pSptRec->m_colorREF = RGB(0, 255, 0);
pSptRec->m_iN = 1;
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = ++iTsn;
pSptRecArray->Add(pSptRec);
}
}
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = 0;
return true;
}
float CMediumMidGardientScan::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
//在这里还是以AB的中点作为中心点来构建坐标系
float fXAxisOffset = m_stMidGardientScan.fABSpace/2;
//先获取逻辑AB所在的侧线
int iYAxisOffset = (int)(m_stMidGardientScan.fAPosY/m_fYPoleSpace);
// float fTestLineXAxisOffset = (m_iXGridSzie-1)/2;
int iYGridIndex = (int)fA - 1;
float fYPosOffset = fabs(float(iYGridIndex - iYAxisOffset))*m_fYPoleSpace;
float fAPosX = -1 * fXAxisOffset;
float fBPosX = fXAxisOffset;
float fMPosX = 0, fNPosX = 0;
if (0 == iYGridIndex%2)
{
fMPosX = fAPosX + m_stMidGardientScan.fMinAMSpace + m_fXPoleSpace*(fX - iYGridIndex*m_iXGridSzie - 1);
fNPosX = fAPosX + m_stMidGardientScan.fMinAMSpace + m_fXPoleSpace*(fY - iYGridIndex*m_iXGridSzie - 1);
}
else
{
fMPosX = fAPosX + m_stMidGardientScan.fMinAMSpace + fabs(m_fXPoleSpace*(fX - (iYGridIndex+1)*m_iXGridSzie));
fNPosX = fAPosX + m_stMidGardientScan.fMinAMSpace + fabs(m_fXPoleSpace*(fY - (iYGridIndex+1)*m_iXGridSzie));
}
float fAM = sqrt(pow(fMPosX - fAPosX, 2) + pow(fYPosOffset,2));
float fAN = sqrt(pow(fNPosX - fAPosX, 2) + pow(fYPosOffset,2));
float fBM = sqrt(pow(fBPosX - fMPosX, 2) + pow(fYPosOffset,2));
float fBN = sqrt(pow(fBPosX - fNPosX, 2) + pow(fYPosOffset,2));
if (0 == fAM || 0 ==fAN)
{
return 0;
// AfxMessageBox(_T("Calcualte K value error.value = "))
}
return fabs(2*VAL_PI/(1.0/fAM - 1.0/fAN - 1.0/fBM + 1/fBN));
}
bool CMediumMidGardientScan::GenerateSptRecElecVal3D(int nSplittedNum, CScript3D *pScript, 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;
}
int Id = 0;
//m_PointNum的大小是128,可查看其定义
memset(pScript->m_PointNum, 0, sizeof(pScript->m_PointNum));
pSptRecArray->RemoveAll();
m_iXGridSzie = m_rect.x1 - m_rect.x0 + 1;
m_iYGridSize = m_rect.y1 - m_rect.y0 + 1;
int iStartIndex = 0;
int iChangeParam = 0;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
//按照Y轴进行X轴的跑极
for (int i = 0; i < m_iYGridSize; i++)
{
iStartIndex = i * m_iXGridSzie;
//奇数列和偶数列的电极编号是反序的
if (0 == i%2)
iChangeParam = 0;
else
iChangeParam = 1;
int iM = 0,iN = 0;
int iAdd = 0;
//按照从左到右将那些跑极,MN之间的距离最小从1开始
while(1)
{
iAdd++;
iM = iStartIndex + iAdd + iChangeParam*(m_iXGridSzie-2*iAdd+1);
if (0 == iChangeParam)
{
if (iM + 1 > iStartIndex + m_iXGridSzie)
break;
}
else
{
if (iM -1 <= iStartIndex)
break;
}
int iTmp = 0;
while(1)
{
iTmp++;
iN = iM + iTmp - 2 * iTmp * iChangeParam;
if (0 == iChangeParam)
{
if (iN > iStartIndex + m_iXGridSzie)
break;
}
else
{
if (iN <= iStartIndex)
break;
}
pSptRec = new CSptRecord();
pSptRec->m_iC1 = -1;
pSptRec->m_iC2 = -1;
pSptRec->m_iP1 = iM;
pSptRec->m_iP2 = iN;
pSptRec->m_fK = CalculateCESptKVal(i+1, i+1, iM, iN);
pSptRec->m_SubScriptIndex = Id;//记录这个测点属于哪个子脚本
pSptRec->m_iN = m_uiStackNumber;
pSptRec->m_iTsn = ++iTsn;
pSptRecArray->Add(pSptRec);
(pScript->m_PointNum[Id])++;
}
}
}
*pPtAmount = pSptRecArray->GetSize();
return true;
}
void CMediumMidGardientScan::SetParamVal(const void* pVal)
{
STMidGarScanParam* pParam = (STMidGarScanParam*)pVal;
m_stMidGardientScan.fABSpace = pParam->fABSpace;
m_stMidGardientScan.fAPosY = pParam->fAPosY;
m_stMidGardientScan.fMinAMSpace = pParam->fMinAMSpace;
}
@@ -0,0 +1,71 @@
// MediumQ.cpp: implementation of the CMediumQ class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumQ.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumQ::CMediumQ(int iAR): CMedium(iAR)
{
}
CMediumQ::~CMediumQ()
{
}
bool CMediumQ::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
return true;
}
void CMediumQ::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
return;
}
int CMediumQ::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumQ::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumQ::GetMaxLevelByEAmount(int iEAmount)
{
return (int)VAL_ZERO;
}
float CMediumQ::CalculateDepth(float fA, float fFactor)
{
return (float)((fabs(fA)/0.5)*fFactor);
}
float CMediumQ::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
fK = (float)(VAL_PI * (fA * fA - fB * fB) / (2 * fB));
return fabs(fK);
}
@@ -0,0 +1,71 @@
// MediumR.cpp: implementation of the CMediumR class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumR.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumR::CMediumR(int iAR): CMedium(iAR)
{
}
CMediumR::~CMediumR()
{
}
bool CMediumR::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
return true;
}
void CMediumR::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
return;
}
int CMediumR::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumR::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumR::GetMaxLevelByEAmount(int iEAmount)
{
return (int)VAL_ZERO;
}
float CMediumR::CalculateDepth(float fA, float fFactor)
{
// return (float)(fabs(fA)*fFactor);
return (float)((fabs(fA)/0.5)*fFactor);
}
float CMediumR::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
fK = (float)(VAL_PI * fB * ((fB * fB) /(fA * fA) - 1));
return fabs(fK);
}
@@ -0,0 +1,72 @@
// MediumS.cpp: implementation of the CMediumS class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumS.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumS::CMediumS(int iAR): CMedium(iAR)
{
}
CMediumS::~CMediumS()
{
}
bool CMediumS::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
return true;
}
void CMediumS::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
return;
}
int CMediumS::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumS::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumS::GetMaxLevelByEAmount(int iEAmount)
{
return (int)VAL_ZERO;
}
float CMediumS::CalculateDepth(float fA, float fFactor)
{
// return (float)(fabs(fB)+fabs(fA))*fFactor;
return (float)((fabs(fA)/0.5)*fFactor);
// return 0.0;
}
float CMediumS::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
fK = (float)(VAL_PI * (fA * fA - fB * fB) / fB);
return fabs(fK);
}
@@ -0,0 +1,215 @@
// MediumCustom2D.cpp: implementation of the CMediumCustom2D class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumS3P.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern int g_iUILanguage;
CMediumS3P::CMediumS3P(int iAR) : CMedium(iAR)
{
}
CMediumS3P::~CMediumS3P()
{
}
void CMediumS3P::SetParamVal(const void* pVal)
{
m_uiStartElecID = ((int*)pVal)[0];
m_uiMinN = ((int*)pVal)[1];
m_uiMaxN = ((int*)pVal)[2];
}
float CMediumS3P::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
//在这里也可以将K值的公司改成K=2*pai*n*(n+1)*a
//由于AM=MN=1,所以也可以换算成K=4*pai*a
fK = (float)(4 * VAL_PI*(fX - fA));
return fK;
}
int CMediumS3P::CalculateSptLevel(int iM, int iN)
{
return abs(iN - iM);
}
bool CMediumS3P::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();
CString strLog;
int iC1 = 0, iC2 = -1, iP1 = 0, iP2 = m_uiStartElecID;
int j, k;
int iIndex = 0;
CSptRecord* pSptRec = NULL;
//B无穷,取值固定
//N取值
for (int i = iP2; i < iEAmount - m_uiMaxN; i++)
{
//M取值
iP2 = i;
iP1 = iP2 + 1;
strLog.Format(_T("P2=%d,P1=%d\n"), iP2, iP1);
OutputDebugString(strLog);
//A取值从M之后一次遍历
//for (k = iP1 + m_uiMinN; k < iEAmount - m_uiMaxN; k++)
{
for (j = iP1 + m_uiMinN; (j <= iP1 + m_uiMaxN) && (j <= iEAmount); j++)
{
iC1 = j;
iIndex++;
strLog.Format(_T("iIndex=%d,N(P2)=%d,M(P1)=%d,A=%d\n"), iIndex, iP2, iP1, iC1, iC2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_fK = CalculateCESptKVal(iC1, iC2, iP1, iP2);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// pSptRec->m_iPtNum = iC1Pos;
pSptRec->m_iLevel = CalculateSptLevel(iP1, iP2);
pSptRec->m_colorREF = RGB(0, 255, 0);
pSptRec->m_iN = 1;
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = iIndex;
pSptRecArray->Add(pSptRec);
}
}
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = iEAmount - 1;
/*
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)
{
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);
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);
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);
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);
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);
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);
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);
if (iMaxLevel < pSptRec->m_iLevel)
{
iMaxLevel = pSptRec->m_iLevel;
}
pSptRec->m_bIsSel = TRUE;
//pSptRec->m_iPtNum = 0;
pSptRec->m_iTsn = ++iTsn;
pSptRecArray->Add(pSptRec);
}
pCustomSptDlg->DestroyWindow();
delete pCustomSptDlg;
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
return true;
}
else
return false;*/
}
@@ -0,0 +1,302 @@
// MediumStrongGradient.cpp: implementation of the CMediumStrongGradient class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumStrongGradient.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern int g_iUILanguage;
CMediumStrongGradient::CMediumStrongGradient(int iAR): CMedium(iAR)
{
}
CMediumStrongGradient::~CMediumStrongGradient()
{
}
void CMediumStrongGradient::SetParamVal(const void* pVal)
{
m_bStrongGradient = *(BYTE*)pVal;
}
float CMediumStrongGradient::CalculateSptKVal(int iM, int iN)
{
float fK = (float)VAL_ZERO;
fK = (float)(2 * VAL_PI*(iN - iM));
return fK;
}
float CMediumStrongGradient::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fAM = fabs(fX - fA);
float fAN = fabs(fY - fA);
float fBM = fabs(fB - fX);
float fBN = fabs(fB - fY);
if (0 == fAM || 0 == fAN || 0 == fBM || 0 == fBN)
{
return 0;
// AfxMessageBox(_T("Calcualte K value error.value = "))
}
return fabs(2 * VAL_PI / (1.0 / fAM - 1.0 / fAN - 1.0 / fBM + 1.0 / fBN));
}
int CMediumStrongGradient::CalculateSptLevel(int iM, int iN)
{
return iN - iM;
}
bool CMediumStrongGradient::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 i =0,j = 0;
int a = 1;
int iIndex = 0;
int iMaxLevel = 0;
const int iMaxA = 3; //a取值1~3
const int iFixedNValue = (iEAmount-1)/8; //n固定10
//const int iMaxS = 4;//S的意思是AB最多移動四次
const int iMaxS = 4;//S的意思是AB每次移动四个电极
CString strLog;
//只考虑a=1的情况即MN=1 P1P2=1
//OutputDebugString(_T("打印新装置测点\n"));
CSptRecord* pSptRec = NULL;
//int iC1 = 3, iC2 = 6, iP1 = 1, iP2 = 2;
int iC1 = 1, iC2 = 4, iP1 = 2, iP2 = 3;
int iTempC1 = iC1;
//strLog.Format(_T("\n\n----------------------iFixedNValue取值%d\n"), iFixedNValue);
//OutputDebugString(strLog);
//正序遍历
for (a = 1; a <= iMaxA; a++)
{
iC1 = iTempC1;//a值修改,第二轮巡
strLog.Format(_T("A点取值%d,a=%d\n"), iC1,a);
OutputDebugString(strLog);
for (iC2 = iC1 + (iFixedNValue + 2)*a; iC2 <= iEAmount;) //B点轮循环
{
strLog.Format(_T("B点取值iC1=%d,iC2=%d %d+(%d+2)*%d=%d\n"), iC1, iC2, iC1, iFixedNValue, a, (iFixedNValue + 2)*a);
OutputDebugString(strLog);
for (iP1 = 1; iP1 <= iEAmount - a; iP1++)
{
if ((iP1 + a) == iC2 || (iP1 + a) == iC1 || iP1 == iC1 || iP1 == iC2)
{
continue;
}
//MN均小于A点
if (iP1+a < iC1)
{
for (iP1 = 1; iP1 + a < iC1; iP1++)
{
iP2 = iP1 + a;
strLog.Format(_T("MN均小于A点index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_iN = 1;
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
if (iMaxLevel < pSptRec->m_iLevel)
{
iMaxLevel = pSptRec->m_iLevel;
}
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = iIndex;
pSptRecArray->Add(pSptRec);
}
}
//MN大于A点,小于B点
if (iP1 > iC1 && iP1 + a < iC2)
{
for (iP1 = iC1 + 1; iP1 < iC2 - a; iP1++)
{
iP2 = iP1 + a;
strLog.Format(_T("MN在AB之间index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_iN = 1;
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
if (iMaxLevel < pSptRec->m_iLevel)
{
iMaxLevel = pSptRec->m_iLevel;
}
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = iIndex;
pSptRecArray->Add(pSptRec);
}
}
//MN大于B点
if (iP1 > iC2)
{
for (iP1 = iC2 + 1; iP1 + a <= iEAmount; iP1++)
{
iP2 = iP1 + a;
strLog.Format(_T("MN大于B点index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_iN = 1;
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
if (iMaxLevel < pSptRec->m_iLevel)
{
iMaxLevel = pSptRec->m_iLevel;
}
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = iIndex;
pSptRecArray->Add(pSptRec);
}
}
}
//iC1 = iC1+iMaxS;//每次平移4个电极
iC1 = iC2;
iC2 = iC1 + (iFixedNValue + 2)*a;
}
}
//反序遍历
if (m_bStrongGradient != 0)
{
int iTempC2 = iC2 = iEAmount;
for (a = 1; a <= iMaxA; a++)
{
iC2 = iTempC2;//a值修改,第二轮巡
//strLog.Format(_T("A点取值%d,a=%d\n"), iC2, a);
//OutputDebugString(strLog);
for (iC1 = iC2 - (iFixedNValue + 2)*a; iC1 >= 1;)
{
//iTempSCount++;
//strLog.Format(_T("B点取值iC1=%d,iC2=%d %d+(%d+2)*%d=%d\n"), iC1, iC2, iC1, iFixedNValue, a, (iFixedNValue + 2)*a);
//OutputDebugString(strLog);
for (iP1 = iEAmount - a; iP1 >= 1; iP1--)
{
if ((iP1 - a) == iC2 || (iP1 - a) == iC1 || iP1 == iC1 || iP1 == iC2)
{
continue;
}
//MN均小于A点
if (iP1 + a < iC1)
{
for (iP1 = iC1 - 1 - a; iP1 >= 1; iP1--)
{
iP2 = iP1 + a;
strLog.Format(_T("MN均小于A点index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_iN = 1;
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
if (iMaxLevel < pSptRec->m_iLevel)
{
iMaxLevel = pSptRec->m_iLevel;
}
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = iIndex;
pSptRecArray->Add(pSptRec);
}
}
//MN大于A点,小于B点
if (iP1 > iC1 && iP1 + a < iC2)
{
for (iP1 = iC2 - a - 1; iP1 > iC1; iP1--)
{
iP2 = iP1 + a;
strLog.Format(_T("MN在AB之间index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_iN = 1;
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
if (iMaxLevel < pSptRec->m_iLevel)
{
iMaxLevel = pSptRec->m_iLevel;
}
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = iIndex;
pSptRecArray->Add(pSptRec);
}
}
//MN大于B点
if (iP1 > iC2)
{
for (iP1 = iEAmount - a; iP1 > iC2; iP1--)
{
iP2 = iP1 + a;
strLog.Format(_T("MN大于B点index=%d A=%d,B=%d,M=%d,N=%d\n"), ++iIndex, iC1, iC2, iP1, iP2);
OutputDebugString(strLog);
pSptRec = new CSptRecord();
pSptRec->m_iC1 = iC1;
pSptRec->m_iC2 = iC2;
pSptRec->m_iP1 = iP1;
pSptRec->m_iP2 = iP2;
pSptRec->m_iN = 1;
pSptRec->m_fK = CalculateCESptKVal(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_iLevel = 1;// CalculateSptLevel(pSptRec->m_iP1, pSptRec->m_iP2);
pSptRec->m_fSptXPos = GetUniSptXPos(pSptRec->m_iC1, pSptRec->m_iC2, pSptRec->m_iP1, pSptRec->m_iP2);
if (iMaxLevel < pSptRec->m_iLevel)
{
iMaxLevel = pSptRec->m_iLevel;
}
pSptRec->m_bIsSel = TRUE;
pSptRec->m_iTsn = iIndex;
pSptRecArray->Add(pSptRec);
}
}
}
//iC1 = iC1+iMaxS;//每次平移4个电极
iC2 = iC1;
iC1 = iC2 - (iFixedNValue + 2)*a;
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
}
@@ -0,0 +1,622 @@
// MediumWenAndSch.cpp: implementation of the CMediumStrongWenAndSch class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumStrongWenAndSch.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif
typedef struct ST_LAYER_ORDER_INDEX
{
int iLayer;
std::vector<int> vtIndex;
ST_LAYER_ORDER_INDEX()
{
iLayer = 0;
vtIndex.clear();
}
}STlayerOrderIndex;
extern int g_iUILanguage;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumStrongWenAndSch::CMediumStrongWenAndSch(int iAR) : CMedium(iAR)
{
m_fEOffsetR = 0.5;
m_fLOffsetR = 0;
}
CMediumStrongWenAndSch::~CMediumStrongWenAndSch()
{
}
int CMediumStrongWenAndSch::MOD(int x, int y)
{
long n;
int f;
if ((x == 0) || (y == 0))
{
return x;
}
f = x / y;
n = (long)f;
if (n>f)
{
n = n - 1;
}
f = x - n*y;
return f;
}
bool CMediumStrongWenAndSch::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
{
if (iEAmount < 1)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("Wenner_Schlumber中EA_MOUNT的数目是错误的!"));
else
MessageBoxEx(NULL, _T("The number of EA_MOUNT in Wenner_Schlumberger 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;
}
/*生成脚本之前需要得到所有层数的层数号(i, j),以及每一层的第一个装置。其中i为大层数,j为小层数。
便
1N3nBL_ nBL_ N个电极时i的取值为1到nBL_
2i8i大层中的总的小层数为[i / 2][]j的取值为1到[i / 2]i83, 4, 5
N = 20
203
3, 6, 9, 12, 15, 18nBL_ = 66
i->j
1 -> 1
2 -> 1
3 -> 2
4 -> 2
5 -> 3
6 -> 3
1 + 1 + 2 + 2 + 3 + 3 = 12
N = 65
653
3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63nBL_ = 2121
i->j
1 -> 1
2 -> 1
3 -> 2
4 -> 2
5 -> 3
6 -> 3
7 -> 4
8 -> 4
9 -> 3
10 -> 3
11 -> 3
12 -> 3
13 -> 4
14 -> 4
15 -> 4
16 -> 4
17 -> 5
18 -> 5
19 -> 5
20 -> 5
21 -> 3
a的奇偶性a的具体值
1i8a值从1和2开始2.
1 - 11 - 2 - 3 - 4 a = 1
2 - 11 - 3 - 5 - 7 a = 2
3 - 11 - 5 - 6 - 10 a = 1
3 - 21 - 4 - 7 - 10 a = 3
4 - 11 - 6 - 8 - 13 a = 2
4 - 21 - 5 - 9 - 13 a = 4
5 - 11 - 8 - 9 - 16 a = 1
5 - 21 - 7 - 10 - 16 a = 3
5 - 31 - 6 - 11 - 16 a = 5
6 - 11 - 9 - 11 - 19 a = 2
6 - 21 - 8 - 12 - 19 a = 4
6 - 31 - 7 - 13 - 19 a = 6
7 - 11 - 11 - 12 - 22 a = 1
7 - 21 - 10 - 13 - 22 a = 3
7 - 31 - 9 - 14 - 22 a = 5
7 - 41 - 8 - 15 - 22 a = 7
8 - 11 - 12 - 14 - 25 a = 2
8 - 21 - 11 - 15 - 25 a = 4
8 - 31 - 10 - 16 - 25 a = 6
8 - 41 - 9 - 17 - 25 a = 8
28i16a值从3和4开始4.
9 - 1 1 - 13 - 16 - 28 a = 3
9 - 2 1 - 11 - 18 - 28 a = 7
9 - 3 1 - 9 - 20 - 28 a = 11
10 - 11 - 14 - 18 - 31 a = 4
10 - 21 - 12 - 20 - 31 a = 8
10 - 31 - 10 - 22 - 31 a = 12
11 - 11 - 16 - 19 - 34 a = 3
11 - 21 - 14 - 21 - 34 a = 7
11 - 31 - 12 - 23 - 34 a = 11
12 - 11 - 17 - 21 - 37 a = 4
12 - 21 - 15 - 23 - 37 a = 8
12 - 31 - 13 - 25 - 37 a = 12
13 - 11 - 19 - 22 - 40 a = 3
13 - 21 - 17 - 24 - 40 a = 7
13 - 31 - 15 - 26 - 40 a = 11
13 - 41 - 13 - 28 - 40 a = 15
316i24a值从7和8开始4.
424i32a值从11和12开始6.
532i40a值从15和16开始8.
640i48a值从19和20开始8.
7i48a值从29和30开始12.*/
/////////////////////////使用新算法 by quyx 20190125//////////////////////////////////////////////////
pSptRecArray->RemoveAll();
int iC1Pos, iC2Pos, iP1Pos, iP2Pos;
int iXParam = 1;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
int iLayer = 0, iTailorLayer = 0;
//输入电极数目->计算小于等于N且可以被3整除的数
int nBL = 0;
for (int i = 1; i <= iEAmount; i++)
{
if (MOD(i, 3) == 0)
{
//res(j) = i;
nBL = nBL + 1;
}
}
int nSL[4096];
for (int i = 1; i <= nBL; i++)
{
if (i < 9)
nSL[i] = ceil(i / 2.0);
else
nSL[i] = ceil((i - 8) / 4.0) - 3 * (ceil((ceil((i - 8) / 4.0)) / 3.0) - 1) + 2;
}
//应用方案提供的Mablab公式
for (int i = 1; i <= nBL; i++)
{
for (int j = 1; j <= nSL[i]; j++)
{
if (i <= 8)
{
iC1Pos = 1;
iC2Pos = 3 * i + 1;
iP1Pos = floor((3 * i + 1) / 2) - j + 1;
iP2Pos = floor((3 * i + 1) / 2) - j + 1 + 2 - i % 2 + 2 * (j - 1);
}
else if (i > 8 & i <= 16)
{
iC1Pos = 1;
iC2Pos = 3 * i + 1;
iP1Pos = floor((3 * i + 1) / 2) - 2 * j + 2 - 1;
iP2Pos = floor((3 * i + 1) / 2) - 2 * j + 2 - 1 + 4 - i % 2 + 4 * (j - 1);
}
else if (i > 16 & i <= 24)
{
iC1Pos = 1;
iC2Pos = 3 * i + 1;
iP1Pos = floor((3 * i + 1) / 2) - 2 * j + 2 - 3;
iP2Pos = floor((3 * i + 1) / 2) - 2 * j + 2 - 3 + 8 - i % 2 + 4 * (j - 1);
}
else if (i > 24 & i <= 32)
{
iC1Pos = 1;
iC2Pos = 3 * i + 1;
iP1Pos = floor((3 * i + 1) / 2) - 3 * j + 3 - 5;
iP2Pos = floor((3 * i + 1) / 2) - 3 * j + 3 - 5 + 12 - i % 2 + 6 * (j - 1);
}
else if (i > 32 & i <= 40)
{
iC1Pos = 1;
iC2Pos = 3 * i + 1;
iP1Pos = floor((3 * i + 1) / 2) - 4 * j + 4 - 7;
iP2Pos = floor((3 * i + 1) / 2) - 4 * j + 4 - 7 + 16 - i % 2 + 8 * (j - 1);
}
else if (i > 40 & i <= 48)
{
iC1Pos = 1;
iC2Pos = 3 * i + 1;
iP1Pos = floor((3 * i + 1) / 2) - 5 * j + 5 - 9;
iP2Pos = floor((3 * i + 1) / 2) - 5 * j + 5 - 9 + 20 - i % 2 + 10 * (j - 1);
}
else if (i > 48)
{
iC1Pos = 1;
iC2Pos = 3 * i + 1;
iP1Pos = floor((3 * i + 1) / 2) - 6 * j + 6 - 14;
iP2Pos = floor((3 * i + 1) / 2) - 6 * j + 6 - 14 + 30 - i % 2 + 12 * (j - 1);
}
if (iC2Pos > iEAmount)
{
continue;
}
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 = iP1Pos + iXParam / 2;
pSptRec->m_iLevel = iLayer + 1; //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);
while (iC2Pos < 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 = iP1Pos + iXParam / 2;
pSptRec->m_iLevel = iLayer + 1; //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);
}
iLayer++;
}
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = iLayer;// -1;
return true;
////////////////////modifyed by lsq 20160510//////////////////////////////////////////////////////
//AM=BN,当AM间隔选择为5或者5的倍数时,此时的下一层点的MN间间距每隔五层增加2个电极点距(MN间间距按1、3、5、7…等间隔增加),
//并且AM的间隔会暂停增加一次,测量时,AM,NB间电极间距按隔离系数由小到大的顺序等间隔增加,
// 第一层时,A=#1M=#2 N=#3 B=#4 … → … A=#57M=#58N=#59B=#60
// 第二层时,A=#1M=#3 N=#4 B=#6 … → … A=#55M=#57N=#58B=#60
// 第三层时,A=#1M=#4 N=#5 B=#8 … → … A=#53M=#56N=#57B=#60
// 第四层时,A=#1M=#5 N=#6 B=#10 … → … A=#51M=#55N=#56B=#60
// 第五层时,A=#1M=#6 N=#7 B=#12 … → … A=#49M=#54N=#55B=#60
// 第六层时,A=#1 M=#6 N=#9 B=#14 … → … A=#47M=#52N=#55B=#60
// 第七层时,A=#1M=#7 N=#10B=#16 … → … A=#45M=#51N=#54B=#60
// 第八层时,A=#1M=#8 N=#11B=#18 … → … A=#43M=#50N=#53B=#60
// 第九层时,A=#1M=#9 N=#12B=#20 … → … A=#41M=#49N=#52B=#60
// 第十层时,A=#1M=#10N=#13B=#22 … → … A=#39M=#48N=#51B=#60
// 第十一层时,A=#1 M=#10N=#15B=#24 … → … A=#37M=#46N=#51B=#60
//while(TRUE)
//{
// iLayer++;
// //iTailorLayer = (iLayer-1)/5;
// iTailorLayer = (iLayer - 1) / 6; //使用新的算法6的间隔 by quyx 20180929
// iC1Pos = 1;
// iP1Pos = iC1Pos + iLayer - iTailorLayer;
// //iXParam = 1 + iTailorLayer*2;
// iXParam = 1 + iTailorLayer; //使用新的算法暂不跳跃 by quyx 20180929
// iP2Pos = iP1Pos + iXParam;
// iC2Pos = iP2Pos + iLayer - iTailorLayer;;
// if (iC2Pos > iEAmount)
// {
// break;
// }
// //确定好每一层的电极初始位置之后,开始横向往右测量,此时每测一次,电极向右平移1
// while(iC2Pos <= 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);
// //在这里这么计算是因为在修改规则之后,无法通过层数判断MN之间的间距,用这种计算方法,
// //由于iXParam为奇数,所以m_iPtNum的位置距离MN真实中点的位置只差0.5个电极间距
// pSptRec->m_iPtNum = iP1Pos + iXParam/2;
// 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++;
// iC2Pos++;
// iP1Pos++;
// iP2Pos++;
// }
//}
//*pPtAmount = pSptRecArray->GetSize();
//*pMaxLevel = iLayer-1;
//return true;
}
float CMediumStrongWenAndSch::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
//这里K值的计算公式为: k = n(n+x)*pai*a/x
//其中a为最小电极间距,我们默认为1,由GD10主机设置
//n:指的是AM之间的间隔系数(即AM=n*a)
//x:指的是MN之间的间隔系数(即MN=x*a)
if (fX == fY)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("MN的距离不能为零!"));
else
MessageBoxEx(NULL, _T("The distance between M and N can not be zero,please check!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return 0;
}
float fNparam = fX - fA;
float fXParam = fY - fX;
return (VAL_PI*fNparam*(fNparam + fXParam)) / fXParam;
}
void CMediumStrongWenAndSch::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;
//此时的OFFSETL相当于每一层第一次ABMN中的点的矩形初始位置,其中X轴的坐标间距为8
//46为坐标轴起始点在X方向的距离
//其中46+ (6+2)*iMul+ 4*iMul*(iLevel-1)*2就是M的起始位置
//iOffsetL = (6+2)*iMul+50+4*iMul*(iLevel-1)*2+(iMul-2);
// iOffsetL = 46+ (6+2)*iMul+ 4*iMul*(iLevel-1)*2 + iMul* ((pSptRecord->m_iP2 - pSptRecord->m_iP1)*(6+2)/2 - 3) ;
// iOffsetR = iOffsetL+6*iMul;
iOffsetL = 46;
iOffsetR = iOffsetL + 6 * iMul;
//矩形的X轴的位置有OFFSETL 再加上向右的偏移距离组成,向右的偏移距离即是全部电极每测一次向右偏移的距离
//举例来说,此时OFFSETL相当于此时的中心点的起始位置,iPtNum-1则相当于此时向右偏移的次数
//其中圆点的半径为3,在这里加4是因为iPtNum距离真正中心点的位置差半个电极间距,
pSptRecord->m_recPtArea.left = iOffsetL + (6 + 2)*iMul*(iPtNum - 1) + (4 - 3)*iMul;
pSptRecord->m_recPtArea.top = 50 + (6 + 2)*iMul*(iLevel - 1);
pSptRecord->m_recPtArea.right = iOffsetR + (6 + 2)*iMul*(iPtNum - 1) + (4 - 3)*iMul;
pSptRecord->m_recPtArea.bottom = (50 + 6 * iMul) + (6 + 2)*iMul*(iLevel - 1);
pSptRecord->m_fPtCenterX = (float)(pSptRecord->m_recPtArea.left + pSptRecord->m_recPtArea.right) / 2;
pSptRecord->m_fPtCenterY = (float)(pSptRecord->m_recPtArea.top + pSptRecord->m_recPtArea.bottom) / 2;
pSptRecord->m_fPtRadius = (float)(abs((int)(pSptRecord->m_fPtCenterX) - pSptRecord->m_recPtArea.left));
}
int CMediumStrongWenAndSch::GetMaxLevelByEAmount(int iEAmount)
{
if (iEAmount < 4)
{
return 0;
}
int iC1Pos, iC2Pos, iP1Pos, iP2Pos;
int iXParam = 1;
int iLayer = 0, iTailorLayer = 0;
while (TRUE)
{
iLayer++;
iTailorLayer = (iLayer - 1) / 5;
iC1Pos = 1;
iP1Pos = iC1Pos + iLayer - iTailorLayer;
iXParam = 1 + iTailorLayer * 2;
iP2Pos = iP1Pos + iXParam;
iC2Pos = iP2Pos + iLayer - iTailorLayer;
if (iC2Pos > iEAmount)
{
break;
}
}
return iLayer - 1;
}
void CMediumStrongWenAndSch::CalculateTdPtLoc(const CRect& vRect, const int& iEAmount, int& iMaxLevel, CRect& lRect, int& iSmWidth, int& iSmHeight, CPtrArray* pTdRecArray)
{
int iTop = 0;
int iBottom = 0;
int iLeft = 0;
int iRight = 0;
int iRectWidth = 0;
int iRectHeight = 0;
iSmWidth = 0;
iSmHeight = 0;
int iLevel = 0;
int iPos = 0;
int iIndex = 0;
int iEOffset = 0;
int iLOffset = 0;
int iNewEAmount = iEAmount;
if (iEAmount%ELECTRODE_AMOUNT_PERCABLE != 0)
{
iNewEAmount = ELECTRODE_AMOUNT_PERCABLE * (1 + iEAmount / ELECTRODE_AMOUNT_PERCABLE);
}
iMaxLevel = this->GetMaxLevelByEAmount(iNewEAmount);
int iXEAmount = (m_iEndPole > m_iStartPole) ? m_iEndPole - m_iStartPole + 1 : iEAmount;
lRect = vRect;
//已此时的CRect的中心移动边来缩小输入的rect的大小
lRect.DeflateRect(141, 40, 61, 40);
//返回大于或者等于指定表达式的最小整数,value 如果有小数部分则进一位
//iEAmount为电极的个数,非测点总数,第一层的测点数是最接近电极数的,在倒三角的剖面中
iSmWidth = (int)ceil(lRect.Width()*1.0 / iXEAmount);
iSmHeight = (int)ceil(lRect.Height()*1.0 / iMaxLevel);
//将iSmWidth变成奇数,那么iSmWidth-1此时将成为偶数,再用它去乘以任何数也都将是偶数
if (fmod((double)iSmWidth, 2.0) == 0.0)
{
iSmWidth++;
}
//由于极端的AM装置中,那么在第一层的最后一个位置,此时AM的点的坐标将会超过X轴的坐标系,
//所以此时要留有一个装置的余量
iRectWidth = iSmWidth + (iSmWidth - 1)*(iXEAmount - 1);
//iRectWidth = iSmWidth+(iSmWidth-1)*(iEAmount-2);
if (fmod((double)iSmHeight, 2.0) == 0.0)
{
iSmHeight++;
}
iRectHeight = iSmHeight + (iSmHeight - 1)*(iMaxLevel - 1);
if (fmod(lRect.Width() - iRectWidth, 2.0) == 0.0)
{
iLeft = (lRect.Width() - iRectWidth) / 2;
iRight = (lRect.Width() - iRectWidth) / 2;
}
else
{
iLeft = (lRect.Width() - iRectWidth) / 2 + 1;
iRight = (lRect.Width() - iRectWidth) / 2;
}
if (fmod(lRect.Height() - iRectHeight, 2.0) == 0.0)
{
iTop = (lRect.Height() - iRectHeight) / 2;
iBottom = (lRect.Height() - iRectHeight) / 2;
}
else
{
iTop = (lRect.Height() - iRectHeight) / 2 + 1;
iBottom = (lRect.Height() - iRectHeight) / 2;
}
lRect.DeflateRect(iLeft, iTop, iRight, iBottom);
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
//iLOffset和iEOffset用来计算中间点和测点之间的偏差
//比如AMN模式中,点在MN的中点位置,此时m_iPosInLevel取得是M点的位置,
//那么iLOffset和iEOffset则用来计算M和中点位置之间的偏差
iEOffset = (int)((iSmWidth - 1)*m_fEOffsetR);
iLOffset = (int)((iSmWidth - 1)*m_fLOffsetR);
while (iIndex < pTdRecArray->GetSize())
{
pRsp2DTdRecord = (CRsp2DTdRecord*)(pTdRecArray->GetAt(iIndex));
iLevel = pRsp2DTdRecord->m_iLevel - 1;
iPos = pRsp2DTdRecord->m_iPosInLevel - 1 - m_iStartPole + 1;
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
pRsp2DTdRecord->m_recPtArea.SetRect(lRect.left + iEOffset + iLOffset*(int)(iLevel / 3) + (iSmWidth - 1)*iPos, lRect.top + (iSmHeight - 1)*iLevel,
lRect.left + iEOffset + iLOffset*(int)(iLevel / 3) + (iSmWidth - 1)*iPos + iSmWidth, lRect.top + (iSmHeight - 1)*iLevel + iSmHeight);
iIndex++;
}
}
void CMediumStrongWenAndSch::ReSortPoint(CPtrArray *f_ptr)
{
//在同一层内,取中点作为间隔点,左右两边分别跑跑,跑完后在取中间点
//例如总共有5个点时,序号分别为1-5,此时的跑极顺序为1,4,2,5,3
//在不同层时,按照层数的从小到大进行跑极
CSptRecord *pSptRecord = NULL;
CSptRecord *pTmp = NULL;
int iMaxLevel = ((CSptRecord *)(f_ptr->GetAt(f_ptr->GetSize() - 1)))->m_iLevel;
if (0 == iMaxLevel)
{
return;
}
int nPreCnt = 0;
std::vector<STlayerOrderIndex> vtLayerOrderInfo;
vtLayerOrderInfo.clear();
int i = 1;
for (; i <= iMaxLevel; i++)
{
int nCurLayerCnt = 0;
for (int j = nPreCnt; j < f_ptr->GetSize(); j++)
{
pTmp = (CSptRecord*)(f_ptr->GetAt(j));
if (i == pTmp->m_iLevel)
{
nCurLayerCnt++;
}
else
break;
}
STlayerOrderIndex stLayerOrder;
stLayerOrder.iLayer = 1;
stLayerOrder.vtIndex.clear();
bool bIsOdd = (nCurLayerCnt % 2 == 0) ? false : true;
int iMidIndex = 0;
if (bIsOdd)
{
iMidIndex = (nCurLayerCnt + 1) / 2;
stLayerOrder.vtIndex.push_back(nPreCnt + iMidIndex - 1);
for (int iIndex = 1; iIndex <iMidIndex; iIndex++)
{
stLayerOrder.vtIndex.push_back(nPreCnt + iMidIndex - iIndex - 1);
stLayerOrder.vtIndex.push_back(nPreCnt + iMidIndex + iIndex - 1);
}
}
else
{
iMidIndex = nCurLayerCnt / 2;
for (int iIndex = 1; iIndex <= iMidIndex; iIndex++)
{
stLayerOrder.vtIndex.push_back(nPreCnt + iMidIndex - (iIndex - 1) - 1);
stLayerOrder.vtIndex.push_back(nPreCnt + iMidIndex + iIndex - 1);
}
}
vtLayerOrderInfo.push_back(stLayerOrder);
nPreCnt += nCurLayerCnt;
}
CPtrArray newPtArr;
newPtArr.RemoveAll();
int iMaxIndex = vtLayerOrderInfo[0].vtIndex.size();
for (int iIndex = 0; iIndex < iMaxIndex; iIndex++)
{
for (i = 1; i <= iMaxLevel; i++)
{
if (iIndex > vtLayerOrderInfo[i - 1].vtIndex.size() - 1)
{
continue;
}
int iOrderIndex = vtLayerOrderInfo[i - 1].vtIndex[iIndex];
pSptRecord = (CSptRecord*)f_ptr->GetAt(iOrderIndex);
newPtArr.Add(pSptRecord);
}
}
if (newPtArr.GetSize() != f_ptr->GetSize())
{
return;
}
f_ptr->RemoveAll();
int iTsn = 0;
for (int k = 0; k < newPtArr.GetSize(); k++)
{
pSptRecord = (CSptRecord*)newPtArr.GetAt(k);
pSptRecord->m_iTsn = ++iTsn;
f_ptr->Add(pSptRecord);
}
}
+106
View File
@@ -0,0 +1,106 @@
// MediumT.cpp: implementation of the CMediumT class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumT.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern int g_iUILanguage;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumT::CMediumT(int iAR): CMedium(iAR)
{
}
CMediumT::~CMediumT()
{
}
bool CMediumT::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
return true;
}
void CMediumT::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
return;
}
int CMediumT::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumT::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumT::GetMaxLevelByEAmount(int iEAmount)
{
return (int)VAL_ZERO;
}
float CMediumT::CalculateDepth(float fA, float fFactor)
{
// return (float)(fabs(fB)+fabs(fA))*fFactor;
return (float)((fabs(fA)/0.5)*fFactor);
// return 0.0;
}
float CMediumT::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
// float fAM = (float)VAL_ZERO;
// float fAN = (float)VAL_ZERO;
// float fBM = (float)VAL_ZERO;
// float fBN = (float)VAL_ZERO;
// fAM = sqrtf((fA + fX - fB) * (fA + fX - fB) + fY * fY);
// fAN = sqrtf((fA + fX + fB) * (fA + fX + fB) + fY * fY);
// fBM = sqrtf((fX - fB - fA) * (fX - fB - fA) + fY * fY);
// fBN = sqrtf((fX + fB - fA) * (fX + fB - fA) + fY * fY);
//
// fK = (float)(2.0 * VAL_PI / fabsf((float)(1.0 / fAM - 1.0 / fAN - 1.0 / fBM - 1.0 / fBN)));
if (0 == fB)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("b的值不能为零!"));
else
MessageBoxEx(NULL, _T("The value of b can not be zero!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return 0;
}
float fAM = sqrt(pow(fA+fX-fB, 2) + pow(fY,2));
float fAN = sqrt(pow(fA+fX+fB, 2) + pow(fY,2));
float fBM = sqrt(pow(fX-fB-fA, 2) + pow(fY,2));
float fBN = sqrt(pow(fX+fB-fA, 2) + pow(fY,2));
fK = 2*VAL_PI/fabsf(1.0/fAM - 1.0/fAN - 1.0/fBM + 1.0/fBN);
//由于采用新的算法,旧的算法注释掉20170316
/*
float fAPlusX = fA + fX;
float fANegativeX = fA - fX;
float fTmp1 = fAPlusX/sqrt(pow(fAPlusX*fAPlusX + fY*fY, 3));
float fTmp2 = fANegativeX/sqrt(pow(fANegativeX*fANegativeX + fY*fY, 3));
fK = VAL_PI/(fB * (fTmp1+fTmp2));
*/
return fK;
}
@@ -0,0 +1,144 @@
// MediumTwoSideAMN.cpp: implementation of the CMediumTwoSideAMN class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumTwoSideAMN.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern int g_iUILanguage;
CMediumTwoSideAMN::CMediumTwoSideAMN(int iAR): CMedium(iAR)
{
m_iMaxSepInterval = 0;
}
CMediumTwoSideAMN::~CMediumTwoSideAMN()
{
}
int CMediumTwoSideAMN::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
if (iM > iA)
{
return iM - iA;
}
else
{
return iA - iN;
}
}
bool CMediumTwoSideAMN::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
{
if (iEAmount < 3)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("双边三极数组的个数是错误的!!"));
else
MessageBoxEx(NULL, _T("The number of Double Side 3P 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;
}
if (m_iMaxSepInterval < 1)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("最大间隔误差"));
else
MessageBoxEx(NULL, _T("Max seprate interval error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
pSptRecArray->RemoveAll();
//装置的位置顺序为AMNB
int iC1Pos = 1, iC2Pos = -1,iP1Pos = 2,iP2Pos = 3;
int iTsn = 0;
CSptRecord *pSptRec = NULL;
//此时AMN方向的移动
while((iC1Pos+m_iMaxSepInterval+1) <= iEAmount)
{
for (int i = 1; i <= m_iMaxSepInterval; i++)
{
iP1Pos = iC1Pos + i;
iP2Pos = iP1Pos + 1;
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);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// 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++;
}
//此时MNA的移动
iC1Pos = 2 + m_iMaxSepInterval;
while(iC1Pos <= iEAmount)
{
for (int i = 1; i <= m_iMaxSepInterval; i++)
{
iP2Pos = iC1Pos - i;
iP1Pos = iP2Pos - 1;
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);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
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++;
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = m_iMaxSepInterval;
return true;
}
float CMediumTwoSideAMN::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fAM = fabs(fX - fA);
float fAN = fabs(fY - fA);
if (0 == fAM || 0 ==fAN)
{
return 0;
// AfxMessageBox(_T("Calcualte K value error.value = "))
}
return fabs(2*VAL_PI/(1.0/fAM - 1.0/fAN));
}
int CMediumTwoSideAMN::GetMaxLevelByEAmount(int iEAmount)
{
return 0;
}
@@ -0,0 +1,73 @@
// MediumU.cpp: implementation of the CMediumU class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumU.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumU::CMediumU(int iAR): CMedium(iAR)
{
}
CMediumU::~CMediumU()
{
}
bool CMediumU::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
return true;
}
void CMediumU::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
return;
}
int CMediumU::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumU::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumU::GetMaxLevelByEAmount(int iEAmount)
{
return (int)VAL_ZERO;
}
float CMediumU::CalculateDepth(float fA, float fFactor)
{
// return (float)(fabs(fB)+fabs(fA))*fFactor;
return (float)((fabs(fA)/0.5)*fFactor);
// return 0.0;
}
float CMediumU::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
// fK = (float)(VAL_PI * (fA * fA - fB * fB) / fB);
return fK;
}
@@ -0,0 +1,72 @@
// MediumUnityProfile.cpp: implementation of the CMediumUnityProfile class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumUnityProfile.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumUnityProfile::CMediumUnityProfile(int iAR): CMedium(iAR)
{
}
CMediumUnityProfile::~CMediumUnityProfile()
{
}
bool CMediumUnityProfile::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
return true;
}
void CMediumUnityProfile::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
return;
}
int CMediumUnityProfile::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumUnityProfile::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return (int)VAL_ZERO;
}
int CMediumUnityProfile::GetMaxLevelByEAmount(int iEAmount)
{
return (int)VAL_ZERO;
}
float CMediumUnityProfile::CalculateDepth(float fA, float fFactor)
{
// return (float)(fabs(fB)+fabs(fA))*fFactor;
return (float)((fabs(fA)/0.5)*fFactor);
// return 0.0;
}
float CMediumUnityProfile::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
fK = (float)(VAL_PI * (fA * fA - fB * fB) / fB);
return fK;
}
+373
View File
@@ -0,0 +1,373 @@
// MediumV.cpp: implementation of the CMediumV class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumV.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumV::CMediumV(int iAR)
{
m_iAR = iAR;
}
CMediumV::~CMediumV()
{
// scr_destroy(m_scr);
}
bool CMediumV::GenerateSptRecElecVal(int iEAmount, int *pMaxLevel, int *pPtAmount, CPtrArray *pSptRecArray)
{
*pMaxLevel = 0;
CSptRecord* pSptRecord = NULL;
struct _point *node, *head = NULL;
head = scr_get_points(m_scr);
int iAmount = 0; //记录测点总数
for (node = head; node;)
{
pSptRecord = new CSptRecord();
pSptRecord->m_iC1 = node->A;
pSptRecord->m_iC2 = node->B;
pSptRecord->m_iP1 = node->M;
pSptRecord->m_iP2 = node->N;
// pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = node->KS;
// pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
// pSptRecord->m_iPtNum = iAVal;
// pSptRecord->m_colorREF = RGB(150, 255, 255);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
// CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (node->next == head)
break;
node = node->next;
iAmount++;
}
*pPtAmount = iAmount;
return true;
}
void CMediumV::CalculateSptPtLoc(int iMul, CSptRecord *pSptRecord)
{
}
int CMediumV::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumV::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumV::GetMaxLevelByEAmount(int iEAmount)
{
return FALSE;
}
float CMediumV::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return FALSE;
}
void CMediumV::create()
{
m_rect.x0 = 1;
m_rect.y0 = 1;
m_rect.x1 = 12;
m_rect.y1 = 12;
m_scr = scr_create("Pole-Pole", NULL, &m_rect, 0, 0);
}
void CMediumV::SetRect(int x0, int y0, int x1, int y1)
{
rect_init(&m_rect, x0, y0, x1, y1);
scr_set_rect(m_scr, &m_rect);
}
void CMediumV::setZone(bool enable, int zonec, int *zonev)
{
scr_set_zone(m_scr, enable, zonec, zonev);
}
BOOL CMediumV::setPoleStart(int startpole)
{
return scr_set_pole_start(m_scr, startpole);
}
BOOL CMediumV::generate()
{
return scr_generate(m_scr);
}
int CMediumV::getPoleStart()
{
return scr_get_pole_start(m_scr);
}
int CMediumV::getPoleCount()
{
return scr_get_pole_count(m_scr);
}
struct _rect * CMediumV::getRect()
{
return scr_get_rect(m_scr);
}
void CMediumV::SetPointCPosition(char *f_type, int f_x, int f_y)
{
return;
}
void CMediumV::SaveScr()
{
struct _rect rect = { 1, 1, 12, 12 };
struct _rect *r;
struct _point *node, *head = NULL;
int length;
FILE *fd;
char *buf = NULL;
if (!m_scr)
return;
head = scr_get_points(m_scr);
if (!head)
goto __exit;
buf = new char[512];
if (!buf)
{
printf("buffer alloc failed!\n");
goto __exit;
}
/* 只写 & 创建 打开 */
{
r = scr_get_rect(m_scr);
_snprintf(buf, 512, "D:\\%s(%d,%d,%d,%d).scr",
scr_get_name(m_scr),
r->x0, r->y0, r->x1, r->y1);
fd = fopen(buf, "wb+");
}
if (fd < 0)
{
printf("open \"%s\" for write failed!\n", scr_get_name(m_scr));
goto __exit;
}
{
time_t now;
struct tm *ptm;
time(&now);
ptm = localtime(&now); //取得当地时间
r = scr_get_rect(m_scr);
length = _snprintf(buf, 512, "<?xml version = \"1.0\" encoding = \"ansi\" ?>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "<script>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t</channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<layout>\r\n");
fwrite(buf, 1, length, fd);
}
for (node = head; node;)
{
length = _snprintf(buf, 512, "\t\t<array tsn = \"%d\" ch = \"1\" c1 = \"%d\" c2 = \"%d\" n = \"1\">\r\n", node->TSN, node->A, node->B);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d, %d</ch>\r\n", node->KS, node->M, node->N);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t</array>\r\n");
fwrite(buf, 1, length, fd);
if (node->next == head)
break;
node = node->next;
}
length = _snprintf(buf, 512, "\t</layout>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "</script>\r\n");
fwrite(buf, 1, length, fd);
__exit:
if (fd >= 0)
fclose(fd);
if (buf)
delete buf;
return;
}
BOOL CMediumV::CheckPointVailed(_point *point, int SplittedId, int *result)
{
int Aid = 0, Bid = 0, Cid = 0, Did = 0;
if (point->A == -1 && point->B == -1 && point->M == -1 && point->N == -1)
return FALSE;
//取得步长
int xStep = 0, yStep = 0;
scr_get_pole_step(m_scr, &xStep, &yStep);
//取得矩形大小
_rect *rect;
rect = scr_get_rect(m_scr);
//将ABMN电极转换为坐标
_pos *posA, *posB, *posM, *posN;
posA = new _pos();
posB = new _pos();
posM = new _pos();
posN = new _pos();
//将传进来的point(测点)转换成坐标
pole_to_pos_by_normal_axis(rect, 1, xStep, yStep, posA, point->A);
pole_to_pos_by_normal_axis(rect, 1, xStep, yStep, posB, point->B);
pole_to_pos_by_normal_axis(rect, 1, xStep, yStep, posM, point->M);
pole_to_pos_by_normal_axis(rect, 1, xStep, yStep, posN, point->N);
//计算ABMN的横坐标的位置
int locA = 0, locB = 0, locM = 0, locN = 0;
locA = posA->x - rect->x0;
locB = posB->x - rect->x0;
locM = posM->x - rect->x0;
locN = posN->x - rect->x0;
//-1代表无穷远,即该点无效,locA % SplitterId,A的横坐标取余脚本分割数,结果为该测点所属的子脚本序列
if (point->A != -1)
Aid = locA % SplittedId;
else
Aid = -1;
if (point->B != -1)
Bid = locB % SplittedId;
else
Bid = -1;
if (point->M != -1)
Cid = locM % SplittedId;
else
Cid = -1;
if (point->N != -1)
Did = locN % SplittedId;
else
Did = -1;
//将4个测点所属的子脚本序列放入数据,方便后面运算
int nArray[4] = {Aid, Bid, Cid, Did};
int i = 0;
BOOL bResult = FALSE;
//判断ABMN测点是否属于同一个子脚本序列(即Did,Aid,Bid,Cid是否相等,-1除外)
if (Aid != -1)
{
for (i = 1; i < 4; i++)
{
if (nArray[i] != -1)
{
if (Aid != nArray[i])
{
bResult = FALSE;
goto _exit;
}
}
}
*result = Aid;
}
else if (Bid != -1)
{
//进入该条件,则表明Aid==-1,故不需要再判断
for (i = 2; i < 4; i++)
{
if (nArray[i] != -1)
{
if (Bid != nArray[i])
{
bResult = FALSE;
goto _exit;
}
}
}
*result = Bid;
}
else if (Cid != -1)
{
//进入该条件,则表明Aid==-1且Bid == -1,故不需要再判断
if (Did != -1)
{
if (Cid != Did)
{
bResult = FALSE;
goto _exit;
}
else
*result = Cid;
}
else
*result = Cid;
}
bResult = TRUE;
_exit:
delete posA;
delete posB;
delete posM;
delete posN;
return bResult;
}
+244
View File
@@ -0,0 +1,244 @@
// MediumW.cpp: implementation of the CMediumW class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumW.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumW::CMediumW(int iAR)
{
m_iAR = iAR;
}
CMediumW::~CMediumW()
{
// scr_destroy(m_scr);
}
bool CMediumW::GenerateSptRecElecVal(int iEAmount, int *pMaxLevel, int *pPtAmount, CPtrArray *pSptRecArray)
{
*pMaxLevel = 0;
CSptRecord* pSptRecord = NULL;
struct _point *node, *head = NULL;
head = scr_get_points(m_scr);
int iAmount = 0; //记录测点总数
for (node = head; node;)
{
pSptRecord = new CSptRecord();
pSptRecord->m_iC1 = node->A;
pSptRecord->m_iC2 = node->B;
pSptRecord->m_iP1 = node->M;
pSptRecord->m_iP2 = node->N;
// pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = node->KS;
// pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
// pSptRecord->m_iPtNum = iAVal;
// pSptRecord->m_colorREF = RGB(150, 255, 255);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
// CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (node->next == head)
break;
node = node->next;
iAmount++;
}
return FALSE;
}
void CMediumW::CalculateSptPtLoc(int iMul, CSptRecord *pSptRecord)
{
}
int CMediumW::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumW::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumW::GetMaxLevelByEAmount(int iEAmount)
{
return FALSE;
}
float CMediumW::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return FALSE;
}
void CMediumW::create()
{
m_rect.x0 = 1;
m_rect.y0 = 1;
m_rect.x1 = 12;
m_rect.y1 = 12;
m_scr = scr_create("Pole-Dipole", NULL, &m_rect, 0, 0);
}
void CMediumW::SetRect(int x0, int y0, int x1, int y1)
{
rect_init(&m_rect, x0, y0, x1, y1);
scr_set_rect(m_scr, &m_rect);
}
void CMediumW::setZone(bool enable, int zonec, int *zonev)
{
scr_set_zone(m_scr, enable, zonec, zonev);
}
BOOL CMediumW::setPoleStart(int startpole)
{
return scr_set_pole_start(m_scr, startpole);
}
BOOL CMediumW::generate()
{
return scr_generate(m_scr);
}
int CMediumW::getPoleStart()
{
return scr_get_pole_start(m_scr);
}
int CMediumW::getPoleCount()
{
return scr_get_pole_count(m_scr);
}
struct _rect * CMediumW::getRect()
{
return scr_get_rect(m_scr);
}
void CMediumW::SetPointCPosition(char *f_type, int f_x, int f_y)
{
return;
}
void CMediumW::SaveScr()
{
struct _rect rect = { 1, 1, 12, 12 };
struct _rect *r;
struct _point *node, *head = NULL;
int length;
FILE *fd;
char *buf = NULL;
if (!m_scr)
return;
head = scr_get_points(m_scr);
if (!head)
goto __exit;
buf = new char[512];
if (!buf)
{
printf("buffer alloc failed!\n");
goto __exit;
}
/* 只写 & 创建 打开 */
{
r = scr_get_rect(m_scr);
_snprintf(buf, 512, "disk/sd/%s(%d,%d,%d,%d).scr",
scr_get_name(m_scr),
r->x0, r->y0, r->x1, r->y1);
fd = fopen(buf, "wb+");
}
if (fd < 0)
{
printf("open \"%s\" for write failed!\n", scr_get_name(m_scr));
goto __exit;
}
{
time_t now;
struct tm *ptm;
time(&now);
ptm = localtime(&now); //取得当地时间
r = scr_get_rect(m_scr);
length = _snprintf(buf, 512, "<?xml version = \"1.0\" encoding = \"ansi\" ?>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "<script>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t</channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<layout>\r\n");
fwrite(buf, 1, length, fd);
}
for (node = head; node;)
{
length = _snprintf(buf, 512, "\t\t<array tsn = \"%d\" ch = \"1\" c1 = \"%d\" c2 = \"%d\" n = \"1\">\r\n", node->TSN, node->A, node->B);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d, %d</ch>\r\n", node->KS, node->M, node->N);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t</array>\r\n");
fwrite(buf, 1, length, fd);
if (node->next == head)
break;
node = node->next;
}
length = _snprintf(buf, 512, "\t</layout>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "</script>\r\n");
fwrite(buf, 1, length, fd);
__exit:
if (fd >= 0)
fclose(fd);
if (buf)
delete buf;
return;
}
+242
View File
@@ -0,0 +1,242 @@
// MediumX.cpp: implementation of the CMediumX class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumX.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumX::CMediumX(int iAR)
{
m_iAR = iAR;
}
CMediumX::~CMediumX()
{
// scr_destroy(m_scr);
}
bool CMediumX::GenerateSptRecElecVal(int iEAmount, int *pMaxLevel, int *pPtAmount, CPtrArray *pSptRecArray)
{
CSptRecord* pSptRecord = NULL;
struct _point *node, *head = NULL;
head = scr_get_points(m_scr);
int iAmount = 0; //记录测点总数
for (node = head; node;)
{
pSptRecord = new CSptRecord();
pSptRecord->m_iC1 = node->A;
pSptRecord->m_iC2 = node->B;
pSptRecord->m_iP1 = node->M;
pSptRecord->m_iP2 = node->N;
// pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = node->KS;
// pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
// pSptRecord->m_iPtNum = iAVal;
// pSptRecord->m_colorREF = RGB(150, 255, 255);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
// CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (node->next == head)
break;
node = node->next;
iAmount++;
}
return FALSE;
}
void CMediumX::CalculateSptPtLoc(int iMul, CSptRecord *pSptRecord)
{
}
int CMediumX::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumX::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumX::GetMaxLevelByEAmount(int iEAmount)
{
return FALSE;
}
float CMediumX::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return FALSE;
}
void CMediumX::create()
{
m_rect.x0 = 1;
m_rect.y0 = 1;
m_rect.x1 = 12;
m_rect.y1 = 12;
m_scr = scr_create("Dipole-Dipole", NULL, &m_rect, 0, 0);
}
void CMediumX::SetRect(int x0, int y0, int x1, int y1)
{
rect_init(&m_rect, x0, y0, x1, y1);
scr_set_rect(m_scr, &m_rect);
}
void CMediumX::setZone(bool enable, int zonec, int *zonev)
{
scr_set_zone(m_scr, enable, zonec, zonev);
}
BOOL CMediumX::setPoleStart(int startpole)
{
return scr_set_pole_start(m_scr, startpole);
}
BOOL CMediumX::generate()
{
return scr_generate(m_scr);
}
int CMediumX::getPoleStart()
{
return scr_get_pole_start(m_scr);
}
int CMediumX::getPoleCount()
{
return scr_get_pole_count(m_scr);
}
struct _rect * CMediumX::getRect()
{
return scr_get_rect(m_scr);
}
void CMediumX::SetPointCPosition(char *f_type, int f_x, int f_y)
{
return;
}
void CMediumX::SaveScr()
{
struct _rect rect = { 1, 1, 12, 12 };
struct _rect *r;
struct _point *node, *head = NULL;
int length;
FILE *fd;
char *buf = NULL;
if (!m_scr)
return;
head = scr_get_points(m_scr);
if (!head)
goto __exit;
buf = new char[512];
if (!buf)
{
printf("buffer alloc failed!\n");
goto __exit;
}
/* 只写 & 创建 打开 */
{
r = scr_get_rect(m_scr);
_snprintf(buf, 512, "disk/sd/%s(%d,%d,%d,%d).scr",
scr_get_name(m_scr),
r->x0, r->y0, r->x1, r->y1);
fd = fopen(buf, "wb+");
}
if (fd < 0)
{
printf("open \"%s\" for write failed!\n", scr_get_name(m_scr));
goto __exit;
}
{
time_t now;
struct tm *ptm;
time(&now);
ptm = localtime(&now); //取得当地时间
r = scr_get_rect(m_scr);
length = _snprintf(buf, 512, "<?xml version = \"1.0\" encoding = \"ansi\" ?>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "<script>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t</channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<layout>\r\n");
fwrite(buf, 1, length, fd);
}
for (node = head; node;)
{
length = _snprintf(buf, 512, "\t\t<array tsn = \"%d\" ch = \"1\" c1 = \"%d\" c2 = \"%d\" n = \"1\">\r\n", node->TSN, node->A, node->B);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d, %d</ch>\r\n", node->KS, node->M, node->N);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t</array>\r\n");
fwrite(buf, 1, length, fd);
if (node->next == head)
break;
node = node->next;
}
length = _snprintf(buf, 512, "\t</layout>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "</script>\r\n");
fwrite(buf, 1, length, fd);
__exit:
if (fd >= 0)
fclose(fd);
if (buf)
delete buf;
return;
}
+244
View File
@@ -0,0 +1,244 @@
// MediumY.cpp: implementation of the CMediumY class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumY.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumY::CMediumY(int iAR)
{
m_iAR = iAR;
}
CMediumY::~CMediumY()
{
}
bool CMediumY::GenerateSptRecElecVal(int iEAmount, int *pMaxLevel, int *pPtAmount, CPtrArray *pSptRecArray)
{
CSptRecord* pSptRecord = NULL;
struct _point *node, *head = NULL;
head = scr_get_points(m_scr);
int iAmount = 0; //记录测点总数
for (node = head; node;)
{
pSptRecord = new CSptRecord();
pSptRecord->m_iC1 = node->A;
pSptRecord->m_iC2 = node->B;
pSptRecord->m_iP1 = node->M;
pSptRecord->m_iP2 = node->N;
// pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = node->KS;
// pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
// pSptRecord->m_iPtNum = iAVal;
// pSptRecord->m_colorREF = RGB(150, 255, 255);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
// CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (node->next == head)
break;
node = node->next;
iAmount++;
}
return FALSE;
}
void CMediumY::CalculateSptPtLoc(int iMul, CSptRecord *pSptRecord)
{
}
int CMediumY::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumY::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumY::GetMaxLevelByEAmount(int iEAmount)
{
return FALSE;
}
float CMediumY::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return FALSE;
}
void CMediumY::create()
{
m_rect.x0 = 1;
m_rect.y0 = 1;
m_rect.x1 = 12;
m_rect.y1 = 12;
m_scr = scr_create("Schlumberger", NULL, &m_rect, 0, 0);
}
void CMediumY::SetRect(int x0, int y0, int x1, int y1)
{
rect_init(&m_rect, x0, y0, x1, y1);
scr_set_rect(m_scr, &m_rect);
}
void CMediumY::setZone(bool enable, int zonec, int *zonev)
{
scr_set_zone(m_scr, enable, zonec, zonev);
}
BOOL CMediumY::setPoleStart(int startpole)
{
return scr_set_pole_start(m_scr, startpole);
}
BOOL CMediumY::generate()
{
return scr_generate(m_scr);
}
int CMediumY::getPoleStart()
{
return scr_get_pole_start(m_scr);
}
int CMediumY::getPoleCount()
{
return scr_get_pole_count(m_scr);
}
struct _rect * CMediumY::getRect()
{
return scr_get_rect(m_scr);
}
void CMediumY::SetPointCPosition(char *f_type, int f_x, int f_y)
{
return;
}
void CMediumY::SaveScr()
{
struct _rect rect = { 1, 1, 12, 12 };
struct _rect *r;
struct _point *node, *head = NULL;
int length;
FILE *fd;
char *buf = NULL;
if (!m_scr)
return;
head = scr_get_points(m_scr);
if (!head)
goto __exit;
buf = new char[512];
if (!buf)
{
printf("buffer alloc failed!\n");
goto __exit;
}
/* 只写 & 创建 打开 */
{
r = scr_get_rect(m_scr);
_snprintf(buf, 512, "disk/sd/%s(%d,%d,%d,%d).scr",
scr_get_name(m_scr),
r->x0, r->y0, r->x1, r->y1);
fd = fopen(buf, "wb+");
}
if (fd < 0)
{
printf("open \"%s\" for write failed!\n", scr_get_name(m_scr));
goto __exit;
}
{
time_t now;
struct tm *ptm;
time(&now);
ptm = localtime(&now); //取得当地时间
r = scr_get_rect(m_scr);
length = _snprintf(buf, 512, "<?xml version = \"1.0\" encoding = \"ansi\" ?>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "<script>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t</channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<layout>\r\n");
fwrite(buf, 1, length, fd);
}
for (node = head; node;)
{
length = _snprintf(buf, 512, "\t\t<array tsn = \"%d\" ch = \"1\" c1 = \"%d\" c2 = \"%d\" n = \"1\">\r\n", node->TSN, node->A, node->B);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d, %d</ch>\r\n", node->KS, node->M, node->N);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t</array>\r\n");
fwrite(buf, 1, length, fd);
if (node->next == head)
break;
node = node->next;
}
length = _snprintf(buf, 512, "\t</layout>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "</script>\r\n");
fwrite(buf, 1, length, fd);
__exit:
if (fd >= 0)
fclose(fd);
if (buf)
delete buf;
return;
}
+242
View File
@@ -0,0 +1,242 @@
// MediumZ.cpp: implementation of the CMediumZ class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumZ.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumZ::CMediumZ(int iAR)
{
m_iAR = iAR;
}
CMediumZ::~CMediumZ()
{
}
bool CMediumZ::GenerateSptRecElecVal(int iEAmount, int *pMaxLevel, int *pPtAmount, CPtrArray *pSptRecArray)
{
CSptRecord* pSptRecord = NULL;
struct _point *node, *head = NULL;
head = scr_get_points(m_scr);
int iAmount = 0; //记录测点总数
for (node = head; node;)
{
pSptRecord = new CSptRecord();
pSptRecord->m_iC1 = node->A;
pSptRecord->m_iC2 = node->B;
pSptRecord->m_iP1 = node->M;
pSptRecord->m_iP2 = node->N;
// pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = node->KS;
// pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
// pSptRecord->m_iPtNum = iAVal;
// pSptRecord->m_colorREF = RGB(150, 255, 255);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
// CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (node->next == head)
break;
node = node->next;
iAmount++;
}
return FALSE;
}
void CMediumZ::CalculateSptPtLoc(int iMul, CSptRecord *pSptRecord)
{
}
int CMediumZ::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumZ::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumZ::GetMaxLevelByEAmount(int iEAmount)
{
return FALSE;
}
float CMediumZ::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return FALSE;
}
void CMediumZ::create()
{
m_rect.x0 = 1;
m_rect.y0 = 1;
m_rect.x1 = 12;
m_rect.y1 = 12;
m_scr = scr_create("WennerAlfa", NULL, &m_rect, 0, 0);
}
void CMediumZ::SetRect(int x0, int y0, int x1, int y1)
{
rect_init(&m_rect, x0, y0, x1, y1);
scr_set_rect(m_scr, &m_rect);
}
void CMediumZ::setZone(bool enable, int zonec, int *zonev)
{
scr_set_zone(m_scr, enable, zonec, zonev);
}
BOOL CMediumZ::setPoleStart(int startpole)
{
return scr_set_pole_start(m_scr, startpole);
}
BOOL CMediumZ::generate()
{
return scr_generate(m_scr);
}
int CMediumZ::getPoleStart()
{
return scr_get_pole_start(m_scr);
}
int CMediumZ::getPoleCount()
{
return scr_get_pole_count(m_scr);
}
struct _rect * CMediumZ::getRect()
{
return scr_get_rect(m_scr);
}
void CMediumZ::SetPointCPosition(char *f_type, int f_x, int f_y)
{
return;
}
void CMediumZ::SaveScr()
{
struct _rect rect = { 1, 1, 12, 12 };
struct _rect *r;
struct _point *node, *head = NULL;
int length;
FILE *fd;
char *buf = NULL;
if (!m_scr)
return;
head = scr_get_points(m_scr);
if (!head)
goto __exit;
buf = new char[512];
if (!buf)
{
printf("buffer alloc failed!\n");
goto __exit;
}
/* 只写 & 创建 打开 */
{
r = scr_get_rect(m_scr);
_snprintf(buf, 512, "disk/sd/%s(%d,%d,%d,%d).scr",
scr_get_name(m_scr),
r->x0, r->y0, r->x1, r->y1);
fd = fopen(buf, "wb+");
}
if (fd < 0)
{
printf("open \"%s\" for write failed!\n", scr_get_name(m_scr));
goto __exit;
}
{
time_t now;
struct tm *ptm;
time(&now);
ptm = localtime(&now); //取得当地时间
r = scr_get_rect(m_scr);
length = _snprintf(buf, 512, "<?xml version = \"1.0\" encoding = \"ansi\" ?>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "<script>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t</channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<layout>\r\n");
fwrite(buf, 1, length, fd);
}
for (node = head; node;)
{
length = _snprintf(buf, 512, "\t\t<array tsn = \"%d\" ch = \"1\" c1 = \"%d\" c2 = \"%d\" n = \"1\">\r\n", node->TSN, node->A, node->B);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d, %d</ch>\r\n", node->KS, node->M, node->N);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t</array>\r\n");
fwrite(buf, 1, length, fd);
if (node->next == head)
break;
node = node->next;
}
length = _snprintf(buf, 512, "\t</layout>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "</script>\r\n");
fwrite(buf, 1, length, fd);
__exit:
if (fd >= 0)
fclose(fd);
if (buf)
delete buf;
return;
}
@@ -0,0 +1,250 @@
// MediumZA.cpp: implementation of the CMediumZA class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumZA.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumZA::CMediumZA(int iAR)
{
m_iAR = iAR;
}
CMediumZA::~CMediumZA()
{
}
bool CMediumZA::GenerateSptRecElecVal(int iEAmount, int *pMaxLevel, int *pPtAmount, CPtrArray *pSptRecArray)
{
*pMaxLevel = 0;
CSptRecord* pSptRecord = NULL;
struct _point *node, *head = NULL;
head = scr_get_points(m_scr);
int iAmount = 0; //记录测点总数
for (node = head; node;)
{
pSptRecord = new CSptRecord();
pSptRecord->m_iC1 = node->A;
pSptRecord->m_iC2 = node->B;
pSptRecord->m_iP1 = node->M;
pSptRecord->m_iP2 = node->N;
pSptRecord->m_iTsn = node->TSN;
pSptRecord->m_fK = node->KS;
// pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
// pSptRecord->m_iPtNum = iAVal;
// pSptRecord->m_colorREF = RGB(150, 255, 255);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
// CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (node->next == head)
break;
node = node->next;
iAmount++;
}
*pPtAmount = iAmount;
return TRUE;
}
void CMediumZA::CalculateSptPtLoc(int iMul, CSptRecord *pSptRecord)
{
}
int CMediumZA::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumZA::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumZA::GetMaxLevelByEAmount(int iEAmount)
{
return FALSE;
}
float CMediumZA::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return FALSE;
}
void CMediumZA::create()
{
m_rect.x0 = 1;
m_rect.y0 = 1;
m_rect.x1 = 12;
m_rect.y1 = 12;
m_scr = NULL;
m_scr = scr_create("WennerBeta", NULL, &m_rect, 0, 0);
}
void CMediumZA::SetRect(int x0, int y0, int x1, int y1)
{
rect_init(&m_rect, x0, y0, x1, y1);
scr_set_rect(m_scr, &m_rect);
}
void CMediumZA::setZone(bool enable, int zonec, int *zonev)
{
// int n[3] = {0,1,2};
// scr_set_zone(m_scr, enable, 3, n);
scr_set_zone(m_scr, enable, zonec, zonev);
}
BOOL CMediumZA::setPoleStart(int startpole)
{
return scr_set_pole_start(m_scr, startpole);
}
BOOL CMediumZA::generate()
{
return scr_generate(m_scr);
}
int CMediumZA::getPoleStart()
{
return scr_get_pole_start(m_scr);
}
int CMediumZA::getPoleCount()
{
return scr_get_pole_count(m_scr);
}
struct _rect * CMediumZA::getRect()
{
return scr_get_rect(m_scr);
}
void CMediumZA::SetPointCPosition(char *f_type, int f_x, int f_y)
{
return;
}
void CMediumZA::SaveScr()
{
struct _rect rect = { 1, 1, 12, 12 };
struct _rect *r;
struct _point *node, *head = NULL;
int length;
FILE *fd;
char *buf = NULL;
if (!m_scr)
return;
head = scr_get_points(m_scr);
if (!head)
goto __exit;
buf = new char[512];
if (!buf)
{
printf("buffer alloc failed!\n");
goto __exit;
}
/* 只写 & 创建 打开 */
{
r = scr_get_rect(m_scr);
_snprintf(buf, 512, "disk/sd/%s(%d,%d,%d,%d).scr",
scr_get_name(m_scr),
r->x0, r->y0, r->x1, r->y1);
fd = fopen(buf, "wb+");
}
if (fd < 0)
{
printf("open \"%s\" for write failed!\n", scr_get_name(m_scr));
goto __exit;
}
{
time_t now;
struct tm *ptm;
time(&now);
ptm = localtime(&now); //取得当地时间
r = scr_get_rect(m_scr);
length = _snprintf(buf, 512, "<?xml version = \"1.0\" encoding = \"ansi\" ?>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "<script>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t</channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<layout>\r\n");
fwrite(buf, 1, length, fd);
}
for (node = head; node;)
{
length = _snprintf(buf, 512, "\t\t<array tsn = \"%d\" ch = \"1\" c1 = \"%d\" c2 = \"%d\" n = \"1\">\r\n", node->TSN, node->A, node->B);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d, %d</ch>\r\n", node->KS, node->M, node->N);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t</array>\r\n");
fwrite(buf, 1, length, fd);
if (node->next == head)
break;
node = node->next;
}
length = _snprintf(buf, 512, "\t</layout>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "</script>\r\n");
fwrite(buf, 1, length, fd);
__exit:
if (fd >= 0)
fclose(fd);
if (buf)
delete buf;
return;
}
@@ -0,0 +1,243 @@
// MediumZB.cpp: implementation of the CMediumZB class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumZB.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumZB::CMediumZB(int iAR)
{
m_iAR = iAR;
}
CMediumZB::~CMediumZB()
{
}
bool CMediumZB::GenerateSptRecElecVal(int iEAmount, int *pMaxLevel, int *pPtAmount, CPtrArray *pSptRecArray)
{
CSptRecord* pSptRecord = NULL;
struct _point *node, *head = NULL;
head = scr_get_points(m_scr);
int iAmount = 0; //记录测点总数
for (node = head; node;)
{
pSptRecord = new CSptRecord();
pSptRecord->m_iC1 = node->A;
pSptRecord->m_iC2 = node->B;
pSptRecord->m_iP1 = node->M;
pSptRecord->m_iP2 = node->N;
// pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = node->KS;
// pSptRecord->m_iLevel = CalculateSptLevel(iMVal, iNVal);
// pSptRecord->m_iPtNum = iAVal;
// pSptRecord->m_colorREF = RGB(150, 255, 255);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
// CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (node->next == head)
break;
node = node->next;
iAmount++;
}
return FALSE;
}
void CMediumZB::CalculateSptPtLoc(int iMul, CSptRecord *pSptRecord)
{
}
int CMediumZB::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumZB::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return FALSE;
}
int CMediumZB::GetMaxLevelByEAmount(int iEAmount)
{
return FALSE;
}
float CMediumZB::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
return FALSE;
}
void CMediumZB::create()
{
m_rect.x0 = 1;
m_rect.y0 = 1;
m_rect.x1 = 12;
m_rect.y1 = 12;
m_scr = scr_create("Gradient", NULL, &m_rect, 0, 0);
}
void CMediumZB::SetRect(int x0, int y0, int x1, int y1)
{
rect_init(&m_rect, x0, y0, x1, y1);
scr_set_rect(m_scr, &m_rect);
}
void CMediumZB::setZone(bool enable, int zonec, int *zonev)
{
scr_set_zone(m_scr, enable, zonec, zonev);
}
BOOL CMediumZB::setPoleStart(int startpole)
{
return scr_set_pole_start(m_scr, startpole);
}
BOOL CMediumZB::generate()
{
return scr_generate(m_scr);
}
int CMediumZB::getPoleStart()
{
return scr_get_pole_start(m_scr);
}
int CMediumZB::getPoleCount()
{
return scr_get_pole_count(m_scr);
}
struct _rect * CMediumZB::getRect()
{
return scr_get_rect(m_scr);
}
void CMediumZB::SetPointCPosition(char *f_type, int f_x, int f_y)
{
scr_init_pole(m_scr, f_type, f_x, f_y);
}
void CMediumZB::SaveScr()
{
struct _rect rect = { 1, 1, 12, 12 };
struct _rect *r;
struct _point *node, *head = NULL;
int length;
FILE *fd;
char *buf = NULL;
if (!m_scr)
return;
head = scr_get_points(m_scr);
if (!head)
goto __exit;
buf = new char[512];
if (!buf)
{
printf("buffer alloc failed!\n");
goto __exit;
}
/* 只写 & 创建 打开 */
{
r = scr_get_rect(m_scr);
_snprintf(buf, 512, "disk/sd/%s(%d,%d,%d,%d).scr",
scr_get_name(m_scr),
r->x0, r->y0, r->x1, r->y1);
fd = fopen(buf, "wb+");
}
if (fd < 0)
{
printf("open \"%s\" for write failed!\n", scr_get_name(m_scr));
goto __exit;
}
{
time_t now;
struct tm *ptm;
time(&now);
ptm = localtime(&now); //取得当地时间
r = scr_get_rect(m_scr);
length = _snprintf(buf, 512, "<?xml version = \"1.0\" encoding = \"ansi\" ?>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "<script>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t</channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<layout>\r\n");
fwrite(buf, 1, length, fd);
}
for (node = head; node;)
{
length = _snprintf(buf, 512, "\t\t<array tsn = \"%d\" ch = \"1\" c1 = \"%d\" c2 = \"%d\" n = \"1\">\r\n", node->TSN, node->A, node->B);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d, %d</ch>\r\n", node->KS, node->M, node->N);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t</array>\r\n");
fwrite(buf, 1, length, fd);
if (node->next == head)
break;
node = node->next;
}
length = _snprintf(buf, 512, "\t</layout>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "</script>\r\n");
fwrite(buf, 1, length, fd);
__exit:
if (fd >= 0)
fclose(fd);
if (buf)
delete buf;
return;
}
@@ -0,0 +1,301 @@
// MediumZC.cpp: implementation of the CMediumZC class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MediumZC.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumZC::CMediumZC(int iAR)
{
m_iAR = iAR;
m_fEOffsetR = 0.5;
m_fLOffsetR = 0.5;
m_fIntervalCof = 6;
}
CMediumZC::~CMediumZC()
{
}
bool CMediumZC::GenerateSptRecElecVal(int iEAmount, //电极总数---in
int* pMaxLevel, //最大层---out
int* pPtAmount, //测点总数---out
CPtrArray* pSptRecArray //脚本记录集---out
) //函数功能:生成脚本电极记录集合
{
// int iEqualValMove = (int)VAL_ZERO;
int iMaxSpace = (int)VAL_ZERO;
// int iSpace = (int)VAL_ZERO; //电极间的距离
int iTsn = (int)VAL_ZERO;
int iAVal = (int)VAL_ZERO;
int iBVal = (int)VAL_ZERO;
int iMVal = (int)VAL_ZERO;
int iNVal = (int)VAL_ZERO;
int iMAVal = (int)VAL_ZERO;
int iMMVal = (int)VAL_ZERO;
int iMNVal = (int)VAL_ZERO;
int iMBVal = (int)VAL_ZERO;
int iDisTance = 0;
int iStep = 0;
// int iMMove = (int)VAL_ZERO;
// int iAMove = (int)VAL_ZERO;
int iTotalMove = (int)VAL_ZERO;
int iMaxLevel = (int)VAL_ZERO;
CSptRecord* pSptRecord = NULL;
CString str = _T("");
iMaxSpace = iEAmount - 3; //BM之间的最大电极间距,(例如第一个电极和最后一个电极相聚N - 1米,第二个电极 和 倒数第二个电极相聚 N - 1 - 1 - 1米)
iTotalMove = iEAmount - 4; //AB总共需要移动的次数
//在这里之前都是按照ABMN来计算的
for (iMBVal = 2; iMBVal <= 2+iTotalMove; iMBVal++)
{
iMAVal = iMBVal - 1; //A始终在B前面一个位置
iMBVal = iMBVal;
iMMVal = iMBVal + 1;
iMNVal = iMMVal + 1;
iAVal = iMAVal;
iBVal = iMBVal;
iMVal = iMMVal;
iNVal = iMNVal;
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iBVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iC2 = iAVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iAVal,iBVal,iMVal,iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMBVal, iMMVal);
pSptRecord->m_iPtNum = iBVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
iMMVal += 1;
for (iMMVal; iMMVal < iEAmount; iMMVal++)
{
iMMVal = iMMVal;
iMNVal = iMMVal + 1;//其他测点位置没有改变
iAVal = iMAVal;
iBVal = iMBVal;
iMVal = iMMVal;
iNVal = iMNVal;
float fInterval = (1.0*(iMVal - iBVal))/(iNVal - iMVal);
if (fInterval > m_fIntervalCof)//BM间距大于6倍AB时,AB之间的距离要增加
{
// iDisTance = (iMVal - iBVal)/(iNVal - iMVal);
iStep = fInterval / m_fIntervalCof;
if (fmod(fInterval,m_fIntervalCof) < 0.00001)
{
iStep -= 1;
}
iBVal = iBVal + iStep;
iMVal = iMVal + iStep;
iNVal = iNVal + (iStep*2);//因为M向后移动了N个单位,导致N要向后移动2倍的N才能将与M的间距扩大为N
if (iNVal > iEAmount)
{
break;
}
}
/*暂时屏蔽,改用新算法
if (iMVal - iBVal > m_iIntervalCof)//BM间距大于6倍AB时,AB之间的距离要增加
{
iDisTance = (iMVal - iBVal)/(iNVal - iMVal);
iStep = iDisTance / m_iIntervalCof;
if (iDisTance % m_iIntervalCof == 0)
{
iStep -= 1;
}
iBVal = iBVal + iStep;
iMVal = iMVal + iStep;
iNVal = iNVal + (iStep*2);//因为M向后移动了N个单位,导致N要向后移动2倍的N才能将与M的间距扩大为N
if (iNVal > iEAmount)
{
break;
}
}
*/
pSptRecord = NULL;
pSptRecord = new CSptRecord;
if (NULL != pSptRecord)
{
pSptRecord->m_iC1 = iBVal;
pSptRecord->m_iP2 = iNVal;
pSptRecord->m_iC2 = iAVal;
pSptRecord->m_iP1 = iMVal;
pSptRecord->m_iTsn = ++iTsn;
pSptRecord->m_fK = CalculateSptKVal(iAVal,iBVal,iMVal, iNVal);
pSptRecord->m_iLevel = CalculateSptLevel(iMBVal, iMMVal);
pSptRecord->m_iPtNum = iBVal;
pSptRecord->m_colorREF = RGB(0, 255, 0);
pSptRecord->m_bIsSel = TRUE;
pSptRecord->m_iN = (int)VAL_ONE;
CalculateSptPtLoc(2, pSptRecord);
pSptRecArray->Add(pSptRecord);
if (pSptRecord->m_iLevel > iMaxLevel)
{
iMaxLevel = pSptRecord->m_iLevel;
}
}
}
}
*pMaxLevel = iMaxLevel;
*pPtAmount = pSptRecArray->GetSize();
return true;
}
void CMediumZC::CalculateSptPtLoc(int iMul, //倍数---in
CSptRecord* pSptRecord //脚本记录指针---out
) //函数功能:计算脚本测点位置
{
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-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));
return;
}
int CMediumZC::GenSptRecLevel(int iA, int iB, int iM, int iN)
{
return iM-iA;
}
int CMediumZC::GenSptRecPosInLevel(int iA, int iB, int iM, int iN)
{
return (int)iA;
}
int CMediumZC::GetMaxLevelByEAmount(int iEAmount)
{
int iLayer = 0;
int iNPos = 0;
int iTmp = 0;
//在这里iTmp指的是BA的距离,而BA = MN
//每一层的第一个点都是从1开始
while(TRUE)
{
iLayer++;
iTmp = 1 + (iLayer-1)/6;
iNPos = 1 + iTmp + iLayer + iTmp;
if (iNPos > iEAmount)
{
break;
}
}
return iLayer -1;
}
float CMediumZC::CalculateDepth(float fA, float fFactor)
{
// return (float)(fabs(fA)*fFactor);
return (float)((fabs(fA)/0.5)*fFactor);
}
float CMediumZC::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fK = (float)VAL_ZERO;
fK = (float)(VAL_PI * fB * ((fB * fB) * (fA * fA) - 1));
return fK;
}
// float CMediumZC::CalculateSptKVal(int iM, int iN)
// {
// //iN:传进来M的位置
// //IM:传进来B的位置
//
// float fK = (float)VAL_ZERO;
// int n = iN - iM ;
// fK = (float)( VAL_PI * n * (n+1) * (n + 2) * 1 );
//
// return fK;
//}
float CMediumZC::CalculateSptKVal(int iA, int iB, int iM, int iN)
{
float fK = 0;
int a = iB - iA;
int na = iM - iB;
float n = na*1.0 / a;
fK = (float)( VAL_PI * n * (n+1) * (n + 2) * a );
return fK;
}
int CMediumZC::CalculateSptLevel(int iM, int iN)
{
return iN - iM;
}
void CMediumZC::ReSortPoint(CPtrArray *f_ptr)
{
return;
}
@@ -0,0 +1,133 @@
// MeidumBipoleUpHole.cpp: implementation of the CMeidumBipoleUpHole class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "MeidumBipoleUpHole.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern int g_iUILanguage;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMediumBipoleUpHole::CMediumBipoleUpHole(int iAR): CMedium(iAR)
{
m_iSurfaceElecNum = 0;
}
CMediumBipoleUpHole::~CMediumBipoleUpHole()
{
}
void CMediumBipoleUpHole::SetParamVal(const void* pVal)
{
m_iSurfaceElecNum = *((int*)pVal);
}
bool CMediumBipoleUpHole::GenerateSptRecElecVal(int iEAmount, int* pMaxLevel, int* pPtAmount, CPtrArray* pSptRecArray)
{
if (iEAmount < 4)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("双极电极的数目是误差的。"));
else
MessageBoxEx(NULL, _T("The number of electrode in BipoleUpHole is error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
if (m_iSurfaceElecNum < 2)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("地表电极数错误!"));
else
MessageBoxEx(NULL, _T("The number of surface electrode is error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
int iHoleElectNum = iEAmount - m_iSurfaceElecNum;
if (iHoleElectNum < 2)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("井内电极数错误!"));
else
MessageBoxEx(NULL, _T("The number of hole electrode 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();
//装置的位置顺序为AMNB
int iC1Pos = 0, iC2Pos = 1,iP1Pos = 0,iP2Pos = 2;
int iTsn = 0, iElecSpace = 1;
CSptRecord *pSptRec = NULL;
//此时固定A的位置不动,B点向右移动,然后M从2开始往右移动,MN的间距始终为1
while((1 + iElecSpace) <= m_iSurfaceElecNum)
{
iC2Pos = 1;
iP2Pos = iC2Pos + iElecSpace;
while(true)
{
if (iP2Pos > m_iSurfaceElecNum)
{
break;
}
iC1Pos = m_iSurfaceElecNum+1;
iP1Pos = iC1Pos + iElecSpace;
for(; iP1Pos <= iEAmount; iP1Pos+=2)
{
iC1Pos = iP1Pos - iElecSpace;
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);
//由于不需要画剖面图,所以这里暂时对m_iPtNum赋值为0
pSptRec->m_iPtNum = 0;
// 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);
}
iC2Pos += 2;
iP2Pos += 2;
}
iElecSpace++;
}
*pPtAmount = pSptRecArray->GetSize();
*pMaxLevel = 0;
return true;
}
float CMediumBipoleUpHole::CalculateCESptKVal(float fA, float fB, float fX, float fY)
{
float fAM = fabs(fX - fA);
float fAN = sqrt(pow(fA-m_iSurfaceElecNum, 2) + pow(m_iSurfaceElecNum-fY, 2));
float fBM = sqrt(pow(fX-m_iSurfaceElecNum, 2) + pow(m_iSurfaceElecNum-fB, 2));
float fBN = fabs(fY - fB);
if (0 == fAM || 0 ==fAN || 0 == fBM || 0 == fBN)
{
return 0;
// AfxMessageBox(_T("Calcualte K value error.value = "))
}
return fabs(2*VAL_PI/(1.0/fAM - 1.0/fAN - 1.0/fBM + 1.0/fBN));
}
@@ -0,0 +1,80 @@
// Project.cpp: implementation of the CProject class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Project.h"
#include "DataMngStruct.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CProject::CProject(DWORD dwID, _ConnectionPtr& pConnection)
{
ASSERT(NULL != pConnection);
m_pConnection = pConnection;
CString szSql;
_RecordsetPtr pRecPro = NULL;
pRecPro.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select CN,PRname,PRdesc,location,Format(PRdate,'YYYY-MM-DD') as PRdate,duration,PS,CS,PM,QAS,standard from project where ID = %u"), dwID);
pRecPro->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecPro->GetRecordCount())
{
m_szCN = pRecPro->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("CN"));
m_szPRname = pRecPro->GetCollect(_T("PRname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRname"));
m_szDesc = pRecPro->GetCollect(_T("PRdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRdesc"));
m_szLocation = pRecPro->GetCollect(_T("location")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("location"));
m_szPRdate = pRecPro->GetCollect(_T("PRdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRdate"));
m_szDuration = pRecPro->GetCollect(_T("duration")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("duration"));
m_szPS = pRecPro->GetCollect(_T("PS")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PS"));
m_szCS = pRecPro->GetCollect(_T("CS")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("CS"));
m_szPM = pRecPro->GetCollect(_T("PM")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PM"));
m_szQAS = pRecPro->GetCollect(_T("QAS")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("QAS"));
m_szStandard = pRecPro->GetCollect(_T("standard")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("standard"));
}
pRecPro->Close();
m_dwID = m_dwID;
}
CProject::~CProject()
{
}
bool CProject::ShowDetailInfo(CListCtrl& proDetailList)
{
int iRowIndex = (int)VAL_ZERO;
while (proDetailList.GetItemCount() != iRowIndex)
{
proDetailList.SetItemText(iRowIndex, 1, _T(""));
iRowIndex++;
}
proDetailList.SetItemText(0, 1, m_szCN);
proDetailList.SetItemText(1, 1, m_szPRname);
proDetailList.SetItemText(2, 1, m_szDesc);
proDetailList.SetItemText(3, 1, m_szLocation);
proDetailList.SetItemText(4, 1, m_szPRdate);
proDetailList.SetItemText(5, 1, m_szDuration);
proDetailList.SetItemText(6, 1, m_szPS);
proDetailList.SetItemText(7, 1, m_szCS);
proDetailList.SetItemText(8, 1, m_szPM);
// proDetailList.SetItemText(9, 1, m_szQAS);
proDetailList.SetItemText(9, 1, m_szStandard);
return true;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,101 @@
// RSP2DTdRecord.cpp: implementation of the CRSP2DTdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "RSP2DTdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRsp2DTdRecord::CRsp2DTdRecord(DWORD dwChID, _ConnectionPtr& pConnection):CTdRecord(pConnection)
{
m_dwChID = dwChID;
m_iTsn = (int)VAL_ZERO;
m_iC1 = (int)VAL_ZERO;
m_iC2 = (int)VAL_ZERO;
m_iP1 = (int)VAL_ZERO;
m_iP2 = (int)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_iLevel = (int)VAL_ZERO;
m_iPosInLevel = (int)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
m_recPtArea.SetRectEmpty();
}
CRsp2DTdRecord::~CRsp2DTdRecord()
{
}
void CRsp2DTdRecord::ClearAll()
{
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
}
BOOL CRsp2DTdRecord::SaveData(DWORD dwChID)
{
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
m_dwChID = dwChID;
szSql.Empty();
szSql.Format(_T("insert into td2dcon(TCHID,TSN,C1,C2,P1,P2,N,K,I,V,R0,SP,bUse) values(%u,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f,%d)"),
m_dwChID,
this->m_iTsn,
this->m_iC1,
this->m_iC2,
this->m_iP1,
this->m_iP2,
this->m_iN,
this->m_fK,
this->m_fI,
this->m_fV,
this->m_fR0,
this->m_fSP,
TRUE);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
BOOL CRsp2DTdRecord::LoadOrgData()
{
// AfxMessageBox(_T("CRsp2DTdRecord::LoadOrgData"));
this->Load2DOrgData();
return TRUE;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,106 @@
// RspCETdRecord.cpp: implementation of the CRspCETdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "RspCETdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRspCETdRecord::CRspCETdRecord(DWORD dwChID, _ConnectionPtr& pConnection):CTdRecord(pConnection)
{
m_dwChID = dwChID;
m_iTsn = (int)VAL_ZERO;
m_fA = (float)VAL_ZERO;
m_fB = (float)VAL_ZERO;
m_fX = (float)VAL_ZERO;
m_fY = (float)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_fDepth = (float)VAL_ZERO;
m_iPosInLevel = (int)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
m_recPtArea.SetRectEmpty();
}
CRspCETdRecord::~CRspCETdRecord()
{
}
BOOL CRspCETdRecord::SaveData(DWORD dwChID)
{
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
if (((float)VAL_ZERO != this->m_fI) || ((float)VAL_ZERO != this->m_fV) && ((float)VAL_ZERO != this->m_fR0) && ((float)VAL_ZERO != this->m_fSP))
{
m_dwChID = dwChID;
szSql.Empty();
szSql.Format(_T("insert into td1dcon(TCHID,TSN,a,b,x,y,N,K,I,V,R0,SP,bUse,dt) values(%u,%d,%.1f,%.1f,%.1f,%.1f,%d,%f,%f,%f,%f,%f,%d,#%s#)"),
m_dwChID,
this->m_iTsn,
this->m_fA,
this->m_fB,
this->m_fX,
this->m_fY,
this->m_iN,
this->m_fK,
this->m_fI,
this->m_fV,
this->m_fR0,
this->m_fSP,
TRUE,
this->m_Datetime);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
}
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
void CRspCETdRecord::ClearAll()
{
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
}
BOOL CRspCETdRecord::LoadOrgData()
{
// AfxMessageBox(_T("CRspCETdRecord::LoadOrgData"));
this->LoadCEOrgData();
return TRUE;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,97 @@
// SP2DTdRecord.cpp: implementation of the CSP2DTdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "SP2DTdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSP2DTdRecord::CSP2DTdRecord(DWORD dwChID, _ConnectionPtr& pConnection):CTdRecord(pConnection)
{
m_dwChID = dwChID;
m_iTsn = (int)VAL_ZERO;
m_iC1 = (int)VAL_ZERO;
m_iC2 = (int)VAL_ZERO;
m_iP1 = (int)VAL_ZERO;
m_iP2 = (int)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_iLevel = (int)VAL_ZERO;
m_iPosInLevel = (int)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
m_recPtArea.SetRectEmpty();
}
CSP2DTdRecord::~CSP2DTdRecord()
{
}
void CSP2DTdRecord::ClearAll()
{
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
}
BOOL CSP2DTdRecord::SaveData(DWORD dwChID)
{
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
m_dwChID = dwChID;
szSql.Empty();
szSql.Format(_T("insert into td2dcon(TCHID,TSN,C1,C2,P1,P2,N,K,I,V,R0,SP) values(%u,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f)"),
m_dwChID,
this->m_iTsn,
this->m_iC1,
this->m_iC2,
this->m_iP1,
this->m_iP2,
this->m_iN,
this->m_fK,
this->m_fI,
this->m_fV,
this->m_fR0,
this->m_fSP);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
BOOL CSP2DTdRecord::LoadOrgData()
{
// AfxMessageBox(_T("CRsp2DTdRecord::LoadOrgData"));
this->Load2DOrgData();
return TRUE;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,98 @@
// SP3DTdRecord.cpp: implementation of the CSP3DTdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "SP3DTdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSP3DTdRecord::CSP3DTdRecord(DWORD dwChID, _ConnectionPtr& pConnection):CTdRecord(pConnection)
{
m_dwChID = dwChID;
m_iTsn = (int)VAL_ZERO;
m_iC1 = (int)VAL_ZERO;
m_iC2 = (int)VAL_ZERO;
m_iP1 = (int)VAL_ZERO;
m_iP2 = (int)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_iLevel = (int)VAL_ZERO;
m_iPosInLevel = (int)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
m_recPtArea.SetRectEmpty();
}
CSP3DTdRecord::~CSP3DTdRecord()
{
}
void CSP3DTdRecord::ClearAll()
{
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
}
BOOL CSP3DTdRecord::SaveData(DWORD dwChID)
{
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
m_dwChID = dwChID;
szSql.Empty();
szSql.Format(_T("insert into td3dcon(TCHID,TSN,C1,C2,P1,P2,N,K,I,V,R0,SP) values(%u,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f)"),
m_dwChID,
this->m_iTsn,
this->m_iC1,
this->m_iC2,
this->m_iP1,
this->m_iP2,
this->m_iN,
this->m_fK,
this->m_fI,
this->m_fV,
this->m_fR0,
this->m_fSP);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
BOOL CSP3DTdRecord::LoadOrgData()
{
// AfxMessageBox(_T("CRsp3DTdRecord::LoadOrgData"));
this->Load3DOrgData();
return TRUE;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,103 @@
// SPCETdRecord.cpp: implementation of the CSPCETdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "SPCETdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSPCETdRecord::CSPCETdRecord(DWORD dwChID, _ConnectionPtr& pConnection):CTdRecord(pConnection)
{
m_dwChID = dwChID;
m_iTsn = (int)VAL_ZERO;
m_fA = (float)VAL_ZERO;
m_fB = (float)VAL_ZERO;
m_fX = (float)VAL_ZERO;
m_fY = (float)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_fDepth = (float)VAL_ZERO;
m_iPosInLevel = (int)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
m_recPtArea.SetRectEmpty();
}
CSPCETdRecord::~CSPCETdRecord()
{
}
BOOL CSPCETdRecord::SaveData(DWORD dwChID)
{
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
if (((float)VAL_ZERO != this->m_fI) || ((float)VAL_ZERO != this->m_fV) && ((float)VAL_ZERO != this->m_fR0) && ((float)VAL_ZERO != this->m_fSP))
{
m_dwChID = dwChID;
szSql.Empty();
szSql.Format(_T("insert into td1dcon(TCHID,TSN,a,b,x,y,N,K,I,V,R0,SP) values(%u,%d,%.1f,%.1f,%.1f,%.1f,%d,%f,%f,%f,%f,%f)"),
m_dwChID,
this->m_iTsn,
this->m_fA,
this->m_fB,
this->m_fX,
this->m_fY,
this->m_iN,
this->m_fK,
this->m_fI,
this->m_fV,
this->m_fR0,
this->m_fSP);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
}
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
void CSPCETdRecord::ClearAll()
{
m_fI = (float)VAL_ZERO;
m_fV = (float)VAL_ZERO;
m_fR0 = (float)VAL_ZERO;
m_fSP = (float)VAL_ZERO;
m_colorREF = RGB(0xFF,0xFF,0xFF);
}
BOOL CSPCETdRecord::LoadOrgData()
{
// AfxMessageBox(_T("CRspCETdRecord::LoadOrgData"));
this->LoadCEOrgData();
return TRUE;
}
@@ -0,0 +1,29 @@
// Script.cpp: implementation of the CScript class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Script.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CScript::CScript(DWORD dwID, _ConnectionPtr& pConnection)
{
m_dwID = dwID;
m_pConnection = pConnection;
m_iAR = 0;
m_iEAmount = (int)VAL_ZERO;
}
CScript::~CScript()
{
}
@@ -0,0 +1,237 @@
// Script.cpp: implementation of the CScript2D class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Script2D.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CScript2D::CScript2D(DWORD dwID, _ConnectionPtr& pConnection): CScript(dwID, pConnection)
{
m_iAR = 0;
}
CScript2D::~CScript2D()
{
}
bool CScript2D::ShowSptDetailInfo(CListCtrl &sptDetailList)
{
_RecordsetPtr pRecSCon = NULL;
_RecordsetPtr pRecSHead = NULL;
_RecordsetPtr pRecMed = NULL;
_RecordsetPtr pRecCm = NULL;
CString szSql = _T("");
CString szLabel = _T("");
int iRowIndex = (int)VAL_ZERO;
pRecSCon.CreateInstance(_uuidof(Recordset));
pRecSHead.CreateInstance(_uuidof(Recordset));
pRecMed.CreateInstance(_uuidof(Recordset));
pRecCm.CreateInstance(_uuidof(Recordset));
while (sptDetailList.GetItemCount() != iRowIndex)
{
sptDetailList.SetItemText(iRowIndex, 1, _T(""));
iRowIndex++;
}
szSql.Empty();
szSql.Format(_T("select CN,Sname,Eamount,CHamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc from scon where ID = %u"), m_dwID);
pRecSCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecSCon->GetRecordCount())
{
sptDetailList.SetItemText(0, 1, pRecSCon->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN")));
sptDetailList.SetItemText(1, 1, pRecSCon->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
sptDetailList.SetItemText(2, 1, pRecSCon->GetCollect(_T("Eamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Eamount")));
sptDetailList.SetItemText(3, 1, pRecSCon->GetCollect(_T("CHamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CHamount")));
sptDetailList.SetItemText(4, 1, pRecSCon->GetCollect(_T("TPamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("TPamount")));
sptDetailList.SetItemText(5, 1, pRecSCon->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
sptDetailList.SetItemText(6, 1, pRecSCon->GetCollect(_T("DEdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
sptDetailList.SetItemText(7, 1, pRecSCon->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("SCdesc")));
}
pRecSCon->Close();
return true;
}
bool CScript2D::ShowChannelList(CListCtrl &sptChannelList)
{
_RecordsetPtr pRecCh = NULL;
_RecordsetPtr pRecMed = NULL;
CString szSql = _T("");
int iIndex = (int)VAL_ZERO;
DWORD dwHandle = (DWORD)VAL_ZERO;
pRecCh.CreateInstance(_uuidof(Recordset));
pRecMed.CreateInstance(_uuidof(Recordset));
if ((int)VAL_ZERO != sptChannelList.GetItemCount())
{
sptChannelList.DeleteAllItems();
}
szSql.Empty();
szSql.Format(_T("select a.ID as ID,a.CHnumber as CHnumber,b.MEname as MEname, a.AR as AR from channel a,medium b where a.SCID = %d and a.AR = b.AR and b.LANG = %d order by a.CHnumber"), m_dwID, LANG_ENUS);
pRecCh->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
while ((short)VAL_ZERO == pRecCh->adoEOF)
{
sptChannelList.InsertItem(iIndex, pRecCh->GetCollect(_T("CHnumber")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCh->GetCollect(_T("CHnumber")));
sptChannelList.SetItemText(iIndex, 1, pRecCh->GetCollect(_T("MEname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCh->GetCollect(_T("MEname")));
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecCh->GetCollect(_T("ID")).ulVal, PZ_STYLE_SPT_CH);
sptChannelList.SetItemData(iIndex, dwHandle);
//获取装置类型编号
m_iAR = pRecCh->GetCollect(_T("AR")).iVal;
iIndex++;
pRecCh->MoveNext();
}
pRecCh->Close();
return true;
}
bool CScript2D::ShowSptConInfo(CListCtrl &sptConList)
{
_RecordsetPtr pRecSptList = NULL;
CString szSql;
int iIndex = (int)VAL_ZERO;
pRecSptList.CreateInstance(_uuidof(Recordset));
if ((int)VAL_ZERO != sptConList.GetItemCount())
{
sptConList.DeleteAllItems();
}
szSql.Empty();
szSql.Format(_T("select b.CHnumber as CHnumber,a.TSN as TSN,a.C1 as C1,a.C2 as C2,a.P1 as P1,a.P2 as P2,a.K as K,a.N as N from script2d a,channel b "
"where b.SCID = %d and a.CHID = b.ID order by a.TSN,a.CHID"), m_dwID);
pRecSptList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
while ((short)VAL_ZERO == pRecSptList->adoEOF)
{
sptConList.InsertItem(iIndex, pRecSptList->GetCollect(_T("CHnumber")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CHnumber")));
sptConList.SetItemText(iIndex, 1, pRecSptList->GetCollect(_T("TSN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("TSN")));
sptConList.SetItemText(iIndex, 2, pRecSptList->GetCollect(_T("C1")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("C1")));
sptConList.SetItemText(iIndex, 3, pRecSptList->GetCollect(_T("C2")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("C2")));
sptConList.SetItemText(iIndex, 4, pRecSptList->GetCollect(_T("P1")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("P1")));
sptConList.SetItemText(iIndex, 5, pRecSptList->GetCollect(_T("P2")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("P2")));
sptConList.SetItemText(iIndex, 6, pRecSptList->GetCollect(_T("K")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("K")));
sptConList.SetItemText(iIndex, 7, pRecSptList->GetCollect(_T("N")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("N")));
//给每一行绑定一个唯一的数,这个数可以传到SortItems里面的对比函数作为lParam1和lParam2,分别用来代表不同的行
//否则如果不调用SetItemData,则lParam1和lParam2都会为0
sptConList.SetItemData(iIndex, (pRecSptList->GetCollect(_T("TSN")).vt == VT_NULL) ? 0 : (int)pRecSptList->GetCollect(_T("TSN")).iVal);
iIndex++;
pRecSptList->MoveNext();
}
pRecSptList->Close();
AdjustRecListColumn(m_iAR, sptConList);
return true;
}
void CScript2D::AdjustRecListColumn(int iAR, CListCtrl& sptConListInfo)
{
if (iAR < 1)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("解析设备数组类型错误"));
else
MessageBoxEx(NULL, _T("Parser device array type error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
std::vector<int> vtListOrder;
vtListOrder.clear();
switch (iAR)
{
case 1:
case 11:
case 4:
case 5:
case 6:
case AR_WENNER_SCH_BASIC:
case 39:
case 41:
vtListOrder.push_back(2);
vtListOrder.push_back(4);
vtListOrder.push_back(5);
vtListOrder.push_back(3);
break;
case 2:
case 9://wenner-beta和偶极-偶极为B\A\M\N
vtListOrder.push_back(3);
vtListOrder.push_back(2);
vtListOrder.push_back(4);
vtListOrder.push_back(5);
break;
case 3:
vtListOrder.push_back(2);
vtListOrder.push_back(4);
vtListOrder.push_back(3);
vtListOrder.push_back(5);
break;
case 42: //井地井装置顺序为B\N\A\M
vtListOrder.push_back(3);
vtListOrder.push_back(5);
vtListOrder.push_back(2);
vtListOrder.push_back(4);
break;
default:
vtListOrder.push_back(2);
vtListOrder.push_back(3);
vtListOrder.push_back(4);
vtListOrder.push_back(5);
break;
}
//根据vtListOrder来进行列的顺序的更改
CHeaderCtrl* pHeaderCtrl = sptConListInfo.GetHeaderCtrl();
if (pHeaderCtrl != NULL)
{
int nColumnCount = pHeaderCtrl->GetItemCount();
LPINT pnOrder = (LPINT) malloc(nColumnCount*sizeof(int));
ASSERT(pnOrder != NULL);
//获得列顺序到数组
sptConListInfo.GetColumnOrderArray(pnOrder, nColumnCount);
if (nColumnCount < 5)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("解析类别列错误"));
else
MessageBoxEx(NULL, _T("Parser list column error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
free(pnOrder);
return;
}
int temp ;
for (int i = 0; i < vtListOrder.size(); i++)
{
temp = vtListOrder[i];
pnOrder[i+2] =temp;
}
//设置列顺序
sptConListInfo.SetColumnOrderArray(nColumnCount, pnOrder);
free(pnOrder);
}
}
@@ -0,0 +1,221 @@
// Script3D.cpp: implementation of the CScript3D class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Script3D.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CScript3D::CScript3D(DWORD dwID, _ConnectionPtr& pConnection): CScript(dwID, pConnection)
{
m_iAR = 0;
}
CScript3D::~CScript3D()
{
}
bool CScript3D::ShowChannelList(CListCtrl& sptChannelList)
{
_RecordsetPtr pRecCh = NULL;
_RecordsetPtr pRecMed = NULL;
CString szSql = _T("");
int iIndex = (int)VAL_ZERO;
DWORD dwHandle = (DWORD)VAL_ZERO;
pRecCh.CreateInstance(_uuidof(Recordset));
pRecMed.CreateInstance(_uuidof(Recordset));
if ((int)VAL_ZERO != sptChannelList.GetItemCount())
{
sptChannelList.DeleteAllItems();
}
szSql.Empty();
szSql.Format(_T("select a.ID as ID,a.CHnumber as CHnumber,b.MEname as MEname,a.AR as AR from channel a,medium b where a.SCID = %d and a.AR = b.AR and b.LANG = %d order by a.CHnumber"), m_dwID, LANG_ENUS);
pRecCh->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
while ((short)VAL_ZERO == pRecCh->adoEOF)
{
sptChannelList.InsertItem(iIndex, pRecCh->GetCollect(_T("CHnumber")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCh->GetCollect(_T("CHnumber")));
sptChannelList.SetItemText(iIndex, 1, pRecCh->GetCollect(_T("MEname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCh->GetCollect(_T("MEname")));
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecCh->GetCollect(_T("ID")).ulVal, PZ_STYLE_SPT_CH);
sptChannelList.SetItemData(iIndex, dwHandle);
m_iAR = pRecCh->GetCollect(_T("AR")).iVal;
iIndex++;
pRecCh->MoveNext();
}
pRecCh->Close();
return true;
}
bool CScript3D::ShowSptConInfo(CListCtrl& sptConList)
{
_RecordsetPtr pRecSptList = NULL;
CString szSql;
int iIndex = (int)VAL_ZERO;
pRecSptList.CreateInstance(_uuidof(Recordset));
if ((int)VAL_ZERO != sptConList.GetItemCount())
{
sptConList.DeleteAllItems();
}
szSql.Empty();
szSql.Format(_T("select b.CHnumber as CHnumber,a.TSN as TSN,a.C1 as C1,a.C2 as C2,a.P1 as P1,a.P2 as P2,a.K as K,a.N as N from script3d a,channel b "
"where b.SCID = %d and a.CHID = b.ID order by a.TSN,a.CHID"), m_dwID);
pRecSptList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
while ((short)VAL_ZERO == pRecSptList->adoEOF)
{
sptConList.InsertItem(iIndex, pRecSptList->GetCollect(_T("CHnumber")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CHnumber")));
sptConList.SetItemText(iIndex, 1, pRecSptList->GetCollect(_T("TSN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("TSN")));
sptConList.SetItemText(iIndex, 2, pRecSptList->GetCollect(_T("C1")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("C1")));
sptConList.SetItemText(iIndex, 3, pRecSptList->GetCollect(_T("C2")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("C2")));
sptConList.SetItemText(iIndex, 4, pRecSptList->GetCollect(_T("P1")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("P1")));
sptConList.SetItemText(iIndex, 5, pRecSptList->GetCollect(_T("P2")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("P2")));
sptConList.SetItemText(iIndex, 6, pRecSptList->GetCollect(_T("K")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("K")));
sptConList.SetItemText(iIndex, 7, pRecSptList->GetCollect(_T("N")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("N")));
//给每一行绑定一个唯一的数,这个数可以传到SortItems里面的对比函数作为lParam1和lParam2,分别用来代表不同的行
//否则如果不调用SetItemData,则lParam1和lParam2都会为0
sptConList.SetItemData(iIndex, (pRecSptList->GetCollect(_T("TSN")).vt == VT_NULL) ? 0 : (int)pRecSptList->GetCollect(_T("TSN")).iVal);
iIndex++;
pRecSptList->MoveNext();
}
pRecSptList->Close();
AdjustRecListColumn(m_iAR, sptConList);
return true;
}
bool CScript3D::ShowSptDetailInfo(CListCtrl &sptDetailList)
{
_RecordsetPtr pRecSCon = NULL;
_RecordsetPtr pRecSHead = NULL;
_RecordsetPtr pRecMed = NULL;
_RecordsetPtr pRecCm = NULL;
CString szSql = _T("");
CString szLabel = _T("");
int iRowIndex = (int)VAL_ZERO;
pRecSCon.CreateInstance(_uuidof(Recordset));
pRecSHead.CreateInstance(_uuidof(Recordset));
pRecMed.CreateInstance(_uuidof(Recordset));
pRecCm.CreateInstance(_uuidof(Recordset));
while (sptDetailList.GetItemCount() != iRowIndex)
{
sptDetailList.SetItemText(iRowIndex, 1, _T(""));
iRowIndex++;
}
szSql.Empty();
szSql.Format(_T("select CN,Sname,Eamount,CHamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc from scon where ID = %u"), m_dwID);
pRecSCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecSCon->GetRecordCount())
{
sptDetailList.SetItemText(0, 1, pRecSCon->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN")));
sptDetailList.SetItemText(1, 1, pRecSCon->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
sptDetailList.SetItemText(2, 1, pRecSCon->GetCollect(_T("Eamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Eamount")));
sptDetailList.SetItemText(3, 1, pRecSCon->GetCollect(_T("CHamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CHamount")));
sptDetailList.SetItemText(4, 1, pRecSCon->GetCollect(_T("TPamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("TPamount")));
sptDetailList.SetItemText(5, 1, pRecSCon->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
sptDetailList.SetItemText(6, 1, pRecSCon->GetCollect(_T("DEdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
sptDetailList.SetItemText(7, 1, pRecSCon->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("SCdesc")));
}
pRecSCon->Close();
return true;
}
void CScript3D::AdjustRecListColumn(int iAR, CListCtrl& sptConListInfo)
{
if (iAR < 1)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("解析设备数组类型错误"));
else
MessageBoxEx(NULL, _T("Parser device array type error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
std::vector<int> vtListOrder;
vtListOrder.clear();
switch (iAR)
{
case 22:
case 23:
case 25:
case 26:
vtListOrder.push_back(2);
vtListOrder.push_back(4);
vtListOrder.push_back(5);
vtListOrder.push_back(3);
break;
case 24:
case 27:
vtListOrder.push_back(3);
vtListOrder.push_back(2);
vtListOrder.push_back(4);
vtListOrder.push_back(5);
break;
default:
vtListOrder.push_back(2);
vtListOrder.push_back(3);
vtListOrder.push_back(4);
vtListOrder.push_back(5);
break;
}
//根据vtListOrder来进行列的顺序的更改
CHeaderCtrl* pHeaderCtrl = sptConListInfo.GetHeaderCtrl();
if (pHeaderCtrl != NULL)
{
int nColumnCount = pHeaderCtrl->GetItemCount();
LPINT pnOrder = (LPINT) malloc(nColumnCount*sizeof(int));
ASSERT(pnOrder != NULL);
//获得列顺序到数组
sptConListInfo.GetColumnOrderArray(pnOrder, nColumnCount);
if (nColumnCount < 6)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("解析列表列错误"));
else
MessageBoxEx(NULL, _T("Parser list column error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
free(pnOrder);
return;
}
int temp ;
for (int i = 0; i < vtListOrder.size(); i++)
{
temp = vtListOrder[i];
pnOrder[i+2] =temp;
}
//设置列顺序
sptConListInfo.SetColumnOrderArray(nColumnCount, pnOrder);
free(pnOrder);
}
}
@@ -0,0 +1,145 @@
// ScriptCE.cpp: implementation of the CScriptCE class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "ScriptCE.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CScriptCE::CScriptCE(DWORD dwID, _ConnectionPtr& pConnection): CScript(dwID, pConnection)
{
}
CScriptCE::~CScriptCE()
{
}
bool CScriptCE::ShowSptConInfo(CListCtrl& sptConList)
{
_RecordsetPtr pRecSptList = NULL;
CString szSql;
int iIndex = (int)VAL_ZERO;
pRecSptList.CreateInstance(_uuidof(Recordset));
if ((int)VAL_ZERO != sptConList.GetItemCount())
{
sptConList.DeleteAllItems();
}
szSql.Empty();
szSql.Format(_T("select b.CHnumber as CHnumber,a.TSN as TSN,a.a as a,a.b as b,a.x as x,a.y as y,a.K as K,a.N as N from script1d a,channel b "
"where b.SCID = %d and a.CHID = b.ID order by a.TSN,a.CHID"), m_dwID);
pRecSptList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
while ((short)VAL_ZERO == pRecSptList->adoEOF)
{
sptConList.InsertItem(iIndex, pRecSptList->GetCollect(_T("CHnumber")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CHnumber")));
sptConList.SetItemText(iIndex, 1, pRecSptList->GetCollect(_T("TSN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("TSN")));
sptConList.SetItemText(iIndex, 2, pRecSptList->GetCollect(_T("a")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("a")));
sptConList.SetItemText(iIndex, 3, pRecSptList->GetCollect(_T("b")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("b")));
sptConList.SetItemText(iIndex, 4, pRecSptList->GetCollect(_T("x")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("x")));
sptConList.SetItemText(iIndex, 5, pRecSptList->GetCollect(_T("y")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("y")));
sptConList.SetItemText(iIndex, 6, pRecSptList->GetCollect(_T("K")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("K")));
sptConList.SetItemText(iIndex, 7, pRecSptList->GetCollect(_T("N")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("N")));
iIndex++;
pRecSptList->MoveNext();
}
pRecSptList->Close();
return true;
}
bool CScriptCE::ShowSptDetailInfo(CListCtrl& sptDetailList)
{
_RecordsetPtr pRecSCon = NULL;
_RecordsetPtr pRecSHead = NULL;
_RecordsetPtr pRecMed = NULL;
_RecordsetPtr pRecCm = NULL;
CString szSql = _T("");
CString szLabel = _T("");
int iRowIndex = (int)VAL_ZERO;
pRecSCon.CreateInstance(_uuidof(Recordset));
pRecSHead.CreateInstance(_uuidof(Recordset));
pRecMed.CreateInstance(_uuidof(Recordset));
pRecCm.CreateInstance(_uuidof(Recordset));
while (sptDetailList.GetItemCount() != iRowIndex)
{
sptDetailList.SetItemText(iRowIndex, 1, _T(""));
iRowIndex++;
}
szSql.Empty();
szSql.Format(_T("select CN,Sname,Eamount,CHamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc from scon where ID = %u"), m_dwID);
pRecSCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecSCon->GetRecordCount())
{
sptDetailList.SetItemText(0, 1, pRecSCon->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN")));
sptDetailList.SetItemText(1, 1, pRecSCon->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
sptDetailList.SetItemText(2, 1, pRecSCon->GetCollect(_T("Eamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Eamount")));
sptDetailList.SetItemText(3, 1, pRecSCon->GetCollect(_T("CHamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CHamount")));
sptDetailList.SetItemText(4, 1, pRecSCon->GetCollect(_T("TPamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("TPamount")));
sptDetailList.SetItemText(5, 1, pRecSCon->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
sptDetailList.SetItemText(6, 1, pRecSCon->GetCollect(_T("DEdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
sptDetailList.SetItemText(7, 1, pRecSCon->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("SCdesc")));
}
pRecSCon->Close();
return true;
}
bool CScriptCE::ShowChannelList(CListCtrl& sptChannelList)
{
_RecordsetPtr pRecCh = NULL;
_RecordsetPtr pRecMed = NULL;
CString szSql = _T("");
int iIndex = (int)VAL_ZERO;
DWORD dwHandle = (DWORD)VAL_ZERO;
pRecCh.CreateInstance(_uuidof(Recordset));
pRecMed.CreateInstance(_uuidof(Recordset));
if ((int)VAL_ZERO != sptChannelList.GetItemCount())
{
sptChannelList.DeleteAllItems();
}
szSql.Empty();
szSql.Format(_T("select a.ID as ID,a.CHnumber as CHnumber,b.MEname as MEname from channel a,medium b where a.SCID = %d and a.AR = b.AR and b.LANG = %d order by a.CHnumber"), m_dwID, LANG_ENUS);
pRecCh->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
while ((short)VAL_ZERO == pRecCh->adoEOF)
{
sptChannelList.InsertItem(iIndex, pRecCh->GetCollect(_T("CHnumber")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCh->GetCollect(_T("CHnumber")));
sptChannelList.SetItemText(iIndex, 1, pRecCh->GetCollect(_T("MEname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCh->GetCollect(_T("MEname")));
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecCh->GetCollect(_T("ID")).ulVal, PZ_STYLE_SPT_CH);
sptChannelList.SetItemData(iIndex, dwHandle);
iIndex++;
pRecCh->MoveNext();
}
pRecCh->Close();
return true;
}
@@ -0,0 +1,186 @@
// Scriptor3D.cpp: implementation of the Scriptor3D class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "Scriptor3D.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Scriptor3D::Scriptor3D()
{
}
Scriptor3D::~Scriptor3D()
{
}
void Scriptor3D::create(const char *name, int flags)
{
m_rect.x0 = 1;
m_rect.y0 = 1;
m_rect.x1 = 12;
m_rect.y1 = 12;
m_scr = scr_create(name,ONLY_45DIAGONAL, &m_rect, 0, 0);
}
void Scriptor3D::SetRect(int x0, int y0, int x1, int y1)
{
rect_init(&m_rect, x0, y0, x1, y1);
scr_set_rect(m_scr, &m_rect);
}
void Scriptor3D::set_zone(bool enable, int zonec, int *zonev)
{
scr_set_zone(m_scr, enable, zonec, zonev);
}
BOOL Scriptor3D::generate()
{
return scr_generate(m_scr);
}
struct _rect * Scriptor3D::get_rect()
{
return scr_get_rect(m_scr);
}
int Scriptor3D::get_pole_count()
{
return scr_get_pole_count(m_scr);
}
BOOL Scriptor3D::set_pole_start(int startpole)
{
return scr_set_pole_start(m_scr, startpole);
}
int Scriptor3D::get_pole_start()
{
return scr_get_pole_start(m_scr);
}
void Scriptor3D::destroy()
{
scr_destroy(m_scr);
}
struct _point * Scriptor3D::get_points()
{
return scr_get_points(m_scr);
}
void Scriptor3D::_save_scr()
{
struct _rect rect = { 1, 1, 12, 12 };
struct _rect *r;
struct _point *node, *head = NULL;
int length;
FILE *fd;
char *buf = NULL;
if (!m_scr)
return;
head = scr_get_points(m_scr);
if (!head)
goto __exit;
buf = new char[512];
if (!buf)
{
printf("buffer alloc failed!\n");
goto __exit;
}
/* 只写 & 创建 打开 */
{
r = scr_get_rect(m_scr);
_snprintf(buf, 512, "disk/sd/%s(%d,%d,%d,%d).scr",
scr_get_name(m_scr),
r->x0, r->y0, r->x1, r->y1);
fd = fopen(buf, "wb+");
}
if (fd < 0)
{
printf("open \"%s\" for write failed!\n", scr_get_name(m_scr));
goto __exit;
}
{
time_t now;
struct tm *ptm;
time(&now);
ptm = localtime(&now); //取得当地时间
r = scr_get_rect(m_scr);
length = _snprintf(buf, 512, "<?xml version = \"1.0\" encoding = \"ansi\" ?>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "<script>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<cn>%s</cn>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<name>%s</name>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<type>%d</type>\r\n", scr_get_type(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<description>%s</description>\r\n", scr_get_name(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<definer>jimmy.lee</definer>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<date>%04d-%02d-%02d</date>\r\n", (1900 + ptm->tm_year), (1 + ptm->tm_mon), ptm->tm_mday);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_count>%d</pole_count>\r\n", scr_get_pole_count(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<pole_start>%d</pole_start>\r\n", scr_get_pole_start(m_scr));
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<rect>%d, %d, %d, %d</rect>\r\n", r->x0, r->y0, r->x1, r->y1);
length = _snprintf(buf, 512, "\t<channel_count>1</channel_count>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t<ar>1:1</ar>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t</channel>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t<layout>\r\n");
fwrite(buf, 1, length, fd);
}
for (node = head; node;)
{
length = _snprintf(buf, 512, "\t\t<array tsn = \"%d\" ch = \"1\" c1 = \"%d\" c2 = \"%d\" n = \"1\">\r\n", node->TSN, node->A, node->B);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t\t<ch n=\"1\" ks=\"%f\">%d, %d</ch>\r\n", node->KS, node->M, node->N);
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "\t\t</array>\r\n");
fwrite(buf, 1, length, fd);
if (node->next == head)
break;
node = node->next;
}
length = _snprintf(buf, 512, "\t</layout>\r\n");
fwrite(buf, 1, length, fd);
length = _snprintf(buf, 512, "</script>\r\n");
fwrite(buf, 1, length, fd);
__exit:
if (fd >= 0)
fclose(fd);
if (buf)
delete buf;
return;
}
@@ -0,0 +1,396 @@
// SptPtSort.cpp: implementation of the CSptPtSort class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "SptPtSort.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSptPtSort::CSptPtSort()
{
}
CSptPtSort::~CSptPtSort()
{
}
bool CSptPtSort::MultiChannlePtSortForMNB(CPtrArray* pSptPtArray)
{
if (NULL == pSptPtArray)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("pSptPtArray不能为空"));
else
MessageBoxEx(NULL, _T("pSptPtArray can not be null."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
m_mapSptKey.clear();
STSptPtSubKetVt sptKeyInfoVt;
int iSize = pSptPtArray->GetSize();
CSptRecord *pSptRecord = NULL;
std::map<int, STSptPtSubKetVt>::iterator iter;
STSptPtSubKetVt stSptPtVt;
//首先构建MAP表
int i = 0;
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord*)pSptPtArray->GetAt(i);
if (pSptRecord == NULL)
continue;
//int iATmp = (pSptRecord->m_iC1 < 1) ? 0 : pSptRecord->m_iC1;
//int iAB = ((iATmp << 16) | (WORD)(pSptRecord->m_iC2));
iter = m_mapSptKey.find(pSptRecord->m_iTsn);
STSptPtSubKeyInfo stSubKeyInfo;
stSubKeyInfo.iPosIndex = i;
stSubKeyInfo.wMPt = pSptRecord->m_iP1;
stSubKeyInfo.wNPt = pSptRecord->m_iP2;
stSubKeyInfo.bIsFind = false;
//如果查找到
if (iter != m_mapSptKey.end())
{
iter->second.mapSptSubkeyInfo[pSptRecord->m_iP1] = stSubKeyInfo;
}
//如果没有查找到则将新的点作为节点插入
else
{
stSptPtVt.ClearContent();
stSptPtVt.mapSptSubkeyInfo[pSptRecord->m_iP1] = stSubKeyInfo;
m_mapSptKey[pSptRecord->m_iTsn] = stSptPtVt;
}
}
CPtrArray sortPtrArr;
sortPtrArr.RemoveAll();
iter = m_mapSptKey.begin();
//开始遍历整个MAP表,获取排序后的
for (; iter != m_mapSptKey.end(); iter++)
{
int iFindCnt = 1;
std::map<int, STSptPtSubKeyInfo>::iterator subIter = iter->second.mapSptSubkeyInfo.begin();
sortPtrArr.Add(pSptPtArray->GetAt(subIter->second.iPosIndex));
int iSize = iter->second.mapSptSubkeyInfo.size();
subIter->second.bIsFind = true;
int iN = subIter->second.wNPt;
std::map<int, STSptPtSubKeyInfo>::iterator iterLastMinM = subIter;
while (iFindCnt < iSize)
{
subIter = iter->second.mapSptSubkeyInfo.find(iN);
//用此时的N去查找,如果查找到,则直接用该值作为下一个MN的位置
if (subIter != iter->second.mapSptSubkeyInfo.end())
{
sortPtrArr.Add(pSptPtArray->GetAt(subIter->second.iPosIndex));
iN = subIter->second.wNPt;
subIter->second.bIsFind = true;
}
else
{
while (iterLastMinM != iter->second.mapSptSubkeyInfo.end())
{
iterLastMinM++;
//如果没有被使用
if (false == iterLastMinM->second.bIsFind)
{
iterLastMinM->second.bIsFind = true;
sortPtrArr.Add(pSptPtArray->GetAt(iterLastMinM->second.iPosIndex));
iN = iterLastMinM->second.wNPt;
break;
}
}
}
iFindCnt++;
}
}
//开始将排序好的链表代替原有的
if (iSize != sortPtrArr.GetSize())
{
CString strErr = _T("");
if (LANG_ZHCN == g_iUILanguage)
{
strErr.Format(_T("多通道错误的排序点。初始大小= %d,排序大小= %d"), iSize, sortPtrArr.GetSize());
AfxMessageBox(strErr);
}
else
{
strErr.Format(_T("Sort point of multi-channel error.orginal size = %d, sort size = %d"), iSize, sortPtrArr.GetSize());
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return false;
}
pSptPtArray->RemoveAll();
int iTsn = 0;
CString strLog;
strLog.Format(_T("\n\nCSptPtSort::MultiChannlePtSortForMNB 测点排序----------------begin---\n"));
OutputDebugString(strLog);
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord*)sortPtrArr.GetAt(i);
pSptRecord->m_iTsn = ++iTsn;
strLog.Format(_T("CSptPtSort::MultiChannlePtSortForMNB Tsn=%d,A=%d,M=%d,N=%d,B=%d,k=%d,n=%d,level=%d\n"),
pSptRecord->m_iTsn, pSptRecord->m_iC1, pSptRecord->m_iP1, pSptRecord->m_iP2,
pSptRecord->m_iC2, pSptRecord->m_fK, pSptRecord->m_iN, pSptRecord->m_iLevel);
OutputDebugString(strLog);
pSptPtArray->Add(pSptRecord);
}
strLog.Format(_T("CSptPtSort::MultiChannlePtSortForMNB 测点排序----------------end---\n\n"));
OutputDebugString(strLog);
return true;
}
bool CSptPtSort::MultiChannlePtSort(CPtrArray* pSptPtArray)
{
if (NULL == pSptPtArray)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("pSptPtArray不能为空"));
else
MessageBoxEx(NULL, _T("pSptPtArray can not be null."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
m_mapSptKey.clear();
STSptPtSubKetVt sptKeyInfoVt;
int iSize = pSptPtArray->GetSize();
CSptRecord *pSptRecord = NULL;
std::map<int,STSptPtSubKetVt>::iterator iter;
STSptPtSubKetVt stSptPtVt;
//首先构建MAP表
int i = 0;
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord*)pSptPtArray->GetAt(i);
int iATmp = (pSptRecord->m_iC1 < 1 ) ? 0 : pSptRecord->m_iC1;
int iAB = ((iATmp << 16) | (WORD)(pSptRecord->m_iC2));
iter = m_mapSptKey.find(iAB);
STSptPtSubKeyInfo stSubKeyInfo;
stSubKeyInfo.iPosIndex = i;
stSubKeyInfo.wMPt = pSptRecord->m_iP1;
stSubKeyInfo.wNPt = pSptRecord->m_iP2;
stSubKeyInfo.bIsFind = false;
//如果查找到
if (iter != m_mapSptKey.end())
{
iter->second.mapSptSubkeyInfo[pSptRecord->m_iP1] = stSubKeyInfo;
}
//如果没有查找到则将新的点作为节点插入
else
{
stSptPtVt.ClearContent();
stSptPtVt.mapSptSubkeyInfo[pSptRecord->m_iP1] = stSubKeyInfo;
m_mapSptKey[iAB] = stSptPtVt;
}
}
CPtrArray sortPtrArr;
sortPtrArr.RemoveAll();
iter = m_mapSptKey.begin();
//开始遍历整个MAP表,获取排序后的
for (; iter != m_mapSptKey.end(); iter++)
{
int iFindCnt = 1;
std::map<int,STSptPtSubKeyInfo>::iterator subIter = iter->second.mapSptSubkeyInfo.begin();
sortPtrArr.Add(pSptPtArray->GetAt(subIter->second.iPosIndex));
int iSize = iter->second.mapSptSubkeyInfo.size();
subIter->second.bIsFind = true;
int iN = subIter->second.wNPt;
std::map<int,STSptPtSubKeyInfo>::iterator iterLastMinM = subIter;
while(iFindCnt < iSize)
{
subIter = iter->second.mapSptSubkeyInfo.find(iN);
//用此时的N去查找,如果查找到,则直接用该值作为下一个MN的位置
if (subIter != iter->second.mapSptSubkeyInfo.end())
{
sortPtrArr.Add(pSptPtArray->GetAt(subIter->second.iPosIndex));
iN = subIter->second.wNPt;
subIter->second.bIsFind = true;
}
else
{
while(iterLastMinM != iter->second.mapSptSubkeyInfo.end())
{
iterLastMinM++;
//如果没有被使用
if (false == iterLastMinM->second.bIsFind)
{
iterLastMinM->second.bIsFind = true;
sortPtrArr.Add(pSptPtArray->GetAt(iterLastMinM->second.iPosIndex));
iN = iterLastMinM->second.wNPt;
break;
}
}
}
iFindCnt++;
}
}
//开始将排序好的链表代替原有的
if (iSize != sortPtrArr.GetSize())
{
CString strErr = _T("");
if (LANG_ZHCN == g_iUILanguage)
{
strErr.Format(_T("多通道错误的排序点。初始大小= %d,排序大小= %d"), iSize, sortPtrArr.GetSize());
AfxMessageBox(strErr);
}
else
{
strErr.Format(_T("Sort point of multi-channel error.orginal size = %d, sort size = %d"), iSize, sortPtrArr.GetSize());
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return false;
}
pSptPtArray->RemoveAll();
int iTsn = 0;
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord*)sortPtrArr.GetAt(i);
pSptRecord->m_iTsn = ++iTsn;
pSptPtArray->Add(pSptRecord);
}
return true;
}
bool CSptPtSort::MultiChannlePtCplSort(CPtrArray* pSptPtArray)
{
if (NULL == pSptPtArray)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("pSptPtArray不能为空"));
else
MessageBoxEx(NULL, _T("pSptPtArray can not be null."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return false;
}
m_mapSptKey.clear();
STSptPtSubKetVt sptKeyInfoVt;
int iSize = pSptPtArray->GetSize();
CSptRecord *pSptRecord = NULL;
std::map<int,STSptPtSubKetVt>::iterator iter;
STSptPtSubKetVt stSptPtVt;
//首先构建MAP表
int i = 0;
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord*)pSptPtArray->GetAt(i);
int iATmp = (pSptRecord->m_iC1 < 1 ) ? 0 : pSptRecord->m_iC1;
int iAB = ((iATmp << 16) | (WORD)(pSptRecord->m_iC2));
iter = m_mapSptKey.find(iAB);
STSptPtSubKeyInfo stSubKeyInfo;
stSubKeyInfo.iPosIndex = i;
stSubKeyInfo.wMPt = pSptRecord->m_iP1;
stSubKeyInfo.wNPt = pSptRecord->m_iP2;
stSubKeyInfo.bIsFind = false;
std::map<int, STSptPtCplSubkeyInfo>::iterator iterCplSubKey;
//如果查找到AB
if (iter != m_mapSptKey.end())
{
//继续查找M
iterCplSubKey = iter->second.mapSptCplSubkey.find(stSubKeyInfo.wMPt);
//如果查找到M,则往同一个M的容器里插入
if (iterCplSubKey != iter->second.mapSptCplSubkey.end())
iterCplSubKey->second.vtSptSubkey.push_back(stSubKeyInfo);
else
{
STSptPtCplSubkeyInfo stCplSubKeyTmp;
stCplSubKeyTmp.vtSptSubkey.push_back(stSubKeyInfo);
iter->second.mapSptCplSubkey[stSubKeyInfo.wMPt] = stCplSubKeyTmp;
}
}
//如果没有查找到则将新的点作为节点插入
else
{
stSptPtVt.ClearContent();
STSptPtCplSubkeyInfo stCplSubKey;
stCplSubKey.vtSptSubkey.push_back(stSubKeyInfo);
stSptPtVt.mapSptCplSubkey[stSubKeyInfo.wMPt] = stCplSubKey;
m_mapSptKey[iAB] = stSptPtVt;
}
}
CPtrArray sortPtrArr;
sortPtrArr.RemoveAll();
iter = m_mapSptKey.begin();
//开始遍历整个MAP表,获取排序后的
for (; iter != m_mapSptKey.end(); iter++)
{
std::map<int,STSptPtCplSubkeyInfo>::iterator iterCplSubKey = iter->second.mapSptCplSubkey.begin();
for (; iterCplSubKey != iter->second.mapSptCplSubkey.end(); iterCplSubKey++)
{
//开始遍历同一个M值里的vector的循环
while(1)
{
int iIndex = iterCplSubKey->second.FindMinNPosIndex();
if (iIndex < 0)
{
break;
}
sortPtrArr.Add(pSptPtArray->GetAt(iterCplSubKey->second.vtSptSubkey[iIndex].iPosIndex));
WORD wNPos = iterCplSubKey->second.vtSptSubkey[iIndex].wNPt;
iterCplSubKey->second.vtSptSubkey[iIndex].bIsFind = true;
std::map<int,STSptPtCplSubkeyInfo>::iterator iterTmp;
while(1)
{
//此时开始以N的值作为M来进行搜索
iterTmp = iter->second.mapSptCplSubkey.find(wNPos);
//如果没有找到则退出循环
if (iterTmp == iter->second.mapSptCplSubkey.end())
{
break;
}
//如果找到的,之前已经被用过了,也推出循环
int iTmpIndex = iterTmp->second.FindMinNPosIndex();
if (iTmpIndex < 0)
{
break;
}
sortPtrArr.Add(pSptPtArray->GetAt(iterTmp->second.vtSptSubkey[iTmpIndex].iPosIndex));
iterTmp->second.vtSptSubkey[iTmpIndex].bIsFind = true;
wNPos = iterTmp->second.vtSptSubkey[iTmpIndex].wNPt;
}
}
}
}
//开始将排序好的链表代替原有的
if (iSize != sortPtrArr.GetSize())
{
CString strErr = _T("");
if (LANG_ZHCN == g_iUILanguage)
{
strErr.Format(_T("多通道错误的排序点。初始大小= %d,排序大小= %d"), iSize, sortPtrArr.GetSize());
AfxMessageBox(strErr);
}
else
{
strErr.Format(_T("Sort point of multi-channel error.orginal size = %d, sort size = %d"), iSize, sortPtrArr.GetSize());
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
}
return false;
}
pSptPtArray->RemoveAll();
int iTsn = 0;
for (i = 0; i < iSize; i++)
{
pSptRecord = (CSptRecord*)sortPtrArr.GetAt(i);
pSptRecord->m_iTsn = ++iTsn;
pSptPtArray->Add(pSptRecord);
}
return true;
}
@@ -0,0 +1,54 @@
// SptRecord.cpp: implementation of the CSptRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "SptRecord.h"
#include "Constant.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSptRecord::CSptRecord()
{
m_colorREF = RGB(255, 255, 255);
m_bIsSel = FALSE;
m_iTsn = (int)VAL_ZERO;
m_iC1 = (int)VAL_ZERO;
m_iC2 = (int)VAL_ZERO;
m_iP1 = (int)VAL_ZERO;
m_iP2 = (int)VAL_ZERO;
m_fA = (float)VAL_ZERO;
m_fB = (float)VAL_ZERO;
m_fX = (float)VAL_ZERO;
m_fY = (float)VAL_ZERO;
m_fK = (float)VAL_ZERO;
m_iN = (int)VAL_ZERO;
m_iLevel = (int)VAL_ZERO;
m_iPtNum = (int)VAL_ZERO;
m_fSptXPos = 0;
}
CSptRecord::~CSptRecord()
{
}
bool CSptRecord::PtInRegion(CPoint point)
{
float fDistance = (point.x-m_fPtCenterX)*(point.x-m_fPtCenterX) + (point.y-m_fPtCenterY)*(point.y-m_fPtCenterY);
if (fDistance <= (m_fPtRadius*m_fPtRadius))
{
return true;
}
else
{
return false;
}
}
@@ -0,0 +1,918 @@
// TdChannel.cpp: implementation of the CTdChannel class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "TdChannel.h"
#include "MediumQ.h"
#include "Rsp2DTdRecord.h"
#include "RspCETdRecord.h"
#include "Rsp3DTdRecord.h"
#include "Ipsp3DTdRecord.h"
#include "Ipsp2DTdRecord.h"
#include "IpspCETdRecord.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTdChannel::CTdChannel(DWORD dwScID, int iChNum, _ConnectionPtr& pConnection)
{
this->m_dwScID = dwScID;
this->m_iChNum = iChNum;
m_dwID = (int)VAL_ZERO;
m_iEAmount = (int)VAL_ZERO;
m_iMaxLevel = (int)VAL_ZERO;
m_pConnection = pConnection;
m_pMedium = NULL;
m_tdRecArray.RemoveAll();
// m_tdRecArray.SetSize(20480);
m_fMaxR0 = (float)VAL_ZERO;
m_fMinR0 = (float)VAL_ZERO;
m_fScaleR0 = (float)VAL_ZERO;
m_fMaxDepth = (float)VAL_ZERO;
}
CTdChannel::~CTdChannel()
{
}
BOOL CTdChannel::Load3DScriptFromDB()
{
_RecordsetPtr pRecCh = NULL;
_RecordsetPtr pRecSpt3D = NULL;
CString szSql = _T("");
CRsp3DTdRecord* pRsp3DTdRecord = NULL;
DWORD dwChID = (DWORD)VAL_ZERO;
pRecCh.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select ID from channel where SCID = %u and CHnumber = %d"), m_dwScID, m_iChNum);
pRecCh->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecCh->GetRecordCount())
{
dwChID = (DWORD)pRecCh->GetCollect(_T("ID")).ulVal;
}
pRecCh->Close();
pRecSpt3D.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,C1,C2,P1,P2,K,N from Script3d where CHID = %u order by TSN"), dwChID);
pRecSpt3D->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecSpt3D->adoEOF)
{
pRsp3DTdRecord = new CRsp3DTdRecord(this->m_dwID, this->m_pConnection);
pRsp3DTdRecord->m_iTsn = (int)pRecSpt3D->GetCollect(_T("TSN")).lVal;
pRsp3DTdRecord->m_iC1 = (int)pRecSpt3D->GetCollect(_T("C1")).iVal;
pRsp3DTdRecord->m_iC2 = (int)pRecSpt3D->GetCollect(_T("C2")).iVal;
pRsp3DTdRecord->m_iP1 = (int)pRecSpt3D->GetCollect(_T("P1")).iVal;
pRsp3DTdRecord->m_iP2 = (int)pRecSpt3D->GetCollect(_T("P2")).iVal;
pRsp3DTdRecord->m_fK = (float)pRecSpt3D->GetCollect(_T("K")).fltVal;
pRsp3DTdRecord->m_iN = (int)pRecSpt3D->GetCollect(_T("N")).iVal;
pRsp3DTdRecord->m_fR0 = (float)VAL_ZERO;
pRsp3DTdRecord->m_fI = (float)VAL_ZERO;
pRsp3DTdRecord->m_fV = (float)VAL_ZERO;
pRsp3DTdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
pRsp3DTdRecord->m_recPtArea.SetRectEmpty();
pRsp3DTdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pRsp3DTdRecord->m_iC1, pRsp3DTdRecord->m_iC2, pRsp3DTdRecord->m_iP1, pRsp3DTdRecord->m_iP2);
pRsp3DTdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pRsp3DTdRecord->m_iC1, pRsp3DTdRecord->m_iC2, pRsp3DTdRecord->m_iP1, pRsp3DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pRsp3DTdRecord);
pRecSpt3D->MoveNext();
}
pRecSpt3D->Close();
return TRUE;
}
BOOL CTdChannel::Load2DScriptFromDB()
{
_RecordsetPtr pRecCh = NULL;
_RecordsetPtr pRecSpt2D = NULL;
CString szSql = _T("");
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
DWORD dwChID = (DWORD)VAL_ZERO;
pRecCh.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select ID from channel where SCID = %u and CHnumber = %d"), m_dwScID, m_iChNum);
pRecCh->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecCh->GetRecordCount())
{
dwChID = (DWORD)pRecCh->GetCollect(_T("ID")).ulVal;
}
pRecCh->Close();
pRecSpt2D.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,C1,C2,P1,P2,K,N from Script2d where CHID = %u order by TSN"), dwChID);
pRecSpt2D->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecSpt2D->adoEOF)
{
pRsp2DTdRecord = new CRsp2DTdRecord(this->m_dwID, this->m_pConnection);
pRsp2DTdRecord->m_iTsn = (int)pRecSpt2D->GetCollect(_T("TSN")).lVal;
pRsp2DTdRecord->m_iC1 = (int)pRecSpt2D->GetCollect(_T("C1")).iVal;
pRsp2DTdRecord->m_iC2 = (int)pRecSpt2D->GetCollect(_T("C2")).iVal;
pRsp2DTdRecord->m_iP1 = (int)pRecSpt2D->GetCollect(_T("P1")).iVal;
pRsp2DTdRecord->m_iP2 = (int)pRecSpt2D->GetCollect(_T("P2")).iVal;
pRsp2DTdRecord->m_fK = (float)pRecSpt2D->GetCollect(_T("K")).fltVal;
pRsp2DTdRecord->m_iN = (int)pRecSpt2D->GetCollect(_T("N")).iVal;
pRsp2DTdRecord->m_fR0 = (float)VAL_ZERO;
pRsp2DTdRecord->m_fI = (float)VAL_ZERO;
pRsp2DTdRecord->m_fV = (float)VAL_ZERO;
pRsp2DTdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
pRsp2DTdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
pRsp2DTdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pRsp2DTdRecord);
pRecSpt2D->MoveNext();
}
pRecSpt2D->Close();
return TRUE;
}
void CTdChannel::SetColorToTdRec(CRsp2DTdRecord* pRsp2DTdRecord)
{
int iIndex = (int)VAL_ZERO;
int iColorIndex = (int)VAL_ZERO;
COLORREF aColor[15]={RGB(0,0,0xFF),RGB(0,0x33,0xFF),RGB(0,0x66,0xFF),RGB(0,0x88,0xFF),RGB(0,0xCF,0xFE),RGB(0,0xFE,0xFF),RGB(0,0xFE,0x99),RGB(0,0xFE,0x33),RGB(0x99,0xFE,0),RGB(0xFF,0xFE,0),RGB(0xFE,0xCC,0),RGB(0xFE,0x98,0),RGB(0xFE,0x66,0),RGB(0xFE,0x33,0),RGB(0xFF,0,0)};
pRsp2DTdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
if (0 == pRsp2DTdRecord->m_fR0)
{
return;
}
//在这里SetMaxR0AndMinR0的函数已经添加到LoadRsp2DTdData中去了,也就是在加载2D数据的时候就已经获取到
//这个任务的R0的最大值和最小值,所以此时再数据在去比较的时候就不会跳转到SetMaxR0AndMinR0为真的函数结构中去了
//实际就全部走下面的else的分支,如果其它的数据需要显示剖面图的话,那么也需要在加载数据的时候调用etMaxR0AndMinR0
//来预先获得RO的最大值和最小值
if (SetMaxR0AndMinR0(pRsp2DTdRecord->m_fR0) == TRUE)
{
//这里完全属于冗余切会导致运算N*N次,N为测点数,所以这里不应该跳转到
if (m_fMaxR0 == m_fMinR0)
{
((CRsp2DTdRecord*)this->m_tdRecArray.GetAt(iIndex))->m_colorREF = aColor[8];
}
else
{
m_fScaleR0 = (m_fMaxR0-m_fMinR0)/15;
}
iIndex = (int)VAL_ZERO;
while ((iIndex < this->m_tdRecArray.GetSize()) && ((int)VAL_ZERO != m_fScaleR0))
{
if (0 != ((CRsp2DTdRecord*)this->m_tdRecArray.GetAt(iIndex))->m_fR0)
{
iColorIndex = (int)floor((((CRsp2DTdRecord*)this->m_tdRecArray.GetAt(iIndex))->m_fR0-m_fMinR0)/m_fScaleR0);
if (iColorIndex > 14)
{
iColorIndex = 14;
}
((CRsp2DTdRecord*)this->m_tdRecArray.GetAt(iIndex))->m_colorREF = aColor[iColorIndex];
}
else
{
((CRsp2DTdRecord*)this->m_tdRecArray.GetAt(iIndex))->m_colorREF = RGB(0xFF,0xFF,0xFF);
}
iIndex++;
}
}
else
{
if (m_fMaxR0 == m_fMinR0)
{
((CRsp2DTdRecord*)this->m_tdRecArray.GetAt(iIndex))->m_colorREF = aColor[8];
}
else
{
m_fScaleR0 = (m_fMaxR0-m_fMinR0)/15;
}
iColorIndex = (int)floor((pRsp2DTdRecord->m_fR0-m_fMinR0)/m_fScaleR0);
if (iColorIndex > 14)
{
iColorIndex = 14;
}
pRsp2DTdRecord->m_colorREF = aColor[iColorIndex];
}
}
BOOL CTdChannel::SetMaxR0AndMinR0(float fR0)
{
if ((0 == m_fMaxR0) && (0 == m_fMinR0))
{
m_fMaxR0 = fR0;
m_fMinR0 = fR0;
}
else if (fR0 > m_fMaxR0)
{
m_fMaxR0 = fR0;
}
else if (fR0 < m_fMinR0)
{
m_fMinR0 = fR0;
}
else
{
return FALSE;
}
return TRUE;
}
void CTdChannel::Clear3DSptRecList()
{
int iListIndex = (int)VAL_ZERO;
iListIndex = (int)VAL_ZERO;
while (iListIndex < this->m_tdRecArray.GetSize())
{
if (this->m_tdRecArray.GetAt(iListIndex) != NULL)
{
delete (CRsp3DTdRecord*)m_tdRecArray.GetAt(iListIndex);
}
iListIndex++;
}
this->m_tdRecArray.RemoveAll();
m_fMaxR0 = (float)VAL_ZERO;
m_fMinR0 = (float)VAL_ZERO;
m_fScaleR0 = (float)VAL_ZERO;
m_iMaxLevel = (int)VAL_ZERO;
}
void CTdChannel::Clear2DSptRecList()
{
int iListIndex = (int)VAL_ZERO;
iListIndex = (int)VAL_ZERO;
while (iListIndex < this->m_tdRecArray.GetSize())
{
if (this->m_tdRecArray.GetAt(iListIndex) != NULL)
{
delete (CRsp2DTdRecord*)m_tdRecArray.GetAt(iListIndex);
}
iListIndex++;
}
this->m_tdRecArray.RemoveAll();
m_fMaxR0 = (float)VAL_ZERO;
m_fMinR0 = (float)VAL_ZERO;
m_fScaleR0 = (float)VAL_ZERO;
m_iMaxLevel = (int)VAL_ZERO;
}
void CTdChannel::ClearCESptRecList()
{
int iListIndex = (int)VAL_ZERO;
iListIndex = (int)VAL_ZERO;
while (iListIndex < this->m_tdRecArray.GetSize())
{
if (this->m_tdRecArray.GetAt(iListIndex) != NULL)
{
delete (CRspCETdRecord*)(m_tdRecArray.GetAt(iListIndex));
}
iListIndex++;
}
m_fMaxR0 = (float)VAL_ZERO;
m_fMinR0 = (float)VAL_ZERO;
this->m_tdRecArray.RemoveAll();
}
BOOL CTdChannel::SaveRsp3DTdData(DWORD dwScID)
{
CRsp3DTdRecord* pRsp3DTdRecord = NULL;
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
szSql.Empty();
szSql.Format(_T("insert into tdchannel(TDID,CHnumber,AR) values(%u,%d,%d)"),
dwScID,
this->m_iChNum,
this->m_pMedium->m_iAR);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
pRecTdCha->Open(_T("select max(ID) as ID from tdchannel"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecTdCha->GetRecordCount())
{
this->m_dwID = (int)pRecTdCha->GetCollect(_T("ID")).ulVal;
}
pRecTdCha->Close();
iTdRecIndex = (int)VAL_ZERO;
while (iTdRecIndex < m_tdRecArray.GetSize())
{
pRsp3DTdRecord = NULL;
pRsp3DTdRecord = (CRsp3DTdRecord*)m_tdRecArray.GetAt(iTdRecIndex);
pRsp3DTdRecord->SaveData(m_dwID);
iTdRecIndex++;
}
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
BOOL CTdChannel::SaveRsp2DTdData(DWORD dwScID)
{
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
szSql.Empty();
szSql.Format(_T("insert into tdchannel(TDID,CHnumber,AR) values(%u,%d,%d)"),
dwScID,
this->m_iChNum,
this->m_pMedium->m_iAR);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
pRecTdCha->Open(_T("select max(ID) as ID from tdchannel"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecTdCha->GetRecordCount())
{
this->m_dwID = (int)pRecTdCha->GetCollect(_T("ID")).ulVal;
}
pRecTdCha->Close();
iTdRecIndex = (int)VAL_ZERO;
while (iTdRecIndex < m_tdRecArray.GetSize())
{
pRsp2DTdRecord = NULL;
pRsp2DTdRecord = (CRsp2DTdRecord*)m_tdRecArray.GetAt(iTdRecIndex);
pRsp2DTdRecord->SaveData(m_dwID);
iTdRecIndex++;
}
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
BOOL CTdChannel::SaveRspCETdData(DWORD dwScID)
{
CRspCETdRecord* pRspCETdRecord = NULL;
_RecordsetPtr pRecTdCha;
_CommandPtr pCmdIns;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
pRecTdCha.CreateInstance(_uuidof(Recordset));
pCmdIns.CreateInstance(_uuidof(Command));
pCmdIns->ActiveConnection = m_pConnection;
try
{
szSql.Empty();
szSql.Format(_T("insert into tdchannel(TDID,CHnumber,AR) values(%u,%d,%d)"),
dwScID,
this->m_iChNum,
this->m_pMedium->m_iAR);
pCmdIns->CommandText = szSql.AllocSysString();
pCmdIns->Execute(NULL, NULL, adCmdText);
pRecTdCha->Open(_T("select max(ID) as ID from tdchannel"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecTdCha->GetRecordCount())
{
this->m_dwID = (int)pRecTdCha->GetCollect(_T("ID")).ulVal;
}
pRecTdCha->Close();
iTdRecIndex = (int)VAL_ZERO;
while (iTdRecIndex < m_tdRecArray.GetSize())
{
pRspCETdRecord = NULL;
pRspCETdRecord = (CRspCETdRecord*)m_tdRecArray.GetAt(iTdRecIndex);
pRspCETdRecord->SaveData(m_dwID);
iTdRecIndex++;
}
}
catch(_com_error e)
{
throw e;
return FALSE;
}
return TRUE;
}
BOOL CTdChannel::LoadRsp3DTdData()
{
CRsp3DTdRecord* pRsp3DTdRecord = NULL;
_RecordsetPtr pRecTdCon;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
if ((int)VAL_ZERO == this->m_tdRecArray.GetSize())
{
pRecTdCon.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,C1,C2,P1,P2,N,K,I,V,R0,SP,bUse from td3dcon where TCHID = %u"), this->m_dwID);
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
{
if (pRecTdCon->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
{
pRsp3DTdRecord = new CRsp3DTdRecord(this->m_dwID, this->m_pConnection);
pRsp3DTdRecord->m_iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
pRsp3DTdRecord->m_iC1 = (int)pRecTdCon->GetCollect(_T("C1")).iVal;
pRsp3DTdRecord->m_iC2 = (int)pRecTdCon->GetCollect(_T("C2")).iVal;
pRsp3DTdRecord->m_iP1 = (int)pRecTdCon->GetCollect(_T("P1")).iVal;
pRsp3DTdRecord->m_iP2 = (int)pRecTdCon->GetCollect(_T("P2")).iVal;
pRsp3DTdRecord->m_fK = (float)pRecTdCon->GetCollect(_T("K")).fltVal;
pRsp3DTdRecord->m_iN = (int)pRecTdCon->GetCollect(_T("N")).iVal;
pRsp3DTdRecord->m_fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
pRsp3DTdRecord->m_fI = (float)pRecTdCon->GetCollect(_T("I")).fltVal;
pRsp3DTdRecord->m_fV = (float)pRecTdCon->GetCollect(_T("V")).fltVal;
pRsp3DTdRecord->m_fSP = (float)pRecTdCon->GetCollect(_T("SP")).fltVal;
pRsp3DTdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
pRsp3DTdRecord->m_recPtArea.SetRectEmpty();
pRsp3DTdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pRsp3DTdRecord->m_iC1, pRsp3DTdRecord->m_iC2, pRsp3DTdRecord->m_iP1, pRsp3DTdRecord->m_iP2);
pRsp3DTdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pRsp3DTdRecord->m_iC1, pRsp3DTdRecord->m_iC2, pRsp3DTdRecord->m_iP1, pRsp3DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pRsp3DTdRecord);
}
pRecTdCon->MoveNext();
}
pRecTdCon->Close();
}
return TRUE;
}
BOOL CTdChannel::LoadRsp2DTdData()
{
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
_RecordsetPtr pRecTdCon;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
//added by lsq 20160506
//初始化最大和最小的RO值
m_fMaxR0 = m_fMinR0 = (float)VAL_ZERO;
//////////////////////////end////////////////////////////////////////////////
if ((int)VAL_ZERO == this->m_tdRecArray.GetSize())
{
pRecTdCon.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,C1,C2,P1,P2,N,K,I,V,R0,SP,bUse from td2dcon where TCHID = %u"), this->m_dwID);
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
{
if (pRecTdCon->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
{
pRsp2DTdRecord = new CRsp2DTdRecord(this->m_dwID, this->m_pConnection);
if (pRsp2DTdRecord == NULL)
{
ASSERT(pRsp2DTdRecord != NULL);
continue;
}
pRsp2DTdRecord->m_iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
pRsp2DTdRecord->m_iC1 = (int)pRecTdCon->GetCollect(_T("C1")).iVal;
pRsp2DTdRecord->m_iC2 = (int)pRecTdCon->GetCollect(_T("C2")).iVal;
pRsp2DTdRecord->m_iP1 = (int)pRecTdCon->GetCollect(_T("P1")).iVal;
pRsp2DTdRecord->m_iP2 = (int)pRecTdCon->GetCollect(_T("P2")).iVal;
pRsp2DTdRecord->m_fK = (float)pRecTdCon->GetCollect(_T("K")).fltVal;
pRsp2DTdRecord->m_iN = (int)pRecTdCon->GetCollect(_T("N")).iVal;
pRsp2DTdRecord->m_fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
pRsp2DTdRecord->m_fI = (float)pRecTdCon->GetCollect(_T("I")).fltVal;
pRsp2DTdRecord->m_fV = (float)pRecTdCon->GetCollect(_T("V")).fltVal;
pRsp2DTdRecord->m_fSP = (float)pRecTdCon->GetCollect(_T("SP")).fltVal;
////////////////////////////////added by lsq 20160506//////////////////////////////////////////
//在这里是为了在取数据库的过程中就直接得到RO的最大值和最小值
SetMaxR0AndMinR0(pRsp2DTdRecord->m_fR0);
//////////////////////////////////////////////////////////////////////////
pRsp2DTdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
pRsp2DTdRecord->m_recPtArea.SetRectEmpty();
if (m_pMedium == NULL)
{
ASSERT(m_pMedium != NULL);
if (pRsp2DTdRecord)
{
delete pRsp2DTdRecord;
pRsp2DTdRecord = NULL;
}
continue;
}
pRsp2DTdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
pRsp2DTdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pRsp2DTdRecord);
}
pRecTdCon->MoveNext();
}
pRecTdCon->Close();
}
return TRUE;
}
BOOL CTdChannel::LoadRspCETdData()
{
CRspCETdRecord* pRspCETdRecord = NULL;
_RecordsetPtr pRecTdCon;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
if ((int)VAL_ZERO == this->m_tdRecArray.GetSize())
{
pRecTdCon.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,a,b,x,y,N,K,I,V,R0,SP,bUse,dt from td1dcon where TCHID = %u"), this->m_dwID);
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
{
if (pRecTdCon->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
{
pRspCETdRecord = new CRspCETdRecord(this->m_dwID, this->m_pConnection);
pRspCETdRecord->m_iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
pRspCETdRecord->m_fA = (float)pRecTdCon->GetCollect(_T("a")).fltVal;
pRspCETdRecord->m_fB = (float)pRecTdCon->GetCollect(_T("b")).fltVal;
pRspCETdRecord->m_fX = (float)pRecTdCon->GetCollect(_T("x")).fltVal;
pRspCETdRecord->m_fY = (float)pRecTdCon->GetCollect(_T("y")).fltVal;
pRspCETdRecord->m_fK = (float)pRecTdCon->GetCollect(_T("K")).fltVal;
pRspCETdRecord->m_iN = (int)pRecTdCon->GetCollect(_T("N")).iVal;
pRspCETdRecord->m_fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
pRspCETdRecord->m_fI = (float)pRecTdCon->GetCollect(_T("I")).fltVal;
pRspCETdRecord->m_fV = (float)pRecTdCon->GetCollect(_T("V")).fltVal;
pRspCETdRecord->m_fSP = (float)pRecTdCon->GetCollect(_T("SP")).fltVal;
pRspCETdRecord->m_Datetime = (VT_NULL == pRecTdCon->GetCollect(_T("dt")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("dt"));
pRspCETdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
pRspCETdRecord->m_recPtArea.SetRectEmpty();
pRspCETdRecord->m_fDepth = this->m_pMedium->CalculateDepth(pRspCETdRecord->m_fA);
if ((((float)VAL_ZERO == this->m_fMaxR0) || (pRspCETdRecord->m_fR0 > this->m_fMaxR0)) && ((float)VAL_ZERO != pRspCETdRecord->m_fR0))
{
this->m_fMaxR0 = pRspCETdRecord->m_fR0;
}
if ((((float)VAL_ZERO == this->m_fMinR0) || (pRspCETdRecord->m_fR0 < this->m_fMinR0)) && ((float)VAL_ZERO != pRspCETdRecord->m_fR0))
{
this->m_fMinR0 = pRspCETdRecord->m_fR0;
}
if ((((float)VAL_ZERO == this->m_fMaxDepth) || (pRspCETdRecord->m_fDepth > this->m_fMaxDepth)) && ((float)VAL_ZERO != pRspCETdRecord->m_fDepth))
{
this->m_fMaxDepth = pRspCETdRecord->m_fDepth;
}
// pRspCETdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
// pRspCETdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pRspCETdRecord);
}
pRecTdCon->MoveNext();
}
pRecTdCon->Close();
}
return TRUE;
}
BOOL CTdChannel::LoadIpsp3DTdData()
{
CIpsp3DTdRecord* pIpsp3DTdRecord = NULL;
_RecordsetPtr pRecTdCon;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
if ((int)VAL_ZERO == this->m_tdRecArray.GetSize())
{
pRecTdCon.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,C1,C2,P1,P2,N,K,I,V,R0,SP,bUse from td3dcon where TCHID = %u"), this->m_dwID);
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
{
if (pRecTdCon->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
{
pIpsp3DTdRecord = new CIpsp3DTdRecord(this->m_dwID, this->m_pConnection);
pIpsp3DTdRecord->m_iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
pIpsp3DTdRecord->m_iC1 = (int)pRecTdCon->GetCollect(_T("C1")).iVal;
pIpsp3DTdRecord->m_iC2 = (int)pRecTdCon->GetCollect(_T("C2")).iVal;
pIpsp3DTdRecord->m_iP1 = (int)pRecTdCon->GetCollect(_T("P1")).iVal;
pIpsp3DTdRecord->m_iP2 = (int)pRecTdCon->GetCollect(_T("P2")).iVal;
pIpsp3DTdRecord->m_fK = (float)pRecTdCon->GetCollect(_T("K")).fltVal;
pIpsp3DTdRecord->m_iN = (int)pRecTdCon->GetCollect(_T("N")).iVal;
pIpsp3DTdRecord->m_fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
pIpsp3DTdRecord->m_fI = (float)pRecTdCon->GetCollect(_T("I")).fltVal;
pIpsp3DTdRecord->m_fV = (float)pRecTdCon->GetCollect(_T("V")).fltVal;
pIpsp3DTdRecord->m_fSP = (float)pRecTdCon->GetCollect(_T("SP")).fltVal;
pIpsp3DTdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
pIpsp3DTdRecord->m_recPtArea.SetRectEmpty();
pIpsp3DTdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pIpsp3DTdRecord->m_iC1, pIpsp3DTdRecord->m_iC2, pIpsp3DTdRecord->m_iP1, pIpsp3DTdRecord->m_iP2);
pIpsp3DTdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pIpsp3DTdRecord->m_iC1, pIpsp3DTdRecord->m_iC2, pIpsp3DTdRecord->m_iP1, pIpsp3DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pIpsp3DTdRecord);
}
pRecTdCon->MoveNext();
}
pRecTdCon->Close();
}
return TRUE;
}
BOOL CTdChannel::LoadIpsp2DTdData()
{
CIpsp2DTdRecord* pIpsp2DTdRecord = NULL;
_RecordsetPtr pRecTdCon;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
if ((int)VAL_ZERO == this->m_tdRecArray.GetSize())
{
pRecTdCon.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,C1,C2,P1,P2,N,K,I,V,R0,SP,bUse from td2dcon where TCHID = %u"), this->m_dwID);
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
{
if (pRecTdCon->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
{
pIpsp2DTdRecord = new CIpsp2DTdRecord(this->m_dwID, this->m_pConnection);
pIpsp2DTdRecord->m_iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
pIpsp2DTdRecord->m_iC1 = (int)pRecTdCon->GetCollect(_T("C1")).iVal;
pIpsp2DTdRecord->m_iC2 = (int)pRecTdCon->GetCollect(_T("C2")).iVal;
pIpsp2DTdRecord->m_iP1 = (int)pRecTdCon->GetCollect(_T("P1")).iVal;
pIpsp2DTdRecord->m_iP2 = (int)pRecTdCon->GetCollect(_T("P2")).iVal;
pIpsp2DTdRecord->m_fK = (float)pRecTdCon->GetCollect(_T("K")).fltVal;
pIpsp2DTdRecord->m_iN = (int)pRecTdCon->GetCollect(_T("N")).iVal;
pIpsp2DTdRecord->m_fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
pIpsp2DTdRecord->m_fI = (float)pRecTdCon->GetCollect(_T("I")).fltVal;
pIpsp2DTdRecord->m_fV = (float)pRecTdCon->GetCollect(_T("V")).fltVal;
pIpsp2DTdRecord->m_fSP = (float)pRecTdCon->GetCollect(_T("SP")).fltVal;
pIpsp2DTdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
pIpsp2DTdRecord->m_recPtArea.SetRectEmpty();
pIpsp2DTdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pIpsp2DTdRecord->m_iC1, pIpsp2DTdRecord->m_iC2, pIpsp2DTdRecord->m_iP1, pIpsp2DTdRecord->m_iP2);
pIpsp2DTdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pIpsp2DTdRecord->m_iC1, pIpsp2DTdRecord->m_iC2, pIpsp2DTdRecord->m_iP1, pIpsp2DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pIpsp2DTdRecord);
}
pRecTdCon->MoveNext();
}
pRecTdCon->Close();
}
return TRUE;
}
BOOL CTdChannel::LoadIpspCETdData()
{
CIpspCETdRecord* pIpspCETdRecord = NULL;
_RecordsetPtr pRecTdCon;
CString szSql = _T("");
int iTdRecIndex = (int)VAL_ZERO;
if ((int)VAL_ZERO == this->m_tdRecArray.GetSize())
{
pRecTdCon.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,a,b,x,y,N,K,I,V,R0,SP,bUse from td1dcon where TCHID = %u"), this->m_dwID);
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
{
if (pRecTdCon->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
{
pIpspCETdRecord = new CIpspCETdRecord(this->m_dwID, this->m_pConnection);
pIpspCETdRecord->m_iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
pIpspCETdRecord->m_fA = (float)pRecTdCon->GetCollect(_T("a")).fltVal;
pIpspCETdRecord->m_fB = (float)pRecTdCon->GetCollect(_T("b")).fltVal;
pIpspCETdRecord->m_fX = (float)pRecTdCon->GetCollect(_T("x")).fltVal;
pIpspCETdRecord->m_fY = (float)pRecTdCon->GetCollect(_T("y")).fltVal;
pIpspCETdRecord->m_fK = (float)pRecTdCon->GetCollect(_T("K")).fltVal;
pIpspCETdRecord->m_iN = (int)pRecTdCon->GetCollect(_T("N")).iVal;
pIpspCETdRecord->m_fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
pIpspCETdRecord->m_fI = (float)pRecTdCon->GetCollect(_T("I")).fltVal;
pIpspCETdRecord->m_fV = (float)pRecTdCon->GetCollect(_T("V")).fltVal;
pIpspCETdRecord->m_fSP = (float)pRecTdCon->GetCollect(_T("SP")).fltVal;
pIpspCETdRecord->m_colorREF = RGB(0xFF,0xFF,0xFF);
pIpspCETdRecord->m_recPtArea.SetRectEmpty();
pIpspCETdRecord->m_fDepth = this->m_pMedium->CalculateDepth(pIpspCETdRecord->m_fA);
if ((((float)VAL_ZERO == this->m_fMaxR0) || (pIpspCETdRecord->m_fR0 > this->m_fMaxR0)) && ((float)VAL_ZERO != pIpspCETdRecord->m_fR0))
{
this->m_fMaxR0 = pIpspCETdRecord->m_fR0;
}
if ((((float)VAL_ZERO == this->m_fMinR0) || (pIpspCETdRecord->m_fR0 < this->m_fMinR0)) && ((float)VAL_ZERO != pIpspCETdRecord->m_fR0))
{
this->m_fMinR0 = pIpspCETdRecord->m_fR0;
}
if ((((float)VAL_ZERO == this->m_fMaxDepth) || (pIpspCETdRecord->m_fDepth > this->m_fMaxDepth)) && ((float)VAL_ZERO != pIpspCETdRecord->m_fDepth))
{
this->m_fMaxDepth = pIpspCETdRecord->m_fDepth;
}
// pRspCETdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
// pRspCETdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pIpspCETdRecord);
}
pRecTdCon->MoveNext();
}
pRecTdCon->Close();
}
return TRUE;
}
BOOL CTdChannel::LoadCEScriptFromDB()
{
_RecordsetPtr pRecCh = NULL;
_RecordsetPtr pRecSptCE = NULL;
CString szSql = _T("");
CRspCETdRecord* pRspCETdRecord = NULL;
DWORD dwChID = (DWORD)VAL_ZERO;
pRecCh.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select ID from channel where SCID = %u and CHnumber = %d"), m_dwScID, m_iChNum);
pRecCh->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecCh->GetRecordCount())
{
dwChID = (DWORD)pRecCh->GetCollect(_T("ID")).ulVal;
}
pRecCh->Close();
pRecSptCE.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TSN,a,b,x,y,K,N from Script1d where CHID = %u order by TSN"), dwChID);
pRecSptCE->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
this->m_tdRecArray.RemoveAll();
while ((short)VAL_ZERO == pRecSptCE->adoEOF)
{
pRspCETdRecord = new CRspCETdRecord(this->m_dwID, this->m_pConnection);
pRspCETdRecord->m_iTsn = (int)pRecSptCE->GetCollect(_T("TSN")).lVal;
pRspCETdRecord->m_fA = (float)pRecSptCE->GetCollect(_T("a")).fltVal;
pRspCETdRecord->m_fB = (float)pRecSptCE->GetCollect(_T("b")).fltVal;
pRspCETdRecord->m_fX = (float)pRecSptCE->GetCollect(_T("x")).fltVal;
pRspCETdRecord->m_fY = (float)pRecSptCE->GetCollect(_T("y")).fltVal;
pRspCETdRecord->m_fK = (float)pRecSptCE->GetCollect(_T("K")).fltVal;
pRspCETdRecord->m_iN = (int)pRecSptCE->GetCollect(_T("N")).iVal;
pRspCETdRecord->m_fR0 = (float)VAL_ZERO;
pRspCETdRecord->m_fI = (float)VAL_ZERO;
pRspCETdRecord->m_fV = (float)VAL_ZERO;
pRspCETdRecord->m_colorREF = RGB(0xFF, 0xFF, 0xFF);
pRspCETdRecord->m_recPtArea.SetRectEmpty();
pRspCETdRecord->m_fDepth = ((CMediumQ*)this->m_pMedium)->CalculateDepth(pRspCETdRecord->m_fA, this->m_fDepthFactor);
// pRspCETdRecord->m_fLevel
// pRspCETdRecord->m_iLevel = this->m_pMedium->GenSptRecLevel(pRspCETdRecord->m_iC1, pRspCETdRecord->m_iC2, pRspCETdRecord->m_iP1, pRspCETdRecord->m_iP2);
// pRspCETdRecord->m_iPosInLevel = this->m_pMedium->GenSptRecPosInLevel(pRspCETdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2);
this->m_tdRecArray.Add((void*)pRspCETdRecord);
pRecSptCE->MoveNext();
}
pRecSptCE->Close();
return TRUE;
}
void CTdChannel::SetColorToTd()
{
int iIndex = (int)VAL_ZERO;
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
// this->m_fMaxR0 = 0.0;
// this->m_fMinR0 = 0.0;
while (iIndex < m_tdRecArray.GetSize())
{
pRsp2DTdRecord = NULL;
pRsp2DTdRecord = (CRsp2DTdRecord*)m_tdRecArray.GetAt(iIndex);
SetColorToTdRec(pRsp2DTdRecord);
iIndex++;
}
}
CTdRecord* CTdChannel::GetTdRecord(int iTSN)
{
CTdRecord* pTdRecord = NULL;
int iIndex = (int)VAL_ZERO;
if ((int)VAL_ZERO != this->m_tdRecArray.GetSize())
{
do
{
pTdRecord = (CTdRecord*)this->m_tdRecArray.GetAt(iIndex);
if ((this->m_dwID == pTdRecord->m_dwChID) && (pTdRecord->m_iTsn == iTSN))
{
return pTdRecord;
}
iIndex++;
} while (iIndex <= this->m_tdRecArray.GetUpperBound());
}
return NULL;
}
@@ -0,0 +1,325 @@
// TdRecord.cpp: implementation of the CTdRecord class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "TdRecord.h"
#include "disptdrecsplinesgrapdlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTdRecord::CTdRecord(_ConnectionPtr& pConnection)
{
m_pConnection = pConnection;
m_fMaxAbsV = 0.0;
}
CTdRecord::~CTdRecord()
{
this->m_saVRawData.RemoveAll();
this->m_saIRawData.RemoveAll();
}
BOOL CTdRecord::LoadCEOrgData()
{
float fValue = 0.0;
CString szValue = _T("");
CString szVRawData = _T("");
CString szIRawData = _T("");
CString szSql = _T("");
_RecordsetPtr pRecRawData = NULL;
int iIndex = (int)VAL_ZERO;
this->m_saVRawData.RemoveAll();
this->m_saIRawData.RemoveAll();
try
{
pRecRawData.CreateInstance(_uuidof(Recordset));
szSql.Empty();
// szSql.Format(_T("select Vrawdata,Irawdata from td1dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_iTsn);
szSql.Format(_T("select Vrawdata,Irawdata from td1dcon where TSN = %d and TCHID in (select id from tdchannel where tdid = %d)"), this->m_iTsn, this->m_dwChID);
// szSql.Format(_T("select IIf(IsNull(Vrawdata),'',Vrawdata) as Vrawdata,IIf(IsNull(Irawdata),'',Irawdata) as Irawdata from td1dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_iTsn);
pRecRawData->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if (0 != pRecRawData->GetRecordCount())
{
szVRawData.Empty();
szVRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Vrawdata"));
SplitterString(m_saVRawData, szVRawData, _T(";"));
iIndex = (int)VAL_ZERO;
while (iIndex < m_saVRawData.GetSize())
{
szValue.Empty();
szValue = m_saVRawData.GetAt(iIndex);
if (4 == iIndex)
{
szValue.TrimLeft(szValue.Left(5));
}
szValue.TrimLeft();
if (iIndex >= 4)
{
fValue = 0.0;
fValue = this->ConvertVOrgData((float)atof(szValue));
if (fabsf(fValue) > this->m_fMaxAbsV)
{
this->m_fMaxAbsV = fabsf(fValue);
}
szValue.Empty();
szValue.Format(_T("%.4f"), fValue);
}
m_saVRawData.SetAt(iIndex, szValue);
iIndex++;
}
szIRawData.Empty();
szIRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Irawdata"));
SplitterString(m_saIRawData, szIRawData, _T(";"));
iIndex = (int)VAL_ZERO;
while (iIndex < m_saIRawData.GetSize())
{
szValue.Empty();
szValue = m_saIRawData.GetAt(iIndex);
if (4 == iIndex)
{
szValue.TrimLeft(szValue.Left(5));
}
szValue.TrimLeft();
m_saIRawData.SetAt(iIndex, szValue);
iIndex++;
}
}
pRecRawData->Close();
}
catch (_com_error e)
{
// AfxMessageBox(e.Description());
throw;
}
return TRUE;
}
BOOL CTdRecord::Load2DOrgData()
{
float fValue = 0.0;
CString szValue = _T("");
CString szVRawData = _T("");
CString szIRawData = _T("");
CString szSql = _T("");
_RecordsetPtr pRecRawData = NULL;
int iIndex = (int)VAL_ZERO;
this->m_saVRawData.RemoveAll();
this->m_saIRawData.RemoveAll();
try
{
pRecRawData.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select Vrawdata,Irawdata from td2dcon where TSN = %d and TCHID in (select id from tdchannel where tdid = %d)"), this->m_iTsn, this->m_dwChID);
// szSql.Format(_T("select IIf(IsNull(Vrawdata),'',Vrawdata) as Vrawdata,IIf(IsNull(Irawdata),'',Irawdata) as Irawdata from td2dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_iTsn);
pRecRawData->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if (0 != pRecRawData->GetRecordCount())
{
szVRawData.Empty();
szVRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Vrawdata"));
SplitterString(m_saVRawData, szVRawData, _T(";"));
iIndex = (int)VAL_ZERO;
while (iIndex < m_saVRawData.GetSize())
{
szValue.Empty();
szValue = m_saVRawData.GetAt(iIndex);
if (4 == iIndex)
{
szValue.TrimLeft(szValue.Left(5));
}
szValue.TrimLeft();
if (iIndex >= 4)
{
fValue = 0.0;
fValue = this->ConvertVOrgData((float)atof(szValue));
if (fabsf(fValue) > this->m_fMaxAbsV)
{
this->m_fMaxAbsV = fabsf(fValue);
}
szValue.Empty();
szValue.Format(_T("%.4f"), fValue);
}
m_saVRawData.SetAt(iIndex, szValue);
iIndex++;
}
szIRawData.Empty();
szIRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Irawdata"));
SplitterString(m_saIRawData, szIRawData, _T(";"));
iIndex = (int)VAL_ZERO;
while (iIndex < m_saIRawData.GetSize())
{
szValue.Empty();
szValue = m_saIRawData.GetAt(iIndex);
if (4 == iIndex)
{
szValue.TrimLeft(szValue.Left(5));
}
szValue.TrimLeft();
m_saIRawData.SetAt(iIndex, szValue);
iIndex++;
}
}
pRecRawData->Close();
}
catch (_com_error e)
{
// AfxMessageBox(e.Description());
throw;
}
return TRUE;
}
float CTdRecord::ConvertVOrgData(float fVOrgData)
{
return fVOrgData;
}
void CTdRecord::DisplayRawDataSplines()
{
LoadOrgData();
if ((int)VAL_ZERO != this->m_saVRawData.GetSize())
{
CDispTdRecSplinesGrapDlg* pDispTdRecSplinesGrapDlg = new CDispTdRecSplinesGrapDlg(this->m_saVRawData, this->m_fMaxAbsV);
pDispTdRecSplinesGrapDlg->DoModal();
delete pDispTdRecSplinesGrapDlg;
}
}
BOOL CTdRecord::Load3DOrgData()
{
float fValue = 0.0;
CString szValue = _T("");
CString szVRawData = _T("");
CString szIRawData = _T("");
CString szSql = _T("");
_RecordsetPtr pRecRawData = NULL;
int iIndex = (int)VAL_ZERO;
this->m_saVRawData.RemoveAll();
this->m_saIRawData.RemoveAll();
try
{
pRecRawData.CreateInstance(_uuidof(Recordset));
szSql.Empty();
// szSql.Format(_T("select Vrawdata,Irawdata from td3dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_iTsn);
szSql.Format(_T("select Vrawdata,Irawdata from td3dcon where TSN = %d and TCHID in (select id from tdchannel where tdid = %d)"), this->m_iTsn, this->m_dwChID);
// szSql.Format(_T("select IIf(IsNull(Vrawdata),'',Vrawdata) as Vrawdata,IIf(IsNull(Irawdata),'',Irawdata) as Irawdata from td2dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_iTsn);
pRecRawData->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if (0 != pRecRawData->GetRecordCount())
{
szVRawData.Empty();
szVRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Vrawdata"));
SplitterString(m_saVRawData, szVRawData, _T(";"));
iIndex = (int)VAL_ZERO;
while (iIndex < m_saVRawData.GetSize())
{
szValue.Empty();
szValue = m_saVRawData.GetAt(iIndex);
if (4 == iIndex)
{
szValue.TrimLeft(szValue.Left(5));
}
szValue.TrimLeft();
if (iIndex >= 4)
{
fValue = 0.0;
fValue = this->ConvertVOrgData((float)atof(szValue));
if (fabsf(fValue) > this->m_fMaxAbsV)
{
this->m_fMaxAbsV = fabsf(fValue);
}
szValue.Empty();
szValue.Format(_T("%.4f"), fValue);
}
m_saVRawData.SetAt(iIndex, szValue);
iIndex++;
}
szIRawData.Empty();
szIRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Irawdata"));
SplitterString(m_saIRawData, szIRawData, _T(";"));
iIndex = (int)VAL_ZERO;
while (iIndex < m_saIRawData.GetSize())
{
szValue.Empty();
szValue = m_saIRawData.GetAt(iIndex);
if (4 == iIndex)
{
szValue.TrimLeft(szValue.Left(5));
}
szValue.TrimLeft();
m_saIRawData.SetAt(iIndex, szValue);
iIndex++;
}
}
pRecRawData->Close();
}
catch (_com_error e)
{
// AfxMessageBox(e.Description());
throw;
}
return TRUE;
}
float CTdRecord::GetMaxAbsV()
{
return m_fMaxAbsV;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,81 @@
// TestingZone.cpp: implementation of the CTestingZone class.
//
//////////////////////////////////////////////////////////////////////
#include "geomative.h"
#include "TestingZone.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTestingZone::CTestingZone(DWORD dwID, _ConnectionPtr& pConnection)
{
ASSERT(NULL != pConnection);
m_pConnection = pConnection;
CString szSql = _T("");
_RecordsetPtr pRecTz = NULL;
pRecTz.CreateInstance(_uuidof(Recordset));
szSql.Empty();
szSql.Format(_T("select TZname,TZtype,CN,Format(Cdate,'YYYY-MM-DD') as Cdate,TZdesc,location from tz where ID = %u"), dwID);
pRecTz->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
if ((long)VAL_ZERO != pRecTz->GetRecordCount())
{
m_szTZname = pRecTz->GetCollect(_T("TZname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZname"));
m_szTZtype = pRecTz->GetCollect(_T("TZtype")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZtype"));
m_szCDate = pRecTz->GetCollect(_T("Cdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("Cdate"));
m_szDesc = pRecTz->GetCollect(_T("TZdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZdesc"));
m_szLocation = pRecTz->GetCollect(_T("location")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("location"));
m_szCN = pRecTz->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("CN"));
}
pRecTz->Close();
m_dwID = dwID;
}
CTestingZone::~CTestingZone()
{
}
bool CTestingZone::ShowDetailInfo(CListCtrl &tzDetailList)
{
int iRowIndex = (int)VAL_ZERO;
while (tzDetailList.GetItemCount() != iRowIndex)
{
tzDetailList.SetItemText(iRowIndex, 1, _T(""));
iRowIndex++;
}
CString szTzType;
if (m_szTZtype == "1" || m_szTZtype == "0")
{
szTzType = "1D VES | 2D ERI";
}
else if (m_szTZtype == "2")
{
szTzType = "3D ERT";
}
else
{
szTzType = "All Type";
}
tzDetailList.SetItemText(0, 1, m_szTZname);
tzDetailList.SetItemText(1, 1, szTzType);
tzDetailList.SetItemText(2, 1, m_szCDate);
tzDetailList.SetItemText(3, 1, m_szDesc);
tzDetailList.SetItemText(4, 1, m_szLocation);
return true;
}
@@ -0,0 +1,172 @@
// appdevolgrlistview.cpp : implementation file
//
#include "stdafx.h"
#include "geomative.h"
#include "appdevolgrlistview.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAppDevOLGRListView
IMPLEMENT_DYNCREATE(CAppDevOLGRListView, CListView)
CAppDevOLGRListView::CAppDevOLGRListView()
{
}
CAppDevOLGRListView::~CAppDevOLGRListView()
{
}
BEGIN_MESSAGE_MAP(CAppDevOLGRListView, CListView)
//{{AFX_MSG_MAP(CAppDevOLGRListView)
ON_WM_RBUTTONDOWN()
ON_COMMAND(IDM_OP_DEV_GR_REF, OnOpDevRefreshGR)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAppDevOLGRListView drawing
void CAppDevOLGRListView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CAppDevOLGRListView diagnostics
#ifdef _DEBUG
void CAppDevOLGRListView::AssertValid() const
{
CListView::AssertValid();
}
void CAppDevOLGRListView::Dump(CDumpContext& dc) const
{
CListView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CAppDevOLGRListView message handlers
void CAppDevOLGRListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
CString strColTitle;
GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES);
m_pMngFrm = (CMDIChildWnd*)GetParentFrame();
strColTitle.Empty();
strColTitle.LoadString(IDS_DB_DEVGR_ECODE);
GetListCtrl().InsertColumn(0, strColTitle, LVCFMT_LEFT, 100);
strColTitle.Empty();
strColTitle.LoadString(IDS_DB_DEVGR_MDATE);
GetListCtrl().InsertColumn(1, strColTitle, LVCFMT_LEFT, 110);
strColTitle.Empty();
strColTitle.LoadString(IDS_DB_DEVGR_MTIME);
GetListCtrl().InsertColumn(2, strColTitle, LVCFMT_LEFT, 100);
strColTitle.Empty();
strColTitle.LoadString(IDS_DB_DEVGR_RESISTANCE);
GetListCtrl().InsertColumn(3, strColTitle, LVCFMT_LEFT, 100);
strColTitle.Empty();
strColTitle.LoadString(IDS_DB_DEVGR_RESISTANCE_STATUS);
GetListCtrl().InsertColumn(4, strColTitle, LVCFMT_LEFT, 150);
strColTitle.Empty();
strColTitle.LoadString(IDS_DB_DEVGR_RESISTANCE1);
GetListCtrl().InsertColumn(5, strColTitle, LVCFMT_LEFT, 100);
strColTitle.Empty();
strColTitle.LoadString(IDS_DB_DEVGR_RESISTANCE1_STATUS);
GetListCtrl().InsertColumn(6, strColTitle, LVCFMT_LEFT, 150);
}
BOOL CAppDevOLGRListView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
cs.style &= ~LVS_TYPEMASK;
cs.style |= LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS;
return CListView::PreCreateWindow(cs);
}
void CAppDevOLGRListView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMenu grMenu;
CMenu* pPopGrMenu = NULL;
POSITION posRec;
UINT uFlag;
int iItem = GetListCtrl().HitTest(point, &uFlag);
if ((uFlag == LVHT_ONITEM) && (iItem != (int)VAL_MINUS_ONE))
{
GetListCtrl().SetItemState(iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
}
posRec = GetListCtrl().GetFirstSelectedItemPosition();
iItem = GetListCtrl().GetNextSelectedItem(posRec);
if (iItem != (int)VAL_MINUS_ONE)
{
// ::SendMessage(m_pMngFrm->m_hWnd, WM_DEVGRRECREFRESH, (WPARAM)iItem, (LPARAM)VAL_ZERO);
this->ClientToScreen(&point);
grMenu.LoadMenu(IDR_GR_REFRESH);
pPopGrMenu = grMenu.GetSubMenu(0);
pPopGrMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}
CListView::OnRButtonDown(nFlags, point);
}
void CAppDevOLGRListView::OnOpDevRefreshGR()
{
DWORD dwPos = (DWORD)VAL_ZERO;
CString szLabel = _T("");
UINT uFlag;
POSITION posRec;
dwPos = GetMessagePos();
CPoint point(LOWORD(dwPos), HIWORD(dwPos));
int iItem = GetListCtrl().HitTest(point, &uFlag);
if ((uFlag == LVHT_ONITEM) && (iItem != (int)VAL_MINUS_ONE))
{
GetListCtrl().SetItemState(iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
}
posRec = GetListCtrl().GetFirstSelectedItemPosition();
iItem = GetListCtrl().GetNextSelectedItem(posRec);
if (iItem != (int)VAL_MINUS_ONE)
{
::SendMessage(m_pMngFrm->m_hWnd, WM_DEVREFRESHGRREC, (WPARAM)iItem, (LPARAM)VAL_ZERO);
}
}
//DEL void CAppDevOLGRListView::OnOpDevRefreshAllGR()
//DEL {
//DEL ::SendMessage(m_pMngFrm->m_hWnd, WM_DEVREFRESHALLGRREC, (WPARAM)VAL_ZERO, (LPARAM)VAL_ZERO);
//DEL }