Compare commits

..

No commits in common. "d09d1006ca009c512d98a7ca2087fb459d16dbbc" and "2d7f3dcf7514a7fdd50264559b77f61f5f963d24" have entirely different histories.

6 changed files with 22 additions and 188 deletions

View File

@ -444,67 +444,6 @@ void PropertyWidget::changedCorePhysicsProperty(QtProperty *qtProperty, const QV
this->m_tdCorePhysics->setCpCoreValue(temp); this->m_tdCorePhysics->setCpCoreValue(temp);
this->m_tdCorePhysics->mPlot->saveToSLFCorePhysics(); this->m_tdCorePhysics->mPlot->saveToSLFCorePhysics();
} }
else if("左刻度" == m_propertyData[qtProperty])
{
double temp = variant.toDouble();
this->m_formInfo->m_cp_leftScale = temp;
this->m_tdCorePhysics->setCpLeftScale(temp);
}
else if("右刻度" == m_propertyData[qtProperty])
{
double temp = variant.toDouble();
this->m_formInfo->m_cp_rightScale = temp;
this->m_tdCorePhysics->setCpRightScale(temp);
}
else if("等分刻度数或自定义序列" == m_propertyData[qtProperty])
{
double temp = variant.toDouble();
this->m_formInfo->m_cp_scaleDivisionsOrCustom = temp;
this->m_tdCorePhysics->setCpScaleDivisionsOrCustom(temp);
}
else if("刻度类型" == m_propertyData[qtProperty])
{
int newStyle = 0;
int iStyle = variant.value<int>();
switch(iStyle)
{
case 0:
// 线性
newStyle = 0;
break;
case 1:
// 对数
newStyle = 1;
break;
case 2:
// 倾角
newStyle = 2;
break;
}
this->m_formInfo->m_cp_scaleType = newStyle;
this->m_tdCorePhysics->setCpScaleType(newStyle);
}
else if("显示单位" == m_propertyData[qtProperty])
{
QString temp = variant.toString();
this->m_formInfo->m_strUnit = temp;
this->m_tdCorePhysics->setCpDisplayUnit(temp);
this->m_formInfo->repaint();
}
else if("曲线单位" == m_propertyData[qtProperty])
{
QFont temp = variant.value<QFont>();
this->m_formInfo->m_strUnitFont = temp;
this->m_formInfo->repaint();
}
else if("曲线刻度" == m_propertyData[qtProperty])
{
QFont temp = variant.value<QFont>();
this->m_formInfo->m_cp_curveScale = temp;
this->m_tdCorePhysics->setCpCurveScale(temp);
}
this->m_tdCorePhysics->update(); this->m_tdCorePhysics->update();
} }
@ -3323,6 +3262,7 @@ void PropertyWidget::initCorePhysicsItemProperty(TransparentDraggableCorePhysics
m_strUuid = formInfo->m_strUuid; m_strUuid = formInfo->m_strUuid;
m_strTrackUuid = formInfo->m_strTrackUuid; m_strTrackUuid = formInfo->m_strTrackUuid;
//
m_strSlfName = formInfo->m_strSlfName; m_strSlfName = formInfo->m_strSlfName;
m_strWellName = formInfo->m_strWellName; m_strWellName = formInfo->m_strWellName;
m_strTrackName = formInfo->m_strTrackName; m_strTrackName = formInfo->m_strTrackName;
@ -3345,19 +3285,15 @@ void PropertyWidget::initCorePhysicsItemProperty(TransparentDraggableCorePhysics
listStyle.append("虚点点线"); listStyle.append("虚点点线");
_CreateEnumPropertyItem("曲线线型", "线型", (int)formInfo->m_cp_lineStyle, listStyle); _CreateEnumPropertyItem("曲线线型", "线型", (int)formInfo->m_cp_lineStyle, listStyle);
_CreateVariantPropertyItem("显示设置", "左刻度", formInfo->m_cp_leftScale, QVariant::Double); _CreateVariantPropertyItem("显示设置", "左刻度", formInfo->m_yxzpLabelFont, QVariant::Font);
_CreateVariantPropertyItem("显示设置", "右刻度", formInfo->m_cp_rightScale, QVariant::Double); _CreateVariantPropertyItem("显示设置", "右刻度", formInfo->m_yxzpLabelRotation, QVariant::Int);
_CreateVariantPropertyItem("显示设置", "等分刻度数或自定义序列", formInfo->m_cp_scaleDivisionsOrCustom, QVariant::Int); _CreateVariantPropertyItem("显示设置", "等分刻度数或自定义序列", formInfo->m_yxzpTwoEndDrawing, QVariant::Bool);
QStringList listStyle4; _CreateVariantPropertyItem("显示设置", "刻度类型", formInfo->m_yxzpDrawColor, QVariant::Bool);
listStyle4.append("线性"); _CreateVariantPropertyItem("显示设置", "显示单位", formInfo->m_nRotationAngle, QVariant::Double);
listStyle4.append("对数");
listStyle4.append("倾角");
_CreateEnumPropertyItem("显示设置", "刻度类型", formInfo->m_cp_scaleType, listStyle4);
_CreateVariantPropertyItem("显示设置", "显示单位", formInfo->m_strUnit, QVariant::String);
_CreateVariantPropertyItem("字体", "字体", formInfo->m_curveNameFont, QVariant::Font); _CreateVariantPropertyItem("字体", "曲线名称", formInfo->m_yxzpTwoEndDrawing, QVariant::Bool);
_CreateVariantPropertyItem("字体", "曲线单位", formInfo->m_strUnitFont, QVariant::Font); _CreateVariantPropertyItem("字体", "曲线单位", formInfo->m_yxzpDrawColor, QVariant::Bool);
_CreateVariantPropertyItem("字体", "曲线刻度", formInfo->m_cp_curveScale, QVariant::Font); _CreateVariantPropertyItem("字体", "曲线刻度", formInfo->m_nRotationAngle, QVariant::Double);
_CreateVariantPropertyItem("绘制方式", "杆状", formInfo->m_cp_drawAsBar, QVariant::Bool); _CreateVariantPropertyItem("绘制方式", "杆状", formInfo->m_cp_drawAsBar, QVariant::Bool);
_CreateVariantPropertyItem("绘制方式", "左界", formInfo->m_cp_leftBoundary, QVariant::Bool); _CreateVariantPropertyItem("绘制方式", "左界", formInfo->m_cp_leftBoundary, QVariant::Bool);

View File

@ -49,9 +49,6 @@ void TransparentDraggableCorePhysics::setRange(double left_Low, double right_Hig
} }
} }
m_lY1 = lY1; m_lY1 = lY1;
// lY2除以实际左到右刻度数值
lY2 = lY2 / (getCpRightScale() - getCpLeftScale()) * 100;
qcpItemLine->start->setCoords(left_Low, lY1);//圆心位置 qcpItemLine->start->setCoords(left_Low, lY1);//圆心位置
qcpItemLine->end->setCoords(right_Hight, lY2);//圆心位置 qcpItemLine->end->setCoords(right_Hight, lY2);//圆心位置
@ -114,9 +111,9 @@ void TransparentDraggableCorePhysics::initRect()
tracer = new QCPItemTracer(this->mPlot); tracer = new QCPItemTracer(this->mPlot);
tracer->setGraph(nullptr); // 不关联曲线,自由定位 tracer->setGraph(nullptr); // 不关联曲线,自由定位
tracer->setStyle(QCPItemTracer::tsCircle); // 圆形可选tsSquare, tsCross, tsPlus等 tracer->setStyle(QCPItemTracer::tsCircle); // 圆形可选tsSquare, tsCross, tsPlus等
tracer->setSize(3); // 点的大小(像素) tracer->setSize(8); // 点的大小(像素)
tracer->setPen(QPen(Qt::red)); // 边框颜色 tracer->setPen(QPen(Qt::red)); // 边框颜色
tracer->setBrush(QBrush(QColor(0, 0, 0, 0))); // 黄色半透明Alpha=128 tracer->setBrush(QBrush(Qt::yellow)); // 填充颜色
tracer->setInterpolating(false); tracer->setInterpolating(false);
// 绑定到线条终点(关键!) // 绑定到线条终点(关键!)
tracer->position->setParentAnchor(this->qcpItemLine->end); tracer->position->setParentAnchor(this->qcpItemLine->end);
@ -377,10 +374,6 @@ double TransparentDraggableCorePhysics::getCpLeftScale() const
void TransparentDraggableCorePhysics::setCpLeftScale(double value) void TransparentDraggableCorePhysics::setCpLeftScale(double value)
{ {
this->m_cp_leftScale = value; this->m_cp_leftScale = value;
this->mPlot->yAxis2->setRange(value, this->mPlot->yAxis2->range().upper);
// 重新绘制图形
this->setRange(this->m_left_Low, this->m_left_Low, this->getCpCoreValue(), false);
} }
double TransparentDraggableCorePhysics::getCpRightScale() const double TransparentDraggableCorePhysics::getCpRightScale() const
@ -391,10 +384,6 @@ double TransparentDraggableCorePhysics::getCpRightScale() const
void TransparentDraggableCorePhysics::setCpRightScale(double value) void TransparentDraggableCorePhysics::setCpRightScale(double value)
{ {
this->m_cp_rightScale = value; this->m_cp_rightScale = value;
this->mPlot->yAxis2->setRange(this->mPlot->yAxis2->range().lower, value);
// 重新绘制图形
this->setRange(this->m_left_Low, this->m_left_Low, this->getCpCoreValue(), false);
} }
int TransparentDraggableCorePhysics::getCpScaleType() const int TransparentDraggableCorePhysics::getCpScaleType() const
@ -405,23 +394,6 @@ int TransparentDraggableCorePhysics::getCpScaleType() const
void TransparentDraggableCorePhysics::setCpScaleType(int value) void TransparentDraggableCorePhysics::setCpScaleType(int value)
{ {
this->m_cp_scaleType = value; this->m_cp_scaleType = value;
int newStyle = 0;
switch(value)
{
case 0:
// 线性
this->mPlot->yAxis2->setScaleType(QCPAxis::stLinear);
break;
case 1:
// 对数
this->mPlot->yAxis2->setScaleType(QCPAxis::stLogarithmic);
break;
case 2:
// 倾角 没有倾角类型
this->mPlot->yAxis2->setScaleType(QCPAxis::stLogarithmic);
break;
}
} }
int TransparentDraggableCorePhysics::getCpScaleDivisionsOrCustom() const int TransparentDraggableCorePhysics::getCpScaleDivisionsOrCustom() const
@ -432,24 +404,6 @@ int TransparentDraggableCorePhysics::getCpScaleDivisionsOrCustom() const
void TransparentDraggableCorePhysics::setCpScaleDivisionsOrCustom(int value) void TransparentDraggableCorePhysics::setCpScaleDivisionsOrCustom(int value)
{ {
this->m_cp_scaleDivisionsOrCustom = value; this->m_cp_scaleDivisionsOrCustom = value;
// 创建文本刻度 Ticker
QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
double minVal = this->mPlot->yAxis2->range().lower;
double maxVal = this->mPlot->yAxis2->range().upper;
// 计算步长:(最大值 - 最小值) / 等分数
double step = (maxVal - minVal) / value;
// 生成刻度
for (int i = 0; i <= value; ++i) {
double value = minVal + step * i;
// 取整显示34.0 显示为 "34"
QString label = QString::number(qRound(value));
textTicker->addTick(value, label);
}
// 应用 Ticker
this->mPlot->yAxis2->setTicker(textTicker);
// 设置范围(稍微留边距,让刻度显示完整)
// this->mPlot->yAxis2->setRange(minVal - step * 0.1, maxVal + step * 0.1);
} }
QString TransparentDraggableCorePhysics::getCpDisplayUnit() const QString TransparentDraggableCorePhysics::getCpDisplayUnit() const
@ -482,16 +436,14 @@ void TransparentDraggableCorePhysics::setCpCurveUnit(const QString &value)
this->m_cp_curveUnit = value; this->m_cp_curveUnit = value;
} }
QFont TransparentDraggableCorePhysics::getCpCurveScale() const double TransparentDraggableCorePhysics::getCpCurveScale() const
{ {
return this->m_cp_curveScale; return this->m_cp_curveScale;
} }
void TransparentDraggableCorePhysics::setCpCurveScale(QFont value) void TransparentDraggableCorePhysics::setCpCurveScale(double value)
{ {
this->m_cp_curveScale = value; this->m_cp_curveScale = value;
this->mPlot->yAxis2->setTickLabelFont(value);
} }
bool TransparentDraggableCorePhysics::getCpDrawAsBar() const bool TransparentDraggableCorePhysics::getCpDrawAsBar() const
@ -635,11 +587,7 @@ void TransparentDraggableCorePhysics::setCpSymbolSize(int value)
{ {
this->m_cp_symbolSize = value; this->m_cp_symbolSize = value;
QList<QCPItemTracer*> tracers = this->mPlot->findChildren<QCPItemTracer*>(); tracer->setSize(value); // 点的大小(像素)
foreach (QCPItemTracer *tracer, tracers) {
tracer->setSize(value); // 点的大小(像素)
}
} }
QColor TransparentDraggableCorePhysics::getCpSymbolFillColor() const QColor TransparentDraggableCorePhysics::getCpSymbolFillColor() const

