深度 json文件保存读取

This commit is contained in:
crqiqi77 2026-03-24 09:43:05 +08:00
parent ce7b7b962f
commit 5d647c3d26
7 changed files with 361 additions and 70 deletions

View File

@ -3412,7 +3412,12 @@ void PropertyWidget::initTubingItemProperty(TransparentDraggableGuan* tdGuan, do
void PropertyWidget::changedDepthProperty(QString strProperty, QVariant varVal)
{
if ("主刻度线长度" == strProperty)
if ("显示单位" == strProperty)
{
this->m_formInfo->m_strUnit = varVal.toString();
this->m_formInfo->repaint();
}
else if ("主刻度线长度" == strProperty)
{
int temp = varVal.toInt();
this->m_formInfo->m_sdMajorTickLineLength = temp;
@ -3458,11 +3463,6 @@ void PropertyWidget::changedDepthProperty(QString strProperty, QVariant varVal)
bool temp = varVal.toBool();
this->m_formInfo->m_sdMeasuredDepth = temp;
}
else if ("显示单位" == strProperty)
{
this->m_formInfo->m_strUnit = varVal.toString();
this->m_formInfo->repaint();
}
else if ("单位" == strProperty)
{
QFont temp = varVal.value<QFont>();
@ -3496,4 +3496,56 @@ void PropertyWidget::changedDepthProperty(QString strProperty, QVariant varVal)
}
this->m_formInfo->m_sdMeasuredDepthPosition = newStyle;
}
else if ("垂深位置" == strProperty)
{
int temp = varVal.toInt();
int newStyle = 0;
switch(temp)
{
case 0:
// 偏左
newStyle = Qt::NoPen;
break;
case 1:
// 居中
newStyle = Qt::SolidLine;
break;
case 2:
// 偏右
newStyle = Qt::DashLine;
break;
}
this->m_formInfo->m_sdVerticalDepthPosition = newStyle;
}
else if ("海拔垂深位置" == strProperty)
{
int temp = varVal.toInt();
int newStyle = 0;
switch(temp)
{
case 0:
// 偏左
newStyle = Qt::NoPen;
break;
case 1:
// 居中
newStyle = Qt::SolidLine;
break;
case 2:
// 偏右
newStyle = Qt::DashLine;
break;
}
this->m_formInfo->m_sdElevationVerticalDepthPosition = newStyle;
}
else if ("垂深" == strProperty)
{
bool temp = varVal.toBool();
this->m_formInfo->m_sdVerticalDepth = temp;
}
else if ("海拔垂深" == strProperty)
{
bool temp = varVal.toBool();
this->m_formInfo->m_sdElevationVerticalDepth = temp;
}
}

View File

