优化波列数据的可视化,可自定义调色板
This commit is contained in:
parent
3688483f56
commit
108c753eb5
|
|
@ -49,6 +49,8 @@ signals:
|
||||||
|
|
||||||
//新建波列
|
//新建波列
|
||||||
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);
|
||||||
|
//删除波列
|
||||||
|
void sig_delWave(QString strUuid, QString strWellName, QString strTrackName, QString strLineName);
|
||||||
|
|
||||||
//属性
|
//属性
|
||||||
//左刻度
|
//左刻度
|
||||||
|
|
|
||||||
|
|
@ -818,3 +818,189 @@ bool getAliasNameFromIni(QString CurveName, QString &strAliasName, QString &strU
|
||||||
|
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getSystemColorNumber(QStringList &names)
|
||||||
|
{
|
||||||
|
QString strImagePath;
|
||||||
|
QString strPathTmp = QCoreApplication::applicationDirPath() + QDir::separator();
|
||||||
|
strImagePath = QDir::toNativeSeparators( strPathTmp );
|
||||||
|
QString filecfg=strImagePath+"image"+QDir::separator()+"colortable"+QDir::separator()+"colortable.cfg";
|
||||||
|
FILE *fp1=fopen(filecfg.toStdString().c_str(),"rt");
|
||||||
|
if(!fp1) return -1;
|
||||||
|
char buf[100];
|
||||||
|
QString str;
|
||||||
|
int i=0;
|
||||||
|
while(!feof(fp1)) {
|
||||||
|
fscanf(fp1,"%s",buf);
|
||||||
|
str=buf;
|
||||||
|
//读取全部
|
||||||
|
//if(str.indexOf("custom",Qt::CaseInsensitive)>=0) continue;
|
||||||
|
names.push_back(str);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
fclose(fp1);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSystemColor(int nIndex,QVector<MyColorItem> &colorList,bool inpolation)
|
||||||
|
{
|
||||||
|
colorList.clear();
|
||||||
|
MyColorItem itemColor;
|
||||||
|
QString strImagePath;
|
||||||
|
QString strPathTmp = QCoreApplication::applicationDirPath() + QDir::separator();
|
||||||
|
strImagePath = QDir::toNativeSeparators( strPathTmp );
|
||||||
|
QString filecfg=strImagePath+"image"+QDir::separator()+"colortable"+QDir::separator()+"colortable.cfg";
|
||||||
|
FILE *fp1=fopen(filecfg.toStdString().c_str(),"rt");
|
||||||
|
if(!fp1) return -1;
|
||||||
|
char buf[100];
|
||||||
|
QString str;
|
||||||
|
int i=0;
|
||||||
|
while(!feof(fp1)) {
|
||||||
|
fscanf(fp1,"%s",buf);
|
||||||
|
if(i>=nIndex) {
|
||||||
|
str=buf;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
fclose(fp1);
|
||||||
|
if(str.isEmpty()) return -1;
|
||||||
|
QString filename=strImagePath+"image"+QDir::separator()+"colortable"+QDir::separator()+str;
|
||||||
|
FILE *fp=fopen(filename.toStdString().c_str(),"rt");
|
||||||
|
if(!fp) return -1;
|
||||||
|
float r,g,b;
|
||||||
|
QStringList strs;
|
||||||
|
int colornum=0;
|
||||||
|
while(!feof(fp)) {
|
||||||
|
char *ret=fgets(buf,100,fp);
|
||||||
|
if(!ret) break;
|
||||||
|
str=buf;
|
||||||
|
str.replace("\r","");
|
||||||
|
str.replace("\n","");
|
||||||
|
str.replace("\t"," ");
|
||||||
|
if(str.indexOf("#")>-1) continue;
|
||||||
|
if(str.indexOf("=")>-1) continue;
|
||||||
|
if(str.indexOf("R",Qt::CaseInsensitive)>-1) continue;
|
||||||
|
if(str.indexOf("G",Qt::CaseInsensitive)>-1) continue;
|
||||||
|
if(str.indexOf("B",Qt::CaseInsensitive)>-1) continue;
|
||||||
|
strs=str.split(" ");
|
||||||
|
strs.removeAll("");
|
||||||
|
if(strs.size()!=3) continue;
|
||||||
|
r=strs[0].toFloat();
|
||||||
|
g=strs[1].toFloat();
|
||||||
|
b=strs[2].toFloat();
|
||||||
|
if(g<=1||b<=1) if(r>0&&r<=1) r*=255;
|
||||||
|
if(r<=1||b<=1) if(g>0&&g<=1) g*=255;
|
||||||
|
if(r<=1||g<=1) if(b>0&&b<=1) b*=255;
|
||||||
|
int rr=r,gg=g,bb=b;
|
||||||
|
colorList.push_back(MyColorItem(QColor(rr,gg,bb)));
|
||||||
|
colornum++;
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
if(colornum<PAITOTALCOLOR_MIN) colornum=PAITOTALCOLOR_MIN; // 最小总颜色数目
|
||||||
|
if(colornum>PAITOTALCOLOR_MAX) colornum=PAITOTALCOLOR_MAX; // 最大总颜色数目
|
||||||
|
if(inpolation)
|
||||||
|
{
|
||||||
|
colorList=myInpolation(colorList,colornum);//SYSTEM_INPOLATION);
|
||||||
|
}
|
||||||
|
return colorList.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<MyColorItem> myInpolation(const QVector<MyColorItem> &colorList,int totalColorNum)
|
||||||
|
{
|
||||||
|
QVector<MyColorItem> newColorList;
|
||||||
|
|
||||||
|
// 填充新的颜色项目
|
||||||
|
for(int i=0;i<totalColorNum;i++)
|
||||||
|
newColorList.push_back(MyColorItem());
|
||||||
|
|
||||||
|
float gap=(colorList.count()-1)*1.0/(totalColorNum-1);
|
||||||
|
for(int i=0;i<totalColorNum;i++)
|
||||||
|
{
|
||||||
|
float pos=i*gap;
|
||||||
|
int index1=pos;
|
||||||
|
if(::fabs(pos-index1)<1.0e-10)
|
||||||
|
{
|
||||||
|
newColorList[i]=colorList[index1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int index2=index1+1;
|
||||||
|
if(index2>=colorList.size()) index2=colorList.size()-1;
|
||||||
|
float flgap1=pos-index1;
|
||||||
|
float flgap2=index2-pos;
|
||||||
|
int r=colorList[index1].color.red()*flgap2+colorList[index2].color.red()*flgap1;
|
||||||
|
int g=colorList[index1].color.green()*flgap2+colorList[index2].color.green()*flgap1;
|
||||||
|
int b=colorList[index1].color.blue()*flgap2+colorList[index2].color.blue()*flgap1;
|
||||||
|
newColorList[i]=MyColorItem(QColor(r,g,b));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return newColorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取定制的颜色方案
|
||||||
|
void ReadColorSettings(QList<SchemeColor> &shcemeLis)
|
||||||
|
{
|
||||||
|
MyColorItem itemColor;
|
||||||
|
QString strImagePath;
|
||||||
|
QString strPathTmp = QCoreApplication::applicationDirPath() + QDir::separator();
|
||||||
|
strImagePath = QDir::toNativeSeparators( strPathTmp );
|
||||||
|
QString filecfg=strImagePath+"image"+QDir::separator()+"colortable"+QDir::separator()+"colortable.cfg";
|
||||||
|
FILE *fp1=fopen(filecfg.toStdString().c_str(),"rt");
|
||||||
|
if(!fp1) return;
|
||||||
|
char buf[100];
|
||||||
|
QString str,name;
|
||||||
|
int i=0;
|
||||||
|
while(!feof(fp1)) {
|
||||||
|
fscanf(fp1,"%s",buf);
|
||||||
|
name=buf;
|
||||||
|
if(name.indexOf("custom",Qt::CaseInsensitive)>=0) {
|
||||||
|
QString filename=strImagePath+"image"+QDir::separator()+"colortable"+QDir::separator()+name;
|
||||||
|
FILE *fp=fopen(filename.toStdString().c_str(),"rt");
|
||||||
|
if(!fp) return;
|
||||||
|
QVector<MyColorItem> colorList;
|
||||||
|
float r,g,b;
|
||||||
|
QStringList strs;
|
||||||
|
while(!feof(fp)) {
|
||||||
|
char *ret=fgets(buf,100,fp);
|
||||||
|
if(!ret) break;
|
||||||
|
str=buf;
|
||||||
|
str.replace("\r","");
|
||||||
|
str.replace("\n","");
|
||||||
|
if(str.indexOf("#")>-1) continue;
|
||||||
|
if(str.indexOf("=")>-1) continue;
|
||||||
|
if(str.indexOf("R",Qt::CaseInsensitive)>-1) continue;
|
||||||
|
if(str.indexOf("G",Qt::CaseInsensitive)>-1) continue;
|
||||||
|
if(str.indexOf("B",Qt::CaseInsensitive)>-1) continue;
|
||||||
|
strs=str.split(" ");
|
||||||
|
strs.removeAll("");
|
||||||
|
if(strs.size()!=3) continue;
|
||||||
|
r=strs[0].toFloat();
|
||||||
|
g=strs[1].toFloat();
|
||||||
|
b=strs[2].toFloat();
|
||||||
|
if((r>0&&r<=1)||(g>0&&g<=1)||(b>0&&b<=1)) {
|
||||||
|
r*=255;
|
||||||
|
g*=255;
|
||||||
|
b*=255;
|
||||||
|
}
|
||||||
|
int rr=r,gg=g,bb=b;
|
||||||
|
colorList.push_back(MyColorItem(QColor(rr,gg,bb)));
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
SchemeColor schemeItem;
|
||||||
|
name=name.mid(name.lastIndexOf("\\")+1);
|
||||||
|
if(name.lastIndexOf(".rgb",-1,Qt::CaseInsensitive)>-1)name=name.mid(0,name.lastIndexOf(".rgb",-1,Qt::CaseInsensitive));
|
||||||
|
schemeItem.schemeName=name;
|
||||||
|
schemeItem.colorList=colorList;
|
||||||
|
schemeItem.isDirty=false;
|
||||||
|
schemeItem.isCustom=true;
|
||||||
|
schemeItem.currentIndex=0;
|
||||||
|
shcemeLis.push_back(schemeItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(fp1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,109 @@
|
||||||
|
|
||||||
#pragma execution_character_set("utf-8")
|
#pragma execution_character_set("utf-8")
|
||||||
|
|
||||||
|
#define PAITOTALCOLOR_MIN 2 // 最小总颜色数目
|
||||||
|
#define PAITOTALCOLOR_MAX 65 // 最大总颜色数目
|
||||||
|
#define SECTIONVIEW_NUM 255
|
||||||
|
#define SYSTEM_INPOLATION 65 // 系统缺省颜色需要插值成的数目
|
||||||
|
|
||||||
|
struct My_ColorItem
|
||||||
|
{
|
||||||
|
QRgb color; // 颜色值
|
||||||
|
float fromValue; // 对应的振幅开始值
|
||||||
|
float toValue; // 对应的振幅的结束值
|
||||||
|
char strComments[64]; // 描述信息
|
||||||
|
};
|
||||||
|
class MyColorItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyColorItem()
|
||||||
|
{
|
||||||
|
color=QColor(0,0,0);
|
||||||
|
fromValue=toValue=0;
|
||||||
|
strComments="";
|
||||||
|
}
|
||||||
|
MyColorItem(const QColor &color,float value=0)
|
||||||
|
{
|
||||||
|
this->color=color;
|
||||||
|
this->fromValue=this->toValue=value;
|
||||||
|
strComments="";
|
||||||
|
}
|
||||||
|
|
||||||
|
MyColorItem(const MyColorItem &other)
|
||||||
|
{
|
||||||
|
color=other.color;
|
||||||
|
fromValue=other.fromValue;
|
||||||
|
toValue=other.toValue;
|
||||||
|
strComments=other.strComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
MyColorItem & operator=(const MyColorItem &other)
|
||||||
|
{
|
||||||
|
color=other.color;
|
||||||
|
fromValue=other.fromValue;
|
||||||
|
toValue=other.toValue;
|
||||||
|
strComments=other.strComments;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
QColor color; // 颜色值
|
||||||
|
float fromValue; // 对应的振幅开始值
|
||||||
|
float toValue; // 对应的振幅的结束值
|
||||||
|
QString strComments; // 描述信息
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class SchemeColor
|
||||||
|
* @brief 描述一种颜色方案
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct Scheme_Color
|
||||||
|
{
|
||||||
|
char schemeName[64];
|
||||||
|
int size;
|
||||||
|
struct My_ColorItem colorList[256];
|
||||||
|
bool isDirty;
|
||||||
|
bool isCustom;
|
||||||
|
int currentIndex; // 当前编辑的位置
|
||||||
|
};
|
||||||
|
class SchemeColor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SchemeColor()
|
||||||
|
{
|
||||||
|
schemeName="";
|
||||||
|
colorList.clear();
|
||||||
|
isDirty=isCustom=false;
|
||||||
|
currentIndex=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SchemeColor(const SchemeColor &other)
|
||||||
|
{
|
||||||
|
schemeName=other.schemeName;
|
||||||
|
colorList=other.colorList;
|
||||||
|
isDirty=other.isDirty;
|
||||||
|
isCustom=other.isCustom;
|
||||||
|
currentIndex=other.currentIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SchemeColor & operator=(const SchemeColor &other)
|
||||||
|
{
|
||||||
|
schemeName=other.schemeName;
|
||||||
|
colorList=other.colorList;
|
||||||
|
isDirty=other.isDirty;
|
||||||
|
isCustom=other.isCustom;
|
||||||
|
currentIndex=other.currentIndex;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString schemeName;
|
||||||
|
QVector<MyColorItem> colorList;
|
||||||
|
bool isDirty;
|
||||||
|
bool isCustom;
|
||||||
|
int currentIndex; // 当前编辑的位置
|
||||||
|
};
|
||||||
|
|
||||||
//const double PI = osg::PI;
|
//const double PI = osg::PI;
|
||||||
const double PI = 3.14159265358979323846;
|
const double PI = 3.14159265358979323846;
|
||||||
struct LayerInfo
|
struct LayerInfo
|
||||||
|
|
@ -83,6 +186,25 @@ void SetSystemExisting(bool exiting);
|
||||||
bool SystemExiting();
|
bool SystemExiting();
|
||||||
bool getAllSlf(QString prjname, QVector<QString> &vecSlfList, QVector<QString> &vecWellList);//直方图,获取当前工程下的slf
|
bool getAllSlf(QString prjname, QVector<QString> &vecSlfList, QVector<QString> &vecWellList);//直方图,获取当前工程下的slf
|
||||||
bool getAliasNameFromIni(QString CurveName, QString &strAliasName, QString &strUnit);//曲线别名,单位
|
bool getAliasNameFromIni(QString CurveName, QString &strAliasName, QString &strUnit);//曲线别名,单位
|
||||||
|
/**
|
||||||
|
* @brief 获取系统缺省的系统颜色
|
||||||
|
* @param nIndex 系统颜色序号
|
||||||
|
* @param colorList 返回颜色列表
|
||||||
|
* @param 当前颜色方案使用的总颜色数目
|
||||||
|
*/
|
||||||
|
int getSystemColor(int nIndex,QVector<MyColorItem> &colorList,bool inpolation);
|
||||||
|
int getSystemColorNumber(QStringList &names);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 将制定的颜色表插值成指定的颜色
|
||||||
|
* @param colorList 控制颜色表
|
||||||
|
* @param 当掐颜色方案使用的总颜色数目
|
||||||
|
* @return 返回插值以后的颜色
|
||||||
|
*/
|
||||||
|
QVector<MyColorItem> myInpolation(const QVector<MyColorItem> &colorList,int totalColorNum);
|
||||||
|
|
||||||
|
// 读取定制的颜色方案
|
||||||
|
void ReadColorSettings(QList<SchemeColor> &shcemeLis);
|
||||||
|
|
||||||
struct WellHead
|
struct WellHead
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ FormDraw::FormDraw(QWidget *parent, QString strWellName, QString strTrackName) :
|
||||||
connect(CallManage::getInstance(), SIGNAL(sig_MouseMove(QString, QString, QString, float)), this, SLOT(s_MouseMove(QString, QString, QString, float)));
|
connect(CallManage::getInstance(), SIGNAL(sig_MouseMove(QString, QString, QString, float)), this, SLOT(s_MouseMove(QString, QString, QString, float)));
|
||||||
//波列
|
//波列
|
||||||
connect(CallManage::getInstance(), SIGNAL(sig_AddWave(QString, QString, QString, QString, QString)), this, SLOT(s_addWave(QString, QString, QString, QString, QString)));
|
connect(CallManage::getInstance(), SIGNAL(sig_AddWave(QString, QString, QString, QString, QString)), this, SLOT(s_addWave(QString, QString, QString, QString, QString)));
|
||||||
|
connect(CallManage::getInstance(), SIGNAL(sig_delWave(QString, QString, QString, QString)), this, SLOT(s_delWave(QString, QString, QString, QString)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -328,6 +329,52 @@ void FormDraw::s_delLine(QString strUuid, QString strWellName, QString strTrackN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FormDraw::s_delWave(QString strUuid, QString strWellName, QString strTrackName, QString strLineName)
|
||||||
|
{
|
||||||
|
//井名&道名不一致
|
||||||
|
if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDebug() << "FormDraw s_delWave";
|
||||||
|
|
||||||
|
if(m_listWaveName.contains(strLineName))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "FormDraw strLineName not exist! " << strLineName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 获取当前widget的所有子控件
|
||||||
|
const QObjectList &children = this->children();
|
||||||
|
// 遍历子控件列表
|
||||||
|
for (QObject *child : children) {
|
||||||
|
// 判断子控件是否为QWidget类型
|
||||||
|
if (QWidget *childWidget = qobject_cast<QWidget *>(child)) {
|
||||||
|
// 打印子控件的信息,使用缩进表示层级关系
|
||||||
|
//qDebug() << QString("%1").arg(childWidget->objectName());
|
||||||
|
QString strObjName = childWidget->objectName();
|
||||||
|
if(strObjName=="QMyCustomPlot")
|
||||||
|
{
|
||||||
|
QMyCustomPlot *form = (QMyCustomPlot*)childWidget;
|
||||||
|
if(form->m_strLineName == strLineName)
|
||||||
|
{
|
||||||
|
childWidget->deleteLater(); // 安排控件的删除,稍后执行
|
||||||
|
m_listWaveName.removeOne(strLineName);
|
||||||
|
//break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FormDraw::s_MouseMove(QString strUuid, QString strWellName, QString strTrackName, float dep)
|
void FormDraw::s_MouseMove(QString strUuid, QString strWellName, QString strTrackName, float dep)
|
||||||
{
|
{
|
||||||
//井名&道名不一致
|
//井名&道名不一致
|
||||||
|
|
@ -833,9 +880,24 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa
|
||||||
colorScale->axis()->setLabel("Magnetic Field Strength");
|
colorScale->axis()->setLabel("Magnetic Field Strength");
|
||||||
|
|
||||||
// 将颜色贴图的“颜色渐变”设置为其中一个预设
|
// 将颜色贴图的“颜色渐变”设置为其中一个预设
|
||||||
colorMap->setGradient(QCPColorGradient::gpPolar);//gpJet);
|
//colorMap->setGradient(QCPColorGradient::gpPolar);//gpJet);
|
||||||
// 我们还可以创建一个QCPColorGradient实例并向其中添加自己的颜色
|
// 我们还可以创建一个QCPColorGradient实例并向其中添加自己的颜色
|
||||||
// 渐变,请参阅QCPColorGradient的文档以获取可能的效果.
|
// 渐变,请参阅QCPColorGradient的文档以获取可能的效果.
|
||||||
|
int nIndex=11;
|
||||||
|
QVector<MyColorItem> colorList;
|
||||||
|
bool inpolation = true;
|
||||||
|
int iColorNum = getSystemColor(nIndex, colorList, inpolation);
|
||||||
|
|
||||||
|
QCPColorGradient gradient;
|
||||||
|
for(int i=0; i<iColorNum; i++)
|
||||||
|
{
|
||||||
|
double dbTmpIndex=(double)(i+1)/iColorNum;
|
||||||
|
gradient.setColorStopAt(dbTmpIndex, colorList[i].color); // x% 位置的颜色
|
||||||
|
}
|
||||||
|
// gradient.setColorStopAt(0, Qt::white); // 0% 位置的颜色
|
||||||
|
// gradient.setColorStopAt(1, Qt::black); // 100% 位置的颜色
|
||||||
|
colorMap->setGradient(gradient);
|
||||||
|
|
||||||
|
|
||||||
// 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内:
|
// 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内:
|
||||||
colorMap->rescaleDataRange();
|
colorMap->rescaleDataRange();
|
||||||
|
|
@ -927,7 +989,7 @@ void FormDraw::dragEnterEvent(QDragEnterEvent* event)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
event->ignore();
|
event->ignore();
|
||||||
QApplication::setOverrideCursor(Qt::ForbiddenCursor); // 设置鼠标为不可添加状态
|
//QApplication::setOverrideCursor(Qt::ForbiddenCursor); // 设置鼠标为不可添加状态
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -989,8 +1051,8 @@ void FormDraw::dropEvent(QDropEvent* event)
|
||||||
|
|
||||||
if(m_strWellName == strWellName)
|
if(m_strWellName == strWellName)
|
||||||
{
|
{
|
||||||
//新建曲线
|
//新建波列
|
||||||
//emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strWaveName);
|
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strWaveName);
|
||||||
|
|
||||||
// 接受拖拽事件
|
// 接受拖拽事件
|
||||||
event->setDropAction(Qt::MoveAction);
|
event->setDropAction(Qt::MoveAction);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ public slots:
|
||||||
|
|
||||||
//
|
//
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FORMDRAW_H
|
#endif // FORMDRAW_H
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include "geometryutils.h"
|
||||||
|
|
||||||
//曲线名称(单个)
|
//曲线名称(单个)
|
||||||
FormInfo::FormInfo(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor) :
|
FormInfo::FormInfo(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor) :
|
||||||
|
|
@ -22,7 +23,7 @@ FormInfo::FormInfo(QWidget *parent, QString strSlfName, QString strWellName, QSt
|
||||||
m_strLineName = strLineName;
|
m_strLineName = strLineName;
|
||||||
m_lineColor = lineColor;
|
m_lineColor = lineColor;
|
||||||
//
|
//
|
||||||
m_dWidth = 2;
|
m_dWidth = 3;
|
||||||
m_lineStyle = Qt::SolidLine;
|
m_lineStyle = Qt::SolidLine;
|
||||||
m_newFillMode = "无填充";
|
m_newFillMode = "无填充";
|
||||||
m_newHeadFill = "不绘制";
|
m_newHeadFill = "不绘制";
|
||||||
|
|
@ -179,12 +180,27 @@ void FormInfo::paintEvent(QPaintEvent* event)
|
||||||
painter.drawText(rect.left(), rect.top(), rect.width(), rect.height()/3, Qt::AlignCenter, m_strAliasName);
|
painter.drawText(rect.left(), rect.top(), rect.width(), rect.height()/3, Qt::AlignCenter, m_strAliasName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nIndex=1;
|
||||||
|
QVector<MyColorItem> colorList;
|
||||||
|
bool inpolation = true;
|
||||||
|
int iColorNum = getSystemColor(nIndex, colorList, inpolation);
|
||||||
|
if(m_strType=="waveObject")
|
||||||
|
{
|
||||||
|
//波列
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QFont font2("微软雅黑", 8, false, false);
|
QFont font2("微软雅黑", 8, false, false);
|
||||||
painter.setFont(font2);
|
painter.setFont(font2);
|
||||||
painter.setPen(m_lineColor);
|
painter.setPen(m_lineColor);
|
||||||
//painter.drawText(rect.left() + 20, 55, m_strUnit);
|
//painter.drawText(rect.left() + 20, 55, m_strUnit);
|
||||||
//painter.drawText(rect.left() + 20, 80, QString::number(m_vmin)+" ~ "+QString::number(m_vmax));
|
//painter.drawText(rect.left() + 20, 80, QString::number(m_vmin)+" ~ "+QString::number(m_vmax));
|
||||||
|
if(m_strType=="curveObject")
|
||||||
|
{
|
||||||
|
//曲线
|
||||||
painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3, Qt::AlignCenter, m_strUnit);
|
painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3, Qt::AlignCenter, m_strUnit);
|
||||||
|
}
|
||||||
|
|
||||||
painter.drawText(rect.left(), rect.top()+rect.height()*2/3, rect.width(), rect.height()/3 ,Qt::AlignCenter, QString::number(m_vmin)+" ~ "+QString::number(m_vmax));
|
painter.drawText(rect.left(), rect.top()+rect.height()*2/3, rect.width(), rect.height()/3 ,Qt::AlignCenter, QString::number(m_vmin)+" ~ "+QString::number(m_vmax));
|
||||||
|
|
||||||
QWidget::paintEvent(event);
|
QWidget::paintEvent(event);
|
||||||
|
|
@ -203,7 +219,7 @@ void FormInfo::dragEnterEvent(QDragEnterEvent* event)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
event->ignore();
|
event->ignore();
|
||||||
QApplication::setOverrideCursor(Qt::ForbiddenCursor); // 设置鼠标为不可添加状态
|
//QApplication::setOverrideCursor(Qt::ForbiddenCursor); // 设置鼠标为不可添加状态
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -255,6 +255,8 @@ void PreQTableWidget::performDrag()
|
||||||
|
|
||||||
FormInfo *formInfo = (FormInfo*)myWidget;//获得widget
|
FormInfo *formInfo = (FormInfo*)myWidget;//获得widget
|
||||||
|
|
||||||
|
if(formInfo->m_strType == "curveObject")
|
||||||
|
{
|
||||||
//曲线对象(AC、BS...)
|
//曲线对象(AC、BS...)
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
// 这里需要根据你的item数据来设置mimeData,例如:
|
// 这里需要根据你的item数据来设置mimeData,例如:
|
||||||
|
|
@ -280,6 +282,35 @@ void PreQTableWidget::performDrag()
|
||||||
//m_listLineName.removeOne(formInfo->m_strLineName);
|
//m_listLineName.removeOne(formInfo->m_strLineName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(formInfo->m_strType == "waveObject")
|
||||||
|
{
|
||||||
|
//波列对象
|
||||||
|
QMimeData *mimeData = new QMimeData;
|
||||||
|
// 这里需要根据你的item数据来设置mimeData,例如:
|
||||||
|
mimeData->setText(formInfo->m_strSlfName + "#$$#"+ formInfo->m_strWellName + "#$$#" +formInfo->m_strLineName);
|
||||||
|
// 创建QDrag对象
|
||||||
|
QDrag *drag = new QDrag(this);
|
||||||
|
drag->setMimeData(mimeData);
|
||||||
|
// 可以设置拖拽时的光标图标
|
||||||
|
QRect itemRect = visualItemRect(currentItem()); // 获取项的矩形区域
|
||||||
|
QPixmap itemPixmap = QWidget::grab(itemRect);//QPixmap::grabWidget(this, itemRect); // 获取项的屏幕截图
|
||||||
|
// 调整拖拽光标的热点,使其位于截图的中心
|
||||||
|
drag->setPixmap(itemPixmap);
|
||||||
|
|
||||||
|
// 执行拖拽操作
|
||||||
|
m_AddSuc = false;
|
||||||
|
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
|
||||||
|
if (dropAction == Qt::MoveAction) { //&& m_AddSuc
|
||||||
|
// 处理拖拽结束的逻辑,例如从界面上移除拖拽的项
|
||||||
|
removeRow(iCurrentRow);
|
||||||
|
//删除波列
|
||||||
|
emit CallManage::getInstance()->sig_delWave(m_strUuid, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName);
|
||||||
|
//
|
||||||
|
//m_listLineName.removeOne(formInfo->m_strLineName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// if(!currentItem())
|
// if(!currentItem())
|
||||||
// {
|
// {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
|
||||||
//this->setOpenGl(true);//不开启,电脑不支持会卡
|
//this->setOpenGl(true);//不开启,电脑不支持会卡
|
||||||
this->setNotAntialiasedElements(QCP::aeAll); // 关闭所有抗锯齿
|
this->setNotAntialiasedElements(QCP::aeAll); // 关闭所有抗锯齿
|
||||||
|
|
||||||
|
//jyl
|
||||||
xAxis->setTickLabels(false);
|
xAxis->setTickLabels(false);
|
||||||
yAxis->setTickLabels(false);
|
yAxis->setTickLabels(false);
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ QtProjectWidgets::QtProjectWidgets(QWidget *parent)
|
||||||
|
|
||||||
//为树 tree 创建信号槽,鼠标press时会触发对应的信号。
|
//为树 tree 创建信号槽,鼠标press时会触发对应的信号。
|
||||||
connect(ui->treeWidget, &QTreeWidget::itemPressed, this, &QtProjectWidgets::onItemClicked);
|
connect(ui->treeWidget, &QTreeWidget::itemPressed, this, &QtProjectWidgets::onItemClicked);
|
||||||
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &QtProjectWidgets::onItemChanged);
|
//connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &QtProjectWidgets::onItemChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtProjectWidgets::~QtProjectWidgets()
|
QtProjectWidgets::~QtProjectWidgets()
|
||||||
|
|
@ -468,8 +468,8 @@ void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, Q
|
||||||
itemSheetChild->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
itemSheetChild->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||||||
itemSheetChild->setIcon(0, iconSheet);
|
itemSheetChild->setIcon(0, iconSheet);
|
||||||
//在创建的每个节点下,加上下面代码
|
//在创建的每个节点下,加上下面代码
|
||||||
itemSheetChild->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsDragEnabled); //设置树形控件子项的属性
|
// itemSheetChild->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsDragEnabled); //设置树形控件子项的属性
|
||||||
itemSheetChild->setCheckState(0, Qt::Unchecked);//也可以是其他状态
|
// itemSheetChild->setCheckState(0, Qt::Unchecked);//也可以是其他状态
|
||||||
|
|
||||||
if (0 == itemSheet->childCount())
|
if (0 == itemSheet->childCount())
|
||||||
{
|
{
|
||||||
|
|
@ -540,8 +540,8 @@ void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, Q
|
||||||
itemCurveLog->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
itemCurveLog->setData(0, Qt::UserRole + 2, wellname); // 存储额外数据,井名
|
||||||
itemCurveLog->setIcon(0, iconSheet);
|
itemCurveLog->setIcon(0, iconSheet);
|
||||||
//在创建的每个节点下,加上下面代码(check框)
|
//在创建的每个节点下,加上下面代码(check框)
|
||||||
itemCurveLog->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsDragEnabled); //设置树形控件子项的属性
|
// itemCurveLog->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsTristate | Qt::ItemIsDragEnabled); //设置树形控件子项的属性
|
||||||
itemCurveLog->setCheckState(0, Qt::Unchecked);//也可以是其他状态
|
// itemCurveLog->setCheckState(0, Qt::Unchecked);//也可以是其他状态
|
||||||
if (0 == itemCurve->childCount())
|
if (0 == itemCurve->childCount())
|
||||||
{
|
{
|
||||||
itemwell->addChild(itemCurve);//添加一级子节点
|
itemwell->addChild(itemCurve);//添加一级子节点
|
||||||
|
|
@ -881,23 +881,23 @@ void QtProjectWidgets::onItemClicked(QTreeWidgetItem* item, int index)
|
||||||
//勾选/不勾选树图节点
|
//勾选/不勾选树图节点
|
||||||
void QtProjectWidgets::onItemChanged(QTreeWidgetItem* item, int index)
|
void QtProjectWidgets::onItemChanged(QTreeWidgetItem* item, int index)
|
||||||
{
|
{
|
||||||
qDebug() << "QtProjectWidgets onItemChanged";
|
// qDebug() << "QtProjectWidgets onItemChanged";
|
||||||
QString strTreeTag = item->data(0, Qt::UserRole).toString();
|
// QString strTreeTag = item->data(0, Qt::UserRole).toString();
|
||||||
if (strTreeTag == "curveObject" || strTreeTag == "tableObject"){
|
// if (strTreeTag == "curveObject" || strTreeTag == "tableObject"){
|
||||||
//曲线对象(AC、BS...) || 表格对象
|
// //曲线对象(AC、BS...) || 表格对象
|
||||||
m_strCurveObjectName = item->text(0);
|
// m_strCurveObjectName = item->text(0);
|
||||||
m_strSlfName = item->data(0, Qt::UserRole+1).toString();
|
// m_strSlfName = item->data(0, Qt::UserRole+1).toString();
|
||||||
//
|
// //
|
||||||
bool bCkecked = false;
|
// bool bCkecked = false;
|
||||||
if(item->checkState(0) == Qt::Checked)
|
// if(item->checkState(0) == Qt::Checked)
|
||||||
{
|
// {
|
||||||
bCkecked = true;
|
// bCkecked = true;
|
||||||
}
|
// }
|
||||||
//曲线("*.slf", "AC", "curveObject", true)
|
// //曲线("*.slf", "AC", "curveObject", true)
|
||||||
//表格("*.slf“, "LAYER_DATA", "tableObject", false)
|
// //表格("*.slf“, "LAYER_DATA", "tableObject", false)
|
||||||
//(m_strSlfName, m_strCurveObjectName, strTreeTag, bCkecked)
|
// //(m_strSlfName, m_strCurveObjectName, strTreeTag, bCkecked)
|
||||||
|
|
||||||
//插件测试(信号槽)
|
// //插件测试(信号槽)
|
||||||
emit CallManage::getInstance()->sig_testPlugin(m_strCurveObjectName);
|
// emit CallManage::getInstance()->sig_testPlugin(m_strCurveObjectName);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user