logplus/logPlus/forminfo.cpp
2026-03-24 09:43:05 +08:00

1221 lines
44 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "forminfo.h"
#include "ui_forminfo.h"
#include "CallManage.h"
#include <QDebug>
#include <QMimeData>
#include <QPushButton>
#include <QVBoxLayout>
#include <QMenu>
#include <QPainterPath>
#include "geometryutils.h"
#include "qtColorSchemeComboBox.h"
//曲线名称(单个)
FormInfo::FormInfo(QWidget *parent, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor) :
QWidget(parent),
ui(new Ui::FormInfo)
{
ui->setupUi(this);
//
setAcceptDrops(true);
m_strSlfName = strSlfName;
m_strWellName = strWellName;
m_strTrackName = strTrackName;
m_strLineName = strLineName;
m_lineColor = lineColor;
//
m_dWidth = 3;
m_lineStyle = Qt::SolidLine;
m_newFillMode = "无填充";
m_newHeadFill = "不绘制";
// //
// QPushButton *button = new QPushButton("Drag Me", this);
// QVBoxLayout *layout = new QVBoxLayout(this);
// layout->addWidget(button);
// setLayout(layout);
// // 设置拖拽功能
// setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
// setAttribute(Qt::WA_TranslucentBackground);
//左刻度
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLeftScale(QString, QString, QString, QString, QString, double)), this, SLOT(s_ChangeLeftScale(QString, QString, QString, QString, QString, double)));
//右刻度
connect(CallManage::getInstance(), SIGNAL(sig_ChangeRightScale(QString, QString, QString, QString, QString, double)), this, SLOT(s_ChangeRightScale(QString, QString, QString, QString, QString, double)));
//刻度类型
connect(CallManage::getInstance(), SIGNAL(sig_ChangeScaleType(QString, QString, QString, QString, QString, QString)), this, SLOT(s_ChangeScaleType(QString, QString, QString, QString, QString, QString)));
//颜色
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineColor(QString, QString, QString, QString, QString, QColor)), this, SLOT(s_ChangeLineColor(QString, QString, QString, QString, QString, QColor)));
//线宽
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineWidth(QString, QString, QString, QString, QString, double)), this, SLOT(s_ChangeLineWidth(QString, QString, QString, QString, QString, double)));
//线型
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineStyle(QString, QString, QString, QString, QString, Qt::PenStyle)), this, SLOT(s_ChangeLineStyle(QString, QString, QString, QString, QString, Qt::PenStyle)));
//绘制方式
//曲线
connect(CallManage::getInstance(), SIGNAL(sig_ChangeDrawLine(QString, QString, QString, QString, QString, bool)), this, SLOT(s_ChangeDrawLine(QString, QString, QString, QString, QString, bool)));
//杆状
connect(CallManage::getInstance(), SIGNAL(sig_ChangeDrawGan(QString, QString, QString, QString, QString, bool)), this, SLOT(s_ChangeDrawGan(QString, QString, QString, QString, QString, bool)));
//点状
connect(CallManage::getInstance(), SIGNAL(sig_ChangeDrawPoint(QString, QString, QString, QString, QString, bool)), this, SLOT(s_ChangeDrawPoint(QString, QString, QString, QString, QString, bool)));
//绘制对称曲线
connect(CallManage::getInstance(), SIGNAL(sig_ChangeDrawSymmetry(QString, QString, QString, QString, QString, bool)), this, SLOT(s_ChangeDrawSymmetry(QString, QString, QString, QString, QString, bool)));
//斜井三图一表
connect(CallManage::getInstance(), SIGNAL(sig_ChangeTvdProperty(QString, QString, QString, QString, QString, QString, QString, QVariant)),
this, SLOT(s_ChangeTvdProperty(QString, QString, QString, QString, QString, QString, QString, QVariant)));
//岩性填充-不填充
connect(CallManage::getInstance(), SIGNAL(sig_ClearFillMode(QString, QString, QString, QString, QString)), this, SLOT(s_ClearFillMode(QString, QString, QString, QString, QString)));
//岩性填充-填充
connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QString, QColor, QColor, QString, bool)),
this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QString, QColor, QColor, QString, bool)));
//修改曲线选择状态 iSelect=0未知1标准曲线2主曲线3从曲线
connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineStatus(QString, QString, QString, QString, QString, int, bool)), this, SLOT(s_ChangeLineStatus(QString, QString, QString, QString, QString, int, bool)));
QFont font1("微软雅黑", 10);
QFont font2("微软雅黑", 8);
m_curveNameFont = font1; // 曲线名称
m_curveUnitFont = font2; // 曲线单位
m_curveScaleFont = font2; // 曲线刻度
m_layerFont = font1;
m_bShowScale = true;
}
FormInfo::~FormInfo()
{
delete ui;
}
void FormInfo::initProperty(QJsonObject obj)
{
m_vmin = obj.value("vmin").toDouble();
m_vmax = obj.value("vmax").toDouble();
m_strUnit = obj.value("Unit").toString();
QString strType = obj.value("Type").toString();
if ("waveObject" == strType)
{
m_nDrawType = obj.value("DrawType").toInt();
m_nFillType = obj.value("FillType").toInt();
m_strAmp = obj.value("Amp").toString();
m_fMaxAmp = obj.value("MaxAmp").toDouble();
m_nSchemeIndex = obj.value("SchemeIndex").toInt();
m_nColorNum = obj.value("ColorNum").toInt();
m_bDrawDepth = obj.value("DrawDepth").toBool();
m_bDrawBase = obj.value("DrawBase").toBool();
m_bOddEven = obj.value("OddEven").toBool();
m_nWaveJg = obj.value("WaveJg").toInt();
m_fWaveHei = obj.value("WaveHei").toDouble();
}
else if ("depthObject" == strType)
{
m_bVerticaDrawing = obj["bVerticaDrawing"].toBool(); // 垂向绘制
m_nRotationAngle = obj["nRotationAngle"].toInt(); // 旋转角度
m_headHeight = obj["headHeight"].toInt();
m_strUnit = obj["strUnit"].toString(); // 单位
{
QStringList fontParts = obj["curveNameFont"].toString().split(","); // 按逗号拆分
if (fontParts.size() >= 2) {
m_curveNameFont.setFamily(fontParts[0]); // 设置字体名称
m_curveNameFont.setPointSize(fontParts[1].toInt()); // 设置字号
}
}
{
QStringList fontParts = obj["strUnitFont"].toString().split(","); // 按逗号拆分
if (fontParts.size() >= 2) {
m_strUnitFont.setFamily(fontParts[0]); // 设置字体名称
m_strUnitFont.setPointSize(fontParts[1].toInt()); // 设置字号
}
}
m_headHeight = obj["headHeight"].toInt();
m_sdRulerColor = obj["sdRulerColor"].toString(); // 标尺颜色
m_sdInterval = obj["sdInterval"].toDouble(); // 间隔
// 标注字体
{
QStringList fontParts = obj["sdLabelFont"].toString().split(","); // 按逗号拆分
if (fontParts.size() >= 2) {
m_sdLabelFont.setFamily(fontParts[0]); // 设置字体名称
m_sdLabelFont.setPointSize(fontParts[1].toInt()); // 设置字号
}
}
m_sdRotationAngle = obj["sdRotationAngle"].toDouble(); // 旋转(°)
m_sdDrawStartDepth = obj["sdDrawStartDepth"].toBool(); // 绘制起点深度
m_sdDrawEndDepth = obj["sdDrawEndDepth"].toBool(); // 绘制终点深度
m_sdMeasuredDepth = obj["sdMeasuredDepth"].toBool(); // 斜深
m_sdElevationVerticalDepth = obj["sdElevationVerticalDepth"].toBool(); // 海拔垂深
m_sdVerticalDepth = obj["sdVerticalDepth"].toBool(); // 垂深
m_sdMeasuredDepthPosition = obj["sdMeasuredDepthPosition"].toInt(); // 斜深位置
m_sdVerticalDepthPosition = obj["sdVerticalDepthPosition"].toInt(); // 垂深位置
m_sdElevationVerticalDepthPosition = obj["sdElevationVerticalDepthPosition"].toInt(); // 海拔垂深位置
m_sdMajorTickLineLength = obj["sdMajorTickLineLength"].toInt(); // 主刻度线长度
m_sdMajorTickLineWidth = obj["sdMajorTickLineWidth"].toInt(); // 主刻度线宽度
m_sdMinorTickLineLength = obj["sdMinorTickLineLength"].toInt(); // 次刻度线长度
m_sdMinorTickLineWidth = obj["sdMinorTickLineWidth"].toInt(); // 次刻度线宽度
}
}
QJsonObject FormInfo::makeJson()
{
// 创建根对象
QJsonObject rootObj;
//
QString slffilename=QString("");
int ind=m_strSlfName.lastIndexOf('\\');
int ind2=m_strSlfName.lastIndexOf('/');
if(ind2>ind) ind=ind2;
if(ind>-1) {
slffilename=m_strSlfName.mid(ind+1);
}
rootObj["SlfName"] = slffilename;
rootObj["WellName"] = m_strWellName;
// rootObj["TrackName"] = m_strTrackName;
rootObj["LineName"] = m_strLineName;
rootObj["AliasName"] = m_strAliasName;
//
rootObj["Type"] = m_strType;
rootObj["curveNameFont"] = m_curveNameFont.toString();
rootObj["lineColor"] = m_lineColor.name();
if (m_strType == "tableObject")
{
//垂向绘制
rootObj["VerticaDrawing"] = m_bVerticaDrawing;
rootObj["RotationAngle"] = m_nRotationAngle;
if (m_strLineName == "GUJING1_RESULT" || m_strLineName == "GUJING2_RESULT" || m_strLineName == "GUJING3_RESULT"
|| m_strLineName == "SWALL_CORE" || m_strLineName == "WORDS_RELUST" || m_strLineName == "LAYER_DATA")
{
//固井结论/井壁取心/文字结论/地质分层
//item属性写入slf文件不需要此次记录
return rootObj;
}
else if (m_strLineName == "GEO_LITH")
{
//录井剖面
rootObj["OilZhan"] = m_dOilZhan;//含油占比
rootObj["LithColor"] = m_bLithColor;
rootObj["LithOne"] = m_bLithOne;
rootObj["ShowOil"] = m_bShowOil;
rootObj["CenterOil"] = m_bCenterOil;
rootObj["ShowColor"] = m_bShowColor;
rootObj["ShowColorNum"] = m_bShowColorNum;
//item属性写入slf文件不需要此次记录
return rootObj;
}
}
else if (m_strType == "JiegutextObject")
{
//气测/FMT/射孔/文本
//item属性写入slf文件不需要此次记录
return rootObj;
}
else if (m_strType == "LogfaceObject")
{
//沉积相
rootObj["DrawFac"] = m_bDrawFac;
rootObj["DrawPhase"] = m_bDrawPhase;
rootObj["DrawMFacName"] = m_bDrawMFacName;
//item属性写入slf文件不需要此次记录
return rootObj;
}
else if (m_strType == "TubingstringObject")
{
//套管组件
//垂向绘制
rootObj["VerticaDrawing"] = m_bVerticaDrawing;
rootObj["RotationAngle"] = m_nRotationAngle;
//
rootObj["DrawStruct"] = m_bDrawStruct_Tubing;
rootObj["DrawTubing"] = m_bDrawTubing_Tubing;
rootObj["DrawTools"] = m_bDrawTools_Tubing;
rootObj["DrawSPTool"] = m_bDrawSPTool_Tubing;
rootObj["DrawCCL"] = m_bDrawCCL_Tubing;
//
rootObj["Oguan"] = m_Oguan_Tubing;
rootObj["inD"] = m_inD_Tubing;
rootObj["OutD"] = m_OutD_Tubing;
//item属性写入slf文件不需要此次记录
return rootObj;
}
rootObj["Unit"] = m_strUnit;
rootObj["Width"] = m_dWidth;
rootObj["lineStyle"] = m_lineStyle;
rootObj["vmax"] = m_vmax;
rootObj["vmin"] = m_vmin;
rootObj["ScaleType"] = m_strScaleType;
rootObj["ShowScale"] = m_bShowScale;
if (m_strType == "curveObject")
{
rootObj["DrawLine"] = m_bDrawLine; // 曲线
rootObj["DrawGan"] = m_bDrawGan; // 杆状
rootObj["DrawPoint"] = m_bDrawPoint; // 点状
rootObj["DrawSymmetry"] = m_bDrawSymmetry; // 绘制对称曲线
//岩性填充
rootObj["newFillMode"] = m_newFillMode;
rootObj["newHeadFill"] = m_newHeadFill;
rootObj["newTargetLine"] = m_newTargetLine;
rootObj["newFillType"] = m_newFillType;
//填充颜色
rootObj["newColor"] = m_newColor.name();
rootObj["newLithosImage"] = m_newLithosImage;
rootObj["new_vMax"] = m_new_vMax;
rootObj["new_vMin"] = m_new_vMin;
//岩性前景色
rootObj["frontColor"] = m_frontColor.name();
//岩性背景色
rootObj["backColor"] = m_backColor.name();
}
else if (m_strType == "waveObject")
{
rootObj["DrawType"] = m_nDrawType;
rootObj["FillType"] = m_nFillType;
rootObj["Amp"] = m_strAmp;
rootObj["MaxAmp"] = m_fMaxAmp;
rootObj["DrawDepth"] = m_bDrawDepth; // 绘制波深度
rootObj["DrawBase"] = m_bDrawBase; // 绘制波基线
rootObj["OddEven"] = m_bOddEven; // 奇偶配色
rootObj["WaveJg"] = m_nWaveJg; // 波形间隔
rootObj["WaveHei"] = m_fWaveHei; // 波形高度
rootObj["SchemeIndex"] = m_nSchemeIndex;
rootObj["ColorNum"] = m_nColorNum;
}
else if (m_strType == "depthObject")
{
rootObj["bVerticaDrawing"] = m_bVerticaDrawing; // 垂向绘制
rootObj["nRotationAngle"] = m_nRotationAngle; // 旋转角度
rootObj["strUnit"] = m_strUnit; // 单位
rootObj["curveNameFont"] = m_curveNameFont.toString();
rootObj["strUnitFont"] = m_strUnitFont.toString(); //单位字体
rootObj["headHeight"] = m_headHeight;
rootObj["sdRulerColor"] = m_sdRulerColor.name(); // 标尺颜色
rootObj["sdInterval"] = m_sdInterval; // 间隔
rootObj["sdLabelFont"] = m_sdLabelFont.toString(); // 标注字体
rootObj["sdRotationAngle"] = m_sdRotationAngle; // 旋转(°)
rootObj["sdDrawStartDepth"] = m_sdDrawStartDepth; // 绘制起点深度
rootObj["sdDrawEndDepth"] = m_sdDrawEndDepth; // 绘制终点深度
rootObj["sdMeasuredDepth"] = m_sdMeasuredDepth; // 斜深
rootObj["sdElevationVerticalDepth"] = m_sdElevationVerticalDepth; // 海拔垂深
rootObj["sdVerticalDepth"] = m_sdVerticalDepth; // 垂深
rootObj["sdMeasuredDepthPosition"] = m_sdMeasuredDepthPosition; // 斜深位置
rootObj["sdVerticalDepthPosition"] = m_sdVerticalDepthPosition; // 垂深位置
rootObj["sdElevationVerticalDepthPosition"] = m_sdElevationVerticalDepthPosition; // 海拔垂深位置
rootObj["sdMajorTickLineLength"] = m_sdMajorTickLineLength; // 主刻度线长度
rootObj["sdMajorTickLineWidth"] = m_sdMajorTickLineWidth; // 主刻度线宽度
rootObj["sdMinorTickLineLength"] = m_sdMinorTickLineLength; // 次刻度线长度
rootObj["sdMinorTickLineWidth"] = m_sdMinorTickLineWidth; // 次刻度线宽度
}
return rootObj;
}
void FormInfo::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
QRect rect = this->rect();
//背景透明
painter.fillRect(rect.left(), rect.top(), rect.width(), rect.height(), QColor(0, 0, 0, 0)); //QColor(67, 67, 67, 100)
if(m_newFillMode=="无填充" || m_newHeadFill == "不绘制")
{
painter.setBrush(Qt::NoBrush);
}
else //if(m_newFillMode=="填充" && m_newHeadFill == "绘制")
{
if(m_newFillType == "岩性模式")
{
QColor oldFrontColor(0, 0, 0); // 原始颜色
QColor oldBackColor(255, 255, 255); // 原始颜色
//
QImage image(m_newLithosImage);
for (int y = 0; y < image.height(); ++y) {
for (int x = 0; x < image.width(); ++x) {
QColor pixelColor = QColor(image.pixel(x, y));
if (pixelColor == oldFrontColor) {
image.setPixelColor(x, y, m_frontColor); // 使用 setPixelColor 来设置新颜色
}
if (pixelColor == oldBackColor) {
image.setPixelColor(x, y, m_backColor); // 使用 setPixelColor 来设置新颜色
}
}
}
//
painter.setBrush(QBrush(QPixmap::fromImage(image)));
//painter.setBrush(QBrush(QPixmap(m_newLithosImage)));
//graph(0)->setBrush(QBrush(QPixmap(":/image/file.png")));
}
else if(m_newFillType == "颜色模式")
{
painter.setBrush(QBrush(m_newColor));
}
else if(m_newFillType == "成像化")
{
}
}
//painter.setBrush(QBrush(Qt::red, Qt::SolidPattern));
QRect rectRound(rect.left()+2,rect.top()+4, rect.width()-4, rect.height()-8);
painter.setPen(QPen(m_lineColor, m_dWidth, m_lineStyle));
//painter.drawRoundRect(rectRound);//利用画刷(颜色/岩性图片),画框
painter.drawRect(rectRound);
QString strShowTxt = "";
painter.setBrush(Qt::NoBrush); // 确保文字不被填充色遮挡
painter.setFont(m_curveNameFont);
painter.setPen(m_lineColor); // fontColor QColor(220, 220, 220)
//painter.drawText(rect.left() + 20, 30, m_strAliasName); // titleBarText QStringLiteral("动画")
//painter.drawText(rect, Qt::AlignCenter, m_strAliasName);
if(m_strAliasName == "")
{
//painter.drawText(rect.left(), rect.top(), rect.width(), rect.height()/3, Qt::AlignCenter, m_strLineName);
}
else {
//气测/FMT/射孔/文本
if(m_strType=="JiegutextObject")
{
QStringList list = m_strAliasName.split("/");//QString字符串分割函数
int iMaxNum = list.size();
if (iMaxNum > 1)
{
float fSpace = rect.width()/(float)iMaxNum;
for(int i=0; i<iMaxNum; i++)
{
painter.save();
painter.rotate(90);
int x = rect.left() + i*fSpace + 0.5*fSpace;
int y = rect.top()+4;
//painter.drawText(rect.top()+4, rect.left() + i*fSpace + 0.5*fSpace, list[i]);
painter.drawText(y, -x, list[i]);
painter.restore(); // 恢复原始状态
//break;
}
for(int i=0; i<iMaxNum-1; i++)
{
QPointF p1 = QPointF(rect.left() + (i+1)*fSpace, rect.top()+4);
QPointF p2 = QPointF(rect.left() + (i+1)*fSpace, rect.bottom()-4);
painter.drawLine(p1, p2);
}
}
else {
painter.drawText(rect.left(), rect.top(), rect.width(), rect.height()/3, Qt::AlignCenter, m_strAliasName);
}
return;
}
//iSelect=0未知1标准曲线2主校曲线3从校曲线
QString strAliasNameTmp = m_strAliasName;
if(m_iSelect==0)
{
strAliasNameTmp = strAliasNameTmp;
}
else if(m_iSelect==1)
{
if(m_bMerge)//是拼接状态
{
strAliasNameTmp = strAliasNameTmp + "-目";
}
else {
strAliasNameTmp = strAliasNameTmp + "-标";
}
}
else if(m_iSelect==2)
{
if(m_bMerge)//是拼接状态
{
strAliasNameTmp = strAliasNameTmp + "-源";
}
else {
strAliasNameTmp = strAliasNameTmp + "-主校";
}
}
else if(m_iSelect==3)
{
if(m_bMerge)//是拼接状态
{
strAliasNameTmp = strAliasNameTmp + "-从接";
}
else {
strAliasNameTmp = strAliasNameTmp + "-从校";
}
}
strShowTxt = strAliasNameTmp;
//painter.drawText(rect.left(), rect.top(), rect.width(), rect.height()/3, Qt::AlignCenter, strAliasNameTmp);
}
if(m_strType=="waveObject")
{
if (m_nDrawType == 0 || m_nDrawType == 1)
{
int nbot = rect.bottom()- rect.height() / 3.0;
QVector<QPointF> pts;
int i = 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 + (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 - rect.height() / 12.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() / 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);
}
}
}
if(m_strLineName=="RESULT")
{
//解释结论,不绘制左右范围
strShowTxt = "解释结论";
}
else if(m_strLineName=="CORE_PHYSICS")
{
//岩心分析,不绘制左右范围
strShowTxt = "岩心实验数据";
}
else if(m_strLineName=="FRAC_HOLE.TABLE" && m_strType=="tableObject")
{
//蝌蚪图,不绘制左右范围
strShowTxt = "蝌蚪图";
}
if (strShowTxt.length()>0)
{
QRect rt = rect;
QString text = "";
if (!m_bVerticaDrawing)
{
rt.setX(rect.left());
rt.setY(rect.top() + rect.height() / 3);
rt.setWidth(rect.width());
rt.setHeight(rect.height() / 3);
text = strShowTxt;
}
else
{
for (int i = 0; i < strShowTxt.size(); i++) {
if (!i)text += strShowTxt.at(i);
else {
text += "\n";
text += strShowTxt.at(i);
}
}
}
if (m_nRotationAngle != 0)
{
// 获取文本的精确尺寸
QFontMetrics fm(m_curveUnitFont);
int textWidth = fm.horizontalAdvance(text);
int textHeight = fm.height();
painter.save();
painter.translate(rect.center()); // 将原点移到控件中心
painter.rotate(m_nRotationAngle); // 顺时针旋转90度
// 3. 绘制文本(相对于新原点居中)
painter.drawText(-textWidth / 2, // x偏移向左一半宽度
-textHeight / 2, // y偏移向上一半高度
text);
painter.restore();
}
else
{
painter.drawText(rt, Qt::AlignCenter, text);
}
}
//单位------------------------------
painter.setFont(m_curveUnitFont);
painter.setPen(m_lineColor);
//painter.drawText(rect.left() + 20, 55, m_strUnit);
//painter.drawText(rect.left() + 20, 80, QString::number(m_vmin)+" ~ "+QString::number(m_vmax));
//
if(m_strType=="tableObject" && (m_strLineName=="WORDS_RELUST" || m_strLineName == "RESULT"
|| m_strLineName == "GEO_LITH"|| m_strLineName == "SWALL_CORE"
|| m_strLineName == "GUJING1_RESULT" || m_strLineName == "GUJING2_RESULT" || m_strLineName == "GUJING3_RESULT"
|| m_strLineName == "CORE_PHYSICS" || m_strLineName == "IMAGE_DATA"
|| m_strLineName == "LAYER_DATA") )
{
}
else {
if(m_strType=="waveObject"
|| m_strType=="curveObject")
{
painter.drawText(rect.left()+10, rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignCenter, m_strUnit);
// 显示刻度
if (m_bShowScale)
{
painter.setFont(m_curveScaleFont);
QFontMetrics fm1(m_curveScaleFont);
QRect textRect = fm1.boundingRect(QString::number(m_vmax, 'f', 0));
painter.drawText(rect.left() + 10, rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignLeft | Qt::AlignVCenter, QString::number(m_vmin));// +" ~ " + QString::number(m_vmax));
painter.drawText(rect.left() + 10, rect.top() + rect.height() * 2 / 3, rect.width() - textRect.width(), rect.height() / 3, Qt::AlignRight | Qt::AlignVCenter, QString::number(m_vmax));
}
}
}
if(m_strLineName=="井眼垮塌矢量图"
|| m_strLineName=="井斜方位图")
{
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));
}
if(m_strLineName == "深度")
{
// 2. 给painter设置字体关键步骤
painter.setFont(m_strUnitFont);
painter.drawText(rect.left(), rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignCenter, this->m_strUnit);
}
QWidget::paintEvent(event);
}
void FormInfo::dragEnterEvent(QDragEnterEvent* event)
{
qDebug() << "FormInfo dragEnterEvent";
const QMimeData* mimeData = event->mimeData();
// 检查拖拽的数据类型,确定是否接受拖拽
if (event->mimeData()->hasFormat("text/plain")) {
event->acceptProposedAction();
//QApplication::setOverrideCursor(Qt::PointingHandCursor); // 设置鼠标为可添加状态
}
else
{
event->ignore();
//QApplication::setOverrideCursor(Qt::ForbiddenCursor); // 设置鼠标为不可添加状态
}
}
void FormInfo::dragMoveEvent(QDragMoveEvent* event)
{
qDebug() << "FormInfo dragMoveEvent";
// 可以在这里更新鼠标的位置,根据位置判断是否可以放置
// ...
//dragEnterEvent(event); // 可以使用相同的逻辑
//event->accept();
}
void FormInfo::dropEvent(QDropEvent* event)
{
qDebug() << "FormInfo dropEvent";
// 处理放置动作更新UI或数据
if (event->mimeData()->hasFormat("text/plain")) {
// 获取拖拽的数据
QString strExtern = event->mimeData()->text();
qDebug() << strExtern;
//
QStringList list = strExtern.split("#@@#");//QString字符串分割函数
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 << " strType:" << strType;
if(m_strWellName == strWellName)
{
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);
}
else if(strType=="tableObject")
{
//新建表格曲线
emit CallManage::getInstance()->sig_AddTableLine(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName);
}
// 接受拖拽事件
event->setDropAction(Qt::MoveAction);
event->accept();
}
else
{
// 如果井名不正确,不接受拖拽事件
event->ignore();
}
}
else
{
// 如果数据格式不正确,不接受拖拽事件
event->ignore();
}
}
else
{
// 如果数据格式不正确,不接受拖拽事件
event->ignore();
}
// 恢复鼠标光标
//QApplication::restoreOverrideCursor();
}
//线宽
void FormInfo::setLineWidth(double dWidth)
{
m_dWidth = dWidth;
}
double FormInfo::getLineWidth()
{
return m_dWidth;
}
//线型
void FormInfo::setLineStyle(Qt::PenStyle lineStyle)
{
m_lineStyle = lineStyle;
}
Qt::PenStyle FormInfo::getLineStyle()
{
return m_lineStyle;
}
void FormInfo::setVMax(float vmax)
{
m_vmax = vmax;
}
float FormInfo::getVMax()
{
return m_vmax;
}
void FormInfo::setVMin(float vmin)
{
m_vmin = vmin;
}
float FormInfo::getVMin()
{
return m_vmin;
}
void FormInfo::setFrontColor(QColor frontColor)
{
m_frontColor = frontColor;
}
QColor FormInfo::getFrontColor()
{
return m_frontColor;
}
void FormInfo::setBackColor(QColor backColor)
{
m_backColor = backColor;
}
QColor FormInfo::getBackColor()
{
return m_backColor;
}
bool FormInfo::setInfoProperty(QString strProName, QVariant val)
{
bool bDraw = false;
if ("显示名称" == strProName)
{
this->m_strAliasName = val.toString();
}
else if ("显示单位" == strProName)
{
this->m_strUnit = val.toString();
}
else if ("曲线名称" == strProName || "字体" == strProName)
{
this->m_curveNameFont = val.value<QFont>();
}
else if ("曲线单位" == strProName)
{
this->m_curveUnitFont = val.value<QFont>();
}
else if ("曲线刻度" == strProName)
{
this->m_curveScaleFont = val.value<QFont>();
}
else if ("类型" == strProName)
{
bDraw = true;
this->m_nDrawType = val.toInt();
}
else if ("方式" == strProName)
{
bDraw = true;
this->m_nFillType = val.toInt();
}
else if ("左刻度" == strProName)
{
bDraw = true;
this->m_vmin = val.toDouble();
}
else if ("右刻度" == strProName)
{
bDraw = true;
this->m_vmax = val.toDouble();
}
else if ("幅度刻度" == strProName)
{
this->m_strAmp = val.toString();
}
else if ("最大振幅" == strProName)
{
bDraw = true;
this->m_fMaxAmp = val.toFloat();
}
else if ("显示刻度" == strProName)
{
this->m_bShowScale = val.toBool();
}
else if ("绘制波深度" == strProName)
{
bDraw = true;
this->m_bDrawDepth = val.toBool();
}
else if ("绘制波基线" == strProName)
{
bDraw = true;
this->m_bDrawBase = val.toBool();
}
else if ("奇偶配色" == strProName)
{
bDraw = true;
this->m_bOddEven = val.toBool();
}
else if ("波列基值" == strProName)
{
bDraw = true;
this->m_fWaveBase = val.toFloat();
}
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)
{
this->m_nSchemeIndex = val.toInt();
return true;
}
else if ("变密度颜色级数" == strProName)
{
this->m_nColorNum = val.toInt();
return true;
}
else if ("垂向绘制" == strProName)
{
this->m_bVerticaDrawing = val.toBool();
}
else if ("旋转角度(°)" == strProName)
{
this->m_nRotationAngle = val.toInt();
}
else if ("结论占比%" == strProName)
{
bDraw = true;
this->m_nConclusionProportion = val.toInt();
}
else if ("显示位置(cm)" == strProName)
{
bDraw = true;
this->m_nShowPos = val.toInt();
}
else if ("显示层号" == strProName)
{
bDraw = true;
this->m_bShowLayerNo = val.toBool();
}
else if ("层号字体" == strProName)
{
bDraw = true;
this->m_layerFont = val.value<QFont>();
}
else if ("层号旋转" == strProName)
{
bDraw = true;
this->m_fLayerRotate = val.toFloat();
}
this->update();
return bDraw;
}
int FormInfo::getFillTypeIndex()
{
return m_nFillType;
}
//修改曲线选择状态 iSelect=0未知1标准曲线2主曲线3从曲线
void FormInfo::s_ChangeLineStatus(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int iSelect, bool bMerge)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_iSelect = iSelect;
m_bMerge = bMerge;
update();
}
}
//属性-左刻度
void FormInfo::s_ChangeLeftScale(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newLeftScale)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_vmin = newLeftScale;
update();
}
}
//属性-右刻度
void FormInfo::s_ChangeRightScale(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newRightScale)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_vmax = newRightScale;
update();
}
}
//属性-刻度类型
void FormInfo::s_ChangeScaleType(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strScaleType)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_strScaleType = strScaleType;
}
}
//属性-颜色
void FormInfo::s_ChangeLineColor(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QColor lineColor)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_lineColor = lineColor;
update();
}
}
//属性-线宽
void FormInfo::s_ChangeLineWidth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double width)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_dWidth = width;
update();
}
}
//属性-线型
void FormInfo::s_ChangeLineStyle(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, Qt::PenStyle lineStyle)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_lineStyle = lineStyle;
update();
}
}
//曲线
void FormInfo::s_ChangeDrawLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, bool bDrawLine)
{
m_bDrawLine = bDrawLine;
}
//杆状
void FormInfo::s_ChangeDrawGan(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, bool bDrawGan)
{
m_bDrawGan = bDrawGan;
}
//点状
void FormInfo::s_ChangeDrawPoint(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, bool bDrawPoint)
{
m_bDrawPoint = bDrawPoint;
}
//绘制对称曲线
void FormInfo::s_ChangeDrawSymmetry(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, bool bDrawSymmetry)
{
m_bDrawSymmetry = bDrawSymmetry;
}
void FormInfo::s_ChangeTvdProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
QString strGroup, QString strProperty, QVariant variant)
{
if("井斜数据表参数" == strGroup)
{
if("标题名" == strProperty)
m_Title_table = variant.value<QString>();
else if("头记录高度(cm)" == strProperty)
m_Head_Height = variant.value<double>();
else if("数据记录高度(cm)" == strProperty)
m_Rec_Height = variant.value<double>();
}
else if("立体轨迹图参数" == strGroup)
{
if("标题名" == strProperty)
m_Title_ltgj = variant.value<QString>();
else if("最大位移(m)" == strProperty)
m_MaxWy1 = variant.value<double>();
else if("起始垂深(m)" == strProperty)
m_LTTTVD = variant.value<double>();
else if("垂深间隔(m)" == strProperty)
m_DepSpace1 = variant.value<double>();
else if("是否绘制立体框" == strProperty)
m_is3DFrame = variant.value<bool>();
else if("俯视角(度)" == strProperty)
m_LttAngle_X = variant.value<double>();
else if("侧视角(度)" == strProperty)
m_LttAngle = variant.value<double>();
else if("倾斜角(度)" == strProperty)
m_LttAngle_Z = variant.value<double>();
else if("竖线间隔" == strProperty)
m_LTTTVD = variant.value<double>();
else if("俯视南北间隔数" == strProperty)
m_YD = variant.value<double>();
else if("俯视东西间隔数" == strProperty)
m_XD = variant.value<double>();
else if("附加属性类型" == strProperty)
m_IsDrawProperty = variant.value<int>();
else if("选择井曲线1" == strProperty)
m_CurveName1 = variant.value<QString>();
else if("选择井曲线2" == strProperty)
m_CurveName2 = variant.value<QString>();
else if("调色板参数设置" == strProperty)
m_ColorTableIndex = variant.value<int>();
else if("直径放大系数" == strProperty)
m_calscale = variant.value<double>();
else if("波形基值" == strProperty)
m_baseval = variant.value<double>();
else if("波形最大值" == strProperty)
m_maxval = variant.value<double>();
else if("连续填充" == strProperty)
m_isBlock = variant.value<bool>();
}
else if("立体轨迹图参数" == strGroup)
{
if("最小深度间隔(m)" == strProperty)
m_Rlev = variant.value<bool>();
}
}
//岩性填充-不填充
void FormInfo::s_ClearFillMode(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_newFillMode = "无填充";
update();
}
}
//岩性填充-填充
void FormInfo::s_ChangeFillMode(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName,
QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill,
float vMin, float vMax, QString strOtherScaleType, QColor frontColor, QColor backColor, QString newFillMode, bool bFillNow)
{
if(m_strUuid == strUuid &&
m_strSlfName == strSlfName &&
m_strWellName == strWellName &&
m_strTrackName == strTrackName &&
m_strLineName == strLineName)
{
m_newFillType = newFillType;
m_newTargetLine = newTargetLine;
m_newColor = newColor;
m_newLithosImage = newLithosImage;
m_newHeadFill = newHeadFill;
m_new_vMin = vMin;
m_new_vMax = vMax;
m_strOtherScaleType = strOtherScaleType;
m_frontColor = frontColor;
m_backColor = backColor;
m_newFillMode = newFillMode;//"填充";
update();
}
}
void FormInfo::contextMenuEvent(QContextMenuEvent *event)
{
//曲线
if(m_strType=="curveObject")
{
QMenu menu(this);
menu.addAction(QIcon(::GetImagePath() + "icon/Sheet.png"), "数据对象查看", this, &FormInfo::onShowCurve);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除当前对象", this, &FormInfo::onDeleteCurv);
menu.exec(event->globalPos());
}
else if(m_strType=="tableObject")
{
QMenu menu(this);
menu.addAction(QIcon(::GetImagePath() + "icon/Sheet.png"), "数据对象查看", this, &FormInfo::onShowTable);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除当前对象", this, &FormInfo::onDeleteTable);
menu.exec(event->globalPos());
}
else if(m_strType=="JiegutextObject")
{
//气测/FMT/射孔/文本
QMenu menu(this);
menu.addAction(QIcon(::GetImagePath() + "icon/Sheet.png"), "数据对象查看", this, &FormInfo::onShowTable);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除当前对象", this, &FormInfo::onDeleteTable);
menu.exec(event->globalPos());
}
else if(m_strType=="LogfaceObject")
{
//沉积相
QMenu menu(this);
menu.addAction(QIcon(::GetImagePath() + "icon/Sheet.png"), "数据对象查看", this, &FormInfo::onShowTable);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除当前对象", this, &FormInfo::onDeleteTable);
menu.exec(event->globalPos());
}
else if(m_strType=="TubingstringObject")
{
//套管组件
QMenu menu(this);
menu.addAction(QIcon(::GetImagePath() + "icon/Sheet.png"), "数据对象查看", this, &FormInfo::onShowTable);
menu.addAction(QIcon(::GetImagePath() + "icon/Delete.png"), "删除当前对象", this, &FormInfo::onDeleteTable);
menu.exec(event->globalPos());
}
}
//曲线数据查看
void FormInfo::onShowCurve()
{
emit CallManage::getInstance()->sig_ShowCurve(m_strSlfName, m_strLineName);
}
//删除曲线
void FormInfo::onDeleteCurv()
{
//删除曲线
emit CallManage::getInstance()->sig_delLine(m_strUuid, m_strWellName, m_strTrackName, m_strLineName);
}
//表格查看
void FormInfo::onShowTable()
{
emit CallManage::getInstance()->sig_ShowTable(m_strSlfName, m_strLineName);
}
//删除表格
void FormInfo::onDeleteTable()
{
//删除表格
emit CallManage::getInstance()->sig_delTableLine(m_strUuid, m_strWellName, m_strTrackName, m_strLineName);
}