DYTSrouce/src/ui/PropertyBrowser/qtworkspaceattribute.cpp

557 lines
12 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/ConeWaveComponent.h"
#include "entities/DashedLineComponent.h"
#include "entities/EntitiesManager.h"
#include "utils/Transform.h"
#include "utils/OsgUtils.h"
QWorkspaceAttribute::QWorkspaceAttribute(class WorkSpace* workspace)
: workspace_(workspace) {
}
bool QWorkspaceAttribute::operator==(const QWorkspaceAttribute& other) {
return workspace_ == other.workspace_;
}
QWorkspaceAttribute& QWorkspaceAttribute::operator=(const QWorkspaceAttribute& other) {
workspace_ = other.workspace_;
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;
}
Timestep* obj = workspace_->GetTimestep();
if (nullptr == obj) {
workspace_->SetTimestepPath(timestep);
return;
}
const QString& path = obj->GetPath();
if (path == timestep) {
return;
}
workspace_->SetTimestepPath(timestep);
}
const QString QWorkspaceAttribute::GetTimeStep() const {
if (nullptr == workspace_) {
return "";
}
Timestep* timestep = workspace_->GetTimestep();
if (nullptr == timestep) {
return "";
}
return timestep->GetPath();
}
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()));
}
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_;
}
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();
}
void QConeWaveComponentAttribute::SetColor1(const QColor& c) {
if (nullptr == object_) {
return;
}
osg::Vec4 vColor = object_->GetColor1();
QColor color;
OsgUtils::Vec4ToQColor(vColor, &color);
if (c == color) {
return;
}
OsgUtils::QColorToVec4(color, &vColor);
object_->SetColor1(vColor);
}
QColor QConeWaveComponentAttribute::GetColor1() const {
if (nullptr == object_) {
return QColor();
}
osg::Vec4 vColor = object_->GetColor1();
QColor color;
OsgUtils::Vec4ToQColor(vColor, &color);
return color;
}
void QConeWaveComponentAttribute::SetColor2(const QColor& c) {
if (nullptr == object_) {
return;
}
osg::Vec4 vColor = object_->GetColor2();
QColor color;
OsgUtils::Vec4ToQColor(vColor, &color);
if (c == color) {
return;
}
OsgUtils::QColorToVec4(color, &vColor);
object_->SetColor2(vColor);
}
QColor QConeWaveComponentAttribute::GetColor2() const {
if (nullptr == object_) {
return QColor();
}
osg::Vec4 vColor = object_->GetColor2();
QColor color;
OsgUtils::Vec4ToQColor(vColor, &color);
return color;
}
void QConeWaveComponentAttribute::SetColor3(const QColor& c) {
if (nullptr == object_) {
return;
}
osg::Vec4 vColor = object_->GetColor3();
QColor color;
OsgUtils::Vec4ToQColor(vColor, &color);
if (c == color) {
return;
}
OsgUtils::QColorToVec4(color, &vColor);
object_->SetColor3(vColor);
}
QColor QConeWaveComponentAttribute::GetColor3() const {
if (nullptr == object_) {
return QColor();
}
osg::Vec4 vColor = object_->GetColor3();
QColor color;
OsgUtils::Vec4ToQColor(vColor, &color);
return color;
}
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::SetLevelCount(int c) {
if (nullptr == object_) {
return;
}
if (c == object_->GetLevelCount()) {
return;
}
object_->SetLevelCount(c);
}
int QConeWaveComponentAttribute::GetLevelCount() const {
if (nullptr == object_) {
return 4;
}
return object_->GetLevelCount();
}
void QConeWaveComponentAttribute::SetLevelHeight(float h) {
if (nullptr == object_) {
return;
}
if (h == object_->GetLevelHeight()) {
return;
}
object_->SetLevelHeight(h);
}
float QConeWaveComponentAttribute::GetLevelHeight() const {
if (nullptr == object_) {
return 500.0f;
}
return object_->GetLevelHeight();
}
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;
}