From 88eb156b5eb2136bd0140c48a358392c9b42a6e1 Mon Sep 17 00:00:00 2001 From: jiayulong Date: Tue, 26 May 2026 14:29:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E8=A7=86=E8=A7=A3=E9=87=8A=E7=9A=84?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=9D=A1=EF=BC=8C=E8=BF=BD=E5=8A=A0=E2=80=9C?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=9B=BE=E6=96=87=E4=BB=B6=E2=80=9D=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/CallManage.h | 5 ++++ logPlus/customtabwidget.cpp | 29 +++++++++++++++++++++++ logPlus/customtabwidget.h | 1 + logPlus/mainwindow.cpp | 13 ++++++++++ logPlus/mainwindow.h | 2 ++ logPlus/mainwindowcurve.cpp | 47 +++++++++++++++++++++++++++++++++---- logPlus/mainwindowcurve.h | 2 ++ 7 files changed, 94 insertions(+), 5 deletions(-) diff --git a/logPlus/CallManage.h b/logPlus/CallManage.h index 47d7012..1e7c113 100644 --- a/logPlus/CallManage.h +++ b/logPlus/CallManage.h @@ -329,6 +329,11 @@ signals: //改变多臂井径属性 void sig_changeMCalsProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strNewLineName); + //关闭当前tab页,重新打开新模板 + void sig_tabCloseCurrent(QString fileFull, QString fileName); + //加载视图(重新打开) + void sig_ReOpen(QString fileFull, QString fileName); + // //void sig_addImageToPlot(QMyCustomPlot* customPlot, double left_Low, double right_Hight, QString imagePath); diff --git a/logPlus/customtabwidget.cpp b/logPlus/customtabwidget.cpp index 7f6c67b..cd6e177 100644 --- a/logPlus/customtabwidget.cpp +++ b/logPlus/customtabwidget.cpp @@ -16,6 +16,7 @@ #include "customtabbar.h" #include "PropertyWidget.h" #include "mainwindowsplitter.h" +#include "CallManage.h" CustomTabWidget::CustomTabWidget(QWidget *parent) : QWidget(parent) @@ -37,6 +38,9 @@ CustomTabWidget::CustomTabWidget(QWidget *parent) //关闭tab时,信号槽触发的函数 connect(m_pTabBar, SIGNAL(tabCloseRequested(int)),this,SLOT(slot_tabClose(int))); + //关闭当前tab页,重新打开新模板 + connect(CallManage::getInstance(), SIGNAL(sig_tabCloseCurrent(QString, QString)), this, SLOT(slot_tabCloseCurrent(QString, QString))); + } CustomTabWidget::~CustomTabWidget() @@ -230,3 +234,28 @@ void CustomTabWidget::slot_tabClose(int index) //属性清空 PropertyService()->InitCurrentViewInfo(); } + +//关闭 +void CustomTabWidget::slot_tabCloseCurrent(QString fileFull, QString fileName) +{ + QWidget *selectWidget = m_pStackedWidget->currentWidget(); + if (selectWidget == NULL) + return; + + QString objectName = selectWidget->objectName(); + if(objectName == "MainWindowSplitter") + { + int flag = QMessageBox::warning(NULL,"提示",QString("应用模板后当前图文件将废弃,确定应用模板?"),QMessageBox::Yes,QMessageBox::No); + if(flag!=QMessageBox::Yes) return; + } + + //移除 + int index = m_pTabBar->currentIndex(); + removeTab(index); + + //属性清空 + PropertyService()->InitCurrentViewInfo(); + + //重新打开新模板 + emit CallManage::getInstance()->sig_ReOpen(fileFull, fileName); +} diff --git a/logPlus/customtabwidget.h b/logPlus/customtabwidget.h index a52e34b..9be376a 100644 --- a/logPlus/customtabwidget.h +++ b/logPlus/customtabwidget.h @@ -35,6 +35,7 @@ public: public slots: void setCurrentIndex(int); void slot_tabClose(int index); + void slot_tabCloseCurrent(QString fileFull, QString fileName); signals: void tabIsEmpty(); diff --git a/logPlus/mainwindow.cpp b/logPlus/mainwindow.cpp index ddb9689..1f1aa9d 100644 --- a/logPlus/mainwindow.cpp +++ b/logPlus/mainwindow.cpp @@ -117,6 +117,8 @@ MainWindow::MainWindow(QWidget *parent) : //向左侧树图,刷新新加对象 connect(CallGlobalManage::getInstance(), SIGNAL(sig_AppendConsole(Priority, const QString)), this, SLOT(s_AppendConsole(Priority, const QString))); + //加载视图(重新打开) + connect(CallManage::getInstance(), SIGNAL(sig_ReOpen(QString, QString)), this, SLOT(s_ReOpen(QString, QString))); ConvertorManager::GetInstance().LoadAllConvertorPlugin(); QTimer::singleShot(100, this, [=]() { @@ -601,6 +603,17 @@ void MainWindow::s_PluginMsg(QString msg) qDebug() << "s_PluginMsg:" << msg; } +//加载视图(重新打开) +void MainWindow::s_ReOpen(QString fileFull, QString fileName) +{ + MainWindowSplitter* mainSplitter = new MainWindowSplitter(); + mainSplitter->setSplitterWidget(m_projectWidgets); + m_centerWidgets->addTab(mainSplitter, fileName); + + MainWindowCurve *mainWindowCurve = mainSplitter->getMainWindowCurve(); + mainWindowCurve->Open(fileFull); +} + //可视解释 void MainWindow::s_showView() { diff --git a/logPlus/mainwindow.h b/logPlus/mainwindow.h index 5211c08..6e89f2e 100644 --- a/logPlus/mainwindow.h +++ b/logPlus/mainwindow.h @@ -86,6 +86,8 @@ public slots: void s_DrawImg(); void s_DrawLine(); + //加载视图(重新打开) + void s_ReOpen(QString fileFull, QString fileName); //可视解释 void s_showView(); //开发工具 diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index 59c5331..3805746 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -538,6 +538,7 @@ void MainWindowCurve::initMainToolBar() QIcon selectWellIcon(::GetImagePath()+"icon/SelectWells.png"); QIcon fixwellsectionHeaderIcon(::GetImagePath()+"icon/fixwellsectionHeader.png"); + QIcon opentemplateIcon(::GetImagePath()+"icon/currtemplite.png"); QIcon saveastemplateIcon(::GetImagePath()+"icon/SaveAsTemplate.png"); QIcon executeDepthShiftIcon(::GetImagePath()+"icon/ExecuteDepthShift.png"); QIcon joindepthIcon(::GetImagePath()+"icon/joindepth.png"); @@ -554,6 +555,7 @@ void MainWindowCurve::initMainToolBar() //Main工具栏 m_selectWellAc = new QAction(selectWellIcon, "设置井", this); m_fixwellsectionHeaderAc = new QAction(fixwellsectionHeaderIcon, "锁头", this); + m_opentemplateAc = new QAction(opentemplateIcon, "加载图文件", this); m_saveastemplateAc = new QAction(saveastemplateIcon, "另存为图文件", this); m_zoominAc = new QAction(zoominIcon, "放大", this); m_zoomoutAc = new QAction(zoomoutIcon, "缩小", this); @@ -572,6 +574,7 @@ void MainWindowCurve::initMainToolBar() //add QAction to Widget. ui->mainToolBar->addAction(m_selectWellAc); ui->mainToolBar->addAction(m_fixwellsectionHeaderAc); //锁头 + ui->mainToolBar->addAction(m_opentemplateAc); //加载图文件 ui->mainToolBar->addAction(m_saveastemplateAc); //另存为图文件 ui->mainToolBar->addSeparator(); ui->mainToolBar->addAction(m_zoominAc); //放大 @@ -598,6 +601,7 @@ void MainWindowCurve::initMainToolBar() connect(m_selectWellAc, &QAction::triggered, this, &MainWindowCurve::s_selectWell); connect(m_fixwellsectionHeaderAc, &QAction::triggered, this, &MainWindowCurve::s_showHeadTable); + connect(m_opentemplateAc, &QAction::triggered, this, &MainWindowCurve::s_Open); connect(m_saveastemplateAc, &QAction::triggered, this, &MainWindowCurve::s_Save); connect(m_zoominAc, &QAction::triggered, this, &MainWindowCurve::s_ZoomIn); @@ -2818,8 +2822,43 @@ void MainWindowCurve::loadStyle(const QString &qssFile) } } +void MainWindowCurve::s_Open() +{ + //Logdata + QString folderPath; + folderPath = GetLogdataPath(); + folderPath = folderPath + g_prjname; + //folderPath = folderPath + "/multiwell.json"; + + //打开 + QString fileFull = ""; + fileFull = QFileDialog::getOpenFileName(this, + tr("选择模板"), + folderPath, + tr("多井图文件(*.json)")); + if (fileFull.isEmpty()) + { + return; + } + + QFileInfo fileInfo(fileFull); + QString fileName = fileInfo.fileName(); // 获取文件名 + emit CallManage::getInstance()->sig_tabCloseCurrent(fileFull, fileName); + +// //先清空 +// ui->tableWidget_2->clear(); +// m_listWell.clear(); +// m_mapFWell.clear(); + +// QFileInfo fileInfo(fileFull); +// QString fileName = fileInfo.fileName(); // 获取文件名 + +// Open(fileFull); +} + void MainWindowCurve::s_Save() { + //Logdata QString folderPath; folderPath = GetLogdataPath(); @@ -3739,11 +3778,6 @@ void MainWindowCurve::s_SaveAsSvg() _slotExport(aa, 4, pngName, strTmpName); } -//void MainWindowCurve::s_Open(QString fileFull) -//{ - -//} - //选择井 void MainWindowCurve::s_selectWell() { @@ -5788,11 +5822,13 @@ void MainWindowCurve::slotDeleteSelectWell() { ui->tableWidget_2->removeColumn(column); m_listWell.clear(); + m_mapFWell.clear(); } else { QString strWellName = ui->tableWidget_2->item(iCurrentRow, column)->text(); m_listWell.removeOne(strWellName); + m_mapFWell.remove(strWellName); // ui->tableWidget_2->removeColumn(column+1);//空白列,注意先删除空白列,否则列号改变 ui->tableWidget_2->removeColumn(column); @@ -5802,6 +5838,7 @@ void MainWindowCurve::slotDeleteSelectWell() { QString strWellName = ui->tableWidget_2->item(iCurrentRow, column)->text(); m_listWell.removeOne(strWellName); + m_mapFWell.remove(strWellName); // ui->tableWidget_2->removeColumn(column); ui->tableWidget_2->removeColumn(column-1);//空白列,注意先删除选中列,否则列号改变 diff --git a/logPlus/mainwindowcurve.h b/logPlus/mainwindowcurve.h index caececa..1deb46d 100644 --- a/logPlus/mainwindowcurve.h +++ b/logPlus/mainwindowcurve.h @@ -223,6 +223,7 @@ public slots: public: QAction* m_selectWellAc = nullptr; //选择井 QAction* m_fixwellsectionHeaderAc = nullptr; //锁头 + QAction* m_opentemplateAc = nullptr; //加载图文件 QAction* m_saveastemplateAc = nullptr; //另存为图文件 QAction* m_zoominAc = nullptr; //放大 QAction* m_zoomoutAc = nullptr; //缩小 @@ -312,6 +313,7 @@ public slots: // void s_selectWell(); //选择井 void s_showHeadTable(); //显示/隐藏图头 + void s_Open(); //加载图文件 void s_Save(); //保存图文件 void s_SaveAsPicture(); //导出长图 void s_SaveAsPdf(); //导出PDF