diff --git a/logPlus/TransparentDraggableCorePhysics.h b/logPlus/TransparentDraggableCorePhysics.h index 1073482..5387a06 100644 --- a/logPlus/TransparentDraggableCorePhysics.h +++ b/logPlus/TransparentDraggableCorePhysics.h @@ -48,12 +48,6 @@ public: double getCpCoreValue() const; void setCpCoreValue(double value); -// double getCpRotationAngle() const; -// void setCpRotationAngle(double value); - -// QString getCpDisplayName() const; -// void setCpDisplayName(const QString &value); - int getCpLineWidth() const; void setCpLineWidth(int value); @@ -72,9 +66,6 @@ public: int getCpScaleType() const; void setCpScaleType(int value); -// int getCpScaleDivisionsOrCustom() const; -// void setCpScaleDivisionsOrCustom(int value); - QString getCpDisplayUnit() const; void setCpDisplayUnit(const QString &value); @@ -113,23 +104,16 @@ public: QColor getCpSymbolFillColor() const; void setCpSymbolFillColor(QColor value); - -// int getCpFieldName() const; -// void setCpFieldName(const int &value); - signals: void rangeChanged(QCPRange newRange); private: -// double m_cp_rotationAngle; // 旋转角度 -// QString m_cp_displayName; // 显示名称 int m_cp_lineWidth; // 线宽 QColor m_cp_lineColor; // 线条颜色 Qt::PenStyle m_cp_lineStyle; // 线型 double m_cp_leftScale = 0; // 左刻度 double m_cp_rightScale = 100; // 右刻度 int m_cp_scaleType = 0; // 刻度类型 -// int m_cp_scaleDivisionsOrCustom; // 等分刻度数或自定序列 QString m_cp_displayUnit; // 显示单位 QString m_cp_curveName; // 曲线名称 QString m_cp_curveUnit; // 曲线单位 @@ -143,7 +127,6 @@ private: QColor m_cp_symbolBorderColor; // 边框颜色 int m_cp_symbolSize; // 大小 QColor m_cp_symbolFillColor; // 填充颜色 -// int m_cp_fieldName; // 字段名称 // 这四个是slf文件保存读取的 int m_cp_order; // 序号 double m_cp_depth; // 深度 diff --git a/logPlus/TransparentDraggableCrackObject.cpp b/logPlus/TransparentDraggableCrackObject.cpp new file mode 100644 index 0000000..09eb165 --- /dev/null +++ b/logPlus/TransparentDraggableCrackObject.cpp @@ -0,0 +1,247 @@ +#include "TransparentDraggableCrackObject.h" +#include +#include +#include + +QList TransparentDraggableCrackObject::s_allCurves; +TransparentDraggableCrackObject* TransparentDraggableCrackObject::s_activeCurve = nullptr; + +TransparentDraggableCrackObject::TransparentDraggableCrackObject(QMyCustomPlot *parentPlot, + const QString &strUuid, + double depth) + : QObject(parentPlot) + , mPlot(parentPlot) + , 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) +{ + mPlot->setInteraction(QCP::iRangeDrag, false); + mPlot->setInteraction(QCP::iRangeZoom, true); + + mCurve = new QCPItemCurve(mPlot); + mCurve->setPen(QPen(Qt::black, 2)); + mCurve->setLayer("overlay"); + + 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(); + + // 注册到全局列表 + s_allCurves.append(this); + + mPlot->installEventFilter(this); + mPlot->replot(); +} + +TransparentDraggableCrackObject::~TransparentDraggableCrackObject() +{ + s_allCurves.removeAll(this); + if (s_activeCurve == this) s_activeCurve = nullptr; +} + +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; + double P2y = (a11 * b2 - b1 * a21) / det; + m_orig_startDirX = P1x; + m_orig_startDirY = P1y; + m_orig_endDirX = P2x; + m_orig_endDirY = P2y; + } +} + +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); +} + +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); +} + +void TransparentDraggableCrackObject::setTracerHighlight(QCPItemTracer *tracer, bool highlight) +{ + if (!tracer) return; + if (highlight) { + tracer->setPen(QPen(Qt::red, 2)); + tracer->setBrush(QBrush(Qt::red)); + } else { + tracer->setPen(QPen(Qt::black, 1)); + tracer->setBrush(QBrush(Qt::cyan)); + } + 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; + } + 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(); + } + return false; + } + } + 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; + } + 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(); + return true; + } + break; + + case QEvent::MouseButtonRelease: + if (me->button() == Qt::LeftButton && s_activeCurve == this) { + setTracerHighlight(m_tracer1, false); + setTracerHighlight(m_tracer2, false); + m_dragState = Idle; + s_activeCurve = nullptr; + mPlot->replot(); + event->accept(); + return true; + } + break; + + default: + break; + } + return false; +} diff --git a/logPlus/TransparentDraggableCrackObject.h b/logPlus/TransparentDraggableCrackObject.h new file mode 100644 index 0000000..e2e649b --- /dev/null +++ b/logPlus/TransparentDraggableCrackObject.h @@ -0,0 +1,51 @@ +#ifndef TRANSPARENTDRAGGABLECRACKOBJECT_H +#define TRANSPARENTDRAGGABLECRACKOBJECT_H + +#include +#include "qmycustomplot.h" +#include + +class TransparentDraggableCrackObject : public QObject +{ + Q_OBJECT +public: + explicit TransparentDraggableCrackObject(QMyCustomPlot *parentPlot, + const QString &strUuid = "", + double depth = 0); + ~TransparentDraggableCrackObject(); + +protected: + bool eventFilter(QObject *obj, QEvent *event) override; + +private: + static QList s_allCurves; // 所有曲线实例 + static TransparentDraggableCrackObject* s_activeCurve; // 当前活动曲线 + + QMyCustomPlot *mPlot; + QCPItemCurve *mCurve; + double m_depth; + double m_endX; + + 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_offsetX; + double m_offsetY; + + QCPItemTracer *m_tracer1; + QCPItemTracer *m_tracer2; + + enum DragState { Idle, DraggingPoint1, DraggingPoint2, DraggingCurve }; + DragState m_dragState = Idle; + QPointF m_lastDragPixel; + + void updateCurveFromTargets(); + void updateCurvePosition(); + void updateTracers(); + void setTracerHighlight(QCPItemTracer *tracer, bool highlight); +}; + +#endif diff --git a/logPlus/logPlus.pro b/logPlus/logPlus.pro index cd57fde..c5114de 100644 --- a/logPlus/logPlus.pro +++ b/logPlus/logPlus.pro @@ -44,6 +44,7 @@ SOURCES += \ QCPSizeHandle.cpp \ QCPSizeHandleManager.cpp \ TransparentDraggableCorePhysics.cpp \ + TransparentDraggableCrackObject.cpp \ TransparentDraggableFac.cpp \ TransparentDraggableGeoLith.cpp \ TransparentDraggableGujing.cpp \ @@ -110,6 +111,7 @@ HEADERS += \ QCPSizeHandle.h \ QCPSizeHandleManager.h \ TransparentDraggableCorePhysics.h \ + TransparentDraggableCrackObject.h \ TransparentDraggableFac.h \ TransparentDraggableGeoLith.h \ TransparentDraggableGujing.h \ diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index b6a396d..b7aa944 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -18,6 +18,7 @@ #include "transparentdraggableLayer.h" #include "transparentdraggableRightList.h" #include "TransparentDraggableCorePhysics.h" +#include "TransparentDraggableCrackObject.h" #include "qtcommonclass.h" #include "slf.h" #include "MemRdWt.h" @@ -35,7 +36,7 @@ extern QString g_SelectMFac; QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) : QCustomPlot(parent) -{ +{ m_strSlfName = strSlfName; m_strWellName = strWellName; m_strTrackName = strTrackName; @@ -46,13 +47,13 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel setObjectName("QMyCustomPlot"); //this->setOpenGl(true);//不开启,电脑不支持会卡 // this->setNotAntialiasedElements(QCP::aeAll); // 关闭所有抗锯齿 - m_newColor = Qt::black; + m_newColor = Qt::black; // 开启抗锯齿 this->setAntialiasedElement(QCP::aeAll); - //背景设置成透明色 - this->setBackground(Qt::transparent); - this->setStyleSheet("background: transparent;"); + //背景设置成透明色 + this->setBackground(Qt::transparent); + this->setStyleSheet("background: transparent;"); //jyl if(g_iShow==1) @@ -65,21 +66,21 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel yAxis->setTickLabels(false); } // - xAxis->setTicks(false); - yAxis->setTicks(false); - xAxis2->setTicks(false); - yAxis2->setTicks(false); - xAxis->setTickLabels(false); - yAxis->setTickLabels(false); - xAxis2->setTickLabels(false); - xAxis2->setTickLabels(false); - xAxis->setVisible(false); - xAxis2->setVisible(false); - yAxis->setVisible(false); - yAxis2->setVisible(false); + xAxis->setTicks(false); + yAxis->setTicks(false); + xAxis2->setTicks(false); + yAxis2->setTicks(false); + xAxis->setTickLabels(false); + yAxis->setTickLabels(false); + xAxis2->setTickLabels(false); + xAxis2->setTickLabels(false); + xAxis->setVisible(false); + xAxis2->setVisible(false); + yAxis->setVisible(false); + yAxis2->setVisible(false); - xAxis->grid()->setVisible(false); - yAxis->grid()->setVisible(false); + xAxis->grid()->setVisible(false); + yAxis->grid()->setVisible(false); //套管组件 zoneOrder_Tubing.clear(); @@ -88,7 +89,7 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel zoneOrder_Tubing=GetZoneOrder(QString("TubTools.ini")); } - connect(this->selectionRect(), &QCPSelectionRect::accepted, this, &QMyCustomPlot::slotSelectionRectAccepted); + connect(this->selectionRect(), &QCPSelectionRect::accepted, this, &QMyCustomPlot::slotSelectionRectAccepted); // make bottom and left axes transfer their ranges to top and right axes: connect(xAxis, SIGNAL(rangeChanged(QCPRange)), xAxis2, SLOT(setRange(QCPRange))); connect(yAxis, SIGNAL(rangeChanged(QCPRange)), yAxis2, SLOT(setRange(QCPRange))); @@ -160,8 +161,8 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel // 玫瑰图属性修改 connect(CallManage::getInstance(), SIGNAL(sig_changeRoseProperty(QVariantMap)), this, SLOT(s_changeRoseProperty(QVariantMap))); - - connect(CallManage::getInstance(), SIGNAL(sig_changeDrawProperty(QVariantList)), this, SLOT(s_changeDrawProperty(QVariantList))); + + connect(CallManage::getInstance(), SIGNAL(sig_changeDrawProperty(QVariantList)), this, SLOT(s_changeDrawProperty(QVariantList))); // 岩心分析 connect(CallManage::getInstance(), SIGNAL(sig_changeCorePhysicsProperty(QVariantMap)), this, SLOT(s_changeCorePhysicsProperty(QVariantMap))); @@ -185,552 +186,552 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel void QMyCustomPlot::initGeometry(QString strUuid, int nscale, int nW) { - this->m_strUuid = strUuid; + this->m_strUuid = strUuid; - double dHight = (m_iY2 - m_iY1)*100.0 / (double)nscale * g_dPixelPerCm; - if (g_iShow == 1) - { - //显示刻度 - dHight = dHight + 30; - } + double dHight = (m_iY2 - m_iY1)*100.0 / (double)nscale * g_dPixelPerCm; + if (g_iShow == 1) + { + //显示刻度 + dHight = dHight + 30; + } - qDebug() << "FormDraw dHight=" << QString::number((int)dHight); - if (dHight > 32767) - { - dHight = 32767; - } + qDebug() << "FormDraw dHight=" << QString::number((int)dHight); + if (dHight > 32767) + { + dHight = 32767; + } - //curv->setMaximumHeight((int)dHight); - //curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184 - this->setGeometry(0, 0, nW, (int)dHight);//7500-3184 + //curv->setMaximumHeight((int)dHight); + //curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184 + this->setGeometry(0, 0, nW, (int)dHight);//7500-3184 } void QMyCustomPlot::changePropertyWaveUpdate() { - if (m_nDrawType == 0 || m_nDrawType == 1) - { - if (this->m_colorMap) - this->m_colorMap->setVisible(false); + if (m_nDrawType == 0 || m_nDrawType == 1) + { + if (this->m_colorMap) + this->m_colorMap->setVisible(false); - clearGraphs(); - clearItems(); + clearGraphs(); + clearItems(); - if (this->m_colorMap && this->m_bX2Y) - { - QCPAxis *yAxis = this->yAxis; - QCPAxis *xAxis = this->xAxis; - this->xAxis = yAxis; - this->yAxis = xAxis; - this->m_bX2Y = false; - } - this->initWave2(m_strSlfName, m_strLineName); - } - else if (m_nDrawType == 2) - { - if (this->m_colorMap) - { - this->m_colorMap->setVisible(true); - this->m_colorMap->data()->clear(); - } - clearGraphs(); - clearItems(); + if (this->m_colorMap && this->m_bX2Y) + { + QCPAxis *yAxis = this->yAxis; + QCPAxis *xAxis = this->xAxis; + this->xAxis = yAxis; + this->yAxis = xAxis; + this->m_bX2Y = false; + } + this->initWave2(m_strSlfName, m_strLineName); + } + else if (m_nDrawType == 2) + { + if (this->m_colorMap) + { + this->m_colorMap->setVisible(true); + this->m_colorMap->data()->clear(); + } + clearGraphs(); + clearItems(); - this->initWave(m_strSlfName, m_strLineName); - } + this->initWave(m_strSlfName, m_strLineName); + } } void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName) { - CLogIO *logio = new CLogIO(); - logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead); - // - int index = logio->OpenWave(strWaveName.toStdString().c_str()); - if (index < 0) { - delete logio; - return; - } + CLogIO *logio = new CLogIO(); + logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead); + // + int index = logio->OpenWave(strWaveName.toStdString().c_str()); + if (index < 0) { + delete logio; + return; + } - QMyCustomPlot* widget = this; - Slf_WAVE _wave; - logio->GetWaveInfo(index, &_wave); - float _SDep, _EDep, _Rlev; - _SDep = _wave.StartDepth; - _EDep = _wave.EndDepth; - m_SDep = _SDep; - m_EDep = _EDep; - // _SDep = 0.0 - m_iY2; - // _EDep = 0.0 - m_iY1; - _Rlev = _wave.DepLevel; - int m_Record = (float)(fabs((_EDep - _SDep) / _Rlev + 0.5)); + QMyCustomPlot* widget = this; + Slf_WAVE _wave; + logio->GetWaveInfo(index, &_wave); + float _SDep, _EDep, _Rlev; + _SDep = _wave.StartDepth; + _EDep = _wave.EndDepth; + m_SDep = _SDep; + m_EDep = _EDep; + // _SDep = 0.0 - m_iY2; + // _EDep = 0.0 - m_iY1; + _Rlev = _wave.DepLevel; + int m_Record = (float)(fabs((_EDep - _SDep) / _Rlev + 0.5)); - int _nSamples = _wave.TimeSamples; - m_nSamples = _nSamples; - if (m_fScaleV <= 0.0f) - m_fScaleV = _nSamples; - char *value = new char[(_nSamples + 1)*m_Record*_wave.CodeLen + 1]; - logio->ReadWave(index, _SDep, m_Record, (void *)value); - logio->CloseWave(index); - delete logio; + int _nSamples = _wave.TimeSamples; + m_nSamples = _nSamples; + if (m_fScaleV <= 0.0f) + m_fScaleV = _nSamples; + char *value = new char[(_nSamples + 1)*m_Record*_wave.CodeLen + 1]; + logio->ReadWave(index, _SDep, m_Record, (void *)value); + logio->CloseWave(index); + delete logio; - bool bFistValue = false; - float vmax = -9999;//(float)_nSamples; - float vmin = -9999; + bool bFistValue = false; + float vmax = -9999;//(float)_nSamples; + float vmin = -9999; - float detp = _SDep; - float edepc = _EDep; - if (m_nWaveJg < 10) - m_nWaveJg = 10; - float m_r = _Rlev * m_nWaveJg; - float m_MoveDep = 0.0f; + float detp = _SDep; + float edepc = _EDep; + if (m_nWaveJg < 10) + m_nWaveJg = 10; + float m_r = _Rlev * m_nWaveJg; + float m_MoveDep = 0.0f; - float yscale = 1; - if (m_nWaveHei > 1) - { - float DifBase = 1; - if (m_nDrawType == 2 || m_nDrawType == 6 || m_nDrawType == 10) { - DifBase = (m_MaxRange - m_Base) / m_nColorNum; - } - else { - DifBase = (m_MaxRange - m_Base) / 1; - } - if (fabs(DifBase) <= 1e-6) DifBase = 1; + float yscale = 1; + if (m_nWaveHei > 1) + { + float DifBase = 1; + if (m_nDrawType == 2 || m_nDrawType == 6 || m_nDrawType == 10) { + DifBase = (m_MaxRange - m_Base) / m_nColorNum; + } + else { + DifBase = (m_MaxRange - m_Base) / 1; + } + if (fabs(DifBase) <= 1e-6) DifBase = 1; - yscale = m_nWaveHei + DifBase; - yscale = yscale / DifBase; - } - + yscale = m_nWaveHei + DifBase; + yscale = yscale / DifBase; + } - //QVector< QVector > vecWave; - m_vecWaveData.clear(); - for (float dep1 = detp - 10 * m_r; dep1 < edepc + m_MoveDep + 10 * m_r; dep1 += m_r) - { - int iIndex = Slf_Int(dep1 + m_MoveDep, _SDep, _Rlev); - if (iIndex < 0) { - continue; - } - if (iIndex >= m_Record) - break; + //QVector< QVector > vecWave; + m_vecWaveData.clear(); + for (float dep1 = detp - 10 * m_r; dep1 < edepc + m_MoveDep + 10 * m_r; dep1 += m_r) + { + int iIndex = Slf_Int(dep1 + m_MoveDep, _SDep, _Rlev); + if (iIndex < 0) { + continue; + } - QVector ve(_nSamples); - for (int kk = 0; kk < _nSamples; kk++) - { - double val = GetData(_wave.RepCode, (char *)&value[iIndex * _nSamples*_wave.CodeLen + kk * _wave.CodeLen]); - //ve[kk] = val; - ve[kk] = (int)((val - m_Base)*yscale); - if (val == -9999) - { - continue; - } + if (iIndex >= m_Record) + break; - if (bFistValue == false) - { - //最大值,最小值默认采用第一个有效值 - bFistValue = true; - vmax = vmin = val; - } - // - if (vmax < val)vmax = val; - if (vmin > val)vmin = val; - } - m_vecWaveData << ve; - } + QVector ve(_nSamples); + for (int kk = 0; kk < _nSamples; kk++) + { + double val = GetData(_wave.RepCode, (char *)&value[iIndex * _nSamples*_wave.CodeLen + kk * _wave.CodeLen]); + //ve[kk] = val; + ve[kk] = (int)((val - m_Base)*yscale); + if (val == -9999) + { + continue; + } - delete[] value; + if (bFistValue == false) + { + //最大值,最小值默认采用第一个有效值 + bFistValue = true; + vmax = vmin = val; + } + // + if (vmax < val)vmax = val; + if (vmin > val)vmin = val; + } + m_vecWaveData << ve; + } - float f = 264 / 269.0f; - // m_iY1 = 0.0 -_EDep; - // m_iY2 = 0.0 -_SDep; - //------------------------ - widget->m_iY1 = m_iY1; - widget->m_iY2 = m_iY2; - // - if (!widget->m_bX2Y) - { - widget->xAxis->setRange(vmin, vmax); - widget->yAxis->setRange(m_iY1, m_iY2); - widget->axisRect()->setupFullAxesBox(); - // - widget->xAxis->ticker()->setTickCount(10);//x个主刻度 - widget->yAxis->ticker()->setTickCount(60);//y个主刻度 + delete[] value; - widget->xAxis->setTicks(false); - widget->yAxis->setTicks(false); - widget->xAxis2->setTicks(false); - widget->yAxis2->setTicks(false); - widget->xAxis->setTickLabels(false); - widget->yAxis->setTickLabels(false); - widget->xAxis2->setTickLabels(false); - widget->xAxis2->setTickLabels(false); - widget->xAxis->setVisible(false); - widget->xAxis2->setVisible(false); - widget->yAxis->setVisible(false); - widget->yAxis2->setVisible(false); + float f = 264 / 269.0f; + // m_iY1 = 0.0 -_EDep; + // m_iY2 = 0.0 -_SDep; + //------------------------ + widget->m_iY1 = m_iY1; + widget->m_iY2 = m_iY2; + // + if (!widget->m_bX2Y) + { + widget->xAxis->setRange(vmin, vmax); + widget->yAxis->setRange(m_iY1, m_iY2); + widget->axisRect()->setupFullAxesBox(); + // + widget->xAxis->ticker()->setTickCount(10);//x个主刻度 + widget->yAxis->ticker()->setTickCount(60);//y个主刻度 - //对调XY轴,在最前面设置 - QCPAxis *yAxis = widget->yAxis; - QCPAxis *xAxis = widget->xAxis; - widget->xAxis = yAxis; - widget->yAxis = xAxis; - widget->m_bX2Y = true; - } - widget->m_fmin = vmin; - widget->m_fmax = vmax * f; + widget->xAxis->setTicks(false); + widget->yAxis->setTicks(false); + widget->xAxis2->setTicks(false); + widget->yAxis2->setTicks(false); + widget->xAxis->setTickLabels(false); + widget->yAxis->setTickLabels(false); + widget->xAxis2->setTickLabels(false); + widget->xAxis2->setTickLabels(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); - //------------------- - // set up the QCPColorMap: - if (widget->m_colorMap == NULL) - { - QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis); - widget->m_colorMap = colorMap; + //对调XY轴,在最前面设置 + QCPAxis *yAxis = widget->yAxis; + QCPAxis *xAxis = widget->xAxis; + widget->xAxis = yAxis; + widget->yAxis = xAxis; + widget->m_bX2Y = true; + } + widget->m_fmin = vmin; + widget->m_fmax = vmax * f; - // :现在,我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据: - this->updateWave(); + //------------------- + // set up the QCPColorMap: + if (widget->m_colorMap == NULL) + { + QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis); + widget->m_colorMap = colorMap; - // 添加色标: - QCPColorScale *colorScale = new QCPColorScale(widget); - colorMap->setColorScale(colorScale); // 将颜色图与色标关联 - // 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内: - colorMap->rescaleDataRange(); + // :现在,我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据: + this->updateWave(); - this->setSchemeIndex(m_nSchemeIndex, m_nColorNum); - } - else - { - this->updateWave(); - } + // 添加色标: + QCPColorScale *colorScale = new QCPColorScale(widget); + colorMap->setColorScale(colorScale); // 将颜色图与色标关联 + // 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内: + colorMap->rescaleDataRange(); + + this->setSchemeIndex(m_nSchemeIndex, m_nColorNum); + } + else + { + this->updateWave(); + } } void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) { - QMyCustomPlot* widget = this; - CLogIO *logio = new CLogIO(); - logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead); - // - int index = logio->OpenWave(strWaveName.toStdString().c_str()); - if (index < 0) { - delete logio; - return; - } + QMyCustomPlot* widget = this; + CLogIO *logio = new CLogIO(); + logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead); + // + int index = logio->OpenWave(strWaveName.toStdString().c_str()); + if (index < 0) { + delete logio; + return; + } - float vmax = 264;// (float)_nSamples; - float vmin = 0; + float vmax = 264;// (float)_nSamples; + float vmin = 0; - //widget->m_iX1 = vmin; - //widget->m_iX2 = vmax; - // - widget->xAxis->setRange(vmin, vmax); - widget->yAxis->setRange(m_iY1, m_iY2); - widget->axisRect()->setupFullAxesBox(); + //widget->m_iX1 = vmin; + //widget->m_iX2 = vmax; + // + widget->xAxis->setRange(vmin, vmax); + widget->yAxis->setRange(m_iY1, m_iY2); + widget->axisRect()->setupFullAxesBox(); - //注意,不对调XY轴 - widget->m_bX2Y = false; + //注意,不对调XY轴 + widget->m_bX2Y = false; - Slf_WAVE _wave; - logio->GetWaveInfo(index, &_wave); + Slf_WAVE _wave; + logio->GetWaveInfo(index, &_wave); - float m_SDep = _wave.StartDepth; - float m_EDep = _wave.EndDepth; - float m_Rlev = _wave.DepLevel; - int m_Record = (float)(fabs((m_EDep - m_SDep) / m_Rlev + 0.5)); - int _nSamples = _wave.TimeSamples; + float m_SDep = _wave.StartDepth; + float m_EDep = _wave.EndDepth; + float m_Rlev = _wave.DepLevel; + int m_Record = (float)(fabs((m_EDep - m_SDep) / m_Rlev + 0.5)); + int _nSamples = _wave.TimeSamples; - char *value = new char[(_nSamples + 1)*m_Record*_wave.CodeLen + 1]; - logio->ReadWave(index, m_SDep, m_Record, (void *)value); - logio->CloseWave(index); - delete logio; + char *value = new char[(_nSamples + 1)*m_Record*_wave.CodeLen + 1]; + logio->ReadWave(index, m_SDep, m_Record, (void *)value); + logio->CloseWave(index); + delete logio; - MyDataTypeEnum vVdl; - int lpoint = 0; - int nPoint = _nSamples; - float detp = -m_iY2; - float edepc = -m_iY1; - float m_PlotSdep = -m_iY2; - float m_MoveDep = 0.0f; - float DifBase = (m_MaxRange - m_Base) / 1; - float yscale = m_nWaveHei; - yscale = yscale / DifBase; + MyDataTypeEnum vVdl; + int lpoint = 0; + int nPoint = _nSamples; + float detp = -m_iY2; + float edepc = -m_iY1; + float m_PlotSdep = -m_iY2; + float m_MoveDep = 0.0f; + float DifBase = (m_MaxRange - m_Base) / 1; + float yscale = m_nWaveHei; + yscale = yscale / DifBase; - int nStep = m_nWaveJg;// mWaveMes.m_WaveSpace; - if (m_nWaveJg < 10) - nStep = 10; + int nStep = m_nWaveJg;// mWaveMes.m_WaveSpace; + if (m_nWaveJg < 10) + nStep = 10; - if (nStep < 1) nStep = 1; - float m_r = m_Rlev * nStep; - detp = int((detp - m_PlotSdep) / m_r)*m_r + m_PlotSdep; + if (nStep < 1) nStep = 1; + float m_r = m_Rlev * nStep; + detp = int((detp - m_PlotSdep) / m_r)*m_r + m_PlotSdep; - int nOdd = 0; - int nidx = 0; - for (float dep1 = detp - m_r; dep1 < edepc + m_MoveDep + m_r; dep1 += m_r) - { - if (dep1 >= m_EDep || dep1 + m_r < m_SDep) - { - continue; - } + int nOdd = 0; + int nidx = 0; + for (float dep1 = detp - m_r; dep1 < edepc + m_MoveDep + m_r; dep1 += m_r) + { + if (dep1 >= m_EDep || dep1 + m_r < m_SDep) + { + continue; + } - int iIndex = Slf_Int(dep1 + m_MoveDep, m_SDep, m_Rlev); - if (iIndex < 0) { - continue; - } + int iIndex = Slf_Int(dep1 + m_MoveDep, m_SDep, m_Rlev); + if (iIndex < 0) { + continue; + } - QVector vals; - if (iIndex < 0 || iIndex >= m_Record) - continue; + QVector vals; + if (iIndex < 0 || iIndex >= m_Record) + continue; - vals.resize(nPoint); - vVdl.vchar = &((char *)value)[iIndex*_nSamples*_wave.CodeLen]; + vals.resize(nPoint); + vVdl.vchar = &((char *)value)[iIndex*_nSamples*_wave.CodeLen]; - for (int i = 0; i < nPoint; i++) - { - float ch = 0.0f; - if (i + lpoint < 0) - ch = 0; - else if (i + lpoint < _nSamples) { - if (_wave.RepCode == REPR_CHAR) { - ch = vVdl.vchar[i + lpoint]; - } - else if (_wave.RepCode == REPR_UCHAR) { - ch = vVdl.vuchar[i + lpoint]; - } - else if (_wave.RepCode == REPR_SHORT) { - ch = vVdl.vshort[i + lpoint]; - if (ch == -32767) ch = 0; - } - else if (_wave.RepCode == REPR_USHORT) { - ch = vVdl.vushort[i + lpoint]; - if ((short)ch == -32767) ch = 0; - } - else if (_wave.RepCode == REPR_FLOAT) { - ch = vVdl.vfloat[i + lpoint]; - } - else - ch = GetData(_wave.RepCode, (char *)&vVdl.vchar[(i + lpoint)*_wave.CodeLen]); - if (ch == -9999.0 || ch == -99999.0 || ch == -999.25) - ch = 0; - } - else ch = 0; - vals[i] = ch; - } + for (int i = 0; i < nPoint; i++) + { + float ch = 0.0f; + if (i + lpoint < 0) + ch = 0; + else if (i + lpoint < _nSamples) { + if (_wave.RepCode == REPR_CHAR) { + ch = vVdl.vchar[i + lpoint]; + } + else if (_wave.RepCode == REPR_UCHAR) { + ch = vVdl.vuchar[i + lpoint]; + } + else if (_wave.RepCode == REPR_SHORT) { + ch = vVdl.vshort[i + lpoint]; + if (ch == -32767) ch = 0; + } + else if (_wave.RepCode == REPR_USHORT) { + ch = vVdl.vushort[i + lpoint]; + if ((short)ch == -32767) ch = 0; + } + else if (_wave.RepCode == REPR_FLOAT) { + ch = vVdl.vfloat[i + lpoint]; + } + else + ch = GetData(_wave.RepCode, (char *)&vVdl.vchar[(i + lpoint)*_wave.CodeLen]); + if (ch == -9999.0 || ch == -99999.0 || ch == -999.25) + ch = 0; + } + else ch = 0; + vals[i] = ch; + } - QVector vx; - QVector vy; - double dminy = 0.0; - for (int i = 0; i < nPoint; i++) - { - vx << i; + QVector vx; + QVector vy; + double dminy = 0.0; + for (int i = 0; i < nPoint; i++) + { + vx << i; - double d = (-dep1 - 1) + vals[i] * yscale; - vy << d; - if (d < dminy) - dminy = d; - } + double d = (-dep1 - 1) + vals[i] * yscale; + vy << d; + if (d < dminy) + dminy = d; + } - QCPGraph * graph0 = widget->graph(nidx); - if (graph0 == NULL) - { - graph0 = widget->addGraph(); - graph0->setPen(QPen(m_newColor)); - } - if (m_nDrawType == 0 && m_bOddEven) // 波形&&奇偶配色 - { - if (nOdd % 2 == 1) - graph0->setPen(QPen(QColor(255, 0, 0))); - } - graph0->setData(vx, vy); + QCPGraph * graph0 = widget->graph(nidx); + if (graph0 == NULL) + { + graph0 = widget->addGraph(); + graph0->setPen(QPen(m_newColor)); + } + if (m_nDrawType == 0 && m_bOddEven) // 波形&&奇偶配色 + { + if (nOdd % 2 == 1) + graph0->setPen(QPen(QColor(255, 0, 0))); + } + graph0->setData(vx, vy); - if (m_bDrawDepth) - { - QCPItemText* pText = new QCPItemText(this); - pText->setText(QString::number(dminy*-1, 'f', 2)); - pText->position->setCoords(30, dminy); - if (m_bOddEven && nOdd % 2 == 1) - pText->setColor(QColor(255, 0, 0)); - else - pText->setColor(m_newColor); - } - //graph->setBrush(QBrush(QColor(255, 0, 0, 100))); - nidx++; + if (m_bDrawDepth) + { + QCPItemText* pText = new QCPItemText(this); + pText->setText(QString::number(dminy*-1, 'f', 2)); + pText->position->setCoords(30, dminy); + if (m_bOddEven && nOdd % 2 == 1) + pText->setColor(QColor(255, 0, 0)); + else + pText->setColor(m_newColor); + } + //graph->setBrush(QBrush(QColor(255, 0, 0, 100))); + nidx++; - if (m_bDrawBase || m_nDrawType == 1) // 填充 || 绘制波基线 - { - QCPGraph * graph1 = widget->graph(nidx); - if (graph1 == NULL) - { - graph1 = widget->addGraph(); - graph1->setPen(QPen(m_newColor)); - } - if (m_bOddEven && nOdd % 2 == 1) - graph1->setPen(QPen(QColor(255, 0, 0))); - double dx1 = vx[0]; - double dx2 = vx[vx.size() - 1]; - vx.clear(); - vx << dx1 << dx2; - vy.clear(); - vy << dminy << dminy; - graph1->setData(vx, vy); - nidx++; - if (m_nDrawType == 1) - { - graph0->setBrush(QBrush(m_newColor)); - graph0->setChannelFillGraph(graph1); - } - } + if (m_bDrawBase || m_nDrawType == 1) // 填充 || 绘制波基线 + { + QCPGraph * graph1 = widget->graph(nidx); + if (graph1 == NULL) + { + graph1 = widget->addGraph(); + graph1->setPen(QPen(m_newColor)); + } + if (m_bOddEven && nOdd % 2 == 1) + graph1->setPen(QPen(QColor(255, 0, 0))); + double dx1 = vx[0]; + double dx2 = vx[vx.size() - 1]; + vx.clear(); + vx << dx1 << dx2; + vy.clear(); + vy << dminy << dminy; + graph1->setData(vx, vy); + nidx++; + if (m_nDrawType == 1) + { + graph0->setBrush(QBrush(m_newColor)); + graph0->setChannelFillGraph(graph1); + } + } - nOdd++; - } - widget->replot(); + nOdd++; + } + widget->replot(); - delete[]value; + delete[]value; } void QMyCustomPlot::initColorTable() { - this->setSchemeIndex(m_nSchemeIndex, m_nColorNum); + this->setSchemeIndex(m_nSchemeIndex, m_nColorNum); } void QMyCustomPlot::setSchemeIndex(int nidx, int colorNum) { - if (m_colorMap == NULL) - return; + if (m_colorMap == NULL) + return; - m_nSchemeIndex = nidx; - m_nColorNum = colorNum; + m_nSchemeIndex = nidx; + m_nColorNum = colorNum; - QtColorTableData::getInstance()->SetCurrentSchemeIndex(nidx); - //ColorTableIndex = ind; + QtColorTableData::getInstance()->SetCurrentSchemeIndex(nidx); + //ColorTableIndex = ind; - QtColorTableData::getInstance()->ChangeColorNum(colorNum); - QList rgbList = QtColorTableData::getInstance()->GetRgb(); + QtColorTableData::getInstance()->ChangeColorNum(colorNum); + QList rgbList = QtColorTableData::getInstance()->GetRgb(); - int iColorNum = rgbList.size(); - QCPColorGradient gradient; - for (int i = 0; i < iColorNum; i++) - { - QColor acolor = rgbList.at(i); - double dbTmpIndex = (double)(i) / iColorNum; - gradient.setColorStopAt(dbTmpIndex, acolor); // x% 位置的颜色 - //mWaveMes.m_ColorMessage.Color[i] = acolor; - } + int iColorNum = rgbList.size(); + QCPColorGradient gradient; + for (int i = 0; i < iColorNum; i++) + { + QColor acolor = rgbList.at(i); + double dbTmpIndex = (double)(i) / iColorNum; + gradient.setColorStopAt(dbTmpIndex, acolor); // x% 位置的颜色 + //mWaveMes.m_ColorMessage.Color[i] = acolor; + } - m_colorMap->setGradient(gradient); + m_colorMap->setGradient(gradient); } QCPColorMap * QMyCustomPlot::updateWave() -{ - int nx = m_vecWaveData.size(); - int ny = m_nSamples; +{ + int nx = m_vecWaveData.size(); + int ny = m_nSamples; - m_colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点 - m_colorMap->data()->setRange(QCPRange(0 - m_EDep, 0 - m_SDep), QCPRange(this->m_fmin, this->m_fmax)); + m_colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点 + m_colorMap->data()->setRange(QCPRange(0 - m_EDep, 0 - m_SDep), QCPRange(this->m_fmin, this->m_fmax)); - for (int xIndex = 0; xIndex < nx; ++xIndex) - { - for (int yIndex = 0; yIndex < ny; ++yIndex) - { - double dz = m_vecWaveData[xIndex][yIndex]; - if (m_nMode == 0) - { - if (dz == -9999) - { - dz = m_fmax; - } - } - else if (m_nMode == 1) - { - if (dz == -9999) - { - dz = m_fmin; - } - } - else if (m_nMode == 2) - { - if (dz == -9999) - { - dz = m_fmax; - } - else - { - dz = m_fmin; - } - } - m_colorMap->data()->setCell(nx - xIndex - 1, yIndex, dz); - } - } - return m_colorMap; + for (int xIndex = 0; xIndex < nx; ++xIndex) + { + for (int yIndex = 0; yIndex < ny; ++yIndex) + { + double dz = m_vecWaveData[xIndex][yIndex]; + if (m_nMode == 0) + { + if (dz == -9999) + { + dz = m_fmax; + } + } + else if (m_nMode == 1) + { + if (dz == -9999) + { + dz = m_fmin; + } + } + else if (m_nMode == 2) + { + if (dz == -9999) + { + dz = m_fmax; + } + else + { + dz = m_fmin; + } + } + m_colorMap->data()->setCell(nx - xIndex - 1, yIndex, dz); + } + } + return m_colorMap; } float QMyCustomPlot::getScaleV() { - return m_fScaleV; + return m_fScaleV; } void QMyCustomPlot::groupBeginResult(float fEndDepth, float fStartDepth) { - // 组ID - m_strGroupUid = getUUid(); - m_fResultEndDepth = fEndDepth; - addResultGroup(fEndDepth, fStartDepth, m_strGroupUid, "11"); + // 组ID + m_strGroupUid = getUUid(); + m_fResultEndDepth = fEndDepth; + addResultGroup(fEndDepth, fStartDepth, m_strGroupUid, "11"); } void QMyCustomPlot::groupEndResult() { - m_strGroupUid = ""; + m_strGroupUid = ""; } void QMyCustomPlot::setShowProperty(QVariant val, int ntag) { - QObjectList objList = m_mapDragGroup.values(); - for (int i = 0; i < objList.size(); i++) - { - TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); - if (pGroup == nullptr) - continue; - if (ntag == 1) - { - pGroup->setGroupConclusionProportion(val.toInt()); - } - else if (ntag == 2) - { - pGroup->setGroupShowPos(val.toInt()); - } - else if (ntag == 3) - { - pGroup->setFloorVisible(val.toBool()); - } - else if (ntag == 4) - { - QFont f = val.value(); - pGroup->setFloorFont(f); - } - else if (ntag == 5) - { - pGroup->setFloorRot(val.toDouble()); - } - } + QObjectList objList = m_mapDragGroup.values(); + for (int i = 0; i < objList.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); + if (pGroup == nullptr) + continue; + if (ntag == 1) + { + pGroup->setGroupConclusionProportion(val.toInt()); + } + else if (ntag == 2) + { + pGroup->setGroupShowPos(val.toInt()); + } + else if (ntag == 3) + { + pGroup->setFloorVisible(val.toBool()); + } + else if (ntag == 4) + { + QFont f = val.value(); + pGroup->setFloorFont(f); + } + else if (ntag == 5) + { + pGroup->setFloorRot(val.toDouble()); + } + } } void QMyCustomPlot::setConclusionProportion(int nCopro) { - QObjectList objList = m_mapDragGroup.values(); - for (int i = 0; i < objList.size(); i++) - { - TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); - if (pGroup == nullptr) - continue; - pGroup->setGroupConclusionProportion(nCopro); - } + QObjectList objList = m_mapDragGroup.values(); + for (int i = 0; i < objList.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); + if (pGroup == nullptr) + continue; + pGroup->setGroupConclusionProportion(nCopro); + } } void QMyCustomPlot::setShowPos(int nSPos) { - QObjectList objList = m_mapDragGroup.values(); - for (int i = 0; i < objList.size(); i++) - { - TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); - if (pGroup == nullptr) - continue; - pGroup->setGroupShowPos(nSPos); - } + QObjectList objList = m_mapDragGroup.values(); + for (int i = 0; i < objList.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); + if (pGroup == nullptr) + continue; + pGroup->setGroupShowPos(nSPos); + } } //蝌蚪图,重绘网格线 @@ -772,19 +773,19 @@ void QMyCustomPlot::init(QString strName, QVector xx, QVector yy void QMyCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) { - // 检查是否是左键双击 - if (event->button() == Qt::LeftButton) { - //qDebug() << "左键双击发生!"; - // 在这里添加你的双击处理逻辑 - m_bEditor = true; + // 检查是否是左键双击 + if (event->button() == Qt::LeftButton) { + //qDebug() << "左键双击发生!"; + // 在这里添加你的双击处理逻辑 + m_bEditor = true; - // 接受事件 - event->accept(); - } - else { - // 其他按钮的双击交给基类处理 - QWidget::mouseDoubleClickEvent(event); - } + // 接受事件 + event->accept(); + } + else { + // 其他按钮的双击交给基类处理 + QWidget::mouseDoubleClickEvent(event); + } } //void QMyCustomPlot::mousePressEvent(QMouseEvent *event) @@ -795,50 +796,50 @@ void QMyCustomPlot::mouseDoubleClickEvent(QMouseEvent *event) void QMyCustomPlot::mousePressEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton) - { - if (m_strLineName == "RESULT") - { - if (m_bEditor) - { - //获取鼠标点位置 - double y_pos = event->pos().y(); - //转为图像位置 - double x_val = xAxis->pixelToCoord(y_pos); - mMousePress = true; + if (event->button() == Qt::LeftButton) + { + if (m_strLineName == "RESULT") + { + if (m_bEditor) + { + //获取鼠标点位置 + double y_pos = event->pos().y(); + //转为图像位置 + double x_val = xAxis->pixelToCoord(y_pos); + mMousePress = true; - QObjectList objList = m_mapDragGroup.values(); - for (int i = 0; i < objList.size(); i++) - { - TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); - if (pGroup == nullptr) - continue; - QCPRange rg = pGroup->getRange(); - if (x_val <= rg.upper && x_val >= rg.lower) - { - mMousePress = false; - break; - } - } - if (mMousePress) - { - m_dPressX = x_val; - if (m_pAddLine1 == NULL) - { - m_pAddLine1 = new QCPItemStraightLine(this); - m_pAddLine1->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine)); - m_pAddLine1->setVisible(false); - } - if (m_pAddLine2 == NULL) - { - m_pAddLine2 = new QCPItemStraightLine(this); - m_pAddLine2->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine)); - m_pAddLine2->setVisible(false); - } - } - } - } - } + QObjectList objList = m_mapDragGroup.values(); + for (int i = 0; i < objList.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); + if (pGroup == nullptr) + continue; + QCPRange rg = pGroup->getRange(); + if (x_val <= rg.upper && x_val >= rg.lower) + { + mMousePress = false; + break; + } + } + if (mMousePress) + { + m_dPressX = x_val; + if (m_pAddLine1 == NULL) + { + m_pAddLine1 = new QCPItemStraightLine(this); + m_pAddLine1->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine)); + m_pAddLine1->setVisible(false); + } + if (m_pAddLine2 == NULL) + { + m_pAddLine2 = new QCPItemStraightLine(this); + m_pAddLine2->setPen(QPen(Qt::red, 1, Qt::DashDotDotLine)); + m_pAddLine2->setVisible(false); + } + } + } + } + } // if(m_bDrawCore_PHYSICS)//岩心分析 // { @@ -893,27 +894,27 @@ void QMyCustomPlot::mousePressEvent(QMouseEvent *event) void QMyCustomPlot::mouseMoveEvent(QMouseEvent *event) { - if (m_strLineName == "RESULT") - { - if (mMousePress) - { - //获取鼠标点位置 - double y_pos = event->pos().y(); - //转为图像位置 - double x_val = xAxis->pixelToCoord(y_pos); - double absval = abs(abs(m_dPressX) - abs(x_val)); - if (absval > 0.5 && !m_pAddLine1->visible()) - { - m_pAddLine1->setVisible(true); - m_pAddLine1->point1->setCoords(m_dPressX, 0); - m_pAddLine1->point2->setCoords(m_dPressX, 1); - m_pAddLine2->setVisible(true); - } - m_pAddLine2->point1->setCoords(x_val, 0); - m_pAddLine2->point2->setCoords(x_val, 1); - replot(); - } - } + if (m_strLineName == "RESULT") + { + if (mMousePress) + { + //获取鼠标点位置 + double y_pos = event->pos().y(); + //转为图像位置 + double x_val = xAxis->pixelToCoord(y_pos); + double absval = abs(abs(m_dPressX) - abs(x_val)); + if (absval > 0.5 && !m_pAddLine1->visible()) + { + m_pAddLine1->setVisible(true); + m_pAddLine1->point1->setCoords(m_dPressX, 0); + m_pAddLine1->point2->setCoords(m_dPressX, 1); + m_pAddLine2->setVisible(true); + } + m_pAddLine2->point1->setCoords(x_val, 0); + m_pAddLine2->point2->setCoords(x_val, 1); + replot(); + } + } QCustomPlot::mouseMoveEvent(event); @@ -1088,25 +1089,25 @@ void QMyCustomPlot::mouseMoveEvent(QMouseEvent *event) void QMyCustomPlot::mouseReleaseEvent(QMouseEvent *event) { - if (m_strLineName == "RESULT") - { - if (mMousePress) - { - //获取鼠标点位置 - double y_pos = event->pos().y(); - //转为图像位置 - double x_val = xAxis->pixelToCoord(y_pos); - double absval = abs(abs(m_dPressX) - abs(x_val)); - if (absval < 0.4) - { - mMousePress = false; - m_pAddLine1->setVisible(false); - m_pAddLine2->setVisible(false); - replot(); - } + if (m_strLineName == "RESULT") + { + if (mMousePress) + { + //获取鼠标点位置 + double y_pos = event->pos().y(); + //转为图像位置 + double x_val = xAxis->pixelToCoord(y_pos); + double absval = abs(abs(m_dPressX) - abs(x_val)); + if (absval < 0.4) + { + mMousePress = false; + m_pAddLine1->setVisible(false); + m_pAddLine2->setVisible(false); + replot(); + } - } - } + } + } // if(m_bDrawCore_PHYSICS)//岩心分析 // { @@ -1173,51 +1174,51 @@ void QMyCustomPlot::executeSingle(QMouseEvent *event) void QMyCustomPlot::slotSelectionRectAccepted(const QRect &rect, QMouseEvent *event) { - if ("RESULT" == m_strLineName) - { - if (!mMousePress) - return; + if ("RESULT" == m_strLineName) + { + if (!mMousePress) + return; - // 当选择完成时,获取矩形范围并放大 - QRectF rect = this->selectionRect()->rect(); // 获取选择的矩形区域(像素坐标) - m_bEditRect = true;//当前是否正在编辑曲线。 + // 当选择完成时,获取矩形范围并放大 + QRectF rect = this->selectionRect()->rect(); // 获取选择的矩形区域(像素坐标) + m_bEditRect = true;//当前是否正在编辑曲线。 - // 转换为坐标轴范围 - double top = rect.top(); - double bottom = rect.bottom(); + // 转换为坐标轴范围 + double top = rect.top(); + double bottom = rect.bottom(); - double right_Hight = this->xAxis->pixelToCoord(top); //上边界 - double left_Low = this->xAxis->pixelToCoord(bottom); //下边界 + double right_Hight = this->xAxis->pixelToCoord(top); //上边界 + double left_Low = this->xAxis->pixelToCoord(bottom); //下边界 - bool bAdd = true; - QObjectList objList = m_mapDragGroup.values(); - for (int i = 0; i < objList.size(); i++) - { - TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); - if (pGroup == nullptr) - continue; - QCPRange rg = pGroup->getRange(); - if (right_Hight <= rg.upper && right_Hight >= rg.lower - || left_Low <= rg.upper && left_Low >= rg.lower) - { - bAdd = false; - break; - } - } + bool bAdd = true; + QObjectList objList = m_mapDragGroup.values(); + for (int i = 0; i < objList.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); + if (pGroup == nullptr) + continue; + QCPRange rg = pGroup->getRange(); + if (right_Hight <= rg.upper && right_Hight >= rg.lower + || left_Low <= rg.upper && left_Low >= rg.lower) + { + bAdd = false; + break; + } + } - if (bAdd) - { - QString strUp = ""; - TransparentGroupResult* pGroup = this->addResultGroup(left_Low, right_Hight, strUp, ""); - strUp = ""; - pGroup->addResultToPlot(left_Low, right_Hight, ::GetOilSymbolDir() + "油层.svg", strUp); + if (bAdd) + { + QString strUp = ""; + TransparentGroupResult* pGroup = this->addResultGroup(left_Low, right_Hight, strUp, ""); + strUp = ""; + pGroup->addResultToPlot(left_Low, right_Hight, ::GetOilSymbolDir() + "油层.svg", strUp); - } - mMousePress = false; - m_pAddLine1->setVisible(false); - m_pAddLine2->setVisible(false); - replot(); - } + } + mMousePress = false; + m_pAddLine1->setVisible(false); + m_pAddLine2->setVisible(false); + replot(); + } } //槽函数,选中曲线 @@ -1317,35 +1318,35 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event) menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer); menu.exec(event->globalPos()); } - else if (m_strLineName == "RESULT") // 解释结论 - { - QMenu menu(this); - if (!m_bEditor) - { - menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑解释结论", this, &QMyCustomPlot::onOpenEditResult); - } - else - { - mLastPos = event->pos(); - qDebug() << "mLastPos:" << mLastPos; - menu.addAction(QIcon(::GetImagePath() + "curve.png"), "关闭编辑解释结论", this, &QMyCustomPlot::onCloseEditResult); - menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Layer); - menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); - menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &QMyCustomPlot::DeleteItemGroup); - menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Layer); - menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer); - menu.addAction(QIcon(::GetImagePath() + "icon/SetZone.png"), "更新层号", this, &QMyCustomPlot::updateGroupZone); + else if (m_strLineName == "RESULT") // 解释结论 + { + QMenu menu(this); + if (!m_bEditor) + { + menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑解释结论", this, &QMyCustomPlot::onOpenEditResult); + } + else + { + mLastPos = event->pos(); + qDebug() << "mLastPos:" << mLastPos; + menu.addAction(QIcon(::GetImagePath() + "curve.png"), "关闭编辑解释结论", this, &QMyCustomPlot::onCloseEditResult); + menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "从剪切板文本数据粘贴", this, &QMyCustomPlot::addItems_Layer); + menu.addAction(QIcon(::GetImagePath() + "icon/ClearSelectCore.png"), "取消选中", this, &QMyCustomPlot::ClearSelectItems); + menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &QMyCustomPlot::DeleteItemGroup); + menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "全部清空", this, &QMyCustomPlot::DeleteItems_Layer); + menu.addAction(QIcon(::GetImagePath() + "icon/CopyCoreTxt.png"), "刷新数据", this, &QMyCustomPlot::RefreshItems_Layer); + menu.addAction(QIcon(::GetImagePath() + "icon/SetZone.png"), "更新层号", this, &QMyCustomPlot::updateGroupZone); - menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为层内层", this, &QMyCustomPlot::segmentationInnerLayer); - menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为独立层", this, &QMyCustomPlot::segmentationIndependentLayer); - menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "拆分复合层成独立层", this, &QMyCustomPlot::splitIndependentLayer); - QMap mapsort = this->getSelectGroupResult(); - if (mapsort.size() > 1) - menu.addAction(QIcon(::GetImagePath() + "icon/decreasey.png"), "合并", this, &QMyCustomPlot::megResultLayer); - } - menu.exec(event->globalPos()); + menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为层内层", this, &QMyCustomPlot::segmentationInnerLayer); + menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "分割为独立层", this, &QMyCustomPlot::segmentationIndependentLayer); + menu.addAction(QIcon(::GetImagePath() + "icon/Split.png"), "拆分复合层成独立层", this, &QMyCustomPlot::splitIndependentLayer); + QMap mapsort = this->getSelectGroupResult(); + if (mapsort.size() > 1) + menu.addAction(QIcon(::GetImagePath() + "icon/decreasey.png"), "合并", this, &QMyCustomPlot::megResultLayer); + } + menu.exec(event->globalPos()); - } + } else if (m_strLineName == "IMAGE_DATA") { //岩心图片 @@ -1399,7 +1400,7 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event) { QStringList strs=zoneOrder_Tubing.keys(); QStringList mstrs=QString("油管接箍,套管接箍,偏配,封隔器,筛管,喇叭口,水力猫,短接,管底部,油管深").split(","); - QMenu menu(this); + QMenu menu(this); QMenu *pSubMenu = menu.addMenu("特殊工具"); //套管组件 for(int i=0;iglobalPos()); + } + else if (strType == "CrackObject") // 裂缝 + { + QMenu menu(this); + menu.addAction(QIcon(::GetImagePath() + "curve.png"), "添加裂缝", this, &QMyCustomPlot::addCrackObject); + menu.exec(event->globalPos()); } } @@ -2009,23 +2017,115 @@ void QMyCustomPlot::addCorePhysics() void QMyCustomPlot::addCorePhysicsWithParam(int Order, double Depth, double CorrDepth, double CoreValue) { -// qDebug() << Order << "====="; -// qDebug() << Depth << "====="; -// qDebug() << CorrDepth << "====="; -// qDebug() << CoreValue << "====="; 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() +{ + // 1. 创建对话框 + QDialog dlg(nullptr); + dlg.setWindowTitle("添加裂缝"); + dlg.setFixedSize(420, 300); // 窗口大小 + + // ====================== 控件创建 ====================== + // 深度标签 + 输入框 + QLabel *labDepth = new QLabel("输入裂缝深度"); + QLineEdit *editDepth = new QLineEdit; + double a = this->m_event->pos().y(); + double y_pos = this->yAxis->pixelToCoord(this->m_event->pos().y()); + editDepth->setText(QString::number(qAbs(y_pos))); // 默认值 + editDepth->setFixedWidth(200); + // 类型标签 + 下拉框 + QLabel *labType = new QLabel("选择裂缝类型"); + QComboBox *cbbType = new QComboBox; + cbbType->addItems({"高导缝", "高阻缝", "网状缝", "诱导缝", "层理", "侵蚀面", "孔洞", "气孔", "砾石", "结核", "团块", "断层", "垂直缝", "自定义1", "自定义2"}); + cbbType->setCurrentText("高导缝"); + cbbType->setFixedWidth(200); // 与输入框高度一致 + + // 按钮 + QPushButton *btnOk = new QPushButton("确定"); + QPushButton *btnCancel = new QPushButton("放弃"); + + // ====================== 布局 ====================== + QHBoxLayout *lay1 = new QHBoxLayout; + lay1->addWidget(labDepth); + lay1->addWidget(editDepth); + lay1->setSpacing(20); + lay1->setContentsMargins(30, 0, 30, 0); + + QHBoxLayout *lay2 = new QHBoxLayout; + lay2->addWidget(labType); + lay2->addWidget(cbbType); + lay2->setSpacing(20); + lay2->setContentsMargins(30, 0, 30, 0); + + QHBoxLayout *layBtn = new QHBoxLayout; + layBtn->addStretch(); + layBtn->addWidget(btnOk); + layBtn->addWidget(btnCancel); + layBtn->addStretch(); + layBtn->setContentsMargins(30, 0, 30, 0); + + QVBoxLayout *mainLay = new QVBoxLayout(&dlg); + mainLay->addStretch(); + mainLay->addLayout(lay1); + mainLay->addSpacing(40); + mainLay->addLayout(lay2); + mainLay->addStretch(); + mainLay->addLayout(layBtn); + mainLay->addSpacing(40); + mainLay->setContentsMargins(20, 20, 20, 20); + + // ====================== 信号绑定 ====================== + connect(btnOk, &QPushButton::clicked, &dlg, [&](){ + // 校验输入 + if(editDepth->text().isEmpty()){ + QMessageBox::warning(&dlg,"提示","深度不能为空"); + return; + } + dlg.accept(); // 确认关闭 + }); + + connect(btnCancel, &QPushButton::clicked, &dlg, &QDialog::reject); + + // ====================== 弹出对话框并获取结果 ====================== + 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; + + // ========= 这里就是你要的结果!========= + qDebug() << "深度:" << depth << " 类型:" << type; + } +} + //从剪切板文本数据粘贴 void QMyCustomPlot::pasteCorePhysics() {} @@ -3193,7 +3293,7 @@ void QMyCustomPlot::moveItems_SWallCore() //从剪切板文本数据粘贴 void QMyCustomPlot::addItems_SWallCore() -{ +{ QClipboard *clipboard = QApplication::clipboard(); //获取系统剪贴板指针 QString originalText = clipboard->text(); //获取剪贴板上文本信息 int isspace=originalText.indexOf(" "); @@ -4167,18 +4267,18 @@ void QMyCustomPlot::addItems_Gujing() //取消选中 void QMyCustomPlot::ClearSelectItems() { - if (m_strLineName == "RESULT") - { - QMap mapsort = this->getSelectGroupResult(); - QList listGroup = mapsort.values(); - for (int i = 0; i < listGroup.size(); i++) - { - TransparentGroupResult* pGroup = listGroup.at(i); - if (pGroup == NULL) - continue; - pGroup->setSelectRect(false); - } - } + if (m_strLineName == "RESULT") + { + QMap mapsort = this->getSelectGroupResult(); + QList listGroup = mapsort.values(); + for (int i = 0; i < listGroup.size(); i++) + { + TransparentGroupResult* pGroup = listGroup.at(i); + if (pGroup == NULL) + continue; + pGroup->setSelectRect(false); + } + } else if (m_strLineName == "CORE_PHYSICS") { if(m_SelectShiftLine) @@ -4420,7 +4520,7 @@ bool QMyCustomPlot::CopyToSLFFile(QString targetSLFFileName, bool deleteFromSrc, else logio->CopyFromFile(a_cslfio,curvename); delete[] curvename; delete logio; - return true; + return true; } void QMyCustomPlot::onAddRect() @@ -4844,113 +4944,113 @@ void QMyCustomPlot::s_ReloadPlot(QString strUuid, QString strSlfName, QString st void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist) { - QString strUuid = vlist.at(0).toString(); - QString strSlfName = vlist.at(1).toString(); - QString strWellName = vlist.at(2).toString(); - QString strTrackName = vlist.at(3).toString(); - QString strLineName = vlist.at(4).toString(); + QString strUuid = vlist.at(0).toString(); + QString strSlfName = vlist.at(1).toString(); + QString strWellName = vlist.at(2).toString(); + QString strTrackName = vlist.at(3).toString(); + QString strLineName = vlist.at(4).toString(); - if (m_strUuid == strUuid && - m_strSlfName == strSlfName && - m_strWellName == strWellName && - m_strTrackName == strTrackName && - m_strLineName == strLineName) - { - QString strProperty = vlist.at(5).toString(); - QVariant varVal = vlist.at(6).toString(); - if ("类型" == strProperty) - { - m_nDrawType = varVal.toInt(); - this->changePropertyWaveUpdate(); - } - else if ("绘制波深度" == strProperty) - { - m_bDrawDepth = varVal.toBool(); - this->changePropertyWaveUpdate(); - } - else if ("绘制波基线" == strProperty) - { - m_bDrawBase = varVal.toBool(); - this->changePropertyWaveUpdate(); - } - else if ("奇偶配色" == strProperty) - { - m_bOddEven = varVal.toBool(); - this->changePropertyWaveUpdate(); - } - else if ("波列基值" == strProperty) - { - m_Base = varVal.toFloat(); - this->changePropertyWaveUpdate(); - } - else if ("波形间隔" == strProperty) - { - m_nWaveJg = varVal.toInt(); - this->changePropertyWaveUpdate(); - } - else if ("波形高度" == strProperty) - { - m_nWaveHei = varVal.toInt(); - this->changePropertyWaveUpdate(); - } - else if ("颜色" == strProperty) - { - m_newColor = varVal.value(); - this->changePropertyWaveUpdate(); - } - else if ("方式" == strProperty) - { - m_nMode = varVal.toFloat(); - this->updateWave(); - } - else if ("左刻度" == strProperty) - { + if (m_strUuid == strUuid && + m_strSlfName == strSlfName && + m_strWellName == strWellName && + m_strTrackName == strTrackName && + m_strLineName == strLineName) + { + QString strProperty = vlist.at(5).toString(); + QVariant varVal = vlist.at(6).toString(); + if ("类型" == strProperty) + { + m_nDrawType = varVal.toInt(); + this->changePropertyWaveUpdate(); + } + else if ("绘制波深度" == strProperty) + { + m_bDrawDepth = varVal.toBool(); + this->changePropertyWaveUpdate(); + } + else if ("绘制波基线" == strProperty) + { + m_bDrawBase = varVal.toBool(); + this->changePropertyWaveUpdate(); + } + else if ("奇偶配色" == strProperty) + { + m_bOddEven = varVal.toBool(); + this->changePropertyWaveUpdate(); + } + else if ("波列基值" == strProperty) + { + m_Base = varVal.toFloat(); + this->changePropertyWaveUpdate(); + } + else if ("波形间隔" == strProperty) + { + m_nWaveJg = varVal.toInt(); + this->changePropertyWaveUpdate(); + } + else if ("波形高度" == strProperty) + { + m_nWaveHei = varVal.toInt(); + this->changePropertyWaveUpdate(); + } + else if ("颜色" == strProperty) + { + m_newColor = varVal.value(); + this->changePropertyWaveUpdate(); + } + else if ("方式" == strProperty) + { + m_nMode = varVal.toFloat(); + this->updateWave(); + } + else if ("左刻度" == strProperty) + { - } - else if ("右刻度" == strProperty) - { - if (m_colorMap) - { - m_fScaleV = varVal.toFloat(); - float f = 264 / m_fScaleV; - m_colorMap->data()->setValueRange(QCPRange(m_fmin, m_fmax*f)); - } - } - else if ("最大振幅" == strProperty) - { - m_MaxRange = varVal.toDouble(); - this->changePropertyWaveUpdate(); - } - else if ("色板" == strProperty) - { - this->setSchemeIndex(varVal.toInt(), m_nColorNum); - } - else if ("变密度颜色级数" == strProperty) - { - this->setSchemeIndex(m_nSchemeIndex, varVal.toInt()); - } - else if ("结论占比%" == strProperty) - { - this->setShowProperty(varVal, 1); - } - else if ("显示位置(cm)" == strProperty) - { - this->setShowProperty(varVal, 2); - } - else if ("显示层号" == strProperty) - { - this->setShowProperty(varVal, 3); - } - else if ("层号字体" == strProperty) - { - this->setShowProperty(varVal, 4); - } - else if ("层号旋转" == strProperty) - { - this->setShowProperty(varVal, 5); - } - this->replot(); - } + } + else if ("右刻度" == strProperty) + { + if (m_colorMap) + { + m_fScaleV = varVal.toFloat(); + float f = 264 / m_fScaleV; + m_colorMap->data()->setValueRange(QCPRange(m_fmin, m_fmax*f)); + } + } + else if ("最大振幅" == strProperty) + { + m_MaxRange = varVal.toDouble(); + this->changePropertyWaveUpdate(); + } + else if ("色板" == strProperty) + { + this->setSchemeIndex(varVal.toInt(), m_nColorNum); + } + else if ("变密度颜色级数" == strProperty) + { + this->setSchemeIndex(m_nSchemeIndex, varVal.toInt()); + } + else if ("结论占比%" == strProperty) + { + this->setShowProperty(varVal, 1); + } + else if ("显示位置(cm)" == strProperty) + { + this->setShowProperty(varVal, 2); + } + else if ("显示层号" == strProperty) + { + this->setShowProperty(varVal, 3); + } + else if ("层号字体" == strProperty) + { + this->setShowProperty(varVal, 4); + } + else if ("层号旋转" == strProperty) + { + this->setShowProperty(varVal, 5); + } + this->replot(); + } } void QMyCustomPlot::s_changeDepthProperty(QVariantList vlist) @@ -5289,25 +5389,25 @@ void QMyCustomPlot::addLayerToPlot(double left_Low, double right_Hight, const QS TransparentGroupResult* QMyCustomPlot::addResultGroup(double left_Low, double right_Hight, QString &strUuid, QString strText /*= ""*/) { - TransparentGroupResult *upGroup = nullptr; - if (strUuid != "") - { - upGroup = (TransparentGroupResult *)m_mapDragGroup.value(strUuid); - } + TransparentGroupResult *upGroup = nullptr; + if (strUuid != "") + { + upGroup = (TransparentGroupResult *)m_mapDragGroup.value(strUuid); + } - strUuid = getUUid(); + strUuid = getUUid(); - // 在初始化代码中addResultToPlot - TransparentGroupResult *dragRect = new TransparentGroupResult(this, upGroup, strUuid); - // 设置初始范围 - dragRect->setRange(left_Low, right_Hight); - //最小宽度 - dragRect->setMinWidth(0.1); - dragRect->setTitle(strText); + // 在初始化代码中addResultToPlot + TransparentGroupResult *dragRect = new TransparentGroupResult(this, upGroup, strUuid); + // 设置初始范围 + dragRect->setRange(left_Low, right_Hight); + //最小宽度 + dragRect->setMinWidth(0.1); + dragRect->setTitle(strText); - m_mapDragGroup[strUuid] = dragRect; + m_mapDragGroup[strUuid] = dragRect; - return dragRect; + return dragRect; } void QMyCustomPlot::addResultToPlot(double left_Low, double right_Hight, QString myResult, QString &strUuid, QString strText) @@ -5319,7 +5419,7 @@ void QMyCustomPlot::addResultToPlot(double left_Low, double right_Hight, QStrin upDragRect = (TransparentDraggableResult *)m_mapDraggable_Result[strUuid]; } - strUuid = getUUid(); + strUuid = getUUid(); // 在初始化代码中 TransparentDraggableResult *dragRect = new TransparentDraggableResult(this, upDragRect, strUuid); @@ -5575,9 +5675,9 @@ void QMyCustomPlot::s_ChangeLeftScale(QString strUuid, QString strSlfName, QStri { m_iX1 = newLeftScale; - double rg = m_iX2 - m_iX1; - double lower = m_iX1 - rg * m_nLeftCross; - double upper = m_iX2 + rg * m_nRightCross; + double rg = m_iX2 - m_iX1; + double lower = m_iX1 - rg * m_nLeftCross; + double upper = m_iX2 + rg * m_nRightCross; yAxis->setRange(lower, upper); // replot(); @@ -5606,10 +5706,10 @@ void QMyCustomPlot::s_ChangeRightScale(QString strUuid, QString strSlfName, QStr { m_iX2 = newRightScale; - double rg = m_iX2 - m_iX1; - double lower = m_iX1 - rg * m_nLeftCross; - double upper = m_iX2 + rg * m_nRightCross; - yAxis->setRange(lower, upper); + double rg = m_iX2 - m_iX1; + double lower = m_iX1 - rg * m_nLeftCross; + double upper = m_iX2 + rg * m_nRightCross; + yAxis->setRange(lower, upper); // replot(); } @@ -8160,580 +8260,580 @@ void QMyCustomPlot::RefreshItems_Jiegutext() void QMyCustomPlot::onOpenEditResult() { - m_bEditor = true; - this->selectionRect()->setPen(Qt::NoPen); - this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式 - this->setSelectionRectMode(QCP::srmSelect); // 鼠标框选 + m_bEditor = true; + this->selectionRect()->setPen(Qt::NoPen); + this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式 + this->setSelectionRectMode(QCP::srmSelect); // 鼠标框选 } void QMyCustomPlot::onCloseEditResult() { - ClearSelectItems(); - m_bEditor = false; - //取消框选 - this->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables); - this->setSelectionRectMode(QCP::srmNone); + ClearSelectItems(); + m_bEditor = false; + //取消框选 + this->setInteractions(QCP::iSelectLegend | QCP::iSelectPlottables); + this->setSelectionRectMode(QCP::srmNone); } void QMyCustomPlot::DeleteItemGroup() { - if (m_strLineName == "RESULT") - { - QStringList listRemove; - QMap::iterator it = m_mapDragGroup.begin(); - for (; it != m_mapDragGroup.end(); ++it) - { - TransparentGroupResult *pGroup = qobject_cast(it.value()); - if (pGroup == nullptr) - continue; - if (pGroup->getSelect()) - listRemove << it.key(); - } + if (m_strLineName == "RESULT") + { + QStringList listRemove; + QMap::iterator it = m_mapDragGroup.begin(); + for (; it != m_mapDragGroup.end(); ++it) + { + TransparentGroupResult *pGroup = qobject_cast(it.value()); + if (pGroup == nullptr) + continue; + if (pGroup->getSelect()) + listRemove << it.key(); + } - for (int i = 0; i < listRemove.size(); i++) - { - TransparentGroupResult *pGroup = qobject_cast(m_mapDragGroup.value(listRemove.at(i))); - if (pGroup == nullptr) - continue; - pGroup->removeAllResult(); - } - SaveToSLF_Result(); - } + for (int i = 0; i < listRemove.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(m_mapDragGroup.value(listRemove.at(i))); + if (pGroup == nullptr) + continue; + pGroup->removeAllResult(); + } + SaveToSLF_Result(); + } } void QMyCustomPlot::updateGroupZone() { - QMap mapSort; - QMap::iterator it = m_mapDragGroup.begin(); - for (; it != m_mapDragGroup.end(); ++it) - { - TransparentGroupResult *pGroup = qobject_cast(it.value()); - if (pGroup == nullptr) - continue; + QMap mapSort; + QMap::iterator it = m_mapDragGroup.begin(); + for (; it != m_mapDragGroup.end(); ++it) + { + TransparentGroupResult *pGroup = qobject_cast(it.value()); + if (pGroup == nullptr) + continue; - mapSort.insert(pGroup->getRange().upper, it.key()); - } - int nZid = 1; - QList listkey = mapSort.keys(); - for (int i = listkey.size() - 1; i >= 0; i--) - { - QString skey = mapSort.value(listkey.at(i)); - TransparentGroupResult *pGroup = qobject_cast(m_mapDragGroup.value(skey)); - if (pGroup == nullptr) - continue; - pGroup->setTitle(QString::number(nZid)); - nZid++; - } - this->replot(); + mapSort.insert(pGroup->getRange().upper, it.key()); + } + int nZid = 1; + QList listkey = mapSort.keys(); + for (int i = listkey.size() - 1; i >= 0; i--) + { + QString skey = mapSort.value(listkey.at(i)); + TransparentGroupResult *pGroup = qobject_cast(m_mapDragGroup.value(skey)); + if (pGroup == nullptr) + continue; + pGroup->setTitle(QString::number(nZid)); + nZid++; + } + this->replot(); - SaveToSLF_Result(); + SaveToSLF_Result(); } bool QMyCustomPlot::SaveToSLF_Result() { - static int isrun = false; - if (isrun) return false; - QString ss = m_strSlfName; - if (ss == "") return false; - isrun = true; + static int isrun = false; + if (isrun) return false; + QString ss = m_strSlfName; + if (ss == "") return false; + isrun = true; - CMemRdWt *logio = new CMemRdWt(); - if (ss == "" || !logio->Open(ss.toStdString().c_str(), CSlfIO::modeReadWrite)) - { - delete logio; - QMessageBox::information(NULL, "提示", "SLF文件打开失败,请检查!!", QMessageBox::Yes); - isrun = false; - return false; - } - int resultGroupSize = m_mapDragGroup.size(); - bool isfirst = false; - int iIndex = logio->OpenTable(m_strLineName.toStdString().c_str()); - if (iIndex < 0) - { - if (!resultGroupSize) { - delete logio; - isrun = false; - return false; - } - iIndex = logio->Open_Set_Table(m_strLineName.toStdString().c_str(), 0, 35, - "NO,SDEP,EDEP,ZONE,RESULTNO,THICK,TT,MDEPTH1,MDEPTH2,MDEPTH3,MDEPTH4,MDEPTH5,MDEPTH6,MDEPTH7,MDEPTH8,MDEPTH9,MDEPTH10,OIL,POOROIL,OILWATER,WATEROIL,GAS,POORGAS,GASWATER,WATERGAS,DEST1,DEST2,DEST3,DEST4,DEST5,DEST6,DEST7,DEST8,DEST9,DEST10,SDEP1,EDEP1,SDEP2,EDEP2,SDEP3,EDEP3,SDEP4,EDEP4,SDEP5,EDEP5,SDEP6,EDEP6,SDEP7,EDEP7,SDEP8,EDEP8,SDEP9,EDEP9,SDEP10,EDEP10", - "4,4,4,8,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,48,48,48,48,48,48,48,48,48,48,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",//字段长度 - "1,4,4,6,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,6,6,6,6,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",//字段类型 - "0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");//字段备注 - isfirst = true; - } - logio->SetTableRecordCount(iIndex, resultGroupSize);//-nn); - if (!resultGroupSize) { - delete logio; - //if (isfirst)AddTableToWellRound(); - isrun = false; - return false; - } - QMap zoneOrder = GetZoneOrder(); + CMemRdWt *logio = new CMemRdWt(); + if (ss == "" || !logio->Open(ss.toStdString().c_str(), CSlfIO::modeReadWrite)) + { + delete logio; + QMessageBox::information(NULL, "提示", "SLF文件打开失败,请检查!!", QMessageBox::Yes); + isrun = false; + return false; + } + int resultGroupSize = m_mapDragGroup.size(); + bool isfirst = false; + int iIndex = logio->OpenTable(m_strLineName.toStdString().c_str()); + if (iIndex < 0) + { + if (!resultGroupSize) { + delete logio; + isrun = false; + return false; + } + iIndex = logio->Open_Set_Table(m_strLineName.toStdString().c_str(), 0, 35, + "NO,SDEP,EDEP,ZONE,RESULTNO,THICK,TT,MDEPTH1,MDEPTH2,MDEPTH3,MDEPTH4,MDEPTH5,MDEPTH6,MDEPTH7,MDEPTH8,MDEPTH9,MDEPTH10,OIL,POOROIL,OILWATER,WATEROIL,GAS,POORGAS,GASWATER,WATERGAS,DEST1,DEST2,DEST3,DEST4,DEST5,DEST6,DEST7,DEST8,DEST9,DEST10,SDEP1,EDEP1,SDEP2,EDEP2,SDEP3,EDEP3,SDEP4,EDEP4,SDEP5,EDEP5,SDEP6,EDEP6,SDEP7,EDEP7,SDEP8,EDEP8,SDEP9,EDEP9,SDEP10,EDEP10", + "4,4,4,8,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,48,48,48,48,48,48,48,48,48,48,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",//字段长度 + "1,4,4,6,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,6,6,6,6,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",//字段类型 + "0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0");//字段备注 + isfirst = true; + } + logio->SetTableRecordCount(iIndex, resultGroupSize);//-nn); + if (!resultGroupSize) { + delete logio; + //if (isfirst)AddTableToWellRound(); + isrun = false; + return false; + } + QMap zoneOrder = GetZoneOrder(); - LAYER_DATA m_Result; - QMap mapSortGroup; - QMap::iterator it = m_mapDragGroup.begin(); - for (; it != m_mapDragGroup.end(); ++it) - { - TransparentGroupResult *pGroup = qobject_cast(it.value()); - if (pGroup == nullptr) - continue; + LAYER_DATA m_Result; + QMap mapSortGroup; + QMap::iterator it = m_mapDragGroup.begin(); + for (; it != m_mapDragGroup.end(); ++it) + { + TransparentGroupResult *pGroup = qobject_cast(it.value()); + if (pGroup == nullptr) + continue; - mapSortGroup.insert(pGroup->getRange().upper, pGroup); - } + mapSortGroup.insert(pGroup->getRange().upper, pGroup); + } - QList listGroup = mapSortGroup.values(); - for (int i = 0; i < listGroup.size(); i++) - { - TransparentGroupResult* pGroup = listGroup.at(i); - if (pGroup == NULL) - continue; - - memset(&m_Result, 0, sizeof(LAYER_DATA)); - m_Result.StartDepth = -pGroup->getRange().upper; - m_Result.EndDepth = -pGroup->getRange().lower; + QList listGroup = mapSortGroup.values(); + for (int i = 0; i < listGroup.size(); i++) + { + TransparentGroupResult* pGroup = listGroup.at(i); + if (pGroup == NULL) + continue; - m_Result.Result = pGroup->getNResult(); + memset(&m_Result, 0, sizeof(LAYER_DATA)); + m_Result.StartDepth = -pGroup->getRange().upper; + m_Result.EndDepth = -pGroup->getRange().lower; - const QVector& vec = pGroup->getVecResult(); - const QMap& mapResult = pGroup->getMapDraggable_Result(); - QVector vecDepth; - QVector vecResult; - //vecDepth << 0.0; - //vecResult << 0; - //QString strRet = ""; - for (int k = 0; k < vec.size(); k++) - { - TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(k))); - if (pret == NULL) - continue; - QCPRange rg = pret->getRange(); - vecDepth << -rg.upper; - QFileInfo finfo(pret->getResult()); - QString s = zoneOrder.value(finfo.baseName()); - //QString str = QString("%1").arg(s.toInt(), 2, 10, QChar('0')); - //strRet += str; - vecResult << s.toInt(); - } - QByteArray btzone = UTF8ToGBK(pGroup->getTitle()); - strcpy(m_Result.Zone, btzone.data()); - QByteArray btrmk = UTF8ToGBK(pGroup->getRemark()); - strcpy(m_Result.Description10, btrmk.data()); - //strcpy(m_Result.szResult, strRet.toStdString().c_str()); - m_Result.Result = 0; - int n = vecDepth.size(); - if (n > 0) - { - m_Result.Result = 10 * m_Result.Result + vecResult.at(0); - } - if (n > 1) - { - m_Result.MDepth1 = vecDepth.at(1); - m_Result.Result = 10 * m_Result.Result + vecResult.at(1); - } - if (n > 2) - { - m_Result.MDepth2 = vecDepth.at(2); - m_Result.Result = 10 * m_Result.Result + vecResult.at(2); - } - if (n > 3) - { - m_Result.MDepth3 = vecDepth.at(3); - m_Result.Result = 10 * m_Result.Result + vecResult.at(3); - } - if (n > 4) - { - m_Result.MDepth4 = vecDepth.at(4); - m_Result.Result = 10 * m_Result.Result + vecResult.at(4); - } - if (n > 5) - { - m_Result.MDepth5 = vecDepth.at(5); - m_Result.Result = 10 * m_Result.Result + vecResult.at(5); - } - if (n > 6) - { - m_Result.MDepth6 = vecDepth.at(6); - m_Result.Result = 10 * m_Result.Result + vecResult.at(6); - } - if (n > 7) - { - m_Result.MDepth7 = vecDepth.at(7); - m_Result.Result = 10 * m_Result.Result + vecResult.at(7); - } - if (n > 8) - { - m_Result.MDepth8 = vecDepth.at(8); - m_Result.Result = 10 * m_Result.Result + vecResult.at(8); - } - if (n > 9) - { - m_Result.MDepth9 = vecDepth.at(9); - m_Result.Result = 10 * m_Result.Result + vecResult.at(9); - } - if (n > 10) - { - m_Result.MDepth10 = vecDepth.at(10); - m_Result.Result = 10 * m_Result.Result + vecResult.at(10); - } - logio->WriteTable(iIndex, i + 1, &m_Result); - } - /* - foreach(WelllogItem*iter, items) - { - if (!iter) continue; - memset(&m_Result, 0, sizeof(LAYER_DATA)); - m_Result.StartDepth = iter->GetTopDepth(); - m_Result.EndDepth = iter->GetBottomDepth(); - if (m_Result.EndDepth - m_Result.StartDepth <= 0) { - continue; - } - OGResultItem* pResult = dynamic_cast(iter); - m_Result.Order = j; - m_Result.Result = 0; - m_Result.MDepth1 = pResult->m_MDepth1; - m_Result.MDepth2 = pResult->m_MDepth2; - m_Result.MDepth3 = pResult->m_MDepth3; - m_Result.MDepth4 = pResult->m_MDepth4; - m_Result.MDepth5 = pResult->m_MDepth5; - m_Result.MDepth6 = pResult->m_MDepth6; - m_Result.MDepth7 = pResult->m_MDepth7; - m_Result.MDepth8 = pResult->m_MDepth8; - m_Result.MDepth9 = pResult->m_MDepth9; - m_Result.MDepth10 = pResult->m_MDepth10; + m_Result.Result = pGroup->getNResult(); - QString innerresult = pResult->GetIntResult(); - if (innerresult != "") m_Result.Result = innerresult.toInt(); - if (m_Result.Result < 0) m_Result.Result = 0; - innerresult = pResult->GetIntResult1(); - if (innerresult != ""&&m_Result.MDepth1) - { - m_Result.Result = 10 * m_Result.Result + innerresult.toInt(); - } - innerresult = pResult->GetIntResult2(); - if (innerresult != ""&&m_Result.MDepth2) - { - m_Result.Result = 10 * m_Result.Result + innerresult.toInt(); - } - innerresult = pResult->GetIntResult3(); - if (innerresult != ""&&m_Result.MDepth3) { - m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); - } - innerresult = pResult->GetIntResult4(); - if (innerresult != ""&&m_Result.MDepth4) { - m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); - } - innerresult = pResult->GetIntResult5(); - if (innerresult != ""&&m_Result.MDepth5) { - m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); - } - innerresult = pResult->GetIntResult6(); - if (innerresult != ""&&m_Result.MDepth6) { - m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); - } - innerresult = pResult->GetIntResult7(); - if (innerresult != ""&&m_Result.MDepth7) { - m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); - } - innerresult = pResult->GetIntResult8(); - if (innerresult != ""&&m_Result.MDepth8) { - m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); - } - innerresult = pResult->GetIntResult9(); - if (innerresult != ""&&m_Result.MDepth9) { - m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); - } - innerresult = pResult->GetIntResult10(); - if (innerresult != ""&&m_Result.MDepth10) { - m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); - } - strcpy(m_Result.Zone, pResult->Zone.toStdString().c_str()); - ComputeTT(m_Result, - pResult->result, - pResult->result1, - pResult->result2, - pResult->result3, - pResult->result4, - pResult->result5, - pResult->result6, - pResult->result7, - pResult->result8, - pResult->result9, - pResult->result10 - ); - strcpy(m_Result.Description1, pResult->Description1.toStdString().c_str()); - strcpy(m_Result.Description2, pResult->Description2.toStdString().c_str()); - strcpy(m_Result.Description3, pResult->Description3.toStdString().c_str()); - strcpy(m_Result.Description4, pResult->Description4.toStdString().c_str()); - strcpy(m_Result.Description5, pResult->Description5.toStdString().c_str()); - strcpy(m_Result.Description6, pResult->Description6.toStdString().c_str()); - strcpy(m_Result.Description7, pResult->Description7.toStdString().c_str()); - strcpy(m_Result.Description8, pResult->Description8.toStdString().c_str()); - strcpy(m_Result.Description9, pResult->Description9.toStdString().c_str()); - strcpy(m_Result.Description10, pResult->Description10.toStdString().c_str()); + const QVector& vec = pGroup->getVecResult(); + const QMap& mapResult = pGroup->getMapDraggable_Result(); + QVector vecDepth; + QVector vecResult; + //vecDepth << 0.0; + //vecResult << 0; + //QString strRet = ""; + for (int k = 0; k < vec.size(); k++) + { + TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(k))); + if (pret == NULL) + continue; + QCPRange rg = pret->getRange(); + vecDepth << -rg.upper; + QFileInfo finfo(pret->getResult()); + QString s = zoneOrder.value(finfo.baseName()); + //QString str = QString("%1").arg(s.toInt(), 2, 10, QChar('0')); + //strRet += str; + vecResult << s.toInt(); + } + QByteArray btzone = UTF8ToGBK(pGroup->getTitle()); + strcpy(m_Result.Zone, btzone.data()); + QByteArray btrmk = UTF8ToGBK(pGroup->getRemark()); + strcpy(m_Result.Description10, btrmk.data()); + //strcpy(m_Result.szResult, strRet.toStdString().c_str()); + m_Result.Result = 0; + int n = vecDepth.size(); + if (n > 0) + { + m_Result.Result = 10 * m_Result.Result + vecResult.at(0); + } + if (n > 1) + { + m_Result.MDepth1 = vecDepth.at(1); + m_Result.Result = 10 * m_Result.Result + vecResult.at(1); + } + if (n > 2) + { + m_Result.MDepth2 = vecDepth.at(2); + m_Result.Result = 10 * m_Result.Result + vecResult.at(2); + } + if (n > 3) + { + m_Result.MDepth3 = vecDepth.at(3); + m_Result.Result = 10 * m_Result.Result + vecResult.at(3); + } + if (n > 4) + { + m_Result.MDepth4 = vecDepth.at(4); + m_Result.Result = 10 * m_Result.Result + vecResult.at(4); + } + if (n > 5) + { + m_Result.MDepth5 = vecDepth.at(5); + m_Result.Result = 10 * m_Result.Result + vecResult.at(5); + } + if (n > 6) + { + m_Result.MDepth6 = vecDepth.at(6); + m_Result.Result = 10 * m_Result.Result + vecResult.at(6); + } + if (n > 7) + { + m_Result.MDepth7 = vecDepth.at(7); + m_Result.Result = 10 * m_Result.Result + vecResult.at(7); + } + if (n > 8) + { + m_Result.MDepth8 = vecDepth.at(8); + m_Result.Result = 10 * m_Result.Result + vecResult.at(8); + } + if (n > 9) + { + m_Result.MDepth9 = vecDepth.at(9); + m_Result.Result = 10 * m_Result.Result + vecResult.at(9); + } + if (n > 10) + { + m_Result.MDepth10 = vecDepth.at(10); + m_Result.Result = 10 * m_Result.Result + vecResult.at(10); + } + logio->WriteTable(iIndex, i + 1, &m_Result); + } + /* + foreach(WelllogItem*iter, items) + { + if (!iter) continue; + memset(&m_Result, 0, sizeof(LAYER_DATA)); + m_Result.StartDepth = iter->GetTopDepth(); + m_Result.EndDepth = iter->GetBottomDepth(); + if (m_Result.EndDepth - m_Result.StartDepth <= 0) { + continue; + } + OGResultItem* pResult = dynamic_cast(iter); + m_Result.Order = j; + m_Result.Result = 0; + m_Result.MDepth1 = pResult->m_MDepth1; + m_Result.MDepth2 = pResult->m_MDepth2; + m_Result.MDepth3 = pResult->m_MDepth3; + m_Result.MDepth4 = pResult->m_MDepth4; + m_Result.MDepth5 = pResult->m_MDepth5; + m_Result.MDepth6 = pResult->m_MDepth6; + m_Result.MDepth7 = pResult->m_MDepth7; + m_Result.MDepth8 = pResult->m_MDepth8; + m_Result.MDepth9 = pResult->m_MDepth9; + m_Result.MDepth10 = pResult->m_MDepth10; - m_Result.Sdep1 = pResult->m_SDEP1; - m_Result.Edep1 = pResult->m_EDEP1; - m_Result.Sdep2 = pResult->m_SDEP2; - m_Result.Edep2 = pResult->m_EDEP2; - m_Result.Sdep3 = pResult->m_SDEP3; - m_Result.Edep3 = pResult->m_EDEP3; - m_Result.Sdep4 = pResult->m_SDEP4; - m_Result.Edep4 = pResult->m_EDEP4; - m_Result.Sdep5 = pResult->m_SDEP5; - m_Result.Edep5 = pResult->m_EDEP5; - m_Result.Sdep6 = pResult->m_SDEP6; - m_Result.Edep6 = pResult->m_EDEP6; - m_Result.Sdep7 = pResult->m_SDEP7; - m_Result.Edep7 = pResult->m_EDEP7; - m_Result.Sdep8 = pResult->m_SDEP8; - m_Result.Edep8 = pResult->m_EDEP8; - m_Result.Sdep9 = pResult->m_SDEP9; - m_Result.Edep9 = pResult->m_EDEP9; - m_Result.Sdep10 = pResult->m_SDEP10; - m_Result.Edep10 = pResult->m_EDEP10; + QString innerresult = pResult->GetIntResult(); + if (innerresult != "") m_Result.Result = innerresult.toInt(); + if (m_Result.Result < 0) m_Result.Result = 0; + innerresult = pResult->GetIntResult1(); + if (innerresult != ""&&m_Result.MDepth1) + { + m_Result.Result = 10 * m_Result.Result + innerresult.toInt(); + } + innerresult = pResult->GetIntResult2(); + if (innerresult != ""&&m_Result.MDepth2) + { + m_Result.Result = 10 * m_Result.Result + innerresult.toInt(); + } + innerresult = pResult->GetIntResult3(); + if (innerresult != ""&&m_Result.MDepth3) { + m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); + } + innerresult = pResult->GetIntResult4(); + if (innerresult != ""&&m_Result.MDepth4) { + m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); + } + innerresult = pResult->GetIntResult5(); + if (innerresult != ""&&m_Result.MDepth5) { + m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); + } + innerresult = pResult->GetIntResult6(); + if (innerresult != ""&&m_Result.MDepth6) { + m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); + } + innerresult = pResult->GetIntResult7(); + if (innerresult != ""&&m_Result.MDepth7) { + m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); + } + innerresult = pResult->GetIntResult8(); + if (innerresult != ""&&m_Result.MDepth8) { + m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); + } + innerresult = pResult->GetIntResult9(); + if (innerresult != ""&&m_Result.MDepth9) { + m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); + } + innerresult = pResult->GetIntResult10(); + if (innerresult != ""&&m_Result.MDepth10) { + m_Result.Result = m_Result.Result * 10 + innerresult.toInt(); + } + strcpy(m_Result.Zone, pResult->Zone.toStdString().c_str()); + ComputeTT(m_Result, + pResult->result, + pResult->result1, + pResult->result2, + pResult->result3, + pResult->result4, + pResult->result5, + pResult->result6, + pResult->result7, + pResult->result8, + pResult->result9, + pResult->result10 + ); + strcpy(m_Result.Description1, pResult->Description1.toStdString().c_str()); + strcpy(m_Result.Description2, pResult->Description2.toStdString().c_str()); + strcpy(m_Result.Description3, pResult->Description3.toStdString().c_str()); + strcpy(m_Result.Description4, pResult->Description4.toStdString().c_str()); + strcpy(m_Result.Description5, pResult->Description5.toStdString().c_str()); + strcpy(m_Result.Description6, pResult->Description6.toStdString().c_str()); + strcpy(m_Result.Description7, pResult->Description7.toStdString().c_str()); + strcpy(m_Result.Description8, pResult->Description8.toStdString().c_str()); + strcpy(m_Result.Description9, pResult->Description9.toStdString().c_str()); + strcpy(m_Result.Description10, pResult->Description10.toStdString().c_str()); - logio->WriteTable(iIndex, j + 1, &m_Result); - j++; - } - */ - logio->CloseTable(iIndex); - delete logio; - isrun = false; + m_Result.Sdep1 = pResult->m_SDEP1; + m_Result.Edep1 = pResult->m_EDEP1; + m_Result.Sdep2 = pResult->m_SDEP2; + m_Result.Edep2 = pResult->m_EDEP2; + m_Result.Sdep3 = pResult->m_SDEP3; + m_Result.Edep3 = pResult->m_EDEP3; + m_Result.Sdep4 = pResult->m_SDEP4; + m_Result.Edep4 = pResult->m_EDEP4; + m_Result.Sdep5 = pResult->m_SDEP5; + m_Result.Edep5 = pResult->m_EDEP5; + m_Result.Sdep6 = pResult->m_SDEP6; + m_Result.Edep6 = pResult->m_EDEP6; + m_Result.Sdep7 = pResult->m_SDEP7; + m_Result.Edep7 = pResult->m_EDEP7; + m_Result.Sdep8 = pResult->m_SDEP8; + m_Result.Edep8 = pResult->m_EDEP8; + m_Result.Sdep9 = pResult->m_SDEP9; + m_Result.Edep9 = pResult->m_EDEP9; + m_Result.Sdep10 = pResult->m_SDEP10; + m_Result.Edep10 = pResult->m_EDEP10; - return true; + logio->WriteTable(iIndex, j + 1, &m_Result); + j++; + } + */ + logio->CloseTable(iIndex); + delete logio; + isrun = false; + + return true; } TransparentGroupResult* QMyCustomPlot::getCurGroupResult(double x_val) { - TransparentGroupResult *pClickGroup = NULL; - QObjectList objList = m_mapDragGroup.values(); - for (int i = 0; i < objList.size(); i++) - { - TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); - if (pGroup == nullptr) - continue; - QCPRange rg = pGroup->getRange(); - if (x_val <= rg.upper && x_val >= rg.lower) - { - pClickGroup = pGroup; - break; - } - } - return pClickGroup; + TransparentGroupResult *pClickGroup = NULL; + QObjectList objList = m_mapDragGroup.values(); + for (int i = 0; i < objList.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); + if (pGroup == nullptr) + continue; + QCPRange rg = pGroup->getRange(); + if (x_val <= rg.upper && x_val >= rg.lower) + { + pClickGroup = pGroup; + break; + } + } + return pClickGroup; } QMap QMyCustomPlot::getSelectGroupResult() { - QMap mapsort; - QObjectList objList = m_mapDragGroup.values(); - for (int i = 0; i < objList.size(); i++) - { - TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); - if (pGroup == nullptr || !pGroup->getSelect()) - continue; - QCPRange rg = pGroup->getRange(); - mapsort.insert(-rg.upper, pGroup); - } - return mapsort; + QMap mapsort; + QObjectList objList = m_mapDragGroup.values(); + for (int i = 0; i < objList.size(); i++) + { + TransparentGroupResult *pGroup = qobject_cast(objList.at(i)); + if (pGroup == nullptr || !pGroup->getSelect()) + continue; + QCPRange rg = pGroup->getRange(); + mapsort.insert(-rg.upper, pGroup); + } + return mapsort; } void QMyCustomPlot::segmentationInnerLayer() { - //获取鼠标点位置 - double y_pos = mLastPos.y(); - //转为图像位置 - double x_val = xAxis->pixelToCoord(y_pos); - // 获取当前点击的解释结论组 - TransparentGroupResult *pClickGroup = getCurGroupResult(x_val); - if (pClickGroup == NULL) - return; - pClickGroup->segmentationInnerLayer(x_val); + //获取鼠标点位置 + double y_pos = mLastPos.y(); + //转为图像位置 + double x_val = xAxis->pixelToCoord(y_pos); + // 获取当前点击的解释结论组 + TransparentGroupResult *pClickGroup = getCurGroupResult(x_val); + if (pClickGroup == NULL) + return; + pClickGroup->segmentationInnerLayer(x_val); - SaveToSLF_Result(); + SaveToSLF_Result(); } void QMyCustomPlot::segmentationIndependentLayer() { - //获取鼠标点位置 - double y_pos = mLastPos.y(); - //转为图像位置 - double x_val = xAxis->pixelToCoord(y_pos); - // 获取当前点击的解释结论组 - TransparentGroupResult *pClickGroup = getCurGroupResult(x_val); - if (pClickGroup == NULL) - return; + //获取鼠标点位置 + double y_pos = mLastPos.y(); + //转为图像位置 + double x_val = xAxis->pixelToCoord(y_pos); + // 获取当前点击的解释结论组 + TransparentGroupResult *pClickGroup = getCurGroupResult(x_val); + if (pClickGroup == NULL) + return; - int nidx = pClickGroup->getDraggableResultIndex(x_val); - if (nidx < 0) - return; + int nidx = pClickGroup->getDraggableResultIndex(x_val); + if (nidx < 0) + return; - double dupper; - double dlower; + double dupper; + double dlower; - const QVector& vec = pClickGroup->getVecResult(); - const QMap& mapResult = pClickGroup->getMapDraggable_Result(); + const QVector& vec = pClickGroup->getVecResult(); + const QMap& mapResult = pClickGroup->getMapDraggable_Result(); - QVector> g1; - for (int i = 0; i <= nidx; i++) - { - TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(i))); - if (pret == NULL) - continue; + QVector> g1; + for (int i = 0; i <= nidx; i++) + { + TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(i))); + if (pret == NULL) + continue; - QCPRange rg = pret->getRange(); - if (i == 0) - dupper = rg.upper; + QCPRange rg = pret->getRange(); + if (i == 0) + dupper = rg.upper; - if (i == nidx) - { - dlower = x_val; - rg.lower = x_val; - g1 << qMakePair(rg, pret->getResult()); - } - else - { - g1 << qMakePair(rg, pret->getResult()); - } - } - QString strUuid = ""; - if (g1.size() > 0) - { - TransparentGroupResult* pGroup = this->addResultGroup(dlower, dupper, strUuid); - strUuid = ""; - for (int i = 0; i < g1.size(); i++) - { - const QPair& r = g1.at(i); - pGroup->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid); - } - } + if (i == nidx) + { + dlower = x_val; + rg.lower = x_val; + g1 << qMakePair(rg, pret->getResult()); + } + else + { + g1 << qMakePair(rg, pret->getResult()); + } + } + QString strUuid = ""; + if (g1.size() > 0) + { + TransparentGroupResult* pGroup = this->addResultGroup(dlower, dupper, strUuid); + strUuid = ""; + for (int i = 0; i < g1.size(); i++) + { + const QPair& r = g1.at(i); + pGroup->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid); + } + } - QVector> g2; - for (int i = nidx; i < vec.size(); i++) - { - TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(i))); - if (pret == NULL) - continue; + QVector> g2; + for (int i = nidx; i < vec.size(); i++) + { + TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(i))); + if (pret == NULL) + continue; - QCPRange rg = pret->getRange(); - if (i == vec.size() - 1) - dlower = rg.lower; + QCPRange rg = pret->getRange(); + if (i == vec.size() - 1) + dlower = rg.lower; - if (i == nidx) - { - dupper = x_val; - rg.upper = x_val; - g2 << qMakePair(rg, pret->getResult()); - } - else - { - g2 << qMakePair(rg, pret->getResult()); - } - } - if (g2.size() > 0) - { - TransparentGroupResult* pGroup2 = this->addResultGroup(dlower, dupper, strUuid); - strUuid = ""; - for (int i = 0; i < g2.size(); i++) - { - const QPair& r = g2.at(i); - pGroup2->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid); - } - } - pClickGroup->removeAllResult(); - this->replot(); - SaveToSLF_Result(); + if (i == nidx) + { + dupper = x_val; + rg.upper = x_val; + g2 << qMakePair(rg, pret->getResult()); + } + else + { + g2 << qMakePair(rg, pret->getResult()); + } + } + if (g2.size() > 0) + { + TransparentGroupResult* pGroup2 = this->addResultGroup(dlower, dupper, strUuid); + strUuid = ""; + for (int i = 0; i < g2.size(); i++) + { + const QPair& r = g2.at(i); + pGroup2->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid); + } + } + pClickGroup->removeAllResult(); + this->replot(); + SaveToSLF_Result(); } void QMyCustomPlot::splitIndependentLayer() { - //获取鼠标点位置 - double y_pos = mLastPos.y(); - //转为图像位置 - double x_val = xAxis->pixelToCoord(y_pos); - // 获取当前点击的解释结论组 - TransparentGroupResult *pClickGroup = getCurGroupResult(x_val); - if (pClickGroup == NULL) - return; + //获取鼠标点位置 + double y_pos = mLastPos.y(); + //转为图像位置 + double x_val = xAxis->pixelToCoord(y_pos); + // 获取当前点击的解释结论组 + TransparentGroupResult *pClickGroup = getCurGroupResult(x_val); + if (pClickGroup == NULL) + return; - // 符合层拆分成独立层 - pClickGroup->splitIndependentLayer(); - // 删除原来的复合层 - pClickGroup->removeAllResult(); - this->replot(); - SaveToSLF_Result(); + // 符合层拆分成独立层 + pClickGroup->splitIndependentLayer(); + // 删除原来的复合层 + pClickGroup->removeAllResult(); + this->replot(); + SaveToSLF_Result(); } void QMyCustomPlot::megResultLayer() { - if (QMessageBox::information(NULL, QObject::tr("提示"), QObject::tr("合并为复合层?"), tr("是"), tr("否")) != 0) return; - // 筛选出选中的Group, 并且排序 - QMap mapsort = this->getSelectGroupResult(); - if (mapsort.size() <= 0) - return; + if (QMessageBox::information(NULL, QObject::tr("提示"), QObject::tr("合并为复合层?"), tr("是"), tr("否")) != 0) return; + // 筛选出选中的Group, 并且排序 + QMap mapsort = this->getSelectGroupResult(); + if (mapsort.size() <= 0) + return; - // 取出Group下面的DraggableResult,并且调整 lower,删除原来选中的Group - double dupper; - double dlower; - QVector> gr; - QList listGroup = mapsort.values(); - for (int i = 0; i < listGroup.size(); i++) - { - TransparentGroupResult* pGroup = listGroup.at(i); - if (pGroup == NULL) - continue; + // 取出Group下面的DraggableResult,并且调整 lower,删除原来选中的Group + double dupper; + double dlower; + QVector> gr; + QList listGroup = mapsort.values(); + for (int i = 0; i < listGroup.size(); i++) + { + TransparentGroupResult* pGroup = listGroup.at(i); + if (pGroup == NULL) + continue; - if (i == 0) - { - dupper = pGroup->getRange().upper; - } - if (i == listGroup.size() - 1) - { - dlower = pGroup->getRange().lower; - } + if (i == 0) + { + dupper = pGroup->getRange().upper; + } + if (i == listGroup.size() - 1) + { + dlower = pGroup->getRange().lower; + } - const QVector& vec = pGroup->getVecResult(); - const QMap& mapResult = pGroup->getMapDraggable_Result(); + const QVector& vec = pGroup->getVecResult(); + const QMap& mapResult = pGroup->getMapDraggable_Result(); - for (int k = 0; k < vec.size(); k++) - { - TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(k))); - if (pret == NULL) - continue; - QCPRange rg = pret->getRange(); - if (i + 1 < listGroup.size()) - { - TransparentGroupResult* pLowGroup = listGroup.at(i+1); - if (pGroup) - rg.lower = pLowGroup->getRange().upper; - } - gr << qMakePair(rg, pret->getResult()); - } - pGroup->removeAllResult(); - } + for (int k = 0; k < vec.size(); k++) + { + TransparentDraggableResult* pret = qobject_cast(mapResult.value(vec.at(k))); + if (pret == NULL) + continue; + QCPRange rg = pret->getRange(); + if (i + 1 < listGroup.size()) + { + TransparentGroupResult* pLowGroup = listGroup.at(i+1); + if (pGroup) + rg.lower = pLowGroup->getRange().upper; + } + gr << qMakePair(rg, pret->getResult()); + } + pGroup->removeAllResult(); + } - // 生成新的Group - QString strUuid = ""; - TransparentGroupResult* pNewG = this->addResultGroup(dlower, dupper, strUuid); - strUuid = ""; - for (int i = 0; i < gr.size(); i++) - { - const QPair& r = gr.at(i); - pNewG->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid); - } - this->replot(); - SaveToSLF_Result(); + // 生成新的Group + QString strUuid = ""; + TransparentGroupResult* pNewG = this->addResultGroup(dlower, dupper, strUuid); + strUuid = ""; + for (int i = 0; i < gr.size(); i++) + { + const QPair& r = gr.at(i); + pNewG->addResultToPlot(r.first.lower, r.first.upper, r.second, strUuid); + } + this->replot(); + SaveToSLF_Result(); } bool QMyCustomPlot::getIsEditor() { - if (m_strLineName == "RESULT") - { - return m_bEditor; - } - return true; + if (m_strLineName == "RESULT") + { + return m_bEditor; + } + return true; } //沉积相 @@ -9257,7 +9357,7 @@ void QMyCustomPlot::RefreshItems_Fac(bool bAdd) } //重新加载 - LoadFromSLF_Fac(m_strSlfName, m_strLineName, bAdd); + LoadFromSLF_Fac(m_strSlfName, m_strLineName, bAdd); //属性清空 //PropertyService()->InitCurrentViewInfo(); diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 27ef7d6..8117ae6 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -210,6 +210,7 @@ public: QMap m_mapDraggable_SelectRect; QMap m_mapDraggable_RightList; QMap m_mapDraggable_CorePhysics; // 岩心分析 + QMap m_mapDraggable_CrackObject; // 裂缝 QObject* m_SelectShiftLine=nullptr;//当前选中的分段线 @@ -468,6 +469,9 @@ public slots: void deleteCorePhysics(); //全部清空 void refreshCorePhysics(); //刷新数据 + //右键--裂缝 + void addCrackObject(); // 添加裂缝 + //右键--编辑井壁取心 void addItem_SWallCore(); //增加井壁取心 void moveItems_SWallCore(); //平移水平位置