1170 lines
31 KiB
C++
1170 lines
31 KiB
C++
#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/TrajectoryTraceComponent.h"
|
|
#include "entities/ConeWaveComponent.h"
|
|
#include "entities/DashedLineComponent.h"
|
|
#include "entities/EntitiesManager.h"
|
|
#include "utils/Transform.h"
|
|
#include "utils/OsgUtils.h"
|
|
#include "workspace/WorkSpaceManager.h"
|
|
#include "utils/StringUtils.h"
|
|
|
|
|
|
QWorkspaceAttribute::QWorkspaceAttribute(class WorkSpace* workspace)
|
|
: workspace_(workspace) {
|
|
if (workspace_) {
|
|
filesSeq_ = workspace_->GetFilesSeq();
|
|
}
|
|
}
|
|
|
|
bool QWorkspaceAttribute::operator==(const QWorkspaceAttribute& other) {
|
|
return workspace_ == other.workspace_ && filesSeq_ == other.filesSeq_;
|
|
}
|
|
|
|
QWorkspaceAttribute& QWorkspaceAttribute::operator=(const QWorkspaceAttribute& other) {
|
|
workspace_ = other.workspace_;
|
|
filesSeq_ = other.filesSeq_;
|
|
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::SetSimulationStart(double start) {
|
|
if (!workspace_) return;
|
|
Timestep* t = workspace_->GetTimestep();
|
|
if (!t) return;
|
|
double minTime = 0.0, maxTime = 0.0, step = 0.0;
|
|
t->GetRange(minTime, maxTime, step);
|
|
t->SetManualRange(start, maxTime);
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetSimulationStart() const {
|
|
if (!workspace_) return 0.0;
|
|
Timestep* t = workspace_->GetTimestep();
|
|
if (!t) return 0.0;
|
|
double minTime = 0.0, maxTime = 0.0, step = 0.0;
|
|
t->GetRange(minTime, maxTime, step);
|
|
return minTime;
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetSimulationEnd(double end) {
|
|
if (!workspace_) return;
|
|
Timestep* t = workspace_->GetTimestep();
|
|
if (!t) return;
|
|
double minTime = 0.0, maxTime = 0.0, step = 0.0;
|
|
t->GetRange(minTime, maxTime, step);
|
|
t->SetManualRange(minTime, end);
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetSimulationEnd() const {
|
|
if (!workspace_) return 0.0;
|
|
Timestep* t = workspace_->GetTimestep();
|
|
if (!t) return 0.0;
|
|
double minTime = 0.0, maxTime = 0.0, step = 0.0;
|
|
t->GetRange(minTime, maxTime, step);
|
|
return maxTime;
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetSimulationRange(double start, double end) {
|
|
if (!workspace_) return;
|
|
Timestep* t = workspace_->GetTimestep();
|
|
if (!t) return;
|
|
t->SetManualRange(start, end);
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetSimulationStep(double step) {
|
|
if (!workspace_) return;
|
|
Timestep* t = workspace_->GetTimestep();
|
|
if (!t) return;
|
|
t->SetSpeed(step);
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetSimulationStep() const {
|
|
if (!workspace_) return 1.0;
|
|
Timestep* t = workspace_->GetTimestep();
|
|
if (!t) return 1.0;
|
|
double minTime = 0.0, maxTime = 0.0, step = 0.0;
|
|
t->GetRange(minTime, maxTime, step);
|
|
return step;
|
|
}
|
|
|
|
// Deprecated workspace path setters/getters removed
|
|
|
|
void QWorkspaceAttribute::SetCommondFilePath(const QString& path)
|
|
{
|
|
if (nullptr == workspace_) {
|
|
return;
|
|
}
|
|
workspace_->SetCommondFilePath(path);
|
|
}
|
|
|
|
const QString QWorkspaceAttribute::GetCommondFilePath() const
|
|
{
|
|
if (nullptr == workspace_) {
|
|
return "";
|
|
}
|
|
|
|
|
|
return workspace_->GetCommondFilePath();
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetHomeViewpoint(const QString& vp)
|
|
{
|
|
if (nullptr == workspace_) {
|
|
return;
|
|
}
|
|
// Parse CSV string to osgEarth::Viewpoint and apply
|
|
osgEarth::Viewpoint viewpoint = StringUtils::StringToViewpoint("home", vp.toStdString());
|
|
workspace_->SetHomeViewpoint(viewpoint);
|
|
}
|
|
|
|
QString QWorkspaceAttribute::GetHomeViewpoint() const
|
|
{
|
|
if (nullptr == workspace_) {
|
|
return "";
|
|
}
|
|
const osgEarth::Viewpoint& vp = workspace_->GetHomeViewpoint();
|
|
return QString::fromStdString(StringUtils::ViewpointToString(vp));
|
|
}
|
|
|
|
// ---- Typed HomeViewpoint getters/setters ----
|
|
static void UpdateHomeViewpoint(WorkSpace* ws,
|
|
double lon, double lat, double alt,
|
|
double heading, double pitch, double range) {
|
|
if (!ws) return;
|
|
osgEarth::Viewpoint vp("home", lon, lat, alt, heading, pitch, range);
|
|
ws->SetHomeViewpoint(vp);
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetHomeViewpointLongitude() const {
|
|
if (!workspace_) return 0.0;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& location = vp.focalPoint();
|
|
return location->x();
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetHomeViewpointLatitude() const {
|
|
if (!workspace_) return 0.0;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& location = vp.focalPoint();
|
|
return location->y();
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetHomeViewpointAltitude() const {
|
|
if (!workspace_) return 0.0;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& location = vp.focalPoint();
|
|
return location->z();
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetHomeViewpointHeading() const {
|
|
if (!workspace_) return 0.0;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
return vp.heading().get().getValue();
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetHomeViewpointPitch() const {
|
|
if (!workspace_) return 0.0;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
return vp.pitch().get().getValue();
|
|
}
|
|
|
|
double QWorkspaceAttribute::GetHomeViewpointRange() const {
|
|
if (!workspace_) return 0.0;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
return vp.range().get().getValue();
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetHomeViewpointLongitude(double v) {
|
|
if (!workspace_) return;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& loc = vp.focalPoint();
|
|
UpdateHomeViewpoint(WorkSpaceManager::Get().GetCurrent(), v, loc->y(), loc->z(), vp.heading().get().getValue(), vp.pitch().get().getValue(), vp.range().get().getValue());
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetHomeViewpointLatitude(double v) {
|
|
if (!workspace_) return;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& loc = vp.focalPoint();
|
|
UpdateHomeViewpoint(WorkSpaceManager::Get().GetCurrent(), loc->x(), v, loc->z(), vp.heading().get().getValue(), vp.pitch().get().getValue(), vp.range().get().getValue());
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetHomeViewpointAltitude(double v) {
|
|
if (!workspace_) return;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& loc = vp.focalPoint();
|
|
UpdateHomeViewpoint(WorkSpaceManager::Get().GetCurrent(), loc->x(), loc->y(), v, vp.heading().get().getValue(), vp.pitch().get().getValue(), vp.range().get().getValue());
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetHomeViewpointHeading(double v) {
|
|
if (!workspace_) return;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& loc = vp.focalPoint();
|
|
UpdateHomeViewpoint(WorkSpaceManager::Get().GetCurrent(), loc->x(), loc->y(), loc->z(), v, vp.pitch().get().getValue(), vp.range().get().getValue());
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetHomeViewpointPitch(double v) {
|
|
if (!workspace_) return;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& loc = vp.focalPoint();
|
|
UpdateHomeViewpoint(WorkSpaceManager::Get().GetCurrent(), loc->x(), loc->y(), loc->z(), vp.heading().get().getValue(), v, vp.range().get().getValue());
|
|
}
|
|
|
|
void QWorkspaceAttribute::SetHomeViewpointRange(double v) {
|
|
if (!workspace_) return;
|
|
const auto& vp = workspace_->GetHomeViewpoint();
|
|
const auto& loc = vp.focalPoint();
|
|
UpdateHomeViewpoint(WorkSpaceManager::Get().GetCurrent(), loc->x(), loc->y(), loc->z(), vp.heading().get().getValue(), vp.pitch().get().getValue(), v);
|
|
}
|
|
|
|
std::vector<std::shared_ptr<FileEntry>> QWorkspaceAttribute::GetFileEntries(FileEntryType type) const {
|
|
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;
|
|
}
|
|
|
|
// 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);
|
|
// Trigger files changed signal properly
|
|
workspace_->NotifyFileEntryUpdated(type);
|
|
}
|
|
|
|
QString QWorkspaceAttribute::GetFileEntryAbsPath(FileEntryType type, int index) const {
|
|
if (nullptr == workspace_) {
|
|
return QString();
|
|
}
|
|
return workspace_->GetFileEntryAbsPath(type, index);
|
|
}
|
|
|
|
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) {
|
|
if (nullptr == entity) {
|
|
return;
|
|
}
|
|
transform_ = (new QTransformAttribute(entity->GetTransform()));
|
|
visible_ = entity->IsVisible();
|
|
}
|
|
|
|
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_;
|
|
}
|
|
|
|
void QEntityAttribute::SetVisible(bool v) {
|
|
visible_ = v;
|
|
if (nullptr == entity_) {
|
|
return;
|
|
}
|
|
|
|
entity_->SetVisible(v);
|
|
}
|
|
|
|
bool QEntityAttribute::IsVisible() const {
|
|
return visible_;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
QTrajectoryTraceComponentAttribute::QTrajectoryTraceComponentAttribute(TrajectoryTraceComponent* obj)
|
|
: object_(obj) {
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetColor(const QColor& c) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
osg::Vec4 vColor = object_->GetColor();
|
|
QColor color;
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
if (c == color) {
|
|
return;
|
|
}
|
|
|
|
OsgUtils::QColorToVec4(c, &vColor);
|
|
const std::string value = StringUtils::Vec4ToString(vColor);
|
|
object_->SetAttribute("color", value.c_str());
|
|
}
|
|
|
|
QColor QTrajectoryTraceComponentAttribute::GetColor() const {
|
|
if (nullptr == object_) {
|
|
return QColor();
|
|
}
|
|
|
|
osg::Vec4 vColor = object_->GetColor();
|
|
QColor color;
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
return color;
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetLineWidth(double width) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
const std::string value = std::to_string(width);
|
|
object_->SetAttribute("lineWidth", value.c_str());
|
|
}
|
|
|
|
double QTrajectoryTraceComponentAttribute::GetLineWidth() const {
|
|
if (nullptr == object_) {
|
|
return 2.0;
|
|
}
|
|
|
|
return object_->GetLineWidth();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetSampleInterval(double interval) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
const std::string value = std::to_string(interval);
|
|
object_->SetAttribute("sampleInterval", value.c_str());
|
|
}
|
|
|
|
double QTrajectoryTraceComponentAttribute::GetSampleInterval() const {
|
|
if (nullptr == object_) {
|
|
return 0.1;
|
|
}
|
|
|
|
return object_->GetSampleInterval();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetMinMoveDistance(double distance) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
const std::string value = std::to_string(distance);
|
|
object_->SetAttribute("minMoveDistance", value.c_str());
|
|
}
|
|
|
|
double QTrajectoryTraceComponentAttribute::GetMinMoveDistance() const {
|
|
if (nullptr == object_) {
|
|
return 1.0;
|
|
}
|
|
|
|
return object_->GetMinMoveDistance();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetMaxPoints(int maxPoints) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
const std::string value = std::to_string(maxPoints);
|
|
object_->SetAttribute("maxPoints", value.c_str());
|
|
}
|
|
|
|
int QTrajectoryTraceComponentAttribute::GetMaxPoints() const {
|
|
if (nullptr == object_) {
|
|
return 5000;
|
|
}
|
|
|
|
return object_->GetMaxPoints();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetTailDuration(double duration) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
const std::string value = std::to_string(duration);
|
|
object_->SetAttribute("tailDuration", value.c_str());
|
|
}
|
|
|
|
double QTrajectoryTraceComponentAttribute::GetTailDuration() const {
|
|
if (nullptr == object_) {
|
|
return 30.0;
|
|
}
|
|
|
|
return object_->GetTailDuration();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetVisible(bool visible) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
object_->SetAttribute("visible", visible ? "true" : "false");
|
|
}
|
|
|
|
bool QTrajectoryTraceComponentAttribute::IsVisible() const {
|
|
if (nullptr == object_) {
|
|
return true;
|
|
}
|
|
|
|
return object_->IsTraceVisible();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetDashed(bool dashed) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
object_->SetAttribute("dashed", dashed ? "true" : "false");
|
|
}
|
|
|
|
bool QTrajectoryTraceComponentAttribute::IsDashed() const {
|
|
if (nullptr == object_) {
|
|
return false;
|
|
}
|
|
|
|
return object_->IsDashed();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetDashLength(double length) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
const std::string value = std::to_string(length);
|
|
object_->SetAttribute("dashLength", value.c_str());
|
|
}
|
|
|
|
double QTrajectoryTraceComponentAttribute::GetDashLength() const {
|
|
if (nullptr == object_) {
|
|
return 150.0;
|
|
}
|
|
|
|
return object_->GetDashLength();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetGapLength(double length) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
const std::string value = std::to_string(length);
|
|
object_->SetAttribute("gapLength", value.c_str());
|
|
}
|
|
|
|
double QTrajectoryTraceComponentAttribute::GetGapLength() const {
|
|
if (nullptr == object_) {
|
|
return 100.0;
|
|
}
|
|
|
|
return object_->GetGapLength();
|
|
}
|
|
|
|
void QTrajectoryTraceComponentAttribute::SetDashScrollSpeed(double speed) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
const std::string value = std::to_string(speed);
|
|
object_->SetAttribute("dashScrollSpeed", value.c_str());
|
|
}
|
|
|
|
double QTrajectoryTraceComponentAttribute::GetDashScrollSpeed() const {
|
|
if (nullptr == object_) {
|
|
return 0.0;
|
|
}
|
|
|
|
return object_->GetDashScrollSpeed();
|
|
}
|
|
|
|
bool QTrajectoryTraceComponentAttribute::operator==(const QTrajectoryTraceComponentAttribute& other) {
|
|
return object_ == other.object_;
|
|
}
|
|
|
|
QTrajectoryTraceComponentAttribute& QTrajectoryTraceComponentAttribute::operator=(const QTrajectoryTraceComponentAttribute& 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();
|
|
}
|
|
|
|
void QConeWaveComponentAttribute::SetBaseColor(const QColor& c) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
osg::Vec4 vColor = object_->GetBaseColor();
|
|
QColor color;
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
if (c == color) {
|
|
return;
|
|
}
|
|
|
|
OsgUtils::QColorToVec4(c, &vColor);
|
|
object_->SetBaseColor(vColor);
|
|
}
|
|
|
|
QColor QConeWaveComponentAttribute::GetBaseColor() const {
|
|
if (nullptr == object_) {
|
|
return QColor();
|
|
}
|
|
osg::Vec4 vColor = object_->GetBaseColor();
|
|
QColor color;
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
return color;
|
|
}
|
|
|
|
void QConeWaveComponentAttribute::SetWaveColor(const QColor& c) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
osg::Vec4 vColor = object_->GetWaveColor();
|
|
QColor color;
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
if (c == color) {
|
|
return;
|
|
}
|
|
|
|
OsgUtils::QColorToVec4(c, &vColor);
|
|
object_->SetWaveColor(vColor);
|
|
}
|
|
|
|
QColor QConeWaveComponentAttribute::GetWaveColor() const {
|
|
if (nullptr == object_) {
|
|
return QColor();
|
|
}
|
|
osg::Vec4 vColor = object_->GetWaveColor();
|
|
QColor color;
|
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
|
return color;
|
|
}
|
|
|
|
void QConeWaveComponentAttribute::SetRingBrightAlpha(float a) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
if (a == object_->GetRingBrightAlpha()) {
|
|
return;
|
|
}
|
|
|
|
object_->SetRingBrightAlpha(a);
|
|
}
|
|
|
|
float QConeWaveComponentAttribute::GetRingBrightAlpha() const {
|
|
if (nullptr == object_) {
|
|
return 0.5f;
|
|
}
|
|
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();
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
void QConeWaveComponentAttribute::SetWaveCount(int c) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
if (c == object_->GetWaveCount()) {
|
|
return;
|
|
}
|
|
|
|
object_->SetWaveCount(c);
|
|
}
|
|
|
|
int QConeWaveComponentAttribute::GetWaveCount() const {
|
|
if (nullptr == object_) {
|
|
return 4;
|
|
}
|
|
return object_->GetWaveCount();
|
|
}
|
|
|
|
void QConeWaveComponentAttribute::SetWaveSpeed(float h) {
|
|
if (nullptr == object_) {
|
|
return;
|
|
}
|
|
|
|
if (h == object_->GetWaveSpeed()) {
|
|
return;
|
|
}
|
|
|
|
object_->SetWaveSpeed(h);
|
|
}
|
|
|
|
float QConeWaveComponentAttribute::GetWaveSpeed() const {
|
|
if (nullptr == object_) {
|
|
return 500.0f;
|
|
}
|
|
return object_->GetWaveSpeed();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
// ---- 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);
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|
|
|
|
QString QCurveEntryAttribute::GetName() const {
|
|
if (!entry_) return QString();
|
|
return entry_->GetName();
|
|
}
|
|
|
|
void QCurveEntryAttribute::SetChartType(ChartType type) {
|
|
if (!entry_) return;
|
|
entry_->SetChartType(type);
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|
|
|
|
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);
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|
|
|
|
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);
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|
|
|
|
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);
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|
|
|
|
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);
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|
|
|
|
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);
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|
|
|
|
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);
|
|
if (auto ws = WorkSpaceManager::Get().GetCurrent()) { ws->NotifyFileEntryUpdated(FileEntryType::Curve); }
|
|
}
|