追加1.岩心分析视图 2.杆状图

This commit is contained in:
jiayulong 2025-12-25 15:10:14 +08:00
parent 31f492fd50
commit a4a1ac579a
12 changed files with 673 additions and 17 deletions

View File

@ -51,6 +51,7 @@ signals:
void sig_delLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);//删除曲线
void sig_AddDepth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0);//深度
void sig_AddGanZhuangTu(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0);
//新建波列
void sig_AddWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);

View File

@ -267,22 +267,26 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
switch(iStyle)
{
case 0:
//无
newStyle = Qt::NoPen;
break;
case 1:
//实线
newStyle = Qt::SolidLine;
break;
case 1:
case 2:
//虚线
newStyle = Qt::DashLine;
break;
case 2:
case 3:
//点线
newStyle = Qt::DotLine;
break;
case 3:
case 4:
//虚点线
newStyle = Qt::DashDotLine;
break;
case 4:
case 5:
//虚点点线
newStyle = Qt::DashDotDotLine;
break;

View File

@ -46,7 +46,7 @@ FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) :
m_strWellName = strWellName;
m_strTrackName = strTrackName;
m_nSltk=10.0;
connect(CallManage::getInstance(), SIGNAL(sig_AddLine(QString, QString, QString, QString, QString)), this, SLOT(s_addLine(QString, QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_AddLine_Property(QString, QString, QString, QString, QString, double, double, QString, QColor, double, Qt::PenStyle)),
@ -60,6 +60,7 @@ FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) :
connect(CallManage::getInstance(), SIGNAL(sig_AddTableLine(QString, QString, QString, QString, QString)), this, SLOT(s_addTableLine(QString, QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_delTableLine(QString, QString, QString, QString)), this, SLOT(s_delTableLine(QString, QString, QString, QString)));
connect(CallManage::getInstance(), SIGNAL(sig_AddGanZhuangTu(QString, QString, QString, QString, QString, int)), this, SLOT(s_addGanZuangTu(QString, QString, QString, QString, QString,int)));
}
FormDraw::~FormDraw()
@ -340,7 +341,8 @@ void FormDraw::s_addTableLine(QString strUuid, QString strSlfName, QString strWe
{
if(strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT"
|| strLineName == "GEO_LITH" || strLineName == "SWALL_CORE"
|| strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT")
|| strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT"
|| strLineName == "CORE_PHYSICS")
{
}
@ -433,6 +435,11 @@ void FormDraw::s_addTableLine(QString strUuid, QString strSlfName, QString strWe
//固井结论
initGujing(curv, strSlfName, strLineName);
}
else if(strLineName == "CORE_PHYSICS")
{
//岩心实验数据
initCorePhysics(curv, strSlfName, strLineName);
}
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
@ -826,6 +833,158 @@ void FormDraw::s_selectionRectAccepted(const QRect &rect, QMouseEvent *event)
// double y2 = widget->yAxis->pixelToCoord(rect.bottom());
}
void FormDraw::s_addGanZuangTu(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW)
{
//井名&道名不一致
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
{
}
else
{
return;
}
if(m_listLineName.contains(strLineName))
{
qDebug() << "FormDraw strLineName already exist! " << strLineName;
return;
}
//
QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strLineName);
curv->m_strUuid = m_strUuid;
//背景设置成透明色
curv->setBackground(Qt::transparent);
curv->setStyleSheet("background: transparent;");
//
//QRect rect = this->rect();
//curv->setGeometry(rect.left(),rect.top(), rect.width(), rect.height());
double dHight = 0;
dHight = (g_iY2-g_iY1)*100.0/(double)g_iScale * g_dPixelPerCm;
if(g_iShow==1)
{
//显示刻度
dHight = dHight+30;
}
qDebug() << "FormDraw dHight=" << QString::number((int)dHight);
if(dHight>32767)
{
dHight = 32767;
}
//curv->setMaximumHeight((int)dHight);
//curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184
curv->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184
//curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制
// QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// curv->setSizePolicy(policy);
curv->show();
////////////////////////////////////////
m_Value=NULL;
m_Value2=NULL;
m_Value3=NULL;
//m_csUnit = "(°)";
m_bTableData=0;//表格或曲线
m_LeftVal2=0;
m_RightVal2=360;
//m_csCurveDDIR="DDIR";
//m_csCurveDANG="DANG";
//m_csCurveGrad="GRAD";
m_nTailWidth=2;
m_crTail=qRgb(0,0,0);
m_crPointFill=qRgb(0,0,0);
m_crGridSmall=qRgb(100,100,100);
m_nRadius = 6;
m_nTailLen = 10;
m_nCircleWidth=1;
m_flGrad1 = 10;
m_flGrad2 = 50;
//Table dip
m_qsTable="FRAC_HOLE.TABLE";
m_qsDIR=("DIR"); // 方位 曲线名
m_qsDIP=("DIPorS");//倾角
m_qsDepth="DEP";
m_qsID = "ID";
m_qsProperty=("ID");
m_iPrecision = 3;
//读数据
m_csCurveDDIR = "DDIR"; // 方位 曲线名
m_csCurveDANG = "DANG";//倾角
m_csCurveGrad = "GRAD";
this->ReadData(strSlfName, m_csCurveDDIR, 0, &m_Curve);
this->ReadData(strSlfName, m_csCurveDANG, 1, &m_Curve2);
this->ReadData(strSlfName, m_csCurveGrad, 2, &m_Curve3);
curv->yAxis->setTickLabels(true);
curv->yAxis->setTickLabelSide(QCPAxis::lsInside);
QFont font1("微软雅黑", 16); //fontSize 10
curv->yAxis->setTickLabelFont(font1);
curv->yAxis->setRange(g_iY1, g_iY2);
curv->axisRect()->setupFullAxesBox();
//
// curv->xAxis->ticker()->setTickCount(10);//x个主刻度
// curv->yAxis->ticker()->setTickCount(60);//y个主刻度
int iMyWidth = curv->axisRect(0)->width();
float vmax = iMyWidth;
float vmin = 0;
curv->m_iX1 = vmin;
curv->m_iX2 = iMyWidth;
curv->m_iY1 = g_iY1;
curv->m_iY2 = g_iY2;
//
curv->xAxis->setRange(vmin, vmax);
curv->yAxis->setRange(g_iY1, g_iY2);
curv->axisRect()->setupFullAxesBox();
//
curv->xAxis->ticker()->setTickCount(10);//x个主刻度
curv->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = curv->yAxis;
QCPAxis *xAxis = curv->xAxis;
curv->xAxis = yAxis;
curv->yAxis = xAxis;
m_LeftVal = 0;
m_RightVal = 90;
//隐藏刻度
curv->xAxis->setTicks(false);
curv->yAxis->setTicks(false);
curv->xAxis2->setTicks(false);
curv->yAxis2->setTicks(false);
//蝌蚪图
// curv->mKedou = true;
//隐藏网格
// curv->xAxis->grid()->setVisible(false);
// curv->yAxis->grid()->setVisible(false);
DrawStck(curv);
//道-对象
QString strAliasName = "杆状图";
QString strUnit = "";
QColor newlineColor=QColor(0,0,0);
double width=2;
QString strScaleType = "";
//道-对象
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "ganzhuangtuObject");
//
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
m_listLineName.push_back(strLineName);
}
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
{
@ -2585,7 +2744,6 @@ void FormDraw::initGujing(QMyCustomPlot *widget, QString strSlfName, QString str
QString strScaleType = "";
//道-对象
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject");
}
bool FormDraw::LoadFromSLF_Gujing(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
@ -2750,6 +2908,130 @@ void FormDraw::initFgrq(QMyCustomPlot *widget)
}
//岩心实验数据
void FormDraw::initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QString strLineName)
{
float vmax = 100;
float vmin = 0;
QVector<double> x, y;
Slf_CORE_PHYSICS *m_pResult=NULL;
CMemRdWt *logio=new CMemRdWt();
if(strSlfName==""||!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead))
{
delete logio;
// QMessageBox::information(NULL,"提示","SLF文件打开失败请检查",QMessageBox::Yes);
return;
}
int iIndex=logio->OpenTable(strLineName.toStdString().c_str());
if(iIndex>-1) {
int FieldNo=0;
int count=logio->GetTableRecordCount(iIndex);
QString FieldName = "AC";
if(!FieldName.isEmpty()) {
static int err=0;
FieldNo=logio->GetTableFieldNo(iIndex,(char *)FieldName.toStdString().c_str());
if(FieldNo<0) {
if(!err)QMessageBox::information(nullptr, "提示", "岩心试验数据模块初始加载数据不成功,因为隐含"+FieldName+"字段在实际数据表中不存在,稍后请您重新选择有效字段!");
err++;
delete logio;
return;
}
else err=0;
}
else {
delete logio;
return;
}
int len=logio->GetTableRecordLength(iIndex);
m_pResult=(Slf_CORE_PHYSICS *)new char[len+1];
char buf[100];
for(int i=0;i<count;i++) {
logio->GetTableFieldData(iIndex,1,buf,i+1);
sscanf(buf,"%f",&m_pResult->Depth);
logio->GetTableFieldData(iIndex,2,buf,i+1);
sscanf(buf,"%f",&m_pResult->CorrDepth);
// logio->ReadTable(iIndex,i+1,m_pResult);
int Order = m_pResult->Order;
float depth = m_pResult->Depth;
float CorrDepth = m_pResult->CorrDepth;
float CoreValue;
logio->GetTableFieldData(iIndex,FieldNo,buf,i+1);
CoreValue=0;
sscanf(buf,"%f",&CoreValue);
//
if(i==0)
{
//最大值,最小值默认采用第一个有效值
//vmax = vmin = CoreValue;
//默认采用0-100范围
if(vmax<CoreValue)vmax=CoreValue;
if(vmin>CoreValue)vmin=CoreValue;
}
else
{
//
if(vmax<CoreValue)vmax=CoreValue;
if(vmin>CoreValue)vmin=CoreValue;
}
//
x.append(-CorrDepth);
y.append(CoreValue);
}
logio->CloseTable(iIndex);
delete m_pResult;
}
delete logio;
//赋值
m_vmax = vmax;
m_vmin = vmin;
//----------------------------------
widget->m_iX1 = vmin;
widget->m_iX2 = vmax;
widget->m_iY1 = g_iY1;
widget->m_iY2 = g_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(g_iY1, g_iY2);
widget->axisRect()->setupFullAxesBox();
//
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
//对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis;
widget->xAxis = yAxis;
widget->yAxis = xAxis;
// //隐藏刻度
// widget->xAxis->setTicks(false);
// widget->yAxis->setTicks(false);
// widget->xAxis2->setTicks(false);
// widget->yAxis2->setTicks(false);
//
QString strAliasName = "";
QString strUnit = "";
widget->m_bDrawCore_PHYSICS = true;
addRandomGraph(widget, x, y, strSlfName, strLineName, strAliasName, strUnit);
//支持框选------------------
widget->setSelectionRectMode(QCP::SelectionRectMode::srmSelect);
widget->graph(0)->setSelectable(QCP::SelectionType::stMultipleDataRanges);// stSingleData
widget->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式
// widget->setSelectionRectMode(QCP::srmCustom); // 鼠标框选
}
void FormDraw::CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x2,float flHoriRatio)
{
float scale ;
@ -2919,7 +3201,138 @@ void FormDraw::DrawDip(QMyCustomPlot *widget)
k++;
}
}
void FormDraw::DrawStck(QMyCustomPlot *widget)
{
float flWidth[50];
int l;
float dep;
int m_nScaleThinGrid=10;
float lstk=2;
float dang,ddir;
float dg,dy,dx;
// 计算位置
int iMyWidth = widget->axisRect(0)->width();
float x1 = 0;
float x2 = iMyWidth;
float x=0,y=0;
int j=0,i=0,k=0;
float flTemp=0;
for(int i=0;i<50;i++) flWidth[i]=0;
CalcDipWidth(m_nScaleThinGrid, flWidth, 1.2, x1, x2, 1.);
QPen pPen(m_crTail,m_nTailWidth);
QBrush cBrushFill(m_crPointFill);
float flDepthScale,tempf,flVal;
int nPointNum=0,tempi;
QRectF rt,rtRect;
float dgtord,dr;
for(int i=0;i<50;i++) flWidth[i]=0;
if(m_Value==0 || m_Value2==0)
{
Refurbish();
}
if ( m_Value==0 || m_Value2==0 )
return ;
dgtord=3.14159265/180.;
CalcDipWidth(9, flWidth, 1.2, 0, iMyWidth, 1);
while ( 1)
{
dep = m_SDep + k * m_Rlev;
if ( dep >m_EDep )
break;
if(dep<m_SDep)
{
k++;
continue;
}
i=(dep-m_Curve2.StartDepth)/m_Curve2.DepLevel+0.5;
if(i<0)
{
k++;
continue;
}
flVal = GetData(m_Curve2.RepCode,(char *)&m_Value2[i*m_Curve2.CodeLen]);//DANG
if ( flVal > m_RightVal || flVal < m_LeftVal )
{
k++;
continue;
}
tempi = (int)( flVal /10.);
tempf = 0.;
for (j=0; j<tempi; j++)
{
tempf += flWidth[j];
}
x =160;//= tempf + (flVal-tempi*10.)*(flWidth[j+1]/10.);
y = -dep;//起始深度
// pDC->setPen(pPen);// [5/22/2019 9:43 hxb]
// rtRect.setLeft(x - GetLineWidth(pDC,m_nRadius));
// rtRect.setRight(x + GetLineWidth(pDC,m_nRadius));
// rtRect.setBottom(y +GetLineWidth(pDC,m_nRadius));
// rtRect.setTop(y -GetLineWidth(pDC,m_nRadius));
// pDC->setPen(PenCircle);
// pDC->drawEllipse(rtRect.center(),m_nRadius,m_nRadius);
// QCPItemEllipse *qcpItemEllipse = new QCPItemEllipse(widget);
// qcpItemEllipse->setPen(pPen);
// qcpItemEllipse->m_bCustom = true;
// qcpItemEllipse->m_nRadius = m_nRadius;
// qcpItemEllipse->topLeft->setCoords(y, x);//圆心位置
// qcpItemEllipse->bottomRight->setCoords(y, x);//圆心位置
// qcpItemEllipse->setBrush(cBrushFill);//填充圆的颜色
//方位
dang = GetData(m_Curve.RepCode,(char *)&m_Value[i*m_Curve.CodeLen]);//DDIR
dr=dang*dgtord;
//dx=abs(lstk*cos(dr));
// dy=sqrt(lstk*lstk*(1-cos(dr)*cos(dr)));
// // 注意映射方式
// x +=GetLineWidth(pDC,m_nRadius)*sin(dr);
// y -=GetLineWidth(pDC,m_nRadius)*cos(dr);
// float x1=x +GetLineWidth(pDC,m_nTailLen)*sin(dr);
// float y1=y -GetLineWidth(pDC,m_nTailLen)*cos(dr);
// pDC->setPen(pPen);
// pDC->drawLine(QPointF(x,y),QPointF(x1,y1));
QCPItemLine *qcpItemLine = new QCPItemLine(widget);
qcpItemLine->start->setCoords(y, x);//圆心位置
qcpItemLine->end->setCoords(y, x);//圆心位置
qcpItemLine->setPen(pPen);
qcpItemLine->m_bCustom = true;
qcpItemLine->m_nTailLen = m_nSltk; //杆长
qcpItemLine->m_nRadius = 0; //半径
qcpItemLine->m_dr = dr;
QCPItemLine *qcpItemLine1 = new QCPItemLine(widget);
qcpItemLine1->start->setCoords(y, x);//圆心位置
qcpItemLine1->end->setCoords(y, x);//圆心位置
qcpItemLine1->setPen(pPen);
qcpItemLine1->m_bCustom = true;
qcpItemLine1->m_nTailLen = m_nSltk; //杆长
qcpItemLine1->m_nRadius = 0; //半径
qcpItemLine1->m_dr = dr+PI;
//移动对象
// widget->mSizeHandleManager->addItem(qcpItemEllipse, true);
// widget->mSizeHandleManager->addItem(qcpItemLine, true);
k++;
}
}
void FormDraw::DrawTabDip(QMyCustomPlot *widget)
{
float flDepthScale,tempf,flVal;

View File

@ -99,6 +99,7 @@ public:
void ReadData(QString strSlfName, QString strLineName);//表格
void ReadData(QString strSlfName, QString strLineName, int iCurve, Slf_CURVE *curve);//曲线
void DrawDip(QMyCustomPlot *widget);
void DrawStck(QMyCustomPlot *widget);
void DrawTabDip(QMyCustomPlot *widget);
void CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x2,float flHoriRatio);
void Refurbish();
@ -121,6 +122,7 @@ public:
QRectF m_Rect;
float m_nRadius,m_nCircleWidth; // 半径,圆线宽度
float m_nTailWidth,m_nTailLen; // 尾宽度、尾长
float m_nSltk; // 杆状图长度
QColor m_crPointFill,m_crTail,m_crCircle;
QColor m_crGridSmall;
QString m_strSlfName;
@ -157,6 +159,9 @@ public:
void initGujing(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
bool LoadFromSLF_Gujing(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
//岩心实验数据
void initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QString strLineName);
//深度
void initDepth(QMyCustomPlot *widget);
//频率统计图
@ -175,6 +180,7 @@ public slots:
void s_handleRectRangeChange(QCPRange newRange);
void s_selectionRectAccepted(const QRect &rect, QMouseEvent *event);
void s_addGanZuangTu(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW);//杆状图
//
void s_addWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);
void s_delWave(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);

