201 lines
5.3 KiB
C++
201 lines
5.3 KiB
C++
#pragma once
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <cstdint>
|
|
#include <QObject>
|
|
|
|
#include <osgEarth/Viewpoint>
|
|
|
|
#include "scene/OsgScene.h"
|
|
#include "scene/OEScene.h"
|
|
#include "config.h"
|
|
#include "common/SpdLogger.h"
|
|
#include "workspace/FileEntry.h"
|
|
#include "workspace/ChartData.h"
|
|
|
|
//#include "../ui/chartPlot/DYTChart.h"
|
|
|
|
class WorkSpaceItem;
|
|
class CommandManager;
|
|
|
|
class WorkSpace : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit WorkSpace(QObject* parent = nullptr) noexcept;
|
|
WorkSpace(const QString& path, QObject* parent = nullptr);
|
|
~WorkSpace() override = default;
|
|
|
|
inline void SetName(const QString& name) {
|
|
name_ = name;
|
|
}
|
|
inline const QString& GetName() const {
|
|
return name_;
|
|
}
|
|
inline const QString& GetPath() const {
|
|
return path_;
|
|
}
|
|
const QString GetDir() const;
|
|
|
|
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_;
|
|
}
|
|
|
|
void SetCommondFilePath(const QString& path);
|
|
const QString GetCommondFilePath() const {
|
|
return commondPath_;
|
|
}
|
|
|
|
// Execute command xml according to trigger
|
|
enum class CommandWhen { OnCreate, OnLoad };
|
|
void ExecuteCommands(CommandWhen when);
|
|
|
|
void SetSimMatlab(const QString& path);
|
|
const QString GetSimMatlab() const;
|
|
|
|
inline void SetMatlabParam(const QString& path) {
|
|
matlabParamPath_ = path;
|
|
}
|
|
inline const QString GetMatlabParam() const {
|
|
return matlabParamPath_;
|
|
}
|
|
|
|
void SetWavePath(const QString& path);
|
|
const QString GetWavePath() const;
|
|
|
|
void SetReportPath(const QString& path) ;
|
|
const QString GetReportPath() const;
|
|
|
|
void SetRDPath(const QString& path);
|
|
const QString GetRDPath() const;
|
|
|
|
// Files list API (per-type, max 9 per type)
|
|
enum class FileEntryResult { Ok, LimitExceeded, Duplicate, CopyFailed, TypeMismatch, InvalidFile };
|
|
|
|
// New unified file entry management
|
|
FileEntryResult SetFileEntry(std::shared_ptr<FileEntry> fileEntry);
|
|
|
|
std::vector<std::shared_ptr<FileEntry>> GetFileEntries(FileEntryType type) const;
|
|
|
|
// Manage grouped file entries
|
|
bool SetFileEntryCount(FileEntryType type, int count);
|
|
QString GetFileEntryAbsPath(FileEntryType type, int index) const;
|
|
|
|
// Chart data management
|
|
void SetFileTypeData(const QList<FileTypeData>& fileTypes);
|
|
const QList<FileTypeData>& GetFileTypeData() const;
|
|
void AddChartData(FileEntryType type, const std::shared_ptr<BaseChartData>& chart);
|
|
QList<std::shared_ptr<BaseChartData>> GetChartData(FileEntryType type) const;
|
|
|
|
inline void SetHomeViewpoint(const osgEarth::Viewpoint& viewpoint) {
|
|
homeViewpoint_ = viewpoint;
|
|
homeViewpoint_.setHeading(0.0); // Ensure heading is set to 0.0
|
|
}
|
|
inline const osgEarth::Viewpoint& GetHomeViewpoint() const {
|
|
return homeViewpoint_;
|
|
}
|
|
|
|
const std::vector<class Entity*>& GetEntities() const {
|
|
return entities_;
|
|
}
|
|
std::vector<class Entity*>& GetEntities() {
|
|
return entities_;
|
|
}
|
|
|
|
void SetActiveScene(OEScene* scene);
|
|
|
|
OEScene* GetActiveScene() const {
|
|
dyt_check(nullptr != scene_);
|
|
return scene_;
|
|
}
|
|
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);
|
|
bool TrackEntity(class Entity* entity);
|
|
void UntrackEntity();
|
|
class Entity* GetTrackEntity() const {
|
|
return trackedEntity_;
|
|
}
|
|
|
|
bool Save(const QString& path);
|
|
bool Save();
|
|
|
|
bool Load(const QString& dyt);
|
|
void Unlaod();
|
|
|
|
void Begin();
|
|
void OnFrame(double dt);
|
|
void End();
|
|
|
|
void OnLoaded();
|
|
|
|
Q_SIGNALS:
|
|
void EntityAdded(class Entity* entity);
|
|
void EntityRemoved(class Entity* entity);
|
|
void TimestepChanged(class Timestep* timestep);
|
|
void LampStatusChanged(class LampStatus* lampStatus);
|
|
void FilesChanged(FileEntryType type);
|
|
|
|
protected:
|
|
const QString& GetSimMatlabName() const {
|
|
return simMatlabPath_;
|
|
}
|
|
|
|
private:
|
|
QString name_;
|
|
QString uuid_;
|
|
QString describe_;
|
|
QString path_;
|
|
QString commondPath_;
|
|
QString simMatlabPath_;
|
|
|
|
QString waveFile_;
|
|
QString reportFile_;
|
|
QString rdFile_;
|
|
QString matlabParamPath_;
|
|
|
|
osgEarth::Viewpoint homeViewpoint_;
|
|
|
|
bool leaded_{ false };
|
|
std::vector<class Entity*> entities_;
|
|
OEScene* scene_{ nullptr };
|
|
class Timestep* timestep_{ nullptr };
|
|
class LampStatus* lampStatus_{ nullptr };
|
|
class Entity* trackedEntity_{ nullptr };
|
|
// Stored as file entries under workspace dir, keyed by type
|
|
std::map<FileEntryType, std::vector<std::shared_ptr<FileEntry>>> files_;
|
|
// Chart data storage
|
|
QList<FileTypeData> fileTypeData_;
|
|
// Monotonic sequence for file entries changes, used to trigger UI refresh
|
|
std::uint64_t filesSeq_{ 0 };
|
|
// Executor for command XML actions
|
|
std::unique_ptr<CommandManager> cmdMgr_;
|
|
public:
|
|
std::uint64_t GetFilesSeq() const { return filesSeq_; }
|
|
friend class WorkSpaceXMLWrite;
|
|
friend class WorkSpaceXMLParse;
|
|
};
|
|
|