追加“沉积相”绘图
This commit is contained in:
parent
5cb225fec7
commit
ae7a7392eb
|
|
@ -68,6 +68,9 @@ signals:
|
||||||
//地质层位道
|
//地质层位道
|
||||||
void sig_AddGeoSection(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW = 0);
|
void sig_AddGeoSection(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_AddWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);
|
void sig_AddWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);
|
||||||
//删除波列
|
//删除波列
|
||||||
|
|
|
||||||
263
logPlus/DrawFac.cpp
Normal file
263
logPlus/DrawFac.cpp
Normal file
|
|
@ -0,0 +1,263 @@
|
||||||
|
#include <math.h>
|
||||||
|
#include <cassert>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "MemRdWt.h"
|
||||||
|
#include "DrawFac.h"
|
||||||
|
#include <qdatetime.h>
|
||||||
|
#include "geometryutils.h"
|
||||||
|
|
||||||
|
CDrawFac::CDrawFac(QMyCustomPlot *myCustomPlot, QString strSlfName, QString csCurve)
|
||||||
|
{
|
||||||
|
m_myCustomPlot = myCustomPlot;
|
||||||
|
|
||||||
|
//隐藏刻度
|
||||||
|
myCustomPlot->xAxis->setTicks(false);
|
||||||
|
myCustomPlot->yAxis->setTicks(false);
|
||||||
|
myCustomPlot->xAxis2->setTicks(false);
|
||||||
|
myCustomPlot->yAxis2->setTicks(false);
|
||||||
|
|
||||||
|
//画2条竖线
|
||||||
|
int iMyWidth = myCustomPlot->axisRect(0)->width();
|
||||||
|
QCPItemStraightLine *qcpItemLine = new QCPItemStraightLine(myCustomPlot);
|
||||||
|
qcpItemLine->point1->setCoords(-1, iMyWidth/2);//位置
|
||||||
|
qcpItemLine->point2->setCoords(-2, iMyWidth/2);//位置
|
||||||
|
//qcpItemLine->setPen(pPenStraightLine);
|
||||||
|
|
||||||
|
QCPItemStraightLine *qcpItemLine2 = new QCPItemStraightLine(myCustomPlot);
|
||||||
|
qcpItemLine2->point1->setCoords(-1, 3*iMyWidth/4);//位置
|
||||||
|
qcpItemLine2->point2->setCoords(-2, 3*iMyWidth/4);//位置
|
||||||
|
|
||||||
|
ReadFracDef();
|
||||||
|
|
||||||
|
ReadData(strSlfName, csCurve);
|
||||||
|
DrawFac(1);//相
|
||||||
|
DrawFac(2);//亚相
|
||||||
|
}
|
||||||
|
|
||||||
|
CDrawFac::~CDrawFac(void)
|
||||||
|
{
|
||||||
|
m_FracDef.clear();
|
||||||
|
m_ObjList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDrawFac::ReadFracDef()
|
||||||
|
{
|
||||||
|
m_FracDef.clear();
|
||||||
|
|
||||||
|
QString fracFilePath = GetConfPath() + "GEoFac.ini";
|
||||||
|
|
||||||
|
//
|
||||||
|
FAC_DEF fd;
|
||||||
|
char str[512],fac[512],phase[64],mFac[64];
|
||||||
|
int r,g,b,id;
|
||||||
|
FILE *fp;
|
||||||
|
QString qs;
|
||||||
|
fp = fopen(fracFilePath.toStdString().c_str(), "r");
|
||||||
|
if ( fp != nullptr )
|
||||||
|
{
|
||||||
|
fgets(str,256,fp); // 跳过第一行
|
||||||
|
while (!feof(fp))
|
||||||
|
{
|
||||||
|
fgets(str,256,fp);
|
||||||
|
qs = str;
|
||||||
|
qs.trimmed();
|
||||||
|
if (qs.length() < 8) break ;
|
||||||
|
//代码 微相 亚相 相
|
||||||
|
sscanf(str,"%d %s %s %s",&fd.iCode,mFac,phase,fac);
|
||||||
|
fd.mFac = mFac;
|
||||||
|
fd.Fac = fac;
|
||||||
|
fd.Phase = phase;
|
||||||
|
m_FracDef.append(fd);
|
||||||
|
if ( feof(fp))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(fac,"打开沉积相参数配置文件错误:%s!",str);
|
||||||
|
QMessageBox::information(nullptr, "读取文件失败", fac);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDrawFac::ReadData(QString strSlfName, QString csCurve)
|
||||||
|
{
|
||||||
|
if(strSlfName.isEmpty()) return;
|
||||||
|
//清空
|
||||||
|
m_ObjList.clear();
|
||||||
|
|
||||||
|
QString cs;
|
||||||
|
int nLineWidth=2;
|
||||||
|
int nField;
|
||||||
|
QColor crColor(255,0,0);
|
||||||
|
FAC_TABLE frac;
|
||||||
|
CMemRdWt mrw;
|
||||||
|
char strFracTable[256];
|
||||||
|
int i,j,iIndex,nCount,iType=1;
|
||||||
|
|
||||||
|
if (mrw.Open(strSlfName.toStdString().c_str()) ) // 打开井文件
|
||||||
|
{
|
||||||
|
iIndex=mrw.OpenTable(csCurve.toStdString().c_str());
|
||||||
|
if(iIndex>=0)
|
||||||
|
{
|
||||||
|
nField=mrw.GetTableFieldCount(iIndex);
|
||||||
|
nCount=mrw.GetTableRecordCount(iIndex);
|
||||||
|
cs ="";
|
||||||
|
if ( nField != 7 )
|
||||||
|
nCount = 0;
|
||||||
|
for(i=0;i<nCount;i++)
|
||||||
|
{
|
||||||
|
mrw.ReadTable(iIndex,i+1,(void*)&frac);
|
||||||
|
m_ObjList.append(frac);
|
||||||
|
|
||||||
|
//显示文本
|
||||||
|
m_myCustomPlot->addMFacToPlot(-frac.edep, -frac.sdep, QString::fromLocal8Bit(frac.mFac));
|
||||||
|
}
|
||||||
|
mrw.CloseTable(iIndex);
|
||||||
|
}
|
||||||
|
mrw.Close(); //关闭井文件
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDrawFac::DrawFac(int iType)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
float dep1,dep2;
|
||||||
|
float top,bottom;
|
||||||
|
QString str1,str2;
|
||||||
|
QColor crColor(0,0,0);
|
||||||
|
QPen qPen(crColor, 1, Qt::SolidLine);
|
||||||
|
if ( m_ObjList.count()<2 )
|
||||||
|
return ;
|
||||||
|
|
||||||
|
//绘制相、亚相
|
||||||
|
FAC_TABLE pObj;
|
||||||
|
pObj =m_ObjList[0];
|
||||||
|
if (iType==1)
|
||||||
|
str1 = QString::fromLocal8Bit(pObj.Fac);
|
||||||
|
else
|
||||||
|
str1 = QString::fromLocal8Bit(pObj.Phase);
|
||||||
|
str1.trimmed();
|
||||||
|
top = pObj.sdep;
|
||||||
|
|
||||||
|
for (j=1;j<m_ObjList.count(); j++)
|
||||||
|
{
|
||||||
|
pObj =m_ObjList[j];
|
||||||
|
|
||||||
|
if (iType==1)
|
||||||
|
str2= QString::fromLocal8Bit(pObj.Fac);
|
||||||
|
else
|
||||||
|
str2 = QString::fromLocal8Bit(pObj.Phase);
|
||||||
|
str2.trimmed();
|
||||||
|
|
||||||
|
if (str2!=str1 || j==(m_ObjList.count()-1))
|
||||||
|
{
|
||||||
|
if ( j==(m_ObjList.count()-1))
|
||||||
|
bottom = m_ObjList[j].edep;
|
||||||
|
else
|
||||||
|
bottom = m_ObjList[j-1].edep;
|
||||||
|
|
||||||
|
|
||||||
|
//显示文本
|
||||||
|
if (iType==1)
|
||||||
|
{
|
||||||
|
//相
|
||||||
|
m_myCustomPlot->addFacToPlot(-bottom, -top, str1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//亚相
|
||||||
|
m_myCustomPlot->addPhaseToPlot(-bottom, -top, str1);
|
||||||
|
}
|
||||||
|
|
||||||
|
top = pObj.sdep;
|
||||||
|
str1=str2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//void CDrawFac::DrawFrac(QPainter* pDC,QRectF mrt)
|
||||||
|
//{
|
||||||
|
// QRectF rt;
|
||||||
|
// float flDepthScale = m_DepthScale*m_nVertRatio;
|
||||||
|
// float sdepc,edepc,sdep,edep;
|
||||||
|
// float temp,temp2;
|
||||||
|
// CFracObj *pObj;
|
||||||
|
// QString cs;
|
||||||
|
// int i,j,n,nCol=2;
|
||||||
|
// QColor crColor(0,0,0);
|
||||||
|
// QPen qPen(crColor, 1, Qt::SolidLine);
|
||||||
|
// rt=mrt;
|
||||||
|
// flDepthScale = m_DepthScale*m_nVertRatio;
|
||||||
|
// rt = mrt;
|
||||||
|
// // 计算显示深度
|
||||||
|
// GetDepth(pDC,mrt,rt,sdep,edep,sdepc,edepc);
|
||||||
|
|
||||||
|
// if ( edep > m_PlotEdep ) edep = m_PlotEdep;
|
||||||
|
// if ( sdep < m_PlotSdep ) sdep = m_PlotSdep;
|
||||||
|
// if ( sdep > m_PlotEdep ) return ;
|
||||||
|
// if ( edep < m_PlotSdep ) return ;
|
||||||
|
// if ( edep > m_PlotEdep ) edep = m_PlotEdep;
|
||||||
|
// pDC->setBrush(Qt::NoBrush);
|
||||||
|
// pDC->setFont(m_LabelFont);
|
||||||
|
|
||||||
|
// if ( m_bDrawFac)
|
||||||
|
// nCol++;
|
||||||
|
// if ( m_bDrawPhase)
|
||||||
|
// nCol++;
|
||||||
|
// n = m_FracDef.count();
|
||||||
|
// pDC->setPen(qPen);
|
||||||
|
// //绘制微相
|
||||||
|
// for (j=0;j<m_ObjList.count(); j++)
|
||||||
|
// {
|
||||||
|
// pObj =m_ObjList[j];
|
||||||
|
// CalQRectF(pObj,mrt,sdep,flDepthScale);
|
||||||
|
// if ( pObj->m_Frac.edep <sdep || pObj->m_Frac.sdep > edep)
|
||||||
|
// continue;
|
||||||
|
// rt= pObj->m_Rect;
|
||||||
|
// temp = mrt.left()+2.*mrt.width()/nCol;
|
||||||
|
// rt.setRight(temp);
|
||||||
|
// if (m_bSymbol) //绘制微相符号
|
||||||
|
// pObj->Draw(pDC,rt,m_iMode);
|
||||||
|
// if ( m_bDrawMFac )
|
||||||
|
// {
|
||||||
|
// cs = pObj->m_Frac.mFac;
|
||||||
|
// pDC->drawText(rt,Qt::AlignCenter| Qt::AlignVCenter,cs);
|
||||||
|
// }
|
||||||
|
// pDC->drawLine(QPoint(mrt.left(),rt.top()),QPoint(temp,rt.top()));
|
||||||
|
// pDC->drawLine(QPoint(mrt.left(),rt.bottom()),QPoint(temp,rt.bottom()));
|
||||||
|
// }
|
||||||
|
// if ( m_bDrawFac && m_bDrawPhase)
|
||||||
|
// {
|
||||||
|
// temp = mrt.left()+2.*mrt.width()/nCol;
|
||||||
|
// temp2 = mrt.left()+3.*mrt.width()/nCol;
|
||||||
|
// DrawFac(pDC,mrt,2,temp,temp2);
|
||||||
|
// DrawFac(pDC,mrt,1,temp2,mrt.right());
|
||||||
|
// pDC->drawLine(QPoint(temp,mrt.top()),QPoint(temp,mrt.bottom()));
|
||||||
|
// pDC->drawLine(QPoint(temp2,mrt.top()),QPoint(temp2,mrt.bottom()));
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if ( m_bDrawFac || m_bDrawPhase)
|
||||||
|
// {
|
||||||
|
// temp = mrt.left()+2.*mrt.width()/nCol;
|
||||||
|
// if ( m_bDrawFac )
|
||||||
|
// DrawFac(pDC,mrt,1,temp,mrt.right());
|
||||||
|
// else
|
||||||
|
// DrawFac(pDC,mrt,2,temp,mrt.right());
|
||||||
|
// pDC->drawLine(QPoint(temp,mrt.top()),QPoint(temp,mrt.bottom()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 绘制边框
|
||||||
|
// if ( m_selection.count() > 0 )
|
||||||
|
// {
|
||||||
|
// CFracObj *pObj = m_selection[0];
|
||||||
|
// if (pObj->m_bSelected !=0 )
|
||||||
|
// {
|
||||||
|
// CalQRectF(pObj,mrt,sdep,flDepthScale);
|
||||||
|
// pObj->DrawTracker(pDC,selected,1);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
49
logPlus/DrawFac.h
Normal file
49
logPlus/DrawFac.h
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#ifndef DrawFac_H
|
||||||
|
#define DrawFac_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "qmycustomplot.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int iCode; //代码
|
||||||
|
QString Fac; //相
|
||||||
|
QString Phase; //亚相
|
||||||
|
QString mFac; //微相
|
||||||
|
}FAC_DEF;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int no;
|
||||||
|
float sdep;
|
||||||
|
float edep;
|
||||||
|
char Fac[32];
|
||||||
|
char Phase[32];
|
||||||
|
char mFac[32];
|
||||||
|
char Dest[32];
|
||||||
|
}FAC_TABLE;
|
||||||
|
|
||||||
|
//沉积相
|
||||||
|
class CDrawFac:public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CDrawFac(QMyCustomPlot *myCustomPlot, QString strSlfName, QString csCurve);
|
||||||
|
virtual ~CDrawFac(void);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QList <FAC_DEF> m_FracDef;
|
||||||
|
QList <FAC_TABLE> m_ObjList;
|
||||||
|
|
||||||
|
QMyCustomPlot *m_myCustomPlot;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void ReadFracDef();
|
||||||
|
void ReadData(QString strSlfName, QString csCurve);
|
||||||
|
void DrawFac(int iType);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "memrdwt.h"
|
#include "MemRdWt.h"
|
||||||
#include "PickFrac.h"
|
#include "PickFrac.h"
|
||||||
#include "geometryutils.h"
|
#include "geometryutils.h"
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ void CPickFrac::ReadFracDef()
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
QString qs;
|
QString qs;
|
||||||
fp = fopen(fracFilePath.toStdString().c_str(),"r");
|
fp = fopen(fracFilePath.toStdString().c_str(),"r");
|
||||||
if ( fp !=NULL )
|
if ( fp != nullptr )
|
||||||
{
|
{
|
||||||
fgets(str,256,fp); // 跳过第一行
|
fgets(str,256,fp); // 跳过第一行
|
||||||
while (!feof(fp))
|
while (!feof(fp))
|
||||||
|
|
@ -75,7 +75,7 @@ void CPickFrac::ReadFracDef()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(name,"打开裂缝参数配置文件错误:%s!",str);
|
sprintf(name,"打开裂缝参数配置文件错误:%s!",str);
|
||||||
QMessageBox::information(NULL, "读取文件失败", name);
|
QMessageBox::information(nullptr, "读取文件失败", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "qmycustomplot.h"
|
#include "qmycustomplot.h"
|
||||||
|
|
||||||
|
//裂缝
|
||||||
|
|
||||||
//const int iFracType=15;
|
//const int iFracType=15;
|
||||||
|
|
||||||
typedef struct tagPOINTF
|
typedef struct tagPOINTF
|
||||||
|
|
|
||||||
431
logPlus/TransparentDraggableFac.cpp
Normal file
431
logPlus/TransparentDraggableFac.cpp
Normal file
|
|
@ -0,0 +1,431 @@
|
||||||
|
#include "TransparentDraggableFac.h"
|
||||||
|
|
||||||
|
extern double g_dPixelPerCm;//每厘米像素数
|
||||||
|
//static GeoIndicatorGenerator m_drawGeo;
|
||||||
|
|
||||||
|
TransparentDraggableFac::TransparentDraggableFac(QMyCustomPlot *parentPlot, QString strUuid, double minWidth, QString strTitle)
|
||||||
|
: QObject(parentPlot), mPlot(parentPlot), mstrTitle(strTitle), mMinWidth(minWidth)
|
||||||
|
{
|
||||||
|
m_strUuid = strUuid;
|
||||||
|
//
|
||||||
|
initRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
TransparentDraggableFac::~TransparentDraggableFac()
|
||||||
|
{
|
||||||
|
if(mPlot) {
|
||||||
|
// mPlot->removeItem(mRect);
|
||||||
|
// mPlot->removeItem(mLeftHandle);
|
||||||
|
// mPlot->removeItem(mRightHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置最小宽度
|
||||||
|
void TransparentDraggableFac::setMinWidth(double minWidth)
|
||||||
|
{
|
||||||
|
mMinWidth = minWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置标题
|
||||||
|
void TransparentDraggableFac::setTitle(QString strTitle)
|
||||||
|
{
|
||||||
|
mstrTitle = strTitle;
|
||||||
|
mItemTitle->setText(mstrTitle);
|
||||||
|
//mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置矩形范围
|
||||||
|
void TransparentDraggableFac::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, 3*(lY1+lY2)/4.0);
|
||||||
|
mRect->bottomRight->setCoords(right_Hight, lY2);
|
||||||
|
|
||||||
|
//位置与rect不一样,否则图像反转
|
||||||
|
// mPixmap->topLeft->setCoords(right_Hight, lY1);
|
||||||
|
// mPixmap->bottomRight->setCoords(left_Low, (lY1+lY2)/2.0);
|
||||||
|
|
||||||
|
//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); // 设置文本在矩形中心位置
|
||||||
|
|
||||||
|
float flNewPos = mPlot->xAxis->coordToPixel((left_Low + right_Hight)/2.0) - 15;
|
||||||
|
mItemTitle->position->setCoords(mPlot->xAxis->pixelToCoord(flNewPos),
|
||||||
|
7*(lY1 + lY2)/8.0); // 设置文本在矩形中心位置
|
||||||
|
|
||||||
|
//mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper);
|
||||||
|
//mRect->bottomRight->setCoords(right, mPlot->yAxis->range().lower);
|
||||||
|
|
||||||
|
updateHandles();
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前范围
|
||||||
|
QCPRange TransparentDraggableFac::getRange()
|
||||||
|
{
|
||||||
|
return QCPRange(mRect->topLeft->coords().x(), mRect->bottomRight->coords().x());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置矩形颜色
|
||||||
|
void TransparentDraggableFac::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
mRect->setBrush(QBrush(color));
|
||||||
|
mRect->setPen(QPen(color.darker()));
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除框图
|
||||||
|
void TransparentDraggableFac::deleteRect()
|
||||||
|
{
|
||||||
|
if(mPlot) {
|
||||||
|
|
||||||
|
// mRect->deleteLater();
|
||||||
|
// mLeftHandle->deleteLater();
|
||||||
|
// mRightHandle->deleteLater();
|
||||||
|
// mPixmap->deleteLater();
|
||||||
|
|
||||||
|
mPlot->m_mapDraggableFac.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 TransparentDraggableFac::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, &TransparentDraggableFac::onMousePress);
|
||||||
|
// connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentDraggableFac::onMouseMove);
|
||||||
|
// connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentDraggableFac::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", 8, 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 TransparentDraggableFac::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 TransparentDraggableFac::onDelRect()
|
||||||
|
//{
|
||||||
|
// //mDragMode = DragNone;
|
||||||
|
// //删除框图
|
||||||
|
// deleteRect();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//void TransparentDraggableFac::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(x >= currentRange.lower && x <= currentRange.upper) {
|
||||||
|
// 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, &TransparentDraggableFac::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 TransparentDraggableFac::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 TransparentDraggableFac::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 TransparentDraggableFac::getMyLower()
|
||||||
|
//{
|
||||||
|
// double dLower = mPlot->xAxis->range().lower;
|
||||||
|
// double proposedLeft = mDragStartRange.lower;
|
||||||
|
|
||||||
|
// TransparentDraggableFac *pDraggableRect =NULL;
|
||||||
|
// {
|
||||||
|
// QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggableFac.begin();
|
||||||
|
// while( it != mPlot->m_mapDraggableFac.end() )
|
||||||
|
// {
|
||||||
|
// if(it.key() == m_strUuid)
|
||||||
|
// {
|
||||||
|
// it++;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// pDraggableRect = (TransparentDraggableFac*)it.value();
|
||||||
|
// //
|
||||||
|
// QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
// if(tmpRange.upper >= dLower && tmpRange.upper <= proposedLeft)
|
||||||
|
// {
|
||||||
|
// dLower = tmpRange.upper;
|
||||||
|
// }
|
||||||
|
// it++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return dLower;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//double TransparentDraggableFac::getMyUpper()
|
||||||
|
//{
|
||||||
|
// double dUpper = mPlot->xAxis->range().upper;
|
||||||
|
// double proposedRight = mDragStartRange.upper;
|
||||||
|
|
||||||
|
// TransparentDraggableFac *pDraggableRect =NULL;
|
||||||
|
// {
|
||||||
|
// QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggableFac.begin();
|
||||||
|
// while( it != mPlot->m_mapDraggableFac.end() )
|
||||||
|
// {
|
||||||
|
// if(it.key() == m_strUuid)
|
||||||
|
// {
|
||||||
|
// it++;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// pDraggableRect = (TransparentDraggableFac*)it.value();
|
||||||
|
// //
|
||||||
|
// QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
// if(tmpRange.lower <= dUpper && tmpRange.lower >= proposedRight)
|
||||||
|
// {
|
||||||
|
// dUpper = tmpRange.lower;
|
||||||
|
// }
|
||||||
|
// it++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return dUpper;
|
||||||
|
//}
|
||||||
|
|
||||||
73
logPlus/TransparentDraggableFac.h
Normal file
73
logPlus/TransparentDraggableFac.h
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
#ifndef TRANSPARENTDRAGGABLEFAC_H
|
||||||
|
#define TRANSPARENTDRAGGABLEFAC_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "qmycustomplot.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8
|
||||||
|
|
||||||
|
//沉积相--相
|
||||||
|
class TransparentDraggableFac : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TransparentDraggableFac(QMyCustomPlot *parentPlot, QString strUuid="", double minWidth = 1.0, QString strTitle = "");
|
||||||
|
|
||||||
|
|
||||||
|
~TransparentDraggableFac();
|
||||||
|
|
||||||
|
//设置最小宽度
|
||||||
|
void setMinWidth(double minWidth);
|
||||||
|
//设置标题
|
||||||
|
void setTitle(QString strTitle);
|
||||||
|
|
||||||
|
// 设置矩形范围
|
||||||
|
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 = "";
|
||||||
|
|
||||||
|
enum DragMode { DragNone, DragLeft, DragRight, DragRect };
|
||||||
|
DragMode mDragMode = DragNone;
|
||||||
|
//double mDragStartX = 0;
|
||||||
|
double mDragStartY = 0;
|
||||||
|
QCPRange mDragStartRange;
|
||||||
|
|
||||||
|
// 添加最小宽度成员变量
|
||||||
|
double mMinWidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSPARENTDRAGGABLEFAC_H
|
||||||
431
logPlus/TransparentDraggableMFac.cpp
Normal file
431
logPlus/TransparentDraggableMFac.cpp
Normal file
|
|
@ -0,0 +1,431 @@
|
||||||
|
#include "TransparentDraggableMFac.h"
|
||||||
|
|
||||||
|
extern double g_dPixelPerCm;//每厘米像素数
|
||||||
|
//static GeoIndicatorGenerator m_drawGeo;
|
||||||
|
|
||||||
|
TransparentDraggableMFac::TransparentDraggableMFac(QMyCustomPlot *parentPlot, QString strUuid, double minWidth, QString strTitle)
|
||||||
|
: QObject(parentPlot), mPlot(parentPlot), mstrTitle(strTitle), mMinWidth(minWidth)
|
||||||
|
{
|
||||||
|
m_strUuid = strUuid;
|
||||||
|
//
|
||||||
|
initRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
TransparentDraggableMFac::~TransparentDraggableMFac()
|
||||||
|
{
|
||||||
|
if(mPlot) {
|
||||||
|
// mPlot->removeItem(mRect);
|
||||||
|
// mPlot->removeItem(mLeftHandle);
|
||||||
|
// mPlot->removeItem(mRightHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置最小宽度
|
||||||
|
void TransparentDraggableMFac::setMinWidth(double minWidth)
|
||||||
|
{
|
||||||
|
mMinWidth = minWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置标题
|
||||||
|
void TransparentDraggableMFac::setTitle(QString strTitle)
|
||||||
|
{
|
||||||
|
mstrTitle = strTitle;
|
||||||
|
mItemTitle->setText(mstrTitle);
|
||||||
|
//mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置矩形范围
|
||||||
|
void TransparentDraggableMFac::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);
|
||||||
|
mRect->bottomRight->setCoords(right_Hight, (lY1+lY2)/2.0);
|
||||||
|
|
||||||
|
//位置与rect不一样,否则图像反转
|
||||||
|
// mPixmap->topLeft->setCoords(right_Hight, lY1);
|
||||||
|
// mPixmap->bottomRight->setCoords(left_Low, (lY1+lY2)/2.0);
|
||||||
|
|
||||||
|
//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); // 设置文本在矩形中心位置
|
||||||
|
|
||||||
|
float flNewPos = mPlot->xAxis->coordToPixel((left_Low + right_Hight)/2.0) - 15;
|
||||||
|
mItemTitle->position->setCoords(mPlot->xAxis->pixelToCoord(flNewPos),
|
||||||
|
(lY1 + lY2)/4.0); // 设置文本在矩形中心位置
|
||||||
|
|
||||||
|
//mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper);
|
||||||
|
//mRect->bottomRight->setCoords(right, mPlot->yAxis->range().lower);
|
||||||
|
|
||||||
|
updateHandles();
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前范围
|
||||||
|
QCPRange TransparentDraggableMFac::getRange()
|
||||||
|
{
|
||||||
|
return QCPRange(mRect->topLeft->coords().x(), mRect->bottomRight->coords().x());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置矩形颜色
|
||||||
|
void TransparentDraggableMFac::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
mRect->setBrush(QBrush(color));
|
||||||
|
mRect->setPen(QPen(color.darker()));
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除框图
|
||||||
|
void TransparentDraggableMFac::deleteRect()
|
||||||
|
{
|
||||||
|
if(mPlot) {
|
||||||
|
|
||||||
|
// mRect->deleteLater();
|
||||||
|
// mLeftHandle->deleteLater();
|
||||||
|
// mRightHandle->deleteLater();
|
||||||
|
// mPixmap->deleteLater();
|
||||||
|
|
||||||
|
mPlot->m_mapDraggableMFac.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 TransparentDraggableMFac::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, &TransparentDraggableMFac::onMousePress);
|
||||||
|
connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentDraggableMFac::onMouseMove);
|
||||||
|
connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentDraggableMFac::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 TransparentDraggableMFac::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 TransparentDraggableMFac::onDelRect()
|
||||||
|
{
|
||||||
|
//mDragMode = DragNone;
|
||||||
|
//删除框图
|
||||||
|
deleteRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TransparentDraggableMFac::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(x >= currentRange.lower && x <= currentRange.upper) {
|
||||||
|
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, &TransparentDraggableMFac::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 TransparentDraggableMFac::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 TransparentDraggableMFac::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 TransparentDraggableMFac::getMyLower()
|
||||||
|
{
|
||||||
|
double dLower = mPlot->xAxis->range().lower;
|
||||||
|
double proposedLeft = mDragStartRange.lower;
|
||||||
|
|
||||||
|
TransparentDraggableMFac *pDraggableRect =NULL;
|
||||||
|
{
|
||||||
|
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggableMFac.begin();
|
||||||
|
while( it != mPlot->m_mapDraggableMFac.end() )
|
||||||
|
{
|
||||||
|
if(it.key() == m_strUuid)
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pDraggableRect = (TransparentDraggableMFac*)it.value();
|
||||||
|
//
|
||||||
|
QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
if(tmpRange.upper >= dLower && tmpRange.upper <= proposedLeft)
|
||||||
|
{
|
||||||
|
dLower = tmpRange.upper;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dLower;
|
||||||
|
}
|
||||||
|
|
||||||
|
double TransparentDraggableMFac::getMyUpper()
|
||||||
|
{
|
||||||
|
double dUpper = mPlot->xAxis->range().upper;
|
||||||
|
double proposedRight = mDragStartRange.upper;
|
||||||
|
|
||||||
|
TransparentDraggableMFac *pDraggableRect =NULL;
|
||||||
|
{
|
||||||
|
QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggableMFac.begin();
|
||||||
|
while( it != mPlot->m_mapDraggableMFac.end() )
|
||||||
|
{
|
||||||
|
if(it.key() == m_strUuid)
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pDraggableRect = (TransparentDraggableMFac*)it.value();
|
||||||
|
//
|
||||||
|
QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
if(tmpRange.lower <= dUpper && tmpRange.lower >= proposedRight)
|
||||||
|
{
|
||||||
|
dUpper = tmpRange.lower;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dUpper;
|
||||||
|
}
|
||||||
|
|
||||||
73
logPlus/TransparentDraggableMFac.h
Normal file
73
logPlus/TransparentDraggableMFac.h
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
#ifndef TRANSPARENTDRAGGABLEMFAC_H
|
||||||
|
#define TRANSPARENTDRAGGABLEMFAC_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "qmycustomplot.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8
|
||||||
|
|
||||||
|
//沉积相--微相
|
||||||
|
class TransparentDraggableMFac : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TransparentDraggableMFac(QMyCustomPlot *parentPlot, QString strUuid="", double minWidth = 1.0, QString strTitle = "");
|
||||||
|
|
||||||
|
|
||||||
|
~TransparentDraggableMFac();
|
||||||
|
|
||||||
|
//设置最小宽度
|
||||||
|
void setMinWidth(double minWidth);
|
||||||
|
//设置标题
|
||||||
|
void setTitle(QString strTitle);
|
||||||
|
|
||||||
|
// 设置矩形范围
|
||||||
|
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 = "";
|
||||||
|
|
||||||
|
enum DragMode { DragNone, DragLeft, DragRight, DragRect };
|
||||||
|
DragMode mDragMode = DragNone;
|
||||||
|
//double mDragStartX = 0;
|
||||||
|
double mDragStartY = 0;
|
||||||
|
QCPRange mDragStartRange;
|
||||||
|
|
||||||
|
// 添加最小宽度成员变量
|
||||||
|
double mMinWidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSPARENTDRAGGABLEMFAC_H
|
||||||
431
logPlus/TransparentDraggablePhase.cpp
Normal file
431
logPlus/TransparentDraggablePhase.cpp
Normal file
|
|
@ -0,0 +1,431 @@
|
||||||
|
#include "TransparentDraggablePhase.h"
|
||||||
|
|
||||||
|
extern double g_dPixelPerCm;//每厘米像素数
|
||||||
|
//static GeoIndicatorGenerator m_drawGeo;
|
||||||
|
|
||||||
|
TransparentDraggablePhase::TransparentDraggablePhase(QMyCustomPlot *parentPlot, QString strUuid, double minWidth, QString strTitle)
|
||||||
|
: QObject(parentPlot), mPlot(parentPlot), mstrTitle(strTitle), mMinWidth(minWidth)
|
||||||
|
{
|
||||||
|
m_strUuid = strUuid;
|
||||||
|
//
|
||||||
|
initRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
TransparentDraggablePhase::~TransparentDraggablePhase()
|
||||||
|
{
|
||||||
|
if(mPlot) {
|
||||||
|
// mPlot->removeItem(mRect);
|
||||||
|
// mPlot->removeItem(mLeftHandle);
|
||||||
|
// mPlot->removeItem(mRightHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置最小宽度
|
||||||
|
void TransparentDraggablePhase::setMinWidth(double minWidth)
|
||||||
|
{
|
||||||
|
mMinWidth = minWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置标题
|
||||||
|
void TransparentDraggablePhase::setTitle(QString strTitle)
|
||||||
|
{
|
||||||
|
mstrTitle = strTitle;
|
||||||
|
mItemTitle->setText(mstrTitle);
|
||||||
|
//mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置矩形范围
|
||||||
|
void TransparentDraggablePhase::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)/2.0);
|
||||||
|
mRect->bottomRight->setCoords(right_Hight, 3*(lY1+lY2)/4.0);
|
||||||
|
|
||||||
|
//位置与rect不一样,否则图像反转
|
||||||
|
// mPixmap->topLeft->setCoords(right_Hight, lY1);
|
||||||
|
// mPixmap->bottomRight->setCoords(left_Low, (lY1+lY2)/2.0);
|
||||||
|
|
||||||
|
//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); // 设置文本在矩形中心位置
|
||||||
|
|
||||||
|
float flNewPos = mPlot->xAxis->coordToPixel((left_Low + right_Hight)/2.0) - 15;
|
||||||
|
mItemTitle->position->setCoords(mPlot->xAxis->pixelToCoord(flNewPos),
|
||||||
|
5*(lY1 + lY2)/8.0); // 设置文本在矩形中心位置
|
||||||
|
|
||||||
|
//mRect->topLeft->setCoords(left, mPlot->yAxis->range().upper);
|
||||||
|
//mRect->bottomRight->setCoords(right, mPlot->yAxis->range().lower);
|
||||||
|
|
||||||
|
updateHandles();
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前范围
|
||||||
|
QCPRange TransparentDraggablePhase::getRange()
|
||||||
|
{
|
||||||
|
return QCPRange(mRect->topLeft->coords().x(), mRect->bottomRight->coords().x());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置矩形颜色
|
||||||
|
void TransparentDraggablePhase::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
mRect->setBrush(QBrush(color));
|
||||||
|
mRect->setPen(QPen(color.darker()));
|
||||||
|
mPlot->replot();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除框图
|
||||||
|
void TransparentDraggablePhase::deleteRect()
|
||||||
|
{
|
||||||
|
if(mPlot) {
|
||||||
|
|
||||||
|
// mRect->deleteLater();
|
||||||
|
// mLeftHandle->deleteLater();
|
||||||
|
// mRightHandle->deleteLater();
|
||||||
|
// mPixmap->deleteLater();
|
||||||
|
|
||||||
|
mPlot->m_mapDraggablePhase.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 TransparentDraggablePhase::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, &TransparentDraggablePhase::onMousePress);
|
||||||
|
// connect(mPlot, &QCustomPlot::mouseMove, this, &TransparentDraggablePhase::onMouseMove);
|
||||||
|
// connect(mPlot, &QCustomPlot::mouseRelease, this, &TransparentDraggablePhase::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", 8, 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 TransparentDraggablePhase::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 TransparentDraggablePhase::onDelRect()
|
||||||
|
//{
|
||||||
|
// //mDragMode = DragNone;
|
||||||
|
// //删除框图
|
||||||
|
// deleteRect();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//void TransparentDraggablePhase::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(x >= currentRange.lower && x <= currentRange.upper) {
|
||||||
|
// 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, &TransparentDraggablePhase::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 TransparentDraggablePhase::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 TransparentDraggablePhase::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 TransparentDraggablePhase::getMyLower()
|
||||||
|
//{
|
||||||
|
// double dLower = mPlot->xAxis->range().lower;
|
||||||
|
// double proposedLeft = mDragStartRange.lower;
|
||||||
|
|
||||||
|
// TransparentDraggablePhase *pDraggableRect =NULL;
|
||||||
|
// {
|
||||||
|
// QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggablePhase.begin();
|
||||||
|
// while( it != mPlot->m_mapDraggablePhase.end() )
|
||||||
|
// {
|
||||||
|
// if(it.key() == m_strUuid)
|
||||||
|
// {
|
||||||
|
// it++;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// pDraggableRect = (TransparentDraggablePhase*)it.value();
|
||||||
|
// //
|
||||||
|
// QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
// if(tmpRange.upper >= dLower && tmpRange.upper <= proposedLeft)
|
||||||
|
// {
|
||||||
|
// dLower = tmpRange.upper;
|
||||||
|
// }
|
||||||
|
// it++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return dLower;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//double TransparentDraggablePhase::getMyUpper()
|
||||||
|
//{
|
||||||
|
// double dUpper = mPlot->xAxis->range().upper;
|
||||||
|
// double proposedRight = mDragStartRange.upper;
|
||||||
|
|
||||||
|
// TransparentDraggablePhase *pDraggableRect =NULL;
|
||||||
|
// {
|
||||||
|
// QMap<QString,QObject *>::Iterator it = mPlot->m_mapDraggablePhase.begin();
|
||||||
|
// while( it != mPlot->m_mapDraggablePhase.end() )
|
||||||
|
// {
|
||||||
|
// if(it.key() == m_strUuid)
|
||||||
|
// {
|
||||||
|
// it++;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// pDraggableRect = (TransparentDraggablePhase*)it.value();
|
||||||
|
// //
|
||||||
|
// QCPRange tmpRange = pDraggableRect->getRange();
|
||||||
|
// if(tmpRange.lower <= dUpper && tmpRange.lower >= proposedRight)
|
||||||
|
// {
|
||||||
|
// dUpper = tmpRange.lower;
|
||||||
|
// }
|
||||||
|
// it++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return dUpper;
|
||||||
|
//}
|
||||||
|
|
||||||
72
logPlus/TransparentDraggablePhase.h
Normal file
72
logPlus/TransparentDraggablePhase.h
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
#ifndef TRANSPARENTDRAGGABLEPHASE_H
|
||||||
|
#define TRANSPARENTDRAGGABLEPHASE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "qmycustomplot.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
#pragma execution_character_set("utf-8") // 强制指定执行字符集为 UTF-8
|
||||||
|
|
||||||
|
//沉积相--亚相
|
||||||
|
class TransparentDraggablePhase : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit TransparentDraggablePhase(QMyCustomPlot *parentPlot, QString strUuid="", double minWidth = 1.0, QString strTitle = "");
|
||||||
|
|
||||||
|
~TransparentDraggablePhase();
|
||||||
|
|
||||||
|
//设置最小宽度
|
||||||
|
void setMinWidth(double minWidth);
|
||||||
|
//设置标题
|
||||||
|
void setTitle(QString strTitle);
|
||||||
|
|
||||||
|
// 设置矩形范围
|
||||||
|
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 = "";
|
||||||
|
|
||||||
|
enum DragMode { DragNone, DragLeft, DragRight, DragRect };
|
||||||
|
DragMode mDragMode = DragNone;
|
||||||
|
//double mDragStartX = 0;
|
||||||
|
double mDragStartY = 0;
|
||||||
|
QCPRange mDragStartRange;
|
||||||
|
|
||||||
|
// 添加最小宽度成员变量
|
||||||
|
double mMinWidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSPARENTDRAGGABLEPHASE_H
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include "Gradient.h"
|
#include "Gradient.h"
|
||||||
#include "PickFrac.h"
|
#include "PickFrac.h"
|
||||||
|
#include "DrawFac.h"
|
||||||
#include "ObjGeostratums.h"
|
#include "ObjGeostratums.h"
|
||||||
|
|
||||||
//以下参数从配置文件读取
|
//以下参数从配置文件读取
|
||||||
|
|
@ -80,6 +81,8 @@ 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)));
|
connect(CallManage::getInstance(), SIGNAL(sig_AddGeoSection(QString, QString, QString, QString, QString, int)), this, SLOT(s_addGeoSection(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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
FormDraw::~FormDraw()
|
FormDraw::~FormDraw()
|
||||||
|
|
@ -522,7 +525,16 @@ void FormDraw::setRowHeight(double dHight, QProgressBar *progressBar, int iSplit
|
||||||
int nw = form->geometry().width();
|
int nw = form->geometry().width();
|
||||||
form->setGeometry(0, 0, nw, (int)dHight);//7500-3184
|
form->setGeometry(0, 0, nw, (int)dHight);//7500-3184
|
||||||
//深度改变
|
//深度改变
|
||||||
form->xAxis->setRange(g_iY1, g_iY2);
|
if(form->m_bX2Y == true)
|
||||||
|
{
|
||||||
|
//默认调换
|
||||||
|
form->xAxis->setRange(g_iY1, g_iY2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//针对裂缝的横向波形图,X,Y轴不调换
|
||||||
|
form->yAxis->setRange(g_iY1, g_iY2);
|
||||||
|
}
|
||||||
|
|
||||||
//emit CallManage::getInstance()->sig_ChangeLeftScale(m_strUuid, form->m_strSlfName, m_strWellName, m_strTrackName, form->m_strLineName, form->m_iX1);
|
//emit CallManage::getInstance()->sig_ChangeLeftScale(m_strUuid, form->m_strSlfName, m_strWellName, m_strTrackName, form->m_strLineName, form->m_iX1);
|
||||||
|
|
||||||
|
|
@ -1310,7 +1322,8 @@ void FormDraw::s_addCrack(QString strUuid, QString strSlfName, QString strWellNa
|
||||||
//裂缝
|
//裂缝
|
||||||
QString strWaveName = "FRAC_HOLE.TABLE";
|
QString strWaveName = "FRAC_HOLE.TABLE";
|
||||||
|
|
||||||
//注意,没有对调XY轴
|
//注意,不对调XY轴
|
||||||
|
curv->m_bX2Y = false;
|
||||||
CPickFrac *pickFrac = new CPickFrac(curv, strSlfName, strWaveName, iMyWidth);
|
CPickFrac *pickFrac = new CPickFrac(curv, strSlfName, strWaveName, iMyWidth);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -1413,9 +1426,93 @@ void FormDraw::s_addGeoSection(QString strUuid, QString strSlfName, QString strW
|
||||||
QString strScaleType = "";
|
QString strScaleType = "";
|
||||||
//道-对象
|
//道-对象
|
||||||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "GeoSectionObject");
|
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "GeoSectionObject");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//沉积相
|
||||||
|
void FormDraw::s_addLogface(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;
|
||||||
|
|
||||||
|
//沉积相
|
||||||
|
QString strWaveName = "LITHA";
|
||||||
|
CDrawFac *drawFac = new CDrawFac(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, "LogfaceObject");
|
||||||
|
}
|
||||||
|
|
||||||
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
|
void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLineName,
|
||||||
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
|
double newLeftScale, double newRightScale, QString strScaleType, QColor lineColor, double width, Qt::PenStyle lineStyle)
|
||||||
|
|
@ -2324,6 +2421,7 @@ void FormDraw::initWave2(QMyCustomPlot *widget, QString strSlfName, QString strW
|
||||||
// widget->yAxis = xAxis;
|
// widget->yAxis = xAxis;
|
||||||
|
|
||||||
//注意,不对调XY轴
|
//注意,不对调XY轴
|
||||||
|
widget->m_bX2Y = false;
|
||||||
float nPerHight = 50;//25
|
float nPerHight = 50;//25
|
||||||
float nSpace = 1;
|
float nSpace = 1;
|
||||||
for (int i=0; i<m_Record; i++)
|
for (int i=0; i<m_Record; i++)
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,9 @@ public slots:
|
||||||
//地质层位道
|
//地质层位道
|
||||||
void s_addGeoSection(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);
|
||||||
|
|
||||||
|
//沉积相
|
||||||
|
void s_addLogface(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_addWave(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strWaveName);
|
||||||
void s_delWave(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);
|
void s_delWave(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,10 @@ FormTrack::FormTrack(QWidget *parent, QString strWellName, QString strTrackName)
|
||||||
connect(this, SIGNAL(sig_AddGeoSection(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)),
|
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)));
|
this, SLOT(s_addGeoSection(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(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString)));
|
connect(CallManage::getInstance(), SIGNAL(sig_Raise(QString, QString, QString, QString, QString)), this, SLOT(s_Raise(QString, QString, QString, QString, QString)));
|
||||||
|
|
||||||
|
|
@ -156,6 +160,10 @@ void FormTrack::Add(QString strSlfName, QString strWellName, QString strTrackNam
|
||||||
{
|
{
|
||||||
emit sig_AddGeoSection(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType);
|
emit sig_AddGeoSection(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormTrack::setDrawDt(QStringList listdt, float vmax, float vmin)
|
void FormTrack::setDrawDt(QStringList listdt, float vmax, float vmin)
|
||||||
|
|
@ -622,6 +630,39 @@ void FormTrack::s_addGeoSection(QString strSlfName, QString strWellName, QString
|
||||||
ui->tableWidget->setCellWidget(row, 0, formInfo);
|
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";
|
||||||
|
|
||||||
|
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 = "LogfaceObject";
|
||||||
|
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()
|
QJsonObject FormTrack::makeJson()
|
||||||
{
|
{
|
||||||
// 创建根对象
|
// 创建根对象
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ 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_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_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_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);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
@ -94,6 +95,7 @@ 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_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_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_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_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_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
|
void s_Raise(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,11 @@ void FormWell::s_NewTrack(QString strUuid, QString strWellName, QString strSlfNa
|
||||||
//地质层位道
|
//地质层位道
|
||||||
emit CallManage::getInstance()->sig_AddGeoSection(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
emit CallManage::getInstance()->sig_AddGeoSection(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||||||
}
|
}
|
||||||
|
else if(strType=="LogfaceObject")
|
||||||
|
{
|
||||||
|
//沉积相
|
||||||
|
emit CallManage::getInstance()->sig_AddLogface(m_strUuid, strSlfName, strWellName, strTrackName, strLineName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ui->tableWidget->resizeColumnsToContents(); // 调整列宽以适应内容
|
//ui->tableWidget->resizeColumnsToContents(); // 调整列宽以适应内容
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ SOURCES += \
|
||||||
../CallManage/CallManage.cpp \
|
../CallManage/CallManage.cpp \
|
||||||
../common/geometryutils.cpp \
|
../common/geometryutils.cpp \
|
||||||
ConsoleOutputWidget.cpp \
|
ConsoleOutputWidget.cpp \
|
||||||
|
DrawFac.cpp \
|
||||||
GeoIndicatorGenerator.cpp \
|
GeoIndicatorGenerator.cpp \
|
||||||
Gradient.cpp \
|
Gradient.cpp \
|
||||||
InDefTableDlg.cpp \
|
InDefTableDlg.cpp \
|
||||||
|
|
@ -39,8 +40,11 @@ SOURCES += \
|
||||||
PropertyWidget.cpp \
|
PropertyWidget.cpp \
|
||||||
QCPSizeHandle.cpp \
|
QCPSizeHandle.cpp \
|
||||||
QCPSizeHandleManager.cpp \
|
QCPSizeHandleManager.cpp \
|
||||||
|
TransparentDraggableFac.cpp \
|
||||||
TransparentDraggableGeoLith.cpp \
|
TransparentDraggableGeoLith.cpp \
|
||||||
TransparentDraggableGujing.cpp \
|
TransparentDraggableGujing.cpp \
|
||||||
|
TransparentDraggableMFac.cpp \
|
||||||
|
TransparentDraggablePhase.cpp \
|
||||||
TransparentDraggableRect.cpp \
|
TransparentDraggableRect.cpp \
|
||||||
TransparentDraggableResult.cpp \
|
TransparentDraggableResult.cpp \
|
||||||
TransparentDraggableSwallCore.cpp \
|
TransparentDraggableSwallCore.cpp \
|
||||||
|
|
@ -75,6 +79,7 @@ HEADERS += \
|
||||||
../common/geometryutils.h \
|
../common/geometryutils.h \
|
||||||
ConsoleOutputWidget.h \
|
ConsoleOutputWidget.h \
|
||||||
DraggablePixmap.h \
|
DraggablePixmap.h \
|
||||||
|
DrawFac.h \
|
||||||
GeoIndicatorGenerator.h \
|
GeoIndicatorGenerator.h \
|
||||||
Gradient.h \
|
Gradient.h \
|
||||||
InDefTableDlg.h \
|
InDefTableDlg.h \
|
||||||
|
|
@ -84,8 +89,11 @@ HEADERS += \
|
||||||
PropertyWidget.h \
|
PropertyWidget.h \
|
||||||
QCPSizeHandle.h \
|
QCPSizeHandle.h \
|
||||||
QCPSizeHandleManager.h \
|
QCPSizeHandleManager.h \
|
||||||
|
TransparentDraggableFac.h \
|
||||||
TransparentDraggableGeoLith.h \
|
TransparentDraggableGeoLith.h \
|
||||||
TransparentDraggableGujing.h \
|
TransparentDraggableGujing.h \
|
||||||
|
TransparentDraggableMFac.h \
|
||||||
|
TransparentDraggablePhase.h \
|
||||||
TransparentDraggableRect.h \
|
TransparentDraggableRect.h \
|
||||||
TransparentDraggableResult.h \
|
TransparentDraggableResult.h \
|
||||||
TransparentDraggableSwallCore.h \
|
TransparentDraggableSwallCore.h \
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,9 @@ void MainWindowCurve::initToolBar()
|
||||||
connect(m_deviAc, &QAction::triggered, this, &MainWindowCurve::s_Denv);//井斜方位图
|
connect(m_deviAc, &QAction::triggered, this, &MainWindowCurve::s_Denv);//井斜方位图
|
||||||
connect(m_electric_imagingAc, &QAction::triggered, this, &MainWindowCurve::s_DrawImage);//图像
|
connect(m_electric_imagingAc, &QAction::triggered, this, &MainWindowCurve::s_DrawImage);//图像
|
||||||
connect(m_GeoSectionAc, &QAction::triggered, this, &MainWindowCurve::s_NewGeoSection);//地质层位道
|
connect(m_GeoSectionAc, &QAction::triggered, this, &MainWindowCurve::s_NewGeoSection);//地质层位道
|
||||||
|
|
||||||
|
connect(m_logfaceAc, &QAction::triggered, this, &MainWindowCurve::s_NewLogface);//沉积相
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList MainWindowCurve::insertCol(int nW)
|
QStringList MainWindowCurve::insertCol(int nW)
|
||||||
|
|
@ -1275,6 +1278,17 @@ void MainWindowCurve::s_NewGeoSection()
|
||||||
NewWellAndTrack(sret.at(0), sret.at(1), "LAYER_DATA", "GeoSectionObject");
|
NewWellAndTrack(sret.at(0), sret.at(1), "LAYER_DATA", "GeoSectionObject");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//沉积相
|
||||||
|
void MainWindowCurve::s_NewLogface()
|
||||||
|
{
|
||||||
|
QStringList sret = this->getSelectWell();
|
||||||
|
if(sret.length() <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//新建井+道+曲线(首条)
|
||||||
|
NewWellAndTrack(sret.at(0), sret.at(1), "LITHA", "LogfaceObject");
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowCurve::s_NewTrackChangeWidth(QString strWellName)
|
void MainWindowCurve::s_NewTrackChangeWidth(QString strWellName)
|
||||||
{
|
{
|
||||||
qDebug() << "MainWindowCurve s_NewTrackChangeWidth";
|
qDebug() << "MainWindowCurve s_NewTrackChangeWidth";
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,9 @@ public slots:
|
||||||
void s_roseAc(); // 玫瑰图
|
void s_roseAc(); // 玫瑰图
|
||||||
void s_Jykt(); // 井眼垮塌矢量图
|
void s_Jykt(); // 井眼垮塌矢量图
|
||||||
void s_Denv(); // 井斜方位图
|
void s_Denv(); // 井斜方位图
|
||||||
void s_DrawImage(); // 图像 成图
|
void s_DrawImage(); // 图像 成图
|
||||||
void s_NewGeoSection(); // 地质层位道
|
void s_NewGeoSection(); // 地质层位道
|
||||||
|
void s_NewLogface(); // 沉积相
|
||||||
|
|
||||||
//
|
//
|
||||||
void s_Save();//保存
|
void s_Save();//保存
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@
|
||||||
#include "TransparentDraggableSwallCore.h"
|
#include "TransparentDraggableSwallCore.h"
|
||||||
#include "TransparentDraggableGujing.h"
|
#include "TransparentDraggableGujing.h"
|
||||||
#include "transparentdraggableimage.h"
|
#include "transparentdraggableimage.h"
|
||||||
|
#include "TransparentDraggableMFac.h"
|
||||||
|
#include "TransparentDraggablePhase.h"
|
||||||
|
#include "TransparentDraggableFac.h"
|
||||||
#include "qtcommonclass.h"
|
#include "qtcommonclass.h"
|
||||||
|
|
||||||
//是否隐藏刻度
|
//是否隐藏刻度
|
||||||
|
|
@ -494,6 +497,63 @@ void QMyCustomPlot::addGujingToPlot(double left_Low, double right_Hight, const Q
|
||||||
m_mapDraggable_Gujing[strUuid] = dragRect;
|
m_mapDraggable_Gujing[strUuid] = dragRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//沉积相-微相
|
||||||
|
void QMyCustomPlot::addMFacToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor)
|
||||||
|
{
|
||||||
|
QtCommonClass *qtCommon = new QtCommonClass(this);
|
||||||
|
QString strUuid = qtCommon->getUUid();
|
||||||
|
|
||||||
|
// 在初始化代码中
|
||||||
|
TransparentDraggableMFac *dragRect = new TransparentDraggableMFac(this, strUuid);
|
||||||
|
// 设置初始范围
|
||||||
|
dragRect->setRange(left_Low, right_Hight);
|
||||||
|
// 可选:设置颜色
|
||||||
|
dragRect->setColor(crColor); // 半透明白色
|
||||||
|
//最小宽度
|
||||||
|
dragRect->setMinWidth(0.1);
|
||||||
|
dragRect->setTitle(strText);
|
||||||
|
|
||||||
|
m_mapDraggableMFac[strUuid] = dragRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
//沉积相-亚相
|
||||||
|
void QMyCustomPlot::addPhaseToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor)
|
||||||
|
{
|
||||||
|
QtCommonClass *qtCommon = new QtCommonClass(this);
|
||||||
|
QString strUuid = qtCommon->getUUid();
|
||||||
|
|
||||||
|
// 在初始化代码中
|
||||||
|
TransparentDraggablePhase *dragRect = new TransparentDraggablePhase(this, strUuid);
|
||||||
|
// 设置初始范围
|
||||||
|
dragRect->setRange(left_Low, right_Hight);
|
||||||
|
// 可选:设置颜色
|
||||||
|
dragRect->setColor(crColor); // 半透明白色
|
||||||
|
//最小宽度
|
||||||
|
dragRect->setMinWidth(0.1);
|
||||||
|
dragRect->setTitle(strText);
|
||||||
|
|
||||||
|
m_mapDraggablePhase[strUuid] = dragRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
//沉积相-相
|
||||||
|
void QMyCustomPlot::addFacToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor)
|
||||||
|
{
|
||||||
|
QtCommonClass *qtCommon = new QtCommonClass(this);
|
||||||
|
QString strUuid = qtCommon->getUUid();
|
||||||
|
|
||||||
|
// 在初始化代码中
|
||||||
|
TransparentDraggableFac *dragRect = new TransparentDraggableFac(this, strUuid);
|
||||||
|
// 设置初始范围
|
||||||
|
dragRect->setRange(left_Low, right_Hight);
|
||||||
|
// 可选:设置颜色
|
||||||
|
dragRect->setColor(crColor); // 半透明白色
|
||||||
|
//最小宽度
|
||||||
|
dragRect->setMinWidth(0.1);
|
||||||
|
dragRect->setTitle(strText);
|
||||||
|
|
||||||
|
m_mapDraggableFac[strUuid] = dragRect;
|
||||||
|
}
|
||||||
|
|
||||||
void QMyCustomPlot::onResetZoom()
|
void QMyCustomPlot::onResetZoom()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ public:
|
||||||
QContextMenuEvent *m_event;
|
QContextMenuEvent *m_event;
|
||||||
|
|
||||||
bool m_bDrawRect = true;
|
bool m_bDrawRect = true;
|
||||||
|
bool m_bX2Y = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool m_bDrawCore_PHYSICS = false; //岩心分析
|
bool m_bDrawCore_PHYSICS = false; //岩心分析
|
||||||
|
|
@ -74,6 +75,9 @@ public:
|
||||||
QMap<QString, QObject*> m_mapDraggable_SwallCore;
|
QMap<QString, QObject*> m_mapDraggable_SwallCore;
|
||||||
QMap<QString, QObject*> m_mapDraggable_Gujing;
|
QMap<QString, QObject*> m_mapDraggable_Gujing;
|
||||||
QMap<QString, QObject*> m_mapDraggable_Image;
|
QMap<QString, QObject*> m_mapDraggable_Image;
|
||||||
|
QMap<QString, QObject*> m_mapDraggableMFac;
|
||||||
|
QMap<QString, QObject*> m_mapDraggablePhase;
|
||||||
|
QMap<QString, QObject*> m_mapDraggableFac;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slot_time();
|
void slot_time();
|
||||||
|
|
@ -94,6 +98,10 @@ public:
|
||||||
|
|
||||||
void addGujingToPlot(double left_Low, double right_Hight, const QString strResult);
|
void addGujingToPlot(double left_Low, double right_Hight, const QString strResult);
|
||||||
|
|
||||||
|
void addMFacToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor=QColor(255, 255, 255, 80));
|
||||||
|
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));
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void s_LineClicked(int index);
|
void s_LineClicked(int index);
|
||||||
void onResetZoom();
|
void onResetZoom();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user