Compare commits

..

2 Commits

Author SHA1 Message Date
1255631d7f Merge branch 'main' of http://git.hivekion.com:3000/jiayulong/logplus
# Conflicts:
#	logPlus/PropertyWidget.cpp
2026-02-06 09:23:56 +08:00
4b1cd2bac9 波列实现,波形显示效果
波形绘图类型切换显示效果,波形、变密度成像,填充显示
波列间隔,波列高度属性添加
2026-02-06 09:20:35 +08:00
8 changed files with 253 additions and 237 deletions

View File

@ -55,7 +55,7 @@ QWidget* PropertyWidget::GetPropertyWidget()
} }
//初始化,清空 //初始化,清空
void PropertyWidget::InitCurrentViewInfo() void PropertyWidget::InitCurrentViewInfo(bool bAll)
{ {
QList<QtProperty*> propertyList = m_pPropertyBrowser->properties(); QList<QtProperty*> propertyList = m_pPropertyBrowser->properties();
m_pPropertyBrowser->clear(); m_pPropertyBrowser->clear();
@ -71,18 +71,21 @@ void PropertyWidget::InitCurrentViewInfo()
m_propertyData.clear(); m_propertyData.clear();
m_mapGroupItem.clear(); m_mapGroupItem.clear();
m_fromTop = NULL; if (bAll)
m_formInfo = NULL; {
m_formHead = NULL; m_fromTop = NULL;
m_tableWidget = NULL; m_formInfo = NULL;
m_item = NULL; m_formHead = NULL;
m_strUuid = ""; m_tableWidget = NULL;
m_strSlfName = ""; m_item = NULL;
m_strWellName = ""; m_strUuid = "";
m_strTrackName = ""; m_strSlfName = "";
m_strLineName = ""; m_strWellName = "";
// m_strTrackName = "";
m_strCurrentProperty = ""; m_strLineName = "";
//
m_strCurrentProperty = "";
}
} }
void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant &variant ) void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant &variant )
@ -130,7 +133,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
bool bDraw = false; bool bDraw = false;
QStringList slist; QStringList slist;
slist << "显示名称" << "显示单位" << "曲线名称" << "曲线单位" << "曲线刻度" slist << "显示名称" << "显示单位" << "曲线名称" << "曲线单位" << "曲线刻度"
<< "类型" << "方式" << "左刻度" << "右刻度" << "幅度刻度" << "最大振幅" << "显示刻度" << "色板" << "变密度颜色级数"; << "类型" << "方式" << "左刻度" << "右刻度" << "幅度刻度" << "最大振幅" << "颜色" << "线宽"
<< "波形间隔" << "显示刻度" << "色板" << "变密度颜色级数";
for (int i = 0; i < slist.length(); i++) for (int i = 0; i < slist.length(); i++)
{ {
if (slist.at(i) == m_propertyData[pProperty]) if (slist.at(i) == m_propertyData[pProperty])
@ -155,6 +159,12 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant
listCond << variant; listCond << variant;
emit CallManage::getInstance()->sig_changeDrawProperty(listCond); emit CallManage::getInstance()->sig_changeDrawProperty(listCond);
} }
if ("类型" == m_propertyData[pProperty])
{
this->InitCurrentViewInfo(false);
initWaveProperty(m_formInfo, variant.toInt());
}
return; return;
} }
if("深度比例尺" == m_propertyData[pProperty]) if("深度比例尺" == m_propertyData[pProperty])
@ -1181,7 +1191,7 @@ void PropertyWidget::initProperty(FormInfo *formInfo)
} }
else if (formInfo->m_strType == "waveObject") else if (formInfo->m_strType == "waveObject")
{ {
this->initWaveProperty(formInfo); this->initWaveProperty(formInfo, formInfo->m_nDrawType);
} }
} }
@ -1215,8 +1225,11 @@ void PropertyWidget::initRoseProperty(FormInfo *formInfo)
// _CreateVariantPropertyItem("玫瑰图", "道头字颜色", fromTop->m_fontColor, QVariant::Color); // _CreateVariantPropertyItem("玫瑰图", "道头字颜色", fromTop->m_fontColor, QVariant::Color);
} }
void PropertyWidget::initWaveProperty(FormInfo *formInfo) void PropertyWidget::initWaveProperty(FormInfo *formInfo, int nType)
{ {
if (formInfo == NULL)
return;
_CreateVariantPropertyItem("通常", "选择井曲线", m_strLineName + "@" + m_strSlfName, QVariant::String); _CreateVariantPropertyItem("通常", "选择井曲线", m_strLineName + "@" + m_strSlfName, QVariant::String);
_CreateVariantPropertyItem("通常", "显示名称", formInfo->m_strLineName, QVariant::String); _CreateVariantPropertyItem("通常", "显示名称", formInfo->m_strLineName, QVariant::String);
//_CreateVariantPropertyItem("通常", "例区高度(cm)", formInfo->m_strUnit, QVariant::Double); //_CreateVariantPropertyItem("通常", "例区高度(cm)", formInfo->m_strUnit, QVariant::Double);
@ -1249,22 +1262,36 @@ void PropertyWidget::initWaveProperty(FormInfo *formInfo)
drawType.append("多臂井径"); drawType.append("多臂井径");
_CreateEnumPropertyItem("绘图类型", "类型", formInfo->m_nDrawType, drawType); _CreateEnumPropertyItem("绘图类型", "类型", formInfo->m_nDrawType, drawType);
QStringList fillType; if (nType == 2)
fillType.append("全周"); {
fillType.append("正半周"); QStringList fillType;
fillType.append("负半周"); fillType.append("全周");
_CreateEnumPropertyItem("填充方式", "方式", formInfo->m_nFillType, fillType); fillType.append("正半周");
fillType.append("负半周");
_CreateEnumPropertyItem("填充方式", "方式", formInfo->m_nFillType, fillType);
}
if (nType == 0 || nType == 1)
{
_CreateVariantPropertyItem("波形绘制参数", "绘制波深度", formInfo->m_bDrawDepth, QVariant::Bool);
_CreateVariantPropertyItem("波形绘制参数", "绘制波基线", formInfo->m_bDrawBase, QVariant::Bool);
_CreateVariantPropertyItem("波形绘制参数", "奇偶配色", formInfo->m_bOddEven, QVariant::Bool);
}
//_CreateVariantPropertyItem("波形绘制参数", "自动平滑", true, QVariant::Bool); //_CreateVariantPropertyItem("波形绘制参数", "自动平滑", true, QVariant::Bool);
_CreateVariantPropertyItem("波形绘制参数", "左刻度", formInfo->m_vmin, QVariant::Double); _CreateVariantPropertyItem("波形绘制参数", "左刻度", formInfo->m_vmin, QVariant::Double);
_CreateVariantPropertyItem("波形绘制参数", "右刻度", formInfo->m_vmax, QVariant::Double); _CreateVariantPropertyItem("波形绘制参数", "右刻度", formInfo->m_vmax, QVariant::Double);
_CreateVariantPropertyItem("波形绘制参数", "幅度刻度", formInfo->m_strAmp, QVariant::String); _CreateVariantPropertyItem("波形绘制参数", "幅度刻度", formInfo->m_strAmp, QVariant::String);
_CreateVariantPropertyItem("波形绘制参数", "最大振幅", formInfo->m_fMaxAmp, QVariant::Double); _CreateVariantPropertyItem("波形绘制参数", "最大振幅", formInfo->m_fMaxAmp, QVariant::Double);
_CreateVariantPropertyItem("波形绘制参数", "显示刻度", formInfo->m_bShowScale, QVariant::Bool); _CreateVariantPropertyItem("波形绘制参数", "显示刻度", formInfo->m_bShowScale, QVariant::Bool);
//_CreateVariantPropertyItem("波形绘制参数", "波列基值", 0, QVariant::Double);
//_CreateVariantPropertyItem("波形绘制参数", "波形间隔", 1, QVariant::Int);
//_CreateVariantPropertyItem("波形绘制参数", "波形高度", 1, QVariant::Double);
if (nType == 0 || nType == 1)
{
_CreateVariantPropertyItem("波形绘制参数", "波列基值", formInfo->m_fWaveBase, QVariant::Double);
_CreateVariantPropertyItem("波形绘制参数", "波形间隔", formInfo->m_nWaveJg, QVariant::Int);
_CreateVariantPropertyItem("波形绘制参数", "波形高度", formInfo->m_fWaveHei, QVariant::Double);
_CreateVariantPropertyItem("波形绘制参数", "线宽", formInfo->m_dWidth, QVariant::Int);
_CreateVariantPropertyItem("波形绘制参数", "颜色", formInfo->m_lineColor, QVariant::Color);
}
//_CreateVariantPropertyItem("成像显示", "RGBA数据", false, QVariant::Bool); //_CreateVariantPropertyItem("成像显示", "RGBA数据", false, QVariant::Bool);
//_CreateVariantPropertyItem("成像显示", "绘制阵列数", 1, QVariant::Int); //_CreateVariantPropertyItem("成像显示", "绘制阵列数", 1, QVariant::Int);
//_CreateVariantPropertyItem("成像显示", "是否顶底倒置", false, QVariant::Bool); //_CreateVariantPropertyItem("成像显示", "是否顶底倒置", false, QVariant::Bool);
@ -1274,8 +1301,11 @@ void PropertyWidget::initWaveProperty(FormInfo *formInfo)
//_CreateVariantPropertyItem("成像显示", "是否深度校正", false, QVariant::Bool); //_CreateVariantPropertyItem("成像显示", "是否深度校正", false, QVariant::Bool);
//_CreateVariantPropertyItem("成像显示", "是否自动计算波参数", "", QVariant::String); //_CreateVariantPropertyItem("成像显示", "是否自动计算波参数", "", QVariant::String);
_CreateColorSchemePropertyItem("调色板参数设置", "色板", formInfo->m_nSchemeIndex); if (nType == 2)
_CreateVariantPropertyItem("调色板参数设置", "变密度颜色级数", formInfo->m_nColorNum, QVariant::Int); {
_CreateColorSchemePropertyItem("调色板参数设置", "色板", formInfo->m_nSchemeIndex);
_CreateVariantPropertyItem("调色板参数设置", "变密度颜色级数", formInfo->m_nColorNum, QVariant::Int);
}
// _CreateVariantPropertyItem("调色板参数设置", "图例置顶", false, QVariant::Bool); // _CreateVariantPropertyItem("调色板参数设置", "图例置顶", false, QVariant::Bool);
// _CreateVariantPropertyItem("调色板参数设置", "反转显示", false, QVariant::Bool); // _CreateVariantPropertyItem("调色板参数设置", "反转显示", false, QVariant::Bool);

View File

@ -100,7 +100,7 @@ public:
void _CreateColorSchemePropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue); void _CreateColorSchemePropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue);
void InitCurrentViewInfo(); //初始化属性,清空 void InitCurrentViewInfo(bool bAll = true); //初始化属性,清空
void initWidgetProperty(QString strUuid, int iScale); //可视解释整体属性 void initWidgetProperty(QString strUuid, int iScale); //可视解释整体属性
//井 //井
void initWellProperty(QString strUuid, QString strSlfName, QString strWellName, double iY1, double iY2); void initWellProperty(QString strUuid, QString strSlfName, QString strWellName, double iY1, double iY2);
@ -117,7 +117,7 @@ public:
// 玫瑰图属性 // 玫瑰图属性
void initRoseProperty(FormInfo *formInfo); void initRoseProperty(FormInfo *formInfo);
// 波列属性 // 波列属性
void initWaveProperty(FormInfo *formInfo); void initWaveProperty(FormInfo *formInfo, int nType = 3);
void ChangFillProperty();//填充属性改变 void ChangFillProperty();//填充属性改变

