📄 readdata.cpp
字号:
// ReadData.cpp: implementation of the CReadData class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Mine.h"
#include "ReadData.h"
#include "math.h"
#include "DB.h"
#include "Entity.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern _RecordsetPtr g_pRecordset;
extern int g_nMaxLayer;
extern CNode *g_pNodeHead;
extern float g_fZTranslation;
extern float g_fZZoom;
extern float g_fZMin;
extern float g_fZMax;
extern float xMin,yMin,xMax,yMax;
extern float g_fXZoom;
extern float g_fYZoom;
extern float g_fZZoom;
extern float g_fSize;
extern float g_fXTranslation;
extern float g_fYTranslation;
extern float g_fXMin;
extern float g_fXMax;
extern float g_fYMin;
extern float g_fYMax;
extern float g_fZMin;
extern float g_fZMax;
extern int g_nMaxLayer;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CReadData::CReadData()
{
}
CReadData::~CReadData()
{
}
void CReadData::ReadAdoData()
{
//sql检索语句
CDB db;
db.ConnectDB();
db.Query();
CString strSql;
strSql.Format("SELECT * FROM surfacePoint ORDER BY id ASC");
// db.Query(strSql);
CEntity entity;
CNode *node;
float zMin,zMax;
zMin = zMax = 0;
g_pRecordset->MoveFirst();
xMin=xMax=(float)g_pRecordset->GetCollect("x");
yMin=yMax=(float)g_pRecordset->GetCollect("y");
zMin=zMax=(float)g_pRecordset->GetCollect("z");
while (!g_pRecordset->adoEOF)
{
node=entity.InitNode();
//node->m_nNodeID= (long)m_pRecordset->GetCollect("id");
node->x = (float)g_pRecordset->GetCollect("x");
node->y= (float)g_pRecordset->GetCollect("y");
node->z=(float)g_pRecordset->GetCollect("z");
node->m_nSurfaceLayer = 1;
node->up = NULL;
node->down = NULL;
xMin=xMin<node->x?xMin:node->x ;
xMax=xMax>node->x?xMax:node->x ;
yMin=yMin<node->y?yMin:node->y ;
yMax=yMax>node->y?yMax:node->y ;
zMin=zMin<node->z?zMin:node->z;
zMax=zMax>node->z?zMax:node->z;
g_pRecordset->MoveNext();
}
g_nMaxLayer = 1;
g_pRecordset->Close();
g_fXMin = xMin;
g_fXMax = xMax;
g_fYMin = yMin;
g_fYMax = yMax;
g_fZMin = zMin;
g_fZMax = zMax;
g_fXTranslation = (xMin+xMax)/2;
g_fYTranslation = (yMin+yMax)/2;
g_fZTranslation = (g_fZMax + g_fZMin)/2;
g_fXZoom = fabs((xMax-xMin)/1000);
g_fYZoom = fabs((yMax-yMin)/800);
// g_fZZoom = (zMax - zMin)/500;
node=g_pNodeHead->next ;
while(node!=g_pNodeHead)
{
node->x=(node->x-g_fXTranslation)/7+700;
node->y=(node->y-g_fYTranslation)/7+400;
// node->x=(node->x-g_fXTranslation)/g_fXZoom;
// node->y=(node->y-g_fYTranslation)/g_fYZoom;
node->z=(node->z-g_fYTranslation)/750+4;
node=node->next ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -