a
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user