Compare commits
5 Commits
d677e104fa
...
a74b15aa18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a74b15aa18 | ||
|
|
02a218c0fb | ||
|
|
e14e616293 | ||
|
|
162a3e368f | ||
|
|
963b1c9653 |
|
|
@ -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; i<ui->tableWidget->rowCount(); i++)
|
||||||
|
{
|
||||||
|
//高度
|
||||||
|
iHight += ui->tableWidget->rowHeight(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int j=0; j<ui->tableWidget->columnCount(); j++)
|
||||||
|
{
|
||||||
|
//高度
|
||||||
|
iWidth += ui->tableWidget->columnWidth(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ public:
|
||||||
//Head代表图头, Tail代表成果表
|
//Head代表图头, Tail代表成果表
|
||||||
void DisplayHeads(QJsonArray headsArray, QString strHeadOrTail);
|
void DisplayHeads(QJsonArray headsArray, QString strHeadOrTail);
|
||||||
|
|
||||||
|
//获取图头、结论的宽高,方便输出图
|
||||||
|
void getTableSize(int &iWidth, int &iHight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString m_strHeadOrTail = ""; //Head代表图头, Tail代表成果表
|
QString m_strHeadOrTail = ""; //Head代表图头, Tail代表成果表
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui svg
|
QT += core gui svg printsupport
|
||||||
#QT += opengl
|
#QT += opengl
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
double g_logicalDpi;
|
double g_logicalDpi;
|
||||||
double g_dPixelPerCm;//每厘米像素数
|
double g_dPixelPerCm;//每厘米像素数
|
||||||
|
|
||||||
|
MainWindow *g_mainWindow = nullptr;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
@ -34,6 +36,7 @@ int main(int argc, char *argv[])
|
||||||
//qRegisterMetaType<QPoint>("QPoint");
|
//qRegisterMetaType<QPoint>("QPoint");
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
g_mainWindow = &w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,21 @@ MainWindow::~MainWindow()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
//关闭老项目
|
||||||
|
bool bClosed = closeProject();
|
||||||
|
if(!bClosed)
|
||||||
|
{
|
||||||
|
if(event)
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QMainWindow::closeEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::ReadConfig()
|
void MainWindow::ReadConfig()
|
||||||
{
|
{
|
||||||
int iIndex;
|
int iIndex;
|
||||||
|
|
@ -145,10 +160,7 @@ void MainWindow::ReadConfig()
|
||||||
qtCommon->readShowScale(configPath, iShow);
|
qtCommon->readShowScale(configPath, iShow);
|
||||||
g_iShow = iShow;
|
g_iShow = iShow;
|
||||||
}
|
}
|
||||||
CallManage* MainWindow::getInstanceCallManage()
|
|
||||||
{
|
|
||||||
return CallManage::getInstance();
|
|
||||||
}
|
|
||||||
void MainWindow::loadStyle(const QString &qssFile)
|
void MainWindow::loadStyle(const QString &qssFile)
|
||||||
{
|
{
|
||||||
//加载样式表
|
//加载样式表
|
||||||
|
|
@ -339,13 +351,69 @@ void MainWindow::dockLayout()
|
||||||
m_propertyWidget->InitCurrentViewInfo();
|
m_propertyWidget->InitCurrentViewInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//关闭成功返回true
|
||||||
|
bool MainWindow::closeProject()
|
||||||
|
{
|
||||||
|
//先判断是否需要保存tab页
|
||||||
|
bool bNeedSave = false;
|
||||||
|
if(m_centerWidgets)
|
||||||
|
{
|
||||||
|
int iCount = m_centerWidgets->count();
|
||||||
|
for(int i=0; i<iCount; i++)
|
||||||
|
{
|
||||||
|
QWidget *selectWidget = m_centerWidgets->tabWidget(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; i<iCount; i++)
|
||||||
|
{
|
||||||
|
m_centerWidgets->removeTab(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_prjname="";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::s_New()
|
void MainWindow::s_New()
|
||||||
{
|
{
|
||||||
|
//关闭老项目
|
||||||
|
bool bClosed = closeProject();
|
||||||
|
if(!bClosed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//新建
|
||||||
emit CallManage::getInstance()->sig_NewProject();
|
emit CallManage::getInstance()->sig_NewProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::s_Open()
|
void MainWindow::s_Open()
|
||||||
{
|
{
|
||||||
|
//关闭老项目
|
||||||
|
bool bClosed = closeProject();
|
||||||
|
if(!bClosed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//打开
|
//打开
|
||||||
QString fileFull = "";
|
QString fileFull = "";
|
||||||
fileFull = QFileDialog::getOpenFileName(this,
|
fileFull = QFileDialog::getOpenFileName(this,
|
||||||
|
|
@ -544,19 +612,20 @@ void MainWindow::s_DrawLine()
|
||||||
qDebug() << "vecSlfList:" << QString::number(i+1) << "=" << vecSlfList[i];
|
qDebug() << "vecSlfList:" << QString::number(i+1) << "=" << vecSlfList[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::s_CloseProject()
|
void MainWindow::s_CloseProject()
|
||||||
{
|
{
|
||||||
// if(m_centerWidgets)
|
if(m_centerWidgets)
|
||||||
// {
|
{
|
||||||
// int iCount = m_centerWidgets->count();
|
int iCount = m_centerWidgets->count();
|
||||||
// for(int i=0; i<iCount; i++)
|
for(int i=0; i<iCount; i++)
|
||||||
// {
|
{
|
||||||
// m_centerWidgets->removeTab(0);
|
m_centerWidgets->removeTab(0);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
//关闭老项目
|
||||||
|
g_prjname="";
|
||||||
}
|
}
|
||||||
|
|
||||||
//参数卡数据查看
|
//参数卡数据查看
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ public:
|
||||||
ConsoleOutputWidget *m_consoleOutputWidget;//日志
|
ConsoleOutputWidget *m_consoleOutputWidget;//日志
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
//样式
|
//样式
|
||||||
void loadStyle(const QString &qssFile);
|
void loadStyle(const QString &qssFile);
|
||||||
|
|
||||||
|
|
@ -71,8 +73,7 @@ public:
|
||||||
void dockLayout(); //停靠
|
void dockLayout(); //停靠
|
||||||
|
|
||||||
void ReadConfig();
|
void ReadConfig();
|
||||||
|
bool closeProject();
|
||||||
CallManage *getInstanceCallManage();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void s_New();
|
void s_New();
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@
|
||||||
#include "DepPairs.h"
|
#include "DepPairs.h"
|
||||||
#include "mainwindowsplitter.h"
|
#include "mainwindowsplitter.h"
|
||||||
#include "selectwelldialog.h"
|
#include "selectwelldialog.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include <QSvgGenerator>
|
||||||
|
|
||||||
|
//主窗口,为了方便获取tab当前页
|
||||||
|
extern MainWindow *g_mainWindow;
|
||||||
|
|
||||||
extern int g_iOneWidth; //道宽
|
extern int g_iOneWidth; //道宽
|
||||||
extern QString g_prjname;
|
extern QString g_prjname;
|
||||||
|
|
@ -163,6 +168,7 @@ MainWindowCurve::MainWindowCurve(QWidget *parent) :
|
||||||
|
|
||||||
MainWindowCurve::~MainWindowCurve()
|
MainWindowCurve::~MainWindowCurve()
|
||||||
{
|
{
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,6 +204,8 @@ void MainWindowCurve::initMainToolBar()
|
||||||
QIcon joindepthIcon(::GetImagePath()+"icon/joindepth.png");
|
QIcon joindepthIcon(::GetImagePath()+"icon/joindepth.png");
|
||||||
QIcon ModuleOpenIcon(::GetImagePath()+"icon/ModuleOne.png");
|
QIcon ModuleOpenIcon(::GetImagePath()+"icon/ModuleOne.png");
|
||||||
QIcon SaveAsPictureIcon(::GetImagePath()+"icon/SaveAsPicture.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 runIcon(":/image/capacity.png");
|
||||||
QIcon debugIcon(":/image/anaysis.png");
|
QIcon debugIcon(":/image/anaysis.png");
|
||||||
QIcon loadIcon(":/image/export.png");
|
QIcon loadIcon(":/image/export.png");
|
||||||
|
|
@ -211,6 +219,8 @@ void MainWindowCurve::initMainToolBar()
|
||||||
QAction* m_joindepthAc = nullptr; //拼接
|
QAction* m_joindepthAc = nullptr; //拼接
|
||||||
QAction* m_ModuleOpenAc = nullptr; //处理方法
|
QAction* m_ModuleOpenAc = nullptr; //处理方法
|
||||||
QAction* m_SaveAsPictureAc = nullptr; //导出长图
|
QAction* m_SaveAsPictureAc = nullptr; //导出长图
|
||||||
|
QAction* m_SaveAsPdfAc = nullptr; //导出PDF
|
||||||
|
QAction* m_SaveAsSvgAc = nullptr; //导出SVG
|
||||||
// QAction* m_runAc = nullptr;//
|
// QAction* m_runAc = nullptr;//
|
||||||
// QAction* m_debugAc = nullptr; //
|
// QAction* m_debugAc = nullptr; //
|
||||||
// QAction* m_loadAc = nullptr; //加载
|
// QAction* m_loadAc = nullptr; //加载
|
||||||
|
|
@ -223,6 +233,8 @@ void MainWindowCurve::initMainToolBar()
|
||||||
m_joindepthAc = new QAction(joindepthIcon, "拼接", this);
|
m_joindepthAc = new QAction(joindepthIcon, "拼接", this);
|
||||||
m_ModuleOpenAc = new QAction(ModuleOpenIcon, "处理方法", this);
|
m_ModuleOpenAc = new QAction(ModuleOpenIcon, "处理方法", this);
|
||||||
m_SaveAsPictureAc = new QAction(SaveAsPictureIcon, "导出长图", 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_debugAc = new QAction(debugIcon, "撤销", this);
|
||||||
// m_loadAc = new QAction(loadIcon, "重做", this);
|
// m_loadAc = new QAction(loadIcon, "重做", this);
|
||||||
//m_openAc = new QAction(openFileIcon, "打开", this);
|
//m_openAc = new QAction(openFileIcon, "打开", this);
|
||||||
|
|
@ -237,8 +249,9 @@ void MainWindowCurve::initMainToolBar()
|
||||||
ui->mainToolBar->addAction(m_executeDepthShiftAc);
|
ui->mainToolBar->addAction(m_executeDepthShiftAc);
|
||||||
ui->mainToolBar->addAction(m_joindepthAc);
|
ui->mainToolBar->addAction(m_joindepthAc);
|
||||||
ui->mainToolBar->addAction(m_ModuleOpenAc);
|
ui->mainToolBar->addAction(m_ModuleOpenAc);
|
||||||
|
ui->mainToolBar->addAction(m_SaveAsPictureAc);//导出长图
|
||||||
//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_debugAc);
|
||||||
// ui->mainToolBar->addAction(m_loadAc);
|
// ui->mainToolBar->addAction(m_loadAc);
|
||||||
|
|
@ -253,6 +266,8 @@ void MainWindowCurve::initMainToolBar()
|
||||||
|
|
||||||
connect(m_ModuleOpenAc, &QAction::triggered, this, &MainWindowCurve::s_ModuleOpen);
|
connect(m_ModuleOpenAc, &QAction::triggered, this, &MainWindowCurve::s_ModuleOpen);
|
||||||
connect(m_SaveAsPictureAc, &QAction::triggered, this, &MainWindowCurve::s_SaveAsPicture);
|
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_grepAc, &QAction::triggered, this, &MainWindow::s_Risize);
|
||||||
// connect(m_compileAc, &QAction::triggered, this, &MainWindow::s_AddOne);
|
// connect(m_compileAc, &QAction::triggered, this, &MainWindow::s_AddOne);
|
||||||
|
|
@ -2324,9 +2339,389 @@ void MainWindowCurve::s_ModuleOpen()
|
||||||
//导出长图
|
//导出长图
|
||||||
void MainWindowCurve::s_SaveAsPicture()
|
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; i<ui->tableWidget_2->rowCount(); i++)
|
||||||
|
{
|
||||||
|
//高度
|
||||||
|
iHight += ui->tableWidget_2->rowHeight(i);
|
||||||
|
}
|
||||||
|
//ui->tableWidget_2->setRowHeight(1, iHight+200);
|
||||||
|
//iHight += 3000;
|
||||||
|
|
||||||
|
for(int j=0; j<ui->tableWidget_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));
|
ui->centralwidget->setGeometry(geoRect.x(), geoRect.y(), iWidth, iHight);
|
||||||
pPixmap.save("d:\\3.png", "png");
|
|
||||||
|
//尾
|
||||||
|
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; i<ui->tableWidget_2->rowCount(); i++)
|
||||||
|
{
|
||||||
|
//高度
|
||||||
|
iHight += ui->tableWidget_2->rowHeight(i);
|
||||||
|
}
|
||||||
|
//ui->tableWidget_2->setRowHeight(1, iHight+200);
|
||||||
|
//iHight += 3000;
|
||||||
|
|
||||||
|
for(int j=0; j<ui->tableWidget_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; i<ui->tableWidget_2->rowCount(); i++)
|
||||||
|
{
|
||||||
|
//高度
|
||||||
|
iHight += ui->tableWidget_2->rowHeight(i);
|
||||||
|
}
|
||||||
|
//ui->tableWidget_2->setRowHeight(1, iHight+200);
|
||||||
|
//iHight += 3000;
|
||||||
|
|
||||||
|
for(int j=0; j<ui->tableWidget_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)
|
//void MainWindowCurve::s_Open(QString fileFull)
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,8 @@ public slots:
|
||||||
void s_ExecuteMerge(); //拼接
|
void s_ExecuteMerge(); //拼接
|
||||||
void s_ModuleOpen(); //处理算法
|
void s_ModuleOpen(); //处理算法
|
||||||
void s_SaveAsPicture(); //导出长图
|
void s_SaveAsPicture(); //导出长图
|
||||||
|
void s_SaveAsPdf(); //导出PDF
|
||||||
|
void s_SaveAsSvg(); //导出SVG
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -933,8 +933,9 @@ void QtProjectWidgets::onOpenProject(bool checked)
|
||||||
|
|
||||||
void QtProjectWidgets::s_NewProject()
|
void QtProjectWidgets::s_NewProject()
|
||||||
{
|
{
|
||||||
|
//
|
||||||
ui->treeWidget->clear();//清理数据
|
ui->treeWidget->clear();//清理数据
|
||||||
emit CallManage::getInstance()->sig_CloseProject();//关闭tab页
|
//emit CallManage::getInstance()->sig_CloseProject();//关闭tab页
|
||||||
|
|
||||||
// 创建对话框
|
// 创建对话框
|
||||||
CWellLogProjectDialog* dialog = new CWellLogProjectDialog();
|
CWellLogProjectDialog* dialog = new CWellLogProjectDialog();
|
||||||
|
|
@ -962,7 +963,7 @@ void QtProjectWidgets::s_NewProject()
|
||||||
void QtProjectWidgets::s_OpenProject(QString fileFull)
|
void QtProjectWidgets::s_OpenProject(QString fileFull)
|
||||||
{
|
{
|
||||||
ui->treeWidget->clear();//清理数据
|
ui->treeWidget->clear();//清理数据
|
||||||
emit CallManage::getInstance()->sig_CloseProject();//关闭tab页
|
//emit CallManage::getInstance()->sig_CloseProject();//关闭tab页
|
||||||
|
|
||||||
s_loadTreeWidget(fileFull);
|
s_loadTreeWidget(fileFull);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user