fix new workspace crash
This commit is contained in:
parent
0892fe6c6d
commit
f4bdb4473d
@ -18,6 +18,7 @@
|
|||||||
#include "common/RecourceHelper.h"
|
#include "common/RecourceHelper.h"
|
||||||
#include "scene/ScopedTimer.h"
|
#include "scene/ScopedTimer.h"
|
||||||
#include "viewer/OsgView.h"
|
#include "viewer/OsgView.h"
|
||||||
|
#include "viewer/OsgCameraManipulator.h"
|
||||||
|
|
||||||
const osgEarth::SpatialReference* g_srs_{ nullptr };
|
const osgEarth::SpatialReference* g_srs_{ nullptr };
|
||||||
|
|
||||||
|
@ -676,57 +676,57 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>ModelTreeWidget</name>
|
<name>ModelTreeWidget</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="96"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="98"/>
|
||||||
<source>Release Track</source>
|
<source>Release Track</source>
|
||||||
<translation>取消跟踪</translation>
|
<translation>取消跟踪</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="113"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="115"/>
|
||||||
<source>Add boke Entity</source>
|
<source>Add boke Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="120"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="122"/>
|
||||||
<source>Add lsjhqt Entity</source>
|
<source>Add lsjhqt Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="127"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="129"/>
|
||||||
<source>Add nimizi Entity</source>
|
<source>Add nimizi Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="134"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="136"/>
|
||||||
<source>Add tkdlj Entity</source>
|
<source>Add tkdlj Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="141"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="143"/>
|
||||||
<source>Add jiaofan Entity</source>
|
<source>Add jiaofan Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="148"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="150"/>
|
||||||
<source>Add satellite Entity</source>
|
<source>Add satellite Entity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="250"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="252"/>
|
||||||
<source>Track</source>
|
<source>Track</source>
|
||||||
<translation>跟随</translation>
|
<translation>跟随</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="258"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="260"/>
|
||||||
<source>Add Mesh Component</source>
|
<source>Add Mesh Component</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="262"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="264"/>
|
||||||
<source>Add Path Component</source>
|
<source>Add Path Component</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="269"/>
|
<location filename="../ui/ModelBrowser/ModelTreeWidget.cpp" line="271"/>
|
||||||
<source>Delete</source>
|
<source>Delete</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1271,12 +1271,12 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QtOsgViewWidget</name>
|
<name>QtOsgViewWidget</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="105"/>
|
<location filename="../viewer/QtOsgViewWidget.cpp" line="110"/>
|
||||||
<source>notify</source>
|
<source>notify</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="105"/>
|
<location filename="../viewer/QtOsgViewWidget.cpp" line="110"/>
|
||||||
<source>open dyt file failed</source>
|
<source>open dyt file failed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1724,7 +1724,7 @@
|
|||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="82"/>
|
<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"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="98"/>
|
||||||
<source>warning</source>
|
<source>warning</source>
|
||||||
<translation>警告</translation>
|
<translation>警告</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1759,12 +1759,12 @@
|
|||||||
<translation>当前名称已经存在</translation>
|
<translation>当前名称已经存在</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="97"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="98"/>
|
||||||
<source>create workSpace failed</source>
|
<source>create workSpace failed</source>
|
||||||
<translation>创建失败</translation>
|
<translation>创建失败</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="107"/>
|
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="108"/>
|
||||||
<source>save spaceWork directory</source>
|
<source>save spaceWork directory</source>
|
||||||
<translation>选择空间目录</translation>
|
<translation>选择空间目录</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include <osgEarth/EarthManipulator>
|
||||||
|
|
||||||
#include "common/RecourceHelper.h"
|
#include "common/RecourceHelper.h"
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
#include "entities/EntitiesManager.h"
|
#include "entities/EntitiesManager.h"
|
||||||
@ -332,14 +334,14 @@ void ModelTreeWidget::OnTrackEntity(Entity* entity) {
|
|||||||
|
|
||||||
|
|
||||||
osgGA::CameraManipulator* gaManipulator = manipulator->GetManipulator();
|
osgGA::CameraManipulator* gaManipulator = manipulator->GetManipulator();
|
||||||
CameraControlManipulator* ccm = dynamic_cast<CameraControlManipulator*>(gaManipulator);
|
osgEarth::Util::EarthManipulator* ccm = dynamic_cast<osgEarth::Util::EarthManipulator*>(gaManipulator);
|
||||||
if (nullptr != ccm) {
|
if (nullptr != ccm) {
|
||||||
if (nullptr != entity) {
|
if (nullptr != entity) {
|
||||||
osg::MatrixTransform* mt = entity->GetRootComponent()->GetMatrixTransform();
|
osg::MatrixTransform* mt = entity->GetRootComponent()->GetMatrixTransform();
|
||||||
ccm->setManipulatorMode(CameraControlManipulator::Tracker_ManipulatorMode);
|
ccm->setNode(mt);
|
||||||
ccm->setTrackNode(mt);
|
//ccm->setTetherMode(osgGA::CameraManipulator::TETHER_CENTER_AND_ROTATION);
|
||||||
} else {
|
} else {
|
||||||
ccm->setManipulatorMode(CameraControlManipulator::Roam_ManipulatorMode);
|
ccm->setNode(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,10 @@ void WorkSpaceDlg::OnSure() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace* workSpace = WorkSpaceManager::Get().GetOrCreate(name);
|
|
||||||
workSpace->SetDescribe(ui->etDescribe->toPlainText());
|
|
||||||
workspacePath += QString("/%1.dyt").arg(name);
|
workspacePath += QString("/%1.dyt").arg(name);
|
||||||
|
WorkSpace* workSpace = WorkSpaceManager::Get().GetOrCreate(workspacePath, name);
|
||||||
|
workSpace->SetDescribe(ui->etDescribe->toPlainText());
|
||||||
|
|
||||||
if (!workSpace->Save(workspacePath)) {
|
if (!workSpace->Save(workspacePath)) {
|
||||||
LOG_ERROR("save workSpace failed");
|
LOG_ERROR("save workSpace failed");
|
||||||
QMessageBox::warning(this, tr("warning"), tr("create workSpace failed"));
|
QMessageBox::warning(this, tr("warning"), tr("create workSpace failed"));
|
||||||
|
@ -71,6 +71,11 @@ void QtOsgViewWidget::Initialize(void) {
|
|||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
|
activeScene_ = new OEScene;
|
||||||
|
|
||||||
|
activeScene_->AttachView(view_);
|
||||||
|
activeScene_->InitEventHandle(view_);
|
||||||
|
|
||||||
|
|
||||||
osgEarth::Util::EarthManipulator* manipulator = new osgEarth::Util::EarthManipulator;
|
osgEarth::Util::EarthManipulator* manipulator = new osgEarth::Util::EarthManipulator;
|
||||||
osgEarth::Viewpoint vp("home", 107.85, 32.35, 100.0, -2.50, -90.0, 1.5e7);
|
osgEarth::Viewpoint vp("home", 107.85, 32.35, 100.0, -2.50, -90.0, 1.5e7);
|
||||||
@ -94,13 +99,13 @@ void QtOsgViewWidget::Uninitialize(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QtOsgViewWidget::LoadDefaultScene(void) {
|
void QtOsgViewWidget::LoadDefaultScene(void) {
|
||||||
dyt_check(nullptr != view_, "view is nullptr");
|
dyt_check(nullptr != activeScene_);
|
||||||
WorkSpaceManager::Get().LoadDefaultWorkspace(view_);
|
WorkSpaceManager::Get().LoadDefaultWorkspace(activeScene_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtOsgViewWidget::OnLoadDyt(const QString& path) {
|
void QtOsgViewWidget::OnLoadDyt(const QString& path) {
|
||||||
LOG_INFO("load dyt path:{}", path.toStdString());
|
LOG_INFO("load dyt path:{}", path.toStdString());
|
||||||
WorkSpace* workSpace = WorkSpaceManager::Get().LoadDyt(path, view_);
|
WorkSpace* workSpace = WorkSpaceManager::Get().LoadDyt(path);
|
||||||
if (nullptr == workSpace) {
|
if (nullptr == workSpace) {
|
||||||
QMessageBox::warning(&MainFrame::Get(), tr("notify"), tr("open dyt file failed"), QMessageBox::Ok);
|
QMessageBox::warning(&MainFrame::Get(), tr("notify"), tr("open dyt file failed"), QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
@ -128,9 +133,5 @@ void QtOsgViewWidget::resizeEvent(QResizeEvent* event) {
|
|||||||
double pixelRatio = screen()->devicePixelRatio();
|
double pixelRatio = screen()->devicePixelRatio();
|
||||||
const QSize& size = event->size();
|
const QSize& size = event->size();
|
||||||
view_->Resize(0, 0, size.width() * pixelRatio, size.height() * pixelRatio);
|
view_->Resize(0, 0, size.width() * pixelRatio, size.height() * pixelRatio);
|
||||||
|
|
||||||
if (nullptr != workspace_) {
|
|
||||||
workspace_->ViewReize(size.width() * pixelRatio, size.height() * pixelRatio);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// #include <QGLWidget>
|
// #include <QGLWidget>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "scene/OEScene.h"
|
||||||
|
|
||||||
|
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
class QWheelEvent;
|
class QWheelEvent;
|
||||||
@ -41,5 +43,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
class OsgView* view_{ nullptr };
|
class OsgView* view_{ nullptr };
|
||||||
|
osg::ref_ptr<OEScene> activeScene_;
|
||||||
class WorkSpace* workspace_{ nullptr };
|
class WorkSpace* workspace_{ nullptr };
|
||||||
};
|
};
|
@ -18,57 +18,17 @@
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(WorkSpace*)
|
Q_DECLARE_METATYPE(WorkSpace*)
|
||||||
|
|
||||||
WorkSpace::WorkSpace(OsgView* view, QObject* parent) noexcept
|
WorkSpace::WorkSpace(QObject* parent) noexcept
|
||||||
: QObject(parent)
|
: QObject(parent) {
|
||||||
, view_(view) {
|
|
||||||
uuid_ = QUuid::createUuid().toString();
|
uuid_ = QUuid::createUuid().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace::WorkSpace(const QString& name, QObject* parent)
|
WorkSpace::WorkSpace(const QString& path, QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, name_(name){
|
, path_(path){
|
||||||
uuid_ = QUuid::createUuid().toString();
|
uuid_ = QUuid::createUuid().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkSpace::ViewReize(int width, int height) {
|
|
||||||
if (nullptr != activeScene_) {
|
|
||||||
//activeScene_->GetOceanScene()->setScreenDims(osg::Vec2s(width * 2, height * 2));
|
|
||||||
} else {
|
|
||||||
LOG_WARN("secen_:{} or ocean is nullptr", spdlog::fmt_lib::ptr(activeScene_.get()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WorkSpace::CreateScene(const std::string& scene) {
|
|
||||||
LOG_INFO("create scene {}", scene);
|
|
||||||
if (nullptr == view_) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nullptr != activeScene_) {
|
|
||||||
activeScene_->DetachView(view_);
|
|
||||||
}
|
|
||||||
|
|
||||||
name_ = name_.fromStdString(scene);
|
|
||||||
#if 0
|
|
||||||
activeScene_ = new OsgScene;
|
|
||||||
activeScene_->UseShadows(false);
|
|
||||||
|
|
||||||
activeScene_->ChangeScene(OsgScene::CLOUDY);
|
|
||||||
|
|
||||||
activeScene_->AttachView(view_);
|
|
||||||
activeScene_->InitEventHandle(view_);
|
|
||||||
#else
|
|
||||||
activeScene_ = new OEScene;
|
|
||||||
//activeScene_->UseShadows(false);
|
|
||||||
|
|
||||||
//activeScene_->ChangeScene(OsgScene::CLOUDY);
|
|
||||||
|
|
||||||
activeScene_->AttachView(view_);
|
|
||||||
activeScene_->InitEventHandle(view_);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WorkSpace::AddEntity(Entity* entity) {
|
void WorkSpace::AddEntity(Entity* entity) {
|
||||||
if (nullptr == entity) {
|
if (nullptr == entity) {
|
||||||
@ -91,24 +51,6 @@ void WorkSpace::RemoveEntity(Entity* entity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_OCEAN
|
|
||||||
OsgScene* WorkSpace::GetActiveScene() const {
|
|
||||||
if (!activeScene_.valid()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return activeScene_.get();
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
OEScene* WorkSpace::GetActiveScene() const {
|
|
||||||
if (!activeScene_.valid()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return activeScene_.get();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool WorkSpace::SetTimestep(Timestep* timestep) {
|
bool WorkSpace::SetTimestep(Timestep* timestep) {
|
||||||
if (!timestep) {
|
if (!timestep) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "scene/OsgScene.h"
|
#include "scene/OsgScene.h"
|
||||||
#include "scene/OEScene.h"
|
#include "scene/OEScene.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "common/SpdLogger.h"
|
||||||
|
|
||||||
//#include "../ui/chartPlot/DYTChart.h"
|
//#include "../ui/chartPlot/DYTChart.h"
|
||||||
|
|
||||||
@ -14,8 +16,8 @@ class WorkSpace : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WorkSpace(class OsgView* view, QObject* parent = nullptr) noexcept;
|
explicit WorkSpace(QObject* parent = nullptr) noexcept;
|
||||||
WorkSpace(const QString& name, QObject* parent = nullptr);
|
WorkSpace(const QString& path, QObject* parent = nullptr);
|
||||||
~WorkSpace() override = default;
|
~WorkSpace() override = default;
|
||||||
|
|
||||||
inline void SetName(const QString& name) {
|
inline void SetName(const QString& name) {
|
||||||
@ -47,14 +49,15 @@ public:
|
|||||||
return entities_;
|
return entities_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewReize(int width, int height);
|
void SetActiveScene(OEScene* scene) {
|
||||||
bool CreateScene(const std::string& scene);
|
dyt_check(nullptr != scene);
|
||||||
#if USE_OCEAN
|
scene_ = scene;
|
||||||
OsgScene* GetActiveScene() const;
|
}
|
||||||
#else
|
|
||||||
OEScene* GetActiveScene() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
OEScene* GetActiveScene() const {
|
||||||
|
dyt_check(nullptr != scene_);
|
||||||
|
return scene_;
|
||||||
|
}
|
||||||
bool SetTimestep(class Timestep* timestep);
|
bool SetTimestep(class Timestep* timestep);
|
||||||
bool SetTimestepPath(const QString& path);
|
bool SetTimestepPath(const QString& path);
|
||||||
class Timestep* GetTimestep() const {
|
class Timestep* GetTimestep() const {
|
||||||
@ -96,8 +99,7 @@ private:
|
|||||||
|
|
||||||
bool leaded_{ false };
|
bool leaded_{ false };
|
||||||
std::vector<class Entity*> entities_;
|
std::vector<class Entity*> entities_;
|
||||||
osg::ref_ptr<OEScene> activeScene_;
|
OEScene* scene_{ nullptr };
|
||||||
class OsgView* view_{ nullptr };
|
|
||||||
class Timestep* timestep_{ nullptr };
|
class Timestep* timestep_{ nullptr };
|
||||||
class LampStatus* lampStatus_{ nullptr };
|
class LampStatus* lampStatus_{ nullptr };
|
||||||
};
|
};
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
template<> WorkSpaceManager* Singleton<WorkSpaceManager>::instance_ = nullptr;
|
template<> WorkSpaceManager* Singleton<WorkSpaceManager>::instance_ = nullptr;
|
||||||
|
|
||||||
WorkSpaceManager::WorkSpaceManager(QObject* parent)
|
WorkSpaceManager::WorkSpaceManager(QObject* parent)
|
||||||
: QObject(parent) {
|
: QObject(parent) {}
|
||||||
}
|
|
||||||
|
|
||||||
WorkSpaceManager::~WorkSpaceManager() {
|
WorkSpaceManager::~WorkSpaceManager() {
|
||||||
|
|
||||||
@ -21,7 +20,10 @@ void WorkSpaceManager::OnDestory() {
|
|||||||
SaveDefaultWorkspace();
|
SaveDefaultWorkspace();
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace* WorkSpaceManager::LoadDefaultWorkspace(class OsgView* view) {
|
WorkSpace* WorkSpaceManager::LoadDefaultWorkspace(class OEScene* secen) {
|
||||||
|
dyt_check(nullptr != secen);
|
||||||
|
|
||||||
|
scene_ = secen;
|
||||||
const QString iniFile = GetDefaultWorkSpaceName();
|
const QString iniFile = GetDefaultWorkSpaceName();
|
||||||
if (!QFile::exists(iniFile)) {
|
if (!QFile::exists(iniFile)) {
|
||||||
LOG_ERROR("default workspace file not exist:{}", iniFile.toStdString());
|
LOG_ERROR("default workspace file not exist:{}", iniFile.toStdString());
|
||||||
@ -34,7 +36,7 @@ WorkSpace* WorkSpaceManager::LoadDefaultWorkspace(class OsgView* view) {
|
|||||||
LOG_ERROR("default workspace path is empty");
|
LOG_ERROR("default workspace path is empty");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
WorkSpace* workspace = LoadDyt(path, view);
|
WorkSpace* workspace = LoadDyt(path);
|
||||||
if (nullptr == workspace) {
|
if (nullptr == workspace) {
|
||||||
LOG_ERROR("load default workspace failed");
|
LOG_ERROR("load default workspace failed");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -75,7 +77,7 @@ bool WorkSpaceManager::Remove(const QString& name) {
|
|||||||
if (workSpaces_.end() == itor) {
|
if (workSpaces_.end() == itor) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace* workspace = itor->second;
|
WorkSpace* workspace = itor->second;
|
||||||
if (nullptr != workspace) {
|
if (nullptr != workspace) {
|
||||||
workspace->Unlaod();
|
workspace->Unlaod();
|
||||||
@ -85,8 +87,8 @@ bool WorkSpaceManager::Remove(const QString& name) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt, class OsgView* view) {
|
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) {
|
||||||
WorkSpace* workspace = new WorkSpace(view, this);
|
WorkSpace* workspace = new WorkSpace(this);
|
||||||
if (!workspace->Load(dyt)) {
|
if (!workspace->Load(dyt)) {
|
||||||
LOG_WARN("load workspace failed");
|
LOG_WARN("load workspace failed");
|
||||||
workspace->deleteLater();
|
workspace->deleteLater();
|
||||||
@ -97,7 +99,7 @@ WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt, class OsgView* view) {
|
|||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace* WorkSpaceManager::GetOrCreate(const QString& path) {
|
WorkSpace* WorkSpaceManager::GetOrCreate(const QString& path, const QString& name) {
|
||||||
const auto itor = workSpaces_.find(path);
|
const auto itor = workSpaces_.find(path);
|
||||||
if (workSpaces_.end() != itor) {
|
if (workSpaces_.end() != itor) {
|
||||||
return itor->second;
|
return itor->second;
|
||||||
@ -105,15 +107,22 @@ WorkSpace* WorkSpaceManager::GetOrCreate(const QString& path) {
|
|||||||
|
|
||||||
LOG_INFO("create workspace name:{}", path.toStdString());
|
LOG_INFO("create workspace name:{}", path.toStdString());
|
||||||
WorkSpace* workspace = new WorkSpace(path, this);
|
WorkSpace* workspace = new WorkSpace(path, this);
|
||||||
|
workspace->SetName(name);
|
||||||
workSpaces_[path] = workspace;
|
workSpaces_[path] = workspace;
|
||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorkSpaceManager::SetCurrent(WorkSpace* workspace) {
|
void WorkSpaceManager::SetCurrent(WorkSpace* workspace) {
|
||||||
|
if (current_ == workspace) {
|
||||||
|
LOG_INFO("current == workspace");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (nullptr != current_) {
|
if (nullptr != current_) {
|
||||||
current_->End();
|
current_->End();
|
||||||
}
|
}
|
||||||
current_ = workspace;
|
current_ = workspace;
|
||||||
|
workspace->SetActiveScene(scene_);
|
||||||
|
|
||||||
lastTime_ = clock();
|
lastTime_ = clock();
|
||||||
|
|
||||||
|
@ -19,13 +19,13 @@ public:
|
|||||||
~WorkSpaceManager();
|
~WorkSpaceManager();
|
||||||
void OnDestory();
|
void OnDestory();
|
||||||
|
|
||||||
WorkSpace* LoadDefaultWorkspace(class OsgView* view);
|
WorkSpace* LoadDefaultWorkspace(class OEScene* secen);
|
||||||
void SaveDefaultWorkspace();
|
void SaveDefaultWorkspace();
|
||||||
|
|
||||||
bool Contains(const QString& name) const;
|
bool Contains(const QString& name) const;
|
||||||
bool Remove(const QString& name);
|
bool Remove(const QString& name);
|
||||||
WorkSpace* LoadDyt(const QString& dyt, class OsgView* view);
|
WorkSpace* LoadDyt(const QString& dyt);
|
||||||
WorkSpace* GetOrCreate(const QString& path);
|
WorkSpace* GetOrCreate(const QString& path, const QString& name);
|
||||||
void SetCurrent(WorkSpace* workspace);
|
void SetCurrent(WorkSpace* workspace);
|
||||||
WorkSpace* GetCurrent() const { return current_; }
|
WorkSpace* GetCurrent() const { return current_; }
|
||||||
|
|
||||||
@ -72,6 +72,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<QString, WorkSpace*> workSpaces_;
|
std::unordered_map<QString, WorkSpace*> workSpaces_;
|
||||||
|
class OEScene* scene_{ nullptr };
|
||||||
WorkSpace* current_{ nullptr };
|
WorkSpace* current_{ nullptr };
|
||||||
int64_t lastTime_{ 0 };
|
int64_t lastTime_{ 0 };
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ bool WorkSpaceXMLParse::ParseScene(const tinyxml2::XMLElement* element) {
|
|||||||
if (0 == strcmp(eleName, "scene")) {
|
if (0 == strcmp(eleName, "scene")) {
|
||||||
const char* name = element->Attribute("name");
|
const char* name = element->Attribute("name");
|
||||||
|
|
||||||
return workSpace_->CreateScene(name);
|
workSpace_->SetName(name);
|
||||||
|
return true;
|
||||||
} else if (0 == strcmp(eleName, "describe")) {
|
} else if (0 == strcmp(eleName, "describe")) {
|
||||||
const char* value = element->Attribute("describe");
|
const char* value = element->Attribute("describe");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user