@ -183,9 +183,147 @@ void FormDraw::setDrawData(QStringList listdt, QJsonObject objInfo)
else if("depthObject" == strType)
{
// 在s_addDepth方法设置单位无效
pInfo->m_strUnit = "(米)";
pInfo->m_strUnitFont = QFont("微软雅黑", 8);
// 读取json
// 设置左侧显示属性 设置界面样式
// if(pInfo->m_strUnit.isEmpty()){
// pInfo->m_strUnit = "(米)";
// pInfo->m_strUnitFont = QFont("微软雅黑", 16);
// }
// bool m_sdDrawStartDepth; // 绘制起点深度
// bool m_sdDrawEndDepth; // 绘制终点深度
// int m_sdMajorTickLineLength = 3; // 主刻度线长度
// int m_sdMajorTickLineWidth = 1; // 主刻度线宽度
// int m_sdMinorTickLineLength = 1; // 次刻度线长度
// int m_sdMinorTickLineWidth = 1; // 次刻度线宽度
initDepth(curv);
// 读json后 重新设置样式
// 头部高度
pInfo->setFixedHeight(pInfo->m_headHeight);
// 标尺颜色
curv->yAxis->setTickLabelColor(pInfo->m_sdRulerColor);
// 间隔
QSharedPointer<QCPAxisTickerFixed> fixedTicker(new QCPAxisTickerFixed);
fixedTicker->setTickStep(pInfo->m_sdInterval);
fixedTicker->setScaleStrategy(QCPAxisTickerFixed::ssNone);
curv->yAxis->setTicker(fixedTicker);
// 标注字体
curv->yAxis->setTickLabelFont(pInfo->m_sdLabelFont);
// 旋转(°)
curv->yAxis->setTickLabelRotation(pInfo->m_sdRotationAngle);
// 斜深
curv->yAxis->setTickLabels(pInfo->m_sdMeasuredDepth);
// 海拔垂深
{
bool temp = pInfo->m_sdElevationVerticalDepth;
if(!curv->m_yAxis2)
{
curv->m_yAxis2 = new QCPAxis(curv->axisRect(), QCPAxis::atLeft);
curv->axisRect()->addAxis(QCPAxis::atLeft, curv->m_yAxis2);
curv->m_yAxis2->setRange(0, 100);
curv->m_yAxis2->setOffset(40);
curv->m_yAxis2->setTickLabelPadding(10);
}
curv->m_yAxis2->setVisible(temp);
curv->m_yAxis2->setTickLabels(temp);
curv->m_yAxis2->setTickLabelSide(QCPAxis::lsInside);
}
// 垂深
bool temp2 = pInfo->m_sdVerticalDepth;
if(!curv->m_yAxis3)
{
curv->m_yAxis3 = new QCPAxis(curv->axisRect(), QCPAxis::atLeft);
curv->axisRect()->addAxis(QCPAxis::atLeft, curv->m_yAxis3);
curv->m_yAxis3->setRange(0, 100);
curv->m_yAxis3->setOffset(40);
curv->m_yAxis3->setTickLabelPadding(10);
}
curv->m_yAxis3->setVisible(temp2); // 显示第三个Y轴
curv->m_yAxis3->setTickLabels(temp2);
curv->m_yAxis3->setTickLabelSide(QCPAxis::lsInside);
// 斜深位置
switch(pInfo->m_sdMeasuredDepthPosition)
{
case 0:
// 偏左
curv->yAxis->setTickLabelPadding(5);
break;
case 1:
// 居中
curv->yAxis->setTickLabelPadding(30);
break;
case 2:
curv->yAxis->setTickLabelPadding(50);
break;
}
// 垂深位置
switch(pInfo->m_sdVerticalDepthPosition)
{
case 0:
// 偏左
curv->m_yAxis3->setTickLabelPadding(5 + 10);
break;
case 1:
// 居中
curv->m_yAxis3->setTickLabelPadding(30 + 10);
break;
case 2:
curv->m_yAxis3->setTickLabelPadding(50 + 10);
break;
}
// 海拔垂深位置
switch(pInfo->m_sdElevationVerticalDepthPosition)
{
case 0:
// 偏左
curv->m_yAxis2->setTickLabelPadding(5 + 10);
break;
case 1:
// 居中
curv->m_yAxis2->setTickLabelPadding(30);
break;
case 2:
curv->m_yAxis2->setTickLabelPadding(50 + 10);
break;
}
// 主刻度线长度
{
int temp = pInfo->m_sdMajorTickLineLength;
curv->yAxis->setTickLength(temp, 0);
}
// 主刻度线宽度
{
int temp = pInfo->m_sdMajorTickLineWidth;
QPen tickPen = curv->yAxis->tickPen();
tickPen.setWidth(temp);
curv->yAxis->setTickPen(tickPen);
}
// 次刻度线长度
{
int temp = pInfo->m_sdMinorTickLineLength;
curv->yAxis->setSubTickLength(temp, 0);
}
// 次刻度线宽度
{
int temp = pInfo->m_sdMinorTickLineWidth;
QPen tickPen = curv->yAxis->subTickPen();
tickPen.setWidth(temp);
curv->yAxis->setSubTickPen(tickPen);
}
}
else if("plObject" == strType)
{
@ -325,6 +463,11 @@ void FormDraw::DisplayLines(QJsonArray linesArray)
//套管组件
DisplayTubing_One(lineObjInfo);
}
else if (strType == "depthObject")
{
// 深度
DisplayDepth_One(lineObjInfo);
}
else
{
DisplayType_One(lineObjInfo);
@ -1009,6 +1152,21 @@ void FormDraw::DisplayTubing_One(QJsonObject lineObjInfo)
}
}
void FormDraw::DisplayDepth_One(QJsonObject objInfo)
{
QString strType = objInfo.value("Type").toString();
QString strLineName = objInfo.value("LineName").toString();
QStringList dt;
dt << m_strUuid;
dt << m_strWellName;
dt << m_strSlfName;
dt << strLineName;
dt << strType;
dt << QString::number(m_nTrackW);
this->setDrawData(dt, objInfo);
}
void FormDraw::DisplayLine_One(QJsonObject lineObjInfo)
{
QString strSlfName = "";

View File

@ -59,7 +59,8 @@ public:
void DisplayLine_One(QJsonObject lineObjInfo);
//波列
void DisplayType_One(QJsonObject objInfo);
// 深度
void DisplayDepth_One(QJsonObject lineObjInfo);
//表格:固井结论等
void DisplayTable_One(QJsonObject lineObjInfo);

View File

@ -114,6 +114,52 @@ void FormInfo::initProperty(QJsonObject obj)
m_nWaveJg = obj.value("WaveJg").toInt();
m_fWaveHei = obj.value("WaveHei").toDouble();
}
else if ("depthObject" == strType)
{
m_bVerticaDrawing = obj["bVerticaDrawing"].toBool(); // 垂向绘制
m_nRotationAngle = obj["nRotationAngle"].toInt(); // 旋转角度
m_headHeight = obj["headHeight"].toInt();
m_strUnit = obj["strUnit"].toString(); // 单位
{
QStringList fontParts = obj["curveNameFont"].toString().split(","); // 按逗号拆分
if (fontParts.size() >= 2) {
m_curveNameFont.setFamily(fontParts[0]); // 设置字体名称
m_curveNameFont.setPointSize(fontParts[1].toInt()); // 设置字号
}
}
{
QStringList fontParts = obj["strUnitFont"].toString().split(","); // 按逗号拆分
if (fontParts.size() >= 2) {
m_strUnitFont.setFamily(fontParts[0]); // 设置字体名称
m_strUnitFont.setPointSize(fontParts[1].toInt()); // 设置字号
}
}
m_headHeight = obj["headHeight"].toInt();
m_sdRulerColor = obj["sdRulerColor"].toString(); // 标尺颜色
m_sdInterval = obj["sdInterval"].toDouble(); // 间隔
// 标注字体
{
QStringList fontParts = obj["sdLabelFont"].toString().split(","); // 按逗号拆分
if (fontParts.size() >= 2) {
m_sdLabelFont.setFamily(fontParts[0]); // 设置字体名称
m_sdLabelFont.setPointSize(fontParts[1].toInt()); // 设置字号
}
}
m_sdRotationAngle = obj["sdRotationAngle"].toDouble(); // 旋转(°)
m_sdDrawStartDepth = obj["sdDrawStartDepth"].toBool(); // 绘制起点深度
m_sdDrawEndDepth = obj["sdDrawEndDepth"].toBool(); // 绘制终点深度
m_sdMeasuredDepth = obj["sdMeasuredDepth"].toBool(); // 斜深
m_sdElevationVerticalDepth = obj["sdElevationVerticalDepth"].toBool(); // 海拔垂深
m_sdVerticalDepth = obj["sdVerticalDepth"].toBool(); // 垂深
m_sdMeasuredDepthPosition = obj["sdMeasuredDepthPosition"].toInt(); // 斜深位置
m_sdVerticalDepthPosition = obj["sdVerticalDepthPosition"].toInt(); // 垂深位置
m_sdElevationVerticalDepthPosition = obj["sdElevationVerticalDepthPosition"].toInt(); // 海拔垂深位置
m_sdMajorTickLineLength = obj["sdMajorTickLineLength"].toInt(); // 主刻度线长度
m_sdMajorTickLineWidth = obj["sdMajorTickLineWidth"].toInt(); // 主刻度线宽度
m_sdMinorTickLineLength = obj["sdMinorTickLineLength"].toInt(); // 次刻度线长度
m_sdMinorTickLineWidth = obj["sdMinorTickLineWidth"].toInt(); // 次刻度线宽度
}
}
QJsonObject FormInfo::makeJson()
@ -249,7 +295,31 @@ QJsonObject FormInfo::makeJson()
rootObj["SchemeIndex"] = m_nSchemeIndex;
rootObj["ColorNum"] = m_nColorNum;
}
else if (m_strType == "depthObject")
{
rootObj["bVerticaDrawing"] = m_bVerticaDrawing; // 垂向绘制
rootObj["nRotationAngle"] = m_nRotationAngle; // 旋转角度
rootObj["strUnit"] = m_strUnit; // 单位
rootObj["curveNameFont"] = m_curveNameFont.toString();
rootObj["strUnitFont"] = m_strUnitFont.toString(); //单位字体
rootObj["headHeight"] = m_headHeight;
rootObj["sdRulerColor"] = m_sdRulerColor.name(); // 标尺颜色
rootObj["sdInterval"] = m_sdInterval; // 间隔
rootObj["sdLabelFont"] = m_sdLabelFont.toString(); // 标注字体
rootObj["sdRotationAngle"] = m_sdRotationAngle; // 旋转(°)
rootObj["sdDrawStartDepth"] = m_sdDrawStartDepth; // 绘制起点深度
rootObj["sdDrawEndDepth"] = m_sdDrawEndDepth; // 绘制终点深度
rootObj["sdMeasuredDepth"] = m_sdMeasuredDepth; // 斜深
rootObj["sdElevationVerticalDepth"] = m_sdElevationVerticalDepth; // 海拔垂深
rootObj["sdVerticalDepth"] = m_sdVerticalDepth; // 垂深
rootObj["sdMeasuredDepthPosition"] = m_sdMeasuredDepthPosition; // 斜深位置
rootObj["sdVerticalDepthPosition"] = m_sdVerticalDepthPosition; // 垂深位置
rootObj["sdElevationVerticalDepthPosition"] = m_sdElevationVerticalDepthPosition; // 海拔垂深位置
rootObj["sdMajorTickLineLength"] = m_sdMajorTickLineLength; // 主刻度线长度
rootObj["sdMajorTickLineWidth"] = m_sdMajorTickLineWidth; // 主刻度线宽度
rootObj["sdMinorTickLineLength"] = m_sdMinorTickLineLength; // 次刻度线长度
rootObj["sdMinorTickLineWidth"] = m_sdMinorTickLineWidth; // 次刻度线宽度
}
return rootObj;
}

