From 6d48697012988b6012cad1e031cd23f062bc88fd Mon Sep 17 00:00:00 2001 From: jiayulong Date: Fri, 5 Jun 2026 17:19:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=BF=BD=E5=8A=A0=E6=89=93=E5=8D=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=202.=E8=BF=BD=E5=8A=A0=E9=BC=A0=E6=A0=87=E6=BB=9A?= =?UTF-8?q?=E8=BD=AE=E7=BC=A9=E6=94=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/mainwindowcurve.cpp | 84 +++++++++++++++++++++++++++++++++---- logPlus/mainwindowcurve.h | 3 ++ 2 files changed, 80 insertions(+), 7 deletions(-) diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index 48455bc..ac4bef1 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -442,14 +442,28 @@ QToolBar * MainWindowCurve::getPluginToolBar() //鼠标滚动,通知可视解释窗口 void MainWindowCurve::s_mouseWheel(QWheelEvent *event) { - if (event->angleDelta().y() > 0) { - ui->verticalScrollBar->triggerAction(QAbstractSlider::SliderSingleStepSub); // 向下滚动 - } else { - ui->verticalScrollBar->triggerAction(QAbstractSlider::SliderSingleStepAdd); // 向上滚动 + if (Qt::ControlModifier == QApplication::keyboardModifiers()) + { + if (event->delta() > 0) // 鼠标滚轮向上滚动 + { + ZoomIn(1.1); // 文本放大 + } + else + { + ZoomIn(0.9); // 文本缩小 + } } + else + { + if (event->angleDelta().y() > 0) { + ui->verticalScrollBar->triggerAction(QAbstractSlider::SliderSingleStepSub); // 向下滚动 + } else { + ui->verticalScrollBar->triggerAction(QAbstractSlider::SliderSingleStepAdd); // 向上滚动 + } - //verticalScrollBar() horizontalScrollBar() - //event->accept(); // 确保事件被处理 + //verticalScrollBar() horizontalScrollBar() + //event->accept(); // 确保事件被处理 + } } //自定义滚动条(头) @@ -655,6 +669,7 @@ void MainWindowCurve::initMainToolBar() QIcon SaveAsPictureIcon(::GetImagePath()+"icon/SaveAsPicture.png"); QIcon SaveAsPdfIcon(::GetImagePath()+"icon/ExportPDF.png"); QIcon SaveAsSvgIcon(::GetImagePath()+"icon/ExportSVG.png"); + QIcon PrintIcon(::GetImagePath()+"icon/Print.png"); QIcon doubleHeadIcon(::GetImagePath()+"icon/oneortwohead.png"); QIcon crossIcon(::GetImagePath()+"icon/Cross.png"); QIcon autorollIcon(::GetImagePath()+"icon/autoroll.png"); @@ -676,6 +691,7 @@ void MainWindowCurve::initMainToolBar() m_SaveAsPictureAc = new QAction(SaveAsPictureIcon, "导出长图", this); m_SaveAsPdfAc = new QAction(SaveAsPdfIcon, "导出PDF", this); m_SaveAsSvgAc = new QAction(SaveAsSvgIcon, "导出SVG", this); + m_PrintAc = new QAction(PrintIcon, "打印", this); m_blackAc = new QAction(blackIcon, "黑白图", this); m_doubleHeadAc = new QAction(doubleHeadIcon, "单曲线头", this); m_executeDepthShiftAc = new QAction(executeDepthShiftIcon, "校深", this); @@ -704,6 +720,7 @@ void MainWindowCurve::initMainToolBar() menuPrint->addAction(m_SaveAsPictureAc); //导出长图 menuPrint->addAction(m_SaveAsPdfAc); //导出PDF menuPrint->addAction(m_SaveAsSvgAc); //导出SVG + menuPrint->addAction(m_PrintAc); //打印 printMenuAction->setMenu(menuPrint); @@ -768,7 +785,8 @@ void MainWindowCurve::initMainToolBar() connect(m_zoomoutAc, &QAction::triggered, this, &MainWindowCurve::s_ZoomOut); 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_SaveAsSvgAc, &QAction::triggered, this, &MainWindowCurve::s_SaveAsSvg); + connect(m_PrintAc, &QAction::triggered, this, &MainWindowCurve::s_Print); connect(m_blackAc, &QAction::triggered, this, &MainWindowCurve::s_Black); connect(m_doubleHeadAc, &QAction::triggered, this, &MainWindowCurve::s_DoubleHead); @@ -4059,6 +4077,38 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName, SetScrollBar_Geometry(); } +//打印 +void MainWindowCurve::s_Print() +{ + QPrinter printer(QPrinter::HighResolution); + if (QPrintDialog(&printer).exec() == QDialog::Accepted) + { + QString ip; + QString lpt3; + int port=9100; + char szFile[256]; + strcpy(szFile, "printer.ini"); + QStringList strs=GetSimilarCurves(printer.printerName()+"_IP", szFile); + if(strs.size()>1) { + ip=strs[0]; + port=strs[1].toInt(); + } + else if(strs.size()==1) { + ip=strs[0]; + } + if(ip.isEmpty()) { + strs=GetSimilarCurves(printer.printerName()+"LPT", szFile); + if(strs.size()) lpt3=strs[0]; + } + if(!ip.isEmpty()||!lpt3.isEmpty()) + { + printer.setResolution(QPrinter::ScreenResolution); + _slotExport(printer,1,"",""); + } + else _slotExport(printer,0,"",""); + } +} + //导出长图 void MainWindowCurve::s_SaveAsSvg() { @@ -6722,3 +6772,23 @@ void MainWindowCurve::s_AddMultiWell(QString strUuid, QString strSlfName, QStrin // OpenMultiWell(m_fileJson); } + + +void MainWindowCurve::wheelEvent(QWheelEvent *e) +{ + // 检查按键 Ctrl 是否按下 + if (Qt::ControlModifier == QApplication::keyboardModifiers()) + { + if (e->delta() > 0) // 鼠标滚轮向上滚动 + { + ZoomIn(1.1); // 文本放大 + } + else + { + ZoomIn(0.9); // 文本缩小 + } + } + + // 调用父类事件函数,保证鼠标滚轮查看文本功能正常 + QMainWindow::wheelEvent(e); +} diff --git a/logPlus/mainwindowcurve.h b/logPlus/mainwindowcurve.h index 8cd14c4..7684f46 100644 --- a/logPlus/mainwindowcurve.h +++ b/logPlus/mainwindowcurve.h @@ -41,6 +41,7 @@ private: protected: void resizeEvent(QResizeEvent *event); + void wheelEvent(QWheelEvent *e) override; //滚轮事件 public: void resizeItem(QString strWellName, double tempWidth, double tempHight); @@ -248,6 +249,7 @@ public: QAction* m_SaveAsPictureAc = nullptr; //导出长图 QAction* m_SaveAsPdfAc = nullptr; //导出PDF QAction* m_SaveAsSvgAc = nullptr; //导出SVG + QAction* m_PrintAc = nullptr; //打印 QAction* m_blackAc = nullptr; //黑白图 QAction* m_doubleHeadAc = nullptr; //单曲线头 QAction* m_executeDepthShiftAc = nullptr; //校深 @@ -341,6 +343,7 @@ public slots: void s_SaveAsPicture(); //导出长图 void s_SaveAsPdf(); //导出PDF void s_SaveAsSvg(); //导出SVG + void s_Print(); //打印 void s_ZoomIn(); //放大 void s_ZoomOut(); //缩小 void s_Black(); //黑白图