diff --git a/CallManage/CallManage.h b/CallManage/CallManage.h index 9ab0aba..71d6f3c 100644 --- a/CallManage/CallManage.h +++ b/CallManage/CallManage.h @@ -187,6 +187,8 @@ signals: //改变深度属性 void sig_changeDepthProperty(QVariantList vlist); + // 改变裂缝属性 + void sig_changeCrackProperty(QVariantMap variantMap); // 改变频率统计图属性 void sig_changePlObjectProperty(QVariantMap variantMap); // 改变玫瑰图属性 diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index 9d9c1dd..191b122 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -4376,76 +4376,91 @@ void PropertyWidget::changedCrackProperty(QString strProperty, QVariant varVal) { this->m_formInfo->m_pl_highGap = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("高阻缝" == strProperty) { this->m_formInfo->m_pl_highReservoir = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("网状缝" == strProperty) { this->m_formInfo->m_pl_reticularFracture = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("诱导缝" == strProperty) { this->m_formInfo->m_pl_inducedFracture = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("层理" == strProperty) { this->m_formInfo->m_pl_bedLayer = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("侵蚀面" == strProperty) { this->m_formInfo->m_pl_erosionSurface = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("孔洞" == strProperty) { this->m_formInfo->m_pl_pore = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("气孔" == strProperty) { this->m_formInfo->m_pl_vesicle = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("砾石" == strProperty) { this->m_formInfo->m_pl_gravel = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("结核" == strProperty) { this->m_formInfo->m_pl_nodule = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("团块" == strProperty) { this->m_formInfo->m_pl_lumps = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("断层" == strProperty) { this->m_formInfo->m_pl_fault = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("垂直缝" == strProperty) { this->m_formInfo->m_pl_verticalFracture = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("自定义1" == strProperty) { this->m_formInfo->m_pl_custom1 = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } else if ("自定义2" == strProperty) { this->m_formInfo->m_pl_custom2 = varVal.toBool(); this->m_formInfo->repaint(); + flag = true; } if(flag) @@ -4453,38 +4468,30 @@ void PropertyWidget::changedCrackProperty(QString strProperty, QVariant varVal) QVariantMap variantMap; // 必须用来判断当前道 variantMap["m_strTrackName"] = this->m_formInfo->m_strTrackName; - // 数据 + // 分类 + variantMap["m_pl_highGap"] = this->m_formInfo->m_pl_highGap; + variantMap["m_pl_highReservoir"] = this->m_formInfo->m_pl_highReservoir; + variantMap["m_pl_reticularFracture"] = this->m_formInfo->m_pl_reticularFracture; + variantMap["m_pl_inducedFracture"] = this->m_formInfo->m_pl_inducedFracture; + variantMap["m_pl_bedLayer"] = this->m_formInfo->m_pl_bedLayer; + variantMap["m_pl_erosionSurface"] = this->m_formInfo->m_pl_erosionSurface; + variantMap["m_pl_pore"] = this->m_formInfo->m_pl_pore; + variantMap["m_pl_vesicle"] = this->m_formInfo->m_pl_vesicle; + variantMap["m_pl_gravel"] = this->m_formInfo->m_pl_gravel; + variantMap["m_pl_nodule"] = this->m_formInfo->m_pl_nodule; + variantMap["m_pl_lumps"] = this->m_formInfo->m_pl_lumps; + variantMap["m_pl_fault"] = this->m_formInfo->m_pl_fault; + variantMap["m_pl_verticalFracture"] = this->m_formInfo->m_pl_verticalFracture; + variantMap["m_pl_custom1"] = this->m_formInfo->m_pl_custom1; + variantMap["m_pl_custom2"] = this->m_formInfo->m_pl_custom2; + variantMap["m_pl_dataType"] = this->m_formInfo->m_pl_dataType; + variantMap["m_pl_dataType"] = this->m_formInfo->m_pl_dataType; + variantMap["m_pl_dataType"] = this->m_formInfo->m_pl_dataType; + variantMap["m_pl_dataType"] = this->m_formInfo->m_pl_dataType; + variantMap["m_pl_dataType"] = this->m_formInfo->m_pl_dataType; variantMap["m_pl_dataType"] = this->m_formInfo->m_pl_dataType; - variantMap["m_pl_azimuthCurve"] = this->m_formInfo->m_pl_azimuthCurve; - variantMap["m_pl_inclinationCurve"] = this->m_formInfo->m_pl_inclinationCurve; - // 控制曲线 - variantMap["m_pl_controlCurveName"] = this->m_formInfo->m_pl_controlCurveName; - variantMap["m_pl_controlMinValue"] = this->m_formInfo->m_pl_controlMinValue; - variantMap["m_pl_controlMaxValue"] = this->m_formInfo->m_pl_controlMaxValue; - variantMap["m_pl_sectorCount"] = this->m_formInfo->m_pl_sectorCount; - variantMap["m_pl_circleRadius"] = this->m_formInfo->m_pl_circleRadius; - variantMap["m_pl_circleColor"] = this->m_formInfo->m_pl_circleColor; - variantMap["m_pl_circleLineWidth"] = this->m_formInfo->m_pl_circleLineWidth; - variantMap["m_pl_isFillEnabled"] = this->m_formInfo->m_pl_isFillEnabled; - variantMap["m_pl_fillColor"] = this->m_formInfo->m_pl_fillColor; - // 线数 - variantMap["m_pl_lineNumber"] = this->m_formInfo->m_pl_lineNumber; - variantMap["m_pl_lineHeight"] = this->m_formInfo->m_pl_lineHeight; - variantMap["m_pl_lineThickness"] = this->m_formInfo->m_pl_lineThickness; - variantMap["m_pl_lineColor"] = this->m_formInfo->m_pl_lineColor; - variantMap["m_pl_drawAnnotation"] = this->m_formInfo->m_pl_drawAnnotation; - variantMap["m_pl_drawHistogram"] = this->m_formInfo->m_pl_drawHistogram; - variantMap["m_pl_baselineWidth"] = this->m_formInfo->m_pl_baselineWidth; - variantMap["m_pl_baselineColor"] = this->m_formInfo->m_pl_baselineColor; - // 统计间隔 - variantMap["m_pl_statInterval"] = this->m_formInfo->m_pl_statInterval; - variantMap["m_pl_minInclination"] = this->m_formInfo->m_pl_minInclination; - variantMap["m_pl_maxInclination"] = this->m_formInfo->m_pl_maxInclination; - - variantMap["m_strUuid"] = this->m_formInfo->m_strUuid; - variantMap["m_strTrackName"] = this->m_formInfo->m_strTrackName; -// emit CallManage::getInstance()->sig_changePlObjectProperty(variantMap); + emit CallManage::getInstance()->sig_changeCrackProperty(variantMap); } } diff --git a/logPlus/TransparentDraggableCrackObject.cpp b/logPlus/TransparentDraggableCrackObject.cpp index 09eb165..ca9827a 100644 --- a/logPlus/TransparentDraggableCrackObject.cpp +++ b/logPlus/TransparentDraggableCrackObject.cpp @@ -1,56 +1,250 @@ -#include "TransparentDraggableCrackObject.h" +#include "TransparentDraggableCrackObject.h" #include #include +#include #include -QList TransparentDraggableCrackObject::s_allCurves; -TransparentDraggableCrackObject* TransparentDraggableCrackObject::s_activeCurve = nullptr; +QPointer TransparentDraggableCrackObject::s_activeObject = nullptr; -TransparentDraggableCrackObject::TransparentDraggableCrackObject(QMyCustomPlot *parentPlot, - const QString &strUuid, - double depth) +TransparentDraggableCrackObject::TransparentDraggableCrackObject(QCustomPlot *parentPlot, + const QString &strUuid, double depth, QString type, QString showNames) : QObject(parentPlot) , mPlot(parentPlot) + , m_uuid(strUuid) , m_depth(depth) - , m_endX(mPlot->m_iX2) - , m_orig_x1(m_endX * 0.18) - , m_orig_x2(m_endX * 0.82) - , m_orig_y1(depth + 1.0) - , m_orig_y2(depth - 1.0) - , m_orig_startX(0) - , m_orig_endX(m_endX) - , m_orig_startDirX(m_endX * 0.3) - , m_orig_endDirX(m_endX * 0.7) - , m_offsetX(0.0) - , m_offsetY(0.0) + , m_endX(mPlot->xAxis->range().upper) + , mCurve(nullptr) + , m_tracer1(nullptr) + , m_tracer2(nullptr) + , m_dragStateA(IdleA) + , m_isAddingLine(false) + , m_offsetXB(0.0), m_offsetYB(0.0) + , m_dragStateB(IdleB) + , m_draggedLineIndex(-1) + , m_curveC(nullptr) + , m_offsetXC(0.0), m_offsetYC(0.0) + , m_cFinished(false) + , m_cDragging(false) + , m_draggingPoint(false) + , m_draggedPointIndex(-1) { - mPlot->setInteraction(QCP::iRangeDrag, false); - mPlot->setInteraction(QCP::iRangeZoom, true); + if("高导缝" == type) + { + m_type = TYPE_A; + m_lineColor.setNamedColor("#FF0000"); + m_typeName = "高导缝"; + } + else if("高阻缝" == type) + { + m_type = TYPE_A; + m_lineColor.setNamedColor("#400040"); + m_typeName = "高阻缝"; + } + else if("诱导缝" == type) + { + m_type = TYPE_A; + m_lineColor.setNamedColor("#00FFFF"); + m_typeName = "诱导缝"; + } + else if("层理" == type) + { + m_type = TYPE_A; + m_lineColor.setNamedColor("#00FF00"); + m_typeName = "层理"; + } + else if("侵蚀面" == type) + { + m_type = TYPE_A; + m_lineColor.setNamedColor("#409600"); + m_typeName = "侵蚀面"; + } + else if("断层" == type) + { + m_type = TYPE_A; + m_lineColor.setNamedColor("#A65300"); + m_typeName = "断层"; + } + else if("自定义1" == type) + { + m_type = TYPE_A; + m_lineColor.setNamedColor("#000000"); + m_typeName = "自定义1"; + } + else if("自定义2" == type) + { + m_type = TYPE_A; + m_lineColor.setNamedColor("#000000"); + m_typeName = "自定义2"; + } + else if("网状缝" == type) + { + m_type = TYPE_B; + m_lineColor.setNamedColor("#808000"); + m_typeName = "网状缝"; + } + else if("垂直缝" == type) + { + m_type = TYPE_B; + m_lineColor.setNamedColor("#FF0000"); + m_typeName = "垂直缝"; + } + else if("孔洞" == type) + { + m_type = TYPE_C; + m_lineColor.setNamedColor("#FF8064"); + m_typeName = "孔洞"; + } + else if("气孔" == type) + { + m_type = TYPE_C; + m_lineColor.setNamedColor("#FFFF00"); + m_typeName = "气孔"; + } + else if("砾石" == type) + { + m_type = TYPE_C; + m_lineColor.setNamedColor("#000096"); + m_typeName = "砾石"; + } + else if("结核" == type) + { + m_type = TYPE_C; + m_lineColor.setNamedColor("#A65300"); + m_typeName = "结核"; + } + else if("团块" == type) + { + m_type = TYPE_C; + m_lineColor.setNamedColor("#000000"); + m_typeName = "团块"; + } - mCurve = new QCPItemCurve(mPlot); - mCurve->setPen(QPen(Qt::black, 2)); - mCurve->setLayer("overlay"); + // 创建的时候判断是否显示 +// if(showNames.contains("高导缝")) +// { +// m_isShow = true; +// } +// else if(showNames.contains("高阻缝")) +// { +// m_isShow = true; +// } +// else if(showNames.contains("诱导缝")) +// { +// m_isShow = true; +// } +// else if(showNames.contains("层理")) +// { +// m_isShow = true; +// } +// else if(showNames.contains("侵蚀面")) +// { +// m_isShow = true; +// } +// else if("断层" == type) +// { +// m_type = TYPE_A; +// m_lineColor.setNamedColor("#A65300"); +// } +// else if("自定义1" == type) +// { +// m_type = TYPE_A; +// m_lineColor.setNamedColor("#000000"); +// } +// else if("自定义2" == type) +// { +// m_type = TYPE_A; +// m_lineColor.setNamedColor("#000000"); +// } +// else if("网状缝" == type) +// { +// m_type = TYPE_B; +// m_lineColor.setNamedColor("#808000"); +// } +// else if("垂直缝" == type) +// { +// m_type = TYPE_B; +// m_lineColor.setNamedColor("#FF0000"); +// } +// else if("孔洞" == type) +// { +// m_type = TYPE_C; +// m_lineColor.setNamedColor("#FF8064"); +// } +// else if("气孔" == type) +// { +// m_type = TYPE_C; +// m_lineColor.setNamedColor("#FFFF00"); +// } +// else if("砾石" == type) +// { +// m_type = TYPE_C; +// m_lineColor.setNamedColor("#000096"); +// } +// else if("结核" == type) +// { +// m_type = TYPE_C; +// m_lineColor.setNamedColor("#A65300"); +// } +// else if("团块" == type) +// { +// m_type = TYPE_C; +// m_lineColor.setNamedColor("#000000"); +// } - updateCurveFromTargets(); - updateCurvePosition(); - auto createTracer = [this](double x, double y, const QColor &color) -> QCPItemTracer* { - QCPItemTracer *t = new QCPItemTracer(mPlot); - t->setStyle(QCPItemTracer::tsCircle); - t->setSize(12); - t->setPen(QPen(Qt::black, 1)); - t->setBrush(QBrush(color)); - t->setSelectable(true); - t->setLayer("overlay"); - t->position->setCoords(x, y); - return t; - }; - m_tracer1 = createTracer(m_orig_x1, m_orig_y1, Qt::cyan); - m_tracer2 = createTracer(m_orig_x2, m_orig_y2, Qt::cyan); - updateTracers(); + if (m_type == TYPE_A) { + m_orig_x1 = m_endX * 0.18; + m_orig_x2 = m_endX * 0.82; + m_orig_y1 = depth + 1.0; + m_orig_y2 = depth - 1.0; + m_orig_startX = 0; + m_orig_endX = m_endX; + m_orig_startDirX = m_endX * 0.3; + m_orig_endDirX = m_endX * 0.7; + m_offsetXA = 0.0; + m_offsetYA = 0.0; - // 注册到全局列表 - s_allCurves.append(this); + mCurve = new QCPItemCurve(mPlot); + mCurve->setPen(QPen(m_lineColor, 2)); + mCurve->setLayer("overlay"); + + updateCurveFromTargets(); + updateCurvePosition(); + + auto createTracer = [this](double x, double y) -> QCPItemTracer* { + QCPItemTracer *t = new QCPItemTracer(mPlot); + t->setStyle(QCPItemTracer::tsSquare); + t->setSize(8); + t->setPen(QPen(Qt::black, 1)); + t->setBrush(QBrush(Qt::black)); + t->setSelectable(true); + t->setLayer("overlay"); + t->position->setCoords(x, y); + t->setVisible(false); + return t; + }; + m_tracer1 = createTracer(m_orig_x1 + m_offsetXA, m_orig_y1 + m_offsetYA); + m_tracer2 = createTracer(m_orig_x2 + m_offsetXA, m_orig_y2 + m_offsetYA); + m_itemText = new QCPItemText(mPlot); + m_itemText->setText(m_typeName); + m_itemText->setFont(QFont("Arial", 6, QFont::Bold)); + m_itemText->setColor(Qt::black); + m_itemText->position->setCoords(m_orig_x1 + m_offsetXA + 15, m_orig_y1 + m_offsetYA); + m_itemText->setPositionAlignment(Qt::AlignCenter); + m_itemText->setLayer("overlay"); + m_labelsC.append(m_itemText); + updateTracers(); + } + else if (m_type == TYPE_B) { + // nothing + } + else if (m_type == TYPE_C) { + m_curveC = new QCPCurve(mPlot->xAxis, mPlot->yAxis); + m_curveC->setPen(QPen(m_lineColor, 2)); + m_curveC->setScatterStyle(QCPScatterStyle::ssCircle); + m_curveC->setLineStyle(QCPCurve::lsLine); + m_curveC->setLayer("overlay"); + } mPlot->installEventFilter(this); mPlot->replot(); @@ -58,28 +252,47 @@ TransparentDraggableCrackObject::TransparentDraggableCrackObject(QMyCustomPlot * TransparentDraggableCrackObject::~TransparentDraggableCrackObject() { - s_allCurves.removeAll(this); - if (s_activeCurve == this) s_activeCurve = nullptr; + if (m_type == TYPE_B) clearLines(); + if (m_type == TYPE_C) clearPolylineC(); + if (s_activeObject == this) s_activeObject = nullptr; } +void TransparentDraggableCrackObject::isShow(bool is) +{ + this->m_isShow = is; + if(this->mCurve) + { + this->mCurve->setVisible(this->m_isShow); + } + + if(this->m_curveC) + { + this->m_curveC->setVisible(this->m_isShow); + } + + for (const LineItem &item : m_lines) { + if (item.line) { + item.line->setVisible(this->m_isShow); + } + } + this->mPlot->replot(); +} + +// ========== 模式A辅助 ========== void TransparentDraggableCrackObject::updateCurveFromTargets() { double t1 = m_orig_x1 / m_endX; double t2 = m_orig_x2 / m_endX; double u1 = 1 - t1, u2 = 1 - t2; - double P0x = 0, P0y = m_depth; double P3x = m_endX, P3y = m_depth; double P1x = m_orig_x1, P2x = m_orig_x2; - double a11 = 3 * u1 * u1 * t1; double a12 = 3 * u1 * t1 * t1; double b1 = m_orig_y1 - (u1*u1*u1 * P0y + t1*t1*t1 * P3y); - double a21 = 3 * u2 * u2 * t2; double a22 = 3 * u2 * t2 * t2; double b2 = m_orig_y2 - (u2*u2*u2 * P0y + t2*t2*t2 * P3y); - double det = a11 * a22 - a12 * a21; if (fabs(det) > 1e-6) { double P1y = (b1 * a22 - a12 * b2) / det; @@ -93,16 +306,19 @@ void TransparentDraggableCrackObject::updateCurveFromTargets() void TransparentDraggableCrackObject::updateCurvePosition() { - mCurve->start->setCoords(m_orig_startX + m_offsetX, m_depth + m_offsetY); - mCurve->end->setCoords(m_orig_endX + m_offsetX, m_depth + m_offsetY); - mCurve->startDir->setCoords(m_orig_startDirX + m_offsetX, m_orig_startDirY + m_offsetY); - mCurve->endDir->setCoords(m_orig_endDirX + m_offsetX, m_orig_endDirY + m_offsetY); + if (!mCurve) return; + mCurve->start->setCoords(m_orig_startX + m_offsetXA, m_depth + m_offsetYA); + mCurve->end->setCoords(m_orig_endX + m_offsetXA, m_depth + m_offsetYA); + mCurve->startDir->setCoords(m_orig_startDirX + m_offsetXA, m_orig_startDirY + m_offsetYA); + mCurve->endDir->setCoords(m_orig_endDirX + m_offsetXA, m_orig_endDirY + m_offsetYA); } void TransparentDraggableCrackObject::updateTracers() { - m_tracer1->position->setCoords(m_orig_x1 + m_offsetX, m_orig_y1 + m_offsetY); - m_tracer2->position->setCoords(m_orig_x2 + m_offsetX, m_orig_y2 + m_offsetY); + if (!m_tracer1 || !m_tracer2) return; + m_tracer1->position->setCoords(m_orig_x1 + m_offsetXA, m_orig_y1 + m_offsetYA); + m_tracer2->position->setCoords(m_orig_x2 + m_offsetXA, m_orig_y2 + m_offsetYA); + m_itemText->position->setCoords(m_orig_x1 + m_offsetXA + 15, m_orig_y1 + m_offsetYA); } void TransparentDraggableCrackObject::setTracerHighlight(QCPItemTracer *tracer, bool highlight) @@ -113,135 +329,483 @@ void TransparentDraggableCrackObject::setTracerHighlight(QCPItemTracer *tracer, tracer->setBrush(QBrush(Qt::red)); } else { tracer->setPen(QPen(Qt::black, 1)); - tracer->setBrush(QBrush(Qt::cyan)); + tracer->setBrush(QBrush(Qt::black)); + m_tracer1->setVisible(true); + m_tracer2->setVisible(true); } mPlot->replot(); } +// ========== 模式B辅助 ========== +void TransparentDraggableCrackObject::updateLineEndpoints(LineItem &item) +{ + item.startTracer->position->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB); + item.endTracer->position->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB); +} + +void TransparentDraggableCrackObject::updateLinesPosition() +{ + for (auto &item : m_lines) { + item.line->start->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB); + item.line->end->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB); + updateLineEndpoints(item); + } +} + +void TransparentDraggableCrackObject::clearLines() +{ + for (auto &item : m_lines) { + mPlot->removeItem(item.line); + delete item.line; + if (item.startTracer) { mPlot->removeItem(item.startTracer); delete item.startTracer; } + if (item.endTracer) { mPlot->removeItem(item.endTracer); delete item.endTracer; } + } + m_lines.clear(); + m_isAddingLine = false; + mPlot->replot(); +} + +// ========== 模式C辅助 ========== +void TransparentDraggableCrackObject::updatePolylineC(bool closed) +{ + if (!m_curveC) return; + if (m_pointsC.isEmpty()) { + m_curveC->setData(QVector(), QVector()); + return; + } + QVector xs, ys; + for (const auto &p : m_pointsC) { + xs << p.x() + m_offsetXC; + ys << p.y() + m_offsetYC; + } + if (closed && m_pointsC.size() >= 3) { + xs << m_pointsC.first().x() + m_offsetXC; + ys << m_pointsC.first().y() + m_offsetYC; + } + m_curveC->setData(xs, ys); +} + +void TransparentDraggableCrackObject::clearPolylineC() +{ + for (QCPItemText* label : m_labelsC) { + if (label) { + // 断开与 mPlot 的父子关系,防止 mPlot 销毁时自动删除 + label->setParent(nullptr); + delete label; + } + } + m_labelsC.clear(); + m_pointsC.clear(); + if (m_curveC) { + m_curveC->setData(QVector(), QVector()); + } + m_offsetXC = m_offsetYC = 0.0; + m_cFinished = false; + m_draggingPoint = false; + m_draggedPointIndex = -1; + if (s_activeObject == this) s_activeObject = nullptr; + mPlot->replot(); +} + +// ========== 状态重置 ========== +void TransparentDraggableCrackObject::deactivate() +{ + qDebug() << "[Deactivate]" << m_uuid; + if (m_type == TYPE_A) { + setTracerHighlight(m_tracer1, false); + setTracerHighlight(m_tracer2, false); + m_dragStateA = IdleA; + m_tracer1->setVisible(false); + m_tracer2->setVisible(false); + } else if (m_type == TYPE_B) { + m_dragStateB = IdleB; + m_draggedLineIndex = -1; + } else if (m_type == TYPE_C) { + m_cDragging = false; + m_draggingPoint = false; + m_draggedPointIndex = -1; + } + mPlot->replot(); +} + +// ========== 事件过滤器 ========== bool TransparentDraggableCrackObject::eventFilter(QObject *obj, QEvent *event) { if (obj != mPlot) return false; if (event->type() == QEvent::Wheel) return false; QMouseEvent *me = static_cast(event); - switch (event->type()) { - case QEvent::MouseButtonPress: - if (me->button() == Qt::LeftButton) { - QPointF pixel = me->localPos(); - // 找出所有曲线中命中距离最近的那个 - TransparentDraggableCrackObject* bestCurve = nullptr; - double bestDist = 1e9; - int hitType = -1; // 0:point1, 1:point2, 2:curve - for (auto *curve : s_allCurves) { - double d1 = curve->m_tracer1->selectTest(pixel, false); - double d2 = curve->m_tracer2->selectTest(pixel, false); - double dCurve = curve->mCurve->selectTest(pixel, false); - if (d1 >= 0 && d1 < 15 && d1 < bestDist) { - bestDist = d1; - bestCurve = curve; - hitType = 0; - } - if (d2 >= 0 && d2 < 15 && d2 < bestDist) { - bestDist = d2; - bestCurve = curve; - hitType = 1; - } - if (dCurve >= 0 && dCurve < 20 && dCurve < bestDist) { - bestDist = dCurve; - bestCurve = curve; - hitType = 2; - } - } - if (bestCurve) { - // 清除当前活动曲线的高亮 - if (s_activeCurve && s_activeCurve != bestCurve) { - s_activeCurve->setTracerHighlight(s_activeCurve->m_tracer1, false); - s_activeCurve->setTracerHighlight(s_activeCurve->m_tracer2, false); - s_activeCurve->m_dragState = Idle; - } - s_activeCurve = bestCurve; - if (hitType == 0) { - s_activeCurve->m_dragState = DraggingPoint1; - s_activeCurve->setTracerHighlight(s_activeCurve->m_tracer1, true); - } else if (hitType == 1) { - s_activeCurve->m_dragState = DraggingPoint2; - s_activeCurve->setTracerHighlight(s_activeCurve->m_tracer2, true); - } else { - s_activeCurve->m_dragState = DraggingCurve; - s_activeCurve->m_lastDragPixel = pixel; - } + bool shiftPressed = (me->modifiers() & Qt::ShiftModifier); + + // 鼠标按下 + if (event->type() == QEvent::MouseButtonPress && me->button() == Qt::LeftButton) { + bool hit = false; + + // ========== 模式B:添加直线(优先级最高) ========== + if (m_type == TYPE_B && shiftPressed) { + if (!m_isAddingLine) { + double x = mPlot->xAxis->pixelToCoord(me->pos().x()); + double y = mPlot->yAxis->pixelToCoord(me->pos().y()); + m_tempPoint = QPointF(x - m_offsetXB, y - m_offsetYB); + m_isAddingLine = true; + qDebug() << "Start adding line, point:" << m_tempPoint; event->accept(); return true; } else { - // 未命中任何曲线,清除活动曲线 - if (s_activeCurve) { - s_activeCurve->setTracerHighlight(s_activeCurve->m_tracer1, false); - s_activeCurve->setTracerHighlight(s_activeCurve->m_tracer2, false); - s_activeCurve->m_dragState = Idle; - s_activeCurve = nullptr; - mPlot->replot(); + double x = mPlot->xAxis->pixelToCoord(me->pos().x()); + double y = mPlot->yAxis->pixelToCoord(me->pos().y()); + QPointF p2(x - m_offsetXB, y - m_offsetYB); + QCPItemLine *line = new QCPItemLine(mPlot); + line->setPen(QPen(m_lineColor, 2)); + line->setLayer("overlay"); + auto createTracer = [this](double x, double y, const QColor &color) -> QCPItemTracer* { + QCPItemTracer *t = new QCPItemTracer(mPlot); + t->setStyle(QCPItemTracer::tsSquare); + t->setSize(10); + t->setPen(QPen(Qt::black, 1)); + t->setBrush(QBrush(color)); + t->setSelectable(true); + t->setLayer("overlay"); + t->position->setCoords(x + m_offsetXB, y + m_offsetYB); + return t; + }; + QCPItemTracer *startTracer = createTracer(m_tempPoint.x(), m_tempPoint.y(), Qt::black); + QCPItemTracer *endTracer = createTracer(p2.x(), p2.y(), Qt::black); + LineItem item; + item.startOrig = m_tempPoint; + item.endOrig = p2; + item.line = line; + item.startTracer = startTracer; + item.endTracer = endTracer; + m_lines.append(item); + updateLinesPosition(); + m_isAddingLine = false; + mPlot->replot(); + qDebug() << "Line added from" << m_tempPoint << "to" << p2; + event->accept(); + return true; + } + } + + // ========== 模式A ========== + if (m_type == TYPE_A && !shiftPressed) { + QPointF pixel = me->localPos(); + double d1 = m_tracer1->selectTest(pixel, false); + double d2 = m_tracer2->selectTest(pixel, false); + double curveDist = mCurve->selectTest(pixel, false); + if (d1 >= 0 && d1 < 15 || d2 >= 0 && d2 < 15 || (curveDist >= 0 && curveDist < 5)) { + hit = true; + if (s_activeObject && s_activeObject != this) { + s_activeObject->deactivate(); } - return false; + s_activeObject = this; + if (d1 >= 0 && d1 < 15) { + m_dragStateA = DraggingPoint1; + setTracerHighlight(m_tracer1, true); + } else if (d2 >= 0 && d2 < 15) { + m_dragStateA = DraggingPoint2; + setTracerHighlight(m_tracer2, true); + } else { + m_dragStateA = DraggingCurveA; + m_lastDragPixelA = pixel; + } + event->accept(); + return true; } } - break; - case QEvent::MouseMove: - if (s_activeCurve != this) return false; - if (m_dragState == DraggingPoint1 || m_dragState == DraggingPoint2) { - double newY = mPlot->yAxis->pixelToCoord(me->localPos().y()); - double currentAbsY1 = m_orig_y1 + m_offsetY; - double deltaY = newY - currentAbsY1; - if (m_dragState == DraggingPoint1) { - m_orig_y1 += deltaY; - m_orig_y2 -= deltaY; - } else { - m_orig_y2 += deltaY; - m_orig_y1 -= deltaY; + // ========== 模式B:拖拽(非Shift) ========== + if (m_type == TYPE_B && !shiftPressed && !m_isAddingLine) { + QPointF pixel = me->localPos(); + bool found = false; + for (int i = 0; i < m_lines.size(); ++i) { + auto &item = m_lines[i]; + if (item.startTracer->selectTest(pixel, false) >= 0 && item.startTracer->selectTest(pixel, false) < 10) { + found = true; + hit = true; + if (s_activeObject && s_activeObject != this) s_activeObject->deactivate(); + s_activeObject = this; + m_dragStateB = DraggingStartPoint; + m_draggedLineIndex = i; + m_bDragStart = pixel; + event->accept(); + return true; + } + if (item.endTracer->selectTest(pixel, false) >= 0 && item.endTracer->selectTest(pixel, false) < 10) { + found = true; + hit = true; + if (s_activeObject && s_activeObject != this) s_activeObject->deactivate(); + s_activeObject = this; + m_dragStateB = DraggingEndPoint; + m_draggedLineIndex = i; + m_bDragStart = pixel; + event->accept(); + return true; + } + } + if (!found) { + for (int i = 0; i < m_lines.size(); ++i) { + double dist = m_lines[i].line->selectTest(pixel, false); + if (dist >= 0 && dist < 3) { + hit = true; + if (s_activeObject && s_activeObject != this) s_activeObject->deactivate(); + s_activeObject = this; + m_dragStateB = DraggingLineOverall; + m_bDragStart = pixel; + event->accept(); + return true; + } + } + } + } + + // ========== 模式C ========== + if (m_type == TYPE_C) { + // 1. 左键添加点(Shift) + if (shiftPressed && me->button() == Qt::LeftButton && !m_cFinished) { + if (s_activeObject != this) { + if (s_activeObject) s_activeObject->deactivate(); + s_activeObject = this; + } + double x = mPlot->xAxis->pixelToCoord(me->pos().x()); + double y = mPlot->yAxis->pixelToCoord(me->pos().y()); + QPointF pt(x - m_offsetXC, y - m_offsetYC); + m_pointsC.append(pt); + QCPItemText *label = new QCPItemText(mPlot); + label->setText(" "); + label->setFont(QFont("Arial", 6, QFont::Bold)); + label->setColor(Qt::black); + label->setBrush(QBrush(Qt::black)); + label->setPen(QPen(Qt::black, 1)); + label->position->setCoords(x, y); + label->setPositionAlignment(Qt::AlignCenter); + label->setLayer("overlay"); + m_labelsC.append(label); + updatePolylineC(false); + mPlot->replot(); + event->accept(); + return true; + } + // 2. 左键空白闭环(非Shift,未完成时) + if (!shiftPressed && me->button() == Qt::LeftButton && !m_cFinished) { + if (m_pointsC.size() >= 3) { + m_cFinished = true; + updatePolylineC(true); + mPlot->replot(); + } else { + clearPolylineC(); + } + if (s_activeObject == this) { + s_activeObject->deactivate(); + s_activeObject = nullptr; + } + event->accept(); + return true; + } + // 3. 拖拽整体或点(已完成,非Shift左键) + if (!shiftPressed && me->button() == Qt::LeftButton && m_cFinished) { + QPointF pixel = me->localPos(); + // 优先检测是否命中某个数据点(通过标签) + int hitPointIndex = -1; + for (int i = 0; i < m_labelsC.size(); ++i) { + double dist = m_labelsC[i]->selectTest(pixel, false); + if (dist >= 0 && dist < 10) { + hitPointIndex = i; + break; + } + } + if (hitPointIndex >= 0) { + hit = true; + if (s_activeObject != this) { + if (s_activeObject) s_activeObject->deactivate(); + s_activeObject = this; + } + m_draggingPoint = true; + m_draggedPointIndex = hitPointIndex; + // 记录拖拽开始时的鼠标像素坐标和点的原始坐标(用于计算偏移) + m_cDragStart = pixel; + event->accept(); + return true; + } else { + // 未命中点,检测曲线本体 + double curveDist = m_curveC ? m_curveC->selectTest(pixel, false) : -1; + if (curveDist >= 0 && curveDist < 3) { + hit = true; + if (s_activeObject != this) { + if (s_activeObject) s_activeObject->deactivate(); + s_activeObject = this; + } + m_cDragging = true; + m_cDragStart = pixel; + event->accept(); + return true; + } else { + // 未命中任何图元,清除活动对象 + if (s_activeObject == this) { + s_activeObject->deactivate(); + s_activeObject = nullptr; + } + return false; + } + } + } + } + + // 未命中任何图元:清除全局活动对象 + if (!hit) { + if (s_activeObject) { + s_activeObject->deactivate(); + s_activeObject = nullptr; + } + return false; + } + return false; + } + + // 鼠标移动 + if (event->type() == QEvent::MouseMove) { + if (s_activeObject != this) return false; + + // 模式A移动 + if (m_type == TYPE_A) { + if (m_dragStateA == DraggingPoint1 || m_dragStateA == DraggingPoint2) { + double newY = mPlot->yAxis->pixelToCoord(me->localPos().y()); + double currentY = (m_dragStateA == DraggingPoint1) ? m_orig_y1 : m_orig_y2; + double deltaY = newY - (currentY + m_offsetYA); + if (fabs(deltaY) > 5) deltaY = (deltaY > 0 ? 5 : -5); + double newOrigY = currentY + deltaY; + double minY = m_depth - 100; + double maxY = m_depth + 100; + newOrigY = qBound(minY, newOrigY, maxY); + if (m_dragStateA == DraggingPoint1) m_orig_y1 = newOrigY; + else m_orig_y2 = newOrigY; + updateCurveFromTargets(); + updateCurvePosition(); + updateTracers(); + mPlot->replot(); + return true; + } else if (m_dragStateA == DraggingCurveA) { + QPointF current = me->localPos(); + double oldX = mPlot->xAxis->pixelToCoord(m_lastDragPixelA.x()); + double newX = mPlot->xAxis->pixelToCoord(current.x()); + double oldY = mPlot->yAxis->pixelToCoord(m_lastDragPixelA.y()); + double newY = mPlot->yAxis->pixelToCoord(current.y()); + double dx = newX - oldX; + double dy = newY - oldY; + m_offsetXA += dx; + m_offsetYA += dy; + updateCurvePosition(); + updateTracers(); + mPlot->replot(); + m_lastDragPixelA = current; + return true; + } + } + // 模式B移动 + else if (m_type == TYPE_B && m_dragStateB != IdleB) { + QPointF current = me->localPos(); + double oldX = mPlot->xAxis->pixelToCoord(m_bDragStart.x()); + double newX = mPlot->xAxis->pixelToCoord(current.x()); + double oldY = mPlot->yAxis->pixelToCoord(m_bDragStart.y()); + double newY = mPlot->yAxis->pixelToCoord(current.y()); + double dx = newX - oldX; + double dy = newY - oldY; + if (m_dragStateB == DraggingLineOverall) { + m_offsetXB += dx; + m_offsetYB += dy; + updateLinesPosition(); + } else if (m_dragStateB == DraggingStartPoint || m_dragStateB == DraggingEndPoint) { + int idx = m_draggedLineIndex; + if (idx >= 0 && idx < m_lines.size()) { + LineItem &item = m_lines[idx]; + if (m_dragStateB == DraggingStartPoint) { + item.startOrig.rx() += dx; + item.startOrig.ry() += dy; + } else { + item.endOrig.rx() += dx; + item.endOrig.ry() += dy; + } + item.line->start->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB); + item.line->end->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB); + updateLineEndpoints(item); + } } - updateCurveFromTargets(); - updateCurvePosition(); - updateTracers(); mPlot->replot(); - event->accept(); - return true; - } else if (m_dragState == DraggingCurve) { - QPointF currentPixel = me->localPos(); - double oldX = mPlot->xAxis->pixelToCoord(m_lastDragPixel.x()); - double newX = mPlot->xAxis->pixelToCoord(currentPixel.x()); - double oldY = mPlot->yAxis->pixelToCoord(m_lastDragPixel.y()); - double newY = mPlot->yAxis->pixelToCoord(currentPixel.y()); - - double deltaX = newX - oldX; - double deltaY = newY - oldY; - - if (fabs(deltaX) > 1e-6) m_offsetX += deltaX; - if (fabs(deltaY) > 1e-6) m_offsetY += deltaY; - - updateCurvePosition(); - updateTracers(); - mPlot->replot(); - - m_lastDragPixel = currentPixel; - event->accept(); + m_bDragStart = current; return true; } - break; + // 模式C移动 + // 模式C移动 + else if (m_type == TYPE_C) { + if (m_cDragging) { + // 整体拖拽 + QPointF current = me->localPos(); + double oldX = mPlot->xAxis->pixelToCoord(m_cDragStart.x()); + double newX = mPlot->xAxis->pixelToCoord(current.x()); + double oldY = mPlot->yAxis->pixelToCoord(m_cDragStart.y()); + double newY = mPlot->yAxis->pixelToCoord(current.y()); + double dx = newX - oldX; + double dy = newY - oldY; + m_offsetXC += dx; + m_offsetYC += dy; + for (int i = 0; i < m_pointsC.size(); ++i) { + m_labelsC[i]->position->setCoords(m_pointsC[i].x() + m_offsetXC, m_pointsC[i].y() + m_offsetYC); + } + updatePolylineC(m_cFinished && m_pointsC.size() >= 3); + mPlot->replot(); + m_cDragStart = current; + return true; + } else if (m_draggingPoint) { + // 点拖拽:支持二维移动 + QPointF current = me->localPos(); + // 计算鼠标在轴坐标系下的移动量(直接使用像素转坐标,但为了精确,计算差值) + double oldX = mPlot->xAxis->pixelToCoord(m_cDragStart.x()); + double newX = mPlot->xAxis->pixelToCoord(current.x()); + double oldY = mPlot->yAxis->pixelToCoord(m_cDragStart.y()); + double newY = mPlot->yAxis->pixelToCoord(current.y()); + double dx = newX - oldX; + double dy = newY - oldY; + // 更新点的原始坐标 + m_pointsC[m_draggedPointIndex].rx() += dx; + m_pointsC[m_draggedPointIndex].ry() += dy; + // 更新标签位置 + m_labelsC[m_draggedPointIndex]->position->setCoords(m_pointsC[m_draggedPointIndex].x() + m_offsetXC, + m_pointsC[m_draggedPointIndex].y() + m_offsetYC); + updatePolylineC(m_cFinished && m_pointsC.size() >= 3); + mPlot->replot(); + // 更新拖拽起始点 + m_cDragStart = current; + return true; + } + } - case QEvent::MouseButtonRelease: - if (me->button() == Qt::LeftButton && s_activeCurve == this) { + return false; + } + + // 鼠标释放 + if (event->type() == QEvent::MouseButtonRelease && me->button() == Qt::LeftButton) { + if (s_activeObject != this) return false; + + if (m_type == TYPE_A && m_dragStateA != IdleA) { setTracerHighlight(m_tracer1, false); setTracerHighlight(m_tracer2, false); - m_dragState = Idle; - s_activeCurve = nullptr; - mPlot->replot(); - event->accept(); + m_dragStateA = IdleA; return true; + } else if (m_type == TYPE_B && m_dragStateB != IdleB) { + m_dragStateB = IdleB; + m_draggedLineIndex = -1; + return true; + } else if (m_type == TYPE_C) { + if (m_cDragging) { + m_cDragging = false; + return true; + } else if (m_draggingPoint) { + m_draggingPoint = false; + m_draggedPointIndex = -1; + return true; + } } - break; - - default: - break; } + return false; } diff --git a/logPlus/TransparentDraggableCrackObject.h b/logPlus/TransparentDraggableCrackObject.h index e2e649b..571ff34 100644 --- a/logPlus/TransparentDraggableCrackObject.h +++ b/logPlus/TransparentDraggableCrackObject.h @@ -1,51 +1,91 @@ -#ifndef TRANSPARENTDRAGGABLECRACKOBJECT_H +#ifndef TRANSPARENTDRAGGABLECRACKOBJECT_H #define TRANSPARENTDRAGGABLECRACKOBJECT_H #include -#include "qmycustomplot.h" -#include +#include +#include +#include "qcustomplot.h" + +#pragma execution_character_set("utf-8") class TransparentDraggableCrackObject : public QObject { Q_OBJECT public: - explicit TransparentDraggableCrackObject(QMyCustomPlot *parentPlot, - const QString &strUuid = "", - double depth = 0); + enum CurveType { TYPE_A, TYPE_B, TYPE_C }; + + explicit TransparentDraggableCrackObject(QCustomPlot *parentPlot, + const QString &strUuid, double depth, QString type, QString showNames); ~TransparentDraggableCrackObject(); + bool m_isShow = false; + QString m_typeName; + void isShow(bool is); protected: bool eventFilter(QObject *obj, QEvent *event) override; private: - static QList s_allCurves; // 所有曲线实例 - static TransparentDraggableCrackObject* s_activeCurve; // 当前活动曲线 - - QMyCustomPlot *mPlot; - QCPItemCurve *mCurve; + QCustomPlot *mPlot; + CurveType m_type; + QString m_uuid; double m_depth; double m_endX; + QColor m_lineColor; + static QPointer s_activeObject; + + QCPItemText *m_itemText; + // 模式A + QCPItemCurve *mCurve; double m_orig_x1, m_orig_x2; double m_orig_y1, m_orig_y2; double m_orig_startX, m_orig_endX; double m_orig_startDirX, m_orig_startDirY; double m_orig_endDirX, m_orig_endDirY; + double m_offsetXA, m_offsetYA; + QCPItemTracer *m_tracer1, *m_tracer2; + enum DragStateA { IdleA, DraggingPoint1, DraggingPoint2, DraggingCurveA }; + DragStateA m_dragStateA; + QPointF m_lastDragPixelA; - double m_offsetX; - double m_offsetY; + // 模式B + struct LineItem { + QPointF startOrig; + QPointF endOrig; + QCPItemLine *line; + QCPItemTracer *startTracer; + QCPItemTracer *endTracer; + }; + QVector m_lines; + bool m_isAddingLine; + QPointF m_tempPoint; + double m_offsetXB, m_offsetYB; + enum DragStateB { IdleB, DraggingLineOverall, DraggingStartPoint, DraggingEndPoint }; + DragStateB m_dragStateB; + QPointF m_bDragStart; + int m_draggedLineIndex; - QCPItemTracer *m_tracer1; - QCPItemTracer *m_tracer2; - - enum DragState { Idle, DraggingPoint1, DraggingPoint2, DraggingCurve }; - DragState m_dragState = Idle; - QPointF m_lastDragPixel; + // 模式C + QCPCurve *m_curveC; + QVector m_pointsC; // 原始点(无偏移) + QVector m_labelsC; // 序号标签 + double m_offsetXC, m_offsetYC; // 整体偏移 + bool m_cFinished; // 是否已完成选点 + bool m_cDragging; // 是否正在拖拽整体 + bool m_draggingPoint; // 是否正在拖拽点 + int m_draggedPointIndex; // 拖拽的点的索引 + QPointF m_cDragStart; // 拖拽起始像素 void updateCurveFromTargets(); void updateCurvePosition(); void updateTracers(); void setTracerHighlight(QCPItemTracer *tracer, bool highlight); + void updateLinesPosition(); + void clearLines(); + void updateLineEndpoints(LineItem &item); + void updatePolylineC(bool closed); + void clearPolylineC(); + void deactivate(); }; #endif diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 0958b29..424ad80 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -181,6 +181,10 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel // 深度属性修改 connect(CallManage::getInstance(), SIGNAL(sig_changeDepthProperty(QVariantList)), this, SLOT(s_changeDepthProperty(QVariantList))); + + // 频率统计图属性修改 + connect(CallManage::getInstance(), SIGNAL(sig_changeCrackProperty(QVariantMap)), this, SLOT(s_changeCrackProperty(QVariantMap))); + // 频率统计图属性修改 connect(CallManage::getInstance(), SIGNAL(sig_changePlObjectProperty(QVariantMap)), this, SLOT(s_changePlObjectProperty(QVariantMap))); @@ -2031,16 +2035,16 @@ void QMyCustomPlot::addCorePhysicsWithParam(int Order, double Depth, double Corr { QtCommonClass *qtCommon = new QtCommonClass(this); QString strUuid = qtCommon->getUUid(); -// TransparentDraggableCorePhysics *dragRect = new TransparentDraggableCorePhysics(this, strUuid); -// dragRect->setCpDepth(Depth); -// dragRect->setCpCoreValue(CoreValue); -// dragRect->setCpCorrDepth(CorrDepth); -// dragRect->setRange(CorrDepth, CorrDepth, CoreValue); -// dragRect->setCpLineColor(Qt::black); -// dragRect->setCpLineWidth(1); -// dragRect->setCpOrder(Order); -// dragRect->update(); -// m_mapDraggable_CorePhysics[strUuid] = dragRect; + TransparentDraggableCorePhysics *dragRect = new TransparentDraggableCorePhysics(this, strUuid); + dragRect->setCpDepth(Depth); + dragRect->setCpCoreValue(CoreValue); + dragRect->setCpCorrDepth(CorrDepth); + dragRect->setRange(CorrDepth, CorrDepth, CoreValue); + dragRect->setCpLineColor(Qt::black); + dragRect->setCpLineWidth(1); + dragRect->setCpOrder(Order); + dragRect->update(); + m_mapDraggable_CorePhysics[strUuid] = dragRect; } void QMyCustomPlot::addCrackObject() @@ -2115,26 +2119,15 @@ void QMyCustomPlot::addCrackObject() if(dlg.exec() == QDialog::Accepted) { // 获取用户输入 - double depth = editDepth->text().toDouble(); - QString type = cbbType->currentText(); - - QtCommonClass *qtCommon = new QtCommonClass(this); QString strUuid = qtCommon->getUUid(); - TransparentDraggableCrackObject *t = new TransparentDraggableCrackObject(this, strUuid, -depth); - - m_mapDraggable_CrackObject[strUuid] = t; - - - -// TransparentDraggableCorePhysics *dragRect = new TransparentDraggableCorePhysics(this, strUuid); -// dragRect->setRange(depth, depth, 50); -// dragRect->setCpLineColor(Qt::black); -// dragRect->setCpLineWidth(1); -// m_mapDraggable_CorePhysics[strUuid] = dragRect; - + double depth = editDepth->text().toDouble(); + QString type = cbbType->currentText(); + QString showNames = ""; + auto curve = new TransparentDraggableCrackObject(this, strUuid, -depth, type, showNames); + m_mapDraggable_CrackObject[strUuid] = curve; // ========= 这里就是你要的结果!========= - qDebug() << "深度:" << depth << " 类型:" << type; +// qDebug() << "深度:" << depth << " 类型:" << type; } } @@ -10317,6 +10310,99 @@ void QMyCustomPlot::resetPosition() replot(); } +void QMyCustomPlot::s_changeCrackProperty(QVariantMap variantMap) +{ + QString strTrackName = variantMap["m_strTrackName"].toString(); + if(this->m_strTrackName != strTrackName) + { + return; + } + + bool m_pl_highGap = variantMap["m_pl_highGap"].toBool(); // 高导缝 + bool m_pl_highReservoir = variantMap["m_pl_highReservoir"].toBool(); // 高阻缝 + bool m_pl_reticularFracture = variantMap["m_pl_reticularFracture"].toBool(); // 网状缝 + bool m_pl_inducedFracture = variantMap["m_pl_inducedFracture"].toBool(); // 诱导缝 + bool m_pl_bedLayer = variantMap["m_pl_bedLayer"].toBool(); // 层理 + bool m_pl_erosionSurface = variantMap["m_pl_erosionSurface"].toBool(); // 侵蚀面 + bool m_pl_pore = variantMap["m_pl_pore"].toBool(); // 孔洞 + bool m_pl_vesicle = variantMap["m_pl_vesicle"].toBool(); // 气孔 + bool m_pl_gravel = variantMap["m_pl_gravel"].toBool(); // 砾石 + bool m_pl_nodule = variantMap["m_pl_nodule"].toBool(); // 结核 + bool m_pl_lumps = variantMap["m_pl_lumps"].toBool(); // 团块 + bool m_pl_fault = variantMap["m_pl_fault"].toBool(); // 断层 + bool m_pl_verticalFracture = variantMap["m_pl_verticalFracture"].toBool(); // 垂直缝 + bool m_pl_custom1 = variantMap["m_pl_custom1"].toBool(); // 自定义1 + bool m_pl_custom2 = variantMap["m_pl_custom2"].toBool(); // 自定义2 + + TransparentDraggableCrackObject *pDraggableRect = NULL; + QMap::Iterator it = m_mapDraggable_CrackObject.begin(); + while( it != m_mapDraggable_CrackObject.end() ) + { + pDraggableRect = (TransparentDraggableCrackObject*)it.value(); + if("高导缝" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_highGap); + } + else if("高阻缝" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_highReservoir); + } + else if("诱导缝" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_inducedFracture); + } + else if("层理" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_bedLayer); + } + else if("侵蚀面" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_erosionSurface); + } + else if("断层" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_fault); + } + else if("自定义1" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_custom1); + } + else if("自定义2" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_custom2); + } + else if("网状缝" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_reticularFracture); + } + else if("垂直缝" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_verticalFracture); + } + else if("孔洞" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_pore); + } + else if("气孔" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_vesicle); + } + else if("砾石" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_gravel); + } + else if("结核" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_nodule); + } + else if("团块" == pDraggableRect->m_typeName) + { + pDraggableRect->isShow(m_pl_lumps); + } + it++; + } +} + void QMyCustomPlot::s_changePlObjectProperty(QVariantMap variantMap) { QString strTrackName = variantMap["m_strTrackName"].toString(); diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index aa55d1f..88a8461 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -593,6 +593,9 @@ public slots: // 深度 void s_changeDepthProperty(QVariantList vlist); + // 裂缝 + void s_changeCrackProperty(QVariantMap variantMap); + // 频率统计图 void s_changePlObjectProperty(QVariantMap variantMap);