View File

@ -715,6 +715,8 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam
curv->show(); curv->show();
curv->m_iY1 = m_iY1;
curv->m_iY2 = m_iY2;
int _nSamples = 0; int _nSamples = 0;
if(g_iSupport3D) if(g_iSupport3D)
{ {
@ -722,10 +724,10 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam
} }
else else
{ {
initWave(curv, strSlfName, strWaveName, _nSamples); curv->initWave(strSlfName, strWaveName);
_nSamples = curv->getScaleV();
} }
curv->replot();
curv->initColorTable();
connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*)));
// //
@ -2409,142 +2411,6 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi
//AppendConsole(PAI_INFO, "FormDraw initForm end"); //AppendConsole(PAI_INFO, "FormDraw initForm end");
} }
void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples)
{
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;
// _SDep = 0.0 - m_iY2;
// _EDep = 0.0 - m_iY1;
_Rlev = _wave.DepLevel;
int m_Record=(float)(fabs((_EDep-_SDep)/_Rlev+0.5));
_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;
bool bFistValue=false;
float vmax = -9999;//(float)_nSamples;
float vmin = -9999;
//
double** wavedata = widget->getWavedata(_nSamples, m_Record);
//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(bFistValue==false)
{
//最大值,最小值默认采用第一个有效值
bFistValue=true;
vmax = vmin = val;
}
//
if(vmax<val)vmax=val;
if(vmin>val)vmin=val;
}
}
delete[] value;
// m_iY1 = 0.0 -_EDep;
// m_iY2 = 0.0 -_SDep;
//------------------------
widget->m_iX1 = vmin;
widget->m_iX2 = vmax;
widget->m_iY1 = m_iY1;
widget->m_iY2 = m_iY2;
//
widget->xAxis->setRange(vmin, vmax);
widget->yAxis->setRange(m_iY1, m_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;
widget->m_fmin = vmin;
widget->m_fmax = vmax;
//-------------------
// set up the QCPColorMap:
QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis);
widget->m_colorMap = colorMap;
int nx = m_Record;
int ny = _nSamples;
colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点
//colorMap->data()->setRange(QCPRange(m_iY1, m_iY2), QCPRange(vmin, vmax)); // 并在键x和值y维上跨越坐标范围-4..4
colorMap->data()->setRange(QCPRange(0 - _EDep, 0 - _SDep), QCPRange(vmin, vmax));
// 现在我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据
for (int xIndex = 0; xIndex < nx; ++xIndex)
{
for (int yIndex = 0; yIndex < ny; ++yIndex)
{
if (wavedata[yIndex][xIndex] == -9999)
{
colorMap->data()->setCell(nx - xIndex - 1, yIndex, vmin);
continue;
}
//colorMap->data()->setCell(xIndex, yIndex, wavedata[yIndex][xIndex]);
colorMap->data()->setCell(nx - xIndex - 1, yIndex, wavedata[yIndex][xIndex]);
}
}
// 添加色标:
QCPColorScale *colorScale = new QCPColorScale(widget);
colorMap->setColorScale(colorScale); // 将颜色图与色标关联
// 将颜色贴图的“颜色渐变”设置为其中一个预设
//colorMap->setGradient(QCPColorGradient::gpPolar);//gpJet);
// 我们还可以创建一个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% 位置的颜色
//}
//colorMap->setGradient(gradient);
// 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内:
colorMap->rescaleDataRange();
}
void FormDraw::initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples) void FormDraw::initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples)
{ {
CLogIO *logio=new CLogIO(); CLogIO *logio=new CLogIO();

View File

@ -103,10 +103,7 @@ public:
void setupSelectionDemo(QMyCustomPlot *customPlot); void setupSelectionDemo(QMyCustomPlot *customPlot);
//波列 //波列
void initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples);
void initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples); void initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples);
// 绘图类型-波形
void initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName);
//图像-3d成图 //图像-3d成图
int getColorConfig(QVector <QString> &qFiles); int getColorConfig(QVector <QString> &qFiles);

