diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 23046735..d2b30754 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") #/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 @@ -185,7 +185,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/effects/ConeWave.cpp b/src/effects/ConeWave.cpp index 4e5ee310..60a1b6bb 100644 --- a/src/effects/ConeWave.cpp +++ b/src/effects/ConeWave.cpp @@ -10,10 +10,12 @@ #include #include #include +#include +#include ConeWave::ConeWave() { - + osgEarth::Registry::shaderGenerator().run(this); } @@ -27,6 +29,10 @@ void ConeWave::Render(double dt) { void ConeWave::InitGeode() { CreateTexturedCone(this); + //getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); + //getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); + //getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); + //setCullingActive(false); } void ConeWave::Destory() { @@ -76,7 +82,15 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) { tesselate->setCreateBottom(false); tesselate->setCreateBackFace(false); coneDrawable_ = new osg::ShapeDrawable(cone_, tesselate); - addDrawable(coneDrawable_); + geode->addDrawable(coneDrawable_); + //coneDrawable_->setColor(baseColor_); + //osg::StateSet* ss = coneDrawable_->getOrCreateStateSet(); + ////stateset->setRenderBinDetails(120, "OSGEARTH_SCREEN_SPACE_LAYOUT_BIN"); + //ss->setRenderBinDetails(120, "RenderBin"); + //osg::ref_ptr bf = new osg::BlendFunc(); + //ss->setAttributeAndModes(bf, osg::StateAttribute::ON); + //ss->setMode(GL_CULL_FACE, osg::StateAttribute::ON); + //return; static const char* vertSource = { "varying vec3 pos;\n" @@ -128,6 +142,7 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) { stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON); stateset->addUniform(baseColorUniform_); stateset->setAttributeAndModes(program, osg::StateAttribute::ON); + stateset->setAttributeAndModes(new osg::Depth(osg::Depth::LESS, 0.0, 1.0, false)); levelCountUniform_ = new osg::Uniform("num", float(levelCount_)); levelHeightUniform_ = new osg::Uniform("height", levelHeight_); diff --git a/src/entities/PathComponent.cpp b/src/entities/PathComponent.cpp index 0d14d9be..a9109a8b 100644 --- a/src/entities/PathComponent.cpp +++ b/src/entities/PathComponent.cpp @@ -67,7 +67,7 @@ void PathComponent::Begin() { int num = std::min(steps.size(), transforms.size()); for (int index = 0; index < num; ++index) { const Transform& transform = transforms[index]; - osg::AnimationPath::ControlPoint controlPoint(transform.GetLocation() + osg::Vec3(index * 10, 0, 0), + osg::AnimationPath::ControlPoint controlPoint(transform.GetLocation() /*+ osg::Vec3(index * 10, 0, 0)*/, OsgUtils::HPRToQuat(transform.GetRotation() + osg::Vec3(0, 0, -90.0)), transform.GetScale()); animationPath_->insert(steps[index], controlPoint); } diff --git a/src/scene/OEScene.cpp b/src/scene/OEScene.cpp index cc9fdd48..21e02049 100644 --- a/src/scene/OEScene.cpp +++ b/src/scene/OEScene.cpp @@ -63,13 +63,11 @@ void OEScene::AttachView(OsgView* view) { view->GetView()->setSceneData(root_); earthRootNode_ = osgDB::readNodeFile("triton.earth"); - if (!earthRootNode_) { - LOG_ERROR("read earth node(triton.earth) failed"); - return; - } + dyt_check(nullptr != earthRootNode_); logarithmicDepthBuffer_ = std::make_unique(); earthMapNode_ = osgEarth::MapNode::get(earthRootNode_); + dyt_check(nullptr != earthMapNode_); LOG_INFO("earth map node get success: {}", earthMapNode_.valid()); g_srs_ = earthMapNode_->getMapSRS(); diff --git a/src/translations/Dyt_zh_CN.qm b/src/translations/Dyt_zh_CN.qm index 9d80c80d..449ed17f 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 d28efc6e..d678dd1b 100644 --- a/src/translations/Dyt_zh_CN.ts +++ b/src/translations/Dyt_zh_CN.ts @@ -369,25 +369,28 @@ - - + Dyt (*.dyt) - + open dyt file - - + Dyt (*.dyt);;All files (*.*) - - save dyt file + + warning + 警告 + + + + workspace is nullptr @@ -1297,7 +1300,7 @@ Path - 路径 + @@ -1516,12 +1519,12 @@ Property - + 属性 Value - + @@ -1764,53 +1767,51 @@ 新建空间 - - - - - - - + + + + + + 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/ui/Menu/FileManagerMenu.cpp b/src/ui/Menu/FileManagerMenu.cpp index 1f799311..aff15399 100644 --- a/src/ui/Menu/FileManagerMenu.cpp +++ b/src/ui/Menu/FileManagerMenu.cpp @@ -12,6 +12,7 @@ #include "common/SpdLogger.h" #include "workspace/WorkSpace.h" #include "workspace/WorkSpaceManager.h" +#include "utils/FileUtils.h" #include "ui_FileManagerMenu.h" @@ -57,23 +58,31 @@ void FileManagerMenu::OpenWorkSpace() { void FileManagerMenu::SaveWorkSpace() { LOG_INFO("click SaveWorkSpace"); - QString selfilter = tr("Dyt (*.dyt)"); - - const QString workspacePath = Application::GetWorkSpacePath(); - QString dytFile = QFileDialog::getSaveFileName(&MainFrame::Get(), tr("save dyt file"), workspacePath, - tr("Dyt (*.dyt);;All files (*.*)"), - &selfilter); - LOG_INFO("user select file: {}", dytFile.toStdString()); - if (dytFile.isEmpty()) { - return; - } - + WorkSpace* workspace = WorkSpaceManager::Get().GetCurrent(); if (nullptr == workspace) { LOG_WARN("workspace is nullptr"); + QMessageBox::warning(&MainFrame::Get(), tr("warning"), tr("workspace is nullptr")); return; } + const QString name = workspace->GetName(); + QString dytFile = workspace->GetPath(); + LOG_INFO("save {} dyt file: {}", name.toLocal8Bit().constData(), + dytFile.toLocal8Bit().constData()); + /* if (!FileUtils::IsExist(dytFile)) { + QString selfilter = tr("Dyt (*.dyt)"); + const QString workspacePath = Application::GetWorkSpacePath(); + dytFile = QFileDialog::getSaveFileName(&MainFrame::Get(), tr("save dyt file"), workspacePath, + tr("Dyt (*.dyt);;All files (*.*)"), + &selfilter); + LOG_INFO("user select file: {}", dytFile.toLocal8Bit().constData()); + if (dytFile.isEmpty()) { + return; + } + + }*/ + bool success = workspace->Save(dytFile); LOG_INFO("save dyt: {}", success); } diff --git a/src/ui/PropertyBrowser/qtpropertybrowserutils.cpp b/src/ui/PropertyBrowser/qtpropertybrowserutils.cpp index 155a0f99..9dd2f476 100644 --- a/src/ui/PropertyBrowser/qtpropertybrowserutils.cpp +++ b/src/ui/PropertyBrowser/qtpropertybrowserutils.cpp @@ -751,12 +751,12 @@ void QFilePathEdit::onFileSelect() { return; } } - if (!FileUtils::CopyFileToPath(filePath, filePath, true)) { + if (!FileUtils::CopyFileToPath(filePath, savePath, true)) { LOG_ERROR("Failed to copy file to workspace"); QMessageBox::critical(nullptr, "Error", "Failed to copy file to workspace"); return; } - LOG_INFO("PathComponent::SetPath: {}", workPath.toStdString().c_str()); + LOG_INFO("SetPath: {}", savePath.toLocal8Bit().constData()); m_initialvalue = m_fileName; m_stringEdit->setText(m_fileName); } diff --git a/src/ui/WorkSpace/WorkSpaceDlg.cpp b/src/ui/WorkSpace/WorkSpaceDlg.cpp index 7e29d9af..4e74e58b 100644 --- a/src/ui/WorkSpace/WorkSpaceDlg.cpp +++ b/src/ui/WorkSpace/WorkSpaceDlg.cpp @@ -26,8 +26,8 @@ WorkSpaceDlg::WorkSpaceDlg(QWidget* parent) SetTitle(tr("new workspace")); - const QString path = qApp->applicationDirPath() + "/workspace"; - ui->lePath->setText(path); + path_ = qApp->applicationDirPath() + "/workspace"; + ui->lePath->setText(path_); //setFixedHeight(500); } @@ -39,15 +39,20 @@ void WorkSpaceDlg::InitConnect() { connect(ui->pbSure, &QPushButton::clicked, this, &WorkSpaceDlg::OnSure); connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject); connect(ui->tbPath, &QPushButton::clicked, this, &WorkSpaceDlg::OnSelectSavePath); + connect(ui->leName, &QLineEdit::textChanged, [this](const QString& txt) { + QString path = QString("%1/%2").arg(path_).arg(txt); + ui->lePath->setText(path); + } + ); + //connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject); } void WorkSpaceDlg::OnSure() { const QString name = ui->leName->text(); - const QString savePath = ui->lePath->text(); - LOG_INFO("name:{}, save path:{}", name.toStdString(), savePath.toStdString()); - if (name.isEmpty() || savePath.isEmpty()) { + LOG_INFO("name:{}, save path:{}", name.toLocal8Bit().constData(), path_.toLocal8Bit().constData()); + if (name.isEmpty() || path_.isEmpty()) { LOG_WARN("name or save path is empty"); QMessageBox::warning(this, tr("warning"), tr("name or save path is empty, please check it")); return; @@ -61,7 +66,7 @@ void WorkSpaceDlg::OnSure() { current->Unlaod(); } - QString workspacePath = QString("%1/%2").arg(savePath).arg(name); + QString workspacePath = QString("%1/%2").arg(path_).arg(name); QDir dir(workspacePath); if (dir.exists()) { LOG_WARN("current path is contains current folder, {}", workspacePath.toStdString()); @@ -95,12 +100,6 @@ void WorkSpaceDlg::OnSure() { WorkSpace* workSpace = WorkSpaceManager::Get().GetOrCreate(workspacePath, name); workSpace->SetDescribe(ui->etDescribe->toPlainText()); - if (!workSpace->Save(workspacePath)) { - LOG_ERROR("save workSpace failed"); - QMessageBox::warning(this, tr("warning"), tr("create workSpace failed")); - return; - } - WorkSpaceManager::Get().SetCurrent(workSpace); accept(); } @@ -113,9 +112,9 @@ void WorkSpaceDlg::OnSelectSavePath() { LOG_WARN("save path is empty"); return; } - - ui->lePath->setText(savePath); - LOG_INFO("save path: {}", savePath.toStdString()); + path_ = savePath; + ui->lePath->setText(QString("%1/%2").arg(path_).arg(ui->leName->text())); + LOG_INFO("save path: {}", path_.toLocal8Bit().constData()); } void WorkSpaceDlg::InitFrame() { diff --git a/src/ui/WorkSpace/WorkSpaceDlg.h b/src/ui/WorkSpace/WorkSpaceDlg.h index 19b56974..65e580b0 100644 --- a/src/ui/WorkSpace/WorkSpaceDlg.h +++ b/src/ui/WorkSpace/WorkSpaceDlg.h @@ -23,4 +23,5 @@ protected: private: Ui::WorkSpaceDlg* ui; + QString path_; }; \ No newline at end of file diff --git a/src/utils/TransformPath.cpp b/src/utils/TransformPath.cpp index 74541fe6..1cbc23f0 100644 --- a/src/utils/TransformPath.cpp +++ b/src/utils/TransformPath.cpp @@ -22,6 +22,7 @@ TransformPath::~TransformPath() { } TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent) { + LOG_INFO("Loading transform path from file: {}", path.toLocal8Bit().constData()); QFile file(path); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -42,7 +43,7 @@ TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent) bool ok; double value = line.toDouble(&ok); if (ok) { - transform.GetLocation()[i] = value * 1.5; + transform.GetLocation()[i] = value; } else { LOG_WARN("Failed to convert line to double: {}", line.toStdString()); return {}; diff --git a/src/workspace/Timestep.cpp b/src/workspace/Timestep.cpp index 867377de..233b1041 100644 --- a/src/workspace/Timestep.cpp +++ b/src/workspace/Timestep.cpp @@ -16,13 +16,13 @@ Timestep::Timestep(const std::vector& steps, const QString& path, WorkSp maxTime_ = *steps_.rbegin(); } -Timestep* Timestep::Load(const QString& path, WorkSpace* parent) { - const QString filePath = QString("%1/%2").arg(RecourceHelper::Get().GetBasePath()).arg(path); +Timestep* Timestep::Load(const QString& path, WorkSpace* workSpace) { + const QString filePath = QString("%1/%2").arg(workSpace->GetDir()).arg(path); LOG_INFO("Load timestep: {}", filePath.toStdString()); QFile file(filePath); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - LOG_WARN("Cannot open file for reading: {}", file.errorString().toStdString()); + LOG_WARN("Cannot open file for reading: {}", file.errorString().toLocal8Bit().constData()); return nullptr; } @@ -42,7 +42,7 @@ Timestep* Timestep::Load(const QString& path, WorkSpace* parent) { file.close(); - Timestep* timestep = new Timestep(numbers, path, parent); + Timestep* timestep = new Timestep(numbers, path, workSpace); return timestep; } diff --git a/src/workspace/Timestep.h b/src/workspace/Timestep.h index ec76ba7b..ba763e33 100644 --- a/src/workspace/Timestep.h +++ b/src/workspace/Timestep.h @@ -20,7 +20,7 @@ public: explicit Timestep(const std::vector& steps, const QString& path, WorkSpace* parent = nullptr) noexcept; ~Timestep() override = default; - static Timestep* Load(const QString& path, WorkSpace* parent = nullptr); + static Timestep* Load(const QString& path, WorkSpace* workSpace = nullptr); const std::vector& GetSteps() const { return steps_; diff --git a/src/workspace/WorkSpaceManager.cpp b/src/workspace/WorkSpaceManager.cpp index fc3b1a22..798f214e 100644 --- a/src/workspace/WorkSpaceManager.cpp +++ b/src/workspace/WorkSpaceManager.cpp @@ -105,6 +105,19 @@ bool WorkSpaceManager::Remove(const QString& name) { return true; } +bool WorkSpaceManager::Remove(WorkSpace* workspace) { + if (nullptr == workspace) { + LOG_ERROR("workspace is nullptr"); + return true; + } + + auto itor = workSpaces_.find(workspace->GetPath()); + if (workSpaces_.end() == itor) { + return true; + } + workSpaces_.erase(itor); +} + WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) { dyt_check(nullptr != scene_); LOG_INFO("load workspace name:{}", dyt.toLocal8Bit().constData()); @@ -126,7 +139,7 @@ WorkSpace* WorkSpaceManager::GetOrCreate(const QString& path, const QString& nam return itor->second; } - LOG_INFO("create workspace name:{}", path.toStdString()); + LOG_INFO("create workspace name:{}", path.toLocal8Bit().constData()); WorkSpace* workspace = new WorkSpace(path, this); workspace->SetName(name); workSpaces_[path] = workspace; diff --git a/src/workspace/WorkSpaceManager.h b/src/workspace/WorkSpaceManager.h index b88366f2..fe415fdf 100644 --- a/src/workspace/WorkSpaceManager.h +++ b/src/workspace/WorkSpaceManager.h @@ -26,6 +26,7 @@ public: bool Remove(const QString& name); WorkSpace* LoadDyt(const QString& dyt); WorkSpace* GetOrCreate(const QString& path, const QString& name); + bool Remove(WorkSpace* workspace); void SetCurrent(WorkSpace* workspace); WorkSpace* GetCurrent() const { return current_; } diff --git a/src/workspace/WorkSpaceXMLParse.cpp b/src/workspace/WorkSpaceXMLParse.cpp index 7a2046b2..71604656 100644 --- a/src/workspace/WorkSpaceXMLParse.cpp +++ b/src/workspace/WorkSpaceXMLParse.cpp @@ -178,7 +178,7 @@ bool WorkSpaceXMLParse::ParseReport(const tinyxml2::XMLElement* element) } bool WorkSpaceXMLParse::Load(const QString& dyt) { - std::string path = dyt.toStdString(); + std::string path = dyt.toLocal8Bit().constData(); LOG_INFO("load path:{}", path); tinyxml2::XMLDocument xmlDocument; tinyxml2::XMLError error = xmlDocument.LoadFile(path.c_str()); diff --git a/src/workspace/WorkSpaceXMLWrite.cpp b/src/workspace/WorkSpaceXMLWrite.cpp index cc80ad68..acaa67b8 100644 --- a/src/workspace/WorkSpaceXMLWrite.cpp +++ b/src/workspace/WorkSpaceXMLWrite.cpp @@ -16,7 +16,7 @@ WorkSpaceXMLWrite::WorkSpaceXMLWrite(WorkSpace* workspace, QObject* parent) noex , workSpace_(workspace) {} bool WorkSpaceXMLWrite::Save(const QString& path) { - LOG_INFO("save path: {}", path.toStdString()); + LOG_INFO("save path: {}", path.toLocal8Bit().constData()); if (nullptr == workSpace_) { LOG_WARN("worksapce is nullptr"); return false; @@ -41,7 +41,7 @@ bool WorkSpaceXMLWrite::Save(const QString& path) { entity->UnSerialize(entitiesXml); } - tinyxml2::XMLError xmlError = doc.SaveFile(path.toStdString().c_str(), false); + tinyxml2::XMLError xmlError = doc.SaveFile(path.toLocal8Bit().constData(), false); if (tinyxml2::XML_SUCCESS != xmlError) { LOG_WARN("worksapce is nullptr"); return false;