diff --git a/src/entities/Component.cpp b/src/entities/Component.cpp
index 0a2ebf62..95c4d313 100644
--- a/src/entities/Component.cpp
+++ b/src/entities/Component.cpp
@@ -8,8 +8,12 @@
#include "entities/Entity.h"
-Component::Component(QObject* parent)
+Component::Component(Component* parent)
: QObject(parent) {
+ if (nullptr != parent) {
+ owner_ = parent->owner_;
+ }
+
uuid_ = QUuid::createUuid().toString();
}
diff --git a/src/entities/Component.h b/src/entities/Component.h
index 80c5fa46..86b79329 100644
--- a/src/entities/Component.h
+++ b/src/entities/Component.h
@@ -10,7 +10,7 @@ class Component : public QObject {
Q_OBJECT
public:
- explicit Component(QObject* parent = nullptr);
+ explicit Component(Component* parent = nullptr);
virtual ~Component();
virtual void Serialize(const tinyxml2::XMLElement* element);
diff --git a/src/entities/EntitiesManager.cpp b/src/entities/EntitiesManager.cpp
index 286b41aa..11a56260 100644
--- a/src/entities/EntitiesManager.cpp
+++ b/src/entities/EntitiesManager.cpp
@@ -28,7 +28,7 @@ void EntitiesManager::OnDestory() {
);
for (auto* entity : entities) {
RemoveEntity(entity);
- delete entity;
+ entity->deleteLater();
}
}
@@ -70,9 +70,9 @@ bool EntitiesManager::Parse(const tinyxml2::XMLElement* element, WorkSpace* work
}
Entity* EntitiesManager::Create(const QString& name) {
- if (name == "Entity") {
+ /* if (name == "Entity") {
return new Entity(this);
- }
+ }*/
return nullptr;
}
@@ -82,7 +82,7 @@ Entity* EntitiesManager::Create(const tinyxml2::XMLElement* element, Entity* par
return nullptr;
}
- Entity* entity = new Entity(this);
+ Entity* entity = new Entity(workspce);
if (nullptr == entity) {
LOG_WARN("create entity failed");
return nullptr;
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index bc8f329b..337e1676 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -9,8 +9,9 @@
#include "workspace/WorkSpace.h"
-Entity::Entity(QObject* parent)
- : QObject(parent) {
+Entity::Entity(WorkSpace* workspace)
+ : QObject(workspace)
+ , workspace_(workspace) {
Init();
}
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index 78eb8425..4ee236ff 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -11,7 +11,7 @@ class Entity : public QObject {
Q_OBJECT
public:
- explicit Entity(QObject* parent = nullptr);
+ explicit Entity(class WorkSpace* workspace);
explicit Entity(const QString& name, QObject* parent = nullptr);
~Entity();
diff --git a/src/entities/PathComponent.cpp b/src/entities/PathComponent.cpp
index 052095c5..0d14d9be 100644
--- a/src/entities/PathComponent.cpp
+++ b/src/entities/PathComponent.cpp
@@ -108,21 +108,16 @@ void PathComponent::Update(double dt) {
}
void PathComponent::SetPath(const QString& path) {
+ if (path == path_ || path.isEmpty()) {
+ LOG_INFO("path is the same, file:{}", path.toLocal8Bit().constData());
+ return;
+ }
if (nullptr != transformPath_) {
transformPath_->deleteLater();
}
const QString workPath = GetEntity()->GetWorkspace()->GetDir();
- QFileInfo fileInfo(path);
- const QString filePath = QString("%1/%2").arg(workPath).arg(fileInfo.fileName());
- if (!FileUtils::CopyFileToPath(path, filePath, true)) {
- LOG_ERROR("PathComponent::SetPath: 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());
-
-
+ const QString filePath = QString("%1/%2").arg(workPath).arg(path);
transformPath_ = TransformPath::LoadFromFile(filePath, this);
path_ = path;
}
diff --git a/src/translations/Dyt_zh_CN.ts b/src/translations/Dyt_zh_CN.ts
index f4dbcaaf..1e032312 100644
--- a/src/translations/Dyt_zh_CN.ts
+++ b/src/translations/Dyt_zh_CN.ts
@@ -96,39 +96,51 @@
+ Run Simu
+
+
+
2D Curver
- 2D
+ 2D
-
2D(lg) Curver
- 2D(lg)
+ 2D(lg)
-
3D Curver
- 3D
+ 3D
CodeEdtUI
-
+
&file
文件(&f)
-
- &Import the template
+
+ &Import the Main template
-
+
+ &Import the LD template
+
+
+
+
+ &Import the SeekerSim template
+
+
+
+
&save
-
+
matlab editor
@@ -475,6 +487,11 @@
file manager
文件
+
+
+ simu manager
+
+
view manager
视图管理
@@ -849,12 +866,12 @@
QFilePathEdit
-
+
Open File
-
+
All Files (*)
@@ -900,15 +917,15 @@
QtBoolEdit
-
-
-
+
+
+
True
-
-
+
+
False
@@ -1012,97 +1029,97 @@
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
@@ -1334,12 +1351,12 @@
QtPropertyBrowserUtils
-
+
[%1, %2, %3] (%4)
-
+
[%1, %2]
@@ -1573,6 +1590,14 @@
+
+ SimuRunMenuClass
+
+
+ SimuRunMenu
+
+
+
SurfaceDialog
diff --git a/src/ui/PropertyBrowser/qtpropertybrowserutils.cpp b/src/ui/PropertyBrowser/qtpropertybrowserutils.cpp
index 5138f16e..b2d25da7 100644
--- a/src/ui/PropertyBrowser/qtpropertybrowserutils.cpp
+++ b/src/ui/PropertyBrowser/qtpropertybrowserutils.cpp
@@ -47,6 +47,11 @@
#include
#include
#include
+#include
+
+#include "workspace/WorkSpace.h"
+#include "workspace/WorkSpaceManager.h"
+#include "utils/FileUtils.h"
QT_BEGIN_NAMESPACE
@@ -733,8 +738,26 @@ void QFilePathEdit::onFileSelect() {
QString filePath = QFileDialog::getOpenFileName(this, tr("Open File"), m_initialvalue, tr("All Files (*)"));
if (!filePath.isEmpty()) {
m_fileName = QFileInfo(filePath).fileName();
- m_initialvalue = filePath;
- m_stringEdit->setText(filePath);
+ WorkSpace* workSpace = WorkSpaceManager::Get().GetCurrent();
+ dyt_check(nullptr != workSpace);
+
+ const QString workPath = workSpace->GetDir();
+ const QString savePath = QString("%1/%2").arg(workPath).arg(m_fileName);
+ if (FileUtils::IsExist(savePath)) {
+ int ret = QMessageBox::question(this, "question", "File already exists, override it?", QMessageBox::Yes | QMessageBox::No);
+ if (QMessageBox::No == ret) {
+ LOG_INFO("user cancel");
+ return;
+ }
+ }
+ if (!FileUtils::CopyFileToPath(filePath, filePath, 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());
+ m_initialvalue = m_fileName;
+ m_stringEdit->setText(m_fileName);
}
}
diff --git a/src/utils/FileUtils.cpp b/src/utils/FileUtils.cpp
index 78a6094f..5f475214 100644
--- a/src/utils/FileUtils.cpp
+++ b/src/utils/FileUtils.cpp
@@ -6,6 +6,10 @@
#include "common/SpdLogger.h"
+bool FileUtils::IsExist(const QString& filePath) {
+ return QFile::exists(filePath);
+}
+
bool FileUtils::CopyFileToPath(const QString& sourceDir, QString toDir, bool coverFileIfExist) {
toDir.replace("\\", "/");
LOG_INFO("copy file from {} to {}", sourceDir.toStdString(), toDir.toStdString());
diff --git a/src/utils/FileUtils.h b/src/utils/FileUtils.h
index 2b6d1a86..721a669e 100644
--- a/src/utils/FileUtils.h
+++ b/src/utils/FileUtils.h
@@ -5,5 +5,6 @@
class FileUtils {
public:
+ static bool IsExist(const QString& filePath);
static bool CopyFileToPath(const QString& sourceDir, QString toDir, bool coverFileIfExist);
};
\ No newline at end of file
diff --git a/src/workspace/WorkSpaceManager.cpp b/src/workspace/WorkSpaceManager.cpp
index b8190f4f..9c9806f1 100644
--- a/src/workspace/WorkSpaceManager.cpp
+++ b/src/workspace/WorkSpaceManager.cpp
@@ -89,7 +89,9 @@ bool WorkSpaceManager::Remove(const QString& name) {
}
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) {
+ dyt_check(nullptr != scene_);
WorkSpace* workspace = new WorkSpace(this);
+ workspace->SetActiveScene(scene_);
if (!workspace->Load(dyt)) {
LOG_WARN("load workspace failed");
workspace->deleteLater();