曲线属性优化,支持勾选对称,支持记录到模板json文件

This commit is contained in:
jiayulong 2026-03-03 17:27:51 +08:00
parent 61692a81b4
commit 431df68fdf
7 changed files with 286 additions and 28 deletions

View File

@ -538,16 +538,87 @@ void FormDraw::DisplayLine_One(QJsonObject lineObjInfo)
lineColor.setNamedColor(lineObjInfo.value("lineColor").toString());
}
//
bool bDrawLine = true; // 曲线
bool bDrawGan = false; // 杆状
bool bDrawPoint = false; // 点状
bool bDrawSymmetry = false; // 绘制对称曲线
//
if (lineObjInfo.contains("DrawLine"))
{
QJsonValue value = lineObjInfo.value("DrawLine");
if (value.isBool()) {
bDrawLine = value.toBool();
}
}
//
if (lineObjInfo.contains("DrawGan"))
{
QJsonValue value = lineObjInfo.value("DrawGan");
if (value.isBool()) {
bDrawGan = value.toBool();
}
}
//
if (lineObjInfo.contains("DrawPoint"))
{
QJsonValue value = lineObjInfo.value("DrawPoint");
if (value.isBool()) {
bDrawPoint = value.toBool();
}
}
//
if (lineObjInfo.contains("DrawSymmetry"))
{
QJsonValue value = lineObjInfo.value("DrawSymmetry");
if (value.isBool()) {
bDrawSymmetry = value.toBool();
}
}
QString folderPath = GetLogdataPath();
folderPath = folderPath + g_prjname;
strSlfName = folderPath + "/" + "#" + strWellName + "/" + strSlfName;
if (strLineName != "")
{
//此处属性注意顺序,后续使用按照顺序
QStringList listOtherProperty;
listOtherProperty.append(strAliasName);
listOtherProperty.append(strUnit);
listOtherProperty.append(curveNameFont.toString());//曲线名称字体
if(bDrawLine)
{
listOtherProperty.append("DrawLine");
}
else{
listOtherProperty.append("0");
}
//
if(bDrawGan)
{
listOtherProperty.append("DrawGan");
}
else{
listOtherProperty.append("0");
}
//
if(bDrawPoint)
{
listOtherProperty.append("DrawPoint");
}
else{
listOtherProperty.append("0");
}
//
if(bDrawSymmetry)
{
listOtherProperty.append("DrawSymmetry");
}
else{
listOtherProperty.append("0");
}
//新建曲线
s_AddLine_Property(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName,
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle, listOtherProperty);
@ -2441,6 +2512,7 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
QString strAliasName="";
QString strUnit="";
if(listOtherProperty.size()>=2)
{
strAliasName=listOtherProperty[0];
@ -2453,7 +2525,49 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
{
strAliasName=strLineName;
}
}
bool bDrawLine = true; // 曲线
bool bDrawGan = false; // 杆状
bool bDrawPoint = false; // 点状
bool bDrawSymmetry = false; // 绘制对称曲线
if(listOtherProperty.size()>=7)
{
if(listOtherProperty[3]=="DrawLine")
{
bDrawLine = true;
}
else
{
bDrawLine = false;
}
//
if(listOtherProperty[4]=="DrawGan")
{
bDrawGan = true;
}
else
{
bDrawGan = false;
}
//
if(listOtherProperty[5]=="DrawPoint")
{
bDrawPoint = true;
}
else
{
bDrawPoint = false;
}
//
if(listOtherProperty[6]=="DrawSymmetry")
{
bDrawSymmetry = true;
}
else
{
bDrawSymmetry = false;
}
}
//最大值,最小值
@ -2548,8 +2662,13 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
if(newLeftScale!=-9999)
{
widget->m_bDrawLine = bDrawLine;
widget->m_bDrawGan = bDrawGan;
widget->m_bDrawPoint = bDrawPoint;
widget->m_bDrawSymmetry = bDrawSymmetry;
addRandomGraph(widget, x, y, strSlfName, strLineName, strAliasName, strUnit,
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle);
newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle, listOtherProperty);
}
else {
addRandomGraph(widget, x, y, strSlfName, strLineName, strAliasName, strUnit);
@ -6309,11 +6428,12 @@ void FormDraw::ReadData(QString strSlfName, QString strLineName)
}
void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName, QString strAliasName, QString strUnit,
double newLeftScale, double newRightScale, QString strScaleType, QColor newlineColor, double width, Qt::PenStyle lineStyle)
double newLeftScale, double newRightScale, QString strScaleType, QColor newlineColor, double width, Qt::PenStyle lineStyle, QStringList listOtherProperty)
{
widget->addRandomGraph(x, y, strSlfName, strLineName, strAliasName, strUnit,
newLeftScale, newRightScale, strScaleType, newlineColor, width, lineStyle);
//道-对象
if(widget->m_bDrawCore_PHYSICS)
{
@ -6321,7 +6441,7 @@ void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_vmax, m_vmin, strScaleType, "tableObject");
}
else {
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_vmax, m_vmin, strScaleType, "curveObject");
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_vmax, m_vmin, strScaleType, "curveObject", listOtherProperty);
}
//AppendConsole(PAI_INFO, "FormDraw addRandomGraph");
// widget->addGraph();

