1290 lines
39 KiB
C++
1290 lines
39 KiB
C++
#pragma warning( push ,0)
|
||
#include <math.h>
|
||
// #include <osg/LineStipple>
|
||
// #include <osg/DrawPixels>
|
||
#include <cassert>
|
||
#include <QApplication>
|
||
#include <QDebug>
|
||
#include <QGraphicsWidget>
|
||
#include "QPainter"
|
||
// #include "QtWindowWellSection.h"
|
||
// #include "HeadObj.h"
|
||
//#include "geometryutils.h"
|
||
#include "DrawBase.h"
|
||
// #include "WellSectionConst.h"
|
||
// #include "VecSceneManager.h"
|
||
// #include "QtWellTrackNode.h"
|
||
// #include "ConsoleOutputWidget.h"
|
||
// #include "ObjProject.h"
|
||
|
||
#pragma warning( pop )
|
||
|
||
BEGIN_OSGGRAPHICS_NAMESPACE;
|
||
|
||
CDrawBase::CDrawBase()/*:CQtWellLogTrackNode() */
|
||
{
|
||
// hHeadObj = new HeadObj(this,GL_LINES);
|
||
// m_pWave = new ClientItem(this);
|
||
m_Value=0;
|
||
m_SDep=0;
|
||
m_EDep=0;
|
||
m_Rlev=0.125;
|
||
iIndex=-1;
|
||
nHeight=0;
|
||
nWidth=0;
|
||
m_PlotSdep=0;
|
||
m_PlotEdep=0;
|
||
// m_MoveDep=0;
|
||
m_PointNum=0;
|
||
LITH_WIDTH=32;
|
||
LITH_HEIGHT=16;
|
||
// m_pLeftText = new CItemText();
|
||
// m_pRightText = new CItemText();
|
||
// m_pCurveNameText=new CItemText();
|
||
// m_pUnitText=new CItemText();
|
||
|
||
m_pWellLog=NULL;
|
||
}
|
||
|
||
CDrawBase::~CDrawBase()
|
||
{
|
||
if(m_Value!=NULL)
|
||
delete []m_Value;
|
||
// if(hHeadObj&&(long long)hHeadObj->pFF>0x00ffff&&hHeadObj->pFF!=(CDrawBase*)0xfeeefeeefeeefeee&&hHeadObj->pFF!=(CDrawBase*)0xdddddddddddddddd) {
|
||
// if(m_pLeftText){
|
||
// m_pLeftText->setParentItem(NULL);
|
||
// delete m_pLeftText;
|
||
// m_pLeftText=NULL;
|
||
// }
|
||
// if(m_pRightText){
|
||
// m_pRightText->setParentItem(NULL);
|
||
// delete m_pRightText;
|
||
// m_pRightText=NULL;
|
||
// }
|
||
// if(m_pCurveNameText){
|
||
// m_pCurveNameText->setParentItem(NULL);
|
||
// delete m_pCurveNameText;
|
||
// m_pCurveNameText=NULL;
|
||
// }
|
||
// if(m_pUnitText) {
|
||
// m_pUnitText->setParentItem(NULL);
|
||
// delete m_pUnitText;
|
||
// m_pUnitText=NULL;
|
||
// }
|
||
// m_pWave->pFF=NULL;
|
||
// hHeadObj->setParentItem(NULL);
|
||
// delete hHeadObj;
|
||
// hHeadObj=NULL;
|
||
// }
|
||
// if(m_pWave&&m_pWave->pFF&&m_pWave->pFF!=(CDrawBase*)0xfeeefeeefeeefeee&&m_pWave->pFF!=(CDrawBase*)0xdddddddddddddddd&&m_pWave->pFF!=(CDrawBase*)0xabababababababab) {
|
||
// m_pWave->pFF=NULL;
|
||
// m_pWave->setParentItem(NULL);
|
||
// delete m_pWave;
|
||
// m_pWave=NULL;
|
||
// }
|
||
}
|
||
double CDrawBase::getYOSGGlobalFromPixel(double y)
|
||
{
|
||
// if(!m_pSceneManager) return 0;
|
||
// CObjWellLogTrack *pLogTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrack( m_pWellLog);
|
||
// if( pLogTrack )
|
||
// {
|
||
// CObjWellTrack*m_pWellTrack = pLogTrack->GetWellTrack();
|
||
// if(!m_pWellTrack) return 0;
|
||
// CQtWindowWellSection *pWin=dynamic_cast<CQtWindowWellSection*>(m_pSceneManager->GetVecWindow());
|
||
// if(pWin){
|
||
// return pWin->getYOSGGlobalFromPixel(m_pWellTrack,y);
|
||
// }
|
||
// osg::Vec3d vecGeoNormal;
|
||
// m_pSceneManager->GetCoordinate()->ConvertCoordDouble( m_pWellTrack->GetID(),eCoord_OSGPixel,osg::Vec3d(0,y,0),eCoord_OSGGlobal,vecGeoNormal );
|
||
// return vecGeoNormal[1];
|
||
// }
|
||
return 0;
|
||
}
|
||
// osg::Vec3d CDrawBase::OSGPixleToOSGLocal(osg::Vec3d vOSGPixel )
|
||
// {
|
||
// osg::Vec3d vecOSGLocal;
|
||
// m_pQtSceneManager->GetCoordinate()->ConvertCoordDouble(NULL,eCoord_OSGPixel, vOSGPixel,
|
||
// eCoord_OSGLocal,vecOSGLocal );
|
||
// return vecOSGLocal;
|
||
// }
|
||
|
||
double CDrawBase::getYGeoNormalFromPixel(double y)
|
||
{
|
||
// if(!m_pSceneManager) return 0;
|
||
// CObjWellLogTrack *pLogTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrack( m_pWellLog);
|
||
// if( pLogTrack )
|
||
// {
|
||
// CObjWellTrack*m_pWellTrack = pLogTrack->GetWellTrack();
|
||
// if(!m_pWellTrack) return 0;
|
||
// CQtWindowWellSection *pWin=dynamic_cast<CQtWindowWellSection*>(m_pSceneManager->GetVecWindow());
|
||
// if(pWin){
|
||
// return pWin->getYGeoNormalFromPixel(m_pWellTrack,y);
|
||
// }
|
||
// osg::Vec3d vecGeoNormal;
|
||
// m_pSceneManager->GetCoordinate()->ConvertCoordDouble( m_pWellTrack->GetID(),eCoord_OSGPixel,osg::Vec3d(0,y,0),eCoord_GEO,vecGeoNormal );
|
||
// return vecGeoNormal[1];
|
||
// }
|
||
return 0;
|
||
}
|
||
double CDrawBase::getYFromOSGPixel(double y)
|
||
{
|
||
return 0;
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if(!pWellNode) return 0;
|
||
// if(m_pSceneManager->IsWellSectonHorizonLayout())
|
||
// {
|
||
// return pWellNode->ConvertX(eCoord_OSGPixel,y,eCoord_GEO);
|
||
// }
|
||
// else {
|
||
// return pWellNode->ConvertY(eCoord_OSGPixel,y,eCoord_GEO);
|
||
// }
|
||
// return 0;
|
||
}
|
||
|
||
double CDrawBase::getXFromOSGPixel(double x,bool IsWF,bool CalType)
|
||
{
|
||
return 0;
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if(!pWellNode) return 0;
|
||
// float x0=0;
|
||
// CSheet& sheet = GetWellTrackNode()->GetWellSheet();
|
||
// if(m_pSceneManager->IsWellSectonHorizonLayout()) {
|
||
// osg::Vec3d vecSheet = sheet.VecToSheetCoord( osg::Vec3d(1,x,1),eCoord_OSGPixel,this->GetID() );
|
||
// x0=vecSheet[0];
|
||
// }
|
||
// else {
|
||
// osg::Vec3d vecSheet = sheet.VecToSheetCoord( osg::Vec3d(x,1,1),eCoord_OSGPixel,this->GetID() );
|
||
// x0=vecSheet[0];
|
||
// }
|
||
// const sTrack& sTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrackInfo(m_pWellLog);
|
||
// CObjWellLogTrack *pLogTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrack( m_pWellLog );
|
||
|
||
// int nColumeIndex = sTrack.nBeginColumIndex;
|
||
// if( nColumeIndex<0 )
|
||
// {
|
||
// return 0;
|
||
// }
|
||
// QList<PaiObject*> mchilds;
|
||
// pLogTrack->GetChildren(mchilds);
|
||
// CellRange cellRange = sTrack.GetCellRange();
|
||
// cellRange.nEndRow = cellRange.nBeginRow + mchilds.indexOf( m_pWellLog ) + 1 ;
|
||
// cellRange.nBeginRow = cellRange.nEndRow;
|
||
|
||
// int nRowNumber = pWellNode->GetWellSheet().GetRowNumber();
|
||
// QRectF rcF = pWellNode->GetWellSheet().GetCellRect( CellRange(nRowNumber-1,nRowNumber-1,
|
||
// sTrack.nBeginColumIndex,sTrack.nEndColumIndex));
|
||
// if(rcF.width()==0) return 0;
|
||
// float val=0;
|
||
// float lsc=0,rsc=0;
|
||
// if ( CalType !=AXIS_LINEAR ) {
|
||
// if(IsWF) {
|
||
// if(mWaveMes.m_Right-mWaveMes.m_Left>0) {
|
||
// rsc=log10f(mWaveMes.m_Left);
|
||
// lsc=log10f(mWaveMes.m_Right);
|
||
// }
|
||
// else {
|
||
// lsc=log10f(mWaveMes.m_Left);
|
||
// rsc=log10f(mWaveMes.m_Right);
|
||
// }
|
||
// }
|
||
// else {
|
||
// if(m_RightVal-m_LeftVal>0) {
|
||
// rsc=log10f(m_LeftVal);
|
||
// lsc=log10f(m_RightVal);
|
||
// }
|
||
// else {
|
||
// lsc=log10f(m_LeftVal);
|
||
// rsc=log10f(m_RightVal);
|
||
// }
|
||
// }
|
||
// }
|
||
// else {
|
||
// if(IsWF) {
|
||
// if(mWaveMes.m_Right-mWaveMes.m_Left>0) {
|
||
// rsc=(mWaveMes.m_Left);
|
||
// lsc=(mWaveMes.m_Right);
|
||
// }
|
||
// else {
|
||
// lsc=(mWaveMes.m_Right);
|
||
// rsc=(mWaveMes.m_Left);
|
||
// }
|
||
// }
|
||
// else {
|
||
// if(m_RightVal-m_LeftVal>0) {
|
||
// rsc=(m_LeftVal);
|
||
// lsc=(m_RightVal);
|
||
// }
|
||
// else {
|
||
// lsc=(m_RightVal);
|
||
// rsc=(m_LeftVal);
|
||
// }
|
||
// }
|
||
// }
|
||
// val=(rcF.width()-(x0-rcF.left()))*(rsc-lsc)/rcF.width()+lsc;
|
||
// if ( CalType !=AXIS_LINEAR ) {
|
||
// val=powf(10.0f,val);
|
||
// }
|
||
// return val;
|
||
}
|
||
|
||
double CDrawBase::getYGeoFromOSGGlobal(double yOSGGlobal)
|
||
{
|
||
return 0;
|
||
// if(!m_pSceneManager) return 0;
|
||
// CObjWellLogTrack *pLogTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrack( m_pWellLog);
|
||
// if( pLogTrack )
|
||
// {
|
||
// CObjWellTrack*m_pWellTrack = pLogTrack->GetWellTrack();
|
||
// if(!m_pWellTrack) return 0;
|
||
// osg::Vec3d vecGeoNormal;
|
||
// bool bHorizonLayout=m_pWellSceneManager->IsWellSectonHorizonLayout();
|
||
// if(bHorizonLayout) {
|
||
// m_pSceneManager->GetCoordinate()->ConvertCoordDouble( m_pWellTrack->GetID(),eCoord_OSGGlobal,osg::Vec3d(yOSGGlobal,yOSGGlobal,0),eCoord_GEO,vecGeoNormal );
|
||
// }
|
||
// else {
|
||
// m_pSceneManager->GetCoordinate()->ConvertCoordDouble( m_pWellTrack->GetID(),eCoord_OSGGlobal,osg::Vec3d(0,yOSGGlobal,0),eCoord_GEO,vecGeoNormal );
|
||
// }
|
||
// return vecGeoNormal[1];
|
||
// }
|
||
// return 0;
|
||
}
|
||
double CDrawBase::getXGeoFromOSGGlobal(double xOSGGlobal,bool IsWF)
|
||
{
|
||
return 0;
|
||
// if(!m_pSceneManager) return 0;
|
||
// CSheet *pSheet=m_pWellSceneManager->GetCurrentSheet();
|
||
|
||
// osg::Vec3d vecSheet = pSheet->VecToSheetCoord( osg::Vec3d(xOSGGlobal,0,0),eCoord_OSGGlobal,this->GetID() );
|
||
// int x0=vecSheet[0];
|
||
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if( !pWellNode ) return 0;
|
||
|
||
// const sTrack& sTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrackInfo(m_pWellLog);
|
||
// CObjWellLogTrack *pLogTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrack( m_pWellLog );
|
||
|
||
// int nColumeIndex = sTrack.nBeginColumIndex;
|
||
// if( nColumeIndex<0 )
|
||
// {
|
||
// return 0;
|
||
// }
|
||
// QList<PaiObject*> mchilds;
|
||
// pLogTrack->GetChildren(mchilds);
|
||
|
||
// CellRange cellRange = sTrack.GetCellRange();
|
||
// cellRange.nEndRow = cellRange.nBeginRow + mchilds.indexOf( m_pWellLog ) + 1 ;
|
||
// cellRange.nBeginRow = cellRange.nEndRow;
|
||
|
||
// int nRowNumber = pWellNode->GetWellSheet().GetRowNumber();
|
||
// QRectF rcF = pWellNode->GetWellSheet().GetCellRect( CellRange(nRowNumber-1,nRowNumber-1,
|
||
// sTrack.nBeginColumIndex,sTrack.nEndColumIndex));
|
||
// if(rcF.width()==0) return 0;
|
||
// float val=0;
|
||
// if(IsWF) {
|
||
// if(mWaveMes.m_Right-mWaveMes.m_Left>0) val=(x0-rcF.left())*(mWaveMes.m_Right-mWaveMes.m_Left)/rcF.width()+mWaveMes.m_Left;
|
||
// else val=(rcF.width()-(x0-rcF.left()))*(mWaveMes.m_Left-mWaveMes.m_Right)/rcF.width()+mWaveMes.m_Right;
|
||
// }
|
||
// else {
|
||
// if(m_RightVal-m_LeftVal>0) val=(x0-rcF.left())*(m_RightVal-m_LeftVal)/rcF.width()+m_LeftVal;
|
||
// else val=(rcF.width()-(x0-rcF.left()))*(m_LeftVal-m_RightVal)/rcF.width()+m_RightVal;
|
||
// }
|
||
// return val;
|
||
}
|
||
|
||
double CDrawBase::getXOSGGlobalFromPixel(double x)
|
||
{
|
||
// if(!m_pSceneManager) return 0;
|
||
// CObjWellLogTrack *pLogTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrack( m_pWellLog);
|
||
// if( pLogTrack )
|
||
// {
|
||
// CObjWellTrack*m_pWellTrack = pLogTrack->GetWellTrack();
|
||
// if(!m_pWellTrack) return 0;
|
||
// osg::Vec3d vecGeoNormal;
|
||
// m_pSceneManager->GetCoordinate()->ConvertCoordDouble( m_pWellTrack->GetID(),eCoord_OSGPixel,osg::Vec3d(x,0,0),eCoord_OSGGlobal,vecGeoNormal );
|
||
// return vecGeoNormal[0];
|
||
// }
|
||
return 0;
|
||
}
|
||
|
||
void CDrawBase::ReadData()
|
||
{
|
||
|
||
//CMemRdWt mrw;
|
||
|
||
//if (!mrw.Open(sFilePath.toStdString().c_str())) // 打开井文件
|
||
// return;
|
||
|
||
//iIndex = mrw.OpenWave(sName.toStdString().c_str());//("EP_S");
|
||
//if(iIndex<0)return;
|
||
//objViewInfo->m_LogName = sName;
|
||
//mrw.GetWaveInfo(iIndex,&WaveInfo);
|
||
|
||
//m_SDep = WaveInfo.StartDepth;
|
||
//m_EDep = WaveInfo.EndDepth;
|
||
//m_Rlev = WaveInfo.DepLevel;
|
||
//int m_nSamples = WaveInfo.TimeSamples;
|
||
//int m_flRlev2 = WaveInfo.TimeLevel;
|
||
//m_PointNum = (float)(fabs((m_EDep-m_SDep)/m_Rlev+0.5));
|
||
//if(m_Value!=NULL)
|
||
// delete []m_Value;
|
||
|
||
}
|
||
void CDrawBase::SaveData()
|
||
{
|
||
}
|
||
void CDrawBase::InitProperty()
|
||
{
|
||
}
|
||
void CDrawBase::GetProperty()
|
||
{
|
||
}
|
||
void CDrawBase::Refurbish()
|
||
{
|
||
}
|
||
void CDrawBase::DrawLith(QPainter *pDC,QPointF *pt,int nPoint,QBrush m_Colorbrush,QColor pColor,QColor bkColor)
|
||
{
|
||
int x=15;
|
||
|
||
unsigned char *tPixel=new unsigned char[16*16];
|
||
|
||
nHeight=x+1;
|
||
nWidth=x+1;
|
||
LITH_HEIGHT=x+1;
|
||
LITH_WIDTH=x+1;
|
||
// mScale=cx*cy;
|
||
|
||
QImage MemDC(LITH_WIDTH,LITH_HEIGHT,QImage::Format_ARGB32);
|
||
QPainter pa1(&MemDC);
|
||
pa1.fillRect(QRectF(0,0,LITH_WIDTH,LITH_HEIGHT),m_Colorbrush);
|
||
JudgePixel(MemDC,bkColor,tPixel);
|
||
|
||
// x=15/25.0*cy*cx;
|
||
// x=(int)(x/16.0)*16-1;
|
||
// if(x>4*16-1) x=4*14-1;
|
||
if(x<15) x=15;
|
||
x/=2;
|
||
nHeight=x+1;
|
||
nWidth=x+1;
|
||
LITH_HEIGHT=x+1;
|
||
LITH_WIDTH=x+1;
|
||
//mScale=cx*cy;
|
||
|
||
unsigned char *bPixel = new unsigned char[LITH_WIDTH*LITH_HEIGHT];
|
||
memset(bPixel,0,LITH_WIDTH*LITH_HEIGHT);
|
||
|
||
QPointF *point = new QPointF[LITH_WIDTH*LITH_HEIGHT];
|
||
for(int i=0;i<LITH_HEIGHT;i++) {
|
||
for(int j=0;j<LITH_WIDTH;j++) {
|
||
point[i*LITH_WIDTH+j].setX(0);
|
||
point[i*LITH_WIDTH+j].setY(0);
|
||
}
|
||
}
|
||
// memset(point,0,LITH_WIDTH*LITH_HEIGHT*sizeof(POINT));
|
||
int *pointn = new int[LITH_HEIGHT];
|
||
float scale=(x+1)/16.0;
|
||
for (int i=0; i<LITH_WIDTH; i++)
|
||
{
|
||
for (int j=0; j<LITH_HEIGHT; j++)
|
||
{
|
||
int ja=j/scale;
|
||
if(ja>15) ja=15;
|
||
int ib=i/scale;
|
||
if(ib>15) ib=15;
|
||
if(tPixel[ja*16+ib]) {
|
||
bPixel[j*LITH_WIDTH+i]=1;
|
||
}
|
||
}
|
||
}
|
||
delete []tPixel;
|
||
for (int j=0; j<LITH_HEIGHT; j++) {
|
||
pointn[j]=0;
|
||
int jj=0;
|
||
int i=0;
|
||
for (i=0; i<LITH_WIDTH; i++)
|
||
{
|
||
if(bPixel[j*LITH_WIDTH+i]) {
|
||
if(jj==0) point[j*LITH_WIDTH+pointn[j]].setX(i);
|
||
jj=1;
|
||
}
|
||
else if(jj) {
|
||
jj=0;
|
||
point[j*LITH_WIDTH+pointn[j]].setY(i);
|
||
pointn[j]++;
|
||
}
|
||
}
|
||
if(jj) {
|
||
point[j*LITH_WIDTH+pointn[j]].setY(i);
|
||
if(point[j*LITH_WIDTH+pointn[j]].y()<0)point[j*LITH_WIDTH+pointn[j]].setY(0);
|
||
pointn[j]++;
|
||
}
|
||
}
|
||
delete [] bPixel;
|
||
FillLith(pDC,pt,nPoint,pColor,qRgb(0,0,0),point,pointn,LITH_WIDTH,LITH_HEIGHT);
|
||
|
||
delete point;
|
||
delete pointn;
|
||
}
|
||
|
||
void CDrawBase::JudgePixel(QImage &pDC,QColor bkColor,unsigned char *strPixel)
|
||
{
|
||
QRgb bc=bkColor.rgb();
|
||
int i,j;
|
||
memset(strPixel,0x00,LITH_WIDTH*LITH_HEIGHT);
|
||
for (i=0; i<LITH_WIDTH; i++)
|
||
{
|
||
for (j=0; j<LITH_HEIGHT; j++)
|
||
{
|
||
strPixel[j*LITH_WIDTH+i] = (pDC.pixel(i,j)!=bc);
|
||
}
|
||
}
|
||
}
|
||
void CDrawBase::JudgePixel(unsigned char *iptrn,unsigned char *strPixel)
|
||
{
|
||
int i,j,k,m;
|
||
unsigned char ch,chPixel[8];
|
||
|
||
chPixel[0] = 1;
|
||
for (i=1; i<8; i++)
|
||
chPixel[i] = chPixel[i-1]*2;
|
||
|
||
memset(strPixel,0x00,32*16);
|
||
for (i=0; i<LITH_HEIGHT; i++)
|
||
{
|
||
for (j=0; j<4; j++)
|
||
{
|
||
ch = iptrn[i*4+j];
|
||
for (k=0; k<8; k++)
|
||
{
|
||
if ( ch & chPixel[7-k] )
|
||
strPixel[i*32+j*8+k] = 1;//ch & chPixel[7-k] ;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||
// 功能: 填充多边形
|
||
//
|
||
// 参数: lpPoints: 指向顶点坐标数组的指针,数组类型为POINT,多边形由它们顺次封闭连接得到
|
||
// nCount: 顶点的个数
|
||
// nColor: 填充的颜色 默认为黑色
|
||
// pDC: 设备句柄指针
|
||
//
|
||
// 返回: 无返回值
|
||
//
|
||
// 说明: 可以是边相交的多边形
|
||
//
|
||
//
|
||
void CDrawBase::FillLith(QPainter *pDC,QPointF *lpPoints,int nCount,QColor crFore,QColor crBack,QPointF *pixels,int *pointn,int nWidth,int nHeight)
|
||
{
|
||
int penw = 2;
|
||
if(penw<0) penw=1;
|
||
// 检查参数合法性
|
||
if(nCount<=2) return;
|
||
pDC->save();
|
||
QPen pen=pDC->pen();
|
||
pen.setColor(crFore);
|
||
pen.setStyle(Qt::PenStyle::SolidLine);
|
||
pen.setWidth(penw);
|
||
pDC->setPen(pen);
|
||
|
||
int i=0,j=0,k=0;
|
||
int y0=0,y1=0; // 扫描线的最大和最小y坐标
|
||
LPEdge pAET=NULL; // 活化边表头指针
|
||
LPEdge * pET=NULL; // 边表头指针
|
||
|
||
pAET=new Edge; // 初始化表头指针,第一个元素不用
|
||
pAET->pNext=NULL;
|
||
// 获取y方向扫描线边界
|
||
for(i=1;i<nCount;i++)
|
||
{
|
||
lpPoints[i].setY(lpPoints[i].y()/penw*penw);
|
||
}
|
||
y0=y1=lpPoints[0].y();
|
||
for(i=1;i<nCount;i++)
|
||
{
|
||
if(lpPoints[i].y()<y0) y0=lpPoints[i].y();
|
||
else if(lpPoints[i].y()>y1) y1=lpPoints[i].y();
|
||
}
|
||
if(y0>=y1) {
|
||
delete pAET;
|
||
pDC->restore();
|
||
return;
|
||
}
|
||
// 初始化边表,第一个元素不用
|
||
pET=new LPEdge[(y1-y0)/penw+1];
|
||
for(i=0;i<=y1-y0;i+=penw)
|
||
{
|
||
pET[i/penw]= new Edge;
|
||
pET[i/penw]->pNext=NULL;
|
||
}
|
||
for(i=0;i<nCount;i++)
|
||
{
|
||
j=(i+1)%nCount; // 组成边的下一点
|
||
if(lpPoints[i].y() != lpPoints[j].y())// 如果该边不是水平的则加入边表
|
||
{
|
||
LPEdge peg; // 指向该边的指针
|
||
LPEdge ppeg; // 指向边指针的指针
|
||
// 构造边
|
||
peg =new Edge;
|
||
k=(lpPoints[i].y()>lpPoints[j].y())?i:j;
|
||
peg->ymax=lpPoints[k].y(); // 该边最大y坐标
|
||
k=(k==j)?i:j;
|
||
peg->x=(float)lpPoints[k].x(); // 该边与扫描线焦点x坐标
|
||
peg->dx=(float)(lpPoints[i].x()-lpPoints[j].x())/(lpPoints[i].y()-lpPoints[j].y());// 该边斜率的倒数
|
||
peg->pNext=NULL;
|
||
// 插入边
|
||
ppeg=pET[(int)((lpPoints[k].y()-y0)/penw)];
|
||
while(ppeg->pNext) ppeg=ppeg->pNext;
|
||
ppeg->pNext=peg;
|
||
}// end if
|
||
}// end for i
|
||
|
||
// 扫描
|
||
for(i=y0;i<=y1;i+=penw)
|
||
{
|
||
LPEdge peg0=pET[(i-y0)/penw]->pNext;
|
||
LPEdge peg1=pET[(i-y0)/penw];
|
||
if(peg0)// 有新边加入
|
||
{
|
||
while(peg1->pNext) peg1=peg1->pNext;
|
||
peg1->pNext=pAET->pNext;
|
||
pAET->pNext=peg0;
|
||
}
|
||
// 按照x递增排序pAET
|
||
peg0=pAET;
|
||
while(peg0->pNext)
|
||
{
|
||
LPEdge pegmax=peg0;
|
||
LPEdge peg1=peg0;
|
||
LPEdge pegi=NULL;
|
||
while(peg1->pNext)
|
||
{
|
||
if(peg1->pNext->x>pegmax->pNext->x) pegmax=peg1;
|
||
peg1=peg1->pNext;
|
||
}
|
||
pegi=pegmax->pNext;
|
||
pegmax->pNext=pegi->pNext;
|
||
pegi->pNext=pAET->pNext;
|
||
pAET->pNext=pegi;
|
||
if(peg0 == pAET) peg0=pegi;
|
||
}
|
||
// 遍历活边表,画线
|
||
peg0=pAET;
|
||
while(peg0->pNext)
|
||
{
|
||
if(peg0->pNext->pNext)
|
||
{
|
||
LineFillLith(pDC,(int)peg0->pNext->x,(int)peg0->pNext->pNext->x,i/penw,penw,crFore,crBack,pixels,pointn,nWidth,nHeight);
|
||
peg0=peg0->pNext->pNext;
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
// 把ymax=i的节点从活边表删除并把每个节点的x值递增dx
|
||
peg0=pAET;
|
||
while(peg0->pNext)
|
||
{
|
||
if(peg0->pNext->ymax < i+penw+1)
|
||
{
|
||
peg1=peg0->pNext;
|
||
peg0->pNext=peg0->pNext->pNext; //删除
|
||
delete peg1;
|
||
continue;
|
||
}
|
||
peg0->pNext->x+=peg0->pNext->dx; //把每个节点的x值递增dx
|
||
peg0=peg0->pNext;
|
||
}
|
||
}
|
||
// 删除边表
|
||
for(i=0;i<=y1-y0;i+=penw) if(pET[i/penw]) {
|
||
delete pET[i/penw];
|
||
}
|
||
if(pAET) delete pAET;
|
||
if(pET) delete[] pET;
|
||
pDC->restore();
|
||
}
|
||
void CDrawBase::FillLith(QPainter *pDC,QPointF *lpPoints,int nCount,QColor crFore,QColor crBack,QImage image,int x00,int y00)
|
||
{
|
||
int penw = 1;
|
||
if(penw<0) penw=1;
|
||
// 检查参数合法性
|
||
if(nCount<=2) return;
|
||
pDC->save();
|
||
QPen pen=pDC->pen();
|
||
pen.setColor(crFore);
|
||
pen.setStyle(Qt::PenStyle::SolidLine);
|
||
pen.setWidth(penw);
|
||
pDC->setPen(pen);
|
||
|
||
int i=0,j=0,k=0;
|
||
int y0=0,y1=0; // 扫描线的最大和最小y坐标
|
||
LPEdge pAET=NULL; // 活化边表头指针
|
||
LPEdge * pET=NULL; // 边表头指针
|
||
|
||
pAET=new Edge; // 初始化表头指针,第一个元素不用
|
||
pAET->pNext=NULL;
|
||
// 获取y方向扫描线边界
|
||
for(i=1;i<nCount;i++)
|
||
{
|
||
lpPoints[i].setY(lpPoints[i].y()/penw*penw);
|
||
}
|
||
y0=y1=lpPoints[0].y();
|
||
for(i=1;i<nCount;i++)
|
||
{
|
||
if(lpPoints[i].y()<y0) y0=lpPoints[i].y();
|
||
else if(lpPoints[i].y()>y1) y1=lpPoints[i].y();
|
||
}
|
||
if(y0>=y1) {
|
||
delete pAET;
|
||
pDC->restore();
|
||
return;
|
||
}
|
||
// 初始化边表,第一个元素不用
|
||
pET=new LPEdge[(y1-y0)/penw+1];
|
||
for(i=0;i<=y1-y0;i+=penw)
|
||
{
|
||
pET[i/penw]= new Edge;
|
||
pET[i/penw]->pNext=NULL;
|
||
}
|
||
for(i=0;i<nCount;i++)
|
||
{
|
||
j=(i+1)%nCount; // 组成边的下一点
|
||
if(lpPoints[i].y() != lpPoints[j].y())// 如果该边不是水平的则加入边表
|
||
{
|
||
LPEdge peg; // 指向该边的指针
|
||
LPEdge ppeg; // 指向边指针的指针
|
||
// 构造边
|
||
peg =new Edge;
|
||
k=(lpPoints[i].y()>lpPoints[j].y())?i:j;
|
||
peg->ymax=lpPoints[k].y(); // 该边最大y坐标
|
||
k=(k==j)?i:j;
|
||
peg->x=(float)lpPoints[k].x(); // 该边与扫描线焦点x坐标
|
||
peg->dx=(float)(lpPoints[i].x()-lpPoints[j].x())/(lpPoints[i].y()-lpPoints[j].y());// 该边斜率的倒数
|
||
peg->pNext=NULL;
|
||
// 插入边
|
||
ppeg=pET[(int)((lpPoints[k].y()-y0)/penw)];
|
||
while(ppeg->pNext) ppeg=ppeg->pNext;
|
||
ppeg->pNext=peg;
|
||
}// end if
|
||
}// end for i
|
||
|
||
// 扫描
|
||
for(i=y0;i<=y1;i+=penw)
|
||
{
|
||
LPEdge peg0=pET[(i-y0)/penw]->pNext;
|
||
LPEdge peg1=pET[(i-y0)/penw];
|
||
if(peg0)// 有新边加入
|
||
{
|
||
while(peg1->pNext) peg1=peg1->pNext;
|
||
peg1->pNext=pAET->pNext;
|
||
pAET->pNext=peg0;
|
||
}
|
||
// 按照x递增排序pAET
|
||
peg0=pAET;
|
||
while(peg0->pNext)
|
||
{
|
||
LPEdge pegmax=peg0;
|
||
LPEdge peg1=peg0;
|
||
LPEdge pegi=NULL;
|
||
while(peg1->pNext)
|
||
{
|
||
if(peg1->pNext->x>pegmax->pNext->x) pegmax=peg1;
|
||
peg1=peg1->pNext;
|
||
}
|
||
pegi=pegmax->pNext;
|
||
pegmax->pNext=pegi->pNext;
|
||
pegi->pNext=pAET->pNext;
|
||
pAET->pNext=pegi;
|
||
if(peg0 == pAET) peg0=pegi;
|
||
}
|
||
// 遍历活边表,画线
|
||
peg0=pAET;
|
||
while(peg0->pNext)
|
||
{
|
||
if(peg0->pNext->pNext)
|
||
{
|
||
LineFillLith(pDC,(int)peg0->pNext->x,(int)peg0->pNext->pNext->x,i/penw,penw,crFore,crBack,image,x00,y00);
|
||
peg0=peg0->pNext->pNext;
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
// 把ymax=i的节点从活边表删除并把每个节点的x值递增dx
|
||
peg0=pAET;
|
||
while(peg0->pNext)
|
||
{
|
||
if(peg0->pNext->ymax < i+penw+1)
|
||
{
|
||
peg1=peg0->pNext;
|
||
peg0->pNext=peg0->pNext->pNext; //删除
|
||
delete peg1;
|
||
continue;
|
||
}
|
||
peg0->pNext->x+=peg0->pNext->dx; //把每个节点的x值递增dx
|
||
peg0=peg0->pNext;
|
||
}
|
||
}
|
||
// 删除边表
|
||
for(i=0;i<=y1-y0;i+=penw) if(pET[i/penw]) {
|
||
delete pET[i/penw];
|
||
}
|
||
if(pAET) delete pAET;
|
||
if(pET) delete[] pET;
|
||
pDC->restore();
|
||
}
|
||
|
||
void CDrawBase::LineFillLith(QPainter *hdc,int x1,int x2,int y,int ipen,QColor crFore,QColor crBack,QPointF *pixels,int *pointn,int nWidth,int nHeight)
|
||
{
|
||
int iy,i,ix1,ix2,l1,l2,l3;
|
||
int x11;
|
||
bool bQuit = FALSE;
|
||
iy = y % nHeight;
|
||
if(iy<0) return;
|
||
l1 = x1 % nWidth;
|
||
l3 = x1 / nWidth;
|
||
l2 = nWidth;
|
||
int x0=l3*nWidth;
|
||
x11 = x0;//max width
|
||
int loop=0;
|
||
while ( 1 )
|
||
{
|
||
if ( x11+nWidth > x2 ) l2 = x2-x11;//end pos
|
||
for(i=0;i<pointn[iy];i++) {
|
||
if(pixels[iy*nWidth+i].x()<l1&&pixels[iy*nWidth+i].y()<l1) continue;
|
||
if(pixels[iy*nWidth+i].x()>l2) break;
|
||
ix1=x11+pixels[iy*nWidth+i].x()*ipen;
|
||
ix2=x11+pixels[iy*nWidth+i].y()*ipen;
|
||
// if(ix1<l1) ix1=l1;
|
||
// if(ix2>l2) ix2=l2;
|
||
// hdc->drawPoint(x11+ix1,y,ix2-ix1,1,crFore);
|
||
// ix2=x11+ix2*ipen;
|
||
// ix1=x11+ix1*ipen;
|
||
if(ix1<x1) ix1=x1;
|
||
if(ix2>x2) ix2=x2;
|
||
hdc->drawLine(ix1,y*ipen,ix2,y*ipen);
|
||
}
|
||
l1 = 0;
|
||
l3 ++;//new begin
|
||
loop++;
|
||
x11 = x0+loop*nWidth*ipen;
|
||
if ( x11 > x2) break;
|
||
}
|
||
}
|
||
void CDrawBase::LineFillLith(QPainter *hdc,int x1,int x2,int y,int ipen,QColor crFore,QColor crBack,QImage image,int x0,int y0)
|
||
{
|
||
for(int i=x1;i<x2;i++) {
|
||
if(image.pixel(i,y)==crFore.rgb()) {
|
||
hdc->drawPoint(i+x0,y+y0);
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
|
||
void CDrawBase::_Build()
|
||
{
|
||
// m_IsDrawTrack=0;
|
||
// m_pWellLog = dynamic_cast<CObjWellLog *>(this->GetOSGObject());
|
||
// CQtWellLogTrackNode::_Build();
|
||
// m_pLogTrackViewinfo->SetDrawGrid(false);
|
||
// m_pWellSceneManager = dynamic_cast<CQtWellSceneManager*>(m_pSceneManager);
|
||
|
||
// if(!GetWellTrackNode())
|
||
// return;
|
||
// //////读取数据
|
||
// GetProperty();
|
||
// if(m_pWellLog) {
|
||
// sName = m_pWellLog->GetName();
|
||
// sFilePath = m_pWellLog->GetSlfFileName();
|
||
// }
|
||
// ///////////////////////
|
||
// ///
|
||
// /// read data
|
||
// ///
|
||
// ReadData();
|
||
|
||
// int nLen = 0;
|
||
|
||
// ////////////////////////////////////////
|
||
// //开始build wave部分
|
||
// //道的最小最大值一样
|
||
// m_pWellLogXScalTransform->boundingRect().setWidth(0);
|
||
// QGraphicsRectItem *sheetMatrix = GetWellTrackNode()->GetTextContainer();
|
||
// if(hHeadObj) {
|
||
// hHeadObj->setParentItem(sheetMatrix);
|
||
// hHeadObj->setWellLog(m_pWellLog);
|
||
// }
|
||
// if(m_pLeftText)m_pLeftText->setParentItem(sheetMatrix);
|
||
// if(m_pRightText)m_pRightText->setParentItem(sheetMatrix);
|
||
// if(m_pCurveNameText)m_pCurveNameText->setParentItem(sheetMatrix);
|
||
// if(m_pUnitText)m_pUnitText->setParentItem(sheetMatrix);
|
||
// SettingHeaderElements();
|
||
// if(m_pWave) {
|
||
// m_pWave->setWellLog(m_pWellLog);
|
||
// m_pWave->setFlag( QGraphicsItem::ItemClipsToShape,true);
|
||
// m_pWave->setParentItem(m_pHUDSwitch);
|
||
// m_pWave->m_pWellSceneManager=m_pWellSceneManager;
|
||
// }
|
||
// if(m_pWellSceneManager->GetTrackNodeByLogID(m_pWellLog->GetID()))
|
||
// {
|
||
// m_pWellLogTrack=dynamic_cast<CObjWellLogTrack *>(m_pWellSceneManager->GetTrackNodeByLogID(m_pWellLog->GetID())->GetOSGObject());
|
||
// }
|
||
|
||
// SetXScaleTransform();
|
||
}
|
||
// void CDrawBase::_Update( eUpdateEvent e,CObjectEventParam *pEventParam )
|
||
// {
|
||
// GetProperty();
|
||
// Refurbish();
|
||
// CQtWellLogTrackNode::_Update(e,pEventParam);
|
||
// }
|
||
// void CDrawBase::SetWellSheet(CSheet* wellSheet)
|
||
// {
|
||
// m_pWellSheet = wellSheet;
|
||
// }
|
||
|
||
// CQtWellTrackNode * CDrawBase::GetWellTrackNode()
|
||
// {
|
||
// m_pWellLogTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrack( m_pWellLog);
|
||
// if( m_pWellLogTrack )
|
||
// {
|
||
// QUuid wellTrackID = m_pWellLogTrack->GetWellTrack()->GetID();
|
||
// return dynamic_cast<CQtWellTrackNode * >( m_pSceneManager->GetBuilder( wellTrackID ) );
|
||
// }
|
||
// return NULL;
|
||
// }
|
||
void CDrawBase::DrawCurve(QPainter* pdc,QRectF mrt)
|
||
{
|
||
}
|
||
|
||
void CDrawBase::_UpdateHUD()
|
||
{
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if( !pWellNode ) return;
|
||
// const sTrack& sTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrackInfo(m_pWellLog);
|
||
// if(sTrack.nEndColumIndex<0) return;
|
||
// if(sTrack.nEndRowIndex<0) return;
|
||
// if(sTrack.nBeginRowIndex<0) return;
|
||
// int nColumeIndex = sTrack.nBeginColumIndex;
|
||
// if( nColumeIndex<0 )
|
||
// {
|
||
// return;
|
||
// }
|
||
// CSheet *pSheet=m_pWellSceneManager->GetCurrentSheet();
|
||
// QList<PaiObject*> mchilds;
|
||
// m_pWellLogTrack->GetChildren(mchilds);
|
||
|
||
// CellRange cellRange = sTrack.GetCellRange();
|
||
// cellRange.nEndRow = cellRange.nBeginRow + mchilds.indexOf( m_pWellLog ) + 1 ;
|
||
// cellRange.nBeginRow = cellRange.nEndRow;
|
||
|
||
// QRectF headrcF = pWellNode->GetWellSheet().GetCellRect( cellRange );
|
||
// int nRowNumber = pWellNode->GetWellSheet().GetRowNumber();
|
||
|
||
// QRectF rcGDIViewPort = m_pSceneManager->GetCameraCommand().GetViewPortSize( true,false,true );
|
||
// CSheet &m_pWellSheet=pWellNode->GetWellSheet();
|
||
// osg::Vec3d vec1,vec2,vec3,vec4,vec1_Sheet(rcGDIViewPort.x(),rcGDIViewPort.y(),0);
|
||
// m_pSceneManager->GetCoordinate()->ConvertCoordDouble(this->GetID(),eCoord_OSGPixel, osg::Vec3d(rcGDIViewPort.left(),rcGDIViewPort.top(),0), eCoord_OSGGlobal,vec1 );
|
||
// m_pSceneManager->GetCoordinate()->ConvertCoordDouble(this->GetID(),eCoord_OSGPixel, osg::Vec3d(rcGDIViewPort.right(),rcGDIViewPort.top(),0), eCoord_OSGGlobal,vec2 );
|
||
// QRectF rcF = m_pWellSheet.GetCellRect( CellRange(nRowNumber-1,nRowNumber-1,sTrack.nBeginColumIndex,sTrack.nEndColumIndex));
|
||
// vec3 = m_pWellSheet.SheetCoordToVec(osg::Vec3d(rcF.left(),rcF.top(),0), eCoord_OSGGlobal,this->GetID());
|
||
// vec4 = m_pWellSheet.SheetCoordToVec(osg::Vec3d(rcF.right(),rcF.top(),0), eCoord_OSGGlobal,this->GetID());
|
||
// if(vec4[0]<vec1[0]||vec3[0]>vec2[0]) return;
|
||
|
||
// float dTopDepth = pWellNode->GetWellTrack()->GetTopWellLogDepth();
|
||
// float dBottomDepth = pWellNode->GetWellTrack()->GetBottomWellLogDepth();
|
||
// float dTopDepth1,dBottomDepth1;
|
||
// this->GetVisibleDepth(dTopDepth,dBottomDepth,dTopDepth1,dBottomDepth1);
|
||
// if(m_pLogCurveLines){//处理绘图范围
|
||
// double yOSGMinTmp = pWellNode->ConvertY( eCoord_GEO, dTopDepth1 ,eCoord_GEONormal );
|
||
// double yOSGMaxTmp = pWellNode->ConvertY( eCoord_GEO,dBottomDepth1, eCoord_GEONormal );
|
||
// double yOSGMin = qMin( yOSGMinTmp,yOSGMaxTmp );
|
||
// double yOSGMax = qMax( yOSGMinTmp,yOSGMaxTmp );
|
||
// m_pLogCurveLines->Init(2,osg::Vec4f(0,0,1,1));
|
||
// QVector<QPointF> vPoints;
|
||
// vPoints << QPointF( m_dOSGPropertyMin,yOSGMin )
|
||
// << QPointF( m_dOSGPropertyMax,yOSGMax );
|
||
// m_pLogCurveLines->SetPoints(vPoints);
|
||
// m_pLogCurveLines->setVisible(false);
|
||
// }
|
||
// double dMarginOSGPixelY = m_pSceneManager->GetCoordinate()->ConvertDeltaX( QUuid(),eCoord_GDICM,m_pWellSceneManager->FIXED_LOGHead_MARGIN_CM, eCoord_OSGPixel,true);
|
||
// if(m_pWellSceneManager->GetVecWindow()->GetWindowType()!=GetWindowTypeID_QtMultiWellSection())rcF.setY(rcGDIViewPort.y()-dMarginOSGPixelY);//修正高度
|
||
// QMatrix cmpx=GetWellTrackNode()->GetSheetMatrix()->matrix();
|
||
// int drawcurvetype=m_pWellSceneManager->GetCurveDrawType();
|
||
// if(drawcurvetype==DRAWHEAD) {
|
||
// if(hHeadObj)hHeadObj->setRect(headrcF,headrcF);
|
||
// if(m_pWave) {
|
||
// rcF.setHeight(0);
|
||
// m_pWave->setRect(rcF);
|
||
// m_pWave->setMatrix(cmpx);
|
||
// }
|
||
// }
|
||
// else if(drawcurvetype==DRAWCURVE) {
|
||
// headrcF.setHeight(0);
|
||
// if(hHeadObj)hHeadObj->setRect(headrcF,headrcF);
|
||
// if(m_pWave) {
|
||
// m_pWave->setRect(rcF);
|
||
// m_pWave->setMatrix(cmpx);
|
||
// }
|
||
// }
|
||
// else {
|
||
// if(hHeadObj)hHeadObj->setRect(headrcF,headrcF);
|
||
// if(m_pWave) {
|
||
// m_pWave->setRect(rcF);
|
||
// m_pWave->setMatrix(cmpx);
|
||
// }
|
||
// }
|
||
}
|
||
|
||
double CDrawBase::GetData(int RepCode,char *buffer)
|
||
{
|
||
double yy;
|
||
if(!buffer) return 0;
|
||
switch(RepCode)
|
||
{
|
||
case REPR_INT: //0
|
||
yy=(double)(*((int*)buffer));
|
||
break;
|
||
case REPR_SHORT: //1
|
||
yy=(double)(*((short *)buffer));
|
||
break;
|
||
case REPR_LONG://2
|
||
yy=(double)(*((long *)buffer));
|
||
break;
|
||
case REPR_FLOAT://3
|
||
yy=(double)(*((float *)buffer));
|
||
break;
|
||
case REPR_DOUBLE://4
|
||
yy=(double)(*((double *)buffer));
|
||
break;
|
||
case REPR_CHAR://5
|
||
yy=(double)(*((char *)buffer));
|
||
break;
|
||
case REPR_UCHAR://6
|
||
yy=(double)(*((unsigned char *)buffer));
|
||
break;
|
||
case REPR_USHORT://7
|
||
yy=(double)(*((unsigned short *)buffer));
|
||
break;
|
||
case REPR_UINT://8
|
||
yy=(double)(*((unsigned int *)buffer));
|
||
break;
|
||
case REPR_ULONG://9
|
||
yy=(double)(*((unsigned long *)buffer));
|
||
break;
|
||
case REPR_STRING://10
|
||
yy=-99999;
|
||
break;
|
||
}
|
||
return yy;
|
||
}
|
||
void CDrawBase::SetData(int RepCode,char *buffer,float yy)
|
||
{
|
||
switch(RepCode)
|
||
{
|
||
case REPR_INT: //0
|
||
(*((int*)buffer))=(int)yy;
|
||
break;
|
||
case REPR_SHORT: //1
|
||
(*((short *)buffer))=(short)yy;
|
||
break;
|
||
case REPR_LONG://2
|
||
(*((long *)buffer))=(long)yy;
|
||
break;
|
||
case REPR_FLOAT://3
|
||
(*((float *)buffer))=yy;
|
||
break;
|
||
case REPR_DOUBLE://4
|
||
(*((double *)buffer))=(double)yy;
|
||
break;
|
||
case REPR_CHAR://5
|
||
(*((char *)buffer))=(char)yy;
|
||
break;
|
||
case REPR_UCHAR://6
|
||
(*((unsigned char *)buffer))=(unsigned char)yy;
|
||
break;
|
||
case REPR_USHORT://7
|
||
(*((unsigned short *)buffer))=(unsigned short)yy;
|
||
break;
|
||
case REPR_UINT://8
|
||
(*((unsigned int *)buffer))=(unsigned int)yy;
|
||
break;
|
||
case REPR_ULONG://9
|
||
(*((unsigned long *)buffer))=(unsigned long )yy;
|
||
break;
|
||
case REPR_STRING://10
|
||
// *yy=-99999;
|
||
break;
|
||
}
|
||
}
|
||
|
||
void CDrawBase::SettingHeaderElements()
|
||
{
|
||
// if(m_pUnitText) m_pUnitText->setVisible(false);
|
||
// if(m_pCurveNameText)m_pCurveNameText->setVisible(false);
|
||
// if(m_pLeftText)m_pLeftText->setVisible(false);
|
||
// if(m_pRightText)m_pRightText->setVisible(false);
|
||
}
|
||
void CDrawBase::DrawHead(QPainter *pPainter,QRectF rt,QRectF trect)
|
||
{
|
||
// CVecNodeBuilder::DrawHead(pPainter,rt,trect);
|
||
// if(!m_pWellSceneManager) return;
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if( !pWellNode ) return;
|
||
|
||
// const sTrack& sTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrackInfo(m_pWellLog);
|
||
// CObjWellLogTrack *pLogTrack = m_pWellSceneManager->GetWellSectionGeomtry().GetLogTrack( m_pWellLog );
|
||
|
||
// int nColumeIndex = sTrack.nBeginColumIndex;
|
||
// if( nColumeIndex<0 )
|
||
// {
|
||
// return;
|
||
// }
|
||
// CSheet *pSheet=m_pWellSceneManager->GetCurrentSheet();
|
||
// double yTop_OSGPixel(0),xMin_OSGPixel(0),xMax_OSGPixel(0),yBottom_OSGPixel(0);
|
||
// CellRange cellRange = sTrack.GetCellRange();
|
||
// QList<PaiObject*> mchilds;
|
||
// pLogTrack->GetChildren(mchilds);
|
||
|
||
// cellRange.nEndRow = cellRange.nBeginRow + mchilds.indexOf( m_pWellLog ) + 1 ;
|
||
// cellRange.nBeginRow = cellRange.nEndRow;
|
||
|
||
// QRectF rcF = pWellNode->GetWellSheet().GetCellRect( cellRange );
|
||
// yTop_OSGPixel = rcF.top();
|
||
// xMin_OSGPixel = rcF.left();
|
||
// xMax_OSGPixel = rcF.right();
|
||
// yBottom_OSGPixel = rcF.bottom();
|
||
// float rowheight=45;
|
||
// if(m_pWellSceneManager->IsWellSectonHorizonLayout()) rowheight=m_pWellSceneManager->GetCoordinate()->ConvertDeltaX( QUuid(),eCoord_GDICM,DEFAULT_ROW_HEIGHT,eCoord_GDIPixel,true);
|
||
// else rowheight=m_pWellSceneManager->GetCoordinate()->ConvertDeltaY( QUuid(),eCoord_GDICM,DEFAULT_ROW_HEIGHT,eCoord_GDIPixel,true);
|
||
|
||
// rowheight/=m_pSceneManager->GetZoomYRatio();
|
||
// double dYOSGPixel = yTop_OSGPixel +rowheight;
|
||
// if(m_pLeftText) {
|
||
// m_pLeftText->SetPosition(pPainter, osg::Vec3d( xMin_OSGPixel+2,dYOSGPixel,0),Qt::AlignLeft |Qt::AlignBottom); //设置位置
|
||
// }
|
||
// if(m_pRightText) {
|
||
// m_pRightText->SetPosition(pPainter, osg::Vec3d( xMax_OSGPixel-1,dYOSGPixel,0),Qt::AlignRight |Qt::AlignBottom);;
|
||
// }
|
||
// double cellcentre_y=yTop_OSGPixel+rowheight/4;
|
||
// if(m_pCurveNameText) {
|
||
// osg::Vec3d vTextPos = osg::Vec3d((xMin_OSGPixel+xMax_OSGPixel)/2.0,cellcentre_y,ZVALUE_HUDGeometry);
|
||
// if(IsSelected()) {
|
||
// QColor co=GetSelectedObjectColor();
|
||
// m_pCurveNameText->SetColor(osg::Vec4f(co.red()/255.0,co.green()/255.0,co.blue()/255.0,co.alpha()/255.0));//co.red()/255.0,co.green()/255.0,co.blue()/255.0,co.alphaF()/255.0));
|
||
// }
|
||
// m_pCurveNameText->SetText(sName);
|
||
// m_pCurveNameText->SetPosition(pPainter, vTextPos,Qt::AlignHCenter|Qt::AlignVCenter );
|
||
// }
|
||
// dYOSGPixel = yTop_OSGPixel +rowheight*1/3+rowheight*1/4+rowheight*1/8;
|
||
// if(m_pUnitText) {
|
||
// m_pUnitText->SetText(sUnit);
|
||
// m_pUnitText->SetPosition(pPainter,osg::Vec3d((xMin_OSGPixel+xMax_OSGPixel)/2.0,dYOSGPixel,0),Qt::AlignHCenter|Qt::AlignVCenter);
|
||
// }
|
||
// m_pSelectedLine->setVisible(false);
|
||
// pPainter->save();
|
||
// if(IsSelected()) {
|
||
// QPen pPen=pPainter->pen();
|
||
// pPen.setColor(GetSelectedObjectColor());
|
||
// pPen.setWidth(2);
|
||
// pPainter->setBrush(Qt::NoBrush);
|
||
// TranslateOSGLineStyleToQtPenStyle(pPen, DOTLINE );
|
||
// pPainter->setPen(pPen);
|
||
// pPainter->drawRect(rt);
|
||
// }
|
||
// pPainter->restore();
|
||
}
|
||
void CDrawBase::DrawClient(QPainter *pPainter,QRectF rt)
|
||
{
|
||
// CVecNodeBuilder::DrawClient(pPainter,rt);
|
||
}
|
||
|
||
void CDrawBase::GetClientItem(float sdep,float edep, QVector<QLine> &lines)
|
||
{
|
||
|
||
}
|
||
|
||
void CDrawBase::DrawSidelines(QPainter *pPainter,QRectF rt)
|
||
{
|
||
}
|
||
|
||
void CDrawBase::GetDepth(QPainter *pDC,QRectF &mrt,QRectF &rt,float &sdep,float &edep,float &sdepc,float &edepc)
|
||
{
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if(!pWellNode) return;
|
||
// m_PlotSdep=pWellNode->GetOSGViewerTopDepth();
|
||
// m_PlotEdep=pWellNode->GetOSGViewerBottomDepth();
|
||
// sdep=pWellNode->m_curSdep;
|
||
// edep=pWellNode->m_curEdep;
|
||
sdepc=sdep;
|
||
edepc=edep;
|
||
rt = mrt;
|
||
}
|
||
//计算曲线位置
|
||
float CDrawBase::ComputePosToCurveVal(float x,float lsc,float rsc,float lps,float rps,int iType,float scale,float flMin,float flMax)
|
||
{
|
||
return 0;
|
||
// float flVal=0;
|
||
// flVal = lsc+(x-lps)/(rps-lps)*(rsc-lsc);
|
||
// if ( iType == LOGDepth )
|
||
// {
|
||
// flVal = powf(10.0f,flVal);
|
||
// }
|
||
// // 截止值
|
||
// if ( flVal > flMax ) flVal = flMax;
|
||
// if ( flVal < flMin ) flVal = flMin;
|
||
// return flVal;
|
||
}
|
||
//计算曲线位置
|
||
float CDrawBase::ComputeCurvePos(float flVal,float lsc,float rsc,float lps,float rps,int iType,float scale,float flMin,float flMax)
|
||
{
|
||
return 0;
|
||
// bool bFlag;
|
||
// float x;
|
||
// /*
|
||
// // 截止值
|
||
// if ( flVal > flMax )
|
||
// flVal = flMax;
|
||
// if ( flVal < flMin )
|
||
// flVal = flMin;
|
||
// */
|
||
// if ( iType == LOGDepth )
|
||
// {
|
||
// bFlag = FALSE;
|
||
// if (flVal <= 0)
|
||
// bFlag = TRUE;
|
||
// else
|
||
// flVal = log10f(flVal);
|
||
// x = lps+(flVal-lsc)/scale;
|
||
// if (bFlag )
|
||
// x = lps;
|
||
// }
|
||
// else
|
||
// {
|
||
// x = lps+(flVal-lsc)/scale;
|
||
// }
|
||
// if (x < flMin) {
|
||
// x = flMin;
|
||
// }
|
||
// if (x > flMax) {
|
||
// x = flMax;
|
||
// }
|
||
// return x;
|
||
}
|
||
float CDrawBase::ConvertY(eCoordType eInCoordType, double flDep,
|
||
eCoordType eOutCoordType )
|
||
{
|
||
return ConvertY(flDep);
|
||
}
|
||
// float CDrawBase::YConvertToGEO(float y)
|
||
// {
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if(!pWellNode) return -9999;
|
||
// CSheet& sheet = pWellNode->GetWellSheet();
|
||
// osg::Vec3d vecSheet =sheet.SheetCoordToVec( osg::Vec3d( 1,y,0),eCoord_GEO,this->GetID() );
|
||
// return vecSheet[1];
|
||
// }
|
||
// float CDrawBase::XConvertToGEO(float x)
|
||
// {
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if(!pWellNode) return -9999;
|
||
// CSheet& sheet = pWellNode->GetWellSheet();
|
||
// osg::Vec3d vecSheet =sheet.SheetCoordToVec( osg::Vec3d( x,1,0),eCoord_GEO,this->GetID() );
|
||
// return vecSheet[0];
|
||
// }
|
||
float CDrawBase::ConvertY(float fDep)
|
||
{
|
||
return 0;
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if(!pWellNode) return -9999;
|
||
// CSheet& sheet = pWellNode->GetWellSheet();
|
||
|
||
// if(!m_pObjWell) {
|
||
// m_pObjWell=pWellNode->GetWellTrack()->GetWelllogRound()->GetWell();
|
||
// if(!m_pObjWell) {
|
||
// m_pObjWell = dynamic_cast<CObjWell*>(GetProject()->GetObjectByID(pWellNode->GetWellTrack()->GetWellID()));
|
||
// if(!m_pObjWell) {
|
||
// CVecWindowDocument *pDoc=m_pSceneManager->GetDocument();
|
||
// if(pDoc) {
|
||
// m_pObjWell=pDoc->GetCurrentWell();
|
||
// pWellNode->GetWellTrack()->SetWelllogRound(m_pObjWell->GetCurrentObjWellRound());
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
|
||
|
||
// if(m_pSceneManager->GetDrawType()==1&&m_pObjWell) {
|
||
// fDep=m_pObjWell->GetDZ(fDep);
|
||
// }
|
||
// else if(m_pSceneManager->GetDrawType()==2&&m_pObjWell) {
|
||
// fDep=m_pObjWell->GetDX(fDep);
|
||
// }
|
||
// else if(m_pSceneManager->GetDrawType()==3&&m_pObjWell){
|
||
// fDep=m_pObjWell->GetDZ(fDep);
|
||
// }
|
||
// osg::Vec3d vecSheet = sheet.VecToSheetCoord( osg::Vec3d( 1,fDep,0),eCoord_GEO,this->GetID() );
|
||
// osg::Vec3d vec=sheet.ToSheetCoord(vecSheet);
|
||
// m_pSceneManager->GetCoordinate()->ConvertCoordDouble(this->GetID(),eCoord_OSGGlobal,vec ,eCoord_GDIPixel,vecSheet );
|
||
// if(IsXYSwap(eCoord_GEO,eCoord_GDIPixel)) return vecSheet[0];
|
||
// else return vecSheet[1];
|
||
}
|
||
double CDrawBase::GetDdep()
|
||
{
|
||
return 0;
|
||
// CQtWellTrackNode *pWellNode = GetWellTrackNode();
|
||
// if(!pWellNode) return 1;
|
||
// float m_Rlev=0.125;
|
||
// float y0=ConvertY0(pWellNode->m_curSdep);
|
||
// float y11=ConvertY0(pWellNode->m_curEdep);
|
||
// float pointn=(pWellNode->m_curEdep-pWellNode->m_curSdep)/m_Rlev;
|
||
// float ddep=(y11-y0)/pointn;//float ddep = 3.5625000;
|
||
// if(ddep==0) {
|
||
// y0=ConvertY( eCoord_GEO,pWellNode->m_curSdep,eCoord_GDIPixel );
|
||
// y11=ConvertY( eCoord_GEO,pWellNode->m_curEdep,eCoord_GDIPixel );
|
||
// ddep=(y11-y0)/pointn;//float ddep = 3.5625000;
|
||
// }
|
||
// double xScaleOld=1,yScaleOld=1;
|
||
// m_pSceneManager->GetCameraCommand().GetXYScale( xScaleOld,yScaleOld );
|
||
// if(getFacter()) return ddep/=xScaleOld;
|
||
// else return ddep;
|
||
}
|
||
void CDrawBase::Destory()
|
||
{
|
||
// if(hHeadObj&&hHeadObj->pFF!=(CDrawBase*)0xfeeefeeefeeefeee&&hHeadObj->pFF!=(CDrawBase*)0xdddddddddddddddd) {
|
||
// if(m_pLeftText){
|
||
// m_pLeftText->setParentItem(NULL);
|
||
// delete m_pLeftText;
|
||
// m_pLeftText=NULL;
|
||
// }
|
||
// if(m_pRightText){
|
||
// m_pRightText->setParentItem(NULL);
|
||
// delete m_pRightText;
|
||
// m_pRightText=NULL;
|
||
// }
|
||
// if(m_pCurveNameText){
|
||
// m_pCurveNameText->setParentItem(NULL);
|
||
// delete m_pCurveNameText;
|
||
// m_pCurveNameText=NULL;
|
||
// }
|
||
// if(m_pUnitText) {
|
||
// m_pUnitText->setParentItem(NULL);
|
||
// delete m_pUnitText;
|
||
// m_pUnitText=NULL;
|
||
// }
|
||
// m_pWave->pFF=NULL;
|
||
// hHeadObj->setParentItem(NULL);
|
||
// delete hHeadObj;
|
||
// hHeadObj=NULL;
|
||
// }
|
||
// if(m_pWave&&m_pWave->pFF!=(CDrawBase*)0xfeeefeeefeeefeee&&m_pWave->pFF!=(CDrawBase*)0xdddddddddddddddd&&m_pWave->pFF!=(CDrawBase*)0xabababababababab) {
|
||
// m_pWave->pFF=NULL;
|
||
// m_pWave->setParentItem(NULL);
|
||
// delete m_pWave;
|
||
// m_pWave=NULL;
|
||
// }
|
||
// CQtWellLogTrackNode::Destory();
|
||
}
|
||
END_OSGGRAPHICS_NAMESPACE
|