From 5d647c3d261d588e6309bab8af4e93bae82193dd Mon Sep 17 00:00:00 2001 From: crqiqi77 Date: Tue, 24 Mar 2026 09:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=B1=E5=BA=A6=20json=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/PropertyWidget.cpp | 64 +++++++++++++-- logPlus/formdraw.cpp | 162 ++++++++++++++++++++++++++++++++++++- logPlus/formdraw.h | 3 +- logPlus/forminfo.cpp | 72 ++++++++++++++++- logPlus/forminfo.h | 13 ++- logPlus/qmycustomplot.cpp | 116 ++++++++++++++------------ logPlus/qmycustomplot.h | 1 + 7 files changed, 361 insertions(+), 70 deletions(-) diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index e7a18aa..6eb2e55 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -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(); @@ -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; + } } diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index 3b475b3..38ce91f 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -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 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 = ""; diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index dd9d363..d15cd8a 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -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); diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index f8bc4f0..0e861fa 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -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; } diff --git a/logPlus/forminfo.h b/logPlus/forminfo.h index e1663d6..9b54f03 100644 --- a/logPlus/forminfo.h +++ b/logPlus/forminfo.h @@ -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; // 海拔垂深位置 diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 8cd385f..e39cfe0 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -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(); 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(); } } diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 4e515fb..a29f15b 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -159,6 +159,7 @@ public: int m_nWaveHei = 1; // 深度 第三个轴 + QCPAxis *m_yAxis2 = nullptr; QCPAxis *m_yAxis3 = nullptr; // 保存指针 public: bool m_bEditor = false; // 编辑状态