View File

@ -223,16 +223,15 @@ public:
//tvd
// 深度
// ---------------- 基础配置 ----------------
QColor m_sdRulerColor; // 标尺颜色
double m_sdInterval = 1; // 间隔
double m_sdInterval = 20; // 间隔
QFont m_sdLabelFont = QFont("微软雅黑", 16); // 标注字体
double m_sdRotationAngle = 0.0; // 旋转(°)
double m_sdDrawStartDepth; // 绘制起点深度
double m_sdDrawEndDepth; // 绘制终点深度
double m_sdMeasuredDepth = true; // 斜深
double m_sdElevationVerticalDepth; // 海拔垂深
double m_sdVerticalDepth; // 垂深
bool m_sdDrawStartDepth; // 绘制起点深度
bool m_sdDrawEndDepth; // 绘制终点深度
bool m_sdMeasuredDepth = true; // 斜深
bool m_sdElevationVerticalDepth = false; // 海拔垂深
bool m_sdVerticalDepth = false; // 垂深
int m_sdMeasuredDepthPosition = 0; // 斜深位置
int m_sdVerticalDepthPosition = 0; // 垂深位置
int m_sdElevationVerticalDepthPosition; // 海拔垂深位置

View File

@ -4556,31 +4556,7 @@ void QMyCustomPlot::s_changeDepthProperty(QVariantList vlist)
{
QString strProperty = vlist.at(5).toString();
QVariant varVal = vlist.at(6).toString();
if ("主刻度线长度" == strProperty)
{
int height = varVal.toInt();
this->yAxis->setTickLength(height, 0);
}
else if ("主刻度线宽度" == strProperty)
{
int temp = varVal.toInt();
QPen tickPen = this->yAxis->tickPen();
tickPen.setWidth(temp);
this->yAxis->setTickPen(tickPen);
}
else if ("次刻度线长度" == strProperty)
{
int temp = varVal.toInt();
this->yAxis->setSubTickLength(temp, 0);
}
else if ("次刻度线宽度" == strProperty)
{
int temp = varVal.toInt();
QPen tickPen = this->yAxis->subTickPen();
tickPen.setWidth(temp);
this->yAxis->setSubTickPen(tickPen);
}
else if ("标尺颜色" == strProperty)
if ("标尺颜色" == strProperty)
{
QColor newColor = varVal.value<QColor>();
this->yAxis->setTickLabelColor(newColor);
@ -4612,33 +4588,21 @@ void QMyCustomPlot::s_changeDepthProperty(QVariantList vlist)
bool temp = varVal.toBool();
this->yAxis->setTickLabels(temp);
}
else if ("斜深位置" == strProperty)
{
// 没有直接设置偏移方法 动态计算太麻烦
int temp = varVal.toInt();
switch(temp)
{
case 0:
// 偏左
this->yAxis->setTickLabelPadding(5);
break;
case 1:
// 居中
this->yAxis->setTickLabelPadding(30);
break;
case 2:
this->yAxis->setTickLabelPadding(50);
break;
}
}
else if ("海拔垂深" == strProperty)
{
bool temp = varVal.toBool();
this->yAxis2->setTickLabels(temp);
this->yAxis2->setVisible(temp);
this->yAxis2->setTickLabelSide(QCPAxis::lsInside);
// this->yAxis2->setAxisType(QCPAxis::atLeft);
// this->yAxis2->setPosition(QCPAxis::atLeft);
if(!this->m_yAxis2)
{
this->m_yAxis2 = new QCPAxis(this->axisRect(), QCPAxis::atLeft);
this->axisRect()->addAxis(QCPAxis::atLeft, this->m_yAxis2);
this->m_yAxis2->setRange(0, 100);
this->m_yAxis2->setOffset(40);
this->m_yAxis2->setTickLabelPadding(10);
}
// 设置旋转 间隔
this->m_yAxis2->setVisible(temp); // 显示第三个Y轴
this->m_yAxis2->setTickLabels(temp);
this->m_yAxis2->setTickLabelSide(QCPAxis::lsInside);
}
else if ("垂深" == strProperty)
{
@ -4655,21 +4619,22 @@ void QMyCustomPlot::s_changeDepthProperty(QVariantList vlist)
this->m_yAxis3->setTickLabels(temp);
this->m_yAxis3->setTickLabelSide(QCPAxis::lsInside);
}
else if ("海拔垂深位置" == strProperty)
else if ("深位置" == strProperty)
{
// 没有直接设置偏移方法 动态计算太麻烦
int temp = varVal.toInt();
switch(temp)
{
case 0:
// 偏左
this->yAxis2->setTickLabelPadding(50);
this->yAxis->setTickLabelPadding(5);
break;
case 1:
// 居中
this->yAxis2->setTickLabelPadding(30);
this->yAxis->setTickLabelPadding(30);
break;
case 2:
this->yAxis2->setTickLabelPadding(5);
this->yAxis->setTickLabelPadding(50);
break;
}
}
@ -4691,6 +4656,51 @@ void QMyCustomPlot::s_changeDepthProperty(QVariantList vlist)
break;
}
}
else if ("海拔垂深位置" == strProperty)
{
int temp = varVal.toInt();
switch(temp)
{
case 0:
// 偏左
this->m_yAxis2->setTickLabelPadding(5 + 10);
break;
case 1:
// 居中
this->m_yAxis2->setTickLabelPadding(30);
break;
case 2:
this->m_yAxis2->setTickLabelPadding(50 + 10);
break;
}
}
else if ("主刻度线长度" == strProperty)
{
int height = varVal.toInt();
this->yAxis->setTickLength(height, 0);
}
else if ("主刻度线宽度" == strProperty)
{
int temp = varVal.toInt();
QPen tickPen = this->yAxis->tickPen();
tickPen.setWidth(temp);
this->yAxis->setTickPen(tickPen);
}
else if ("次刻度线长度" == strProperty)
{
int temp = varVal.toInt();
this->yAxis->setSubTickLength(temp, 0);
}
else if ("次刻度线宽度" == strProperty)
{
int temp = varVal.toInt();
QPen tickPen = this->yAxis->subTickPen();
tickPen.setWidth(temp);
this->yAxis->setSubTickPen(tickPen);
}
this->replot();
}
}

View File

@ -159,6 +159,7 @@ public:
int m_nWaveHei = 1;
// 深度 第三个轴
QCPAxis *m_yAxis2 = nullptr;
QCPAxis *m_yAxis3 = nullptr; // 保存指针
public:
bool m_bEditor = false; // 编辑状态