View File

@ -87,8 +87,8 @@ public:
QString getCpCurveUnit() const; QString getCpCurveUnit() const;
void setCpCurveUnit(const QString &value); void setCpCurveUnit(const QString &value);
QFont getCpCurveScale() const; double getCpCurveScale() const;
void setCpCurveScale(QFont value); void setCpCurveScale(double value);
bool getCpDrawAsBar() const; bool getCpDrawAsBar() const;
void setCpDrawAsBar(bool value); void setCpDrawAsBar(bool value);
@ -130,14 +130,14 @@ private:
int m_cp_lineWidth; // 线宽 int m_cp_lineWidth; // 线宽
QColor m_cp_lineColor; // 线条颜色 QColor m_cp_lineColor; // 线条颜色
Qt::PenStyle m_cp_lineStyle; // 线型 Qt::PenStyle m_cp_lineStyle; // 线型
double m_cp_leftScale = 0; // 左刻度 double m_cp_leftScale; // 左刻度
double m_cp_rightScale = 100; // 右刻度 double m_cp_rightScale; // 右刻度
int m_cp_scaleType; // 刻度类型 int m_cp_scaleType; // 刻度类型
int m_cp_scaleDivisionsOrCustom; // 等分刻度数或自定序列 int m_cp_scaleDivisionsOrCustom; // 等分刻度数或自定序列
QString m_cp_displayUnit; // 显示单位 QString m_cp_displayUnit; // 显示单位
QString m_cp_curveName; // 曲线名称 QString m_cp_curveName; // 曲线名称
QString m_cp_curveUnit; // 曲线单位 QString m_cp_curveUnit; // 曲线单位
QFont m_cp_curveScale; // 曲线刻度 double m_cp_curveScale; // 曲线刻度
bool m_cp_drawAsBar; // 杆状 bool m_cp_drawAsBar; // 杆状
bool m_cp_leftBoundary; // 左界 bool m_cp_leftBoundary; // 左界
bool m_cp_skipZeroInvalidValues; // 不绘零等无效值 bool m_cp_skipZeroInvalidValues; // 不绘零等无效值

