modify workspace
This commit is contained in:
parent
6b9d56a3cf
commit
8b94963f39
@ -125,6 +125,7 @@ void Entity::End() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entity::Destory() {
|
void Entity::Destory() {
|
||||||
|
LOG_INFO("destory entity, {}", name_.toLocal8Bit().constData());
|
||||||
if (nullptr == workspace_) {
|
if (nullptr == workspace_) {
|
||||||
LOG_WARN("workspace is nullptr");
|
LOG_WARN("workspace is nullptr");
|
||||||
return;
|
return;
|
||||||
|
@ -1740,11 +1740,12 @@
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="49"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="49"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="55"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="64"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="66"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="79"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="82"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="88"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="88"/>
|
||||||
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="97"/>
|
||||||
<source>warning</source>
|
<source>warning</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1754,32 +1755,37 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="55"/>
|
||||||
|
<source>save current workspace?</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="66"/>
|
||||||
<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 type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="64"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
||||||
<source>removeRecursively failed</source>
|
<source>removeRecursively failed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="82"/>
|
||||||
<source>mkpath failed</source>
|
<source>mkpath failed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="79"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="88"/>
|
||||||
<source>name is exits</source>
|
<source>name is exits</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="88"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="97"/>
|
||||||
<source>create workSpace failed</source>
|
<source>create workSpace failed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="98"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="107"/>
|
||||||
<source>save spaceWork directory</source>
|
<source>save spaceWork directory</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -293,7 +293,7 @@ bool ModelTreeWidget::RemoveItemFromParent(QTreeWidgetItem* parentItem, const QS
|
|||||||
if (uuid == itemToRemove) {
|
if (uuid == itemToRemove) {
|
||||||
while (childItem->childCount() > 0) {
|
while (childItem->childCount() > 0) {
|
||||||
QTreeWidgetItem* grandChildItem = childItem->child(0);
|
QTreeWidgetItem* grandChildItem = childItem->child(0);
|
||||||
parentItem->addChild(grandChildItem);
|
childItem->removeChild(grandChildItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
parentItem->removeChild(childItem);
|
parentItem->removeChild(childItem);
|
||||||
|
@ -50,6 +50,15 @@ void WorkSpaceDlg::OnSure() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorkSpace* current = WorkSpaceManager::Get().GetCurrent();
|
||||||
|
if (nullptr != current) {
|
||||||
|
if (QMessageBox::Yes == QMessageBox::question(this, tr("warning"), tr("save current workspace?"))) {
|
||||||
|
current->Save();
|
||||||
|
}
|
||||||
|
current->Unlaod();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString workspacePath = QString("%1/%2").arg(savePath).arg(name);
|
QString workspacePath = QString("%1/%2").arg(savePath).arg(name);
|
||||||
QDir dir(workspacePath);
|
QDir dir(workspacePath);
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
|
@ -75,7 +75,7 @@ void WorkSpace::AddEntity(Entity* entity) {
|
|||||||
LOG_WARN("entity is nullptr");
|
LOG_WARN("entity is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
LOG_INFO("add entity: {}", entity->GetName().toLocal8Bit().constData());
|
||||||
entities_.push_back(entity);
|
entities_.push_back(entity);
|
||||||
entity->SetWorkspace(this);
|
entity->SetWorkspace(this);
|
||||||
|
|
||||||
@ -158,18 +158,29 @@ bool WorkSpace::Save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WorkSpace::Load(const QString& dyt) {
|
bool WorkSpace::Load(const QString& dyt) {
|
||||||
|
if (leaded_) {
|
||||||
|
LOG_INFO("dyt {} loaded", dyt.toStdString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
WorkSpaceXMLParse parse(this);
|
WorkSpaceXMLParse parse(this);
|
||||||
bool success = parse.Load(dyt);
|
bool success = parse.Load(dyt);
|
||||||
if (success) {
|
if (success) {
|
||||||
path_ = dyt;
|
path_ = dyt;
|
||||||
}
|
}
|
||||||
|
leaded_ = success;
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkSpace::Unlaod() {
|
void WorkSpace::Unlaod() {
|
||||||
for (auto& entity : entities_) {
|
if (!leaded_) {
|
||||||
entity->End();
|
LOG_INFO("dyt {} unloaded", name_.toStdString());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
while (!entities_.empty()) {
|
||||||
|
auto entity = entities_.front();
|
||||||
|
entity->Destory();
|
||||||
|
}
|
||||||
|
leaded_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkSpace::Begin() {
|
void WorkSpace::Begin() {
|
||||||
|
@ -87,6 +87,7 @@ private:
|
|||||||
QString describe_;
|
QString describe_;
|
||||||
QString path_;
|
QString path_;
|
||||||
|
|
||||||
|
bool leaded_{ false };
|
||||||
std::vector<class Entity*> entities_;
|
std::vector<class Entity*> entities_;
|
||||||
osg::ref_ptr<OEScene> activeScene_;
|
osg::ref_ptr<OEScene> activeScene_;
|
||||||
class OsgView* view_{ nullptr };
|
class OsgView* view_{ nullptr };
|
||||||
|
@ -36,9 +36,11 @@ bool WorkSpaceManager::Remove(const QString& name) {
|
|||||||
|
|
||||||
WorkSpace* workspace = itor->second;
|
WorkSpace* workspace = itor->second;
|
||||||
if (nullptr != workspace) {
|
if (nullptr != workspace) {
|
||||||
|
workspace->Unlaod();
|
||||||
workspace->deleteLater();
|
workspace->deleteLater();
|
||||||
}
|
}
|
||||||
workSpaces_.erase(itor);
|
workSpaces_.erase(itor);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt, class OsgView* view) {
|
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt, class OsgView* view) {
|
||||||
|
Loading…
Reference in New Issue
Block a user