diff --git a/CallManage/CallManage.h b/CallManage/CallManage.h index f01656d..36c09fc 100644 --- a/CallManage/CallManage.h +++ b/CallManage/CallManage.h @@ -61,7 +61,7 @@ signals: //岩性填充-填充 void sig_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill, - float vMin, float vMax); + float vMin, float vMax, QColor frontColor, QColor backColor); //置顶层 void sig_Raise(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index ff44500..ebe9672 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -225,6 +225,24 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant ChangFillProperty(); } } + else if("岩性前景色" == m_propertyData[pProperty]) + { + qDebug() << "岩性前景色->改变"; + //当前属性类型 + if(m_strCurrentProperty == Curve_Property) + { + ChangFillProperty(); + } + } + else if("岩性背景色" == m_propertyData[pProperty]) + { + qDebug() << "岩性背景色->改变"; + //当前属性类型 + if(m_strCurrentProperty == Curve_Property) + { + ChangFillProperty(); + } + } else if("头部图例" == m_propertyData[pProperty]) { qDebug() << "头部图例->改变"; @@ -246,6 +264,8 @@ void PropertyWidget::ChangFillProperty() QString newHeadFill = "不绘制"; float vMax = 0.0; float vMin = 0.0; + QColor frontColor;//岩性前景色 + QColor backColor;//岩性背景色 for (auto it = m_propertyData.constBegin(); it != m_propertyData.constEnd(); ++it) { @@ -311,6 +331,24 @@ void PropertyWidget::ChangFillProperty() } qDebug() << "填充岩性->" << newLithosImage; } + else if(it.value()=="岩性前景色") + { + QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); + if(pProperty->hasValue()) + { + frontColor = pProperty->value().value(); + } + qDebug() << "岩性前景色->"; + } + else if(it.value()=="岩性背景色") + { + QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); + if(pProperty->hasValue()) + { + backColor = pProperty->value().value(); + } + qDebug() << "岩性背景色->"; + } else if(it.value()=="头部图例") { QtVariantProperty *pProperty = (QtVariantProperty*)it.key(); @@ -331,7 +369,7 @@ void PropertyWidget::ChangFillProperty() { emit CallManage::getInstance()->sig_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, newFillType, newTargetLine, newColor, newLithosImage, newHeadFill, - vMin, vMax); + vMin, vMax, frontColor, backColor); } } @@ -442,6 +480,8 @@ void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOt double dWidth = formInfo->m_dWidth; float vmax = formInfo->m_vmax; float vmin = formInfo->m_vmin; + QColor frontColor = formInfo->m_frontColor; + QColor backColor = formInfo->m_backColor; // m_strSlfName = strSlfName; @@ -507,4 +547,6 @@ void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOt _CreateVariantPropertyItem("岩性填充", "填充颜色", lineColor, QVariant::Color); _CreateVariantPropertyItem("岩性填充", "填充岩性", "./image/胜利符号库/岩性符号/砂岩.png", VariantManager::filePathTypeId()); + _CreateVariantPropertyItem("岩性填充", "岩性前景色", frontColor, QVariant::Color); + _CreateVariantPropertyItem("岩性填充", "岩性背景色", backColor, QVariant::Color); } diff --git a/logPlus/customtabwidget.cpp b/logPlus/customtabwidget.cpp index 42b11a4..51dbc91 100644 --- a/logPlus/customtabwidget.cpp +++ b/logPlus/customtabwidget.cpp @@ -43,9 +43,11 @@ CustomTabWidget::~CustomTabWidget() void CustomTabWidget::addTab(QWidget *widget, const QString &strTab) { - m_pTabBar->addTab(strTab); + int iIndex = m_pTabBar->addTab(strTab); m_pStackedWidget->addWidget(widget); widget->setAcceptDrops(true); + // + m_pTabBar->setCurrentIndex(iIndex); } void CustomTabWidget::addTab(QWidget *page, const QIcon &icon, const QString &label) diff --git a/logPlus/fileopenthread.cpp b/logPlus/fileopenthread.cpp new file mode 100644 index 0000000..d2b9b5b --- /dev/null +++ b/logPlus/fileopenthread.cpp @@ -0,0 +1,414 @@ +#include "fileopenthread.h" +#include +#include + +//#include "CallManage.h" +#include +#include + +extern QString g_prjname; + + +void FileOpenThread::Open(QString fileFull) +{ + QString strPrjname = ""; + QJsonArray wellsArray; + + QJsonParseError jsonError; + // 文件 + QFile file(fileFull); + if(file.open(QIODevice::ReadOnly)) + { + // 解析JSON + QJsonDocument document = QJsonDocument::fromJson(file.readAll(), &jsonError); + if (!document.isNull() && (jsonError.error == QJsonParseError::NoError)) + { + if (document.isObject()) + { + QJsonObject object = document.object(); + // + if (object.contains("prjname")) + { + QJsonValue value = object.value("prjname"); + if (value.isString()) { + strPrjname = value.toString(); + qDebug() << "prjname:" << strPrjname; + + if(strPrjname != g_prjname) + { + file.close(); + qDebug() << "JSON 模板文件项目名称与当前项目不一致!"; + return; + } + } + } + + // + if (object.contains("wells")) + { + QJsonValue value = object.value("wells"); + if (value.isArray()) { + wellsArray = value.toArray(); + qDebug() << "wellsArray number:" << QString::number(wellsArray.size()); + //展示所有井 + DisplayWells(wellsArray); + } + } + } + } + + // + file.close(); + qDebug() << "JSON 模板文件读取成功!"; + } else { + qWarning() << "JSON 模板文件打开失败:" << file.errorString(); + } +} + +void FileOpenThread::DisplayWells(QJsonArray wellsArray) +{ + QMap mapWells; + + int id = 0; + int iCount = wellsArray.size(); + for(int i=0; is_NewWell(strWellName); + emit sig_NewWell(strWellName); + } + } + + // + if (wellObjInfo.contains("formTracks")) + { + QJsonValue value = wellObjInfo.value("formTracks"); + if (value.isArray()) { + tracksArray = value.toArray(); + qDebug() << "tracksArray number:" << QString::number(tracksArray.size()); + //展示所有道 + DisplayTracks(tracksArray); + } + } +} + +//展示所有道 +void FileOpenThread::DisplayTracks(QJsonArray tracksArray) +{ + QMap mapTracks; + + int id = 0; + int iCount = tracksArray.size(); + for(int i=0; igetInstanceCallManage()->sig_NewTrack_No_Line(strWellName, strTrackName);//新建空白道,没有曲线 + emit sig_NewTrack_No_Line(strWellName, strTrackName);//新建空白道,没有曲线 + if(id>0) + { + //改变井宽 + emit sig_NewTrackChangeWidth(strWellName); + //mainWindowCurve->s_NewTrackChangeWidth(strWellName); + } + + // + if (trackObjInfo.contains("formInfos")) + { + QJsonValue value = trackObjInfo.value("formInfos"); + if (value.isArray()) { + linesArray = value.toArray(); + qDebug() << "linesArray number:" << QString::number(linesArray.size()); + //展示所有曲线 + DisplayLines(linesArray); + } + } +} + +//展示所有曲线 +void FileOpenThread::DisplayLines(QJsonArray linesArray) +{ + QMap mapLines; + + int id = 0; + int iCount = linesArray.size(); + for(int i=0; isig_AddLine(strSlfName, strWellName, strTrackName, strLineName); +// emit mainWindow->getInstanceCallManage()->sig_AddLine_Property(strSlfName, strWellName, strTrackName, strLineName, +// newLeftScale, newRightScale, lineColor, width, lineStyle); + + emit sig_AddLine_Property(strSlfName, strWellName, strTrackName, strLineName, + newLeftScale, newRightScale, lineColor, width, lineStyle); + } +} diff --git a/logPlus/fileopenthread.h b/logPlus/fileopenthread.h new file mode 100644 index 0000000..ff18831 --- /dev/null +++ b/logPlus/fileopenthread.h @@ -0,0 +1,45 @@ +#ifndef FILEOPENTHREAD_H +#define FILEOPENTHREAD_H + +#include +#include + +class FileOpenThread : public QThread { + Q_OBJECT +public: + explicit FileOpenThread(const QString &targetFileName) + : targetFileName(targetFileName) {} + +signals: + void sig_NewTrackChangeWidth(QString strWellName);//新建道后,改变井宽 + void sig_NewWell(QString strWellName); + void sig_NewTrack_No_Line(QString strWellName, QString strTrackName);//新建空白道,没有曲线 + void sig_AddLine_Property(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, + double newLeftScale, double newRightScale, QColor lineColor, double width, Qt::PenStyle lineStyle);//新建曲线,带属性 + +protected: + void run() override { + Open(targetFileName); + } + +private: + QString targetFileName; + +public: + //展示所有井 + void DisplayWells(QJsonArray wellsArray); + //展示其中一口井 + void DisplayWell_One(QJsonObject wellObjInfo); + //展示所有道 + void DisplayTracks(QJsonArray tracksArray); + //展示其中一道 + void DisplayTrack_One(QJsonObject trackObjInfo, int id); + //展示所有曲线 + void DisplayLines(QJsonArray linesArray); + //展示其中一条曲线 + void DisplayLine_One(QJsonObject lineObjInfo); + + void Open(QString fileFull);//打开 +}; + +#endif // FILEOPENTHREAD_H diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index 6427e6b..85fbf0d 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -49,8 +49,8 @@ FormInfo::FormInfo(QWidget *parent, QString strSlfName, QString strWellName, QSt //岩性填充-不填充 connect(CallManage::getInstance(), SIGNAL(sig_ClearFillMode(QString, QString, QString, QString)), this, SLOT(s_ClearFillMode(QString, QString, QString, QString))); //岩性填充-填充 - connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float)), - this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float))); + connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor)), + this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor))); } @@ -105,7 +105,25 @@ void FormInfo::paintEvent(QPaintEvent* event) { if(m_newFillType == "岩性模式") { - painter.setBrush(QBrush(QPixmap(m_newLithosImage))); + 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 == "颜色模式") @@ -255,6 +273,27 @@ 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; +} + //属性-左刻度 void FormInfo::s_ChangeLeftScale(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, double newLeftScale) { @@ -336,7 +375,7 @@ void FormInfo::s_ClearFillMode(QString strSlfName, QString strWellName, QString //岩性填充-填充 void FormInfo::s_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill, - float vMin, float vMax) + float vMin, float vMax, QColor frontColor, QColor backColor) { if(m_strSlfName == strSlfName && m_strWellName == strWellName && @@ -349,6 +388,9 @@ void FormInfo::s_ChangeFillMode(QString strSlfName, QString strWellName, QString m_newColor = newColor; m_newLithosImage = newLithosImage; + m_frontColor = frontColor; + m_backColor = backColor; + update(); } diff --git a/logPlus/forminfo.h b/logPlus/forminfo.h index 2bad045..1eb5409 100644 --- a/logPlus/forminfo.h +++ b/logPlus/forminfo.h @@ -49,7 +49,7 @@ public slots: //岩性填充-填充 void s_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill, - float vMin, float vMax); + float vMin, float vMax, QColor frontColor, QColor backColor); public: QString m_strUuid; @@ -71,6 +71,8 @@ public: QString m_newFillType; QColor m_newColor;//填充颜色 QString m_newLithosImage = "";//岩性图片 + QColor m_frontColor;//岩性前景色 + QColor m_backColor;//岩性背景色 public: void setLineWidth(double dWidth); @@ -85,6 +87,12 @@ public: void setVMin(float vmin); float getVMin(); + void setFrontColor(QColor frontColor); + QColor getFrontColor(); + + void setBackColor(QColor backColor); + QColor getBackColor(); + QJsonObject makeJson(); //public: diff --git a/logPlus/formtrack.cpp b/logPlus/formtrack.cpp index 84cd8ab..84c2342 100644 --- a/logPlus/formtrack.cpp +++ b/logPlus/formtrack.cpp @@ -58,6 +58,8 @@ void FormTrack::s_addLine(QString strSlfName, QString strWellName, QString strTr formInfo->setLineWidth(dWidth); formInfo->setVMax(vmax); formInfo->setVMin(vmin); + formInfo->setFrontColor(QColor(0,0,0)); + formInfo->setBackColor(QColor(255,255,255)); //设置高度 ui->tableWidget->setRowHeight(row, 100); // diff --git a/logPlus/logPlus.pro b/logPlus/logPlus.pro index c58b995..38e44ba 100644 --- a/logPlus/logPlus.pro +++ b/logPlus/logPlus.pro @@ -37,6 +37,7 @@ SOURCES += \ customtabbar.cpp \ customtabwidget.cpp \ fileedit.cpp \ + fileopenthread.cpp \ formdraw.cpp \ formhead.cpp \ forminfo.cpp \ @@ -73,6 +74,7 @@ HEADERS += \ customtabbar.h \ customtabwidget.h \ fileedit.h \ + fileopenthread.h \ formdraw.h \ formhead.h \ forminfo.h \ @@ -169,5 +171,6 @@ CONFIG(debug, debug|release){ LIBS += -L../Bin -lOSGDataModel LIBS += -L../Bin -lDataOutput LIBS += -L../Bin/ -lCallPlugin -lHPluginManage + LIBS += -L../Bin/ -lDataMgr #-lCallManage } diff --git a/logPlus/mainwindow.cpp b/logPlus/mainwindow.cpp index 4df08eb..8af2f96 100644 --- a/logPlus/mainwindow.cpp +++ b/logPlus/mainwindow.cpp @@ -17,6 +17,9 @@ #include "PluginName.h" #include "CallManage.h" #include "CallPlugin.h" +#include +#include +#include "fileopenthread.h" //以下参数从配置文件读取 int g_iIndex = 0; @@ -56,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent) : //loadStyle(":/qrc/qss/blacksoft.css"); loadStyle(":/qrc/qss/flatgray.css"); + ReadConfig(); + initTitleBar(); //菜单栏 initToolBar(); //工具栏 initProjectView(); //左侧-项目区 初始化在前 @@ -114,7 +119,10 @@ void MainWindow::ReadConfig() // qtCommon->readXyRange(configPath, g_iX1, g_iX2, g_iY1, g_iY2); } - +CallManage* MainWindow::getInstanceCallManage() +{ + return CallManage::getInstance(); +} void MainWindow::loadStyle(const QString &qssFile) { //加载样式表 @@ -356,10 +364,29 @@ void MainWindow::s_showView() return; } + QFileInfo fileInfo(fileFull); + QString fileName = fileInfo.fileName(); // 获取文件名 + //---- MainWindowCurve *mainWindowCurve = new MainWindowCurve();//中间工作区 - m_centerWidgets->addTab(mainWindowCurve, "解释视图"); - mainWindowCurve->s_Open(fileFull); + m_centerWidgets->addTab(mainWindowCurve, fileName); + + //mainWindowCurve->s_Open(fileFull); + + //QFuture future = QtConcurrent::run(std::bind(&MainWindowCurve::s_Open, mainWindowCurve, fileFull)); + //mainWindowCurve->Open(fileFull); + + // 创建 FileSearchThread 实例 + FileOpenThread *searchThread = new FileOpenThread(fileFull); + connect(searchThread, &FileOpenThread::sig_NewWell, mainWindowCurve, &MainWindowCurve::s_NewWell, Qt::BlockingQueuedConnection); + connect(searchThread, &FileOpenThread::sig_NewTrackChangeWidth, mainWindowCurve, &MainWindowCurve::s_NewTrackChangeWidth, Qt::BlockingQueuedConnection); + connect(searchThread, &FileOpenThread::sig_NewTrack_No_Line, mainWindowCurve, &MainWindowCurve::s_NewTrack_No_Line, Qt::BlockingQueuedConnection); + connect(searchThread, &FileOpenThread::sig_AddLine_Property, mainWindowCurve, &MainWindowCurve::s_AddLine_Property, Qt::BlockingQueuedConnection); + + //connect(searchThread, SIGNAL(sig_NewTrackChangeWidth(QString)), mainWindowCurve, SLOT(s_NewTrackChangeWidth(QString)), Qt::BlockingQueuedConnection); + //connect(searchThread, SIGNAL(sig_NewWell(QString)), mainWindowCurve, SLOT(s_NewWell(QString)), Qt::BlockingQueuedConnection); + // 启动搜索线程 + searchThread->start(); } void MainWindow::s_Risize() diff --git a/logPlus/mainwindow.h b/logPlus/mainwindow.h index 79d0dc9..a0bcf3e 100644 --- a/logPlus/mainwindow.h +++ b/logPlus/mainwindow.h @@ -15,6 +15,7 @@ #include "customtabwidget.h" #include "ConsoleOutputWidget.h" #include "PropertyWidget.h" +#include "CallManage.h" #pragma execution_character_set("utf-8") @@ -70,6 +71,8 @@ public: void ReadConfig(); + CallManage *getInstanceCallManage(); + public slots: void s_New(); void s_Open(); diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index d485665..51cc67c 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -5,6 +5,8 @@ #include "CallManage.h" #include #include "qtcommonclass.h" +#include +#include extern int g_iOneWidth; //道宽 extern QString g_prjname; @@ -70,6 +72,7 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) : connect(this, SIGNAL(sig_NewTrackChangeWidth(QString)), this, SLOT(s_NewTrackChangeWidth(QString))); + connect(this, SIGNAL(sig_NewWell(QString)), this, SLOT(s_NewWell(QString))); } @@ -240,407 +243,9 @@ void MainWindowCurve::s_Save() void MainWindowCurve::s_Open(QString fileFull) { - QString strPrjname = ""; - QJsonArray wellsArray; - QJsonParseError jsonError; - // 文件 - QFile file(fileFull); - if(file.open(QIODevice::ReadOnly)) - { - // 解析JSON - QJsonDocument document = QJsonDocument::fromJson(file.readAll(), &jsonError); - if (!document.isNull() && (jsonError.error == QJsonParseError::NoError)) - { - if (document.isObject()) - { - QJsonObject object = document.object(); - // - if (object.contains("prjname")) - { - QJsonValue value = object.value("prjname"); - if (value.isString()) { - strPrjname = value.toString(); - qDebug() << "prjname:" << strPrjname; - - if(strPrjname != g_prjname) - { - file.close(); - qDebug() << "JSON 模板文件项目名称与当前项目不一致!"; - return; - } - } - } - - // - if (object.contains("wells")) - { - QJsonValue value = object.value("wells"); - if (value.isArray()) { - wellsArray = value.toArray(); - qDebug() << "wellsArray number:" << QString::number(wellsArray.size()); - //展示所有井 - DisplayWells(wellsArray); - } - } - } - } - - // - file.close(); - qDebug() << "JSON 模板文件读取成功!"; - } else { - qWarning() << "JSON 模板文件打开失败:" << file.errorString(); - } } -void MainWindowCurve::DisplayWells(QJsonArray wellsArray) -{ - //清空 - m_listWell.clear(); - ui->tableWidget_2->clear(); - QMap mapWells; - - int id = 0; - int iCount = wellsArray.size(); - for(int i=0; i mapTracks; - - int id = 0; - int iCount = tracksArray.size(); - for(int i=0; isig_NewTrack_No_Line(strWellName, strTrackName);//新建空白道,没有曲线 - if(id>0) - { - //改变井宽 - emit sig_NewTrackChangeWidth(strWellName); - } - - // - if (trackObjInfo.contains("formInfos")) - { - QJsonValue value = trackObjInfo.value("formInfos"); - if (value.isArray()) { - linesArray = value.toArray(); - qDebug() << "linesArray number:" << QString::number(linesArray.size()); - //展示所有曲线 - DisplayLines(linesArray); - } - } -} - -//展示所有曲线 -void MainWindowCurve::DisplayLines(QJsonArray linesArray) -{ - QMap mapLines; - - int id = 0; - int iCount = linesArray.size(); - for(int i=0; isig_AddLine(strSlfName, strWellName, strTrackName, strLineName); - emit CallManage::getInstance()->sig_AddLine_Property(strSlfName, strWellName, strTrackName, strLineName, - newLeftScale, newRightScale, lineColor, width, lineStyle); - } -} - - QJsonObject MainWindowCurve::makeJson() { // 创建根对象 @@ -740,6 +345,9 @@ void MainWindowCurve::s_NewWell(QString strWellName) FormWell *widgetWell = new FormWell(this, strWellName); widgetWell->m_strUuid = m_strUuid; ui->tableWidget_2->setCellWidget(i, columnCount, widgetWell); + + // + m_listWell.push_back(strWellName); } } //ui->tableWidget_2->resizeColumnsToContents(); // 调整列宽以适应内容 @@ -807,6 +415,20 @@ void MainWindowCurve::s_NewTrackChangeWidth(QString strWellName) } } +//新建空白道,没有曲线 +void MainWindowCurve::s_NewTrack_No_Line(QString strWellName, QString strTrackName) +{ + emit CallManage::getInstance()->sig_NewTrack_No_Line(strWellName, strTrackName); +} + +//新建曲线,带属性 +void MainWindowCurve::s_AddLine_Property(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, + double newLeftScale, double newRightScale, QColor lineColor, double width, Qt::PenStyle lineStyle) +{ + emit CallManage::getInstance()->sig_AddLine_Property(strSlfName, strWellName, strTrackName, strLineName, + newLeftScale, newRightScale, lineColor, width, lineStyle); +} + //新建井+道+曲线(首条) void MainWindowCurve::NewWellAndTrack(QString strWellName, QString strSlfName, QString strLineName) { diff --git a/logPlus/mainwindowcurve.h b/logPlus/mainwindowcurve.h index 8af67d2..701fa5a 100644 --- a/logPlus/mainwindowcurve.h +++ b/logPlus/mainwindowcurve.h @@ -46,25 +46,18 @@ public: void NewWellAndTrack(QString strWellName, QString strSlfName, QString strLineName); QJsonObject makeJson(); - //展示所有井 - void DisplayWells(QJsonArray wellsArray); - //展示其中一口井 - void DisplayWell_One(QJsonObject wellObjInfo); - //展示所有道 - void DisplayTracks(QJsonArray tracksArray); - //展示其中一道 - void DisplayTrack_One(QJsonObject trackObjInfo, int id); - //展示所有曲线 - void DisplayLines(QJsonArray linesArray); - //展示其中一条曲线 - void DisplayLine_One(QJsonObject lineObjInfo); signals: void sig_NewTrackChangeWidth(QString strWellName);//新建道后,改变井宽 + void sig_NewWell(QString strWellName); public slots: void s_NewWell(QString strWellName);//新建井 void s_NewTrackChangeWidth(QString strWellName);//新建道后,改变井宽 + void s_NewTrack_No_Line(QString strWellName, QString strTrackName);//新建空白道,没有曲线 + void s_AddLine_Property(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, + double newLeftScale, double newRightScale, QColor lineColor, double width, Qt::PenStyle lineStyle);//新建曲线,带属性 + void s_NewTrack();//新建道 // void s_Save();//保存 diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 2b33772..23c64d9 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -41,8 +41,8 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel //岩性填充-不填充 connect(CallManage::getInstance(), SIGNAL(sig_ClearFillMode(QString, QString, QString, QString)), this, SLOT(s_ClearFillMode(QString, QString, QString, QString))); //岩性填充-填充 - connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float)), - this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float))); + connect(CallManage::getInstance(), SIGNAL(sig_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor)), + this, SLOT(s_ChangeFillMode(QString, QString, QString, QString, QString, QString, QColor, QString, QString, float, float, QColor, QColor))); } @@ -192,7 +192,7 @@ void QMyCustomPlot::s_ChangeLeftScale(QString strSlfName, QString strWellName, Q //其他曲线 s_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, m_newFillType, m_newTargetLine, m_newColor, m_newLithosImage, m_newHeadFill, - newLeftScale, m_vMax); + newLeftScale, m_vMax, m_frontColor, m_backColor); } } @@ -217,7 +217,7 @@ void QMyCustomPlot::s_ChangeRightScale(QString strSlfName, QString strWellName, //其他曲线 s_ChangeFillMode(m_strSlfName, m_strWellName, m_strTrackName, m_strLineName, m_newFillType, m_newTargetLine, m_newColor, m_newLithosImage, m_newHeadFill, - m_vMin, newRightScale); + m_vMin, newRightScale, m_frontColor, m_backColor); } } @@ -291,7 +291,7 @@ void QMyCustomPlot::s_ClearFillMode(QString strSlfName, QString strWellName, QSt //岩性填充-填充 void QMyCustomPlot::s_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill, - float vMin, float vMax) + float vMin, float vMax, QColor frontColor, QColor backColor) { if(m_strSlfName == strSlfName && @@ -307,6 +307,8 @@ void QMyCustomPlot::s_ChangeFillMode(QString strSlfName, QString strWellName, QS m_newHeadFill = newHeadFill; m_vMin = vMin; m_vMax = vMax; + m_frontColor = frontColor; + m_backColor = backColor; //填充 if(this->graphCount() > 1) @@ -374,46 +376,178 @@ void QMyCustomPlot::s_ChangeFillMode(QString strSlfName, QString strWellName, QS } else { - //其他曲线 + //其他曲线(左填充) CLogIO *logio=new CLogIO(); logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead); - int index=logio->OpenCurve(newTargetLine.toStdString().c_str()); - if(index<0) - { - this->addGraph(); + //读取基线信息 + int indexBaseCurv = logio->OpenCurve(strLineName.toStdString().c_str()); + if(indexBaseCurv < 0) { + this->addGraph();//空曲线 delete logio; } else { - Slf_CURVE curveinfo; - float *val; - float sdep,edep,rlev; - // - logio->GetCurveInfo(index,&curveinfo); - sdep=curveinfo.StartDepth; - edep=curveinfo.EndDepth; - rlev=curveinfo.DepLevel; - // - int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5; - val=new float[count]; - logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]); - logio->CloseCurve(index); - delete logio; - - float newVal = 0.0; - for(int i=0; iOpenCurve(newTargetLine.toStdString().c_str()); + if(index<0) { - x.append(-(sdep+ rlev*i)); - //newVal = (m_iX2-m_iX1)*(val[i]-vMin)/(vMax-vMin) + m_iX1; - newVal = val[i]; - y.append(newVal); + this->addGraph();//空曲线 + delete logio; + } + else + { + Slf_CURVE curveinfo; + float *val; + float sdep,edep,rlev; + // + logio->GetCurveInfo(index,&curveinfo); + sdep=curveinfo.StartDepth; + edep=curveinfo.EndDepth; + rlev=curveinfo.DepLevel; + // + int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5; + val=new float[count]; + logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]); + logio->CloseCurve(index); + //读完基线再关闭 +// delete logio; + + float newVal = 0.0; + for(int i=0; iReadCurve(indexBaseCurv, 0-x0, 1, &BaseY0); + // + if(i+1ReadCurve(indexBaseCurv, 0-x1, 1, &BaseY1); + + if(BaseY0<=y0 && BaseY1<=y1) + { + //基线在左,采用基线值 + //y0=BaseY0; + y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin; + // + x.append(x0); + y.append(y0_old); + } + else if(BaseY0>=y0 && BaseY1>=y1) + { + //基线在右,直接赋值 + x.append(x0); + y.append(y0_old); + } + else if(BaseY0<=y0 && BaseY1>=y1) + { + //基线起点在左,采用基线值 + //y0=BaseY0; + y0_old = (BaseY0-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin; + // + x.append(x0); + y.append(y0_old); + + //插值 + float xNew=x0-rlev*(y0-BaseY0)/(BaseY1-y1); + float yNew=(y0-y1)/(x0-x1)*(xNew-x1) + y1; + float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin; + // + x.append(xNew); + y.append(yNew_Old); + } + else if(BaseY0>=y0 && BaseY1<=y1) + { + //基线在右,直接赋值 + x.append(x0); + y.append(y0_old); + + //插值 + float xNew=x0-rlev*(y0-BaseY0)/(BaseY1-y1); + float yNew=(BaseY0-BaseY1)/(x0-x1)*(xNew-x1) + BaseY1; + float yNew_Old=(yNew-m_iX1)/(m_iX2-m_iX1)*(vMax-vMin) + vMin; + // + x.append(xNew); + y.append(yNew_Old); + } + } + else + { + //最后一个点 + if(BaseY0CloseCurve(indexBaseCurv); + delete logio; + // + this->yAxis2->setRange(m_iY1, m_iY2); + this->xAxis2->setRange(vMin, vMax); + this->addGraph(yAxis2, xAxis2); } - this->yAxis2->setRange(m_iY1, m_iY2); - this->xAxis2->setRange(vMin, vMax); - this->addGraph(yAxis2, xAxis2); } } +// else +// { +// //其他曲线 +// CLogIO *logio=new CLogIO(); +// logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead); +// int index=logio->OpenCurve(newTargetLine.toStdString().c_str()); +// if(index<0) +// { +// this->addGraph(); + +// delete logio; +// } +// else +// { +// Slf_CURVE curveinfo; +// float *val; +// float sdep,edep,rlev; +// // +// logio->GetCurveInfo(index,&curveinfo); +// sdep=curveinfo.StartDepth; +// edep=curveinfo.EndDepth; +// rlev=curveinfo.DepLevel; +// // +// int count=(curveinfo.EndDepth-curveinfo.StartDepth)/curveinfo.DepLevel+1.5; +// val=new float[count]; +// logio->ReadCurve(index,curveinfo.StartDepth,count,&val[0]); +// logio->CloseCurve(index); +// delete logio; + +// float newVal = 0.0; +// for(int i=0; iyAxis2->setRange(m_iY1, m_iY2); +// this->xAxis2->setRange(vMin, vMax); +// this->addGraph(yAxis2, xAxis2); +// } +// } this->graph(1)->setData(x, y); graph(1)->setLineStyle(graph(0)->lineStyle());//曲线 @@ -423,8 +557,25 @@ void QMyCustomPlot::s_ChangeFillMode(QString strSlfName, QString strWellName, QS // if(newFillType == "岩性模式") { - graph(0)->setBrush(QBrush(QPixmap(newLithosImage))); - //graph(0)->setBrush(QBrush(QPixmap(":/image/file.png"))); + QColor oldFrontColor(0, 0, 0); // 原始颜色 + QColor oldBackColor(255, 255, 255); // 原始颜色 + // + QImage image(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 来设置新颜色 + } + } + } + + // + graph(0)->setBrush(QBrush(QPixmap::fromImage(image))); + //graph(0)->setBrush(QBrush(QPixmap(newLithosImage))); } else if(newFillType == "颜色模式") { diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 7b75aff..bf999c2 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -38,6 +38,8 @@ public: QString m_newHeadFill; float m_vMin; float m_vMax; + QColor m_frontColor;//岩性前景色 + QColor m_backColor;//岩性背景色 QContextMenuEvent *m_event; @@ -70,7 +72,7 @@ public slots: //岩性填充-填充 void s_ChangeFillMode(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString newFillType, QString newTargetLine, QColor newColor, QString newLithosImage, QString newHeadFill, - float vMin, float vMax); + float vMin, float vMax, QColor frontColor, QColor backColor); void onAddRect();