From 1f1870862dac92e5e1aa132562c475fe0a4e49a9 Mon Sep 17 00:00:00 2001 From: jiayulong Date: Wed, 15 Apr 2026 17:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=95=E5=A3=81=E5=8F=96=E5=BF=83=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=EF=BC=8C=E6=8C=89=E7=85=A7=E8=80=81=E7=89=88=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/PropertyWidget.cpp | 5 +++-- logPlus/TransparentDraggableSwallCore.cpp | 15 ++++++++++----- logPlus/qmycustomplot.cpp | 23 ++++++++++++++--------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index 440e19f..3897a48 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -1080,8 +1080,9 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant double h = SideWallCoreHeight * g_dPixelPerCm; //0.4cm //40; double x1 = m_tdSwallCore->mPlot->xAxis->coordToPixel(-lower); // - double Depth2 = m_tdSwallCore->mPlot->xAxis->pixelToCoord(x1-h); - m_tdSwallCore->setRange(-lower, Depth2); + double Depth1 = m_tdSwallCore->mPlot->xAxis->pixelToCoord(x1+h/2.0); + double Depth2 = m_tdSwallCore->mPlot->xAxis->pixelToCoord(x1-h/2.0); + m_tdSwallCore->setRange(Depth1, Depth2); //保存 m_tdSwallCore->mPlot->SaveToSLF_SwallCore(); } diff --git a/logPlus/TransparentDraggableSwallCore.cpp b/logPlus/TransparentDraggableSwallCore.cpp index 410a5f4..4ea1943 100644 --- a/logPlus/TransparentDraggableSwallCore.cpp +++ b/logPlus/TransparentDraggableSwallCore.cpp @@ -11,8 +11,8 @@ TransparentDraggableSwallCore::TransparentDraggableSwallCore(QMyCustomPlot *pare m_strUuid = strUuid; //图片高度(需要根据高度宏定义,重新计算) -// double h = SideWallCoreHeight * g_dPixelPerCm; //0.4cm //40; -// m_fImageHeight = h/2.0; + double h = SideWallCoreHeight * g_dPixelPerCm; //0.4cm //40; + m_fImageHeight = h/2.0; // initRect(); @@ -506,7 +506,9 @@ void TransparentDraggableSwallCore::onMousePress(QMouseEvent *event) //event->accept(); double low = mRect->topLeft->coords().x(); - //double hight = mRect->bottomRight->coords().x(); + double hight = mRect->bottomRight->coords().x(); + double depth = (low+hight)/2.0; + QString ColorImage = ""; int ind=mPlot->colorinds_SWallCore.indexOf(mstrTitle); if (ind>-1&&indcolors_SWallCore.size()) @@ -517,7 +519,7 @@ void TransparentDraggableSwallCore::onMousePress(QMouseEvent *event) ColorImage=""; } - PropertyService()->initSwallCoreItemProperty(this, low, m_Lith, m_Oil, ColorImage, m_fLeftSpace / g_dPixelPerCm, 1, mstrTitle.toInt()); + PropertyService()->initSwallCoreItemProperty(this, depth, m_Lith, m_Oil, ColorImage, m_fLeftSpace / g_dPixelPerCm, 1, mstrTitle.toInt()); QMenu menu(nullptr); menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除选中对象", this, &TransparentDraggableSwallCore::onDelRect); @@ -735,6 +737,9 @@ void TransparentDraggableSwallCore::onMouseRelease(QMouseEvent *event) { double low = mRect->topLeft->coords().x(); + double hight = mRect->bottomRight->coords().x(); + double depth = (low+hight)/2.0; + QString ColorImage = ""; int ind=mPlot->colorinds_SWallCore.indexOf(mstrTitle); if (ind>-1&&indcolors_SWallCore.size()) @@ -745,7 +750,7 @@ void TransparentDraggableSwallCore::onMouseRelease(QMouseEvent *event) ColorImage=""; } - PropertyService()->initSwallCoreItemProperty(this, low, m_Lith, m_Oil, ColorImage, m_fLeftSpace / g_dPixelPerCm, 1, mstrTitle.toInt()); + PropertyService()->initSwallCoreItemProperty(this, depth, m_Lith, m_Oil, ColorImage, m_fLeftSpace / g_dPixelPerCm, 1, mstrTitle.toInt()); if(m_bChange) { diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 14289f5..5511574 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -2459,10 +2459,12 @@ bool QMyCustomPlot::SaveToSLF_SwallCore() // QCPRange tmpRange = pDraggableRect->getRange(); float fSDepth = -tmpRange.lower; + float fEDepth = -tmpRange.upper; + float fDepth = (fSDepth+fEDepth)/2.0; if(fSDepth == listSDepth[i])//按顺序写入 { memset(&m_Result,0,sizeof(WALLCORE_DATA)); - m_Result.Depth=fSDepth; + m_Result.Depth=fDepth; m_Result.Order=i+1; QString name,lithname,oilname,colorname; @@ -5455,11 +5457,12 @@ void QMyCustomPlot::addSwallCoreToPlot(double Depth, QString LithologyImage, QSt //左侧空白 dragRect->m_fLeftSpace = Sideleft*g_dPixelPerCm; // 设置初始范围 - double h = 32;//SideWallCoreHeight * g_dPixelPerCm; //0.4cm //40; + double h = SideWallCoreHeight * g_dPixelPerCm; //0.4cm //40;//32; double x1 = this->xAxis->coordToPixel(Depth); // - double Depth2 = this->xAxis->pixelToCoord(x1-h); - dragRect->setRange(Depth, Depth2, bRefresh); + double Depth1 = this->xAxis->pixelToCoord(x1+h/2.0); + double Depth2 = this->xAxis->pixelToCoord(x1-h/2.0); + dragRect->setRange(Depth1, Depth2, bRefresh); // 可选:设置颜色 dragRect->setColor(QColor(255, 255, 255, 80)); // 半透明红色255, 100, 100, 80 //最小宽度 @@ -10044,14 +10047,16 @@ void QMyCustomPlot::resetPosition_SwallCore() //-------------------------- // 设置初始范围 - double h = 32; - double Depth = tmpRange.lower; - double x1 = this->xAxis->coordToPixel(Depth); - double Depth2 = this->xAxis->pixelToCoord(x1-h); + //double h = 32; + double Depth1 = tmpRange.lower; + double Depth2 = tmpRange.upper; + +// double x1 = this->xAxis->coordToPixel(Depth); +// double Depth2 = this->xAxis->pixelToCoord(x1-h); //-------------------------- // - pDraggableRect->setRange(Depth, Depth2, false); + pDraggableRect->setRange(Depth1, Depth2, false); } }