modiyf workspace creat and save, set timestep bug
This commit is contained in:
parent
ca5df0f018
commit
74f4d658d1
@ -103,7 +103,7 @@ INCLUDE_DIRECTORIES(
|
|||||||
|
|
||||||
if(MSVC)
|
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")
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
|
||||||
|
|
||||||
foreach(var
|
foreach(var
|
||||||
@ -185,7 +185,7 @@ endif()
|
|||||||
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ProjectDIR}/bin)
|
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ProjectDIR}/bin)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME})
|
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}
|
add_custom_command(TARGET ${PROJECT_NAME}
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
|
@ -10,10 +10,12 @@
|
|||||||
#include <osg/Shader>
|
#include <osg/Shader>
|
||||||
#include <osg/Program>
|
#include <osg/Program>
|
||||||
#include <osg/Uniform>
|
#include <osg/Uniform>
|
||||||
|
#include <osg/Depth>
|
||||||
|
#include <osgEarth/Registry>
|
||||||
|
|
||||||
|
|
||||||
ConeWave::ConeWave() {
|
ConeWave::ConeWave() {
|
||||||
|
osgEarth::Registry::shaderGenerator().run(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -27,6 +29,10 @@ void ConeWave::Render(double dt) {
|
|||||||
|
|
||||||
void ConeWave::InitGeode() {
|
void ConeWave::InitGeode() {
|
||||||
CreateTexturedCone(this);
|
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() {
|
void ConeWave::Destory() {
|
||||||
@ -76,7 +82,15 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) {
|
|||||||
tesselate->setCreateBottom(false);
|
tesselate->setCreateBottom(false);
|
||||||
tesselate->setCreateBackFace(false);
|
tesselate->setCreateBackFace(false);
|
||||||
coneDrawable_ = new osg::ShapeDrawable(cone_, tesselate);
|
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<osg::BlendFunc> bf = new osg::BlendFunc();
|
||||||
|
//ss->setAttributeAndModes(bf, osg::StateAttribute::ON);
|
||||||
|
//ss->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||||
|
//return;
|
||||||
|
|
||||||
static const char* vertSource = {
|
static const char* vertSource = {
|
||||||
"varying vec3 pos;\n"
|
"varying vec3 pos;\n"
|
||||||
@ -128,6 +142,7 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) {
|
|||||||
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||||
stateset->addUniform(baseColorUniform_);
|
stateset->addUniform(baseColorUniform_);
|
||||||
stateset->setAttributeAndModes(program, osg::StateAttribute::ON);
|
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_));
|
levelCountUniform_ = new osg::Uniform("num", float(levelCount_));
|
||||||
levelHeightUniform_ = new osg::Uniform("height", levelHeight_);
|
levelHeightUniform_ = new osg::Uniform("height", levelHeight_);
|
||||||
|
@ -67,7 +67,7 @@ void PathComponent::Begin() {
|
|||||||
int num = std::min(steps.size(), transforms.size());
|
int num = std::min(steps.size(), transforms.size());
|
||||||
for (int index = 0; index < num; ++index) {
|
for (int index = 0; index < num; ++index) {
|
||||||
const Transform& transform = transforms[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());
|
OsgUtils::HPRToQuat(transform.GetRotation() + osg::Vec3(0, 0, -90.0)), transform.GetScale());
|
||||||
animationPath_->insert(steps[index], controlPoint);
|
animationPath_->insert(steps[index], controlPoint);
|
||||||
}
|
}
|
||||||
|
@ -63,13 +63,11 @@ void OEScene::AttachView(OsgView* view) {
|
|||||||
view->GetView()->setSceneData(root_);
|
view->GetView()->setSceneData(root_);
|
||||||
|
|
||||||
earthRootNode_ = osgDB::readNodeFile("triton.earth");
|
earthRootNode_ = osgDB::readNodeFile("triton.earth");
|
||||||
if (!earthRootNode_) {
|
dyt_check(nullptr != earthRootNode_);
|
||||||
LOG_ERROR("read earth node(triton.earth) failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
logarithmicDepthBuffer_ = std::make_unique<osgEarth::Util::LogarithmicDepthBuffer>();
|
logarithmicDepthBuffer_ = std::make_unique<osgEarth::Util::LogarithmicDepthBuffer>();
|
||||||
|
|
||||||
earthMapNode_ = osgEarth::MapNode::get(earthRootNode_);
|
earthMapNode_ = osgEarth::MapNode::get(earthRootNode_);
|
||||||
|
dyt_check(nullptr != earthMapNode_);
|
||||||
LOG_INFO("earth map node get success: {}", earthMapNode_.valid());
|
LOG_INFO("earth map node get success: {}", earthMapNode_.valid());
|
||||||
g_srs_ = earthMapNode_->getMapSRS();
|
g_srs_ = earthMapNode_->getMapSRS();
|
||||||
|
|
||||||
|
Binary file not shown.
@ -369,25 +369,28 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="44"/>
|
<location filename="../ui/Menu/FileManagerMenu.cpp" line="45"/>
|
||||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="60"/>
|
|
||||||
<source>Dyt (*.dyt)</source>
|
<source>Dyt (*.dyt)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="47"/>
|
<location filename="../ui/Menu/FileManagerMenu.cpp" line="48"/>
|
||||||
<source>open dyt file</source>
|
<source>open dyt file</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="48"/>
|
<location filename="../ui/Menu/FileManagerMenu.cpp" line="49"/>
|
||||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="64"/>
|
|
||||||
<source>Dyt (*.dyt);;All files (*.*)</source>
|
<source>Dyt (*.dyt);;All files (*.*)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="63"/>
|
<location filename="../ui/Menu/FileManagerMenu.cpp" line="65"/>
|
||||||
<source>save dyt file</source>
|
<source>warning</source>
|
||||||
|
<translation type="unfinished">警告</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/Menu/FileManagerMenu.cpp" line="65"/>
|
||||||
|
<source>workspace is nullptr</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
@ -1297,7 +1300,7 @@
|
|||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8683"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8683"/>
|
||||||
<source>Path</source>
|
<source>Path</source>
|
||||||
<translation type="unfinished">路径</translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
@ -1516,12 +1519,12 @@
|
|||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="454"/>
|
<location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="454"/>
|
||||||
<source>Property</source>
|
<source>Property</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation>属性</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="455"/>
|
<location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="455"/>
|
||||||
<source>Value</source>
|
<source>Value</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation>值</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
@ -1764,53 +1767,51 @@
|
|||||||
<translation>新建空间</translation>
|
<translation>新建空间</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="52"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="58"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="63"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="68"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="75"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="80"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="84"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="89"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="90"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="95"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="100"/>
|
|
||||||
<source>warning</source>
|
<source>warning</source>
|
||||||
<translation>警告</translation>
|
<translation>警告</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="52"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
|
||||||
<source>name or save path is empty, please check it</source>
|
<source>name or save path is empty, please check it</source>
|
||||||
<translation>名称或者路径为空</translation>
|
<translation>名称或者路径为空</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="58"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="63"/>
|
||||||
<source>save current workspace?</source>
|
<source>save current workspace?</source>
|
||||||
<translation>保存当前空间?</translation>
|
<translation>保存当前空间?</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="68"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
||||||
<source>current path is contains current folder, do you want to overwrite it?</source>
|
<source>current path is contains current folder, do you want to overwrite it?</source>
|
||||||
<translation>当前空间已存在,是否替换?</translation>
|
<translation>当前空间已存在,是否替换?</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="75"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="80"/>
|
||||||
<source>removeRecursively failed</source>
|
<source>removeRecursively failed</source>
|
||||||
<translation>删除失败</translation>
|
<translation>删除失败</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="84"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="89"/>
|
||||||
<source>mkpath failed</source>
|
<source>mkpath failed</source>
|
||||||
<translation>创建路径失败</translation>
|
<translation>创建路径失败</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="90"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="95"/>
|
||||||
<source>name is exits</source>
|
<source>name is exits</source>
|
||||||
<translation>名称已存在</translation>
|
<translation>名称已存在</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="100"/>
|
|
||||||
<source>create workSpace failed</source>
|
<source>create workSpace failed</source>
|
||||||
<translation>创建空间失败</translation>
|
<translation type="vanished">创建空间失败</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="111"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="110"/>
|
||||||
<source>save spaceWork directory</source>
|
<source>save spaceWork directory</source>
|
||||||
<translation>保存空间目录</translation>
|
<translation>保存空间目录</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
#include "workspace/WorkSpace.h"
|
#include "workspace/WorkSpace.h"
|
||||||
#include "workspace/WorkSpaceManager.h"
|
#include "workspace/WorkSpaceManager.h"
|
||||||
|
#include "utils/FileUtils.h"
|
||||||
|
|
||||||
#include "ui_FileManagerMenu.h"
|
#include "ui_FileManagerMenu.h"
|
||||||
|
|
||||||
@ -57,23 +58,31 @@ void FileManagerMenu::OpenWorkSpace() {
|
|||||||
|
|
||||||
void FileManagerMenu::SaveWorkSpace() {
|
void FileManagerMenu::SaveWorkSpace() {
|
||||||
LOG_INFO("click 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();
|
WorkSpace* workspace = WorkSpaceManager::Get().GetCurrent();
|
||||||
if (nullptr == workspace) {
|
if (nullptr == workspace) {
|
||||||
LOG_WARN("workspace is nullptr");
|
LOG_WARN("workspace is nullptr");
|
||||||
|
QMessageBox::warning(&MainFrame::Get(), tr("warning"), tr("workspace is nullptr"));
|
||||||
return;
|
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);
|
bool success = workspace->Save(dytFile);
|
||||||
LOG_INFO("save dyt: {}", success);
|
LOG_INFO("save dyt: {}", success);
|
||||||
}
|
}
|
||||||
|
@ -751,12 +751,12 @@ void QFilePathEdit::onFileSelect() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!FileUtils::CopyFileToPath(filePath, filePath, true)) {
|
if (!FileUtils::CopyFileToPath(filePath, savePath, true)) {
|
||||||
LOG_ERROR("Failed to copy file to workspace");
|
LOG_ERROR("Failed to copy file to workspace");
|
||||||
QMessageBox::critical(nullptr, "Error", "Failed to copy file to workspace");
|
QMessageBox::critical(nullptr, "Error", "Failed to copy file to workspace");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG_INFO("PathComponent::SetPath: {}", workPath.toStdString().c_str());
|
LOG_INFO("SetPath: {}", savePath.toLocal8Bit().constData());
|
||||||
m_initialvalue = m_fileName;
|
m_initialvalue = m_fileName;
|
||||||
m_stringEdit->setText(m_fileName);
|
m_stringEdit->setText(m_fileName);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ WorkSpaceDlg::WorkSpaceDlg(QWidget* parent)
|
|||||||
|
|
||||||
SetTitle(tr("new workspace"));
|
SetTitle(tr("new workspace"));
|
||||||
|
|
||||||
const QString path = qApp->applicationDirPath() + "/workspace";
|
path_ = qApp->applicationDirPath() + "/workspace";
|
||||||
ui->lePath->setText(path);
|
ui->lePath->setText(path_);
|
||||||
//setFixedHeight(500);
|
//setFixedHeight(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,15 +39,20 @@ void WorkSpaceDlg::InitConnect() {
|
|||||||
connect(ui->pbSure, &QPushButton::clicked, this, &WorkSpaceDlg::OnSure);
|
connect(ui->pbSure, &QPushButton::clicked, this, &WorkSpaceDlg::OnSure);
|
||||||
connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject);
|
connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject);
|
||||||
connect(ui->tbPath, &QPushButton::clicked, this, &WorkSpaceDlg::OnSelectSavePath);
|
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);
|
//connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkSpaceDlg::OnSure() {
|
void WorkSpaceDlg::OnSure() {
|
||||||
const QString name = ui->leName->text();
|
const QString name = ui->leName->text();
|
||||||
const QString savePath = ui->lePath->text();
|
|
||||||
|
|
||||||
LOG_INFO("name:{}, save path:{}", name.toStdString(), savePath.toStdString());
|
LOG_INFO("name:{}, save path:{}", name.toLocal8Bit().constData(), path_.toLocal8Bit().constData());
|
||||||
if (name.isEmpty() || savePath.isEmpty()) {
|
if (name.isEmpty() || path_.isEmpty()) {
|
||||||
LOG_WARN("name or save path is empty");
|
LOG_WARN("name or save path is empty");
|
||||||
QMessageBox::warning(this, tr("warning"), tr("name or save path is empty, please check it"));
|
QMessageBox::warning(this, tr("warning"), tr("name or save path is empty, please check it"));
|
||||||
return;
|
return;
|
||||||
@ -61,7 +66,7 @@ void WorkSpaceDlg::OnSure() {
|
|||||||
current->Unlaod();
|
current->Unlaod();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString workspacePath = QString("%1/%2").arg(savePath).arg(name);
|
QString workspacePath = QString("%1/%2").arg(path_).arg(name);
|
||||||
QDir dir(workspacePath);
|
QDir dir(workspacePath);
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
LOG_WARN("current path is contains current folder, {}", workspacePath.toStdString());
|
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* workSpace = WorkSpaceManager::Get().GetOrCreate(workspacePath, name);
|
||||||
workSpace->SetDescribe(ui->etDescribe->toPlainText());
|
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);
|
WorkSpaceManager::Get().SetCurrent(workSpace);
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
@ -113,9 +112,9 @@ void WorkSpaceDlg::OnSelectSavePath() {
|
|||||||
LOG_WARN("save path is empty");
|
LOG_WARN("save path is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
path_ = savePath;
|
||||||
ui->lePath->setText(savePath);
|
ui->lePath->setText(QString("%1/%2").arg(path_).arg(ui->leName->text()));
|
||||||
LOG_INFO("save path: {}", savePath.toStdString());
|
LOG_INFO("save path: {}", path_.toLocal8Bit().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkSpaceDlg::InitFrame() {
|
void WorkSpaceDlg::InitFrame() {
|
||||||
|
@ -23,4 +23,5 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::WorkSpaceDlg* ui;
|
Ui::WorkSpaceDlg* ui;
|
||||||
|
QString path_;
|
||||||
};
|
};
|
@ -22,6 +22,7 @@ TransformPath::~TransformPath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent) {
|
TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent) {
|
||||||
|
LOG_INFO("Loading transform path from file: {}", path.toLocal8Bit().constData());
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
@ -42,7 +43,7 @@ TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent)
|
|||||||
bool ok;
|
bool ok;
|
||||||
double value = line.toDouble(&ok);
|
double value = line.toDouble(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
transform.GetLocation()[i] = value * 1.5;
|
transform.GetLocation()[i] = value;
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("Failed to convert line to double: {}", line.toStdString());
|
LOG_WARN("Failed to convert line to double: {}", line.toStdString());
|
||||||
return {};
|
return {};
|
||||||
|
@ -16,13 +16,13 @@ Timestep::Timestep(const std::vector<double>& steps, const QString& path, WorkSp
|
|||||||
maxTime_ = *steps_.rbegin();
|
maxTime_ = *steps_.rbegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestep* Timestep::Load(const QString& path, WorkSpace* parent) {
|
Timestep* Timestep::Load(const QString& path, WorkSpace* workSpace) {
|
||||||
const QString filePath = QString("%1/%2").arg(RecourceHelper::Get().GetBasePath()).arg(path);
|
const QString filePath = QString("%1/%2").arg(workSpace->GetDir()).arg(path);
|
||||||
LOG_INFO("Load timestep: {}", filePath.toStdString());
|
LOG_INFO("Load timestep: {}", filePath.toStdString());
|
||||||
|
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ Timestep* Timestep::Load(const QString& path, WorkSpace* parent) {
|
|||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
Timestep* timestep = new Timestep(numbers, path, parent);
|
Timestep* timestep = new Timestep(numbers, path, workSpace);
|
||||||
return timestep;
|
return timestep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
explicit Timestep(const std::vector<double>& steps, const QString& path, WorkSpace* parent = nullptr) noexcept;
|
explicit Timestep(const std::vector<double>& steps, const QString& path, WorkSpace* parent = nullptr) noexcept;
|
||||||
~Timestep() override = default;
|
~Timestep() override = default;
|
||||||
|
|
||||||
static Timestep* Load(const QString& path, WorkSpace* parent = nullptr);
|
static Timestep* Load(const QString& path, WorkSpace* workSpace = nullptr);
|
||||||
|
|
||||||
const std::vector<double>& GetSteps() const {
|
const std::vector<double>& GetSteps() const {
|
||||||
return steps_;
|
return steps_;
|
||||||
|
@ -105,6 +105,19 @@ bool WorkSpaceManager::Remove(const QString& name) {
|
|||||||
return true;
|
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) {
|
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) {
|
||||||
dyt_check(nullptr != scene_);
|
dyt_check(nullptr != scene_);
|
||||||
LOG_INFO("load workspace name:{}", dyt.toLocal8Bit().constData());
|
LOG_INFO("load workspace name:{}", dyt.toLocal8Bit().constData());
|
||||||
@ -126,7 +139,7 @@ WorkSpace* WorkSpaceManager::GetOrCreate(const QString& path, const QString& nam
|
|||||||
return itor->second;
|
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* workspace = new WorkSpace(path, this);
|
||||||
workspace->SetName(name);
|
workspace->SetName(name);
|
||||||
workSpaces_[path] = workspace;
|
workSpaces_[path] = workspace;
|
||||||
|
@ -26,6 +26,7 @@ public:
|
|||||||
bool Remove(const QString& name);
|
bool Remove(const QString& name);
|
||||||
WorkSpace* LoadDyt(const QString& dyt);
|
WorkSpace* LoadDyt(const QString& dyt);
|
||||||
WorkSpace* GetOrCreate(const QString& path, const QString& name);
|
WorkSpace* GetOrCreate(const QString& path, const QString& name);
|
||||||
|
bool Remove(WorkSpace* workspace);
|
||||||
void SetCurrent(WorkSpace* workspace);
|
void SetCurrent(WorkSpace* workspace);
|
||||||
WorkSpace* GetCurrent() const { return current_; }
|
WorkSpace* GetCurrent() const { return current_; }
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ bool WorkSpaceXMLParse::ParseReport(const tinyxml2::XMLElement* element)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WorkSpaceXMLParse::Load(const QString& dyt) {
|
bool WorkSpaceXMLParse::Load(const QString& dyt) {
|
||||||
std::string path = dyt.toStdString();
|
std::string path = dyt.toLocal8Bit().constData();
|
||||||
LOG_INFO("load path:{}", path);
|
LOG_INFO("load path:{}", path);
|
||||||
tinyxml2::XMLDocument xmlDocument;
|
tinyxml2::XMLDocument xmlDocument;
|
||||||
tinyxml2::XMLError error = xmlDocument.LoadFile(path.c_str());
|
tinyxml2::XMLError error = xmlDocument.LoadFile(path.c_str());
|
||||||
|
@ -16,7 +16,7 @@ WorkSpaceXMLWrite::WorkSpaceXMLWrite(WorkSpace* workspace, QObject* parent) noex
|
|||||||
, workSpace_(workspace) {}
|
, workSpace_(workspace) {}
|
||||||
|
|
||||||
bool WorkSpaceXMLWrite::Save(const QString& path) {
|
bool WorkSpaceXMLWrite::Save(const QString& path) {
|
||||||
LOG_INFO("save path: {}", path.toStdString());
|
LOG_INFO("save path: {}", path.toLocal8Bit().constData());
|
||||||
if (nullptr == workSpace_) {
|
if (nullptr == workSpace_) {
|
||||||
LOG_WARN("worksapce is nullptr");
|
LOG_WARN("worksapce is nullptr");
|
||||||
return false;
|
return false;
|
||||||
@ -41,7 +41,7 @@ bool WorkSpaceXMLWrite::Save(const QString& path) {
|
|||||||
entity->UnSerialize(entitiesXml);
|
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) {
|
if (tinyxml2::XML_SUCCESS != xmlError) {
|
||||||
LOG_WARN("worksapce is nullptr");
|
LOG_WARN("worksapce is nullptr");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user