导入文件 ,解编lis wis等中文路径无法导入问题。

改变窗口获取高度逻辑,用于绘图渲染
This commit is contained in:
DESKTOP-450PEFP\mainc 2026-06-18 13:34:59 +08:00
parent c699f66026
commit 73f6c3171d
6 changed files with 53 additions and 23 deletions

View File

@ -741,9 +741,9 @@ bool ImportDataDialog::SelectAndDeleteWellLog(int iRow,InterfaceWidget *pCurren
char *outfile = new char[outputfilename.toStdString().size()+300]; char *outfile = new char[outputfilename.toStdString().size()+300];
strcpy(outfile, outputfilename.toStdString().c_str()); strcpy(outfile, outputfilename.toStdString().c_str());
char *logfilename = new char[m_FilePath.toStdString().size()+1]; //char *logfilename = new char[m_FilePath.toStdString().size()+1];
strcpy(logfilename, m_FilePath.toStdString().c_str()); //strcpy(logfilename, m_FilePath.toStdString().c_str());
QLineEdit * xEdit=pCurrentInterfaceWidget->GetXCodeLineEdit(); QLineEdit * xEdit=pCurrentInterfaceWidget->GetXCodeLineEdit();
QLineEdit * yEdit=pCurrentInterfaceWidget->GetYCodeLineEdit(); QLineEdit * yEdit=pCurrentInterfaceWidget->GetYCodeLineEdit();
@ -767,7 +767,7 @@ bool ImportDataDialog::SelectAndDeleteWellLog(int iRow,InterfaceWidget *pCurren
// QString strCh(logfilename); // 汉字路径转换 // QString strCh(logfilename); // 汉字路径转换
// // QString strChOut(outfile); // 汉字路径转换 // // QString strChOut(outfile); // 汉字路径转换
if(((InterIConvertor*)(pCurrentInterfaceWidget->m_pConvertor))->Transfer(/*strCh.toLocal8Bit().data()*//*UTF8ToGBK(logfilename).data()*/logfilename,outfile/*strChOut.toLocal8Bit().data()*/,&OutCurveNo[0],&OutCurve[0],&strChineseName[0],&strUnit[0],iRow)) if(((InterIConvertor*)(pCurrentInterfaceWidget->m_pConvertor))->Transfer(UTF8ToGBK(m_FilePath).data(),outfile/*strChOut.toLocal8Bit().data()*/,&OutCurveNo[0],&OutCurve[0],&strChineseName[0],&strUnit[0],iRow))
{ {
MyWelllogRound *wellRound=pCurrentInterfaceWidget->m_pConvertor->GetWellLogRoundInfo(); MyWelllogRound *wellRound=pCurrentInterfaceWidget->m_pConvertor->GetWellLogRoundInfo();
if(wellRound) { if(wellRound) {
@ -782,7 +782,7 @@ bool ImportDataDialog::SelectAndDeleteWellLog(int iRow,InterfaceWidget *pCurren
delete OutCurve[i]; delete OutCurve[i];
delete strUnit[i]; delete strUnit[i];
} }
delete []logfilename; //delete []logfilename;
delete []outfile; delete []outfile;
return 0; return 0;
} }

View File

@ -141,10 +141,11 @@ bool InterIConvertor::Init()
bool InterIConvertor::IsSupport( const QString &filename ) bool InterIConvertor::IsSupport( const QString &filename )
{ {
IConvertor::IsSupport(filename); IConvertor::IsSupport(filename);
string tempStr=filename.toStdString(); // string tempStr=filename.toStdString();
char *filePath=const_cast<char*>(tempStr.c_str()); // char *filePath=const_cast<char*>(tempStr.c_str());
// QString strCh(filePath); // 汉字路径转换 // QString strCh(filePath); // 汉字路径转换
int Value= ScanLogFile(filePath/*UTF8ToGBK(filePath).data()*//*strCh.toLocal8Bit().data()*/,m_fileMessage,&m_vCurverName[0],&m_vCurverUnit[0]); QByteArray bt = UTF8ToGBK(filename);
int Value= ScanLogFile(bt.data(),m_fileMessage,&m_vCurverName[0],&m_vCurverUnit[0]);
m_CurveData.Curve_Num=Value; m_CurveData.Curve_Num=Value;
if(Value<=0) return 0;//ww if(Value<=0) return 0;//ww
return Value; return Value;

View File

@ -1124,7 +1124,7 @@ QString GBKToUTF8(const QByteArray& gbkData) {
// UTF-8 转 GBK // UTF-8 转 GBK
QByteArray UTF8ToGBK(const QString& utf8Str) { QByteArray UTF8ToGBK(const QString& utf8Str) {
// 此处编码 库加了#pragma execution_character_set("utf-8") ,是否正确??? // 此处编码 库加了#pragma execution_character_set("utf-8") ,是否正确???
return utf8Str.toStdString().c_str(); //return utf8Str.toStdString().c_str();
QTextCodec* gbkCodec = QTextCodec::codecForName("GBK"); QTextCodec* gbkCodec = QTextCodec::codecForName("GBK");
if (!gbkCodec) { if (!gbkCodec) {
return QByteArray(); return QByteArray();

View File

@ -156,6 +156,24 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMainWindow::closeEvent( event ); QMainWindow::closeEvent( event );
} }
QScreen* getBestScreen() {
// 优先使用鼠标所在屏幕
QScreen* screen = QGuiApplication::screenAt(QCursor::pos());
if (screen) return screen;
// 其次使用主屏幕
screen = QGuiApplication::primaryScreen();
if (screen) return screen;
// 最后使用第一个屏幕
QList<QScreen*> screens = QGuiApplication::screens();
if (!screens.isEmpty()) {
return screens.first();
}
return nullptr;
}
void MainWindow::ReadConfig() void MainWindow::ReadConfig()
{ {
int iIndex; int iIndex;
@ -197,15 +215,14 @@ void MainWindow::ReadConfig()
} }
else else
{ {
if (iHeight < QApplication::desktop()->width()) QScreen* sr = getBestScreen();
if (sr)
{ {
iHeight = QApplication::desktop()->width(); if (iHeight < sr->size().width())
iHeight = sr->size().width();
if (iHeight < sr->size().height())
iHeight = sr->size().height();
} }
if(iHeight < QApplication::desktop()->height())
{
//不能低于分辨率
iHeight = QApplication::desktop()->height();
}
} }
g_iHeight_MyCustom = iHeight; g_iHeight_MyCustom = iHeight;
@ -228,6 +245,16 @@ void MainWindow::ReadConfig()
g_iPageStep = iPageStep; g_iPageStep = iPageStep;
} }
void MainWindow::resizeEvent(QResizeEvent *event)
{
int nhei = event->size().width();
if (nhei < event->size().height())
{
nhei = event->size().height();
}
g_iHeight_MyCustom = nhei;
}
void MainWindow::loadStyle(const QString &qssFile) void MainWindow::loadStyle(const QString &qssFile)
{ {
//加载样式表 //加载样式表

View File

@ -56,6 +56,8 @@ public:
public: public:
virtual void closeEvent(QCloseEvent *event); virtual void closeEvent(QCloseEvent *event);
protected: protected:
void resizeEvent(QResizeEvent *event);
//样式 //样式
void loadStyle(const QString &qssFile); void loadStyle(const QString &qssFile);

View File

@ -145,7 +145,7 @@ int CLisConvertor::ScanLogFile(char *FileName,char *Message,char **CurveName,ch
strcpy(szTemp, "[LIS]"); strcpy(szTemp, "[LIS]");
int pos1=GetBeginPosit(FileName,szTemp); int pos1=GetBeginPosit(FileName,szTemp);
mWellDynamicInfo=&WellDynamicInfo; mWellDynamicInfo=&WellDynamicInfo;
if((fp=fopen(/*FileName*/UTF8ToGBK(FileName),"rb"))==NULL) { if((fp=fopen(FileName,"rb"))==NULL) {
QMessageBox::information(NULL,FileName,"Open Not File:",QMessageBox::Ok); QMessageBox::information(NULL,FileName,"Open Not File:",QMessageBox::Ok);
return 0; return 0;
} }
@ -592,15 +592,15 @@ bool CLisConvertor::Transfer(char *FileName,char *outfile,int *OutCurveNo,char *
if(xCoord != -99999 && yCoord != -99999) if(xCoord != -99999 && yCoord != -99999)
{ {
char buf[256]; //char buf[256];
QString strWellInfo= "井基本信息"; const char* strWellInfo= "井基本信息";
strcpy(buf, strWellInfo.toLocal8Bit().data()); //strcpy(buf, strWellInfo.toLocal8Bit().data());
int index = m_SlfFile.FindObjectIndex(buf); int index = m_SlfFile.FindObjectIndex(strWellInfo);
int indexSTable = m_SlfFile.OpenSTATIC(buf); int indexSTable = m_SlfFile.OpenSTATIC(strWellInfo);
m_SlfFile.WriteTable(indexSTable, 1, &WellStaticInfo); m_SlfFile.WriteTable(indexSTable, 1, &WellStaticInfo);
m_SlfFile.CloseTable(indexSTable); m_SlfFile.CloseTable(indexSTable);
int indexDTable=m_SlfFile.OpenDYNAMIC(buf); int indexDTable=m_SlfFile.OpenDYNAMIC(strWellInfo);
m_SlfFile.WriteTable(indexDTable, 1, &WellDynamicInfo); m_SlfFile.WriteTable(indexDTable, 1, &WellDynamicInfo);
m_SlfFile.CloseTable(indexDTable); m_SlfFile.CloseTable(indexDTable);
} }
@ -736,7 +736,7 @@ bool CLisConvertor::Transfer(char *FileName,char *outfile,int *OutCurveNo,char *
// format spcification number // format spcification number
int nfmsp=0 ,nfrmob; int nfmsp=0 ,nfrmob;
if((fp=fopen(UTF8ToGBK(FileName),"rb")) == NULL) { if((fp=fopen(FileName,"rb")) == NULL) {
QMessageBox::information(NULL,FileName,"Open Not File:",QMessageBox::Ok); QMessageBox::information(NULL,FileName,"Open Not File:",QMessageBox::Ok);
return 0; return 0;
} }