// 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, "\r\n"); fwrite(buf, 1, length, fd); length = _snprintf(buf, 512, "\r\n"); fwrite(buf, 1, length, fd); __exit: if (fd >= 0) fclose(fd); if (buf) delete buf; return; }