From cb6a3e1696da7ff2520b38f4924f061811d14d1d Mon Sep 17 00:00:00 2001 From: jiayulong Date: Tue, 9 Jun 2026 17:56:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E2=80=9C=E6=89=93=E5=8D=B0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E2=80=9D=E5=92=8C=E2=80=9C=E6=89=93=E5=8D=B0=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E2=80=9D=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=87=BA=E5=9B=BE=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E8=B0=83=E6=95=B4=E4=B8=BA=E7=99=BD=E8=89=B2=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E6=B5=AA=E8=B4=B9=E5=A2=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/mainwindowcurve.cpp | 70 ++++++++++++++++++++++++++++++++++--- logPlus/mainwindowcurve.h | 9 ++++- logPlus/mainwindowcurve.ui | 6 ++++ 3 files changed, 80 insertions(+), 5 deletions(-) diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index 01eddab..d8fc958 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -26,6 +26,7 @@ #include "DepthProgress.h" #include "wellheader.h" +#include //主窗口,为了方便获取tab当前页 extern MainWindow *g_mainWindow; @@ -93,7 +94,7 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) : ui->toolBar_3->hide(); ui->toolBar_plugin->hide(); //加载样式 - //loadStyle(":/qrc/qss/flatgray.css"); + loadStyle(":/qrc/qss/flatgray.css"); //this->setStyleSheet("QWidget{border: 1px solid black;}"); //ui->centralwidget->setVisible(false); @@ -713,6 +714,8 @@ void MainWindowCurve::initMainToolBar() QIcon SaveAsPdfIcon(::GetImagePath()+"icon/ExportPDF.png"); QIcon SaveAsSvgIcon(::GetImagePath()+"icon/ExportSVG.png"); QIcon PrintIcon(::GetImagePath()+"icon/Print.png"); + QIcon PrintSetupIcon(::GetImagePath()+"icon/PrintPage.png"); + QIcon PrintPreviewIcon(::GetImagePath()+"icon/PrintPrev.png"); QIcon doubleHeadIcon(::GetImagePath()+"icon/oneortwohead.png"); QIcon crossIcon(::GetImagePath()+"icon/Cross.png"); QIcon autorollIcon(::GetImagePath()+"icon/autoroll.png"); @@ -737,6 +740,8 @@ void MainWindowCurve::initMainToolBar() m_SaveAsPdfAc = new QAction(SaveAsPdfIcon, "导出PDF", this); m_SaveAsSvgAc = new QAction(SaveAsSvgIcon, "导出SVG", this); m_PrintAc = new QAction(PrintIcon, "打印", this); + m_PrintSetupAc = new QAction(PrintSetupIcon, "打印设置", this); + m_PrintPreviewAc = new QAction(PrintPreviewIcon, "打印预览", this); m_blackAc = new QAction(blackIcon, "黑白图", this); m_doubleHeadAc = new QAction(doubleHeadIcon, "单曲线头", this); m_executeDepthShiftAc = new QAction(executeDepthShiftIcon, "校深", this); @@ -766,6 +771,8 @@ void MainWindowCurve::initMainToolBar() menuPrint->addAction(m_SaveAsPdfAc); //导出PDF menuPrint->addAction(m_SaveAsSvgAc); //导出SVG menuPrint->addAction(m_PrintAc); //打印 + menuPrint->addAction(m_PrintSetupAc); //打印设置 + menuPrint->addAction(m_PrintPreviewAc); //打印预览 printMenuAction->setMenu(menuPrint); @@ -835,6 +842,8 @@ void MainWindowCurve::initMainToolBar() connect(m_SaveAsPdfAc, &QAction::triggered, this, &MainWindowCurve::s_SaveAsPdf); connect(m_SaveAsSvgAc, &QAction::triggered, this, &MainWindowCurve::s_SaveAsSvg); connect(m_PrintAc, &QAction::triggered, this, &MainWindowCurve::s_Print); + connect(m_PrintSetupAc, &QAction::triggered, this, &MainWindowCurve::s_PrintSetup); + connect(m_PrintPreviewAc, &QAction::triggered, this, &MainWindowCurve::s_PrintPreview); connect(m_blackAc, &QAction::triggered, this, &MainWindowCurve::s_Black); connect(m_doubleHeadAc, &QAction::triggered, this, &MainWindowCurve::s_DoubleHead); @@ -3693,6 +3702,12 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName, tmpPath += "/"; } + int left=9, top=20, right=9, bottom=0; + if (ui->centralwidget->layout()) + { + ui->centralwidget->layout()->getContentsMargins(&left, &top, &right, &bottom); + } + //获取可视视图大小 tableWidget_2 int iHight = 0; int iWidth = 0; @@ -3701,14 +3716,14 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName, { iHight += ui->tableWidget_2->rowHeight(i); } - iHight += 9 + (ui->tableWidget_2->rowCount()+1);//上margin + 边框n+1 + iHight += top + (ui->tableWidget_2->rowCount()+1);//上margin + 边框n+1 //宽度 for(int j=0; jtableWidget_2->columnCount(); j++) { iWidth += ui->tableWidget_2->columnWidth(j); } - iWidth += 9*2 + (ui->tableWidget_2->columnCount()+1) +40;//左右margin + 边框n+1 + iWidth += left + right + (ui->tableWidget_2->columnCount()+1) +40;//左右margin + 边框n+1 // if(iWidth < ui->tableWidget_2->width()) // { // iWidth = ui->tableWidget_2->width(); @@ -3839,7 +3854,7 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName, bDoubleHead = false; } - int iTableWellTrack_height = ui->tableWidget_2->rowHeight(0) + (9+3) + iTableSize_Head -1 +13; + int iTableWellTrack_height = ui->tableWidget_2->rowHeight(0) + (top+3) + iTableSize_Head -1 +2; //图片高度 int iTotalSize_Height = iHight_Head+iHight_Tail; int iNum = dDeep/dScrollHeight; @@ -4150,6 +4165,53 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName, ShowTableHead_One(); //2个滚动条位置 SetScrollBar_Geometry(); + + //锁头 + s_showHeadTable(); //显示/隐藏图头 +} + +//打印设置 +void MainWindowCurve::s_PrintSetup() +{ +// QPrinter printer(QPrinter::HighResolution); +// QPageSetupDialog dialog(&printer); +// if (dialog.exec() == QDialog::Accepted) { +// // 用户点击了确定,printer 对象已更新为新的页面设置 +// // 可以在此处获取设置好的纸张大小、方向等 +// qDebug() << "Paper size:" << printer.paperSize(); +// } + + int left, top, right, bottom; + if (ui->centralwidget->layout()) + { + ui->centralwidget->layout()->getContentsMargins(&left, &top, &right, &bottom); + + ui->centralwidget->layout()->setContentsMargins(left+10, top+10, right+10, bottom+10); + } + + + QMessageBox::information(NULL,"提示","打印设置完成!",QMessageBox::Ok); + //居中 + //emit sig_resizeWindow(); + + //锁头 + s_showHeadTable(); +} + +//打印预览 +void MainWindowCurve::s_PrintPreview() +{ + QPrinter printer(QPrinter::HighResolution); + QPrintPreviewDialog preview(&printer); + QObject::connect(&preview, SIGNAL(paintRequested(QPrinter*)), + this, SLOT(printPreview(QPrinter*))); + preview.exec(); +} + +//打印预览 +void MainWindowCurve::printPreview(QPrinter *printer) +{ + _slotExport(*printer, 0, "", ""); } //打印 diff --git a/logPlus/mainwindowcurve.h b/logPlus/mainwindowcurve.h index aec5dfc..f47beef 100644 --- a/logPlus/mainwindowcurve.h +++ b/logPlus/mainwindowcurve.h @@ -73,6 +73,9 @@ public slots: void slotCreateHead(); void slotCreateTail(); + //打印预览 + void printPreview(QPrinter*printer); + public: MainWindowSplitter* m_pParentWin = NULL; @@ -252,6 +255,8 @@ public: QAction* m_SaveAsPdfAc = nullptr; //导出PDF QAction* m_SaveAsSvgAc = nullptr; //导出SVG QAction* m_PrintAc = nullptr; //打印 + QAction* m_PrintSetupAc = nullptr; //打印设置 + QAction* m_PrintPreviewAc = nullptr; //打印预览 QAction* m_blackAc = nullptr; //黑白图 QAction* m_doubleHeadAc = nullptr; //单曲线头 QAction* m_executeDepthShiftAc = nullptr; //校深 @@ -290,7 +295,7 @@ public slots: void s_pinLvAc(); // 频率统计 void s_NewGanZhuangTu(); // 杆状图 void s_roseAc(); // 玫瑰图 - void s_dcaAc(); // DCA分析 + void s_dcaAc(); // DCA分析 void s_Jykt(); // 井眼垮塌矢量图 void s_Denv(); // 井斜方位图 void s_DrawImage(); // 图像 成图 @@ -346,6 +351,8 @@ public slots: void s_SaveAsPdf(); //导出PDF void s_SaveAsSvg(); //导出SVG void s_Print(); //打印 + void s_PrintSetup(); //打印设置 + void s_PrintPreview(); //打印预览 void s_Zoom(); //缩放 void s_ZoomIn(); //放大 void s_ZoomOut(); //缩小 diff --git a/logPlus/mainwindowcurve.ui b/logPlus/mainwindowcurve.ui index 8c697c3..fc50a74 100644 --- a/logPlus/mainwindowcurve.ui +++ b/logPlus/mainwindowcurve.ui @@ -13,6 +13,12 @@ MainWindow + + QMainWindow +{ + background-color: #FFFFFF; +} +