View File

@ -6603,53 +6603,11 @@ void FormDraw::initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QStrin
widget->xAxis = yAxis; widget->xAxis = yAxis;
widget->yAxis = xAxis; widget->yAxis = xAxis;
QCPAxis *yAxis2 = widget->yAxis2;
QCPAxis *xAxis2 = widget->xAxis2;
widget->xAxis2 = yAxis2;
widget->yAxis2 = xAxis2;
// //隐藏刻度 // //隐藏刻度
widget->xAxis->setTicks(false); widget->xAxis->setTicks(false);
widget->yAxis->setTicks(false); widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false); widget->xAxis2->setTicks(false);
widget->yAxis2->setTicks(true); widget->yAxis2->setTicks(false);
widget->yAxis2->setTickLabels(true);
widget->yAxis2->setTickLabelSide(QCPAxis::lsInside);
widget->yAxis2->setRange(0, 100);
// 设置刻度
// 创建文本刻度 Ticker
QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
double minVal = widget->yAxis2->range().lower;
double maxVal = widget->yAxis2->range().upper;
int value = 2;
// 计算步长:(最大值 - 最小值) / 等分数
double step = (maxVal - minVal) / value;
// 生成刻度
for (int i = 0; i <= value; ++i) {
double value = minVal + step * i;
// 取整显示34.0 显示为 "34"
QString label = QString::number(qRound(value));
textTicker->addTick(value, label);
}
// 应用 Ticker
widget->yAxis2->setTicker(textTicker);
// 创建固定刻度器 - 刻度位置和标签完全由你控制
// QSharedPointer<QCPAxisTickerFixed> fixedTicker(new QCPAxisTickerFixed);
// fixedTicker->setTickStep(10.0); // 固定刻度间隔
// widget->yAxis2->setTicker(fixedTicker);
// 获取当前数据范围
// double lower = widget->yAxis2->range().lower;
// double upper = widget->yAxis2->range().upper;
// widget->yAxis2->setRange(lower - 9, upper + 11);
// double margin = (upper - lower) * 0.05; // 5% 边距
// widget->yAxis2->setRange(lower - margin, upper + margin);
QVector<double> x, y; QVector<double> x, y;

