2025-01-04 04:12:51 +00:00
|
|
|
#include "qtworkspaceattribute.h"
|
|
|
|
|
|
|
|
|
|
#include "workspace/WorkSpace.h"
|
|
|
|
|
#include "workspace/Timestep.h"
|
|
|
|
|
#include "entities/Entity.h"
|
|
|
|
|
#include "entities/MeshComponent.h"
|
|
|
|
|
#include "entities/PathComponent.h"
|
|
|
|
|
#include "entities/ConeWaveComponent.h"
|
|
|
|
|
#include "entities/DashedLineComponent.h"
|
|
|
|
|
#include "entities/EntitiesManager.h"
|
|
|
|
|
#include "utils/Transform.h"
|
|
|
|
|
#include "utils/OsgUtils.h"
|
2025-11-03 16:23:24 +00:00
|
|
|
#include "workspace/WorkSpaceManager.h"
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
QWorkspaceAttribute::QWorkspaceAttribute(class WorkSpace* workspace)
|
|
|
|
|
: workspace_(workspace) {
|
2025-10-12 14:55:13 +00:00
|
|
|
if (workspace_) {
|
|
|
|
|
filesSeq_ = workspace_->GetFilesSeq();
|
|
|
|
|
}
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QWorkspaceAttribute::operator==(const QWorkspaceAttribute& other) {
|
2025-10-12 14:55:13 +00:00
|
|
|
return workspace_ == other.workspace_ && filesSeq_ == other.filesSeq_;
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWorkspaceAttribute& QWorkspaceAttribute::operator=(const QWorkspaceAttribute& other) {
|
|
|
|
|
workspace_ = other.workspace_;
|
2025-10-12 14:55:13 +00:00
|
|
|
filesSeq_ = other.filesSeq_;
|
2025-01-04 04:12:51 +00:00
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWorkspaceAttribute::SetName(const QString& name) {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workspace_->SetName(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString QWorkspaceAttribute::GetName() const {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return workspace_->GetName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWorkspaceAttribute::SetDescription(const QString& desc) {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workspace_->SetDescribe(desc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString QWorkspaceAttribute::GetDescription() const {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return workspace_->GetDescribe();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QWorkspaceAttribute::SetTimeStep(const QString& timestep) {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-04 16:11:29 +00:00
|
|
|
Timestep* obj = workspace_->GetTimestep();
|
|
|
|
|
if (nullptr == obj) {
|
|
|
|
|
workspace_->SetTimestepPath(timestep);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString& path = obj->GetPath();
|
|
|
|
|
if (path == timestep) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
workspace_->SetTimestepPath(timestep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString QWorkspaceAttribute::GetTimeStep() const {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Timestep* timestep = workspace_->GetTimestep();
|
|
|
|
|
if (nullptr == timestep) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return timestep->GetPath();
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-02 09:47:54 +00:00
|
|
|
// Deprecated workspace path setters/getters removed
|
2025-01-07 15:45:23 +00:00
|
|
|
|
2025-10-13 16:15:18 +00:00
|
|
|
void QWorkspaceAttribute::SetCommondFilePath(const QString& path)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
workspace_->SetCommondFilePath(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString QWorkspaceAttribute::GetCommondFilePath() const
|
|
|
|
|
{
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2025-10-14 16:41:12 +00:00
|
|
|
|
2025-10-20 18:17:40 +00:00
|
|
|
|
2025-10-15 23:37:49 +00:00
|
|
|
return workspace_->GetCommondFilePath();
|
2025-10-13 16:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
2025-10-26 07:55:41 +00:00
|
|
|
std::vector<std::shared_ptr<FileEntry>> QWorkspaceAttribute::GetFileEntries(FileEntryType type) const {
|
2025-10-12 14:14:16 +00:00
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
return workspace_->GetFileEntries(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWorkspaceAttribute::SetFileEntryCount(FileEntryType type, int count) {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
workspace_->SetFileEntryCount(type, count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QWorkspaceAttribute::SetFileEntryPath(FileEntryType type, int index, const QString& path) {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-10-26 07:55:41 +00:00
|
|
|
|
|
|
|
|
// Get the file entries for this type
|
|
|
|
|
auto entries = workspace_->GetFileEntries(type);
|
|
|
|
|
if (index < 0 || index >= static_cast<int>(entries.size())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update the path of the specific entry
|
|
|
|
|
entries[index]->SetPath(path);
|
2025-11-03 16:23:24 +00:00
|
|
|
// Trigger files changed signal properly
|
|
|
|
|
workspace_->NotifyFileEntryUpdated(type);
|
2025-10-12 14:14:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QWorkspaceAttribute::GetFileEntryAbsPath(FileEntryType type, int index) const {
|
|
|
|
|
if (nullptr == workspace_) {
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
return workspace_->GetFileEntryAbsPath(type, index);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
QTransformAttribute::QTransformAttribute(class Transform* obj)
|
|
|
|
|
: object_(obj) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QTransformAttribute::operator!=(const QTransformAttribute& other) {
|
|
|
|
|
return object_ != other.object_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QTransformAttribute::SetLocation(const osg::Vec3& l) {
|
|
|
|
|
object_->SetLocation(l);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const osg::Vec3 QTransformAttribute::GetLocation() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return osg::Vec3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
return object_->GetLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QTransformAttribute::SetRotation(const osg::Vec3& r) {
|
|
|
|
|
object_->SetRotation(r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const osg::Vec3 QTransformAttribute::GetRotation() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return osg::Vec3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
return object_->GetRotation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QTransformAttribute::SetScale(const osg::Vec3& s) {
|
|
|
|
|
object_->SetScale(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const osg::Vec3 QTransformAttribute::GetScale() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return osg::Vec3(1.0f, 1.0f, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
return object_->GetScale();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QTransformAttribute::operator==(const QTransformAttribute& other) {
|
|
|
|
|
return object_ == other.object_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTransformAttribute& QTransformAttribute::operator=(const QTransformAttribute& other) {
|
|
|
|
|
if (this == &other) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_ = other.object_;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QEntityAttribute::QEntityAttribute(class Entity* entity)
|
|
|
|
|
: entity_(entity) {
|
2025-06-27 16:23:58 +00:00
|
|
|
if (nullptr == entity) {
|
2025-01-04 04:12:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
transform_ = (new QTransformAttribute(entity->GetTransform()));
|
2025-06-27 16:23:58 +00:00
|
|
|
visible_ = entity->IsVisible();
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QEntityAttribute::operator==(const QEntityAttribute& other) {
|
|
|
|
|
return entity_ == other.entity_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QEntityAttribute& QEntityAttribute::operator=(const QEntityAttribute& other) {
|
|
|
|
|
entity_ = other.entity_;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QEntityAttribute::SetName(const QString& name) {
|
|
|
|
|
if (nullptr == entity_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entity_->SetName(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString QEntityAttribute::GetName() const {
|
|
|
|
|
if (nullptr == entity_) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return entity_->GetName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTransformAttribute QEntityAttribute::GetTransform() const {
|
|
|
|
|
if (nullptr == transform_) {
|
|
|
|
|
return QTransformAttribute();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *transform_;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-27 16:23:58 +00:00
|
|
|
void QEntityAttribute::SetVisible(bool v) {
|
|
|
|
|
visible_ = v;
|
|
|
|
|
if (nullptr == entity_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entity_->SetVisible(v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QEntityAttribute::IsVisible() const {
|
|
|
|
|
return visible_;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
QMeshComponentAttribute::QMeshComponentAttribute(class MeshComponent* object)
|
|
|
|
|
: object_(object) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QMeshComponentAttribute::SetMesh(const QString& mesh) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mesh.toStdString() == object_->GetMesh()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
object_->LoadNode(mesh.toStdString().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QMeshComponentAttribute::GetMesh() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return QString(object_->GetMesh().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool QMeshComponentAttribute::operator==(const QMeshComponentAttribute& other) {
|
|
|
|
|
return object_ == other.object_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMeshComponentAttribute& QMeshComponentAttribute::operator=(const QMeshComponentAttribute& other) {
|
|
|
|
|
if (this == &other) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_ = other.object_;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPathComponentAttribute::QPathComponentAttribute(PathComponent* object)
|
|
|
|
|
: object_(object) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QPathComponentAttribute::SetPath(const QString& path) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_->SetPath(path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QPathComponentAttribute::GetPath() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return object_->GetPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QPathComponentAttribute::operator==(const QPathComponentAttribute& other) {
|
|
|
|
|
return object_ == other.object_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPathComponentAttribute& QPathComponentAttribute::operator=(const QPathComponentAttribute& other) {
|
|
|
|
|
if (this == &other) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_ = other.object_;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QConeWaveComponentAttribute::QConeWaveComponentAttribute(ConeWaveComponent* object)
|
|
|
|
|
: object_(object) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QConeWaveComponentAttribute::SetRadius(float r) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (r == object_->GetRadius()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_->SetRadius(r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float QConeWaveComponentAttribute::GetRadius() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return 10.0f;
|
|
|
|
|
}
|
|
|
|
|
return object_->GetRadius();
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
void QConeWaveComponentAttribute::SetBaseColor(const QColor& c) {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
osg::Vec4 vColor = object_->GetBaseColor();
|
2025-01-04 04:12:51 +00:00
|
|
|
QColor color;
|
|
|
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
|
|
|
if (c == color) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
OsgUtils::QColorToVec4(c, &vColor);
|
|
|
|
|
object_->SetBaseColor(vColor);
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
QColor QConeWaveComponentAttribute::GetBaseColor() const {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return QColor();
|
|
|
|
|
}
|
2025-06-25 16:13:22 +00:00
|
|
|
osg::Vec4 vColor = object_->GetBaseColor();
|
2025-01-04 04:12:51 +00:00
|
|
|
QColor color;
|
|
|
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
|
|
|
return color;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
void QConeWaveComponentAttribute::SetWaveColor(const QColor& c) {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
osg::Vec4 vColor = object_->GetWaveColor();
|
2025-01-04 04:12:51 +00:00
|
|
|
QColor color;
|
|
|
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
|
|
|
if (c == color) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
OsgUtils::QColorToVec4(c, &vColor);
|
|
|
|
|
object_->SetWaveColor(vColor);
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
QColor QConeWaveComponentAttribute::GetWaveColor() const {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return QColor();
|
|
|
|
|
}
|
2025-06-25 16:13:22 +00:00
|
|
|
osg::Vec4 vColor = object_->GetWaveColor();
|
2025-01-04 04:12:51 +00:00
|
|
|
QColor color;
|
|
|
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
|
|
|
return color;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
void QConeWaveComponentAttribute::SetRingBrightAlpha(float a) {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
if (a == object_->GetRingBrightAlpha()) {
|
2025-01-04 04:12:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
object_->SetRingBrightAlpha(a);
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
float QConeWaveComponentAttribute::GetRingBrightAlpha() const {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
2025-06-25 16:13:22 +00:00
|
|
|
return 0.5f;
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
2025-06-25 16:13:22 +00:00
|
|
|
return object_->GetRingBrightAlpha();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QConeWaveComponentAttribute::SetRingDarkAlpha(float a) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a = std::max(a, 0.0f);
|
|
|
|
|
a = std::min(a, 1.0f);
|
|
|
|
|
|
|
|
|
|
object_->SetRingDarkAlpha(a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float QConeWaveComponentAttribute::GetRingDarkAlpha() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return 0.5f;
|
|
|
|
|
}
|
|
|
|
|
return object_->GetRingDarkAlpha();
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QConeWaveComponentAttribute::SetHeight(float h) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (h == object_->GetHeight()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_->SetHeight(h);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float QConeWaveComponentAttribute::GetHeight() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return 60.0f;
|
|
|
|
|
}
|
|
|
|
|
return object_->GetHeight();
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
void QConeWaveComponentAttribute::SetWaveCount(int c) {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
if (c == object_->GetWaveCount()) {
|
2025-01-04 04:12:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
object_->SetWaveCount(c);
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
int QConeWaveComponentAttribute::GetWaveCount() const {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
2025-06-25 16:13:22 +00:00
|
|
|
return object_->GetWaveCount();
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
void QConeWaveComponentAttribute::SetWaveSpeed(float h) {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
if (h == object_->GetWaveSpeed()) {
|
2025-01-04 04:12:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
object_->SetWaveSpeed(h);
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-25 16:13:22 +00:00
|
|
|
float QConeWaveComponentAttribute::GetWaveSpeed() const {
|
2025-01-04 04:12:51 +00:00
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return 500.0f;
|
|
|
|
|
}
|
2025-06-25 16:13:22 +00:00
|
|
|
return object_->GetWaveSpeed();
|
2025-01-04 04:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QConeWaveComponentAttribute::operator==(const QConeWaveComponentAttribute& other) {
|
|
|
|
|
return object_ == other.object_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QConeWaveComponentAttribute& QConeWaveComponentAttribute::operator=(const QConeWaveComponentAttribute& other) {
|
|
|
|
|
if (this == &other) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_ = other.object_;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDashedLineComponentAttribute::QDashedLineComponentAttribute(class DashedLineComponent* obj)
|
|
|
|
|
: object_(obj) {
|
|
|
|
|
if (nullptr == obj) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startEntity_ = QEntityAttribute(obj->GetStartEntityPtr());
|
|
|
|
|
endEntity_ = QEntityAttribute(obj->GetEndEntityPtr());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QDashedLineComponentAttribute::SetStart(const QString& uuid) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startUUid_ = object_->GetStartEntity();
|
|
|
|
|
startName_ = object_->GetStartEntityName();
|
|
|
|
|
|
|
|
|
|
if (uuid == startName_ || uuid == startUUid_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::string suuid = uuid.toStdString();
|
|
|
|
|
std::string suuid_ = startName_.toStdString();
|
|
|
|
|
std::string suuid2 = startUUid_.toStdString();
|
|
|
|
|
|
|
|
|
|
object_->SetStartEntity(uuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QDashedLineComponentAttribute::SetStart(const QEntityAttribute& start) {
|
|
|
|
|
startEntity_ = start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QEntityAttribute& QDashedLineComponentAttribute::GetStart() const {
|
|
|
|
|
return startEntity_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//QString QDashedLineComponentAttribute::GetStart() const {
|
|
|
|
|
// if (nullptr == object_) {
|
|
|
|
|
// return "";
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// startUUid_ = object_->GetStartEntity();
|
|
|
|
|
// startName_ = object_->GetStartEntityName();
|
|
|
|
|
// return startName_;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void QDashedLineComponentAttribute::SetEnd(const QString& uuid) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
endUUid_ = object_->GetEndEntity();
|
|
|
|
|
endName_ = object_->GetEndEntityName();
|
|
|
|
|
if (uuid == endUUid_ || uuid == endName_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_->SetEndEntity(uuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QDashedLineComponentAttribute::SetEnd(const QEntityAttribute& end) {
|
|
|
|
|
endEntity_ = end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//QString QDashedLineComponentAttribute::GetEnd() const {
|
|
|
|
|
// if (nullptr == object_) {
|
|
|
|
|
// return "";
|
|
|
|
|
// }
|
|
|
|
|
// endUUid_ = object_->GetEndEntity();
|
|
|
|
|
// endName_ = object_->GetEndEntityName();
|
|
|
|
|
// return endName_;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void QDashedLineComponentAttribute::SetRadius(float r) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (r == object_->GetRadius()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_->SetRadius(r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float QDashedLineComponentAttribute::GetRadius() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return 2.0f;
|
|
|
|
|
}
|
|
|
|
|
return object_->GetRadius();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QDashedLineComponentAttribute::SetColor(const QColor& c) {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
osg::Vec4 vColor = object_->GetBaseColor();
|
|
|
|
|
QColor color;
|
|
|
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
|
|
|
if (c == color) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OsgUtils::QColorToVec4(color, &vColor);
|
|
|
|
|
object_->SetBaseColor(vColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QColor QDashedLineComponentAttribute::GetColor() const {
|
|
|
|
|
if (nullptr == object_) {
|
|
|
|
|
return QColor();
|
|
|
|
|
}
|
|
|
|
|
osg::Vec4 vColor = object_->GetBaseColor();
|
|
|
|
|
QColor color;
|
|
|
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
|
|
|
return color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QDashedLineComponentAttribute::operator==(const QDashedLineComponentAttribute& other) {
|
|
|
|
|
return object_ == other.object_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDashedLineComponentAttribute& QDashedLineComponentAttribute::operator=(const QDashedLineComponentAttribute& other) {
|
|
|
|
|
if (this == &other) {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_ = other.object_;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2025-11-02 16:36:16 +00:00
|
|
|
|
|
|
|
|
// ---- QCurveEntryAttribute ----
|
|
|
|
|
QCurveEntryAttribute::QCurveEntryAttribute(FileEntryCurve* entry)
|
|
|
|
|
: entry_(entry) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QCurveEntryAttribute::operator==(const QCurveEntryAttribute& other) {
|
|
|
|
|
return entry_ == other.entry_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QCurveEntryAttribute& QCurveEntryAttribute::operator=(const QCurveEntryAttribute& other) {
|
|
|
|
|
entry_ = other.entry_;
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetName(const QString& name) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
entry_->SetName(name);
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QCurveEntryAttribute::GetName() const {
|
|
|
|
|
if (!entry_) return QString();
|
|
|
|
|
return entry_->GetName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetChartType(ChartType type) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
entry_->SetChartType(type);
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChartType QCurveEntryAttribute::GetChartType() const {
|
|
|
|
|
if (!entry_) return ChartType::Wave;
|
|
|
|
|
return entry_->GetChartType();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int QCurveEntryAttribute::GetCurveCount() const {
|
|
|
|
|
if (!entry_) return 0;
|
|
|
|
|
return entry_->GetCurveProperties().size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetCurveCount(int count) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
if (count < 0) count = 0;
|
|
|
|
|
auto props = entry_->GetCurveProperties();
|
|
|
|
|
int current = props.size();
|
|
|
|
|
if (count == current) return;
|
|
|
|
|
if (count > current) {
|
|
|
|
|
// Append default curve properties
|
|
|
|
|
for (int i = current; i < count; ++i) {
|
|
|
|
|
FileEntryCurve::CurveProperty cp;
|
|
|
|
|
cp.name = QString("Curve %1").arg(i + 1);
|
|
|
|
|
cp.color = QColor(0, 255, 0);
|
|
|
|
|
cp.data.wave.start = 0;
|
|
|
|
|
cp.data.wave.stop = 0;
|
|
|
|
|
entry_->AddCurveProperty(cp);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Remove surplus from the end
|
|
|
|
|
for (int i = current - 1; i >= count; --i) {
|
|
|
|
|
entry_->RemoveCurveProperty(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QCurveEntryAttribute::GetCurveName(int index) const {
|
|
|
|
|
if (!entry_) return QString();
|
|
|
|
|
const auto& cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return QString();
|
|
|
|
|
return cps.at(index).name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetCurveName(int index, const QString& name) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
auto cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return;
|
|
|
|
|
auto cp = cps.at(index);
|
|
|
|
|
cp.name = name;
|
|
|
|
|
// overwrite by remove/add pattern
|
|
|
|
|
entry_->RemoveCurveProperty(index);
|
|
|
|
|
entry_->AddCurveProperty(cp);
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QColor QCurveEntryAttribute::GetCurveColor(int index) const {
|
|
|
|
|
if (!entry_) return QColor();
|
|
|
|
|
const auto& cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return QColor();
|
|
|
|
|
return cps.at(index).color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetCurveColor(int index, const QColor& color) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
auto cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return;
|
|
|
|
|
auto cp = cps.at(index);
|
|
|
|
|
cp.color = color;
|
|
|
|
|
entry_->RemoveCurveProperty(index);
|
|
|
|
|
entry_->AddCurveProperty(cp);
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int QCurveEntryAttribute::GetWaveStart(int index) const {
|
|
|
|
|
if (!entry_) return 0;
|
|
|
|
|
const auto& cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return 0;
|
|
|
|
|
return cps.at(index).data.wave.start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetWaveStart(int index, int start) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
auto cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return;
|
|
|
|
|
auto cp = cps.at(index);
|
|
|
|
|
cp.data.wave.start = start;
|
|
|
|
|
entry_->RemoveCurveProperty(index);
|
|
|
|
|
entry_->AddCurveProperty(cp);
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int QCurveEntryAttribute::GetWaveStop(int index) const {
|
|
|
|
|
if (!entry_) return 0;
|
|
|
|
|
const auto& cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return 0;
|
|
|
|
|
return cps.at(index).data.wave.stop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetWaveStop(int index, int stop) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
auto cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return;
|
|
|
|
|
auto cp = cps.at(index);
|
|
|
|
|
cp.data.wave.stop = stop;
|
|
|
|
|
entry_->RemoveCurveProperty(index);
|
|
|
|
|
entry_->AddCurveProperty(cp);
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double QCurveEntryAttribute::GetReportX(int index) const {
|
|
|
|
|
if (!entry_) return 0.0;
|
|
|
|
|
const auto& cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return 0.0;
|
|
|
|
|
return cps.at(index).data.report.x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetReportX(int index, double x) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
auto cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return;
|
|
|
|
|
auto cp = cps.at(index);
|
|
|
|
|
cp.data.report.x = x;
|
|
|
|
|
entry_->RemoveCurveProperty(index);
|
|
|
|
|
entry_->AddCurveProperty(cp);
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double QCurveEntryAttribute::GetReportY(int index) const {
|
|
|
|
|
if (!entry_) return 0.0;
|
|
|
|
|
const auto& cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return 0.0;
|
|
|
|
|
return cps.at(index).data.report.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QCurveEntryAttribute::SetReportY(int index, double y) {
|
|
|
|
|
if (!entry_) return;
|
|
|
|
|
auto cps = entry_->GetCurveProperties();
|
|
|
|
|
if (index < 0 || index >= cps.size()) return;
|
|
|
|
|
auto cp = cps.at(index);
|
|
|
|
|
cp.data.report.y = y;
|
|
|
|
|
entry_->RemoveCurveProperty(index);
|
|
|
|
|
entry_->AddCurveProperty(cp);
|
2025-11-03 16:23:24 +00:00
|
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
2025-11-02 16:36:16 +00:00
|
|
|
}
|