打印功能,追加“打印设置”和“打印预览”功能,出图背景调整为白色,避免浪费墨。
This commit is contained in:
parent
06c77bf2e1
commit
cb6a3e1696
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "DepthProgress.h"
|
#include "DepthProgress.h"
|
||||||
#include "wellheader.h"
|
#include "wellheader.h"
|
||||||
|
#include <QPageSetupDialog>
|
||||||
|
|
||||||
//主窗口,为了方便获取tab当前页
|
//主窗口,为了方便获取tab当前页
|
||||||
extern MainWindow *g_mainWindow;
|
extern MainWindow *g_mainWindow;
|
||||||
|
|
@ -93,7 +94,7 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||||
ui->toolBar_3->hide();
|
ui->toolBar_3->hide();
|
||||||
ui->toolBar_plugin->hide();
|
ui->toolBar_plugin->hide();
|
||||||
//加载样式
|
//加载样式
|
||||||
//loadStyle(":/qrc/qss/flatgray.css");
|
loadStyle(":/qrc/qss/flatgray.css");
|
||||||
|
|
||||||
//this->setStyleSheet("QWidget{border: 1px solid black;}");
|
//this->setStyleSheet("QWidget{border: 1px solid black;}");
|
||||||
//ui->centralwidget->setVisible(false);
|
//ui->centralwidget->setVisible(false);
|
||||||
|
|
@ -713,6 +714,8 @@ void MainWindowCurve::initMainToolBar()
|
||||||
QIcon SaveAsPdfIcon(::GetImagePath()+"icon/ExportPDF.png");
|
QIcon SaveAsPdfIcon(::GetImagePath()+"icon/ExportPDF.png");
|
||||||
QIcon SaveAsSvgIcon(::GetImagePath()+"icon/ExportSVG.png");
|
QIcon SaveAsSvgIcon(::GetImagePath()+"icon/ExportSVG.png");
|
||||||
QIcon PrintIcon(::GetImagePath()+"icon/Print.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 doubleHeadIcon(::GetImagePath()+"icon/oneortwohead.png");
|
||||||
QIcon crossIcon(::GetImagePath()+"icon/Cross.png");
|
QIcon crossIcon(::GetImagePath()+"icon/Cross.png");
|
||||||
QIcon autorollIcon(::GetImagePath()+"icon/autoroll.png");
|
QIcon autorollIcon(::GetImagePath()+"icon/autoroll.png");
|
||||||
|
|
@ -737,6 +740,8 @@ void MainWindowCurve::initMainToolBar()
|
||||||
m_SaveAsPdfAc = new QAction(SaveAsPdfIcon, "导出PDF", this);
|
m_SaveAsPdfAc = new QAction(SaveAsPdfIcon, "导出PDF", this);
|
||||||
m_SaveAsSvgAc = new QAction(SaveAsSvgIcon, "导出SVG", this);
|
m_SaveAsSvgAc = new QAction(SaveAsSvgIcon, "导出SVG", this);
|
||||||
m_PrintAc = new QAction(PrintIcon, "打印", 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_blackAc = new QAction(blackIcon, "黑白图", this);
|
||||||
m_doubleHeadAc = new QAction(doubleHeadIcon, "单曲线头", this);
|
m_doubleHeadAc = new QAction(doubleHeadIcon, "单曲线头", this);
|
||||||
m_executeDepthShiftAc = new QAction(executeDepthShiftIcon, "校深", this);
|
m_executeDepthShiftAc = new QAction(executeDepthShiftIcon, "校深", this);
|
||||||
|
|
@ -766,6 +771,8 @@ void MainWindowCurve::initMainToolBar()
|
||||||
menuPrint->addAction(m_SaveAsPdfAc); //导出PDF
|
menuPrint->addAction(m_SaveAsPdfAc); //导出PDF
|
||||||
menuPrint->addAction(m_SaveAsSvgAc); //导出SVG
|
menuPrint->addAction(m_SaveAsSvgAc); //导出SVG
|
||||||
menuPrint->addAction(m_PrintAc); //打印
|
menuPrint->addAction(m_PrintAc); //打印
|
||||||
|
menuPrint->addAction(m_PrintSetupAc); //打印设置
|
||||||
|
menuPrint->addAction(m_PrintPreviewAc); //打印预览
|
||||||
printMenuAction->setMenu(menuPrint);
|
printMenuAction->setMenu(menuPrint);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -835,6 +842,8 @@ void MainWindowCurve::initMainToolBar()
|
||||||
connect(m_SaveAsPdfAc, &QAction::triggered, this, &MainWindowCurve::s_SaveAsPdf);
|
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_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_blackAc, &QAction::triggered, this, &MainWindowCurve::s_Black);
|
||||||
connect(m_doubleHeadAc, &QAction::triggered, this, &MainWindowCurve::s_DoubleHead);
|
connect(m_doubleHeadAc, &QAction::triggered, this, &MainWindowCurve::s_DoubleHead);
|
||||||
|
|
@ -3693,6 +3702,12 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName,
|
||||||
tmpPath += "/";
|
tmpPath += "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int left=9, top=20, right=9, bottom=0;
|
||||||
|
if (ui->centralwidget->layout())
|
||||||
|
{
|
||||||
|
ui->centralwidget->layout()->getContentsMargins(&left, &top, &right, &bottom);
|
||||||
|
}
|
||||||
|
|
||||||
//获取可视视图大小 tableWidget_2
|
//获取可视视图大小 tableWidget_2
|
||||||
int iHight = 0;
|
int iHight = 0;
|
||||||
int iWidth = 0;
|
int iWidth = 0;
|
||||||
|
|
@ -3701,14 +3716,14 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName,
|
||||||
{
|
{
|
||||||
iHight += ui->tableWidget_2->rowHeight(i);
|
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; j<ui->tableWidget_2->columnCount(); j++)
|
for(int j=0; j<ui->tableWidget_2->columnCount(); j++)
|
||||||
{
|
{
|
||||||
|
|
||||||
iWidth += ui->tableWidget_2->columnWidth(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())
|
// if(iWidth < ui->tableWidget_2->width())
|
||||||
// {
|
// {
|
||||||
// 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;
|
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 iTotalSize_Height = iHight_Head+iHight_Tail;
|
||||||
int iNum = dDeep/dScrollHeight;
|
int iNum = dDeep/dScrollHeight;
|
||||||
|
|
@ -4150,6 +4165,53 @@ void MainWindowCurve::_slotExport(QPrinter &printer, int IsBmp, QString pngName,
|
||||||
ShowTableHead_One();
|
ShowTableHead_One();
|
||||||
//2个滚动条位置
|
//2个滚动条位置
|
||||||
SetScrollBar_Geometry();
|
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, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
//打印
|
//打印
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,9 @@ public slots:
|
||||||
void slotCreateHead();
|
void slotCreateHead();
|
||||||
void slotCreateTail();
|
void slotCreateTail();
|
||||||
|
|
||||||
|
//打印预览
|
||||||
|
void printPreview(QPrinter*printer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindowSplitter* m_pParentWin = NULL;
|
MainWindowSplitter* m_pParentWin = NULL;
|
||||||
|
|
||||||
|
|
@ -252,6 +255,8 @@ public:
|
||||||
QAction* m_SaveAsPdfAc = nullptr; //导出PDF
|
QAction* m_SaveAsPdfAc = nullptr; //导出PDF
|
||||||
QAction* m_SaveAsSvgAc = nullptr; //导出SVG
|
QAction* m_SaveAsSvgAc = nullptr; //导出SVG
|
||||||
QAction* m_PrintAc = nullptr; //打印
|
QAction* m_PrintAc = nullptr; //打印
|
||||||
|
QAction* m_PrintSetupAc = nullptr; //打印设置
|
||||||
|
QAction* m_PrintPreviewAc = nullptr; //打印预览
|
||||||
QAction* m_blackAc = nullptr; //黑白图
|
QAction* m_blackAc = nullptr; //黑白图
|
||||||
QAction* m_doubleHeadAc = nullptr; //单曲线头
|
QAction* m_doubleHeadAc = nullptr; //单曲线头
|
||||||
QAction* m_executeDepthShiftAc = nullptr; //校深
|
QAction* m_executeDepthShiftAc = nullptr; //校深
|
||||||
|
|
@ -290,7 +295,7 @@ public slots:
|
||||||
void s_pinLvAc(); // 频率统计
|
void s_pinLvAc(); // 频率统计
|
||||||
void s_NewGanZhuangTu(); // 杆状图
|
void s_NewGanZhuangTu(); // 杆状图
|
||||||
void s_roseAc(); // 玫瑰图
|
void s_roseAc(); // 玫瑰图
|
||||||
void s_dcaAc(); // DCA分析
|
void s_dcaAc(); // DCA分析
|
||||||
void s_Jykt(); // 井眼垮塌矢量图
|
void s_Jykt(); // 井眼垮塌矢量图
|
||||||
void s_Denv(); // 井斜方位图
|
void s_Denv(); // 井斜方位图
|
||||||
void s_DrawImage(); // 图像 成图
|
void s_DrawImage(); // 图像 成图
|
||||||
|
|
@ -346,6 +351,8 @@ public slots:
|
||||||
void s_SaveAsPdf(); //导出PDF
|
void s_SaveAsPdf(); //导出PDF
|
||||||
void s_SaveAsSvg(); //导出SVG
|
void s_SaveAsSvg(); //导出SVG
|
||||||
void s_Print(); //打印
|
void s_Print(); //打印
|
||||||
|
void s_PrintSetup(); //打印设置
|
||||||
|
void s_PrintPreview(); //打印预览
|
||||||
void s_Zoom(); //缩放
|
void s_Zoom(); //缩放
|
||||||
void s_ZoomIn(); //放大
|
void s_ZoomIn(); //放大
|
||||||
void s_ZoomOut(); //缩小
|
void s_ZoomOut(); //缩小
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,12 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QMainWindow
|
||||||
|
{
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user