819 lines
31 KiB
C++
819 lines
31 KiB
C++
#include "qmycustomplot.h"
|
|
#include "CallManage.h"
|
|
#include "geometryutils.h"
|
|
#include "TransparentDraggableRect.h"
|
|
|
|
QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) :
|
|
QCustomPlot(parent)
|
|
{
|
|
m_strSlfName = strSlfName;
|
|
m_strWellName = strWellName;
|
|
m_strTrackName = strTrackName;
|
|
m_strLineName = strLineName;
|
|
|
|
|
|
setObjectName("QMyCustomPlot");
|
|
//this->setOpenGl(true);
|
|
|
|
xAxis->setTickLabels(false);
|
|
yAxis->setTickLabels(false);
|
|
//
|
|
xAxis2->setTickLabels(false);
|
|
yAxis2->setTickLabels(false);
|
|
|
|
// make bottom and left axes transfer their ranges to top and right axes:
|
|
connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange)));
|
|
connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange)));
|
|
|
|
//关联信号槽
|
|
//左刻度
|
|
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLeftScale(QString, QString, QString, QString, QString, double)), this, SLOT(s_ChangeLeftScale(QString, QString, QString, QString, QString, double)));
|
|
//右刻度
|
|
connect(CallManage::getInstance(), SIGNAL(sig_ChangeRightScale(QString, QString, QString, QString, QString, double)), this, SLOT(s_ChangeRightScale(QString, QString, QString, QString, QString, double)));
|
|
//刻度类型
|
|
connect(CallManage::getInstance(), SIGNAL(sig_ChangeScaleType(QString, QString, QString, QString, QString, QString)), this, SLOT(s_ChangeScaleType(QString, QString, QString, QString, QString, QString)));
|
|
|
|
//曲线选中,置顶
|
|
connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString)));
|
|
//颜色
|
|
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineColor(QString, QString, QString, QString, QString, QColor)), this, SLOT(s_ChangeLineColor(QString, QString, QString, QString, QString, QColor)));
|
|
//线宽
|
|
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineWidth(QString, QString, QString, QString, QString, double)), this, SLOT(s_ChangeLineWidth(QString, QString, QString, QString, QString, double)));
|
|
//线型
|
|
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineStyle(QString, QString, QString, QString, QString, Qt::PenStyle)), this, SLOT(s_ChangeLineStyle(QString, QString, QString, QString, QString, Qt::PenStyle)));
|
|
//岩性填充-不填充
|
|
connect(CallManage::getInstance(), SIGNAL(sig_ClearFillMode(QString, QString, QString, QString, QString)), this, SLOT(s_ClearFillMode(QString, QString, QString, QString, QString)));
|
|
//岩性填充-填充
|
|
connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor, QString)),
|
|
this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor, QString)));
|
|
|
|
}
|
|
|
|
void QMyCustomPlot::init(QString strName, QVector<double> xx, QVector<double> yy0)
|
|
{
|
|
//raise(); //置于上层显示
|
|
}
|
|
|
|
void QMyCustomPlot::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
qDebug() << "mousePress";
|
|
QCustomPlot::mousePressEvent(event);
|
|
}
|
|
|
|
//槽函数,选中曲线
|
|
void QMyCustomPlot::s_LineClicked(int index)
|
|
{
|
|
// qDebug() << "s_LineClicked";
|
|
|
|
// //全部取消选中
|
|
// deselectAll();
|
|
|
|
// //重新选中
|
|
// QCPGraph *graph = this->graph(index);
|
|
// if (graph)
|
|
// {
|
|
// //qDebug() << "s_LineClicked graph";
|
|
// graph->setSelection(QCPDataSelection(graph->data()->dataRange()));
|
|
|
|
// QCPPlottableLegendItem *item = legend->itemWithPlottable(graph);
|
|
// if (item)
|
|
// {
|
|
// //qDebug() << "s_LineClicked item";
|
|
// //仅显示当前被选中的曲线
|
|
// item->setSelected(true);
|
|
// replot();
|
|
// }
|
|
// }
|
|
}
|
|
|
|
void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
|
|
{
|
|
QMenu menu(this);
|
|
QAction *resetAction = menu.addAction("添加框图");
|
|
|
|
m_event = event;
|
|
connect(resetAction, &QAction::triggered, this, &QMyCustomPlot::onAddRect);
|
|
|
|
// if (selectedGraphs().size() > 0)//选中曲线
|
|
// {
|
|
// menu.addAction("删除选中曲线", this, SLOT(removeSelectedGraph()));
|
|
// }
|
|
|
|
menu.exec(event->globalPos());
|
|
}
|
|
|
|
void QMyCustomPlot::onAddRect()
|
|
{
|
|
double right_Hight = xAxis->pixelToCoord(m_event->pos().y());//x轴展示深度
|
|
double left_Low = right_Hight-5;
|
|
//添加图形
|
|
//emit CallManage::getInstance()->sig_addImageToPlot(this, left_Low, right_Hight, ":/image/file.png");
|
|
addImageToPlot(left_Low, right_Hight, ":/image/file.png");
|
|
|
|
}
|
|
|
|
void QMyCustomPlot::addImageToPlot(double left_Low, double right_Hight, const QString imagePath)
|
|
{
|
|
// 在初始化代码中
|
|
TransparentDraggableRect *dragRect = new TransparentDraggableRect(this);
|
|
// 设置初始范围
|
|
dragRect->setRange(left_Low, right_Hight);
|
|
// 可选:设置颜色
|
|
dragRect->setColor(QColor(255, 100, 100, 80)); // 半透明红色
|
|
//最小宽度
|
|
dragRect->setMinWidth(5);
|
|
}
|
|
|
|
void QMyCustomPlot::onResetZoom()
|
|
{
|
|
|
|
// //rescaleAxes();
|
|
// //x,y互换
|
|
// yAxis->setRange(m_iX1, m_iX2);
|
|
// xAxis->setRange(m_iY1, m_iY2);
|
|
// //
|
|
// replot();
|
|
}
|
|
|
|
void QMyCustomPlot::removeSelectedGraph()
|
|
{
|
|
// if (selectedGraphs().size() > 0)
|
|
// {
|
|
// QString strLineName = selectedGraphs().first()->name();
|
|
// qDebug() << "removeSelectedGraph name=" << strLineName;
|
|
|
|
// removeGraph(selectedGraphs().first());
|
|
// replot();
|
|
|
|
// //emit CallManage::getInstance()->sig_DelCurve(m_indexID, strLineName);
|
|
// }
|
|
}
|
|
|
|
void QMyCustomPlot::removeSelectedGraphByTitle()
|
|
{
|
|
// if (selectedGraphs().size() > 0)
|
|
// {
|
|
// QString strLineName = selectedGraphs().first()->name();
|
|
// qDebug() << "removeSelectedGraph name=" << strLineName;
|
|
|
|
// removeGraph(selectedGraphs().first());
|
|
// replot();
|
|
|
|
// emit CallManage::getInstance()->sig_DelCurve(m_indexID, strLineName);
|
|
// }
|
|
}
|
|
|
|
void QMyCustomPlot::s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
|
|
{
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
raise();
|
|
}
|
|
}
|
|
|
|
//属性-左刻度
|
|
void QMyCustomPlot::s_ChangeLeftScale(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newLeftScale)
|
|
{
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
m_iX1 = newLeftScale;
|
|
yAxis->setRange(m_iX1, m_iX2);
|
|
//
|
|
replot();
|
|
}
|
|
else if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_newTargetLine == strLineName)
|
|
{
|
|
//其他曲线
|
|
s_ChangeFillMode(m_strUuid, m_strSlfName, m_strWellName, m_strTrackName, m_strLineName,
|
|
m_newFillType, m_newTargetLine, m_newColor, m_newLithosImage, m_newHeadFill,
|
|
newLeftScale, m_vMax, m_frontColor, m_backColor, m_newFillMode);
|
|
}
|
|
}
|
|
|
|
//属性-右刻度
|
|
void QMyCustomPlot::s_ChangeRightScale(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newRightScale)
|
|
{
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
m_iX2 = newRightScale;
|
|
yAxis->setRange(m_iX1, m_iX2);
|
|
//
|
|
replot();
|
|
}
|
|
else if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_newTargetLine == strLineName)
|
|
{
|
|
//其他曲线
|
|
s_ChangeFillMode(m_strUuid, m_strSlfName, m_strWellName, m_strTrackName, m_strLineName,
|
|
m_newFillType, m_newTargetLine, m_newColor, m_newLithosImage, m_newHeadFill,
|
|
m_vMin, newRightScale, m_frontColor, m_backColor, m_newFillMode);
|
|
}
|
|
}
|
|
|
|
//属性-刻度类型
|
|
void QMyCustomPlot::s_ChangeScaleType(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strScaleType)
|
|
{
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
m_strScaleType = strScaleType;
|
|
|
|
if(m_strScaleType=="对数")
|
|
{
|
|
yAxis->setScaleType(QCPAxis::stLogarithmic);
|
|
}
|
|
else //if(m_strScaleType=="线性")
|
|
{
|
|
yAxis->setScaleType(QCPAxis::stLinear);
|
|
}
|
|
|
|
//
|
|
replot();
|
|
}
|
|
else if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_newTargetLine == strLineName)
|
|
{
|
|
//其他曲线
|
|
//s_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName,
|
|
// m_newFillType, m_newTargetLine, m_newColor, m_newLithosImage, m_newHeadFill,
|
|
// m_vMin, newRightScale, m_frontColor, m_backColor, m_newFillMode);
|
|
}
|
|
}
|
|
|
|
//属性-颜色
|
|
void QMyCustomPlot::s_ChangeLineColor(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor)
|
|
{
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
QPen pen = this->graph(0)->pen();
|
|
pen.setColor(lineColor);
|
|
graph(0)->setPen(pen);
|
|
//
|
|
replot();
|
|
}
|
|
}
|
|
|
|
//属性-线宽
|
|
void QMyCustomPlot::s_ChangeLineWidth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double width)
|
|
{
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
QPen pen = this->graph(0)->pen();
|
|
pen.setWidthF(width);
|
|
graph(0)->setPen(pen);
|
|
//
|
|
replot();
|
|
}
|
|
}
|
|
|
|
//属性-线型
|
|
void QMyCustomPlot::s_ChangeLineStyle(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, Qt::PenStyle lineStyle)
|
|
{
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
QPen pen = this->graph(0)->pen();
|
|
pen.setStyle(lineStyle);
|
|
graph(0)->setPen(pen);
|
|
//
|
|
replot();
|
|
}
|
|
}
|
|
|
|
//岩性填充-不填充
|
|
void QMyCustomPlot::s_ClearFillMode(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
|
|
{
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
//清空填充
|
|
if(this->graphCount() > 1)
|
|
{
|
|
this->removeGraph(1);
|
|
}
|
|
graph(0)->setBrush(Qt::NoBrush);
|
|
//
|
|
replot();
|
|
}
|
|
}
|
|
|
|
//岩性填充-填充
|
|
void QMyCustomPlot::s_ChangeFillMode(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
|
|
QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill,
|
|
float vMin, float vMax, QColor frontColor, QColor backColor, QString newFillMode)
|
|
{
|
|
|
|
if(m_strUuid == strUuid &&
|
|
m_strSlfName == strSlfName &&
|
|
m_strWellName == strWellName &&
|
|
m_strTrackName == strTrackName &&
|
|
m_strLineName == strLineName)
|
|
{
|
|
//其他曲线
|
|
m_newFillType = newFillType;
|
|
m_newTargetLine = newTargetLine;
|
|
m_newColor = newColor;
|
|
m_newLithosImage = newLithosImage;
|
|
m_newHeadFill = newHeadFill;
|
|
m_vMin = vMin;
|
|
m_vMax = vMax;
|
|
m_frontColor = frontColor;
|
|
m_backColor = backColor;
|
|
m_newFillMode = newFillMode;
|
|
|
|
//填充
|
|
if(this->graphCount() > 1)
|
|
{
|
|
this->removeGraph(1);
|
|
}
|
|
//graph(1)
|
|
QVector<double> x, y;
|
|
|
|
if(newTargetLine=="左界道")
|
|
{
|
|
this->addGraph();
|
|
|
|
x.append(m_iY1);
|
|
y.append(m_iX1);
|
|
//
|
|
x.append(m_iY2);
|
|
y.append(m_iX1);
|
|
}
|
|
else if(newTargetLine=="右界道")
|
|
{
|
|
this->addGraph();
|
|
|
|
x.append(m_iY1);
|
|
y.append(m_iX2);
|
|
//
|
|
x.append(m_iY2);
|
|
y.append(m_iX2);
|
|
}
|
|
else if(newTargetLine=="对称线")
|
|
{
|
|
this->addGraph();
|
|
|
|
CLogIO *logio=new CLogIO();
|
|
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
|
int index=logio->OpenCurve(strLineName.toStdString().c_str());
|
|
if(index<0)
|
|
{
|
|
delete logio;
|
|
}
|
|
else
|
|
{
|
|
Slf_CURVE curveinfo;
|
|
float *val;
|
|
float sdep,edep,rlev;
|
|
float vmax,vmin;
|
|
//
|
|
logio->GetCurveInfo(index,&curveinfo);
|
|
sdep=curveinfo.StartDepth;
|
|
edep=curveinfo.EndDepth;
|
|
rlev=curveinfo.DepLevel;
|
|
//
|
|
int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5;
|
|
val=new float[count];
|
|
logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
|
|
logio->CloseCurve(index);
|
|
delete logio;
|
|
|
|
for(int i=0; i<count; i++)
|
|
{
|
|
x.append(-(sdep+ rlev*i));
|
|
y.append(m_iX1+m_iX2-val[i]);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(newFillMode=="左填充")
|
|
{
|
|
// if(m_strScaleType=="对数")
|
|
// {
|
|
// float iX1_Tmp=log(m_iX1);
|
|
// m_iX1 = iX1_Tmp;
|
|
// //
|
|
|
|
// float iX2_Tmp=log(m_iX2);
|
|
// m_iX2 = iX2_Tmp;
|
|
// }
|
|
|
|
//其他曲线(左填充)
|
|
CLogIO *logio=new CLogIO();
|
|
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
|
|
|
//读取基线信息
|
|
int indexBaseCurv = logio->OpenCurve(strLineName.toStdString().c_str());
|
|
if(indexBaseCurv < 0) {
|
|
this->addGraph();//空曲线
|
|
delete logio;
|
|
}
|
|
else
|
|
{
|
|
//其他曲线
|
|
int index=logio->OpenCurve(newTargetLine.toStdString().c_str());
|
|
if(index<0)
|
|
{
|
|
this->addGraph();//空曲线
|
|
delete logio;
|
|
}
|
|
else
|
|
{
|
|
Slf_CURVE curveinfo;
|
|
float *val;
|
|
float sdep,edep,rlev;
|
|
//
|
|
logio->GetCurveInfo(index,&curveinfo);
|
|
sdep=curveinfo.StartDepth;
|
|
edep=curveinfo.EndDepth;
|
|
rlev=curveinfo.DepLevel;
|
|
//
|
|
int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5;
|
|
val=new float[count];
|
|
logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
|
|
logio->CloseCurve(index);
|
|
//读完基线再关闭
|
|
// delete logio;
|
|
|
|
float newVal = 0.0;
|
|
for(int i=0; i<count; i++)
|
|
{
|
|
float x0=-(sdep+ rlev*i);
|
|
float y0_old=val[i];
|
|
float y0 = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
|
|
|
//读取基线
|
|
float BaseY0=0;
|
|
float BaseY0_Tmp=0;
|
|
logio->ReadCurve(indexBaseCurv, 0-x0, 1, &BaseY0);
|
|
// if(m_strScaleType=="对数")
|
|
// {
|
|
// BaseY0_Tmp=log(BaseY0);
|
|
// BaseY0 = BaseY0_Tmp;
|
|
// }
|
|
|
|
//
|
|
if(i+1<count)
|
|
{
|
|
float x1=-(sdep+ rlev*(i+1));
|
|
//float y1=val[i+1];
|
|
float y1 = (m_iX2-m_iX1)*(val[i+1]-vMin)/(vMax-vMin) + m_iX1;
|
|
//读取基线
|
|
float BaseY1=0;
|
|
float BaseY1_Tmp=0;
|
|
logio->ReadCurve(indexBaseCurv, 0-x1, 1, &BaseY1);
|
|
|
|
// if(m_strScaleType=="对数")
|
|
// {
|
|
// BaseY1_Tmp=log(BaseY1);
|
|
// BaseY1 = BaseY1_Tmp;
|
|
// }
|
|
|
|
if(BaseY0<=y0 && BaseY1<=y1)
|
|
{
|
|
//基线在左,采用基线值
|
|
//y0=BaseY0;
|
|
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
//
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
}
|
|
else if(BaseY0>=y0 && BaseY1>=y1)
|
|
{
|
|
//基线在右,直接赋值
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
}
|
|
else if(BaseY0<=y0 && BaseY1>=y1)
|
|
{
|
|
//基线起点在左,采用基线值
|
|
//y0=BaseY0;
|
|
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
//
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
|
|
//插值
|
|
float xNew=x0-rlev*(y0-BaseY0)/((BaseY1-y1)+(y0-BaseY0));//(BaseY1-y1);
|
|
float yNew=(y0-y1)/(x0-x1)*(xNew-x1) + y1;
|
|
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
//
|
|
x.append(xNew);
|
|
y.append(yNew_Old);
|
|
}
|
|
else if(BaseY0>=y0 && BaseY1<=y1)
|
|
{
|
|
//基线在右,直接赋值
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
|
|
//插值
|
|
float xNew=x0-rlev*(y0-BaseY0)/((BaseY1-y1)+(y0-BaseY0));//(BaseY1-y1);
|
|
float yNew=(BaseY0-BaseY1)/(x0-x1)*(xNew-x1) + BaseY1;
|
|
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
//
|
|
x.append(xNew);
|
|
y.append(yNew_Old);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//最后一个点
|
|
if(BaseY0<y0)
|
|
{
|
|
//基线在左,采用基线值
|
|
//y0=BaseY0;
|
|
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
}
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
}
|
|
|
|
//newVal = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
|
//newVal = val[i];
|
|
//y.append(newVal);
|
|
}
|
|
logio->CloseCurve(indexBaseCurv);
|
|
delete logio;
|
|
//
|
|
this->yAxis2->setRange(m_iY1, m_iY2);
|
|
this->xAxis2->setRange(vMin, vMax);
|
|
this->addGraph(yAxis2, xAxis2);
|
|
}
|
|
}
|
|
}
|
|
else if(newFillMode=="右填充")
|
|
{
|
|
//其他曲线(右填充)
|
|
CLogIO *logio=new CLogIO();
|
|
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
|
|
|
//读取基线信息
|
|
int indexBaseCurv = logio->OpenCurve(strLineName.toStdString().c_str());
|
|
if(indexBaseCurv < 0) {
|
|
this->addGraph();//空曲线
|
|
delete logio;
|
|
}
|
|
else
|
|
{
|
|
//其他曲线
|
|
int index=logio->OpenCurve(newTargetLine.toStdString().c_str());
|
|
if(index<0)
|
|
{
|
|
this->addGraph();//空曲线
|
|
delete logio;
|
|
}
|
|
else
|
|
{
|
|
Slf_CURVE curveinfo;
|
|
float *val;
|
|
float sdep,edep,rlev;
|
|
//
|
|
logio->GetCurveInfo(index,&curveinfo);
|
|
sdep=curveinfo.StartDepth;
|
|
edep=curveinfo.EndDepth;
|
|
rlev=curveinfo.DepLevel;
|
|
//
|
|
int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5;
|
|
val=new float[count];
|
|
logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
|
|
logio->CloseCurve(index);
|
|
//读完基线再关闭
|
|
// delete logio;
|
|
|
|
float newVal = 0.0;
|
|
for(int i=0; i<count; i++)
|
|
{
|
|
float x0=-(sdep+ rlev*i);
|
|
float y0_old=val[i];
|
|
float y0 = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
|
|
|
//读取基线
|
|
float BaseY0=0;
|
|
logio->ReadCurve(indexBaseCurv, 0-x0, 1, &BaseY0);
|
|
//
|
|
if(i+1<count)
|
|
{
|
|
float x1=-(sdep+ rlev*(i+1));
|
|
//float y1=val[i+1];
|
|
float y1 = (m_iX2-m_iX1)*(val[i+1]-vMin)/(vMax-vMin) + m_iX1;
|
|
//读取基线
|
|
float BaseY1=0;
|
|
logio->ReadCurve(indexBaseCurv, 0-x1, 1, &BaseY1);
|
|
|
|
if(BaseY0<=y0 && BaseY1<=y1)
|
|
{
|
|
//基线在左,直接赋值
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
}
|
|
else if(BaseY0>=y0 && BaseY1>=y1)
|
|
{
|
|
//基线在右,采用基线值
|
|
//y0=BaseY0;
|
|
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
//
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
}
|
|
else if(BaseY0<=y0 && BaseY1>=y1)
|
|
{
|
|
//基线起点在左,直接赋值
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
|
|
//插值
|
|
float xNew=x0-rlev*(y0-BaseY0)/((BaseY1-y1)+(y0-BaseY0));//(BaseY1-y1);
|
|
float yNew=(y0-y1)/(x0-x1)*(xNew-x1) + y1;
|
|
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
//
|
|
x.append(xNew);
|
|
y.append(yNew_Old);
|
|
}
|
|
else if(BaseY0>=y0 && BaseY1<=y1)
|
|
{
|
|
//基线在右,采用基线值
|
|
//y0=BaseY0;
|
|
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
//
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
|
|
//插值
|
|
float xNew=x0-rlev*(y0-BaseY0)/((BaseY1-y1)+(y0-BaseY0));//(BaseY1-y1);
|
|
float yNew=(BaseY0-BaseY1)/(x0-x1)*(xNew-x1) + BaseY1;
|
|
float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
//
|
|
x.append(xNew);
|
|
y.append(yNew_Old);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//最后一个点
|
|
if(BaseY0>y0)
|
|
{
|
|
//基线在右,采用基线值
|
|
//y0=BaseY0;
|
|
y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin;
|
|
}
|
|
x.append(x0);
|
|
y.append(y0_old);
|
|
}
|
|
|
|
//newVal = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
|
//newVal = val[i];
|
|
//y.append(newVal);
|
|
}
|
|
logio->CloseCurve(indexBaseCurv);
|
|
delete logio;
|
|
//
|
|
this->yAxis2->setRange(m_iY1, m_iY2);
|
|
this->xAxis2->setRange(vMin, vMax);
|
|
this->addGraph(yAxis2, xAxis2);
|
|
}
|
|
}
|
|
}
|
|
else //填充
|
|
{
|
|
//其他曲线
|
|
CLogIO *logio=new CLogIO();
|
|
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
|
int index=logio->OpenCurve(newTargetLine.toStdString().c_str());
|
|
if(index<0)
|
|
{
|
|
this->addGraph();
|
|
|
|
delete logio;
|
|
}
|
|
else
|
|
{
|
|
Slf_CURVE curveinfo;
|
|
float *val;
|
|
float sdep,edep,rlev;
|
|
//
|
|
logio->GetCurveInfo(index,&curveinfo);
|
|
sdep=curveinfo.StartDepth;
|
|
edep=curveinfo.EndDepth;
|
|
rlev=curveinfo.DepLevel;
|
|
//
|
|
int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5;
|
|
val=new float[count];
|
|
logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]);
|
|
logio->CloseCurve(index);
|
|
delete logio;
|
|
|
|
float newVal = 0.0;
|
|
for(int i=0; i<count; i++)
|
|
{
|
|
x.append(-(sdep+ rlev*i));
|
|
//newVal = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1;
|
|
newVal = val[i];
|
|
y.append(newVal);
|
|
}
|
|
this->yAxis2->setRange(m_iY1, m_iY2);
|
|
this->xAxis2->setRange(vMin, vMax);
|
|
this->addGraph(yAxis2, xAxis2);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
this->graph(1)->setData(x, y);
|
|
graph(1)->setLineStyle(graph(0)->lineStyle());//曲线
|
|
graph(1)->setScatterStyle(graph(0)->scatterStyle());
|
|
//graph(1)->setPen(QColor(255, 255, 255));
|
|
graph(1)->setPen(QColor(0, 0, 0));//(graph(0)->pen());
|
|
|
|
//
|
|
if(newFillType == "岩性模式")
|
|
{
|
|
QColor oldFrontColor(0, 0, 0); // 原始颜色
|
|
QColor oldBackColor(255, 255, 255); // 原始颜色
|
|
//
|
|
QImage image(newLithosImage);
|
|
for (int y = 0; y < image.height(); ++y) {
|
|
for (int x = 0; x < image.width(); ++x) {
|
|
QColor pixelColor = QColor(image.pixel(x, y));
|
|
if (pixelColor == oldFrontColor) {
|
|
image.setPixelColor(x, y, m_frontColor); // 使用 setPixelColor 来设置新颜色
|
|
}
|
|
if (pixelColor == oldBackColor) {
|
|
image.setPixelColor(x, y, m_backColor); // 使用 setPixelColor 来设置新颜色
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
graph(0)->setBrush(QBrush(QPixmap::fromImage(image)));
|
|
//graph(0)->setBrush(QBrush(QPixmap(newLithosImage)));
|
|
}
|
|
else if(newFillType == "颜色模式")
|
|
{
|
|
graph(0)->setBrush(QBrush(newColor));
|
|
}
|
|
else if(newFillType == "成像化")
|
|
{
|
|
|
|
}
|
|
graph(0)->setChannelFillGraph( this->graph(1));
|
|
//
|
|
replot();
|
|
}
|
|
}
|
|
|
|
void QMyCustomPlot::mouseMoveEvent(QMouseEvent *event)
|
|
{
|
|
// 当前鼠标位置(像素坐标)
|
|
//int x_pos = event->pos().x();
|
|
int y_pos = event->pos().y();
|
|
|
|
// 像素坐标转成实际的x,y轴的坐标
|
|
//float x_val = yAxis->pixelToCoord(x_pos);
|
|
float y_val = xAxis->pixelToCoord(y_pos);
|
|
|
|
emit CallManage::getInstance()->sig_MouseMove(m_strUuid, m_strWellName, m_strTrackName, 0-y_val);
|
|
|
|
QCustomPlot::mouseMoveEvent(event);
|
|
}
|