View File

@ -284,26 +284,59 @@ void FormInfo::paintEvent(QPaintEvent* event)
if(m_strType=="waveObject") if(m_strType=="waveObject")
{ {
QtColorTableData::getInstance()->SetCurrentSchemeIndex(m_nSchemeIndex); if (m_nDrawType == 0 || m_nDrawType == 1)
//ColorTableIndex = ind;
QtColorTableData::getInstance()->ChangeColorNum(m_nColorNum);
QList<QRgb> rgbList = QtColorTableData::getInstance()->GetRgb();
int iColorNum = rgbList.size();
//头部绘制调色板
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++)
{ {
QColor acolor = rgbList.at(i); int nbot = rect.bottom()- rect.height() / 3.0;
float temp = (float)i * scale; QVector<QPointF> pts;
if (i)rt7.setLeft(rect.left() + 2 + temp); int i = 0;
else rt7.setLeft(rect.left() + 2 + temp + 1); pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot));
temp = (float)(i + 1) * scale; pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 15.0));
rt7.setRight(rect.left() + 2 + temp); pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 12.0));
QBrush HeadBrush = QBrush(acolor); pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 9.0));
painter.fillRect(rt7, HeadBrush); pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 6.0));
pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 3.0));
pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 9.0));
pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 15.0));
pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot));
pts.append(QPointF(rect.left() + rect.width() / 3.0, nbot));
if (m_nDrawType == 1) {
QPolygonF cRgn;
for (int j = 0; j < pts.size(); j++) {
cRgn.push_back(pts[j]);
}
QPainterPath path;
path.addPolygon(cRgn);
painter.fillPath(path, QBrush(m_lineColor));
}
else
{
painter.drawPolygon(pts);
}
}
else
{
QtColorTableData::getInstance()->SetCurrentSchemeIndex(m_nSchemeIndex);
//ColorTableIndex = ind;
QtColorTableData::getInstance()->ChangeColorNum(m_nColorNum);
QList<QRgb> rgbList = QtColorTableData::getInstance()->GetRgb();
int iColorNum = rgbList.size();
//头部绘制调色板
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++)
{
QColor acolor = rgbList.at(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(acolor);
painter.fillRect(rt7, HeadBrush);
}
} }
} }
@ -594,6 +627,25 @@ bool FormInfo::setInfoProperty(QString strProName, QVariant val)
{ {
this->m_bShowScale = val.toBool(); this->m_bShowScale = val.toBool();
} }
else if ("波形间隔" == strProName)
{
bDraw = true;
this->m_nWaveJg = val.toInt();
}
else if ("波形高度" == strProName)
{
bDraw = true;
this->m_fWaveHei = val.toInt();
}
else if ("颜色" == strProName)
{
bDraw = true;
this->m_lineColor = val.value<QColor>();
}
else if ("线宽" == strProName)
{
this->m_dWidth = val.toInt();
}
else if ("色板" == strProName) else if ("色板" == strProName)
{ {
this->m_nSchemeIndex = val.toInt(); this->m_nSchemeIndex = val.toInt();

View File

@ -100,10 +100,19 @@ public:
int m_nDrawType; // 绘图类型 int m_nDrawType; // 绘图类型
int m_nFillType; // 填充类型 int m_nFillType; // 填充类型
bool m_bDrawDepth = false; // 绘制波深度
bool m_bDrawBase = false; // 绘制波基线
bool m_bOddEven = false; // 奇偶配色
QString m_strAmp; // 幅度刻度 QString m_strAmp; // 幅度刻度
float m_fMaxAmp; // 最大振幅 float m_fMaxAmp; // 最大振幅
bool m_bShowScale; // 显示刻度 bool m_bShowScale; // 显示刻度
float m_fWaveBase = 0.0f; // 波列基值
int m_nWaveJg = 100; // 波形间隔
float m_fWaveHei = 1; // 波形高度
int m_nColorNum = 256; // 调色板参数设置-变密度颜色级数 int m_nColorNum = 256; // 调色板参数设置-变密度颜色级数
int m_nSchemeIndex = 1; // 调色板参数设置-色板 int m_nSchemeIndex = 1; // 调色板参数设置-色板

View File

@ -34,7 +34,7 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
setObjectName("QMyCustomPlot"); setObjectName("QMyCustomPlot");
//this->setOpenGl(true);//不开启,电脑不支持会卡 //this->setOpenGl(true);//不开启,电脑不支持会卡
// this->setNotAntialiasedElements(QCP::aeAll); // 关闭所有抗锯齿 // this->setNotAntialiasedElements(QCP::aeAll); // 关闭所有抗锯齿
m_newColor = Qt::black;
// 开启抗锯齿 // 开启抗锯齿
this->setAntialiasedElement(QCP::aeAll); this->setAntialiasedElement(QCP::aeAll);
@ -104,6 +104,36 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel
connect(CallManage::getInstance(), SIGNAL(sig_changeDrawProperty(QVariantList)), this, SLOT(s_changeDrawProperty(QVariantList))); connect(CallManage::getInstance(), SIGNAL(sig_changeDrawProperty(QVariantList)), this, SLOT(s_changeDrawProperty(QVariantList)));
} }
void QMyCustomPlot::changePropertyWaveUpdate()
{
if (m_nDrawType == 0 || m_nDrawType == 1)
{
if (this->m_colorMap)
this->m_colorMap->setVisible(false);
clearGraphs();
if (this->m_bX2Y)
{
QCPAxis *yAxis = this->yAxis;
QCPAxis *xAxis = this->xAxis;
this->xAxis = yAxis;
this->yAxis = xAxis;
this->m_bX2Y = false;
}
this->initWave2(m_strSlfName, m_strLineName);
}
else if (m_nDrawType == 2)
{
if (this->m_colorMap)
this->m_colorMap->setVisible(true);
clearGraphs();
this->m_bX2Y = true;
this->initWave(m_strSlfName, m_strLineName);
}
}
void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName) void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName)
{ {
CLogIO *logio = new CLogIO(); CLogIO *logio = new CLogIO();
@ -127,7 +157,8 @@ void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName)
int m_Record = (float)(fabs((_EDep - _SDep) / _Rlev + 0.5)); int m_Record = (float)(fabs((_EDep - _SDep) / _Rlev + 0.5));
int _nSamples = _wave.TimeSamples; int _nSamples = _wave.TimeSamples;
if (m_fScaleV <= 0.0f)
m_fScaleV = _nSamples;
char *value = new char[(_nSamples + 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->ReadWave(index, _SDep, m_Record, (void *)value);
logio->CloseWave(index); logio->CloseWave(index);
@ -181,6 +212,11 @@ void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName)
widget->xAxis->ticker()->setTickCount(10);//x个主刻度 widget->xAxis->ticker()->setTickCount(10);//x个主刻度
widget->yAxis->ticker()->setTickCount(60);//y个主刻度 widget->yAxis->ticker()->setTickCount(60);//y个主刻度
widget->xAxis->setTicks(false);
widget->yAxis->setTicks(false);
widget->xAxis2->setTicks(false);
widget->yAxis2->setTicks(false);
//对调XY轴在最前面设置 //对调XY轴在最前面设置
QCPAxis *yAxis = widget->yAxis; QCPAxis *yAxis = widget->yAxis;
QCPAxis *xAxis = widget->xAxis; QCPAxis *xAxis = widget->xAxis;
@ -274,7 +310,10 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName)
float m_Base = 0.0f; float m_Base = 0.0f;
float DifBase = (m_MaxRange - m_Base) / 1; float DifBase = (m_MaxRange - m_Base) / 1;
int nStep = 600;// mWaveMes.m_WaveSpace; int nStep = m_nWaveJg;// mWaveMes.m_WaveSpace;
if (m_nWaveJg < 10)
nStep = 10;
if (nStep < 1) nStep = 1; if (nStep < 1) nStep = 1;
float m_r = m_Rlev * nStep; float m_r = m_Rlev * nStep;
detp = int((detp - m_PlotSdep) / m_r)*m_r + m_PlotSdep; detp = int((detp - m_PlotSdep) / m_r)*m_r + m_PlotSdep;
@ -323,8 +362,8 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName)
else if (_wave.RepCode == REPR_FLOAT) { else if (_wave.RepCode == REPR_FLOAT) {
ch = vVdl.vfloat[i + lpoint]; ch = vVdl.vfloat[i + lpoint];
} }
//else else
//ch = GetData(_wave.RepCode, (char *)&vVdl.vchar[(i + lpoint)*_wave.CodeLen]); ch = GetData(_wave.RepCode, (char *)&vVdl.vchar[(i + lpoint)*_wave.CodeLen]);
if (ch == -9999.0 || ch == -99999.0 || ch == -999.25) if (ch == -9999.0 || ch == -99999.0 || ch == -999.25)
ch = 0; ch = 0;
} }
@ -334,29 +373,51 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName)
{ {
nmy = ch; nmy = ch;
} }
//if (objViewInfo->m_Logarithmic == AXIS_LOGARITHMIC ||
// objViewInfo->m_maxRange == -99999) {
// if (vmin > ch) vmin = ch;
// if (vmax < ch) vmax = ch;
//}
} }
QVector<double> vx; QVector<double> vx;
QVector<double> vy; QVector<double> vy;
double dminy = 0.0;
for (int i = 0; i < nPoint; i++) for (int i = 0; i < nPoint; i++)
{ {
vx << i; vx << i;
vy << (-dep1 - 1) + vals[i] / nmy;
double d = (-dep1 - 1) + vals[i] / (nmy/ m_nWaveHei);
vy << d;
if (d < dminy)
dminy = d;
} }
QCPGraph * graph = widget->graph(nidx); QCPGraph * graph0 = widget->graph(nidx);
if (graph == NULL) if (graph0 == NULL)
{ {
graph = widget->addGraph(); graph0 = widget->addGraph();
//graph->setPen(QPen(clor)); graph0->setPen(QPen(m_newColor));
} }
graph->setData(vx, vy); graph0->setData(vx, vy);
//graph->setBrush(QBrush(QColor(255, 0, 0, 100)));
nidx++; nidx++;
if (m_nDrawType == 1)
{
QCPGraph * graph1 = widget->graph(nidx);
if (graph1 == NULL)
{
graph1 = widget->addGraph();
graph1->setPen(QPen(m_newColor));
}
double dx1 = vx[0];
double dx2 = vx[vx.size() - 1];
vx.clear();
vx << dx1 << dx2;
vy.clear();
vy << dminy << dminy;
graph1->setData(vx, vy);
nidx++;
graph0->setBrush(QBrush(m_newColor));
graph0->setChannelFillGraph(graph1);
}
} }
widget->replot(); widget->replot();
@ -461,6 +522,11 @@ QCPColorMap * QMyCustomPlot::updateWave()
return m_colorMap; return m_colorMap;
} }
float QMyCustomPlot::getScaleV()
{
return m_fScaleV;
}
//蝌蚪图,重绘网格线 //蝌蚪图,重绘网格线
void QMyCustomPlot::drawCustomElements() void QMyCustomPlot::drawCustomElements()
{ {
@ -1240,36 +1306,23 @@ void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist)
QString strValue = vlist.at(6).toString(); QString strValue = vlist.at(6).toString();
if ("类型" == strProperty) if ("类型" == strProperty)
{ {
if (strValue == "0") m_nDrawType = strValue.toInt();
{ this->changePropertyWaveUpdate();
if (this->m_colorMap) }
this->m_colorMap->setVisible(false); else if ("波形间隔" == strProperty)
for (int i = 0; i < graphCount(); i++) {
{ m_nWaveJg = strValue.toInt();
graph(i)->setVisible(true); this->changePropertyWaveUpdate();
} }
else if ("波形高度" == strProperty)
if (this->m_bX2Y) {
{ m_nWaveHei = strValue.toInt();
QCPAxis *yAxis = this->yAxis; this->changePropertyWaveUpdate();
QCPAxis *xAxis = this->xAxis; }
this->xAxis = yAxis; else if ("颜色" == strProperty)
this->yAxis = xAxis; {
this->m_bX2Y = false; m_newColor = vlist.at(6).value<QColor>();
} this->changePropertyWaveUpdate();
this->initWave2(m_strSlfName, m_strLineName);
}
else if (strValue == "2")
{
if (this->m_colorMap)
this->m_colorMap->setVisible(true);
for (int i = 0; i < graphCount(); i++)
{
graph(i)->setVisible(false);
}
this->m_bX2Y = true;
this->initWave(m_strSlfName, m_strLineName);
}
} }
else if ("方式" == strProperty) else if ("方式" == strProperty)
{ {
@ -1284,7 +1337,8 @@ void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist)
{ {
if (m_colorMap) if (m_colorMap)
{ {
float f = 264 / strValue.toFloat(); m_fScaleV = strValue.toFloat();
float f = 264 / m_fScaleV;
m_colorMap->data()->setValueRange(QCPRange(m_fmin, m_fmax*f)); m_colorMap->data()->setValueRange(QCPRange(m_fmin, m_fmax*f));
} }
} }

View File

@ -21,7 +21,10 @@ public:
{ {
} }
void changePropertyWaveUpdate();
// 绘图类型-变密度(成像)
void initWave(QString strSlfName, QString strWaveName); void initWave(QString strSlfName, QString strWaveName);
// 绘图类型-波形
void initWave2(QString strSlfName, QString strWaveName); void initWave2(QString strSlfName, QString strWaveName);
@ -29,6 +32,8 @@ public:
void setSchemeIndex(int nidx, int colorNum); void setSchemeIndex(int nidx, int colorNum);
double** getWavedata(int nrow, int ncol); double** getWavedata(int nrow, int ncol);
QCPColorMap * updateWave(); QCPColorMap * updateWave();
float getScaleV();
protected: protected:
//virtual void mouseMoveEvent(QMouseEvent *event); //virtual void mouseMoveEvent(QMouseEvent *event);
@ -75,13 +80,16 @@ public:
double** m_wavedata = NULL; double** m_wavedata = NULL;
int m_nRow = 0; int m_nRow = 0;
int m_nCol = 0; int m_nCol = 0;
int m_nDrawType = 3; // 绘图类型
// 0.全周 1.正半周 2.负半周 // 0.全周 1.正半周 2.负半周
int m_nMode = 1; int m_nMode = 1;
float m_fScaleV = 264.0f; float m_fScaleV = 0.0f;
float m_fmin; float m_fmin;
float m_fmax; float m_fmax;
int m_nColorNum = 256; int m_nColorNum = 256;
int m_nSchemeIndex = 1; int m_nSchemeIndex = 1;
int m_nWaveJg = 100;
int m_nWaveHei = 1;
public: public:
//分段刷新 //分段刷新
QVector<double> m_x; QVector<double> m_x;