|
|
#include "stdafx.h"
|
|
|
#include "SectionDoc.h"
|
|
|
|
|
|
|
|
|
CSectionDoc::CSectionDoc()
|
|
|
{
|
|
|
//m_pWells = nullptr;
|
|
|
m_pItemPrint = nullptr;
|
|
|
}
|
|
|
|
|
|
|
|
|
CSectionDoc::~CSectionDoc()
|
|
|
{
|
|
|
list<CEntityWell*>::iterator begin = m_Wells.begin(), end = m_Wells.end();
|
|
|
while (begin != end)
|
|
|
{
|
|
|
CEntityWell* temp = *begin;
|
|
|
begin = m_Wells.erase(begin);
|
|
|
delete temp;
|
|
|
}
|
|
|
list<CEntityBend*>::iterator beginBend = m_Bends.begin(), endBend = m_Bends.end();
|
|
|
while (beginBend != endBend)
|
|
|
{
|
|
|
CEntityBend* temp = *beginBend;
|
|
|
beginBend = m_Bends.erase(beginBend);
|
|
|
delete temp;
|
|
|
}
|
|
|
|
|
|
//for (list<CEntityWell*>::iterator it = m_Wells.begin(); it != m_Wells.end();)
|
|
|
//{
|
|
|
// //mylist.erase(it++);
|
|
|
// it = m_Wells.erase(it);
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
void CSectionDoc::AddWell(LPCTSTR wellName, double locationX, double locationY)
|
|
|
{
|
|
|
CEntityWell* pWell = new CEntityWell();
|
|
|
pWell->_WellName = wellName;
|
|
|
pWell->_LocationX = locationX;
|
|
|
pWell->_LocationY = locationY;
|
|
|
m_Wells.push_back(pWell);
|
|
|
}
|
|
|
void CSectionDoc::SetWellStratiUnits(LPCTSTR wellName, int count
|
|
|
, LPCTSTR* stratiNames, double* tops, double* bottoms, LPCTSTR* unitNames)
|
|
|
{
|
|
|
for (list<CEntityWell*>::iterator iter = m_Wells.begin(); iter != m_Wells.end(); iter++)
|
|
|
{
|
|
|
if ((*iter)->_WellName.Compare(wellName) == 0)
|
|
|
{
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
CEntityStratiUnit* pStratiUnit = new CEntityStratiUnit();
|
|
|
pStratiUnit->_Name = stratiNames[i];
|
|
|
pStratiUnit->_UnitName = stratiNames[i];
|
|
|
pStratiUnit->_Bottom = bottoms[i];
|
|
|
pStratiUnit->_Top = tops[i];
|
|
|
(*iter)->m_StratiUnits.push_back(pStratiUnit);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int pnpoly(int vertCount, double *vertx, double *verty, double testx, double testy)
|
|
|
{
|
|
|
//if (p.x < minX || p.x > maxX || p.y < minY || p.y > maxY) {
|
|
|
// // 这个测试都过不了。。。直接返回false;
|
|
|
//}
|
|
|
int i, j, c = 0;
|
|
|
for (i = 0, j = vertCount - 1; i < vertCount; j = i++) {
|
|
|
if (((verty[i] > testy) != (verty[j] > testy)) &&
|
|
|
(testx < (vertx[j] - vertx[i]) * (testy - verty[i]) / (verty[j] - verty[i]) + vertx[i]))
|
|
|
c = !c;
|
|
|
}
|
|
|
return c;
|
|
|
}
|
|
|
CRect8 CSectionDoc::GetStratiRect(LPCTSTR wellName, LPCTSTR unitName)
|
|
|
{
|
|
|
CRect8 rect;
|
|
|
for (list<CEntityWell*>::iterator iter = m_Wells.begin(); iter != m_Wells.end(); iter++)
|
|
|
{
|
|
|
if ((*iter)->_WellName.Compare(wellName) == 0)
|
|
|
{
|
|
|
for (list<CEntityStratiUnit*>::iterator itStrati = (*iter)->m_StratiUnits.begin();
|
|
|
itStrati!= (*iter)->m_StratiUnits.end();itStrati++)
|
|
|
{
|
|
|
if ((*itStrati)->_UnitName.Compare(unitName) == 0) {
|
|
|
rect.left = (*iter)->_LocationX;
|
|
|
rect.top = (*itStrati)->_Top;
|
|
|
rect.right = rect.left + 50;
|
|
|
rect.bottom = (*itStrati)->_Bottom;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return rect;
|
|
|
}
|
|
|
|
|
|
void CSectionDoc::AddBend(CEntityBend* pBend) {
|
|
|
|
|
|
m_Bends.push_back(pBend);
|
|
|
}
|
|
|
CEntityBend* CSectionDoc::FindBend(LPCTSTR leftWell, LPCTSTR leftStrati, LPCTSTR rightWell, LPCTSTR rightStrati)
|
|
|
{
|
|
|
list<CEntityBend*>::iterator beginBend = m_Bends.begin(), endBend = m_Bends.end();
|
|
|
while (beginBend != endBend)
|
|
|
{
|
|
|
CEntityBend* temp = *beginBend;
|
|
|
if (temp->leftWell.Compare(leftWell)== 0
|
|
|
&& temp->leftStrati.Compare(leftStrati)==0
|
|
|
&& temp->rightWell.Compare(rightWell) == 0
|
|
|
&& temp->rightStrati.Compare(rightStrati) == 0)
|
|
|
{
|
|
|
return temp;
|
|
|
}
|
|
|
beginBend++;
|
|
|
}
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
void CSectionDoc::SelectBend(CDC* pdc, int mouseX, int mouseY)
|
|
|
{
|
|
|
list<CEntityBend*>::iterator beginBend = m_Bends.begin(), endBend = m_Bends.end();
|
|
|
while (beginBend != endBend)
|
|
|
{
|
|
|
CEntityBend* temp = *beginBend;
|
|
|
int nSize = temp->points.GetSize();
|
|
|
double* vertx = new double[nSize+1];
|
|
|
double* verty = new double[nSize+1];
|
|
|
dfPoint dp,dpFirst;
|
|
|
POSITION p = temp->points.GetHeadPosition();
|
|
|
dp = temp->points.GetNext(p);
|
|
|
dpFirst = dp;
|
|
|
int i = 0;
|
|
|
while (p)
|
|
|
{
|
|
|
vertx[i] = dp.x0;
|
|
|
verty[i] = dp.y0;
|
|
|
dp = temp->points.GetNext(p);
|
|
|
i++;
|
|
|
}
|
|
|
vertx[nSize] = dpFirst.x0;
|
|
|
verty[nSize] = dpFirst.y0;
|
|
|
if (pnpoly(nSize, vertx, verty, mouseX, mouseY)>0)
|
|
|
{
|
|
|
//temp->DrawSelect(pdc);
|
|
|
temp->selected = true;
|
|
|
}
|
|
|
else {
|
|
|
temp->selected = false;
|
|
|
}
|
|
|
beginBend++;
|
|
|
}
|
|
|
|
|
|
}
|