You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
map-display/loadscenedatathread.cpp

111 lines
4.6 KiB
C++

#include "loadscenedatathread.h"
#include "Scene/UGLayer3D.h"
#include "geofileparser.h"
#include "qfileinfo.h"
#include "qthread.h"
#include "translator.h"
#include <QDebug>
#include <QElapsedTimer>
LoadSceneDataThread::LoadSceneDataThread(QObject *parent)
: QObject{parent}
{
}
void LoadSceneDataThread::working()
{
qDebug() << "当前子线程对象的地址: " << QThread::currentThread();
GeoFileParser geoFileParser;
UGString ugImageLayerName;
UGLayer3D* pLayer = NULL;
UGString ugTerrianLayerName;
UGTerrainAccessor* tm = NULL;
int imageTotalCount = imagePathList.size();
int terrianTotalCount = terrianPathList.size();
int i = 0;
int j = 0;
//导入影像数据
if(!imagePathList.isEmpty())
{
// ShowProgressDialog* progressDlg = new ShowProgressDialog();
// connect(this,&MainWindow::closedProgressDialog,progressDlg,&ShowProgressDialog::closedProgressDialog);
// QThreadPool::globalInstance()->start(progressDlg);
// qDebug()<<"*****************activeThreadCount:"<<QThreadPool::globalInstance()->activeThreadCount();
// QTimer* timer = new QTimer();
// connect(timer, &QTimer::timeout, progressDlg, &ShowProgressDialog::updateProgressDialog);
// timer->start(100);//开启一个没有终点的定时器
for(i;i<imagePathList.size();i++)
{
// progressDlg->setLabelText("影像文件(" + QString::number(i+1) + "/" + QString::number(imagePathList.size()) + ")导入中...");
QFileInfo fileInfo(imagePathList.at(i));
UGString imageName = Translator::QStr2UGStr(fileInfo.baseName());
QElapsedTimer mstimer;
mstimer.start();
bool ss = geoFileParser.importTiffData(pDataSource,imageName,imagePathList.at(i),true);
float time = (double)mstimer.nsecsElapsed() / (double)1000000;
qDebug() << "ImageTime:::" << time/1000;
if(ss)
{
ugImageLayerName = imageName + _U("@") + datasourceName; // 数据集名@数据源名,图层默认命名格式,也是通过该格式的名称获得关联数据
// m_mutex.lock();
pLayer = pSceneControl->GetSceneEditWnd()->GetScene3D()->m_Layers.AddLayer(ugImageLayerName);
// m_mutex.unlock();
}
// emit sendTaskName(Translator::UGStr2QStr(imageName));
emit sendTaskFinishedCount(i+1,imageTotalCount,j,terrianTotalCount);
}
// emit closedProgressDialog();
}
//导入地形数据
if(!terrianPathList.isEmpty())
{
for(j;j<terrianPathList.size();j++)
{
// progressDlg->setLabelText("地形文件(" + QString::number(j+1) + "/" + QString::number(terrianPathList.size()) + ")导入中...");
QFileInfo fileInfo(terrianPathList.at(j));
UGString terrianName = Translator::QStr2UGStr(fileInfo.baseName());
QElapsedTimer mstimer;
mstimer.start();
bool ss = geoFileParser.importTiffData(pDataSource,terrianName,terrianPathList.at(j),true,
UGImportParams::ModeGrid,UGDataCodec::encLZW);
float time = (double)mstimer.nsecsElapsed() / (double)1000000;
qDebug() << "TerrianTime:::" << time/1000;
if(ss)
{
qDebug()<<"*********************LoadTerrainSuccessed";
ugTerrianLayerName = terrianName + _U("@") + datasourceName; // 数据集名@数据源名,图层默认命名格式,也是通过该格式的名称获得关联数据
tm = pSceneControl->GetSceneEditWnd()->GetScene3D()->m_TerrainLayer3Ds.AddTerrainLayer(ugTerrianLayerName,terrianName);
}
// emit sendTaskName(Translator::UGStr2QStr(terrianName));
// emit sendTaskName(terrianPathList.at(j));
qDebug()<<"*********************TerrainFinished";
emit sendTaskFinishedCount(i,imageTotalCount,j+1,terrianTotalCount);
}
}
// if(!imagePathList.isEmpty())
// {
// pSceneControl->ViewToLayer(pLayer);
// }
pLayer = NULL;
tm = NULL;
pSceneControl = NULL;
pDataSource = NULL;
// emit taskFinish();
}
void LoadSceneDataThread::receiveFileList(SceneControl *pSceneControl, UGDataSource *pDataSource, QStringList imagePathList, QStringList terrianPathList)
{
this->pSceneControl = pSceneControl;
this->pDataSource = pDataSource;
this->imagePathList = imagePathList;
this->terrianPathList = terrianPathList;
this->datasourceName = pDataSource->GetAlias();
working();
}