From 3ccb9d67f26837690a1cea5df2ff9cff97b60707 Mon Sep 17 00:00:00 2001 From: jiayulong Date: Wed, 7 Jan 2026 17:39:27 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=BF=9B=E8=A1=8C=E6=B2=89=E7=A7=AF=E7=9B=B8?= =?UTF-8?q?=E7=BB=98=E5=9B=BE=EF=BC=8C2.=E6=90=AD=E5=BB=BA=E2=80=9C?= =?UTF-8?q?=E6=B0=94=E6=B5=8B/FMT/=E5=B0=84=E5=AD=94/=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E2=80=9D=E7=BB=98=E5=9B=BE=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CallManage/CallManage.h | 6 + logPlus/ObjGeostratums.cpp | 4 + logPlus/ObjGeostratums.h | 5 +- logPlus/ObjTubingstringResult.cpp | 178 +++++++ logPlus/ObjTubingstringResult.h | 50 ++ logPlus/TransparentDraggableFac.cpp | 3 +- logPlus/TransparentDraggableGeoLith.cpp | 4 +- logPlus/TransparentDraggableGujing.cpp | 6 +- logPlus/TransparentDraggableMFac.cpp | 2 +- logPlus/TransparentDraggablePhase.cpp | 2 +- logPlus/TransparentDraggableRect.cpp | 2 +- logPlus/TransparentDraggableResult.cpp | 6 +- logPlus/TransparentDraggableSwallCore.cpp | 2 +- logPlus/formdraw.cpp | 194 ++++++++ logPlus/formdraw.h | 7 + logPlus/formtrack.cpp | 82 ++++ logPlus/formtrack.h | 6 +- logPlus/formwell.cpp | 12 +- logPlus/logPlus.pro | 4 + logPlus/mainwindowcurve.cpp | 24 + logPlus/mainwindowcurve.h | 2 + logPlus/qmycustomplot.cpp | 28 +- logPlus/qmycustomplot.h | 3 + logPlus/transparentdraggableGuan.cpp | 570 ++++++++++++++++++++++ logPlus/transparentdraggableGuan.h | 88 ++++ logPlus/transparentdraggableimage.cpp | 6 +- 26 files changed, 1274 insertions(+), 22 deletions(-) create mode 100644 logPlus/ObjTubingstringResult.cpp create mode 100644 logPlus/ObjTubingstringResult.h create mode 100644 logPlus/transparentdraggableGuan.cpp create mode 100644 logPlus/transparentdraggableGuan.h diff --git a/CallManage/CallManage.h b/CallManage/CallManage.h index 2e6cf78..8e1737e 100644 --- a/CallManage/CallManage.h +++ b/CallManage/CallManage.h @@ -67,10 +67,16 @@ signals: //地质层位道 void sig_AddGeoSection(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0); + + //气测/FMT/射孔/文本 + void sig_AddJiegutext(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0); //沉积相 void sig_AddLogface(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0); + //套管组件 + void sig_AddTubingstring(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0); + //新建波列 void sig_AddWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName); //删除波列 diff --git a/logPlus/ObjGeostratums.cpp b/logPlus/ObjGeostratums.cpp index a224921..d5ad14d 100644 --- a/logPlus/ObjGeostratums.cpp +++ b/logPlus/ObjGeostratums.cpp @@ -10,6 +10,10 @@ CObjGeostratums::CObjGeostratums() { } +CObjGeostratums::~CObjGeostratums() +{ +} + bool CObjGeostratums::LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString csCurve) { LAYER_DATA m_Result; diff --git a/logPlus/ObjGeostratums.h b/logPlus/ObjGeostratums.h index 01f718b..6a3c93b 100644 --- a/logPlus/ObjGeostratums.h +++ b/logPlus/ObjGeostratums.h @@ -1,5 +1,5 @@ -#ifndef PAI_FRAME_OBJGEOSTRATUMS_H -#define PAI_FRAME_OBJGEOSTRATUMS_H +#ifndef OBJGEOSTRATUMS_H +#define OBJGEOSTRATUMS_H #include #include "qmycustomplot.h" @@ -14,6 +14,7 @@ class CObjGeostratums :public QObject Q_OBJECT public: CObjGeostratums(); + virtual ~CObjGeostratums(); virtual bool LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString csCurve); diff --git a/logPlus/ObjTubingstringResult.cpp b/logPlus/ObjTubingstringResult.cpp new file mode 100644 index 0000000..9d6fe5f --- /dev/null +++ b/logPlus/ObjTubingstringResult.cpp @@ -0,0 +1,178 @@ +#include +#include "ObjTubingstringResult.h" +#include "MemRdWt.h" +#include "geometryutils.h" + +CObjTubingstringResult::CObjTubingstringResult() +{ + if(zoneOrder.size()==0) + { + zoneOrder=GetZoneOrder(QString("TubTools.ini")); + } + + cclimgpath=GetSymbolDir()+"\\管柱组件\\"; +} + +CObjTubingstringResult::~CObjTubingstringResult() +{ + m_pResultList.clear(); +} + +bool CObjTubingstringResult::LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString csCurve) +{ + m_pResultList.clear(); + +// //隐藏刻度 +// widget->xAxis->setTicks(false); +// widget->yAxis->setTicks(false); +// widget->xAxis2->setTicks(false); +// widget->yAxis2->setTicks(false); + + Slf_JIEGUPOS *m_pResult=NULL; + CMemRdWt *logio=new CMemRdWt(); + if(strSlfName==""||!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead)) + { + delete logio; +// QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); + return false; + } + + + int iIndex=logio->OpenTable(csCurve.toStdString().c_str()); + if(iIndex>-1) { + int count=logio->GetTableRecordCount(iIndex); + //int fieldnum=logio->GetTableFieldCount(iIndex); + int len=logio->GetTableRecordLength(iIndex); + m_pResult=(Slf_JIEGUPOS *)new char[len+1]; + char buf[200]; + logio->IsChange=true; + + bool bDrawGuanzhu = false; + for(int i=0;iReadTable(iIndex,i+1,m_pResult); + + Slf_JIEGUPOS result; + result.Depth=m_pResult->Depth; + result.Order=m_pResult->Order; + result.Number=m_pResult->Number; + m_pResultList.append(result); + + // + double depth=m_pResult->Depth; + int Order=m_pResult->Order; + int Number=m_pResult->Number; + + if(bDrawGuanzhu == false) + { + //还没有画管柱 + if(Number == zoneOrder.value("管底部").toInt()|| + Number == zoneOrder.value("油管深").toInt()|| + Number == zoneOrder.value("喇叭口").toInt()|| + Number == zoneOrder.value("剌叭口").toInt()) + { + bDrawGuanzhu = true;//画管柱 + + QString shotimgfile=GetSymbolDir()+"\\管柱组件\\管柱.png"; + //QImage shotimg(shotimgfile); + //pPainter->drawImage(rect,shotimg); + + double lY1 = widget->yAxis->range().lower;//+10 + double lY2 = widget->yAxis->range().upper; + QCPItemPixmap *mPixmap; + mPixmap = new QCPItemPixmap(widget); + //mPixmap->setPixmap(QPixmap(":/image/file.png")); // 设置图片 + mPixmap->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式 + mPixmap->setLayer("overlay"); // 确保在最上层 + // + float upper = widget->xAxis->range().upper; + mPixmap->topLeft->setCoords(upper, lY1 + (lY2-lY1-m_Oguan)/2.0); + mPixmap->bottomRight->setCoords(-depth, lY2 - (lY2-lY1-m_Oguan)/2.0); + mPixmap->setPixmap(QPixmap(shotimgfile)); // 设置图片 + } + } + } + logio->CloseTable(iIndex); + delete m_pResult; + } + delete logio; + + for(int i=0; ixAxis->coordToPixel(-depth)-h/2.0; + float lower = widget->xAxis->coordToPixel(-depth)+h/2.0; + float newUpper = widget->xAxis->pixelToCoord(upper); + float newLower = widget->xAxis->pixelToCoord(lower); + widget->addGuanToPlot(newLower, newUpper, cclimgfile, in); + +// QString cclimgfile=cclimgpath+name+".png"; +// double lY1 = widget->yAxis->range().lower;//+10 +// double lY2 = widget->yAxis->range().upper; +// QCPItemPixmap *mPixmap; +// mPixmap = new QCPItemPixmap(widget); +// mPixmap->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式 +// mPixmap->setLayer("overlay"); // 确保在最上层 +// // +// float upper = widget->xAxis->coordToPixel(-depth)-h/2.0; +// float lower = widget->xAxis->coordToPixel(-depth)+h/2.0; +// float newUpper = widget->xAxis->pixelToCoord(upper); +// float newLower = widget->xAxis->pixelToCoord(lower); +// mPixmap->topLeft->setCoords(newUpper, lY1 + (lY2-lY1-in)/2.0); +// mPixmap->bottomRight->setCoords(newLower, lY2 - (lY2-lY1-in)/2.0); +// mPixmap->setPixmap(QPixmap(cclimgfile)); // 设置图片 +} diff --git a/logPlus/ObjTubingstringResult.h b/logPlus/ObjTubingstringResult.h new file mode 100644 index 0000000..60430d0 --- /dev/null +++ b/logPlus/ObjTubingstringResult.h @@ -0,0 +1,50 @@ +/** +* @file ObjTubingstringResult.h +* @brief 套管 +* @date +* @author: +*/ + +#ifndef OBTubingstringResultITEM_H +#define OBTubingstringResultITEM_H + +#include +#include "qmycustomplot.h" + +struct Slf_JIEGUPOS { + int Order; + float Depth; + float Number; + char Dest[64]; +}; + +/** +* @class +* @brief +* @see +*/ +class CObjTubingstringResult :public QObject +{ + Q_OBJECT +public: + CObjTubingstringResult(); + virtual ~CObjTubingstringResult(); + + +public: + bool LoadFromSLF(QMyCustomPlot *widget, QString strSlfName, QString csCurve); + void drawOne(QMyCustomPlot *widget, Slf_JIEGUPOS result); + +public: + QMap zoneOrder; + float m_Oguan = 63.5; + float m_Oind = 121.36; + bool m_bDrawCCL = false; + QString cclimgpath=""; + + QList m_pResultList; +private: + +}; + +#endif diff --git a/logPlus/TransparentDraggableFac.cpp b/logPlus/TransparentDraggableFac.cpp index 9bc1855..84c206e 100644 --- a/logPlus/TransparentDraggableFac.cpp +++ b/logPlus/TransparentDraggableFac.cpp @@ -76,7 +76,7 @@ void TransparentDraggableFac::setColor(const QColor &color) { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图 @@ -155,6 +155,7 @@ void TransparentDraggableFac::initRect() //mItemTitle->position->setType(QCPItemPosition::ptAxisRectRatio); mItemTitle->position->setCoords(0.5, 0); mItemTitle->setLayer("overlay"); + mItemTitle->setRotation(90); } void TransparentDraggableFac::updateHandles() diff --git a/logPlus/TransparentDraggableGeoLith.cpp b/logPlus/TransparentDraggableGeoLith.cpp index 425ed92..05203a4 100644 --- a/logPlus/TransparentDraggableGeoLith.cpp +++ b/logPlus/TransparentDraggableGeoLith.cpp @@ -79,7 +79,7 @@ TransparentDraggableGeoLith::TransparentDraggableGeoLith(QMyCustomPlot *parentPl { mstrTitle = strTitle; mItemTitle->setText(mstrTitle); - mPlot->replot(); + //mPlot->replot(); } //设置解释结论 @@ -404,7 +404,7 @@ TransparentDraggableGeoLith::TransparentDraggableGeoLith(QMyCustomPlot *parentPl { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图 diff --git a/logPlus/TransparentDraggableGujing.cpp b/logPlus/TransparentDraggableGujing.cpp index f4cf19b..51a3063 100644 --- a/logPlus/TransparentDraggableGujing.cpp +++ b/logPlus/TransparentDraggableGujing.cpp @@ -81,7 +81,7 @@ void TransparentDraggableGujing::setTitle(QString strTitle) { mstrTitle = strTitle; mItemTitle->setText(mstrTitle); - mPlot->replot(); + //mPlot->replot(); } //设置解释结论 @@ -165,7 +165,7 @@ void TransparentDraggableGujing::drawResult(double left_Low, double right_Hight, mPixmap->setPixmap(QPixmap(val)); // 设置图片 } - mPlot->replot(); + //mPlot->replot(); } // 设置矩形范围 @@ -207,7 +207,7 @@ void TransparentDraggableGujing::setColor(const QColor &color) { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图 diff --git a/logPlus/TransparentDraggableMFac.cpp b/logPlus/TransparentDraggableMFac.cpp index b9ef041..36c1275 100644 --- a/logPlus/TransparentDraggableMFac.cpp +++ b/logPlus/TransparentDraggableMFac.cpp @@ -76,7 +76,7 @@ void TransparentDraggableMFac::setColor(const QColor &color) { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图 diff --git a/logPlus/TransparentDraggablePhase.cpp b/logPlus/TransparentDraggablePhase.cpp index 297f318..fe216a5 100644 --- a/logPlus/TransparentDraggablePhase.cpp +++ b/logPlus/TransparentDraggablePhase.cpp @@ -76,7 +76,7 @@ void TransparentDraggablePhase::setColor(const QColor &color) { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图 diff --git a/logPlus/TransparentDraggableRect.cpp b/logPlus/TransparentDraggableRect.cpp index a1fb9c1..b4616f3 100644 --- a/logPlus/TransparentDraggableRect.cpp +++ b/logPlus/TransparentDraggableRect.cpp @@ -72,7 +72,7 @@ void TransparentDraggableRect::setColor(const QColor &color) { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图 diff --git a/logPlus/TransparentDraggableResult.cpp b/logPlus/TransparentDraggableResult.cpp index 14283b2..d9c8a0a 100644 --- a/logPlus/TransparentDraggableResult.cpp +++ b/logPlus/TransparentDraggableResult.cpp @@ -86,7 +86,7 @@ void TransparentDraggableResult::setTitle(QString strTitle) { mstrTitle = strTitle; mItemTitle->setText(mstrTitle); - mPlot->replot(); + //mPlot->replot(); } //设置解释结论 @@ -158,7 +158,7 @@ void TransparentDraggableResult::drawResult(double left_Low, double right_Hight, } - mPlot->replot(); + //mPlot->replot(); } // 设置矩形范围 @@ -213,7 +213,7 @@ QCPRange TransparentDraggableResult::getRange() void TransparentDraggableResult::setColor(const QColor &color) { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图 diff --git a/logPlus/TransparentDraggableSwallCore.cpp b/logPlus/TransparentDraggableSwallCore.cpp index ea52c5d..77b52fe 100644 --- a/logPlus/TransparentDraggableSwallCore.cpp +++ b/logPlus/TransparentDraggableSwallCore.cpp @@ -377,7 +377,7 @@ void TransparentDraggableSwallCore::setColor(const QColor &color) { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图 diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index d0be682..beffd18 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -10,6 +10,7 @@ #include "Gradient.h" #include "PickFrac.h" #include "DrawFac.h" +#include "ObjTubingstringResult.h" #include "ObjGeostratums.h" //以下参数从配置文件读取 @@ -81,8 +82,15 @@ FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) : //地质层位道 connect(CallManage::getInstance(), SIGNAL(sig_AddGeoSection(QString, QString, QString, QString, QString, int)), this, SLOT(s_addGeoSection(QString, QString, QString, QString, QString,int))); + //气测/FMT/射孔/文本 + connect(CallManage::getInstance(), SIGNAL(sig_AddJiegutext(QString, QString, QString, QString, QString, int)), this, SLOT(s_addJiegutext(QString, QString, QString, QString, QString,int))); + //沉积相 connect(CallManage::getInstance(), SIGNAL(sig_AddLogface(QString, QString, QString, QString, QString, int)), this, SLOT(s_addLogface(QString, QString, QString, QString, QString,int))); + + //套管组件 + connect(CallManage::getInstance(), SIGNAL(sig_AddTubingstring(QString, QString, QString, QString, QString, int)), this, SLOT(s_addTubingstring(QString, QString, QString, QString, QString,int))); + } FormDraw::~FormDraw() @@ -1428,6 +1436,99 @@ void FormDraw::s_addGeoSection(QString strUuid, QString strSlfName, QString strW m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "GeoSectionObject"); } +//气测/FMT/射孔/文本 +void FormDraw::s_addJiegutext(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW) +{ + //井名&道名不一致 + if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName) + { + } + else + { + return; + } + + if(m_listLineName.contains(strLineName)) + { + qDebug() << "FormDraw strLineName already exist! " << strLineName; + return; + } + + // + QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strLineName); + curv->m_strUuid = m_strUuid; + //背景设置成透明色 + curv->setBackground(Qt::transparent); + curv->setStyleSheet("background: transparent;"); + // + double dHight = 0; + dHight = (g_iY2-g_iY1)*100.0/(double)g_iScale * g_dPixelPerCm; + if(g_iShow==1) + { + //显示刻度 + dHight = dHight+30; + } + qDebug() << "FormDraw dHight=" << QString::number((int)dHight); + if(dHight>32767) + { + dHight = 32767; + } + + curv->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184 + curv->show(); + + //------------------- + int iMyWidth = curv->axisRect(0)->width(); + + m_LeftVal = 0; + m_RightVal = iMyWidth; + + float vmax = iMyWidth; + float vmin = 0; + curv->m_iX1 = vmin; + curv->m_iX2 = vmax; + curv->m_iY1 = g_iY1; + curv->m_iY2 = g_iY2; + // + curv->xAxis->setRange(vmin, vmax); + curv->yAxis->setRange(g_iY1, g_iY2); + curv->axisRect()->setupFullAxesBox(); + // + curv->xAxis->ticker()->setTickCount(10);//x个主刻度 + curv->yAxis->ticker()->setTickCount(60);//y个主刻度 + + //对调XY轴,在最前面设置 + QCPAxis *yAxis = curv->yAxis; + QCPAxis *xAxis = curv->xAxis; + curv->xAxis = yAxis; + curv->yAxis = xAxis; + + //隐藏刻度 + curv->xAxis->setTicks(false); + curv->yAxis->setTicks(false); + curv->xAxis2->setTicks(false); + curv->yAxis2->setTicks(false); + + //气测/FMT/射孔/文本 + QString strWaveName = "TUBTOOLS"; + CObjTubingstringResult *objTubingstringResult = new CObjTubingstringResult(); + objTubingstringResult->LoadFromSLF(curv, strSlfName, strWaveName); + + // + connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); + + // + m_listLineName.push_back(strLineName); + + QString strAliasName = "气测/FMT/射孔/文本"; + QString strUnit = ""; + QColor newlineColor=QColor(0,0,0); + double width=2; + QString strScaleType = ""; + //道-对象 + m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "TubingstringObject"); +} + //沉积相 void FormDraw::s_addLogface(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW) { @@ -1514,6 +1615,99 @@ void FormDraw::s_addLogface(QString strUuid, QString strSlfName, QString strWell m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "LogfaceObject"); } +//套管组件 +void FormDraw::s_addTubingstring(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW) +{ + //井名&道名不一致 + if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName) + { + } + else + { + return; + } + + if(m_listLineName.contains(strLineName)) + { + qDebug() << "FormDraw strLineName already exist! " << strLineName; + return; + } + + // + QMyCustomPlot *curv = new QMyCustomPlot(this, strSlfName, strWellName, strTrackName, strLineName); + curv->m_strUuid = m_strUuid; + //背景设置成透明色 + curv->setBackground(Qt::transparent); + curv->setStyleSheet("background: transparent;"); + // + double dHight = 0; + dHight = (g_iY2-g_iY1)*100.0/(double)g_iScale * g_dPixelPerCm; + if(g_iShow==1) + { + //显示刻度 + dHight = dHight+30; + } + qDebug() << "FormDraw dHight=" << QString::number((int)dHight); + if(dHight>32767) + { + dHight = 32767; + } + + curv->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184 + curv->show(); + + //------------------- + int iMyWidth = curv->axisRect(0)->width(); + + m_LeftVal = 0; + m_RightVal = iMyWidth; + + float vmax = iMyWidth; + float vmin = 0; + curv->m_iX1 = vmin; + curv->m_iX2 = vmax; + curv->m_iY1 = g_iY1; + curv->m_iY2 = g_iY2; + // + curv->xAxis->setRange(vmin, vmax); + curv->yAxis->setRange(g_iY1, g_iY2); + curv->axisRect()->setupFullAxesBox(); + // + curv->xAxis->ticker()->setTickCount(10);//x个主刻度 + curv->yAxis->ticker()->setTickCount(60);//y个主刻度 + + //对调XY轴,在最前面设置 + QCPAxis *yAxis = curv->yAxis; + QCPAxis *xAxis = curv->xAxis; + curv->xAxis = yAxis; + curv->yAxis = xAxis; + + //隐藏刻度 + curv->xAxis->setTicks(false); + curv->yAxis->setTicks(false); + curv->xAxis2->setTicks(false); + curv->yAxis2->setTicks(false); + + //套管组件 + QString strWaveName = "TUBTOOLS"; + CObjTubingstringResult *objTubingstringResult = new CObjTubingstringResult(); + objTubingstringResult->LoadFromSLF(curv, strSlfName, strWaveName); + + // + connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); + + // + m_listLineName.push_back(strLineName); + + QString strAliasName = "套管组件"; + QString strUnit = ""; + QColor newlineColor=QColor(0,0,0); + double width=2; + QString strScaleType = ""; + //道-对象 + m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "TubingstringObject"); +} + void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName, double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle) { diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index 68e7fb0..06cd857 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -212,6 +212,10 @@ public slots: void s_addDrawImage(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW); //裂缝 void s_addCrack(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW); + + //气测/FMT/射孔/文本 + void s_addJiegutext(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW); + //地质层位道 void s_addGeoSection(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW); @@ -219,6 +223,9 @@ public slots: //沉积相 void s_addLogface(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW); + //套管组件 + void s_addTubingstring(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW); + // void s_addWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName); void s_delWave(QString strUuid, QString strWellName, QString strTrackName, QString strLineName); diff --git a/logPlus/formtrack.cpp b/logPlus/formtrack.cpp index ec0fe5c..708a392 100644 --- a/logPlus/formtrack.cpp +++ b/logPlus/formtrack.cpp @@ -83,10 +83,18 @@ FormTrack::FormTrack(QWidget *parent, QString strWellName, QString strTrackName) connect(this, SIGNAL(sig_AddGeoSection(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), this, SLOT(s_addGeoSection(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString))); + //气测/FMT/射孔/文本 + connect(this, SIGNAL(sig_AddJiegutext(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), + this, SLOT(s_addJiegutext(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString))); + //沉积相 connect(this, SIGNAL(sig_AddLogface(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), this, SLOT(s_addLogface(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString))); + //套管组件 + connect(this, SIGNAL(sig_AddTubingstring(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), + this, SLOT(s_addTubingstring(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString))); + //曲线选中,置顶 connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString))); @@ -159,11 +167,19 @@ void FormTrack::Add(QString strSlfName, QString strWellName, QString strTrackNam else if(strType=="GeoSectionObject") { emit sig_AddGeoSection(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); + } + else if(strType=="JiegutextObject") + { + emit sig_AddJiegutext(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); } else if(strType=="LogfaceObject") { emit sig_AddLogface(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); } + else if(strType=="TubingstringObject") + { + emit sig_AddTubingstring(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); + } } void FormTrack::setDrawDt(QStringList listdt, float vmax, float vmin) @@ -630,6 +646,39 @@ void FormTrack::s_addGeoSection(QString strSlfName, QString strWellName, QString ui->tableWidget->setCellWidget(row, 0, formInfo); } +void FormTrack::s_addJiegutext(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType) +{ + qDebug() << "FormTrack s_addJiegutext"; + + ui->tableWidget->m_strUuid = m_strUuid; + int row = ui->tableWidget->rowCount(); + ui->tableWidget->setRowCount(row + 1); + + //避免出现小滚动条 + //ui->tableWidget->resize(g_iOneWidth, 100*(row + 1)+10); + //this->resize(g_iOneWidth, 100*(row + 1)+30); + + //曲线信息栏 + FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); + formInfo->m_strUuid = m_strUuid; + formInfo->m_strAliasName = strAliasName; + formInfo->m_strUnit = strUnit; + formInfo->m_strScaleType = strScaleType; + formInfo->m_strType = "JiegutextObject"; + formInfo->m_nJg = 2; + formInfo->setLineWidth(dWidth); + formInfo->setVMax(vmax); + formInfo->setVMin(vmin); + formInfo->setFrontColor(QColor(0,0,0)); + formInfo->setBackColor(QColor(255,255,255)); + //设置高度 + ui->tableWidget->setRowHeight(row, 100); + //单元格委托 + //ui->tableWidget->setItemDelegateForRow(row, m_delegate); + // + ui->tableWidget->setCellWidget(row, 0, formInfo); +} + void FormTrack::s_addLogface(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType) { qDebug() << "FormTrack s_addLogface"; @@ -663,6 +712,39 @@ void FormTrack::s_addLogface(QString strSlfName, QString strWellName, QString st ui->tableWidget->setCellWidget(row, 0, formInfo); } +void FormTrack::s_addTubingstring(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType) +{ + qDebug() << "FormTrack s_addTubingstring"; + + ui->tableWidget->m_strUuid = m_strUuid; + int row = ui->tableWidget->rowCount(); + ui->tableWidget->setRowCount(row + 1); + + //避免出现小滚动条 + //ui->tableWidget->resize(g_iOneWidth, 100*(row + 1)+10); + //this->resize(g_iOneWidth, 100*(row + 1)+30); + + //曲线信息栏 + FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); + formInfo->m_strUuid = m_strUuid; + formInfo->m_strAliasName = strAliasName; + formInfo->m_strUnit = strUnit; + formInfo->m_strScaleType = strScaleType; + formInfo->m_strType = "TubingstringObject"; + formInfo->m_nJg = 2; + formInfo->setLineWidth(dWidth); + formInfo->setVMax(vmax); + formInfo->setVMin(vmin); + formInfo->setFrontColor(QColor(0,0,0)); + formInfo->setBackColor(QColor(255,255,255)); + //设置高度 + ui->tableWidget->setRowHeight(row, 100); + //单元格委托 + //ui->tableWidget->setItemDelegateForRow(row, m_delegate); + // + ui->tableWidget->setCellWidget(row, 0, formInfo); +} + QJsonObject FormTrack::makeJson() { // 创建根对象 diff --git a/logPlus/formtrack.h b/logPlus/formtrack.h index 142c63f..6e93096 100644 --- a/logPlus/formtrack.h +++ b/logPlus/formtrack.h @@ -79,7 +79,9 @@ signals: void sig_AddDrawImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void sig_AddCrack(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void sig_AddGeoSection(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); - void sig_AddLogface(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); + void sig_AddJiegutext(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); + void sig_AddLogface(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); + void sig_AddTubingstring(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); public slots: @@ -95,7 +97,9 @@ public slots: void s_addDrawImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void s_addCrack(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void s_addGeoSection(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); + void s_addJiegutext(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void s_addLogface(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); + void s_addTubingstring(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); diff --git a/logPlus/formwell.cpp b/logPlus/formwell.cpp index 28ca9d8..8393d2e 100644 --- a/logPlus/formwell.cpp +++ b/logPlus/formwell.cpp @@ -191,11 +191,21 @@ void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfNa //地质层位道 emit CallManage::getInstance()->sig_AddGeoSection(m_strUuid, strSlfName, strWellName, strTrackName, strLineName); } - else if(strType=="LogfaceObject") + else if(strType=="JiegutextObject") + { + //气测/FMT/射孔/文本 + emit CallManage::getInstance()->sig_AddJiegutext(m_strUuid, strSlfName, strWellName, strTrackName, strLineName); + } + else if(strType=="LogfaceObject") { //沉积相 emit CallManage::getInstance()->sig_AddLogface(m_strUuid, strSlfName, strWellName, strTrackName, strLineName); } + else if(strType=="TubingstringObject") + { + //套管组件 + emit CallManage::getInstance()->sig_AddTubingstring(m_strUuid, strSlfName, strWellName, strTrackName, strLineName); + } } //ui->tableWidget->resizeColumnsToContents(); // 调整列宽以适应内容 diff --git a/logPlus/logPlus.pro b/logPlus/logPlus.pro index 1c51fe4..3ad095d 100644 --- a/logPlus/logPlus.pro +++ b/logPlus/logPlus.pro @@ -36,6 +36,7 @@ SOURCES += \ InDefTableDlg.cpp \ InterfaceWidget.cpp \ ObjGeostratums.cpp \ + ObjTubingstringResult.cpp \ PickFrac.cpp \ PropertyWidget.cpp \ QCPSizeHandle.cpp \ @@ -70,6 +71,7 @@ SOURCES += \ qtcommonclass.cpp \ qtprojectwidgets.cpp \ totalTitleBar.cpp \ + transparentdraggableGuan.cpp \ transparentdraggableimage.cpp \ variantfactory.cpp \ variantmanager.cpp @@ -85,6 +87,7 @@ HEADERS += \ InDefTableDlg.h \ InterfaceWidget.h \ ObjGeostratums.h \ + ObjTubingstringResult.h \ PickFrac.h \ PropertyWidget.h \ QCPSizeHandle.h \ @@ -118,6 +121,7 @@ HEADERS += \ qtcommonclass.h \ qtprojectwidgets.h \ totalTitleBar.h \ + transparentdraggableGuan.h \ transparentdraggableimage.h \ variantfactory.h \ variantmanager.h diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index dd3f664..8b9ff1d 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -386,8 +386,10 @@ void MainWindowCurve::initToolBar() connect(m_deviAc, &QAction::triggered, this, &MainWindowCurve::s_Denv);//井斜方位图 connect(m_electric_imagingAc, &QAction::triggered, this, &MainWindowCurve::s_DrawImage);//图像 connect(m_GeoSectionAc, &QAction::triggered, this, &MainWindowCurve::s_NewGeoSection);//地质层位道 + connect(m_jiegutextAc, &QAction::triggered, this, &MainWindowCurve::s_NewJiegutext);//气测/FMT/射孔/文本 connect(m_logfaceAc, &QAction::triggered, this, &MainWindowCurve::s_NewLogface);//沉积相 + connect(m_TubingstringAc, &QAction::triggered, this, &MainWindowCurve::s_NewTubingstring);//套管组件 } @@ -1278,6 +1280,17 @@ void MainWindowCurve::s_NewGeoSection() NewWellAndTrack(sret.at(0), sret.at(1), "LAYER_DATA", "GeoSectionObject"); } +//气测/FMT/射孔/文本 +void MainWindowCurve::s_NewJiegutext() +{ + QStringList sret = this->getSelectWell(); + if(sret.length() <= 0) + return; + + //新建井+道+曲线(首条) + NewWellAndTrack(sret.at(0), sret.at(1), "GASLOG", "JiegutextObject"); +} + //沉积相 void MainWindowCurve::s_NewLogface() { @@ -1289,6 +1302,17 @@ void MainWindowCurve::s_NewLogface() NewWellAndTrack(sret.at(0), sret.at(1), "LITHA", "LogfaceObject"); } +//套管组件 +void MainWindowCurve::s_NewTubingstring() +{ + QStringList sret = this->getSelectWell(); + if(sret.length() <= 0) + return; + + //新建井+道+曲线(首条) + NewWellAndTrack(sret.at(0), sret.at(1), "TUBTOOLS", "TubingstringObject"); +} + void MainWindowCurve::s_NewTrackChangeWidth(QString strWellName) { qDebug() << "MainWindowCurve s_NewTrackChangeWidth"; diff --git a/logPlus/mainwindowcurve.h b/logPlus/mainwindowcurve.h index d73bb2e..71b09d2 100644 --- a/logPlus/mainwindowcurve.h +++ b/logPlus/mainwindowcurve.h @@ -130,7 +130,9 @@ public slots: void s_Denv(); // 井斜方位图 void s_DrawImage(); // 图像 成图 void s_NewGeoSection(); // 地质层位道 + void s_NewJiegutext(); // 气测/FMT/射孔/文本 void s_NewLogface(); // 沉积相 + void s_NewTubingstring(); // 套管组件 // void s_Save();//保存 diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index fc9ebbb..7821ea5 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -10,6 +10,7 @@ #include "TransparentDraggableMFac.h" #include "TransparentDraggablePhase.h" #include "TransparentDraggableFac.h" +#include "transparentdraggableGuan.h" #include "qtcommonclass.h" //是否隐藏刻度 @@ -449,7 +450,7 @@ void QMyCustomPlot::addSwallCoreToPlot(double Depth, QString LithologyImage, QSt m_mapDraggable_SwallCore[strUuid] = dragRect; //刷新 - this->replot(); + //this->replot(); } void QMyCustomPlot::addGeoLithToPlot(double left_Low, double right_Hight, const QString myLith, const QString myOil, const QString myColor) @@ -474,7 +475,7 @@ void QMyCustomPlot::addGeoLithToPlot(double left_Low, double right_Hight, const m_mapDraggable_GeoLith[strUuid] = dragRect; //刷新 - this->replot(); + //this->replot(); } void QMyCustomPlot::addGujingToPlot(double left_Low, double right_Hight, const QString strResult) @@ -554,6 +555,29 @@ void QMyCustomPlot::addFacToPlot(double left_Low, double right_Hight, const QStr m_mapDraggableFac[strUuid] = dragRect; } +//套管 +void QMyCustomPlot::addGuanToPlot(double left_Low, double right_Hight, const QString imagePath, float in) +{ + QtCommonClass *qtCommon = new QtCommonClass(this); + QString strUuid = qtCommon->getUUid(); + + // 在初始化代码中 + TransparentDraggableGuan *dragRect = new TransparentDraggableGuan(this, strUuid); + //长度 + dragRect->setOin(in); + //图片,提前设值,后面setRange改变 + dragRect->setResult(imagePath); + // 设置初始范围 + dragRect->setRange(left_Low, right_Hight); + // 可选:设置颜色 + dragRect->setColor(QColor(255, 255, 255, 80)); // 半透明红色 + //最小宽度 + dragRect->setMinWidth(0.1); + //dragRect->setTitle(strText); + + m_mapDraggable_Guan[strUuid] = dragRect; +} + void QMyCustomPlot::onResetZoom() { diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index f1815f8..8f54c3a 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -78,6 +78,7 @@ public: QMap m_mapDraggableMFac; QMap m_mapDraggablePhase; QMap m_mapDraggableFac; + QMap m_mapDraggable_Guan; public slots: void slot_time(); @@ -102,6 +103,8 @@ public: void addPhaseToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor=QColor(255, 255, 255, 80)); void addFacToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor=QColor(255, 255, 255, 80)); + void addGuanToPlot(double left_Low, double right_Hight, const QString imagePath, float in); + public slots: void s_LineClicked(int index); void onResetZoom(); diff --git a/logPlus/transparentdraggableGuan.cpp b/logPlus/transparentdraggableGuan.cpp new file mode 100644 index 0000000..12a67ff --- /dev/null +++ b/logPlus/transparentdraggableGuan.cpp @@ -0,0 +1,570 @@ +#include "transparentdraggableGuan.h" + + +extern double g_dPixelPerCm;//每厘米像素数 +//static GeoIndicatorGenerator m_drawGeo; + +TransparentDraggableGuan::TransparentDraggableGuan(QMyCustomPlot *parentPlot, QString strUuid, double minWidth, QString strTitle) + : QObject(parentPlot), mPlot(parentPlot), /*mstrTitle(strTitle),*/ mMinWidth(minWidth) +{ + m_strUuid = strUuid; + // + initRect(); +} + +TransparentDraggableGuan::~TransparentDraggableGuan() +{ + if(mPlot) { + // mPlot->removeItem(mRect); + // mPlot->removeItem(mLeftHandle); + // mPlot->removeItem(mRightHandle); + } +} + + +void TransparentDraggableGuan::DrawSVGNormal(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout) +{ + QString svg=svgFileName; + QRectF boundingRect = painter->transform().mapRect(borderRect); + painter->save(); + QTransform transform; + transform.reset(); + if (!IsWellSectonHorizonLayout) + { + painter->setWorldTransform(transform); + } + else + { + } + QPixmap tiledmap(svg); + QRect border(boundingRect.left(),boundingRect.top(),boundingRect.width(),boundingRect.height()); + painter->drawPixmap(border,tiledmap); + painter->restore(); +} +//拉伸 +void TransparentDraggableGuan::DrawSVGSteched(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout) +{ + QString svg=svgFileName; + QSvgRenderer m_SvgRenderer; + m_SvgRenderer.load(svg); + m_SvgRenderer.render(painter,borderRect); +} +//平铺 +void TransparentDraggableGuan::DrawSVGTiled(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout) +{ + QString svg=svgFileName; + QRectF boundingRect = painter->transform().mapRect(borderRect); + painter->save(); + QTransform transform; + transform.reset(); + if (!IsWellSectonHorizonLayout) + { + painter->setWorldTransform(transform); + } + else + { + } + QPixmap tiledmap(svg); + painter->drawTiledPixmap(boundingRect,tiledmap); + painter->restore(); +} + + + +//设置最小宽度 +void TransparentDraggableGuan::setMinWidth(double minWidth) +{ + mMinWidth = minWidth; +} + +//设置外径长 +void TransparentDraggableGuan::setOin(float in) +{ + mIn = in; +} + +////设置标题 +//void TransparentDraggableGuan::setTitle(QString strTitle) +//{ +// mstrTitle = strTitle; +// mItemTitle->setText(mstrTitle); +// //mPlot->replot(); +//} + +//设置解释结论 +void TransparentDraggableGuan::setResult(QString filePath) +{ + m_Result = filePath; + mPixmap->setPixmap(QPixmap(filePath)); // 设置图片 +} + +void TransparentDraggableGuan::drawResult(double left_Low, double right_Hight, double lY1, double lY2) +{ + if(m_Result=="") + { + return; + } + + double x1 = mPlot->xAxis->coordToPixel(left_Low); + double x2 = mPlot->xAxis->coordToPixel(right_Hight); + double y1 = mPlot->yAxis->coordToPixel(lY1); + double y2 = mPlot->yAxis->coordToPixel(lY2); + + // + QString filePath = m_Result; + // + QString strLast = filePath.right(4); + if(strLast.toLower()==".svg") + { + QString path,filename; + GetWellNameAndPath(filePath, filename, path); + QString basename = filename; + + QString val=filePath; + QImage image(y2-y1, x1-x2,QImage::Format_RGB32); + QPainter painter(&image); + QRectF fillRect(0,0, y2-y1, x1-x2); + painter.fillRect(fillRect,Qt::white); + //拉伸 + DrawSVGSteched(&painter,filePath,fillRect,0); + //平铺 + //DrawSVGTiled(&painter,filePath,fillRect,0); + //正常 + //DrawSVGNormal(&painter,filePath,fillRect,0); + + val=GetImagePath()+"TempNew"; + QDir ss; + if(!ss.exists(val)) { + ss.mkdir(val); + } + val+=QDir::separator(); + val+=basename+".png"; + image.save(val); + + // + mPixmap->setPixmap(QPixmap(val)); // 设置图片 + } + else + { + mPixmap->setPixmap(QPixmap(filePath)); // 设置图片 + +// QString path,filename; +// GetWellNameAndPath(filePath, filename, path); +// QString basename = filename; + +// QString val=filePath; +// QImage image(y2-y1, x1-x2,QImage::Format_RGB32); +// QPainter painter(&image); +// QRectF fillRect(0,0, y2-y1, x1-x2); +// painter.fillRect(fillRect,Qt::white); +// //平铺 +// DrawSVGNormal(&painter,filePath,fillRect,0); + +// val=GetImagePath()+"TempNew"; +// QDir ss; +// if(!ss.exists(val)) { +// ss.mkdir(val); +// } +// val+=QDir::separator(); +// val+=basename+".png"; +// image.save(val); + +// // +// mPixmap->setPixmap(QPixmap(val)); // 设置图片 + } + + //mPlot->replot(); +} + +// 设置矩形范围 +void TransparentDraggableGuan::setRange(double left_Low, double right_Hight) +{ + if(left_Low >= right_Hight) return; + + double lY1 = mPlot->yAxis->range().lower;//+10 + double lY2 = mPlot->yAxis->range().upper; + mRect->topLeft->setCoords(left_Low, lY1 + (lY2-lY1-mIn)/2.0); + mRect->bottomRight->setCoords(right_Hight, lY2 - (lY2-lY1-mIn)/2.0); + + //位置与rect不一样,否则图像反转 + mPixmap->topLeft->setCoords(right_Hight, lY1 + (lY2-lY1-mIn)/2.0); + mPixmap->bottomRight->setCoords(left_Low, lY2 - (lY2-lY1-mIn)/2.0); + //drawResult(left_Low, right_Hight, lY1, lY2); + + //mItemTitle->position->setCoords(0.5, 0.5); + // 设置父锚点,定位点 + //mItemTitle->position->setParentAnchor(mRect->bottom); +// mItemTitle->position->setCoords((mRect->topLeft->coords().x() + mRect->bottomRight->coords().x())/2, +// (mRect->topLeft->coords().y() + mRect->bottomRight->coords().y())/2); // 设置文本在矩形中心位置 + + //mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper); + //mRect->bottomRight->setCoords(right, mPlot->yAxis->range().lower); + + updateHandles(); + mPlot->replot(); +} + +// 获取当前范围 +QCPRange TransparentDraggableGuan::getRange() +{ + return QCPRange(mRect->topLeft->coords().x(), mRect->bottomRight->coords().x()); +} + +// 设置矩形颜色 +void TransparentDraggableGuan::setColor(const QColor &color) +{ + mRect->setBrush(QBrush(color)); + mRect->setPen(QPen(color.darker())); + //mPlot->replot(); +} + +// 删除框图 +void TransparentDraggableGuan::deleteRect() +{ + if(mPlot) { + + // mRect->deleteLater(); + // mLeftHandle->deleteLater(); + // mRightHandle->deleteLater(); + // mPixmap->deleteLater(); + + mPlot->m_mapDraggable_Guan.remove(m_strUuid); + + mPlot->removeItem(mRect); +// mPlot->removeItem(mLeftHandle); +// mPlot->removeItem(mRightHandle); + mPlot->removeItem(mPixmap); +// mPlot->removeItem(mItemTitle); + + mPlot->replot(); + this->deleteLater(); + + // + // //避免二次绘制框图 + // mPlot->m_bDrawRect = false; + // mDragMode = DragNone; + // //取消选中框 + // mPlot->selectionRect()->cancel(); + // mPlot->replot(); + // mPlot->selectionRect()->mActive=true; + } +} + + +void TransparentDraggableGuan::initRect() +{ + // 创建透明矩形 + mRect = new QCPItemRect(mPlot); + mRect->setLayer("overlay"); // 确保在最上层 + mRect->setBrush(QBrush(QColor(255, 255, 255, 50))); // 半透明蓝色 + mRect->setPen(QPen(QColor(70, 70, 255, 200))); + +// // 创建左右边界控制点 +// mLeftHandle = new QCPItemRect(mPlot); +// mLeftHandle->setLayer("overlay"); +// mLeftHandle->setBrush(QBrush(Qt::red)); +// mLeftHandle->setPen(QPen(Qt::darkRed)); + +// mRightHandle = new QCPItemRect(mPlot); +// mRightHandle->setLayer("overlay"); +// mRightHandle->setBrush(QBrush(Qt::red)); +// mRightHandle->setPen(QPen(Qt::darkRed)); + + // 设置初始位置 + //double center = mPlot->xAxis->range().center(); + // setRange(center - 10, center + 10); + + // 连接鼠标事件 + connect(mPlot, &QCustomPlot::mousePress, this, &TransparentDraggableGuan::onMousePress); + connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentDraggableGuan::onMouseMove); + connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentDraggableGuan::onMouseRelease); + + mPixmap = new QCPItemPixmap(mPlot); + //mPixmap->setPixmap(QPixmap(":/image/file.png")); // 设置图片 + mPixmap->setScaled(true, Qt::IgnoreAspectRatio); // 设置缩放方式 + mPixmap->setLayer("overlay"); // 确保在最上层 + +// mItemTitle = new QCPItemText(mPlot); +// mItemTitle->setText(mstrTitle); +// //mItemTitle->setBrush(QBrush(Qt::red)); +// mItemTitle->setFont(QFont("Arial", 12, QFont::Bold)); +// mItemTitle->setColor(Qt::black); +// mItemTitle->setPositionAlignment(Qt::AlignTop | Qt::AlignHCenter); +// mItemTitle->position->setType(QCPItemPosition::ptPlotCoords); +// //mItemTitle->position->setType(QCPItemPosition::ptAxisRectRatio); +// mItemTitle->position->setCoords(0.5, 0); +// mItemTitle->setLayer("overlay"); +} + +void TransparentDraggableGuan::updateHandles() +{ + // 左边界矩形控制点 +// mLeftHandle->topLeft->setParentAnchor(mRect->topLeft); +// mLeftHandle->bottomRight->setParentAnchor(mRect->topRight);//(mRect->bottomLeft); +// mLeftHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小 +// mLeftHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小 + +// // 右边界矩形控制点 +// mRightHandle->topLeft->setParentAnchor(mRect->bottomLeft); +// mRightHandle->bottomRight->setParentAnchor(mRect->bottomRight); +// mRightHandle->topLeft->setCoords(-0.5, 0.5); // 矩形大小 +// mRightHandle->bottomRight->setCoords(0.5, -0.5); // 矩形大小 + +} + +void TransparentDraggableGuan::onDelRect() +{ + //mDragMode = DragNone; + //删除框图 + deleteRect(); +} + + +void TransparentDraggableGuan::onMousePress(QMouseEvent *event) +{ + if(event->button() != Qt::LeftButton)//右键 + { + double y = mPlot->xAxis->pixelToCoord(event->pos().y());//x轴展示深度 + QCPRange currentRange = getRange(); +// if(mLeftHandle->selectTest(event->pos(), false) < 5) { +// mDragMode = DragNone; +// } +// else if(mRightHandle->selectTest(event->pos(), false) < 5) { +// mDragMode = DragNone; +// } + //else + if(y >= currentRange.lower && y <= currentRange.upper) { + mDragMode = DragNone; + } + else { + mDragMode = DragNone; + return; + } + + //event->accept(); + + QMenu menu(nullptr); + QAction *delAction = menu.addAction("删除框图"); + //delAction->installEventFilter(this); + connect(delAction, &QAction::triggered, this, &TransparentDraggableGuan::onDelRect); + + // QAction* pItem = menu.exec(event->globalPos()); + // if(pItem == delAction) + // { + // //event->accept(); + + // int ii=0; + // ii++; + // } + menu.exec(event->globalPos()); + + return; + } + + event->accept(); + + // 检查点击了哪个部分 + //double x = mPlot->xAxis->pixelToCoord(event->pos().x()); + //double y = mPlot->yAxis->pixelToCoord(event->pos().y()); + + double y = mPlot->xAxis->pixelToCoord(event->pos().y());//x轴展示深度 + + QCPRange currentRange = getRange(); + +// if(mLeftHandle->selectTest(event->pos(), false) < 5) { +// mDragMode = DragLeft; +// } +// else if(mRightHandle->selectTest(event->pos(), false) < 5) { +// mDragMode = DragRight; +// } +// //else if(x >= currentRange.lower && x <= currentRange.upper) { +// else + if(y >= currentRange.lower && y <= currentRange.upper) { + mDragMode = DragRect; + } + else { + mDragMode = DragNone; + return; + } + + //mDragStartX = x; + mDragStartY = y; + mDragStartRange = currentRange; + +} + +void TransparentDraggableGuan::onMouseMove(QMouseEvent *event) +{ + if(mDragMode == DragNone) return; + + event->accept(); + + //double x = mPlot->xAxis->pixelToCoord(event->pos().x()); + //double dx = x - mDragStartX; + + double y = mPlot->xAxis->pixelToCoord(event->pos().y()); + double dy = y - mDragStartY; + + QCPRange newRange = mDragStartRange; + + switch(mDragMode) { +// case DragLeft: { +// //double proposedLeft = mDragStartRange.lower + dx; +// double proposedLeft = mDragStartRange.lower + dy; +// // 确保不超出轴范围且不使宽度小于最小值 +// newRange.lower = qBound( +// //mPlot->xAxis->range().lower, +// getMyLower(), +// proposedLeft, +// mDragStartRange.upper - mMinWidth); +// break; +// } +// case DragRight: { +// //double proposedRight = mDragStartRange.upper + dx; +// double proposedRight = mDragStartRange.upper + dy; +// // 确保不超出轴范围且不使宽度小于最小值 +// newRange.upper = qBound( +// mDragStartRange.lower + mMinWidth, +// proposedRight, +// getMyUpper()); +// //mPlot->xAxis->range().upper); +// break; +// } + case DragRect: { + double width = mDragStartRange.size(); + //double center = mDragStartRange.center() + dx; + double center = mDragStartRange.center() + dy; + newRange.lower = center - width/2; + newRange.upper = center + width/2; + + // 检查是否超出轴范围 + if(newRange.lower < getMyLower()) { + newRange.lower = getMyLower(); + newRange.upper = newRange.lower + width; + } + else if(newRange.upper > getMyUpper()) { + newRange.upper = getMyUpper(); + newRange.lower = newRange.upper - width; + } + + // QCPRange axisRange = mPlot->xAxis->range(); + // if(newRange.lower < axisRange.lower) { + // newRange.lower = axisRange.lower; + // newRange.upper = newRange.lower + width; + // } + // else if(newRange.upper > axisRange.upper) { + // newRange.upper = axisRange.upper; + // newRange.lower = newRange.upper - width; + // } + break; + } + default: + break; + } + + // //取整数(方便显示统计,左右边界整数显示。) + // newRange.lower = (int)newRange.lower; + // QCPRange rangeByFile = mPlot->xAxis->range(); + // if (std::fabs(rangeByFile.upper - (int)newRange.upper) >= 1.0) + // { + // newRange.upper = (int)newRange.upper; + // } + + // 最终确保宽度不小于最小值(针对整体拖动的情况) + if(newRange.size() < mMinWidth) { + if(mDragMode == DragRect) { + // 如果是整体拖动,保持中心点不变 + double center = newRange.center(); + newRange.lower = center - mMinWidth/2; + newRange.upper = center + mMinWidth/2; + } else { + // 如果是边界拖动,强制设置最小宽度 +// if(mDragMode == DragLeft) { +// newRange.lower = newRange.upper - mMinWidth; +// } else if(mDragMode == DragRight) { +// newRange.upper = newRange.lower + mMinWidth; +// } + } + } + + setRange(newRange.lower, newRange.upper); + +} + +void TransparentDraggableGuan::onMouseRelease(QMouseEvent *event) +{ + if(event->button() == Qt::LeftButton && mDragMode != DragNone) { + event->accept(); + //避免二次绘制框图 + mPlot->m_bDrawRect = false; + //emit rangeChanged(getRange()); + mDragMode = DragNone; + //取消选中状态 + // QCPDataSelection emptySelection; + // mPlot->graph(0)->setSelection(emptySelection); + // mPlot->replot(); + + //取消选中框 + mPlot->selectionRect()->cancel(); + mPlot->replot(); + mPlot->selectionRect()->mActive=true; + } +} + +double TransparentDraggableGuan::getMyLower() +{ + double dLower = mPlot->xAxis->range().lower; +// double proposedLeft = mDragStartRange.lower; + +// TransparentDraggableGuan *pDraggableRect =NULL; +// { +// QMap::Iterator it = mPlot->m_mapDraggable_Guan.begin(); +// while( it != mPlot->m_mapDraggable_Guan.end() ) +// { +// if(it.key() == m_strUuid) +// { +// it++; +// continue; +// } +// pDraggableRect = (TransparentDraggableGuan*)it.value(); +// // +// QCPRange tmpRange = pDraggableRect->getRange(); +// if(tmpRange.upper >= dLower && tmpRange.upper <= proposedLeft) +// { +// dLower = tmpRange.upper; +// } +// it++; +// } +// } + + return dLower; +} + +double TransparentDraggableGuan::getMyUpper() +{ + double dUpper = mPlot->xAxis->range().upper; +// double proposedRight = mDragStartRange.upper; + +// TransparentDraggableGuan *pDraggableRect =NULL; +// { +// QMap::Iterator it = mPlot->m_mapDraggable_Guan.begin(); +// while( it != mPlot->m_mapDraggable_Guan.end() ) +// { +// if(it.key() == m_strUuid) +// { +// it++; +// continue; +// } +// pDraggableRect = (TransparentDraggableGuan*)it.value(); +// // +// QCPRange tmpRange = pDraggableRect->getRange(); +// if(tmpRange.lower <= dUpper && tmpRange.lower >= proposedRight) +// { +// dUpper = tmpRange.lower; +// } +// it++; +// } +// } + + return dUpper; +} diff --git a/logPlus/transparentdraggableGuan.h b/logPlus/transparentdraggableGuan.h new file mode 100644 index 0000000..fa74325 --- /dev/null +++ b/logPlus/transparentdraggableGuan.h @@ -0,0 +1,88 @@ +#ifndef TRANSPARENTDRAGGABLEGUAN_H +#define TRANSPARENTDRAGGABLEGUAN_H + +#include +#include "qmycustomplot.h" +#include +#include +#include "geometryutils.h" +#include + +#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8 + +class TransparentDraggableGuan : public QObject +{ + Q_OBJECT +public: + explicit TransparentDraggableGuan(QMyCustomPlot *parentPlot, QString strUuid="", double minWidth = 1.0, QString strTitle = ""); + + + ~TransparentDraggableGuan(); + + + void DrawSVGNormal(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout); + //拉伸 + void DrawSVGSteched(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout); + //平铺 + void DrawSVGTiled(QPainter* painter,QString svgFileName,QRectF borderRect,bool IsWellSectonHorizonLayout); + //设置最小宽度 + void setMinWidth(double minWidth); + //设置标题 + //void setTitle(QString strTitle); + //设置外径长 + void setOin(float in); + + //设置解释结论 + void setResult(QString filePath); + void drawResult(double left_Low, double right_Hight, double lY1, double lY2); + + // 设置矩形范围 + void setRange(double left_Low, double right_Hight); + // 获取当前范围 + QCPRange getRange(); + + // 设置矩形颜色 + void setColor(const QColor &color); + + // 删除框图 + void deleteRect(); + +signals: + void rangeChanged(QCPRange newRange); + +private: + void initRect(); + void updateHandles() ; + +private slots: + void onDelRect(); + void onMousePress(QMouseEvent *event); + void onMouseMove(QMouseEvent *event); + void onMouseRelease(QMouseEvent *event); + double getMyLower(); + double getMyUpper(); + +private: + QMyCustomPlot *mPlot; + QCPItemRect *mRect; +// QCPItemRect *mLeftHandle; +// QCPItemRect *mRightHandle; + + QCPItemPixmap *mPixmap; +// QCPItemText *mItemTitle; +// QString mstrTitle=""; + QString m_strUuid = ""; + QString m_Result; + + enum DragMode { DragNone, DragLeft, DragRight, DragRect }; + DragMode mDragMode = DragNone; + //double mDragStartX = 0; + double mDragStartY = 0; + QCPRange mDragStartRange; + + // 添加最小宽度成员变量 + double mMinWidth; + float mIn=123; +}; + +#endif // TRANSPARENTDRAGGABLEGUAN_H diff --git a/logPlus/transparentdraggableimage.cpp b/logPlus/transparentdraggableimage.cpp index 3e02513..31677ec 100644 --- a/logPlus/transparentdraggableimage.cpp +++ b/logPlus/transparentdraggableimage.cpp @@ -82,7 +82,7 @@ void TransparentDraggableImage::setTitle(QString strTitle) { mstrTitle = strTitle; mItemTitle->setText(mstrTitle); - mPlot->replot(); + //mPlot->replot(); } //设置解释结论 @@ -166,7 +166,7 @@ void TransparentDraggableImage::drawResult(double left_Low, double right_Hight, // mPixmap->setPixmap(QPixmap(val)); // 设置图片 } - mPlot->replot(); + //mPlot->replot(); } // 设置矩形范围 @@ -208,7 +208,7 @@ void TransparentDraggableImage::setColor(const QColor &color) { mRect->setBrush(QBrush(color)); mRect->setPen(QPen(color.darker())); - mPlot->replot(); + //mPlot->replot(); } // 删除框图