View File

@ -217,7 +217,8 @@ void FormInfo::paintEvent(QPaintEvent* event)
if(m_strType=="tableObject" && (m_strLineName=="WORDS_RELUST" || m_strLineName == "RESULT"
|| m_strLineName == "GEO_LITH"|| m_strLineName == "SWALL_CORE"
|| m_strLineName == "GUJING1_RESULT" || m_strLineName == "GUJING2_RESULT" || m_strLineName == "GUJING3_RESULT") )
|| m_strLineName == "GUJING1_RESULT" || m_strLineName == "GUJING2_RESULT" || m_strLineName == "GUJING3_RESULT"
|| m_strLineName == "CORE_PHYSICS") )
{
//文字结论,不绘制左右范围
}

View File

@ -55,6 +55,9 @@ FormTrack::FormTrack(QWidget *parent, QString strWellName, QString strTrackName)
// 深度
connect(this, SIGNAL(sig_AddDepth(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
this, SLOT(s_addDepth(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
// 杆状图
connect(this, SIGNAL(sig_AddGanZhuangTu(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
this, SLOT(s_addGanZhuangTu(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
//曲线选中,置顶
connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString)));
@ -101,6 +104,10 @@ void FormTrack::Add(QString strSlfName, QString strWellName, QString strTrackNam
{
emit sig_AddDepth(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
}
else if(strType=="ganzhuangtuObject")
{
emit sig_AddGanZhuangTu(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
}
}
void FormTrack::setDrawDt(QStringList listdt, float vmax, float vmin)
@ -246,7 +253,8 @@ void FormTrack::s_AddTableLine(QString strSlfName, QString strWellName, QString
{
if(strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT"
|| strLineName == "GEO_LITH" || strLineName == "SWALL_CORE"
|| strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT")
|| strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT"
|| strLineName == "CORE_PHYSICS")
{
}
@ -329,7 +337,38 @@ void FormTrack::s_addDepth(QString strSlfName, QString strWellName, QString strT
//
ui->tableWidget->setCellWidget(row, 0, formInfo);
}
void FormTrack::s_addGanZhuangTu(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType)
{
qDebug() << "FormTrack s_addDepth";
ui->tableWidget->m_strUuid = m_strUuid;
int row = ui->tableWidget->rowCount();
ui->tableWidget->setRowCount(row + 1);
//避免出现小滚动条
//ui->tableWidget->resize(g_iOneWidth, 100*(row + 1)+10);
//this->resize(g_iOneWidth, 100*(row + 1)+30);
//曲线信息栏
FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor);
formInfo->m_strUuid = m_strUuid;
formInfo->m_strAliasName = strAliasName;
formInfo->m_strUnit = strUnit;
formInfo->m_strScaleType = strScaleType;
formInfo->m_strType = "depthObject";
formInfo->m_nJg = 2;
formInfo->setLineWidth(dWidth);
formInfo->setVMax(vmax);
formInfo->setVMin(vmin);
formInfo->setFrontColor(QColor(0,0,0));
formInfo->setBackColor(QColor(255,255,255));
//设置高度
ui->tableWidget->setRowHeight(row, 100);
//单元格委托
//ui->tableWidget->setItemDelegateForRow(row, m_delegate);
//
ui->tableWidget->setCellWidget(row, 0, formInfo);
}
QJsonObject FormTrack::makeJson()
{
// 创建根对象

View File

@ -72,14 +72,14 @@ signals:
void sig_AddTableLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void sig_AddDepth(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void sig_AddGanZhuangTu(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
public slots:
void s_addLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void s_addWave(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void s_AddTableLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void s_addDepth(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void s_addGanZhuangTu(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
};

View File

@ -161,6 +161,11 @@ void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfNa
//新建曲线
emit CallManage::getInstance()->sig_AddDepth(m_strUuid, strSlfName, strWellName, strTrackName, strLineName, nW);
}
else if(strType=="ganzhuangtuObject")
{
//新建杆状图
emit CallManage::getInstance()->sig_AddGanZhuangTu(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
}
}
//ui->tableWidget->resizeColumnsToContents(); // 调整列宽以适应内容

View File

@ -372,6 +372,7 @@ void MainWindowCurve::initToolBar()
// connect(m_runAc, &QAction::triggered, this, &MainWindow::s_SaveImage);
// connect(m_debugAc, &QAction::triggered, this, &MainWindow::s_DrawImg);
// connect(m_loadAc, &QAction::triggered, this, &MainWindow::s_DrawLine);
connect(m_ganzhuangtuAc, &QAction::triggered, this, &MainWindowCurve::s_NewGanZhuangTu);
}
void MainWindowCurve::loadStyle(const QString &qssFile)
@ -798,6 +799,51 @@ void MainWindowCurve::s_pinLvAc()
emit CallManage::getInstance()->sig_NewCol(dt);
}
void MainWindowCurve::s_NewGanZhuangTu()
{
QString strSlfName = "";
QString strLeft = m_leftWidgets->getLeftTreeString();
if(strLeft.length() > 0)
{
QStringList list = strLeft.split("#@@#");//QString字符串分割函数
if (list.size() > 3)
{
strSlfName = list[0];
}
}
if(ui->tableWidget_2->columnCount()==0)
{
return;
}
int column = ui->tableWidget_2->currentColumn();//列编号从0开始
if(column<0)
{
//当前没有选中井
return;
}
if(column%2==0)
{
}
else
{
//空白列
return;
}
QString strWellName = ui->tableWidget_2->item(0, column)->text();
int iWidth = ui->tableWidget_2->columnWidth(column);
int nW = 320;
//设置列宽
ui->tableWidget_2->setColumnWidth(column, iWidth+nW+8);
//新建道
emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "杆状图", "ganzhuangtuObject", nW);
}
void MainWindowCurve::s_NewTrackChangeWidth(QString strWellName)
{
qDebug() << "MainWindowCurve s_NewTrackChangeWidth";

View File

@ -109,6 +109,8 @@ public slots:
void s_NewDepth(); // 深度
void s_pinLvAc(); // 频率统计
void s_NewGanZhuangTu(); // 杆状图
//
void s_Save();//保存
//void s_Open(QString fileFull);//打开

View File

@ -129,6 +129,52 @@ void QMyCustomPlot::mousePressEvent(QMouseEvent *event)
// }
// }
if(m_bDrawCore_PHYSICS)//岩心分析
{
//获取鼠标点位置
double x_pos = event->pos().x();
double y_pos = event->pos().y();
double x_val;
double y_val;
//转为图像位置
x_val = xAxis->pixelToCoord(y_pos);
//曲线关联在左右轴判断
y_val = yAxis->pixelToCoord(x_pos);
//从选择中获取数据区间
QCPDataRange range;
if(graph(0)->selected()){
range = graph(0)->selection().dataRange();
}
// 检查选定的区间是否是单个数据点
if (range.size() == 1) {
// 获取选定的数据点的下标范围
dataIndex = range.begin();
// 执行特定操作,例如输出下标:
}else{
dataIndex = -1;
return;
}
double xx = graph(0)->data()->at(dataIndex)->key;
// double yy = graph(0)->data()->at(dataIndex)->value;
//// double newYPoint = y_val / yy; //曲线Y轴数据 m_y.at(dataIndex)
//// double xDistand = abs(x_val - xx); //曲线X轴数据 m_x.at(dataIndex)
//// //鼠标位距离数据点位置判断
//// if (newYPoint > 0.2 && newYPoint < 3 && xDistand < 5) {
//// //在此范围(自由设计)则表示选中数据点
//// dataIndex = dataIndex;
//// }else{
//// dataIndex = -1;
//// }
singleOldPosition = xx; //记录了该点在曲线中Y轴的值 m_y.at(dataIndex)
singleDragMove = true;
}
QCustomPlot::mousePressEvent(event);
}
@ -155,6 +201,14 @@ void QMyCustomPlot::mouseMoveEvent(QMouseEvent *event)
// replot();
// }
// else
if(m_bDrawCore_PHYSICS)//岩心分析
{
if(singleDragMove){
executeSingle(event);
}
}
else
{
// 当前鼠标位置(像素坐标)
//int x_pos = event->pos().x();
@ -178,9 +232,70 @@ void QMyCustomPlot::mouseReleaseEvent(QMouseEvent *event)
// return;
// }
// }
if(m_bDrawCore_PHYSICS)//岩心分析
{
dataIndex = -1;
singleDragMove = false;
//setCursor(Qt::ArrowCursor);
replot(QCustomPlot::rpQueuedReplot);
}
QCustomPlot::mouseReleaseEvent(event);
}
//单点移动功能
void QMyCustomPlot::executeSingle(QMouseEvent *event)
{
try {
if(dataIndex == -1)
{
return;
}
//获取鼠标信息
int x_pos = event->pos().x();
int y_pos = event->pos().y();
// double x_val = xAxis->pixelToCoord(x_pos);
// double y_val = yAxis->pixelToCoord(y_pos);
double x_val;
double y_val;
//转为图像位置
x_val = xAxis->pixelToCoord(y_pos);
//曲线关联在左右轴判断
y_val = yAxis->pixelToCoord(x_pos);
//double xx = graph(0)->data()->at(dataIndex)->key;
//double yy = graph(0)->data()->at(dataIndex)->value;
// //获取数据改变鼠标的形状
// double newYPoint = y_val / yy;
// double xDistand = abs(x_val - xx);
// if (newYPoint > 0.2 && newYPoint < 3 && xDistand < 5) {
// customPlot->setCursor(Qt::ClosedHandCursor);
// }else{
// customPlot->setCursor(Qt::ArrowCursor);
// }
//更新曲线数据中拖动的那个点数据
for(int i =0; i<m_x.size(); i++)
{
if(m_x[i] == singleOldPosition)
{
m_y[i]=y_val;
break;
}
}
graph(0)->data()->clear();
graph(0)->setData(m_x, m_y);
// graph(0)->data()->remove(dataIndex);
// graph(0)->addData(singleOldPosition, y_val); //更新曲线数据
replot(QCustomPlot::rpQueuedReplot); //刷新曲线
} catch (...) {
//FERROR("系统发异常!");
}
}
//槽函数,选中曲线
void QMyCustomPlot::s_LineClicked(int index)
{
@ -1187,9 +1302,16 @@ void QMyCustomPlot::addRandomGraph(QVector<double> x, QVector<double> y, QString
if(newLeftScale!=-9999)
{
graph()->setLineStyle((QCPGraph::LineStyle)(lineStyle));//曲线
graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
if(m_bDrawCore_PHYSICS)//岩心分析
{
graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));//杆状线
graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssCircle)));//圆圈
}
else
{
graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));//曲线
graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssDot)));//点
}
QPen graphPen;
graphPen.setColor(newlineColor);
@ -1199,10 +1321,17 @@ void QMyCustomPlot::addRandomGraph(QVector<double> x, QVector<double> y, QString
}
else
{
graph()->setLineStyle((QCPGraph::LineStyle)(1));//曲线
if(m_bDrawCore_PHYSICS)//岩心分析
{
graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));//杆状线
graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssCircle)));//圆圈
}
else
{
graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));//曲线
graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssDot)));//点
}
graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
// graph()->setScatterStyle(QCPScatterStyle(QPixmap(":/image/file.png")));
//graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));

View File

@ -52,6 +52,13 @@ public:
bool m_bDrawRect = true;
//
bool m_bDrawCore_PHYSICS = false; //岩心分析
int dataIndex = -1;
bool singleDragMove = false;
float singleOldPosition = 0;
public:
//分段刷新
QVector<double> m_x;
@ -129,6 +136,9 @@ public:
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
//单点移动功能
void executeSingle(QMouseEvent *event);
virtual void contextMenuEvent(QContextMenuEvent *event);
private: