左侧树图的表格项,追加拖拽处理
This commit is contained in:
parent
323769671a
commit
9b7d6d8936
|
|
@ -799,23 +799,23 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa
|
|||
|
||||
int _nSamples = _wave.TimeSamples;
|
||||
|
||||
char *value=new char[(_wave.TimeSamples+1)*m_Record*_wave.CodeLen+1];
|
||||
char *value=new char[(_nSamples+1)*m_Record*_wave.CodeLen+1];
|
||||
logio->ReadWave(index,_SDep,m_Record,(void *)value);
|
||||
logio->CloseWave(index);
|
||||
delete logio;
|
||||
|
||||
float vmax = 0;//(float)_wave.TimeSamples;
|
||||
float vmax = 0;//(float)_nSamples;
|
||||
float vmin = 0;
|
||||
//
|
||||
double** wavedata;
|
||||
wavedata = new double*[_wave.TimeSamples];
|
||||
for(int kk = 0;kk<_wave.TimeSamples;kk++){
|
||||
wavedata = new double*[_nSamples];
|
||||
for(int kk = 0;kk<_nSamples;kk++){
|
||||
wavedata[kk] = new double[m_Record];
|
||||
}
|
||||
|
||||
for (int i=0; i<m_Record; i++)
|
||||
{
|
||||
for(int kk = 0;kk<_wave.TimeSamples;kk++)
|
||||
for(int kk = 0;kk<_nSamples;kk++)
|
||||
{
|
||||
double val = GetData(_wave.RepCode,(char *)&value[(kk)*_wave.CodeLen+i*_nSamples*_wave.CodeLen]);
|
||||
wavedata[kk][i] = val;
|
||||
|
|
@ -855,7 +855,7 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa
|
|||
// set up the QCPColorMap:
|
||||
QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis);
|
||||
int nx = m_Record;
|
||||
int ny = _wave.TimeSamples;
|
||||
int ny = _nSamples;
|
||||
colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点
|
||||
colorMap->data()->setRange(QCPRange(g_iY1, g_iY2), QCPRange(vmin, vmax)); // 并在键(x)和值(y)维上跨越坐标范围-4..4
|
||||
// :现在,我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据:
|
||||
|
|
@ -864,25 +864,19 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa
|
|||
{
|
||||
for (int yIndex=0; yIndex<ny; ++yIndex)
|
||||
{
|
||||
// colorMap->data()->cellToCoord(xIndex, yIndex, &x, &y);
|
||||
// double r = 3*qSqrt(x*x+y*y)+1e-2;
|
||||
// z = 2*x*(qCos(r+2)/r-qSin(r+2)/r); // the B field strength of dipole radiation (modulo physical constants);
|
||||
|
||||
if(wavedata[yIndex][xIndex]==-9999)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
colorMap->data()->setCell(xIndex, yIndex, wavedata[yIndex][xIndex]);
|
||||
//colorMap->data()->setCell(xIndex, yIndex, wavedata[yIndex][xIndex]);
|
||||
colorMap->data()->setCell(nx-xIndex-1, yIndex, wavedata[yIndex][xIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 添加色标:
|
||||
QCPColorScale *colorScale = new QCPColorScale(widget);
|
||||
widget->plotLayout()->addElement(0, 1, colorScale); // 将其添加到主轴矩形的右侧
|
||||
colorScale->setType(QCPAxis::atRight); // 刻度应为垂直条,刻度线/坐标轴标签右侧(实际上,右侧已经是默认值)
|
||||
colorMap->setColorScale(colorScale); // 将颜色图与色标关联
|
||||
colorScale->axis()->setLabel("Magnetic Field Strength");
|
||||
|
||||
// 将颜色贴图的“颜色渐变”设置为其中一个预设
|
||||
//colorMap->setGradient(QCPColorGradient::gpPolar);//gpJet);
|
||||
// 我们还可以创建一个QCPColorGradient实例并向其中添加自己的颜色
|
||||
|
|
@ -891,25 +885,25 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa
|
|||
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->setGradient(gradient);
|
||||
// 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内:
|
||||
colorMap->rescaleDataRange();
|
||||
|
||||
//确保轴rect和色标同步其底边距和顶边距(以便它们对齐):
|
||||
QCPMarginGroup *marginGroup = new QCPMarginGroup(widget);
|
||||
widget->axisRect()->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
|
||||
colorScale->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
|
||||
//----调色板--------
|
||||
// widget->plotLayout()->addElement(0, 1, colorScale); // 将其添加到主轴矩形的右侧
|
||||
// colorScale->setType(QCPAxis::atRight); // 刻度应为垂直条,刻度线/坐标轴标签右侧(实际上,右侧已经是默认值)
|
||||
// colorScale->axis()->setLabel("Magnetic Field Strength");
|
||||
// //确保轴rect和色标同步其底边距和顶边距(以便它们对齐):
|
||||
// QCPMarginGroup *marginGroup = new QCPMarginGroup(widget);
|
||||
// widget->axisRect()->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
|
||||
// colorScale->setMarginGroup(QCP::msBottom|QCP::msTop, marginGroup);
|
||||
|
||||
// 重新缩放键(x)和值(y)轴,以便可以看到整个颜色图:
|
||||
//widget->rescaleAxes();
|
||||
|
|
@ -920,10 +914,139 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa
|
|||
double width=2;
|
||||
QString strScaleType = "";
|
||||
//道-对象
|
||||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, _wave.TimeSamples, 0, strScaleType, "waveObject");
|
||||
m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strWaveName, strAliasName, strUnit, newlineColor, width, _nSamples, 0, strScaleType, "waveObject");
|
||||
|
||||
}
|
||||
|
||||
void FormDraw::initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName)
|
||||
{
|
||||
CLogIO *logio=new CLogIO();
|
||||
logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead);
|
||||
//
|
||||
int index=logio->OpenWave(strWaveName.toStdString().c_str());
|
||||
if(index<0) {
|
||||
delete logio;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Slf_WAVE _wave;
|
||||
logio->GetWaveInfo(index, &_wave);
|
||||
float _SDep,_EDep,_Rlev;
|
||||
// _SDep = _wave.StartDepth;
|
||||
// _EDep = _wave.EndDepth;
|
||||
|
||||
g_iY2 = 0 - _wave.StartDepth;
|
||||
g_iY1 = 0 - _wave.EndDepth;
|
||||
|
||||
_SDep = 0.0 - g_iY2;
|
||||
_EDep = 0.0 - g_iY1;
|
||||
_Rlev = _wave.DepLevel;
|
||||
int m_Record=(float)(fabs((_EDep-_SDep)/_Rlev+0.5));
|
||||
|
||||
int _nSamples = _wave.TimeSamples;
|
||||
|
||||
char *value=new char[(_nSamples+1)*m_Record*_wave.CodeLen+1];
|
||||
logio->ReadWave(index,_SDep,m_Record,(void *)value);
|
||||
logio->CloseWave(index);
|
||||
delete logio;
|
||||
|
||||
float vmax = (float)_nSamples;
|
||||
float vmin = 0;
|
||||
//
|
||||
double** wavedata;
|
||||
wavedata = new double*[_nSamples];
|
||||
for(int kk = 0;kk<_nSamples;kk++){
|
||||
wavedata[kk] = new double[m_Record];
|
||||
}
|
||||
|
||||
for (int i=0; i<m_Record; i++)
|
||||
{
|
||||
for(int kk = 0;kk<_nSamples;kk++)
|
||||
{
|
||||
double val = GetData(_wave.RepCode,(char *)&value[(kk)*_wave.CodeLen+i*_nSamples*_wave.CodeLen]);
|
||||
wavedata[kk][i] = val;
|
||||
if(val==-9999)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// if(vmax<val)vmax=val;
|
||||
// if(vmin>val)vmin=val;
|
||||
}
|
||||
}
|
||||
delete[] value;
|
||||
|
||||
// g_iY1 = 0.0 -_EDep;
|
||||
// g_iY2 = 0.0 -_SDep;
|
||||
//------------------------
|
||||
widget->m_iX1 = vmin;
|
||||
widget->m_iX2 = vmax;
|
||||
widget->m_iY1 = g_iY1;
|
||||
widget->m_iY2 = g_iY2;
|
||||
//
|
||||
widget->xAxis->setRange(vmin, vmax);
|
||||
widget->yAxis->setRange(g_iY1, g_iY2);
|
||||
widget->axisRect()->setupFullAxesBox();
|
||||
//
|
||||
widget->xAxis->ticker()->setTickCount(10);//x个主刻度
|
||||
widget->yAxis->ticker()->setTickCount(60);//y个主刻度
|
||||
|
||||
//对调XY轴,在最前面设置
|
||||
// QCPAxis *yAxis = widget->yAxis;
|
||||
// QCPAxis *xAxis = widget->xAxis;
|
||||
// widget->xAxis = yAxis;
|
||||
// widget->yAxis = xAxis;
|
||||
|
||||
float nPerHight = 25;
|
||||
float nSpace = 10;
|
||||
for (int i=0; i<m_Record; i++)
|
||||
{
|
||||
//--------------------------------
|
||||
QVector<double> x;
|
||||
QVector<double> y;
|
||||
widget->addGraph();
|
||||
QString strLineName = "";
|
||||
if(strLineName=="")
|
||||
{
|
||||
strLineName = QString("曲线 %1").arg(widget->graphCount());
|
||||
}
|
||||
widget->graph()->setName(strLineName);
|
||||
|
||||
for(int kk = 0;kk<_nSamples;kk++)
|
||||
{
|
||||
//double val = wavedata[kk][m_Record-i-1];
|
||||
double val = wavedata[kk][i];
|
||||
if(val==-9999)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//x.append(_nSamples-kk-1);
|
||||
//float tempValue = -(_SDep + _Rlev*i+(val*30*2)/vmax);
|
||||
x.append(kk);
|
||||
float tempValue = -(_SDep + nSpace*i+(val*nPerHight*2)/vmax);
|
||||
y.append(tempValue);
|
||||
}
|
||||
|
||||
widget->graph()->setData(x, y);
|
||||
widget->graph()->setLineStyle((QCPGraph::LineStyle)(1));//曲线
|
||||
widget->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(1)));
|
||||
//
|
||||
QPen graphPen;
|
||||
QColor newlineColor = QColor(std::rand()%245+10, std::rand()%245+10, std::rand()%245+10);
|
||||
graphPen.setColor(newlineColor);
|
||||
double width = 1;
|
||||
graphPen.setWidthF(width);
|
||||
graphPen.setStyle(Qt::SolidLine);//实线
|
||||
widget->graph()->setPen(graphPen);
|
||||
//widget->replot();
|
||||
|
||||
if(i>=10)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FormDraw::addRandomGraph(QMyCustomPlot *widget, QVector<double> x, QVector<double> y, QString strSlfName, QString strLineName, QString strAliasName, QString strUnit,
|
||||
double newLeftScale, double newRightScale, QString strScaleType, QColor newlineColor, double width, Qt::PenStyle lineStyle)
|
||||
{
|
||||
|
|
@ -1018,18 +1141,27 @@ void FormDraw::dropEvent(QDropEvent* event)
|
|||
qDebug() << strExtern;
|
||||
//
|
||||
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
|
||||
if (list.size() > 2)
|
||||
if (list.size() > 3)
|
||||
{
|
||||
QString strSlfName = list[0];
|
||||
QString strWellName = list[1];
|
||||
QString strLineName = list[2];
|
||||
QString strType = list[3];
|
||||
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strLineName:" << strLineName;
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName << " strLineName:" << strLineName << " strType:" << strType;
|
||||
|
||||
if(m_strWellName == strWellName)
|
||||
{
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
if(strType=="curveObject")
|
||||
{
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
}
|
||||
else if(strType=="waveObject")
|
||||
{
|
||||
//新建波列
|
||||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
}
|
||||
|
||||
// 接受拖拽事件
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
|
|
@ -1040,39 +1172,11 @@ void FormDraw::dropEvent(QDropEvent* event)
|
|||
// 如果井名不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList listWave = strExtern.split("#$$#");//QString字符串分割函数
|
||||
if (listWave.size() > 2)
|
||||
{
|
||||
QString strSlfName = listWave[0];
|
||||
QString strWellName = listWave[1];
|
||||
QString strWaveName = listWave[2];
|
||||
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strWaveName:" << strWaveName;
|
||||
|
||||
if(m_strWellName == strWellName)
|
||||
{
|
||||
//新建波列
|
||||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strWaveName);
|
||||
|
||||
// 接受拖拽事件
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果井名不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果数据格式不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
// 如果数据格式不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public:
|
|||
void setupSelectionDemo(QMyCustomPlot *customPlot);
|
||||
|
||||
void initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
||||
void initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
|
||||
|
||||
|
||||
signals:
|
||||
|
|
|
|||
|
|
@ -180,14 +180,28 @@ void FormInfo::paintEvent(QPaintEvent* event)
|
|||
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")
|
||||
{
|
||||
//波列
|
||||
|
||||
int nIndex=11;
|
||||
QVector<MyColorItem> colorList;
|
||||
bool inpolation = true;
|
||||
int iColorNum = 256;
|
||||
int iColorNum_tmp = getSystemColor(nIndex, colorList, inpolation);
|
||||
colorList=myInpolation(colorList,256);//重新扩展调色板
|
||||
//头部绘制调色板
|
||||
float scale = (float)(rect.width()-4) / (float)iColorNum;
|
||||
QRectF rt7=QRectF(rect.left()+2, rect.top()+rect.height()/3, rect.width()-4, rect.height()/3);
|
||||
for (int i= 0; i<iColorNum; i++)
|
||||
{
|
||||
float temp = (float)i * scale;
|
||||
if(i)rt7.setLeft(rect.left()+2+temp);
|
||||
else rt7.setLeft(rect.left()+2+temp+1);
|
||||
temp = (float)(i+1) * scale;
|
||||
rt7.setRight(rect.left()+2+temp);
|
||||
QBrush HeadBrush =QBrush(colorList[i].color);
|
||||
painter.fillRect(rt7,HeadBrush);
|
||||
}
|
||||
}
|
||||
|
||||
QFont font2("微软雅黑", 8, false, false);
|
||||
|
|
@ -244,19 +258,27 @@ void FormInfo::dropEvent(QDropEvent* event)
|
|||
qDebug() << strExtern;
|
||||
//
|
||||
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
|
||||
if (list.size() > 2)
|
||||
if (list.size() > 3)
|
||||
{
|
||||
QString strSlfName = list[0];
|
||||
QString strWellName = list[1];
|
||||
QString strLineName = list[2];
|
||||
QString strType = list[3];
|
||||
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strLineName:" << strLineName;
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strLineName:" << strLineName << " strType:" << strType;
|
||||
|
||||
if(m_strWellName == strWellName)
|
||||
{
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
|
||||
if(strType=="curveObject")
|
||||
{
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
}
|
||||
else if(strType=="waveObject")
|
||||
{
|
||||
//新建波列
|
||||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
}
|
||||
// 接受拖拽事件
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
|
|
@ -266,42 +288,12 @@ void FormInfo::dropEvent(QDropEvent* event)
|
|||
// 如果井名不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList listWave = strExtern.split("#$$#");//QString字符串分割函数
|
||||
if (listWave.size() > 2)
|
||||
{
|
||||
QString strSlfName = listWave[0];
|
||||
QString strWellName = listWave[1];
|
||||
QString strWaveName = listWave[2];
|
||||
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strLineName:" << strWaveName;
|
||||
|
||||
if(m_strWellName == strWellName)
|
||||
{
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strWaveName);
|
||||
|
||||
// 接受拖拽事件
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果井名不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果数据格式不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
// 如果数据格式不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <QStackedWidget>
|
||||
|
||||
#include "qtprojectwidgets.h"
|
||||
#include "qtcenterwidgets.h"
|
||||
//#include "qtcenterwidgets.h"
|
||||
#include "mainwindowcurve.h"
|
||||
#include "customtabwidget.h"
|
||||
#include "ConsoleOutputWidget.h"
|
||||
|
|
|
|||
|
|
@ -598,30 +598,24 @@ void MainWindowCurve::dropEvent(QDropEvent* event)
|
|||
qDebug() << strExtern;
|
||||
//
|
||||
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
|
||||
if (list.size() > 2)
|
||||
if (list.size() > 3)
|
||||
{
|
||||
QString strSlfName = list[0];
|
||||
QString strWellName = list[1];
|
||||
QString strLineName = list[2];
|
||||
QString strType = list[3];
|
||||
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strLineName:" << strLineName;
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName << " strLineName:" << strLineName << " strType:" << strType;
|
||||
|
||||
//新建井+道+曲线(首条)
|
||||
NewWellAndTrack(strWellName, strSlfName, strLineName, "curveObject");
|
||||
}
|
||||
else {
|
||||
//
|
||||
QStringList listWave = strExtern.split("#$$#");//QString字符串分割函数
|
||||
if (listWave.size() > 2)
|
||||
if(strType=="curveObject")
|
||||
{
|
||||
//新建井+道+曲线(首条)
|
||||
NewWellAndTrack(strWellName, strSlfName, strLineName, "curveObject");
|
||||
}
|
||||
else if(strType=="waveObject")
|
||||
{
|
||||
QString strSlfName = listWave[0];
|
||||
QString strWellName = listWave[1];
|
||||
QString strWaveName = listWave[2];
|
||||
|
||||
qDebug() << "strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strWaveName:" << strWaveName;
|
||||
|
||||
//新建井+道+波列(首条)
|
||||
NewWellAndTrack(strWellName, strSlfName, strWaveName, "waveObject");
|
||||
NewWellAndTrack(strWellName, strSlfName, strLineName, "waveObject");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,19 +98,28 @@ void PreQTableWidget::dropEvent(QDropEvent *event)
|
|||
|
||||
//
|
||||
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
|
||||
if (list.size() > 2)
|
||||
if (list.size() > 3)
|
||||
{
|
||||
QString strSlfName = list[0];
|
||||
QString strWellName = list[1];
|
||||
QString strLineName = list[2];
|
||||
QString strType = list[3];
|
||||
|
||||
qDebug() << "source strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strLineName:" << strLineName;
|
||||
|
||||
qDebug() << "source strSlfName:" << strSlfName<< " strWellName:" << strWellName << " strLineName:" << strLineName << " strType:" << strType;
|
||||
if(m_strWellName == strWellName)
|
||||
{
|
||||
m_AddSuc = true;
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
|
||||
if(strType=="curveObject")
|
||||
{
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
}
|
||||
else if(strType=="waveObject")
|
||||
{
|
||||
//新建波列
|
||||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
}
|
||||
|
||||
//
|
||||
//m_listLineName.push_back(strLineName);
|
||||
|
|
@ -127,50 +136,18 @@ void PreQTableWidget::dropEvent(QDropEvent *event)
|
|||
}
|
||||
else
|
||||
{
|
||||
int rownum = rowCount();
|
||||
setRowCount(rownum+1);
|
||||
//
|
||||
QStringList listWave = strExtern.split("#$$#");//QString字符串分割函数
|
||||
if (listWave.size() > 2)
|
||||
{
|
||||
QString strSlfName = listWave[0];
|
||||
QString strWellName = listWave[1];
|
||||
QString strWaveName = listWave[2];
|
||||
QTableWidgetItem* item = new QTableWidgetItem(strExtern);
|
||||
item->setFlags(item->flags() & (~Qt::ItemIsEditable));
|
||||
item->setTextAlignment(Qt::AlignCenter); //设置文本居中
|
||||
//
|
||||
setItem(rownum, 0, item);
|
||||
|
||||
qDebug() << "source strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strWaveName:" << strWaveName;
|
||||
|
||||
if(m_strWellName == strWellName)
|
||||
{
|
||||
m_AddSuc = true;
|
||||
//新建波列
|
||||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strWaveName);
|
||||
|
||||
//
|
||||
//m_listLineName.push_back(strLineName);
|
||||
|
||||
// 接受拖拽事件
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果井名不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int rownum = rowCount();
|
||||
setRowCount(rownum+1);
|
||||
//
|
||||
QTableWidgetItem* item = new QTableWidgetItem(strExtern);
|
||||
item->setFlags(item->flags() & (~Qt::ItemIsEditable));
|
||||
item->setTextAlignment(Qt::AlignCenter); //设置文本居中
|
||||
//
|
||||
setItem(rownum, 0, item);
|
||||
|
||||
//
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
//
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,19 +159,27 @@ void PreQTableWidget::dropEvent(QDropEvent *event)
|
|||
|
||||
//
|
||||
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
|
||||
if (list.size() > 2)
|
||||
if (list.size() > 3)
|
||||
{
|
||||
QString strSlfName = list[0];
|
||||
QString strWellName = list[1];
|
||||
QString strLineName = list[2];
|
||||
QString strType = list[3];
|
||||
|
||||
qDebug() << "sourceTree strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strLineName:" << strLineName;
|
||||
|
||||
qDebug() << "sourceTree strSlfName:" << strSlfName<< " strWellName:" << strWellName << " strLineName:" << strLineName << " strType:" << strType;
|
||||
if(m_strWellName == strWellName)
|
||||
{
|
||||
m_AddSuc = true;
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
if(strType=="curveObject")
|
||||
{
|
||||
//新建曲线
|
||||
emit CallManage::getInstance()->sig_AddLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
}
|
||||
else if(strType=="waveObject")
|
||||
{
|
||||
//新建波列
|
||||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
|
||||
}
|
||||
|
||||
//
|
||||
//m_listLineName.push_back(strLineName);
|
||||
|
|
@ -209,38 +194,6 @@ void PreQTableWidget::dropEvent(QDropEvent *event)
|
|||
event->ignore();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
QStringList listWave = strExtern.split("#$$#");//QString字符串分割函数
|
||||
if (listWave.size() > 2)
|
||||
{
|
||||
QString strSlfName = listWave[0];
|
||||
QString strWellName = listWave[1];
|
||||
QString strWaveName = listWave[2];
|
||||
|
||||
qDebug() << "sourceTree strSlfName:" << strSlfName<< " strWellName:" << strWellName<< " strWaveName:" << strWaveName;
|
||||
|
||||
if(m_strWellName == strWellName)
|
||||
{
|
||||
m_AddSuc = true;
|
||||
//新建波列
|
||||
emit CallManage::getInstance()->sig_AddWave(m_strUuid, strSlfName, strWellName, m_strTrackName, strWaveName);
|
||||
|
||||
//
|
||||
//m_listLineName.push_back(strLineName);
|
||||
|
||||
// 接受拖拽事件
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果井名不正确,不接受拖拽事件
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -255,12 +208,13 @@ void PreQTableWidget::performDrag()
|
|||
|
||||
FormInfo *formInfo = (FormInfo*)myWidget;//获得widget
|
||||
|
||||
if(formInfo->m_strType == "curveObject")
|
||||
QString strType = formInfo->m_strType;
|
||||
//if(strType == "curveObject" || strType == "waveObject")
|
||||
{
|
||||
//曲线对象(AC、BS...)
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
// 这里需要根据你的item数据来设置mimeData,例如:
|
||||
mimeData->setText(formInfo->m_strSlfName + "#@@#"+ formInfo->m_strWellName + "#@@#" +formInfo->m_strLineName);
|
||||
mimeData->setText(formInfo->m_strSlfName + "#@@#"+ formInfo->m_strWellName + "#@@#" +formInfo->m_strLineName + "#@@#" + strType);
|
||||
// 创建QDrag对象
|
||||
QDrag *drag = new QDrag(this);
|
||||
drag->setMimeData(mimeData);
|
||||
|
|
@ -276,40 +230,21 @@ void PreQTableWidget::performDrag()
|
|||
if (dropAction == Qt::MoveAction) { //&& m_AddSuc
|
||||
// 处理拖拽结束的逻辑,例如从界面上移除拖拽的项
|
||||
removeRow(iCurrentRow);
|
||||
//删除曲线
|
||||
emit CallManage::getInstance()->sig_delLine(m_strUuid, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName);
|
||||
if(strType=="curveObject")
|
||||
{
|
||||
//删除曲线
|
||||
emit CallManage::getInstance()->sig_delLine(m_strUuid, formInfo->m_strWellName, formInfo->m_strTrackName, formInfo->m_strLineName);
|
||||
}
|
||||
else if(strType=="waveObject")
|
||||
{
|
||||
//删除波列
|
||||
emit CallManage::getInstance()->sig_delWave(m_strUuid, formInfo->m_strWellName, formInfo->m_strTrackName, 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())
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ void QMyTreeWidget::startDrag(Qt::DropActions supportedActions)
|
|||
{
|
||||
//根节点(项目名称)
|
||||
}
|
||||
else if (strTreeTag == "curveObject"){
|
||||
else if (strTreeTag == "curveObject" || strTreeTag == "waveObject" || strTreeTag == "tableObject"){
|
||||
//曲线
|
||||
QString strSlfName = item->data(0, Qt::UserRole+1).toString();
|
||||
QString strWellName = item->data(0, Qt::UserRole+2).toString();
|
||||
|
|
@ -36,34 +36,7 @@ void QMyTreeWidget::startDrag(Qt::DropActions supportedActions)
|
|||
//曲线对象(AC、BS...)
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
// 这里需要根据你的item数据来设置mimeData,例如:
|
||||
mimeData->setText(strSlfName + "#@@#"+ strWellName + "#@@#" +item->text(0));
|
||||
// 创建QDrag对象
|
||||
QDrag *drag = new QDrag(this);
|
||||
drag->setMimeData(mimeData);
|
||||
// 可以设置拖拽时的光标图标
|
||||
QRect itemRect = visualItemRect(item); // 获取项的矩形区域
|
||||
QPixmap itemPixmap = QWidget::grab(itemRect);//QPixmap::grabWidget(this, itemRect); // 获取项的屏幕截图
|
||||
// 调整拖拽光标的热点,使其位于截图的中心
|
||||
drag->setPixmap(itemPixmap);
|
||||
|
||||
// 执行拖拽操作
|
||||
Qt::DropAction dropAction = drag->exec(supportedActions, Qt::MoveAction);
|
||||
/*if (dropAction == Qt::MoveAction) {
|
||||
// 处理拖拽结束的逻辑,例如从界面上移除拖拽的项
|
||||
for (QTreeWidgetItem *item : items) {
|
||||
this->takeTopLevelItem(this->indexOfTopLevelItem(item));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else if (strTreeTag == "waveObject"){
|
||||
//波列数据
|
||||
QString strSlfName = item->data(0, Qt::UserRole+1).toString();
|
||||
QString strWellName = item->data(0, Qt::UserRole+2).toString();
|
||||
|
||||
//波列对象
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
// 这里需要根据你的item数据来设置mimeData,例如:
|
||||
mimeData->setText(strSlfName + "#$$#"+ strWellName + "#$$#" +item->text(0));
|
||||
mimeData->setText(strSlfName + "#@@#"+ strWellName + "#@@#" +item->text(0)+ "#@@#" + strTreeTag);
|
||||
// 创建QDrag对象
|
||||
QDrag *drag = new QDrag(this);
|
||||
drag->setMimeData(mimeData);
|
||||
|
|
|
|||
|
|
@ -408,13 +408,13 @@ void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, Q
|
|||
fileinfo = QFileInfo(fileFull);
|
||||
wellname = fileinfo.completeBaseName();
|
||||
}
|
||||
if(wellname != parentWellname)
|
||||
{
|
||||
//井次名称不一致
|
||||
qDebug() << "井次名称不一致";
|
||||
delete logio;
|
||||
return;
|
||||
}
|
||||
// if(wellname != parentWellname)
|
||||
// {
|
||||
// //井次名称不一致
|
||||
// qDebug() << "井次名称不一致";
|
||||
// delete logio;
|
||||
// return;
|
||||
// }
|
||||
//井次名称
|
||||
QTreeWidgetItem *itemwell = new QTreeWidgetItem();
|
||||
itemwell->setText(0, wellname);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user