View File

@ -732,10 +732,8 @@ void FormInfo::paintEvent(QPaintEvent* event)
if(m_strType=="waveObject" if(m_strType=="waveObject"
|| m_strType=="curveObject") || m_strType=="curveObject")
{ {
QFont oldFont = painter.font();
painter.setFont(m_strUnitFont);
painter.drawText(rect.left()+10, rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignCenter, m_strUnit); painter.drawText(rect.left()+10, rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignCenter, m_strUnit);
painter.setFont(oldFont);
// 显示刻度 // 显示刻度
if (m_bShowScale) if (m_bShowScale)
{ {
@ -757,7 +755,7 @@ void FormInfo::paintEvent(QPaintEvent* event)
if(m_strLineName == "深度") if(m_strLineName == "深度")
{ {
// 2. 给painter设置字体关键步骤 || m_strLineName == "CORE_PHYSICS" // 2. 给painter设置字体关键步骤
painter.setFont(m_strUnitFont); painter.setFont(m_strUnitFont);
painter.drawText(rect.left(), rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignCenter, this->m_strUnit); painter.drawText(rect.left(), rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignCenter, this->m_strUnit);
} }

View File

@ -236,12 +236,6 @@ public:
double m_cp_depth; // 深度 double m_cp_depth; // 深度
double m_cp_corrDepth; // 校正深度 double m_cp_corrDepth; // 校正深度
double m_cp_coreValue; // 数值 double m_cp_coreValue; // 数值
double m_cp_leftScale = 0; // 左刻度
double m_cp_rightScale = 100; // 右刻度
int m_cp_scaleDivisionsOrCustom = 2; // 等分刻度数或自定序列
int m_cp_scaleType = 0; // 刻度类型
QFont m_cp_curveUnit; // 曲线单位
QFont m_cp_curveScale; // 曲线刻度
public: public:
void setLineWidth(double dWidth); void setLineWidth(double dWidth);