diff --git a/WellLogUI/include/WellLogDialog.h b/WellLogUI/include/WellLogDialog.h index 7d88b25..b6f3904 100644 --- a/WellLogUI/include/WellLogDialog.h +++ b/WellLogUI/include/WellLogDialog.h @@ -17,7 +17,9 @@ * @class WellLogDialog * @brief 测井系统默认对话框 */ - +// void OSGWELLLOGUI_EXPORT RenameWellName(CObjWell *pDestWell,CObjWell *pSourceWell,bool isMount=true); +int OSGWELLLOGUI_EXPORT SetWellRoundWellName(QString filename,QString strNewName); +// bool OSGWELLLOGUI_EXPORT RenameWellName(CObjWell *pWell,QString strNewName); class OSGWELLLOGUI_EXPORT WellLogDialog : public QDialog { Q_OBJECT diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index 99cf183..a68cdea 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -3213,6 +3213,9 @@ void FormDraw::setRowHeight(double dHight, QProgressBar *progressBar, int iSplit //emit CallManage::getInstance()->sig_ChangeLeftScale(m_strUuid, form->m_strSlfName, m_strWellName, m_strTrackName, form->m_strLineName, form->m_iX1); + //比例改变后,避免井壁取心等组件变形,需要重新刷新 + form->resetPosition(); + form->replot();//屏蔽,缩减时间 } } diff --git a/logPlus/formmultiheads.cpp b/logPlus/formmultiheads.cpp index 7a57a37..dafa4e9 100644 --- a/logPlus/formmultiheads.cpp +++ b/logPlus/formmultiheads.cpp @@ -348,3 +348,22 @@ void FormMultiHeads::DisplayHeads(QJsonArray headsArray, QString strHeadOrTail) } } } + +//获取图头、结论的宽高,方便输出图 +void FormMultiHeads::getTableSize(int &iWidth, int &iHight) +{ + //获取可视视图大小 tableWidget + iHight = 0; + iWidth = 0; + for(int i=0; itableWidget->rowCount(); i++) + { + //高度 + iHight += ui->tableWidget->rowHeight(i); + } + + for(int j=0; jtableWidget->columnCount(); j++) + { + //高度 + iWidth += ui->tableWidget->columnWidth(j); + } +} diff --git a/logPlus/formmultiheads.h b/logPlus/formmultiheads.h index 81f3304..24d6402 100644 --- a/logPlus/formmultiheads.h +++ b/logPlus/formmultiheads.h @@ -39,6 +39,9 @@ public: //Head代表图头, Tail代表成果表 void DisplayHeads(QJsonArray headsArray, QString strHeadOrTail); + //获取图头、结论的宽高,方便输出图 + void getTableSize(int &iWidth, int &iHight); + public: QString m_strHeadOrTail = ""; //Head代表图头, Tail代表成果表 }; diff --git a/logPlus/logPlus.pro b/logPlus/logPlus.pro index 509081f..cd57fde 100644 --- a/logPlus/logPlus.pro +++ b/logPlus/logPlus.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core gui svg +QT += core gui svg printsupport #QT += opengl greaterThan(QT_MAJOR_VERSION, 4): QT += widgets diff --git a/logPlus/main.cpp b/logPlus/main.cpp index 38594fe..bae95d1 100644 --- a/logPlus/main.cpp +++ b/logPlus/main.cpp @@ -5,6 +5,8 @@ double g_logicalDpi; double g_dPixelPerCm;//每厘米像素数 +MainWindow *g_mainWindow = nullptr; + int main(int argc, char *argv[]) { QApplication a(argc, argv); @@ -34,6 +36,7 @@ int main(int argc, char *argv[]) //qRegisterMetaType("QPoint"); MainWindow w; + g_mainWindow = &w; w.show(); return a.exec(); diff --git a/logPlus/mainwindow.cpp b/logPlus/mainwindow.cpp index 3e9cc99..23007fa 100644 --- a/logPlus/mainwindow.cpp +++ b/logPlus/mainwindow.cpp @@ -106,6 +106,21 @@ MainWindow::~MainWindow() delete ui; } +void MainWindow::closeEvent(QCloseEvent *event) +{ + //关闭老项目 + bool bClosed = closeProject(); + if(!bClosed) + { + if(event) + { + event->ignore(); + } + return; + } + QMainWindow::closeEvent( event ); +} + void MainWindow::ReadConfig() { int iIndex; @@ -145,10 +160,7 @@ void MainWindow::ReadConfig() qtCommon->readShowScale(configPath, iShow); g_iShow = iShow; } -CallManage* MainWindow::getInstanceCallManage() -{ - return CallManage::getInstance(); -} + void MainWindow::loadStyle(const QString &qssFile) { //加载样式表 @@ -339,13 +351,69 @@ void MainWindow::dockLayout() m_propertyWidget->InitCurrentViewInfo(); } +//关闭成功返回true +bool MainWindow::closeProject() +{ + //先判断是否需要保存tab页 + bool bNeedSave = false; + if(m_centerWidgets) + { + int iCount = m_centerWidgets->count(); + for(int i=0; itabWidget(i); + QString objectName = selectWidget->objectName(); + if(objectName == "MainWindowSplitter") + { + bNeedSave = true; + break; + } + } + } + if(bNeedSave) + { + int flag = QMessageBox::warning(NULL,"提示",QString("图文件尚未保存,您确信关闭当前窗口?"),QMessageBox::Yes,QMessageBox::No); + if(flag!=QMessageBox::Yes) + { + return false; + } + } + + //关闭老项目 + if(m_centerWidgets) + { + int iCount = m_centerWidgets->count(); + for(int i=0; iremoveTab(0); + } + } + g_prjname=""; + return true; +} + void MainWindow::s_New() { + //关闭老项目 + bool bClosed = closeProject(); + if(!bClosed) + { + return; + } + + //新建 emit CallManage::getInstance()->sig_NewProject(); } void MainWindow::s_Open() { + //关闭老项目 + bool bClosed = closeProject(); + if(!bClosed) + { + return; + } + //打开 QString fileFull = ""; fileFull = QFileDialog::getOpenFileName(this, @@ -544,19 +612,20 @@ void MainWindow::s_DrawLine() qDebug() << "vecSlfList:" << QString::number(i+1) << "=" << vecSlfList[i]; } } - } void MainWindow::s_CloseProject() { -// if(m_centerWidgets) -// { -// int iCount = m_centerWidgets->count(); -// for(int i=0; iremoveTab(0); -// } -// } + if(m_centerWidgets) + { + int iCount = m_centerWidgets->count(); + for(int i=0; iremoveTab(0); + } + } + //关闭老项目 + g_prjname=""; } //参数卡数据查看 diff --git a/logPlus/mainwindow.h b/logPlus/mainwindow.h index 9e630f1..be08393 100644 --- a/logPlus/mainwindow.h +++ b/logPlus/mainwindow.h @@ -60,6 +60,8 @@ public: ConsoleOutputWidget *m_consoleOutputWidget;//日志 public: + virtual void closeEvent(QCloseEvent *event); + //样式 void loadStyle(const QString &qssFile); @@ -71,8 +73,7 @@ public: void dockLayout(); //停靠 void ReadConfig(); - - CallManage *getInstanceCallManage(); + bool closeProject(); public slots: void s_New(); diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index 78e30dc..fa0e346 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -15,6 +15,11 @@ #include "DepPairs.h" #include "mainwindowsplitter.h" #include "selectwelldialog.h" +#include "mainwindow.h" +#include + +//主窗口,为了方便获取tab当前页 +extern MainWindow *g_mainWindow; extern int g_iOneWidth; //道宽 extern QString g_prjname; @@ -163,6 +168,7 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) : MainWindowCurve::~MainWindowCurve() { + delete ui; } @@ -198,6 +204,8 @@ void MainWindowCurve::initMainToolBar() QIcon joindepthIcon(::GetImagePath()+"icon/joindepth.png"); QIcon ModuleOpenIcon(::GetImagePath()+"icon/ModuleOne.png"); QIcon SaveAsPictureIcon(::GetImagePath()+"icon/SaveAsPicture.png"); + QIcon SaveAsPdfIcon(::GetImagePath()+"icon/ExportPDF.png"); + QIcon SaveAsSvgIcon(::GetImagePath()+"icon/ExportSVG.png"); QIcon runIcon(":/image/capacity.png"); QIcon debugIcon(":/image/anaysis.png"); QIcon loadIcon(":/image/export.png"); @@ -211,6 +219,8 @@ void MainWindowCurve::initMainToolBar() QAction* m_joindepthAc = nullptr; //拼接 QAction* m_ModuleOpenAc = nullptr; //处理方法 QAction* m_SaveAsPictureAc = nullptr; //导出长图 + QAction* m_SaveAsPdfAc = nullptr; //导出PDF + QAction* m_SaveAsSvgAc = nullptr; //导出SVG // QAction* m_runAc = nullptr;// // QAction* m_debugAc = nullptr; // // QAction* m_loadAc = nullptr; //加载 @@ -223,6 +233,8 @@ void MainWindowCurve::initMainToolBar() m_joindepthAc = new QAction(joindepthIcon, "拼接", this); m_ModuleOpenAc = new QAction(ModuleOpenIcon, "处理方法", this); m_SaveAsPictureAc = new QAction(SaveAsPictureIcon, "导出长图", this); + m_SaveAsPdfAc = new QAction(SaveAsPdfIcon, "导出PDF", this); + m_SaveAsSvgAc = new QAction(SaveAsSvgIcon, "导出SVG", this); // m_debugAc = new QAction(debugIcon, "撤销", this); // m_loadAc = new QAction(loadIcon, "重做", this); //m_openAc = new QAction(openFileIcon, "打开", this); @@ -236,9 +248,10 @@ void MainWindowCurve::initMainToolBar() ui->mainToolBar->addAction(m_saveastemplateAc); ui->mainToolBar->addAction(m_executeDepthShiftAc); ui->mainToolBar->addAction(m_joindepthAc); - ui->mainToolBar->addAction(m_ModuleOpenAc); - - //ui->mainToolBar->addAction(m_SaveAsPictureAc);//导出长图 + ui->mainToolBar->addAction(m_ModuleOpenAc); + ui->mainToolBar->addAction(m_SaveAsPictureAc);//导出长图 + ui->mainToolBar->addAction(m_SaveAsPdfAc);//导出PDF + ui->mainToolBar->addAction(m_SaveAsSvgAc);//导出SVG // ui->mainToolBar->addAction(m_debugAc); // ui->mainToolBar->addAction(m_loadAc); @@ -253,6 +266,8 @@ void MainWindowCurve::initMainToolBar() connect(m_ModuleOpenAc, &QAction::triggered, this, &MainWindowCurve::s_ModuleOpen); connect(m_SaveAsPictureAc, &QAction::triggered, this, &MainWindowCurve::s_SaveAsPicture); + connect(m_SaveAsPdfAc, &QAction::triggered, this, &MainWindowCurve::s_SaveAsPdf); + connect(m_SaveAsSvgAc, &QAction::triggered, this, &MainWindowCurve::s_SaveAsSvg); // connect(m_grepAc, &QAction::triggered, this, &MainWindow::s_Risize); // connect(m_compileAc, &QAction::triggered, this, &MainWindow::s_AddOne); @@ -2324,9 +2339,389 @@ void MainWindowCurve::s_ModuleOpen() //导出长图 void MainWindowCurve::s_SaveAsPicture() { + QString strTmpName = ""; + int curIndex = g_mainWindow->m_centerWidgets->currentIndex(); + strTmpName = g_mainWindow->m_centerWidgets->tabText(curIndex); + //去掉后缀.json + int ind=strTmpName.lastIndexOf("."); + if(ind>=0) strTmpName=strTmpName.left(ind); + + // + QString pdfName = GetLogdataPath(); + pdfName = pdfName + g_prjname; + if(strTmpName != "") + { + pdfName=pdfName + "/" + strTmpName +".tif"; + } + + // + QString dir=pdfName; + QString pngName =QFileDialog::getSaveFileName( NULL,"输出为图片",dir, + "图像文件(*.tif);;图像文件(*.png);;图像文件(*.jpg);;图像文件(*.bmp);;图像文件(*.xpm)"); + if(pngName=="") { + return; + } + + + //获取可视视图大小 tableWidget_2 + int iHight = 0; + int iWidth = 0; + for(int i=0; itableWidget_2->rowCount(); i++) + { + //高度 + iHight += ui->tableWidget_2->rowHeight(i); + } + //ui->tableWidget_2->setRowHeight(1, iHight+200); + //iHight += 3000; + + for(int j=0; jtableWidget_2->columnCount(); j++) + { + //宽度 + iWidth += ui->tableWidget_2->columnWidth(j); + } + + // + bool bVisible = m_dock1->isVisible(); + //第一次显示,判断是否从json加载 + if(m_bHeadLoadJson) + { + m_bHeadLoadJson = false; + + QString strHeadOrTail = ""; //Head代表图头, Tail代表成果表 + //展示所有图头 + strHeadOrTail = "Head"; //Head代表图头, Tail代表成果表 + m_formMultiHeads->DisplayHeads(m_headsArray, strHeadOrTail); + //展示所有成果表 + strHeadOrTail = "Tail"; //Head代表图头, Tail代表成果表 + m_formMultiTails->DisplayHeads(m_tailsArray, strHeadOrTail); + } + m_dock1->show(); + m_dock2->show(); + + //----------------------------- + //头 + int iWidth_Head, iHight_Head; + m_formMultiHeads->getTableSize(iWidth_Head, iHight_Head); + QRect geoRect_FormHead = m_dock1->geometry(); + m_dock1->setGeometry(geoRect_FormHead.x(), geoRect_FormHead.y(), iWidth_Head, iHight_Head); + + //中间 + // 获取客户区几何信息(不含边框) + QRect geoRect = ui->centralwidget->geometry(); + qDebug() << "Geometry:" << geoRect.x() << "," << geoRect.y() + << "w:" << geoRect.width() << "h:" << geoRect.height(); //指标体系图 - QPixmap pPixmap = ui->tableWidget_2->grab(QRect(0, 0, ui->tableWidget_2->width()*2, ui->tableWidget_2->height()*2)); - pPixmap.save("d:\\3.png", "png"); + ui->centralwidget->setGeometry(geoRect.x(), geoRect.y(), iWidth, iHight); + + //尾 + int iWidth_Tail, iHight_Tail; + m_formMultiTails->getTableSize(iWidth_Tail, iHight_Tail); + QRect geoRect_Tail = m_dock2->geometry(); + m_dock2->setGeometry(geoRect_Tail.x(), iHight+iHight_Head+40, iWidth_Tail, iHight_Tail); + //----------------------------- + + //QPixmap pPixmap = ui->centralwidget->grab(QRect(0, 0, ui->centralwidget->width(), ui->centralwidget->height())); + int iMaxWidth = iWidth; + if(iWidth_Head>iWidth_Tail) + { + if(iWidth_Head>iWidth) + { + iMaxWidth = iWidth_Head; + } + } + else + { + if(iWidth_Tail>iWidth) + { + iMaxWidth = iWidth_Tail; + } + } + QPixmap pPixmap = this->grab(QRect(geoRect_FormHead.x(), geoRect_FormHead.y(), iMaxWidth, iHight+iHight_Head+iHight_Tail+40)); + pPixmap.save(pngName); + + //恢复窗口 + m_dock1->setGeometry(geoRect_FormHead.x(), geoRect_FormHead.y(), geoRect_FormHead.width(), geoRect_FormHead.height()); + ui->centralwidget->setGeometry(geoRect.x(), geoRect.y(), geoRect.width(), geoRect.height()); + m_dock2->setGeometry(geoRect_Tail.x(), geoRect_Tail.y(), geoRect_Tail.width(), geoRect_Tail.height()); + if(!bVisible) + { + m_dock1->hide(); + m_dock2->hide(); + } +} + +//导出PDF +void MainWindowCurve::s_SaveAsPdf() +{ + QString strTmpName = ""; + + int curIndex = g_mainWindow->m_centerWidgets->currentIndex(); + strTmpName = g_mainWindow->m_centerWidgets->tabText(curIndex); + //去掉后缀.json + int ind=strTmpName.lastIndexOf("."); + if(ind>=0) strTmpName=strTmpName.left(ind); + + // + QString pdfName = GetLogdataPath(); + pdfName = pdfName + g_prjname; + if(strTmpName != "") + { + pdfName=pdfName + "/" + strTmpName +".pdf"; + } + + // + QString pngName =QFileDialog::getSaveFileName( NULL,"输出为PDF文件",pdfName,"PDF文件(*.pdf)"); + if(pngName=="") { + return; + } + + //获取可视视图大小 tableWidget_2 + int iHight = 0; + int iWidth = 0; + for(int i=0; itableWidget_2->rowCount(); i++) + { + //高度 + iHight += ui->tableWidget_2->rowHeight(i); + } + //ui->tableWidget_2->setRowHeight(1, iHight+200); + //iHight += 3000; + + for(int j=0; jtableWidget_2->columnCount(); j++) + { + //宽度 + iWidth += ui->tableWidget_2->columnWidth(j); + } + + // + bool bVisible = m_dock1->isVisible(); + //第一次显示,判断是否从json加载 + if(m_bHeadLoadJson) + { + m_bHeadLoadJson = false; + + QString strHeadOrTail = ""; //Head代表图头, Tail代表成果表 + //展示所有图头 + strHeadOrTail = "Head"; //Head代表图头, Tail代表成果表 + m_formMultiHeads->DisplayHeads(m_headsArray, strHeadOrTail); + //展示所有成果表 + strHeadOrTail = "Tail"; //Head代表图头, Tail代表成果表 + m_formMultiTails->DisplayHeads(m_tailsArray, strHeadOrTail); + } + m_dock1->show(); + m_dock2->show(); + + //----------------------------- + //头 + int iWidth_Head, iHight_Head; + m_formMultiHeads->getTableSize(iWidth_Head, iHight_Head); + QRect geoRect_FormHead = m_dock1->geometry(); + m_dock1->setGeometry(geoRect_FormHead.x(), geoRect_FormHead.y(), iWidth_Head, iHight_Head); + + //中间 + // 获取客户区几何信息(不含边框) + QRect geoRect = ui->centralwidget->geometry(); + qDebug() << "Geometry:" << geoRect.x() << "," << geoRect.y() + << "w:" << geoRect.width() << "h:" << geoRect.height(); + //指标体系图 + ui->centralwidget->setGeometry(geoRect.x(), geoRect.y(), iWidth, iHight); + + //尾 + int iWidth_Tail, iHight_Tail; + m_formMultiTails->getTableSize(iWidth_Tail, iHight_Tail); + QRect geoRect_Tail = m_dock2->geometry(); + m_dock2->setGeometry(geoRect_Tail.x(), iHight+iHight_Head+40, iWidth_Tail, iHight_Tail); + //----------------------------- + + //QPixmap pPixmap = ui->centralwidget->grab(QRect(0, 0, ui->centralwidget->width(), ui->centralwidget->height())); + int iMaxWidth = iWidth; + if(iWidth_Head>iWidth_Tail) + { + if(iWidth_Head>iWidth) + { + iMaxWidth = iWidth_Head; + } + } + else + { + if(iWidth_Tail>iWidth) + { + iMaxWidth = iWidth_Tail; + } + } + QPixmap pPixmap = this->grab(QRect(geoRect_FormHead.x(), geoRect_FormHead.y(), iMaxWidth, iHight+iHight_Head+iHight_Tail+40)); + //pPixmap.save(pngName); + + //恢复窗口 + m_dock1->setGeometry(geoRect_FormHead.x(), geoRect_FormHead.y(), geoRect_FormHead.width(), geoRect_FormHead.height()); + ui->centralwidget->setGeometry(geoRect.x(), geoRect.y(), geoRect.width(), geoRect.height()); + m_dock2->setGeometry(geoRect_Tail.x(), geoRect_Tail.y(), geoRect_Tail.width(), geoRect_Tail.height()); + if(!bVisible) + { + m_dock1->hide(); + m_dock2->hide(); + } + + // + QPrinter printer;//(QPrinter::ScreenResolution); + printer.setOrientation(QPrinter::Portrait); + printer.setResolution(200); + printer.setPaperSize(QPrinter::Custom);//自定义大小 + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setPageMargins(0.0, 0.0, 0.0, 0.0, QPrinter::Point); + printer.setOutputFileName(pngName); + + printer.setPageMargins(0.0,0.0,0.0,0.0,QPrinter::DevicePixel); + printer.setFullPage(true); + + printer.setOrientation(QPrinter::Portrait); + printer.setPaperSize(QPrinter::Custom); + printer.setPaperSize(QSizeF(iMaxWidth, iHight+iHight_Head+iHight_Tail+40),QPrinter::DevicePixel); + + // + float sx=1; + float sy=1; + QPainter painter; + painter.begin(&printer); + painter.setRenderHint(QPainter::Antialiasing); + painter.scale(sx,sy); + painter.drawPixmap(0, 0, pPixmap); + painter.end(); +} + +//导出长图 +void MainWindowCurve::s_SaveAsSvg() +{ + QString strTmpName = ""; + int curIndex = g_mainWindow->m_centerWidgets->currentIndex(); + strTmpName = g_mainWindow->m_centerWidgets->tabText(curIndex); + //去掉后缀.json + int ind=strTmpName.lastIndexOf("."); + if(ind>=0) strTmpName=strTmpName.left(ind); + + // + QString pdfName = GetLogdataPath(); + pdfName = pdfName + g_prjname; + if(strTmpName != "") + { + pdfName=pdfName + "/" + strTmpName +".svg"; + } + + // + QString dir=pdfName; + QString pngName =QFileDialog::getSaveFileName( NULL,"输出为SVG图",pdfName,"svg图文件(*.svg)"); + if(pngName=="") { + return; + } + //获取可视视图大小 tableWidget_2 + int iHight = 0; + int iWidth = 0; + for(int i=0; itableWidget_2->rowCount(); i++) + { + //高度 + iHight += ui->tableWidget_2->rowHeight(i); + } + //ui->tableWidget_2->setRowHeight(1, iHight+200); + //iHight += 3000; + + for(int j=0; jtableWidget_2->columnCount(); j++) + { + //宽度 + iWidth += ui->tableWidget_2->columnWidth(j); + } + + // + bool bVisible = m_dock1->isVisible(); + //第一次显示,判断是否从json加载 + if(m_bHeadLoadJson) + { + m_bHeadLoadJson = false; + + QString strHeadOrTail = ""; //Head代表图头, Tail代表成果表 + //展示所有图头 + strHeadOrTail = "Head"; //Head代表图头, Tail代表成果表 + m_formMultiHeads->DisplayHeads(m_headsArray, strHeadOrTail); + //展示所有成果表 + strHeadOrTail = "Tail"; //Head代表图头, Tail代表成果表 + m_formMultiTails->DisplayHeads(m_tailsArray, strHeadOrTail); + } + m_dock1->show(); + m_dock2->show(); + + //----------------------------- + //头 + int iWidth_Head, iHight_Head; + m_formMultiHeads->getTableSize(iWidth_Head, iHight_Head); + QRect geoRect_FormHead = m_dock1->geometry(); + m_dock1->setGeometry(geoRect_FormHead.x(), geoRect_FormHead.y(), iWidth_Head, iHight_Head); + + //中间 + // 获取客户区几何信息(不含边框) + QRect geoRect = ui->centralwidget->geometry(); + qDebug() << "Geometry:" << geoRect.x() << "," << geoRect.y() + << "w:" << geoRect.width() << "h:" << geoRect.height(); + //指标体系图 + ui->centralwidget->setGeometry(geoRect.x(), geoRect.y(), iWidth, iHight); + + //尾 + int iWidth_Tail, iHight_Tail; + m_formMultiTails->getTableSize(iWidth_Tail, iHight_Tail); + QRect geoRect_Tail = m_dock2->geometry(); + m_dock2->setGeometry(geoRect_Tail.x(), iHight+iHight_Head+40, iWidth_Tail, iHight_Tail); + //----------------------------- + + //QPixmap pPixmap = ui->centralwidget->grab(QRect(0, 0, ui->centralwidget->width(), ui->centralwidget->height())); + int iMaxWidth = iWidth; + if(iWidth_Head>iWidth_Tail) + { + if(iWidth_Head>iWidth) + { + iMaxWidth = iWidth_Head; + } + } + else + { + if(iWidth_Tail>iWidth) + { + iMaxWidth = iWidth_Tail; + } + } + QPixmap pPixmap = this->grab(QRect(geoRect_FormHead.x(), geoRect_FormHead.y(), iMaxWidth, iHight+iHight_Head+iHight_Tail+40)); + //pPixmap.save(pngName); + + //恢复窗口 + m_dock1->setGeometry(geoRect_FormHead.x(), geoRect_FormHead.y(), geoRect_FormHead.width(), geoRect_FormHead.height()); + ui->centralwidget->setGeometry(geoRect.x(), geoRect.y(), geoRect.width(), geoRect.height()); + m_dock2->setGeometry(geoRect_Tail.x(), geoRect_Tail.y(), geoRect_Tail.width(), geoRect_Tail.height()); + if(!bVisible) + { + m_dock1->hide(); + m_dock2->hide(); + } + + // +// QString strTmpPng = pngName; +// int indTmp=strTmpPng.lastIndexOf("."); +// if(indTmp>=0) strTmpPng=strTmpPng.left(indTmp) + "_tmp.PNG"; +// pPixmap.save(strTmpPng); +// QImage image; +// image.load(strTmpPng); + + QSvgGenerator generator; + generator.setFileName(pngName); // 设置输出SVG文件的路径和名称 + generator.setSize(QSize(iMaxWidth, iHight+iHight_Head+iHight_Tail+40)); // 设置SVG的尺寸,这里使用QPixmap的尺寸 + generator.setViewBox(QRect(0, 0, iMaxWidth, iHight+iHight_Head+iHight_Tail+40)); // 设置视图框,可选,根据需要设置 + + // + float sx=1; + float sy=1; + QPainter painter; + painter.begin(&generator); + painter.setRenderHint(QPainter::Antialiasing); + painter.scale(sx,sy); + painter.drawPixmap(0, 0, pPixmap); // 绘制QPixmap到SVG中 + //painter.drawImage(0, 0, image); + painter.end(); // 结束绘制过程 + } //void MainWindowCurve::s_Open(QString fileFull) diff --git a/logPlus/mainwindowcurve.h b/logPlus/mainwindowcurve.h index f2d361d..abdd06d 100644 --- a/logPlus/mainwindowcurve.h +++ b/logPlus/mainwindowcurve.h @@ -244,6 +244,8 @@ public slots: void s_ExecuteMerge(); //拼接 void s_ModuleOpen(); //处理算法 void s_SaveAsPicture(); //导出长图 + void s_SaveAsPdf(); //导出PDF + void s_SaveAsSvg(); //导出SVG }; diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 9e63c40..1313e21 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -9973,7 +9973,17 @@ void QMyCustomPlot::resetPosition_SwallCore() it++; // QCPRange tmpRange = pDraggableRect->getRange(); - pDraggableRect->setRange(tmpRange.lower, tmpRange.upper, false); + + //-------------------------- + // 设置初始范围 + double h = 32; + double Depth = tmpRange.lower; + double x1 = this->xAxis->coordToPixel(Depth); + double Depth2 = this->xAxis->pixelToCoord(x1-h); + //-------------------------- + + // + pDraggableRect->setRange(Depth, Depth2, false); } } diff --git a/logPlus/qtprojectwidgets.cpp b/logPlus/qtprojectwidgets.cpp index 3a954c4..1343166 100644 --- a/logPlus/qtprojectwidgets.cpp +++ b/logPlus/qtprojectwidgets.cpp @@ -170,7 +170,6 @@ void QtProjectWidgets::s_loadTreeWidget(QString fileFull) ui->treeWidget->setHeaderHidden(true); // 隐藏表头 ui->treeWidget->clear();//清理数据 - // QFileInfo fileinfo; fileinfo = QFileInfo(fileFull); // @@ -637,6 +636,15 @@ void QtProjectWidgets::loadWellTree(QTreeWidgetItem *parent, QString fileFull, Q } } +void QtProjectWidgets::expandAll(QTreeWidgetItem* item) { + if (item) { + item->setExpanded(true); // 展开当前项 + for (int i = 0; i < item->childCount(); ++i) { + expandAll(item->child(i)); // 递归展开所有子项 + } + } +} + //初始化树形控件中的右键菜单 void QtProjectWidgets::initMenu() { @@ -644,6 +652,10 @@ void QtProjectWidgets::initMenu() m_action_Paste ->setIcon(QIcon(GetImagePath() + "icon/Copy.png")); // 设置图标":/image/u174.png" connect(m_action_Paste, SIGNAL(triggered()), this, SLOT(onPasteSelObject())); + m_action_WellPaste = new QAction("粘贴井次", ui->treeWidget); + m_action_WellPaste ->setIcon(QIcon(GetImagePath() + "icon/Copy.png")); // 设置图标 + connect(m_action_WellPaste, SIGNAL(triggered()), this, SLOT(onPasteWell())); + //根节点(项目名称)-右键菜单 _menuRoot = new QMenu(ui->treeWidget); initRootTreeMenu(_menuRoot, ui->treeWidget); @@ -841,6 +853,8 @@ void QtProjectWidgets::initWellNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget action_New->setIcon(QIcon(GetImagePath() + "icon/outcurves.png")); // 设置图标 connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onOutWellLogRound())); menu->addAction(action_New); + + menu->addAction(m_action_WellPaste); } //初始化根节点(井次名称)-右键菜单 @@ -856,10 +870,21 @@ void QtProjectWidgets::initSlfNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget) connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onImportSlfTable())); menu->addAction(action_New); + action_New = new QAction("备份", treeWidget); + action_New->setIcon(QIcon(GetImagePath() + "icon/Copy.png")); // 设置图标 + connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onSlfbackup())); + menu->addAction(action_New); + + QAction* action_Cut = new QAction("剪切井次", treeWidget); + action_Cut->setIcon(QIcon(GetImagePath() + "icon/Cut.png")); // 设置图标 + connect(action_Cut, SIGNAL(triggered()), this, SLOT(onCutSlf())); + menu->addAction(action_Cut); + action_New = new QAction("编辑测井信息", treeWidget); action_New->setIcon(QIcon(GetImagePath() + "icon/Edit.png")); // 设置图标 connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onWelllogInformation())); menu->addAction(action_New); + menu->addAction(m_action_Paste); // @@ -908,8 +933,9 @@ void QtProjectWidgets::onOpenProject(bool checked) void QtProjectWidgets::s_NewProject() { + // ui->treeWidget->clear();//清理数据 - emit CallManage::getInstance()->sig_CloseProject();//关闭tab页 + //emit CallManage::getInstance()->sig_CloseProject();//关闭tab页 // 创建对话框 CWellLogProjectDialog* dialog = new CWellLogProjectDialog(); @@ -937,7 +963,7 @@ void QtProjectWidgets::s_NewProject() void QtProjectWidgets::s_OpenProject(QString fileFull) { ui->treeWidget->clear();//清理数据 - emit CallManage::getInstance()->sig_CloseProject();//关闭tab页 + //emit CallManage::getInstance()->sig_CloseProject();//关闭tab页 s_loadTreeWidget(fileFull); } @@ -1047,6 +1073,77 @@ void QtProjectWidgets::onShowWave(bool checked) emit CallManage::getInstance()->sig_ShowWave(m_strSlfName, m_strCurveObjectName); } +//备份井次 +void QtProjectWidgets::onSlfbackup() +{ + if(!m_strSlfName.isEmpty()) + { + QString path,strWellName,Slfname; + foreach(QTreeWidgetItem *pItem, ui->treeWidget->selectedItems()) + { + QTreeWidgetItem *parentItem = pItem; + if (parentItem && m_strSlfName == parentItem->data(0, Qt::UserRole+1).toString()) + { + strWellName = parentItem->parent()->text(0); + } + } + GetWellNameAndPath(m_strSlfName,Slfname,path); + QString newfile=path+"/"+Slfname+"_backup.slf"; + if(QFile::copy(m_strSlfName,newfile)) { + QString strProjectFolder = GetProjectFolder(); + QString strProjectFile = strProjectFolder + g_prjname; + strProjectFile += ".wwl"; + s_OpenProject(strProjectFile); + + int topCount = ui->treeWidget->topLevelItemCount(); // 获取顶级节点数量 + if(topCount<1) + { + return; + } + + QTreeWidgetItem *item = ui->treeWidget->topLevelItem(0); + int childCount = item->childCount(); // 获取子节点数量 + for (int i = 0; i < childCount; ++i) + { + //井组,数据分析... + QTreeWidgetItem *wellGroupItem = item->child(i); + QString wellGroupname = wellGroupItem->text(0); + if (wellGroupname == "井组") + { + int wellCount = wellGroupItem->childCount(); // 获取井节点数量 + for (int j = 0; j < wellCount; ++j) + { + //井组,数据分析... + QTreeWidgetItem *wellItem = wellGroupItem->child(j); + QString wellname = wellItem->text(0); + if(wellname==strWellName)//井 + { + wellItem->setExpanded(true); + } + } + } + } + return ; + } + else QMessageBox::information(NULL,"提示","备份失败!"); + } +} + +//剪切井次 +void QtProjectWidgets::onCutSlf() +{ + m_mapCopyObject.clear(); + m_strCutSlfName = m_strSlfName; + foreach(QTreeWidgetItem *pItem, ui->treeWidget->selectedItems()) + { + QTreeWidgetItem *parentItem = pItem; + if (parentItem && m_strSlfName == parentItem->data(0, Qt::UserRole+1).toString()) + { + m_strCutWellname = parentItem->parent()->text(0); + } + } +} + //编辑测井信息 void QtProjectWidgets::onWelllogInformation() { @@ -1185,16 +1282,51 @@ void QtProjectWidgets::onDeleteObject() logio->DeleteObject(m_strCurveObjectName.toLocal8Bit().data()); logio->Close(); - foreach(QTreeWidgetItem *pItem, ui->treeWidget->selectedItems()) + QString strProjectFolder = GetProjectFolder(); + QString strProjectFile = strProjectFolder + g_prjname; + strProjectFile += ".wwl"; + s_OpenProject(strProjectFile); + + int topCount = ui->treeWidget->topLevelItemCount(); // 获取顶级节点数量 + if(topCount<1) { - QTreeWidgetItem *parentItem = pItem->parent()->parent(); // 上两层目录是井次 - RefreshWellRoundTree(parentItem); - break; + return; + } + + QTreeWidgetItem *item = ui->treeWidget->topLevelItem(0); + int childCount = item->childCount(); // 获取子节点数量 + for (int i = 0; i < childCount; ++i) + { + //井组,数据分析... + QTreeWidgetItem *wellGroupItem = item->child(i); + QString wellGroupname = wellGroupItem->text(0); + if (wellGroupname == "井组") + { + int wellCount = wellGroupItem->childCount(); // 获取井节点数量 + for (int j = 0; j < wellCount; ++j) + { + //井组,数据分析... + QTreeWidgetItem *wellItem = wellGroupItem->child(j); + QString wellname = wellItem->text(0); + + int slfCount = wellItem->childCount(); // 获取井节点数量 + // wellItem->sortChildren(0, Qt::SortOrder::AscendingOrder); + for (int k = 0; k < slfCount; ++k) + { + if (m_strSlfName == wellItem->child(k)->data(0, Qt::UserRole+1).toString()) + { + wellItem->setExpanded(true); + expandAll(wellItem->child(k)); + } + } + } + } } } void QtProjectWidgets::onCopySelObject() // 复制 { + m_strCutWellname = ""; m_mapCopyObject.clear(); foreach(QTreeWidgetItem *pItem, ui->treeWidget->selectedItems()) { @@ -1215,7 +1347,6 @@ void QtProjectWidgets::onCopySelObject() // 复制 } } } - } void QtProjectWidgets::onPasteSelObject() // 粘贴 @@ -1361,6 +1492,81 @@ void QtProjectWidgets::onPasteSelObject() // 粘贴 } } +// 粘贴井次 +void QtProjectWidgets::onPasteWell() +{ + QString strNewName=m_strWellname; + QString name="您确信移动到"+strNewName+"井下吗?\n如果移动,该井数据将被移入(当前井下数据也被备份于Logdata/Temp下)。"; + int flag = QMessageBox::warning(NULL,"提示",name,QMessageBox::Yes,QMessageBox::No); + if(flag==QMessageBox::Yes) + { + QString wellfile=m_strCutSlfName; + QString newfilename; + int index=wellfile.lastIndexOf("#"); + int index1=wellfile.lastIndexOf("\\"); + int index2=wellfile.lastIndexOf("/"); + if(index2>index1) index1=index2; + QString olddir=wellfile.left(index1); + QString newdir=wellfile.mid(index,index1-index); + newfilename=wellfile; + newfilename.replace(newdir,"#"+strNewName); + + QFileInfo check_file(newfilename); + if (check_file.exists() && check_file.isFile()) { + QString strMessage="已存在井次文件"+newfilename+"确定要覆盖么?"; + int flag1 =QMessageBox::warning(NULL,"提示",strMessage,QMessageBox::Yes,QMessageBox::No); + if(flag!=QMessageBox::Yes) + return; + + QFile::remove(newfilename); + } + + QDir ss; + if(ss.rename(wellfile,newfilename)) + { + SetWellRoundWellName(newfilename,strNewName); + } + } + + QString strProjectFolder = GetProjectFolder(); + QString strProjectFile = strProjectFolder + g_prjname; + strProjectFile += ".wwl"; + s_OpenProject(strProjectFile); + + int topCount = ui->treeWidget->topLevelItemCount(); // 获取顶级节点数量 + if(topCount<1) + { + return; + } + + QTreeWidgetItem *item = ui->treeWidget->topLevelItem(0); + int childCount = item->childCount(); // 获取子节点数量 + for (int i = 0; i < childCount; ++i) + { + //井组,数据分析... + QTreeWidgetItem *wellGroupItem = item->child(i); + QString wellGroupname = wellGroupItem->text(0); + if (wellGroupname == "井组") + { + int wellCount = wellGroupItem->childCount(); // 获取井节点数量 + for (int j = 0; j < wellCount; ++j) + { + //井组,数据分析... + QTreeWidgetItem *wellItem = wellGroupItem->child(j); + QString wellname = wellItem->text(0); + if(wellname==m_strWellname || wellname==m_strCutWellname)//井 + { + wellItem->setExpanded(true); + } + } + } + } + + m_strCutWellname = ""; + m_strCutSlfName = ""; + return; +} + //刷新井次树 void QtProjectWidgets::RefreshWellRoundTree(QTreeWidgetItem *parentItem) { @@ -1378,13 +1584,17 @@ void QtProjectWidgets::RefreshWellRoundTree(QTreeWidgetItem *parentItem) for (int i = 0; i < WellCount; ++i) { QTreeWidgetItem *childItem = pWellItem->child(i); - childItem->setExpanded(true); - int childCount = childItem->childCount(); - for (int j = 0; j < childCount; ++j) + if (childItem && m_strSlfName == childItem->data(0, Qt::UserRole+1).toString()) { - childItem->child(j)->setExpanded(true); + childItem->setExpanded(true); + int childCount = childItem->childCount(); + for (int j = 0; j < childCount; ++j) + { + childItem->child(j)->setExpanded(true); + } } } + pWellItem->sortChildren(0, Qt::SortOrder::AscendingOrder); } } @@ -1618,6 +1828,7 @@ void QtProjectWidgets::onItemClicked(QTreeWidgetItem* item, int index) } else if (strTreeTag == "wellname") { + m_strWellname = item->text(0); //根节点(项目名称)-右键菜单 popMenu = _menuWellName; } @@ -1657,6 +1868,11 @@ void QtProjectWidgets::onItemClicked(QTreeWidgetItem* item, int index) else m_action_Paste->setVisible(true); + if (m_strWellname==m_strCutWellname || m_strCutWellname.isEmpty()) + m_action_WellPaste->setVisible(false); + else + m_action_WellPaste->setVisible(true); + if (qApp->mouseButtons() == Qt::RightButton) // 只针对鼠标右键,弹出菜单 { if (NULL == popMenu) diff --git a/logPlus/qtprojectwidgets.h b/logPlus/qtprojectwidgets.h index cf69b35..62d7d26 100644 --- a/logPlus/qtprojectwidgets.h +++ b/logPlus/qtprojectwidgets.h @@ -51,6 +51,8 @@ public slots: //波列 void onShowWave(bool checked = false); //波列查看 + void onSlfbackup(); //备份井次 + void onCutSlf(); //剪切井次 void onEditWelllogRound(); void onImportSingleWellLogData(); void onImportSlfTable(); @@ -65,6 +67,7 @@ public slots: void onDeleteObject(); // 删除 void onCopySelObject(); // 复制 void onPasteSelObject(); // 粘贴 + void onPasteWell(); // 粘贴井次 void RefreshWellRoundTree(QTreeWidgetItem *parentItem); // 刷新井次树 //向左侧树图,追加固井结论表格 void s_AddGujingToTree(QString strSlfName, QString strWellName, QString strLineName); @@ -89,6 +92,7 @@ public: QMenu *_menuWaveFolder; //波列目录 QAction* m_action_Paste; //粘贴 + QAction* m_action_WellPaste; //井次粘贴 //根节点(项目名称)-右键菜单 QAction* m_action_New; QAction* m_action_Open; @@ -99,9 +103,12 @@ public: QAction* m_action_ShowCurve; QAction* m_action_DepthShift; + QString m_strWellname; QString m_strSlfName; QString m_strCurveObjectName; + QString m_strCutWellname; + QString m_strCutSlfName; QMap> m_mapShowObject;// 显示Slf文件里对象名 QMap> m_mapCopyObject;// 复制Slf文件里对象名 int m_ReFlag; @@ -110,6 +117,8 @@ public: void loadIndexSysTree(QTreeWidgetItem *parent, QString fileFull, QString prjname); void loadWellTree(QTreeWidgetItem *parent, QString fileFull, QString parentWellname); + void expandAll(QTreeWidgetItem* item); + //初始化树形控件中的右键菜单 void initMenu();