2025-01-04 04:12:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <map>
|
2025-10-13 00:20:53 +00:00
|
|
|
#include <memory>
|
2025-10-12 14:55:13 +00:00
|
|
|
#include <cstdint>
|
2025-01-04 04:12:51 +00:00
|
|
|
#include <QObject>
|
|
|
|
|
|
2025-01-05 18:18:16 +00:00
|
|
|
#include <osgEarth/Viewpoint>
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
#include "scene/OsgScene.h"
|
|
|
|
|
#include "scene/OEScene.h"
|
2025-01-05 13:49:36 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
#include "common/SpdLogger.h"
|
2025-10-12 14:14:16 +00:00
|
|
|
#include "workspace/FileEntry.h"
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
//#include "../ui/chartPlot/DYTChart.h"
|
|
|
|
|
|
|
|
|
|
class WorkSpaceItem;
|
2025-10-13 00:20:53 +00:00
|
|
|
class CommandManager;
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
class WorkSpace : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2025-01-05 13:49:36 +00:00
|
|
|
explicit WorkSpace(QObject* parent = nullptr) noexcept;
|
|
|
|
|
WorkSpace(const QString& path, QObject* parent = nullptr);
|
2025-01-04 04:12:51 +00:00
|
|
|
~WorkSpace() override = default;
|
|
|
|
|
|
|
|
|
|
inline void SetName(const QString& name) {
|
|
|
|
|
name_ = name;
|
|
|
|
|
}
|
|
|
|
|
inline const QString& GetName() const {
|
|
|
|
|
return name_;
|
|
|
|
|
}
|
2025-01-05 11:12:18 +00:00
|
|
|
inline const QString& GetPath() const {
|
|
|
|
|
return path_;
|
|
|
|
|
}
|
2025-01-05 15:12:58 +00:00
|
|
|
const QString GetDir() const;
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
inline void SetUUid(const QString& uuid) {
|
|
|
|
|
uuid_ = uuid;
|
|
|
|
|
}
|
|
|
|
|
inline const QString& GetUUid() const {
|
|
|
|
|
return uuid_;
|
|
|
|
|
}
|
|
|
|
|
// static WorkSpace* Create(const QString& name);
|
|
|
|
|
inline void SetDescribe(const QString& describe) {
|
|
|
|
|
describe_ = describe;
|
|
|
|
|
}
|
|
|
|
|
inline const QString& GetDescribe() const {
|
|
|
|
|
return describe_;
|
|
|
|
|
}
|
2025-10-11 00:32:25 +00:00
|
|
|
|
|
|
|
|
void SetCommondFilePath(const QString& path);
|
2025-10-14 16:41:12 +00:00
|
|
|
const QString GetCommondFilePath() const {
|
|
|
|
|
return commondPath_;
|
|
|
|
|
}
|
2025-10-11 00:32:25 +00:00
|
|
|
|
2025-10-13 00:20:53 +00:00
|
|
|
// Execute command xml according to trigger
|
|
|
|
|
enum class CommandWhen { OnCreate, OnLoad };
|
|
|
|
|
void ExecuteCommands(CommandWhen when);
|
|
|
|
|
|
2025-11-02 09:47:54 +00:00
|
|
|
// Deprecated path APIs removed: SimMatlab/MatlabParam/Wave/Report/RD
|
2025-01-07 15:45:23 +00:00
|
|
|
|
2025-10-12 14:14:16 +00:00
|
|
|
// Files list API (per-type, max 9 per type)
|
2025-10-26 07:55:41 +00:00
|
|
|
enum class FileEntryResult { Ok, LimitExceeded, Duplicate, CopyFailed, TypeMismatch, InvalidFile };
|
|
|
|
|
|
|
|
|
|
// New unified file entry management
|
2025-10-27 00:35:04 +00:00
|
|
|
FileEntryResult SetFileEntry(std::shared_ptr<FileEntry> fileEntry, bool is_copy = true);
|
2025-10-26 07:55:41 +00:00
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<FileEntry>> GetFileEntries(FileEntryType type) const;
|
2025-10-12 14:14:16 +00:00
|
|
|
|
|
|
|
|
// Manage grouped file entries
|
|
|
|
|
bool SetFileEntryCount(FileEntryType type, int count);
|
|
|
|
|
QString GetFileEntryAbsPath(FileEntryType type, int index) const;
|
|
|
|
|
|
2025-01-05 18:18:16 +00:00
|
|
|
inline void SetHomeViewpoint(const osgEarth::Viewpoint& viewpoint) {
|
|
|
|
|
homeViewpoint_ = viewpoint;
|
2025-06-17 18:05:47 +00:00
|
|
|
homeViewpoint_.setHeading(0.0); // Ensure heading is set to 0.0
|
2025-01-05 18:18:16 +00:00
|
|
|
}
|
|
|
|
|
inline const osgEarth::Viewpoint& GetHomeViewpoint() const {
|
|
|
|
|
return homeViewpoint_;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
const std::vector<class Entity*>& GetEntities() const {
|
|
|
|
|
return entities_;
|
|
|
|
|
}
|
|
|
|
|
std::vector<class Entity*>& GetEntities() {
|
|
|
|
|
return entities_;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-21 00:20:00 +00:00
|
|
|
void SetActiveScene(OEScene* scene);
|
2025-01-04 04:12:51 +00:00
|
|
|
|
2025-01-05 13:49:36 +00:00
|
|
|
OEScene* GetActiveScene() const {
|
|
|
|
|
dyt_check(nullptr != scene_);
|
|
|
|
|
return scene_;
|
|
|
|
|
}
|
2025-01-04 04:12:51 +00:00
|
|
|
bool SetTimestep(class Timestep* timestep);
|
|
|
|
|
bool SetTimestepPath(const QString& path);
|
|
|
|
|
class Timestep* GetTimestep() const {
|
|
|
|
|
return timestep_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SetLampStatus(class LampStatus* timestep);
|
|
|
|
|
bool SetLampPath(const QString& path);
|
|
|
|
|
class LampStatus* GetLampStatus() const {
|
|
|
|
|
return lampStatus_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AddEntity(class Entity* entity);
|
|
|
|
|
void RemoveEntity(class Entity* entity);
|
2025-06-17 18:05:47 +00:00
|
|
|
bool TrackEntity(class Entity* entity);
|
|
|
|
|
void UntrackEntity();
|
2025-06-18 15:33:06 +00:00
|
|
|
class Entity* GetTrackEntity() const {
|
|
|
|
|
return trackedEntity_;
|
|
|
|
|
}
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
bool Save(const QString& path);
|
|
|
|
|
bool Save();
|
|
|
|
|
|
|
|
|
|
bool Load(const QString& dyt);
|
|
|
|
|
void Unlaod();
|
|
|
|
|
|
|
|
|
|
void Begin();
|
|
|
|
|
void OnFrame(double dt);
|
|
|
|
|
void End();
|
|
|
|
|
|
2025-11-02 09:47:54 +00:00
|
|
|
void OnLoaded();
|
2025-01-05 11:12:18 +00:00
|
|
|
|
2025-11-03 16:23:24 +00:00
|
|
|
// 通知:某类型的文件条目属性已更新(不改变数量,仅触发刷新)
|
|
|
|
|
void NotifyFileEntryUpdated(FileEntryType type, std::shared_ptr<FileEntry> fileEntry = nullptr);
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
Q_SIGNALS:
|
2025-10-12 14:14:16 +00:00
|
|
|
void EntityAdded(class Entity* entity);
|
|
|
|
|
void EntityRemoved(class Entity* entity);
|
|
|
|
|
void TimestepChanged(class Timestep* timestep);
|
|
|
|
|
void LampStatusChanged(class LampStatus* lampStatus);
|
2025-10-27 14:58:41 +00:00
|
|
|
void FilesChanged(FileEntryType type, std::shared_ptr<FileEntry> fileEntry);
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
private:
|
2025-11-02 09:47:54 +00:00
|
|
|
QString name_;
|
|
|
|
|
QString uuid_;
|
|
|
|
|
QString describe_;
|
|
|
|
|
QString path_;
|
|
|
|
|
QString commondPath_;
|
|
|
|
|
// Removed deprecated path members: simMatlabPath_, waveFile_, reportFile_, rdFile_, matlabParamPath_
|
|
|
|
|
|
|
|
|
|
osgEarth::Viewpoint homeViewpoint_;
|
2025-01-04 04:12:51 +00:00
|
|
|
|
2025-01-05 03:33:33 +00:00
|
|
|
bool leaded_{ false };
|
2025-10-12 14:55:13 +00:00
|
|
|
std::vector<class Entity*> entities_;
|
|
|
|
|
OEScene* scene_{ nullptr };
|
|
|
|
|
class Timestep* timestep_{ nullptr };
|
|
|
|
|
class LampStatus* lampStatus_{ nullptr };
|
|
|
|
|
class Entity* trackedEntity_{ nullptr };
|
2025-10-12 14:14:16 +00:00
|
|
|
// Stored as file entries under workspace dir, keyed by type
|
2025-10-26 07:55:41 +00:00
|
|
|
std::map<FileEntryType, std::vector<std::shared_ptr<FileEntry>>> files_;
|
2025-10-12 14:55:13 +00:00
|
|
|
// Monotonic sequence for file entries changes, used to trigger UI refresh
|
|
|
|
|
std::uint64_t filesSeq_{ 0 };
|
2025-10-13 00:20:53 +00:00
|
|
|
// Executor for command XML actions
|
|
|
|
|
std::unique_ptr<CommandManager> cmdMgr_;
|
2025-10-12 14:55:13 +00:00
|
|
|
public:
|
|
|
|
|
std::uint64_t GetFilesSeq() const { return filesSeq_; }
|
2025-07-05 04:07:30 +00:00
|
|
|
friend class WorkSpaceXMLWrite;
|
2025-10-14 16:41:12 +00:00
|
|
|
friend class WorkSpaceXMLParse;
|
2025-01-04 04:12:51 +00:00
|
|
|
};
|
|
|
|
|
|