View File

@ -102,7 +102,7 @@ public:
void initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
double newLeftScale=-9999, double newRightScale=-9999, QString strScaleType="线性", QColor lineColor=QColor(0,0,0), double width=1, Qt::PenStyle lineStyle=Qt::SolidLine, QStringList listOtherProperty={});
void addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName, QString strAliasName, QString strUnit,
double newLeftScale=-9999, double newRightScale=-9999, QString strScaleType="线性", QColor lineColor=QColor(0,0,0), double width=1, Qt::PenStyle lineStyle=Qt::SolidLine);
double newLeftScale=-9999, double newRightScale=-9999, QString strScaleType="线性", QColor lineColor=QColor(0,0,0), double width=1, Qt::PenStyle lineStyle=Qt::SolidLine, QStringList listOtherProperty={});
void setupLineStyleDemo(QMyCustomPlot *customPlot);
void setupSelectionDemo(QMyCustomPlot *customPlot);

View File

@ -155,6 +155,11 @@ QJsonObject FormInfo::makeJson()
if (m_strType == "curveObject")
{
rootObj["DrawLine"] = m_bDrawLine; // 曲线
rootObj["DrawGan"] = m_bDrawGan; // 杆状
rootObj["DrawPoint"] = m_bDrawPoint; // 点状
rootObj["DrawSymmetry"] = m_bDrawSymmetry; // 绘制对称曲线
//岩性填充
rootObj["newFillMode"] = m_newFillMode;
rootObj["newHeadFill"] = m_newHeadFill;

View File

@ -45,8 +45,8 @@ FormTrack::FormTrack(QWidget *parent, QString strWellName, QString strTrackName)
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
//曲线
connect(this, SIGNAL(sig_AddLine(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
this, SLOT(s_addLine(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)));
connect(this, SIGNAL(sig_AddLine(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString, QStringList)),
this, SLOT(s_addLine(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString, QStringList)));
//删除曲线
connect(CallManage::getInstance(), SIGNAL(sig_delLine(QString, QString, QString, QString)),
this, SLOT(s_delLine(QString, QString, QString, QString)));
@ -175,7 +175,7 @@ void FormTrack::Add(QString strSlfName, QString strWellName, QString strTrackNam
if(strType=="curveObject")
{
emit sig_AddLine(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
emit sig_AddLine(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType, listOtherProperty);
}
else if(strType=="waveObject")
{
@ -304,7 +304,7 @@ FormInfo* FormTrack::setDrawDt(QStringList listdt, QJsonObject obj)
return formInfo;
}
void FormTrack::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 FormTrack::s_addLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QStringList listOtherProperty)
{
qDebug() << "FormTrack s_addLine";
@ -328,6 +328,52 @@ void FormTrack::s_addLine(QString strSlfName, QString strWellName, QString strTr
formInfo->setVMin(vmin);
formInfo->setFrontColor(QColor(0,0,0));
formInfo->setBackColor(QColor(255,255,255));
//
if(listOtherProperty.size()>=3)
{
QFont curveNameFont("微软雅黑", 10); // 名称字体
curveNameFont.fromString(listOtherProperty[2]);
formInfo->m_curveNameFont = curveNameFont;
}
if(listOtherProperty.size()>=7)
{
if(listOtherProperty[3]=="DrawLine")
{
formInfo->m_bDrawLine = true;
}
else
{
formInfo->m_bDrawLine = false;
}
//
if(listOtherProperty[4]=="DrawGan")
{
formInfo->m_bDrawGan = true;
}
else
{
formInfo->m_bDrawGan = false;
}
//
if(listOtherProperty[5]=="DrawPoint")
{
formInfo->m_bDrawPoint = true;
}
else
{
formInfo->m_bDrawPoint = false;
}
//
if(listOtherProperty[6]=="DrawSymmetry")
{
formInfo->m_bDrawSymmetry = true;
}
else
{
formInfo->m_bDrawSymmetry = false;
}
}
//设置高度
ui->tableWidget->setRowHeight(row, 100);
//单元格委托

View File

@ -68,7 +68,7 @@ public:
QStringList getLineList(QString strWellName, QString strTrackName);
signals:
void sig_AddLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
void sig_AddLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QStringList listOtherProperty={});
void sig_AddWave(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType);
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, QStringList listOtherProperty={});
@ -87,7 +87,7 @@ signals:
void sig_AddTubingstring(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_addLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QStringList listOtherProperty={});
void s_delLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);
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);

View File

@ -2707,6 +2707,7 @@ void QMyCustomPlot::s_ChangeDrawSymmetry(QString strUuid, QString strSlfName, QS
for(int i=0; i<count; i++)
{
x.append(-(sdep+ rlev*i));
//对称处理
if(m_strScaleType=="对数")
{
y.append(log(m_iX1)+log(m_iX2)-log(val[i]));
@ -2727,7 +2728,35 @@ void QMyCustomPlot::s_ChangeDrawSymmetry(QString strUuid, QString strSlfName, QS
{
this->xAxis2->setRange(m_iX1, m_iX2);
}
this->addGraph(yAxis2, xAxis2);
//移除
if(graph_Symmetry)
{
this->removeGraph(graph_Symmetry);
graph_Symmetry=nullptr;
}
//新建
graph_Symmetry = this->addGraph(yAxis2, xAxis2);
if(graph_Symmetry)
{
graph_Symmetry->setData(x, y);
graph_Symmetry->setLineStyle(graph(0)->lineStyle());//曲线
graph_Symmetry->setScatterStyle(graph(0)->scatterStyle());
//graph_Fill->setPen(QColor(255, 255, 255));
graph_Symmetry->setPen(QColor(0, 0, 0));//(graph(0)->pen());
//
replot();
}
}
else
{
//移除
if(graph_Symmetry)
{
this->removeGraph(graph_Symmetry);
graph_Symmetry=nullptr;
//
replot();
}
}
}
@ -2786,12 +2815,15 @@ void QMyCustomPlot::s_ChangeFillMode(QString strUuid, QString strSlfName, QStrin
return;
}
//填充
if(this->graphCount() > 1)
//if(this->graphCount() > 1)
if(graph_Fill)
{
this->removeGraph(1);
//this->removeGraph(1);
this->removeGraph(graph_Fill);
graph_Fill=nullptr;
}
//graph(1)
QCPGraph *graph_Fill=nullptr;
//QCPGraph *graph_Fill=nullptr;
QVector<double> x, y;
if(newTargetLine=="左界道")
@ -3348,12 +3380,12 @@ void QMyCustomPlot::addRandomGraph(QVector<double> x, QVector<double> y, QString
m_x.append(x);
m_y.append(y);
addGraph();
QCPGraph *graph=addGraph();
if(strLineName=="")
{
strLineName = QString("曲线 %1").arg(graphCount());
}
graph()->setName(strLineName);
graph->setName(strLineName);
//禁用自动重绘:在大量数据更新前禁用自动重绘
//setNotAntialiasedElements(QCP::aeAll);
@ -3363,32 +3395,74 @@ void QMyCustomPlot::addRandomGraph(QVector<double> x, QVector<double> y, QString
{
if(m_bDrawCore_PHYSICS)//岩心分析
{
graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));//杆状线
graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssCircle)));//圆圈
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)));//点
//勾选3个
if(m_bDrawLine && m_bDrawGan && m_bDrawPoint)
{
graph->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));//杆状线
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssCircle)));//圆圈
}
//勾选2个
else if(m_bDrawLine && m_bDrawGan && !m_bDrawPoint){//曲线+杆状
graph->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssDot)));
}
else if(m_bDrawLine && !m_bDrawGan && m_bDrawPoint){//曲线+点状
graph->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssCircle)));//圆圈
}
else if(!m_bDrawLine && m_bDrawGan && m_bDrawPoint){//杆状+点状
graph->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssCircle)));//圆圈
}
//勾选1个
else if(m_bDrawLine && !m_bDrawGan && !m_bDrawPoint)//曲线
{
graph->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssDot)));
}
else if(!m_bDrawLine && m_bDrawGan && !m_bDrawPoint)//杆状
{
graph->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssDot)));
}
else if(!m_bDrawLine && !m_bDrawGan && m_bDrawPoint)//点状
{
graph->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsNone));
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssCircle)));//圆圈
}
//勾选0个
else if(!m_bDrawLine && !m_bDrawGan && !m_bDrawPoint)//曲线
{
graph->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsNone));
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssNone)));
}
// graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));//曲线
// graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssDot)));//点
}
QPen graphPen;
graphPen.setColor(newlineColor);
graphPen.setWidthF(width);
graphPen.setStyle(lineStyle);//实线
graph()->setPen(graphPen);
graph->setPen(graphPen);
}
else
{
if(m_bDrawCore_PHYSICS)//岩心分析
{
graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsImpulse));//杆状线
graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssCircle)));//圆圈
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->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));//曲线
graph->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssDot)));//点
}
// graph()->setScatterStyle(QCPScatterStyle(QPixmap(":/image/file.png")));
@ -3400,26 +3474,27 @@ void QMyCustomPlot::addRandomGraph(QVector<double> x, QVector<double> y, QString
width = 2;
graphPen.setWidthF(width);
graphPen.setStyle(Qt::SolidLine);//实线
graph()->setPen(graphPen);
graph->setPen(graphPen);
//replot();
}
if(x.size()<m_iSplitNum)
{
graph()->setData(x, y);
graph->setData(x, y);
replot();
//replot(QCustomPlot::rpRefreshHint);// 仅刷新可见部分,跳过轴计算等
}
else
{
graph()->setData(x.mid(0,m_iSplitNum), y.mid(0,m_iSplitNum));
graph->setData(x.mid(0,m_iSplitNum), y.mid(0,m_iSplitNum));
replot();
m_iCurNum = m_iSplitNum;
QTimer::singleShot(100, this, SLOT(slot_time()));
}
}
void QMyCustomPlot::slot_time()
@ -3435,6 +3510,13 @@ void QMyCustomPlot::slot_time()
{
graph()->addData(m_x.mid(m_iCurNum), m_y.mid(m_iCurNum));
m_iCurNum = m_x.size();
//处理完成,绘制对称曲线
if(m_bDrawSymmetry)
{
s_ChangeDrawSymmetry(m_strUuid, m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, m_bDrawSymmetry);
}
//处理完成,填充
//默认true只有模板存在填充时才会false
if(m_bFillNow==false)

View File

@ -59,6 +59,11 @@ public:
float m_iX1, m_iX2;
float m_iY1, m_iY2;
//填充曲线
QCPGraph *graph_Fill=nullptr;
//对称曲线
QCPGraph *graph_Symmetry=nullptr;
//其他曲线
QString m_newFillType;
QString m_newTargetLine;