diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 585b213d..87c20252 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,7 +103,7 @@ INCLUDE_DIRECTORIES( if(MSVC) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /Od") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") #/Od set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") foreach(var @@ -183,7 +183,7 @@ endif() SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ProjectDIR}/bin) TARGET_LINK_LIBRARIES(${PROJECT_NAME}) -SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") +#SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD diff --git a/src/entities/ConeWaveComponent.cpp b/src/entities/ConeWaveComponent.cpp index 3c077d0f..a7082b46 100644 --- a/src/entities/ConeWaveComponent.cpp +++ b/src/entities/ConeWaveComponent.cpp @@ -43,9 +43,9 @@ bool ConeWaveComponent::SetAttribute(const char* name, const char* value) { } else if (0 == strcmp("event", name)) { SetTimeAction(value); } else if (0 == strcmp("levelCount", name)) { - SetHeight(atof(value)); + SetLevelCount(atof(value)); } else if (0 == strcmp("levelHeihgt", name)) { - SetTimeAction(value); + SetLevelHeight(atof(value)); } return SceneComponent::SetAttribute(name, value); diff --git a/src/entities/SceneComponent.cpp b/src/entities/SceneComponent.cpp index b9113791..02c67721 100644 --- a/src/entities/SceneComponent.cpp +++ b/src/entities/SceneComponent.cpp @@ -172,8 +172,10 @@ void SceneComponent::AttachParent(SceneComponent* parent) { LOG_INFO("parent is nullptr"); return; } - parent_ = parent; - parent->children_.push_back(this); + if (parent_ != parent) { + parent_ = parent; + parent->children_.push_back(this); + } AttachEntity(parent->GetEntity()); if (nullptr != mt_ && nullptr != parent->mt_) { diff --git a/src/main.cpp b/src/main.cpp index 879af81c..4fe99b41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,9 +9,7 @@ int main(int argc, char* argv[]) { SpdLogger logger("logs/log.txt", 5); -#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0)) Application::setAttribute(Qt::AA_EnableHighDpiScaling); -#endif Application app(argc, argv); app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); diff --git a/src/scene/TritonContext.cpp b/src/scene/TritonContext.cpp index 8606e581..f6edc18a 100644 --- a/src/scene/TritonContext.cpp +++ b/src/scene/TritonContext.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #define LC "[TritonContext] " @@ -97,6 +98,12 @@ TritonContext::initialize(osg::RenderInfo& renderInfo) resourcePath = osgDB::concatPaths(::getenv("TRITON_PATH"), "Resources"); } + if ( resourcePath.empty() ) + { + const QString dir = QString("%1/TritonResources").arg(QApplication::applicationDirPath()); + resourcePath = dir.toStdString(); + } + _resourceLoader = new ::Triton::ResourceLoader(resourcePath.c_str()); _environment = new ::Triton::Environment(); diff --git a/src/scene/TritonIntersections.cpp b/src/scene/TritonIntersections.cpp index 31a6615a..727dbd64 100644 --- a/src/scene/TritonIntersections.cpp +++ b/src/scene/TritonIntersections.cpp @@ -22,7 +22,7 @@ using namespace osgEarth; using namespace osgEarth::Triton; TritonIntersections::TritonIntersections() : -_maxRange(2.0, Units::KILOMETERS) +_maxRange(1.0, Units::KILOMETERS) { } diff --git a/src/scene/TritonLayer.cpp b/src/scene/TritonLayer.cpp index 9f015255..5c5092b9 100644 --- a/src/scene/TritonLayer.cpp +++ b/src/scene/TritonLayer.cpp @@ -116,7 +116,7 @@ namespace osgEarth { namespace Triton // Place in the depth-sorted bin and set a rendering order. // We want Triton to render after the terrain. _drawable->getOrCreateStateSet()->setRenderBinDetails( - _tritonLayer->getRenderBinNumber(), + _tritonLayer->getRenderBinNumber(), "DepthSortedBin"); // Install a vdatum for sea level calculations: @@ -187,7 +187,7 @@ namespace osgEarth { namespace Triton // Make sure it's in range so as not to waste cycles: osg::Vec3d anchor = osg::Vec3d(0,0,0) * local2world; double m = ir->getMaxRange().as(Units::METERS); - if ((eye-anchor).length2() > (m*m)) + if ((eye-anchor).length2() > (m)) { continue; } diff --git a/src/translations/Dyt_zh_CN.bak.qm b/src/translations/Dyt_zh_CN.bak.qm deleted file mode 100644 index 7d92a45b..00000000 Binary files a/src/translations/Dyt_zh_CN.bak.qm and /dev/null differ diff --git a/src/translations/Dyt_zh_CN.qm b/src/translations/Dyt_zh_CN.qm index 7c0161f3..77648716 100644 Binary files a/src/translations/Dyt_zh_CN.qm and b/src/translations/Dyt_zh_CN.qm differ diff --git a/src/translations/Dyt_zh_CN.ts b/src/translations/Dyt_zh_CN.ts index d586ed54..30a28039 100644 --- a/src/translations/Dyt_zh_CN.ts +++ b/src/translations/Dyt_zh_CN.ts @@ -97,7 +97,7 @@ Run Simu - + 运行 @@ -199,7 +199,7 @@ ... - + ... @@ -361,17 +361,17 @@ new workspace - + 新建空间 open workspace - + 打开空间 save workspace - + 保存空间 @@ -382,7 +382,7 @@ open dyt file - + 打开空间文件 @@ -393,7 +393,7 @@ save dyt file - + 保存空间文件 @@ -458,27 +458,27 @@ Dyt - + Dyt file manager - + 文件管理 - - system manager - - - - - play manager - - - - + simu manager - + 仿真管理 + + + + play manager + 回放管理 + + + + system manager + 系统管理 @@ -491,7 +491,7 @@ model elements - + 实体 @@ -553,7 +553,7 @@ attribute - + 属性 @@ -640,7 +640,7 @@ model elements - + 实体 @@ -650,23 +650,13 @@ ModelBrowserPannal - - - 新建列 - - - - - 新建项目 - - ModelTreeWidget Release Track - + 取消关注 @@ -701,7 +691,7 @@ Track - + 关注 @@ -716,7 +706,7 @@ Delete - + 删除 @@ -740,12 +730,12 @@ play - + 播放 stop - + 停止 @@ -765,12 +755,12 @@ up - + 加速 down - + 减速 @@ -782,7 +772,7 @@ question - + 询问 @@ -794,14 +784,14 @@ has not workspace - + 未找到对应的空间 pause - + 暂停 @@ -809,7 +799,7 @@ attribute - + 属性 @@ -839,7 +829,7 @@ Open File - + 选择文件 @@ -852,7 +842,7 @@ Open File - + 选择文件 @@ -865,17 +855,17 @@ error - + 错误 the appliaction is crash - + 程序出现了问题 List all tabs - + 所有标签 @@ -940,7 +930,7 @@ ... - + ... @@ -1142,7 +1132,7 @@ ... - + ... @@ -1150,7 +1140,7 @@ Name - + 名称 @@ -1163,7 +1153,7 @@ ... - + ... @@ -1251,7 +1241,7 @@ Name - + 名称 @@ -1272,14 +1262,20 @@ QtOsgViewWidget - - notify - + + + warning + 警告 - + + default workspace failed + 加载默认空间失败 + + + open dyt file failed - + 打开空间文件失败 @@ -1293,7 +1289,7 @@ Path - + 路径 @@ -1486,7 +1482,7 @@ ... - + ... @@ -1543,7 +1539,7 @@ Name - + 名称 @@ -1604,7 +1600,7 @@ SimuRunMenu - + 运行 @@ -1630,22 +1626,22 @@ exit - + 退出 ui setting - + ui设置 question - + 询问 are you sure to exit - + 确定退出 @@ -1704,103 +1700,103 @@ New WorkSpace - + 新建空间 Name - + 名称 input workspace name - + 输入空间名称 Path - + 路径 select workspace save path - + 选择空间保存路径 ... - + ... describe - + 描述 Sure - + 确定 Cancel - + 取消 - + new workspace - + 新建空间 - - - - - - - + + + + + + + warning - + 警告 - + name or save path is empty, please check it - + 当前空间已经存在,请确认 - + save current workspace? - + 保存当前空间? - + current path is contains current folder, do you want to overwrite it? - + 当前空间已经存在,是否覆盖当前空间? - + removeRecursively failed - + 删除失败 - + mkpath failed - + 创建空间失败 - + name is exits - + 空间已经存在 - + create workSpace failed - + 创建空间失败 - + save spaceWork directory - + 保存空间路径 diff --git a/src/translations/Dyt_zh_CN_.ts b/src/translations/Dyt_zh_CN_.ts deleted file mode 100644 index 62e24a18..00000000 --- a/src/translations/Dyt_zh_CN_.ts +++ /dev/null @@ -1,1608 +0,0 @@ - - - - - AddParamSetting - - - ParamSetting - 参数设置 - - - - AddParamSettingClass - - - AddParamSetting - 添加参数设置 - - - - 参数名称 - 参数名称 - - - - 描述 - 描述 - - - - 数据类型 - 数据类型 - - - - 最大值 - 最大值 - - - - 最小值 - 最小值 - - - - 小数点有效位 - 小数点有效位 - - - - 初始值 - 初始值 - - - - 添加 - 添加 - - - - 删除 - 删除 - - - - 应用 - 应用 - - - - ChartPlotMenuClass - - - ChartPlotMenu - 绘图 - - - - 2D Curver - 2D画布 - - - - 2D(lg) Curver - 2D(lg)画布 - - - - 3D Curver - 3D画布 - - - - DYTChart - - - 2D Curve - 2D画布 - - - - 2D(lg) Curve - 2D(lg)画图 - - - - 3D Curve - 3D画布 - - - - DYTChartClass - - - Form - 窗口 - - - - x轴 - x轴 - - - - - - 选择数据列 - 选择数据列 - - - - y轴 - y轴 - - - - z轴 - z轴 - - - - 已添加的曲线 - 已经添加的曲线 - - - - 曲线名称 - 曲线名称 - - - - 颜色 - 颜色 - - - - - - - ... - ... - - - - x轴标题 - x轴标题 - - - - 绑定x轴数据 - 绑定x轴数据 - - - - y轴标题 - y轴数据 - - - - 绑定y轴数据 - 绑定y轴数据 - - - - z轴标题 - z轴标题 - - - - 绑定z轴数据 - 绑定z轴数据 - - - - y轴数据类型 - y轴数据类型 - - - - 一般 - 一般 - - - - 对数 - 对数 - - - - 删除 - 删除 - - - - 更新 - 更新 - - - - 添加 - 添加 - - - - DockTitleBar - - - DockTitleBar - 标题 - - - - DynamicDisplayMenu - - - DynamicDisplayMenu - 动态显示 - - - - EntityListDialog - - - ModelBrowserPannal - 模型浏览版 - - - - 新建列 - 新建列 - - - - 新建项目 - 新建项目 - - - - FileManagerMenu - - - FileManagerMenu - 文件管理 - - - - - Dyt (*.dyt) - Dyt (*.dyt) - - - - open dyt file - 打开Dyt文件 - - - - - Dyt (*.dyt);;All files (*.*) - - - - - save dyt file - 保存Dyt文件 - - - - FitCurveChartView - - - FitCurveChartView - 绘图视图 - - - - FitCurveDialog - - - FitCurveDialog - 绘图对话框 - - - - 2D Curve - 2D画布 - - - - 2D(y(lg)) Curve - 2D(y(lg))画布 - - - - FrameTitleBar - - - Frame - Frame - - - - default - 默认 - - - - silver - 银色 - - - - blue - 蓝色 - - - - LayoutSettingUIClass - - - LayoutSettingUI - - - - - MainFrame - - - Dyt - DYT - - - - file manager - 文件管理 - - - - view manager - 视图管理 - - - - plan manager - 想定管理 - - - - dynamic display - 动态显示 - - - - system manager - 系统管理 - - - - play manager - 播放管理 - - - - MainWindow - - - MainWindow - 主窗口 - - - - model elements - 模型元素 - - - - attribte - 属性 - - - - Wave Curve - 波浪曲线 - - - - Speed Curve - 速度曲线 - - - - 3D Curve - 3D曲线 - - - - Report Table - 报表 - - - - Report - 上报 - - - - Signal Indicator Lamp - 信号指示灯 - - - - ParamSetting - 参数设置 - - - - name: 5year 0412 - - - - - start: no start - - - - - ModelBrowser - - - model elements - 实体 - - - - ModelBrowserPannal - - - ModelBrowserPannal - 模型列表 - - - - 新建列 - - - - - 新建项目 - - - - - ModelTreeWidget - - - Release Track - 释放跟踪 - - - - Add boke Entity - 添加BOKE实体 - - - - Add lsjhqt Entity - 添加LSJHQT实体 - - - - Add nimizi Entity - 添加NIMIZI实体 - - - - Add tkdlj Entity - 添加TKDLJ实体 - - - - Add jiaofan Entity - 添加jiaofan实体 - - - - Add satellite Entity - 添加SATELLITE实体 - - - - Track - 跟踪 - - - - Add Mesh Component - 添加MESH组件 - - - - Add Path Component - 添加PATH组件 - - - - Delete - 删除 - - - - PlanManagerMenu - - - PlanManagerMenu - 想定管理 - - - - PlayManagerMenu - - - PlayManagerMenu - 播放管理 - - - - - play - 播放 - - - - stop - 停止 - - - - 000.000 - - - - - 00000 - - - - - x1 - - - - - up - 加速 - - - - down - 减速 - - - - - - - - - - - question - 询问 - - - - - - - - - - - has not workspace - 没有工作空间 - - - - - pause - 暂停 - - - - PropertyBrowser - - - attribute - 属性 - - - - - WorkSpace - 工作空间 - - - - - Entity - 实体 - - - - ModelBase - 模型 - - - - color base - 颜色 - - - - QFilePathEdit - - - Open File - 打开 - - - - All Files (*) - - - - - QObject - - - error - 磁盘我 - - - - the appliaction is crash - 程序出现了问题 - - - - List all tabs - - - - - Detach Group - - - - - Close Active Tab - - - - - Close Group - - - - - Close Tab - - - - - QtBoolEdit - - - - - True - - - - - - False - - - - - QtBoolPropertyManager - - - True - - - - - False - - - - - QtCharEdit - - - Clear Char - - - - - QtColorEditWidget - - - ... - - - - - QtColorPropertyManager - - - Red - - - - - Green - - - - - Blue - - - - - Alpha - - - - - QtConeWaveComponentManager - - - - ConeWaveComponent - - - - - Height - - - - - Radius - - - - - Color1 - - - - - Color2 - - - - - Color3 - - - - - QtCursorDatabase - - - Arrow - - - - - Up Arrow - - - - - Cross - - - - - Wait - - - - - IBeam - - - - - Size Vertical - - - - - Size Horizontal - - - - - Size Backslash - - - - - Size Slash - - - - - Size All - - - - - Blank - - - - - Split Vertical - - - - - Split Horizontal - - - - - Pointing Hand - - - - - Forbidden - - - - - Open Hand - - - - - Closed Hand - - - - - What's This - - - - - Busy - - - - - QtDashedLineComponentManager - - - - DashedLineComponent - - - - - Start - - - - - End - - - - - Radius - - - - - Color - - - - - QtEntityEditWidget - - - ... - - - - - QtEntityPropertyManager - - - Name - - - - - Transform - - - - - QtFontEditWidget - - - ... - - - - - Select Font - - - - - QtFontPropertyManager - - - Family - - - - - Point Size - - - - - Bold - - - - - Italic - - - - - Underline - - - - - Strikeout - - - - - Kerning - - - - - QtLocalePropertyManager - - - <Invalid> - - - - - %1, %2 - - - - - Language - - - - - Country - - - - - QtMeshComponetManager - - - - MeshComponent - - - - - Mesh - Mesh - - - - QtModelBasePropertyManager - - - Name - - - - - Description - - - - - Inflow - - - - - InnerBottomElevation - - - - - QtOsgViewWidget - - - notify - 通知 - - - - open dyt file failed - 打开dyt文件失败 - - - - QtPathComponentManager - - - - PathComponent - - - - - Path - - - - - QtPointFPropertyManager - - - (%1, %2) - - - - - X - - - - - Y - - - - - QtPointPropertyManager - - - (%1, %2) - - - - - X - - - - - Y - - - - - QtPropertyBrowserUtils - - - [%1, %2, %3] (%4) - - - - - [%1, %2] - - - - - [%1, %2, %3] - - - - - [%1, %2, %3] [%4, %5, %6] [%7, %8, %9] - - - - - QtRectFPropertyManager - - - [(%1, %2), %3 x %4] - - - - - X - - - - - Y - - - - - Width - - - - - Height - - - - - QtRectPropertyManager - - - [(%1, %2), %3 x %4] - - - - - X - - - - - Y - - - - - Width - - - - - Height - - - - - QtSizeFPropertyManager - - - %1 x %2 - - - - - Width - - - - - Height - - - - - QtSizePolicyPropertyManager - - - - <Invalid> - - - - - [%1, %2, %3, %4] - - - - - Horizontal Policy - - - - - Vertical Policy - - - - - Horizontal Stretch - - - - - Vertical Stretch - - - - - QtSizePropertyManager - - - %1 x %2 - - - - - Width - - - - - Height - - - - - QtTransfromEditWidget - - - ... - - - - - QtTransfromPropertyManager - - - Location - - - - - Rotation - - - - - Scale - - - - - QtTreePropertyBrowser - - - Property - - - - - Value - - - - - QtVec3PropertyManager - - - X - - - - - Y - - - - - Z - - - - - QtWorkspacePropertyManager - - - Name - - - - - Description - - - - - Timestep - - - - - SignalIndicatorLampUI - - - SignalIndicatorLampUI - - - - - Signal Indicator Lamp - 信号指示灯 - - - - SurfaceDialog - - - DSurfaceDialog - - - - - 3D Curve - 3D曲线 - - - - SystemManagerMenu - - - SystemManagerMenu - 系统管理 - - - - exit - 退出 - - - - restart - 重启 - - - - setting - 设置 - - - - setting restore - 设置重置 - - - - help - 帮助 - - - - license - 权限 - - - - logs - 日志 - - - - - clean logs - 清除日志 - - - - question - 询问 - - - - are you sure to exit - 确认退出 - - - - TargetListWgt - - - TargetListWgt - 目标列表权重 - - - - 停止更新 - - - - - 显示行数 - - - - - 前一页 - - - - - / - - - - - 后一页 - - - - - 跳转 - - - - - Data Table - 时间表 - - - - ViewManagerMenu - - - ViewManagerMenu - 视图管理 - - - - WorkSpaceDlg - - - New WorkSpace - 新空间 - - - - Name - 名称 - - - - 1 - - - - - Path - 路径 - - - - d:/hysw - - - - - ... - - - - - describe - 描述 - - - - Sure - 确认 - - - - Cancel - 取消 - - - - - warning - 警告 - - - - name or save path is empty, please check it - 名称或者保存路径为空,请核查 - - - - name is exits - 文件已经存在 - - - - save spaceWork directory - 保存空间目录 - - - - ads::CDockAreaTitleBar - - - Detach Area - - - - - Close Area - - - - - Close Other Areas - - - - - ads::CDockManager - - - Show View - - - - - ads::CDockWidgetTab - - - Detach - - - - - Close - - - - - Close Others - - - - - osgQOpenGLWidget - - - Screen %1 - - - - - Choose fullscreen target screen - - - - - Screen - - - - diff --git a/src/ui/MainFrame.cpp b/src/ui/MainFrame.cpp index b786f9d2..cedba96a 100644 --- a/src/ui/MainFrame.cpp +++ b/src/ui/MainFrame.cpp @@ -101,15 +101,14 @@ void MainFrame::InitUI() { //AddMenuWidget("view_manager", tr("view manager"), new ViewManagerMenu(this)); //AddMenuWidget("plan_manager", tr("plan manager"), new PlanManagerMenu(this)); //AddMenuWidget("dynamic_display", tr("dynamic display"), new DynamicDisplayMenu(this)); - - SystemManagerMenu* system_ = new SystemManagerMenu(this); - AddMenuWidget("system_manager", tr("system manager"), system_); + ChartPlotMenu* chartMenu = new ChartPlotMenu(this); + AddMenuWidget("simu_manager", tr("simu manager"), chartMenu); PlayManagerMenu* playMenu = new PlayManagerMenu(this); AddMenuWidget("play_manager", tr("play manager"), playMenu); - ChartPlotMenu *chartMenu = new ChartPlotMenu(this); - AddMenuWidget("simu_manager", tr("simu manager"), chartMenu); + SystemManagerMenu* system_ = new SystemManagerMenu(this); + AddMenuWidget("system_manager", tr("system manager"), system_); MainWindow* mainWindow = new MainWindow(this); layout->addWidget(mainWindow); diff --git a/src/ui/ModelBrowser/ModelBrowserPannal.ui b/src/ui/ModelBrowser/ModelBrowserPannal.ui index cf239814..7c0694ab 100644 --- a/src/ui/ModelBrowser/ModelBrowserPannal.ui +++ b/src/ui/ModelBrowser/ModelBrowserPannal.ui @@ -22,16 +22,6 @@ false - - - 新建列 - - - - - 新建项目 - - diff --git a/src/ui/WorkSpace/WorkSpaceDlg.cpp b/src/ui/WorkSpace/WorkSpaceDlg.cpp index 5b83447a..7e29d9af 100644 --- a/src/ui/WorkSpace/WorkSpaceDlg.cpp +++ b/src/ui/WorkSpace/WorkSpaceDlg.cpp @@ -5,6 +5,7 @@ #include "ui/FrameTitleBar.h" +#include "app/Application.h" #include "common/SpdLogger.h" #include "workspace/WorkSpace.h" #include "workspace/WorkSpaceManager.h" @@ -25,6 +26,8 @@ WorkSpaceDlg::WorkSpaceDlg(QWidget* parent) SetTitle(tr("new workspace")); + const QString path = qApp->applicationDirPath() + "/workspace"; + ui->lePath->setText(path); //setFixedHeight(500); } @@ -58,7 +61,6 @@ void WorkSpaceDlg::OnSure() { current->Unlaod(); } - QString workspacePath = QString("%1/%2").arg(savePath).arg(name); QDir dir(workspacePath); if (dir.exists()) { @@ -104,7 +106,9 @@ void WorkSpaceDlg::OnSure() { } void WorkSpaceDlg::OnSelectSavePath() { - const QString savePath = QFileDialog::getExistingDirectory(this, tr("save spaceWork directory")); + const QString workspacePath = Application::GetWorkSpacePath(); + const QString savePath = QFileDialog::getExistingDirectory(this, + tr("save spaceWork directory"), workspacePath, QFileDialog::DontResolveSymlinks); if (savePath.isEmpty()) { LOG_WARN("save path is empty"); return; diff --git a/src/utils/TransformPath.cpp b/src/utils/TransformPath.cpp index 9092ed34..74541fe6 100644 --- a/src/utils/TransformPath.cpp +++ b/src/utils/TransformPath.cpp @@ -26,7 +26,7 @@ TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent) if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { LOG_WARN("Cannot open file for reading: path:{} error:{}", - path.toStdString(), file.errorString().toStdString()); + path.toLocal8Bit().constData(), file.errorString().toLocal8Bit().constData()); return nullptr; } diff --git a/src/viewer/QtOsgViewWidget.cpp b/src/viewer/QtOsgViewWidget.cpp index 68fbb22a..190f45d3 100644 --- a/src/viewer/QtOsgViewWidget.cpp +++ b/src/viewer/QtOsgViewWidget.cpp @@ -118,14 +118,17 @@ void QtOsgViewWidget::Uninitialize(void) { void QtOsgViewWidget::LoadDefaultScene(void) { dyt_check(nullptr != activeScene_); - WorkSpaceManager::Get().LoadDefaultWorkspace(activeScene_); + if (nullptr == WorkSpaceManager::Get().LoadDefaultWorkspace(activeScene_)) { + LOG_ERROR("load default workspace failed"); + QMessageBox::warning(this, tr("warning"), tr("default workspace failed")); + } } void QtOsgViewWidget::OnLoadDyt(const QString& path) { LOG_INFO("load dyt path:{}", path.toStdString()); WorkSpace* workSpace = WorkSpaceManager::Get().LoadDyt(path); if (nullptr == workSpace) { - QMessageBox::warning(&MainFrame::Get(), tr("notify"), tr("open dyt file failed"), QMessageBox::Ok); + QMessageBox::warning(&MainFrame::Get(), tr("warning"), tr("open dyt file failed"), QMessageBox::Ok); return; } diff --git a/src/workspace/WorkSpace.cpp b/src/workspace/WorkSpace.cpp index d73a4d49..677410a3 100644 --- a/src/workspace/WorkSpace.cpp +++ b/src/workspace/WorkSpace.cpp @@ -114,10 +114,12 @@ bool WorkSpace::Load(const QString& dyt) { LOG_INFO("dyt {} loaded", dyt.toStdString()); return true; } + LOG_INFO("dyt {} loading", dyt.toLocal8Bit().constData()); + path_ = dyt; WorkSpaceXMLParse parse(this); bool success = parse.Load(dyt); - if (success) { - path_ = dyt; + if (!success) { + path_ = ""; } leaded_ = success; return success; diff --git a/src/workspace/WorkSpaceManager.cpp b/src/workspace/WorkSpaceManager.cpp index 9c9806f1..fc3b1a22 100644 --- a/src/workspace/WorkSpaceManager.cpp +++ b/src/workspace/WorkSpaceManager.cpp @@ -2,7 +2,9 @@ #include #include +#include +#include "app/Application.h" #include "workspace/WorkSpace.h" #include "workspace/Timestep.h" #include "common/SpdLogger.h" @@ -31,12 +33,25 @@ WorkSpace* WorkSpaceManager::LoadDefaultWorkspace(class OEScene* secen) { } QSettings settings(iniFile, QSettings::IniFormat); - const QString path = settings.value("workspace/path", "").toString(); + QString path = settings.value("workspace/name", "").toString(); if (path.isEmpty()) { LOG_ERROR("default workspace path is empty"); return nullptr; } - WorkSpace* workspace = LoadDyt(path); + LOG_INFO("load default workspace name:{}", path.toLocal8Bit().constData()); + + WorkSpace* workspace = nullptr; + + const QString workspaceDir = Application::GetWorkSpacePath(); + QFileInfo fileInfo(path); + QString newPath = QString("%1/%2/%3").arg(workspaceDir).arg(fileInfo.baseName()).arg(fileInfo.fileName()); + QFileInfo newFileInfo(newPath); + if (newFileInfo.exists()) { + workspace = LoadDyt(newPath); + } else { + newPath = QString("%1/%2").arg(workspaceDir).arg(fileInfo.fileName()); + workspace = LoadDyt(newPath); + } if (nullptr == workspace) { LOG_ERROR("load default workspace failed"); return nullptr; @@ -60,9 +75,11 @@ void WorkSpaceManager::SaveDefaultWorkspace() { } current->Save(); - const QString path = current->GetPath(); + QString path = current->GetPath(); + QFileInfo fileInfo(path); + LOG_INFO("save default workspace name:{}", fileInfo.fileName().toLocal8Bit().constData()); QSettings settings(iniFile, QSettings::IniFormat); - settings.setValue("workspace/path", path); + settings.setValue("workspace/name", fileInfo.fileName()); } bool WorkSpaceManager::Contains(const QString& name) const { @@ -90,6 +107,7 @@ bool WorkSpaceManager::Remove(const QString& name) { WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) { dyt_check(nullptr != scene_); + LOG_INFO("load workspace name:{}", dyt.toLocal8Bit().constData()); WorkSpace* workspace = new WorkSpace(this); workspace->SetActiveScene(scene_); if (!workspace->Load(dyt)) {