modify cone wave

This commit is contained in:
brige 2025-06-26 00:13:22 +08:00
parent 22ae2a57d2
commit 8d957bbbb2
8 changed files with 294 additions and 302 deletions

View File

@ -127,31 +127,66 @@ void ConeWave::Destory() {
void ConeWave::SetHeight(float height) { void ConeWave::SetHeight(float height) {
height_ = height; height_ = height;
if (cone_) { if (cone_.valid()) {
cone_->setHeight(height_); cone_->setHeight(height_);
// 强制更新ShapeDrawable
if (coneDrawable_.valid()) {
coneDrawable_->dirtyDisplayList();
coneDrawable_->dirtyBound();
} }
//coneDrawable_->build();
} }
// 确保着色器已经初始化
void ConeWave::SetRadius(float radius) { if (!levelHeightUniform_.valid() && coneDrawable_.valid()) {
radius_ = radius; CreateRadarShader();
if (cone_) { }
cone_->setRadius(radius); // 更新着色器中的高度uniform
if (levelHeightUniform_.valid()) {
levelHeightUniform_->set(height_ > 0 ? height_ : 100.0f);
} }
// coneDrawable_->build();
} }
void ConeWave::SetBaseColor(const osg::Vec4& color) { void ConeWave::SetBaseColor(const osg::Vec4& color) {
baseColor_ = color; baseColor_ = color;
//if (baseColorUniform_) { // 确保着色器已经初始化
// baseColorUniform_->set(color); if (!baseColorUniform_.valid() && coneDrawable_.valid()) {
//} CreateRadarShader();
}
if (baseColorUniform_.valid()) {
baseColorUniform_->set(baseColor_);
}
} }
void ConeWave::SetWaveCount(int count) {
waveCount_ = count;
// 确保着色器已经初始化
if (!waveCountUniform_.valid() && coneDrawable_.valid()) {
CreateRadarShader();
}
if (waveCountUniform_.valid()) {
waveCountUniform_->set(static_cast<float>(waveCount_));
}
}
void ConeWave::SetWaveSpeed(float speed) {
waveSpeed_ = speed;
// 确保着色器已经初始化
if (!waveSpeedUniform_.valid() && coneDrawable_.valid()) {
CreateRadarShader();
}
if (waveSpeedUniform_.valid()) {
waveSpeedUniform_->set(waveSpeed_);
}
}
// 雷达扫描波效果相关方法实现 // 雷达扫描波效果相关方法实现
void ConeWave::SetWaveRadius(float radius) { void ConeWave::SetWaveRadius(float radius) {
waveRadius_ = radius; waveRadius_ = radius;
// 确保着色器已经初始化
if (!waveRadiusUniform_.valid() && coneDrawable_.valid()) {
CreateRadarShader();
}
if (waveRadiusUniform_.valid()) { if (waveRadiusUniform_.valid()) {
waveRadiusUniform_->set(radius); waveRadiusUniform_->set(radius);
} }
@ -166,30 +201,24 @@ void ConeWave::SetWaveRadius(float radius) {
} }
} }
void ConeWave::SetWaveSpeed(float speed) {
waveSpeed_ = speed;
if (waveSpeedUniform_.valid()) {
waveSpeedUniform_->set(speed);
}
}
void ConeWave::SetWaveCount(int count) {
waveCount_ = count;
if (waveCountUniform_.valid()) {
waveCountUniform_->set(static_cast<float>(count));
}
}
void ConeWave::SetWaveColor(const osg::Vec4& color) { void ConeWave::SetWaveColor(const osg::Vec4& color) {
waveColor_ = color; waveColor_ = color;
// 确保着色器已经初始化
if (!waveColorUniform_.valid() && coneDrawable_.valid()) {
CreateRadarShader();
}
if (waveColorUniform_.valid()) { if (waveColorUniform_.valid()) {
waveColorUniform_->set(color); waveColorUniform_->set(waveColor_);
} }
} }
// 透明度控制方法实现 // 透明度控制方法实现
void ConeWave::SetRingBrightAlpha(float alpha) { void ConeWave::SetRingBrightAlpha(float alpha) {
ringBrightAlpha_ = alpha; ringBrightAlpha_ = alpha;
// 确保着色器已经初始化
if (!ringBrightAlphaUniform_.valid() && coneDrawable_.valid()) {
CreateRadarShader();
}
if (ringBrightAlphaUniform_.valid()) { if (ringBrightAlphaUniform_.valid()) {
ringBrightAlphaUniform_->set(alpha); ringBrightAlphaUniform_->set(alpha);
} }
@ -197,6 +226,10 @@ void ConeWave::SetRingBrightAlpha(float alpha) {
void ConeWave::SetRingDarkAlpha(float alpha) { void ConeWave::SetRingDarkAlpha(float alpha) {
ringDarkAlpha_ = alpha; ringDarkAlpha_ = alpha;
// 确保着色器已经初始化
if (!ringDarkAlphaUniform_.valid() && coneDrawable_.valid()) {
CreateRadarShader();
}
if (ringDarkAlphaUniform_.valid()) { if (ringDarkAlphaUniform_.valid()) {
ringDarkAlphaUniform_->set(alpha); ringDarkAlphaUniform_->set(alpha);
} }
@ -209,6 +242,9 @@ void ConeWave::SetConeAlpha(float alpha) {
osg::Vec4 currentColor = coneDrawable_->getColor(); osg::Vec4 currentColor = coneDrawable_->getColor();
currentColor.a() = alpha; currentColor.a() = alpha;
coneDrawable_->setColor(currentColor); coneDrawable_->setColor(currentColor);
// 强制更新ShapeDrawable以应用颜色变化
coneDrawable_->dirtyDisplayList();
} }
} }
@ -251,6 +287,11 @@ void ConeWave::CreateRadarScanWave() {
} }
void ConeWave::CreateRadarShader() { void ConeWave::CreateRadarShader() {
// 防止重复创建着色器
if (waveTimeUniform_.valid()) {
return;
}
// 顶点着色器 - 使用简单的基于高度的条纹效果 // 顶点着色器 - 使用简单的基于高度的条纹效果
static const char* vertexShaderSource = static const char* vertexShaderSource =
"varying vec3 pos;\n" "varying vec3 pos;\n"

View File

@ -40,26 +40,11 @@ public:
return height_; return height_;
} }
void SetRadius(float radius);
float GetRadius() const {
return radius_;
}
void SetBaseColor(const osg::Vec4& color); void SetBaseColor(const osg::Vec4& color);
const osg::Vec4 GetBaseColor() const { const osg::Vec4 GetBaseColor() const {
return baseColor_; return baseColor_;
} }
void SetLevelCount(int count) {};
int GetLevelCount() const {
return 0.f; // levelCount_;
}
void SetLevelHeight(float height) {}
float GetLevelHeihgt() const {
return 0.f; // levelHeight_;
}
// 透明度控制方法 // 透明度控制方法
void SetRingBrightAlpha(float alpha); void SetRingBrightAlpha(float alpha);
float GetRingBrightAlpha() const { return ringBrightAlpha_; } float GetRingBrightAlpha() const { return ringBrightAlpha_; }

View File

@ -15,14 +15,10 @@ ConeWaveComponent::ConeWaveComponent(SceneComponent* parent)
: SceneComponent(parent) { : SceneComponent(parent) {
coneWave_ = new ConeWave(); coneWave_ = new ConeWave();
coneWave_->InitGeode(); coneWave_->InitGeode();
colorMap_[1] = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
colorMap_[2] = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
colorMap_[3] = osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f);
} }
ConeWaveComponent::~ConeWaveComponent() { ConeWaveComponent::~ConeWaveComponent() {
// coneWave_->Destory(); coneWave_->Destory();
} }
std::string ConeWaveComponent::GetTypeName() { std::string ConeWaveComponent::GetTypeName() {
@ -30,22 +26,12 @@ std::string ConeWaveComponent::GetTypeName() {
} }
bool ConeWaveComponent::SetAttribute(const char* name, const char* value) { bool ConeWaveComponent::SetAttribute(const char* name, const char* value) {
if (0 == strcmp("color1" ,name)) { if (0 == strcmp("radius", name)) {
AddColor(1, StringUtils::StringToVec4(value));
} else if (0 == strcmp("color2" ,name)) {
AddColor(2, StringUtils::StringToVec4(value));
}else if (0 == strcmp("color3" ,name)) {
AddColor(3, StringUtils::StringToVec4(value));
} else if (0 == strcmp("radius", name)) {
SetRadius(atof(value)); SetRadius(atof(value));
} else if (0 == strcmp("height", name)) { } else if (0 == strcmp("height", name)) {
SetHeight(atof(value)); SetHeight(atof(value));
} else if (0 == strcmp("event", name)) { } else if (0 == strcmp("event", name)) {
SetTimeAction(value); SetTimeAction(value);
} else if (0 == strcmp("levelCount", name)) {
SetLevelCount(atof(value));
} else if (0 == strcmp("levelHeihgt", name)) {
SetLevelHeight(atof(value));
} else if (0 == strcmp("waveRadius", name)) { } else if (0 == strcmp("waveRadius", name)) {
SetWaveRadius(atof(value)); SetWaveRadius(atof(value));
} else if (0 == strcmp("waveSpeed", name)) { } else if (0 == strcmp("waveSpeed", name)) {
@ -60,25 +46,12 @@ bool ConeWaveComponent::SetAttribute(const char* name, const char* value) {
} }
bool ConeWaveComponent::SaveAttribute(tinyxml2::XMLElement* element) { bool ConeWaveComponent::SaveAttribute(tinyxml2::XMLElement* element) {
if (colorMap_.find(1) != colorMap_.end()) {
element->SetAttribute("color1", StringUtils::Vec4ToString(colorMap_[1]).c_str());
} else {
element->SetAttribute("color1", StringUtils::Vec4ToString(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)).c_str());
}
if (colorMap_.find(2) != colorMap_.end()) {
element->SetAttribute("color2", StringUtils::Vec4ToString(colorMap_[2]).c_str());
} else {
element->SetAttribute("color2", StringUtils::Vec4ToString(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)).c_str());
}
if (colorMap_.find(3) != colorMap_.end()) {
element->SetAttribute("color3", StringUtils::Vec4ToString(colorMap_[3]).c_str());
} else {
element->SetAttribute("color3", StringUtils::Vec4ToString(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f)).c_str());
}
element->SetAttribute("radius", std::to_string(GetRadius()).c_str()); element->SetAttribute("radius", std::to_string(GetRadius()).c_str());
element->SetAttribute("height", std::to_string(GetHeight()).c_str()); element->SetAttribute("height", std::to_string(GetHeight()).c_str());
element->SetAttribute("levelCount", std::to_string(GetLevelCount()).c_str()); element->SetAttribute("waveRadius", std::to_string(GetWaveRadius()).c_str());
element->SetAttribute("levelHeihgt", std::to_string(GetLevelHeight()).c_str()); element->SetAttribute("waveSpeed", std::to_string(GetWaveSpeed()).c_str());
element->SetAttribute("waveCount", std::to_string(GetWaveCount()).c_str());
element->SetAttribute("waveColor", StringUtils::Vec4ToString(GetWaveColor()).c_str());
element->SetAttribute("event", timeAction_ == nullptr ? "" : timeAction_->GetPath().toStdString().c_str()); element->SetAttribute("event", timeAction_ == nullptr ? "" : timeAction_->GetPath().toStdString().c_str());
return SceneComponent::SaveAttribute(element); return SceneComponent::SaveAttribute(element);
} }
@ -97,9 +70,9 @@ void ConeWaveComponent::Update(double dt) {
void ConeWaveComponent::SetHeight(float height) { void ConeWaveComponent::SetHeight(float height) {
coneWave_->SetHeight(height); coneWave_->SetHeight(height);
if (nullptr != mt_) { // if (nullptr != mt_) {
mt_->setMatrix(osg::Matrix::translate(osg::Vec3(0.0f, 0.0f, -coneWave_->GetHeght() * 0.75f))); // mt_->setMatrix(osg::Matrix::translate(osg::Vec3(0.0f, 0.0f, -coneWave_->GetHeght() * 0.75f)));
} // }
} }
float ConeWaveComponent::GetHeight() const { float ConeWaveComponent::GetHeight() const {
@ -107,27 +80,11 @@ float ConeWaveComponent::GetHeight() const {
} }
void ConeWaveComponent::SetRadius(float radius) { void ConeWaveComponent::SetRadius(float radius) {
coneWave_->SetRadius(radius); coneWave_->SetWaveRadius(radius);
} }
float ConeWaveComponent::GetRadius() const { float ConeWaveComponent::GetRadius() const {
return coneWave_->GetRadius(); return coneWave_->GetWaveRadius();
}
void ConeWaveComponent::SetLevelCount(int count) {
coneWave_->SetLevelCount(count);
}
float ConeWaveComponent::GetLevelCount() const {
return coneWave_->GetLevelCount();
}
void ConeWaveComponent::SetLevelHeight(float height) {
coneWave_->SetLevelHeight(height);
}
float ConeWaveComponent::GetLevelHeight() const {
return coneWave_->GetLevelHeihgt();
} }
void ConeWaveComponent::SetBaseColor(const osg::Vec4& color) { void ConeWaveComponent::SetBaseColor(const osg::Vec4& color) {
@ -138,33 +95,6 @@ const osg::Vec4 ConeWaveComponent::GetBaseColor() const {
return coneWave_->GetBaseColor(); return coneWave_->GetBaseColor();
} }
void ConeWaveComponent::SetColor1(const osg::Vec4& color) {
colorMap_[1] = color;
}
const osg::Vec4 ConeWaveComponent::GetColor1() const {
const auto color = colorMap_.find(1);
return color->second;
}
void ConeWaveComponent::SetColor2(const osg::Vec4& color) {
colorMap_[2] = color;
}
const osg::Vec4 ConeWaveComponent::GetColor2() const {
const auto color = colorMap_.find(2);
return color->second;
}
void ConeWaveComponent::SetColor3(const osg::Vec4& color) {
colorMap_[3] = color;
}
const osg::Vec4 ConeWaveComponent::GetColor3() const {
const auto color = colorMap_.find(3);
return color->second;
}
void ConeWaveComponent::SetTimeAction(const QString& path) { void ConeWaveComponent::SetTimeAction(const QString& path) {
if (nullptr != timeAction_) { if (nullptr != timeAction_) {
timeAction_->deleteLater(); timeAction_->deleteLater();
@ -182,7 +112,6 @@ void ConeWaveComponent::AddToRender() {
void ConeWaveComponent::Initialize() { void ConeWaveComponent::Initialize() {
mt_ = new osg::MatrixTransform; mt_ = new osg::MatrixTransform;
mt_->addChild(coneWave_); mt_->addChild(coneWave_);
mt_->setMatrix(osg::Matrix::translate(osg::Vec3(0.0f, 0.0f, -coneWave_->GetHeght() * 0.75f)));
} }
void ConeWaveComponent::UpdateEvent() { void ConeWaveComponent::UpdateEvent() {
@ -204,15 +133,6 @@ void ConeWaveComponent::UpdateEvent() {
return; return;
} }
currentStatus_ = lampStatus->GetCurrent(); currentStatus_ = lampStatus->GetCurrent();
if (colorMap_.find(currentStatus_) == colorMap_.end()) {
coneWave_->setNodeMask(0x0);
return;
}
osg::Vec4& color = colorMap_[currentStatus_];
coneWave_->SetBaseColor(color);
coneWave_->setNodeMask(0xff);
Timestep* timeStep = workspace->GetTimestep(); Timestep* timeStep = workspace->GetTimestep();
if (nullptr == timeStep) { if (nullptr == timeStep) {
@ -228,11 +148,6 @@ void ConeWaveComponent::UpdateEvent() {
coneWave_->setNodeMask(value == 0 ? 0x0 : 0xff); coneWave_->setNodeMask(value == 0 ? 0x0 : 0xff);
}
void ConeWaveComponent::AddColor(int32_t status, const osg::Vec4& color) {
colorMap_[status] = color;
} }
// 雷达扫描波效果相关方法实现 // 雷达扫描波效果相关方法实现
@ -289,3 +204,28 @@ const osg::Vec4& ConeWaveComponent::GetWaveColor() const {
return defaultColor; return defaultColor;
} }
void ConeWaveComponent::SetRingBrightAlpha(float alpha) {
if (coneWave_.valid()) {
coneWave_->SetRingBrightAlpha(alpha);
}
}
float ConeWaveComponent::GetRingBrightAlpha() const {
if (coneWave_.valid()) {
return coneWave_->GetRingBrightAlpha();
}
return 0.0f;
}
void ConeWaveComponent::SetRingDarkAlpha(float alpha) {
if (coneWave_.valid()) {
coneWave_->SetRingDarkAlpha(alpha);
}
}
float ConeWaveComponent::GetRingDarkAlpha() const {
if (coneWave_.valid()) {
return coneWave_->GetRingDarkAlpha();
}
return 0.0f;
}

View File

@ -31,25 +31,11 @@ public:
void SetRadius(float radius); void SetRadius(float radius);
float GetRadius() const; float GetRadius() const;
void SetLevelCount(int count);
float GetLevelCount() const;
void SetLevelHeight(float height);
float GetLevelHeight() const;
void SetBaseColor(const osg::Vec4& color); void SetBaseColor(const osg::Vec4& color);
const osg::Vec4 GetBaseColor() const; const osg::Vec4 GetBaseColor() const;
void SetWaveColor(const osg::Vec4& color);
const osg::Vec4& GetWaveColor() const;
void SetColor1(const osg::Vec4& color);
const osg::Vec4 GetColor1() const;
void SetColor2(const osg::Vec4& color);
const osg::Vec4 GetColor2() const;
void SetColor3(const osg::Vec4& color);
const osg::Vec4 GetColor3() const;
// 雷达扫描波效果相关方法
void SetWaveRadius(float radius); void SetWaveRadius(float radius);
float GetWaveRadius() const; float GetWaveRadius() const;
@ -59,8 +45,10 @@ public:
void SetWaveCount(int count); void SetWaveCount(int count);
int GetWaveCount() const; int GetWaveCount() const;
void SetWaveColor(const osg::Vec4& color); void SetRingBrightAlpha(float alpha);
const osg::Vec4& GetWaveColor() const; float GetRingBrightAlpha() const;
void SetRingDarkAlpha(float alpha);
float GetRingDarkAlpha() const;
void SetTimeAction(const QString& path); void SetTimeAction(const QString& path);
@ -68,11 +56,9 @@ protected:
void AddToRender() override; void AddToRender() override;
void Initialize(); void Initialize();
void UpdateEvent(); void UpdateEvent();
void AddColor(int32_t status, const osg::Vec4& color);
protected: protected:
osg::ref_ptr<class ConeWave> coneWave_; osg::ref_ptr<class ConeWave> coneWave_;
std::unordered_map<int32_t, osg::Vec4> colorMap_;
class TimeAction* timeAction_{ nullptr }; class TimeAction* timeAction_{ nullptr };
int currentStatus_{ 0 }; int currentStatus_{ 0 };
}; };

View File

@ -944,44 +944,49 @@
<context> <context>
<name>QtConeWaveComponentManager</name> <name>QtConeWaveComponentManager</name>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8848"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8854"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8857"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8863"/>
<source>ConeWaveComponent</source> <source>ConeWaveComponent</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8944"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8951"/>
<source>Height</source> <source>Height</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8951"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8958"/>
<source>Radius</source> <source>Radius</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8958"/>
<source>levelCount</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8965"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8965"/>
<source>levelHeight</source> <source>waveCount</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8972"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8972"/>
<source>Color1</source> <source>waveSpeed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8979"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8979"/>
<source>Color2</source> <source>baseColor</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8986"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8986"/>
<source>Color3</source> <source>waveColor</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8993"/>
<source>ringBrightAlpha</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9000"/>
<source>ringDarkAlpha</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -1086,28 +1091,28 @@
<context> <context>
<name>QtDashedLineComponentManager</name> <name>QtDashedLineComponentManager</name>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9171"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9192"/>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9180"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9201"/>
<source>DashedLineComponent</source> <source>DashedLineComponent</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9249"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9270"/>
<source>Start</source> <source>Start</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9256"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9277"/>
<source>End</source> <source>End</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9263"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9284"/>
<source>Radius</source> <source>Radius</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9270"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="9291"/>
<source>Color</source> <source>Color</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -8726,19 +8726,21 @@ public:
QMap<const QtProperty*, QtProperty*> m_properyToRadius; QMap<const QtProperty*, QtProperty*> m_properyToRadius;
QMap<const QtProperty*, QtProperty*> m_properyToHeight; QMap<const QtProperty*, QtProperty*> m_properyToHeight;
QMap<const QtProperty*, QtProperty*> m_properyToLevelCount; QMap<const QtProperty*, QtProperty*> m_properyToWaveCount;
QMap<const QtProperty*, QtProperty*> m_properyToLevelHeight; QMap<const QtProperty*, QtProperty*> m_properyToWaveSpeed;
QMap<const QtProperty*, QtProperty*> m_properyToColor1; QMap<const QtProperty*, QtProperty*> m_properyToBaseColor;
QMap<const QtProperty*, QtProperty*> m_properyToColor2; QMap<const QtProperty*, QtProperty*> m_properyToWaveColor;
QMap<const QtProperty*, QtProperty*> m_properyToColor3; QMap<const QtProperty*, QtProperty*> m_properyToRingBrightAlpha;
QMap<const QtProperty*, QtProperty*> m_properyToRingDarkAlpha;
QMap<const QtProperty*, QtProperty*> m_radiusToPropery; QMap<const QtProperty*, QtProperty*> m_radiusToPropery;
QMap<const QtProperty*, QtProperty*> m_heightToPropery; QMap<const QtProperty*, QtProperty*> m_heightToPropery;
QMap<const QtProperty*, QtProperty*> m_levelCountToPropery; QMap<const QtProperty*, QtProperty*> m_waveCountToPropery;
QMap<const QtProperty*, QtProperty*> m_levelHeightToPropery; QMap<const QtProperty*, QtProperty*> m_waveSpeedToPropery;
QMap<const QtProperty*, QtProperty*> m_color1ToPropery; QMap<const QtProperty*, QtProperty*> m_baseColorToPropery;
QMap<const QtProperty*, QtProperty*> m_color2ToPropery; QMap<const QtProperty*, QtProperty*> m_waveColorToPropery;
QMap<const QtProperty*, QtProperty*> m_color3ToPropery; QMap<const QtProperty*, QtProperty*> m_ringBrightAlphaToPropery;
QMap<const QtProperty*, QtProperty*> m_ringDarkAlphaToPropery;
}; };
@ -8751,33 +8753,37 @@ void QtConeWaveComponentManagerPrivate::slotDoubleChanged(QtProperty* property,
QConeWaveComponentAttribute c = m_values[prop]; QConeWaveComponentAttribute c = m_values[prop];
c.SetHeight(value); c.SetHeight(value);
q_ptr->setValue(prop, c); q_ptr->setValue(prop, c);
} else if (QtProperty* prop = m_levelHeightToPropery.value(property, 0)) { } else if (QtProperty* prop = m_waveSpeedToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop]; QConeWaveComponentAttribute c = m_values[prop];
c.SetLevelHeight(value); c.SetWaveSpeed(value);
q_ptr->setValue(prop, c);
} else if (QtProperty* prop = m_ringBrightAlphaToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop];
c.SetRingBrightAlpha(value);
q_ptr->setValue(prop, c);
} else if (QtProperty* prop = m_ringDarkAlphaToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop];
c.SetRingDarkAlpha(value);
q_ptr->setValue(prop, c); q_ptr->setValue(prop, c);
} }
} }
void QtConeWaveComponentManagerPrivate::slotIntChanged(QtProperty* property, int value) { void QtConeWaveComponentManagerPrivate::slotIntChanged(QtProperty* property, int value) {
if (QtProperty* prop = m_levelCountToPropery.value(property, 0)) { if (QtProperty* prop = m_waveCountToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop]; QConeWaveComponentAttribute c = m_values[prop];
c.SetLevelCount(value); c.SetWaveCount(value);
q_ptr->setValue(prop, c); q_ptr->setValue(prop, c);
} }
} }
void QtConeWaveComponentManagerPrivate::slotColorChanged(QtProperty* property, const QColor& value) { void QtConeWaveComponentManagerPrivate::slotColorChanged(QtProperty* property, const QColor& value) {
if (QtProperty* prop = m_color1ToPropery.value(property, 0)) { if (QtProperty* prop = m_baseColorToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop]; QConeWaveComponentAttribute c = m_values[prop];
c.SetColor1(value); c.SetBaseColor(value);
q_ptr->setValue(prop, c); q_ptr->setValue(prop, c);
} else if (QtProperty* prop = m_color2ToPropery.value(property, 0)) { } else if (QtProperty* prop = m_waveColorToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop]; QConeWaveComponentAttribute c = m_values[prop];
c.SetColor2(value); c.SetWaveColor(value);
q_ptr->setValue(prop, c);
} else if (QtProperty* prop = m_color3ToPropery.value(property, 0)) {
QConeWaveComponentAttribute c = m_values[prop];
c.SetColor3(value);
q_ptr->setValue(prop, c); q_ptr->setValue(prop, c);
} }
} }
@ -8791,26 +8797,26 @@ void QtConeWaveComponentManagerPrivate::slotPropertyDestroyed(QtProperty* proper
m_heightToPropery[subProp] = 0; m_heightToPropery[subProp] = 0;
m_heightToPropery.remove(property); m_heightToPropery.remove(property);
} }
if (QtProperty* subProp = m_levelCountToPropery.value(property, nullptr)) { if (QtProperty* subProp = m_waveCountToPropery.value(property, nullptr)) {
m_levelCountToPropery[subProp] = 0; m_waveCountToPropery[subProp] = 0;
m_levelCountToPropery.remove(property); m_waveCountToPropery.remove(property);
} }
if (QtProperty* subProp = m_levelHeightToPropery.value(property, nullptr)) { if (QtProperty* subProp = m_waveSpeedToPropery.value(property, nullptr)) {
m_levelHeightToPropery[subProp] = 0; m_waveSpeedToPropery[subProp] = 0;
m_levelHeightToPropery.remove(property); m_waveSpeedToPropery.remove(property);
} }
if (QtProperty* subProp = m_color1ToPropery.value(property, nullptr)) { if (QtProperty* subProp = m_baseColorToPropery.value(property, nullptr)) {
m_color1ToPropery[subProp] = 0; m_baseColorToPropery[subProp] = 0;
m_color1ToPropery.remove(property); m_baseColorToPropery.remove(property);
} }
if (QtProperty* subProp = m_color2ToPropery.value(property, nullptr)) { if (QtProperty* subProp = m_waveColorToPropery.value(property, nullptr)) {
m_color2ToPropery[subProp] = 0; m_waveColorToPropery[subProp] = 0;
m_color2ToPropery.remove(property); m_waveColorToPropery.remove(property);
} }
if (QtProperty* subProp = m_color3ToPropery.value(property, nullptr)) { if (QtProperty* subProp = m_ringBrightAlphaToPropery.value(property, nullptr)) {
m_color3ToPropery[subProp] = 0; m_ringBrightAlphaToPropery[subProp] = 0;
m_color3ToPropery.remove(property); m_ringBrightAlphaToPropery.remove(property);
} }
} }
@ -8923,11 +8929,12 @@ void QtConeWaveComponentManager::setValue(QtProperty* property, const QConeWaveC
d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToRadius[property], value.GetRadius()); d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToRadius[property], value.GetRadius());
d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToHeight[property], value.GetHeight()); d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToHeight[property], value.GetHeight());
d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToLevelHeight[property], value.GetLevelHeight()); d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToWaveSpeed[property], value.GetWaveSpeed());
d_ptr->m_intProperyManager->setValue(d_ptr->m_properyToLevelCount[property], value.GetLevelCount()); d_ptr->m_intProperyManager->setValue(d_ptr->m_properyToWaveCount[property], value.GetWaveCount());
d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor1[property], value.GetColor1()); d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToBaseColor[property], value.GetBaseColor());
d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor2[property], value.GetColor2()); d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToWaveColor[property], value.GetWaveColor());
d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor3[property], value.GetColor3()); d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToRingBrightAlpha[property], value.GetRingBrightAlpha());
d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToRingDarkAlpha[property], value.GetRingDarkAlpha());
emit propertyChanged(property); emit propertyChanged(property);
emit valueChanged(property, value); emit valueChanged(property, value);
@ -8955,38 +8962,45 @@ void QtConeWaveComponentManager::initializeProperty(QtProperty* property) {
property->addSubProperty(prop); property->addSubProperty(prop);
prop = d_ptr->m_intProperyManager->addProperty(); prop = d_ptr->m_intProperyManager->addProperty();
prop->setPropertyName(tr("levelCount")); prop->setPropertyName(tr("waveCount"));
d_ptr->m_intProperyManager->setValueOnly(prop, val.GetLevelCount()); d_ptr->m_intProperyManager->setValueOnly(prop, val.GetWaveCount());
d_ptr->m_properyToLevelCount[property] = prop; d_ptr->m_properyToWaveCount[property] = prop;
d_ptr->m_levelCountToPropery[prop] = property; d_ptr->m_waveCountToPropery[prop] = property;
property->addSubProperty(prop); property->addSubProperty(prop);
prop = d_ptr->m_doubleProperyManager->addProperty(); prop = d_ptr->m_doubleProperyManager->addProperty();
prop->setPropertyName(tr("levelHeight")); prop->setPropertyName(tr("waveSpeed"));
d_ptr->m_doubleProperyManager->setValueOnly(prop, val.GetLevelHeight()); d_ptr->m_doubleProperyManager->setValueOnly(prop, val.GetWaveSpeed());
d_ptr->m_properyToLevelHeight[property] = prop; d_ptr->m_properyToWaveSpeed[property] = prop;
d_ptr->m_levelHeightToPropery[prop] = property; d_ptr->m_waveSpeedToPropery[prop] = property;
property->addSubProperty(prop); property->addSubProperty(prop);
prop = d_ptr->m_colorProperyManager->addProperty(); prop = d_ptr->m_colorProperyManager->addProperty();
prop->setPropertyName(tr("Color1")); prop->setPropertyName(tr("baseColor"));
d_ptr->m_colorProperyManager->setValue(prop, val.GetColor1()); d_ptr->m_colorProperyManager->setValue(prop, val.GetBaseColor());
d_ptr->m_properyToColor1[property] = prop; d_ptr->m_properyToBaseColor[property] = prop;
d_ptr->m_color1ToPropery[prop] = property; d_ptr->m_baseColorToPropery[prop] = property;
property->addSubProperty(prop); property->addSubProperty(prop);
prop = d_ptr->m_colorProperyManager->addProperty(); prop = d_ptr->m_colorProperyManager->addProperty();
prop->setPropertyName(tr("Color2")); prop->setPropertyName(tr("waveColor"));
d_ptr->m_colorProperyManager->setValue(prop, val.GetColor2()); d_ptr->m_colorProperyManager->setValue(prop, val.GetWaveColor());
d_ptr->m_properyToColor2[property] = prop; d_ptr->m_properyToWaveColor[property] = prop;
d_ptr->m_color2ToPropery[prop] = property; d_ptr->m_waveColorToPropery[prop] = property;
property->addSubProperty(prop); property->addSubProperty(prop);
prop = d_ptr->m_colorProperyManager->addProperty(); prop = d_ptr->m_doubleProperyManager->addProperty();
prop->setPropertyName(tr("Color3")); prop->setPropertyName(tr("ringBrightAlpha"));
d_ptr->m_colorProperyManager->setValue(prop, val.GetColor3()); d_ptr->m_doubleProperyManager->setValue(prop, val.GetRingBrightAlpha());
d_ptr->m_properyToColor3[property] = prop; d_ptr->m_properyToRingBrightAlpha[property] = prop;
d_ptr->m_color3ToPropery[prop] = property; d_ptr->m_ringBrightAlphaToPropery[prop] = property;
property->addSubProperty(prop);
prop = d_ptr->m_doubleProperyManager->addProperty();
prop->setPropertyName(tr("ringDarkAlpha"));
d_ptr->m_doubleProperyManager->setValue(prop, val.GetRingDarkAlpha());
d_ptr->m_properyToRingDarkAlpha[property] = prop;
d_ptr->m_ringDarkAlphaToPropery[prop] = property;
property->addSubProperty(prop); property->addSubProperty(prop);
} }
@ -9008,40 +9022,47 @@ void QtConeWaveComponentManager::uninitializeProperty(QtProperty* property) {
} }
d_ptr->m_properyToHeight.remove(property); d_ptr->m_properyToHeight.remove(property);
prop = d_ptr->m_levelCountToPropery[property]; prop = d_ptr->m_waveCountToPropery[property];
if (prop) { if (prop) {
d_ptr->m_levelCountToPropery.remove(prop); d_ptr->m_waveCountToPropery.remove(prop);
delete prop; delete prop;
} }
d_ptr->m_properyToRadius.remove(property); d_ptr->m_properyToWaveCount.remove(property);
prop = d_ptr->m_levelHeightToPropery[property]; prop = d_ptr->m_waveSpeedToPropery[property];
if (prop) { if (prop) {
d_ptr->m_levelHeightToPropery.remove(prop); d_ptr->m_waveSpeedToPropery.remove(prop);
delete prop; delete prop;
} }
d_ptr->m_properyToHeight.remove(property); d_ptr->m_properyToWaveSpeed.remove(property);
prop = d_ptr->m_color1ToPropery[property]; prop = d_ptr->m_baseColorToPropery[property];
if (prop) { if (prop) {
d_ptr->m_color1ToPropery.remove(prop); d_ptr->m_baseColorToPropery.remove(prop);
delete prop; delete prop;
} }
d_ptr->m_properyToColor1.remove(property); d_ptr->m_properyToBaseColor.remove(property);
prop = d_ptr->m_color2ToPropery[property]; prop = d_ptr->m_waveColorToPropery[property];
if (prop) { if (prop) {
d_ptr->m_color2ToPropery.remove(prop); d_ptr->m_waveColorToPropery.remove(prop);
delete prop; delete prop;
} }
d_ptr->m_properyToColor2.remove(property); d_ptr->m_properyToWaveColor.remove(property);
prop = d_ptr->m_color3ToPropery[property]; prop = d_ptr->m_ringBrightAlphaToPropery[property];
if (prop) { if (prop) {
d_ptr->m_color3ToPropery.remove(prop); d_ptr->m_ringBrightAlphaToPropery.remove(prop);
delete prop; delete prop;
} }
d_ptr->m_properyToColor3.remove(property); d_ptr->m_properyToRingBrightAlpha.remove(property);
prop = d_ptr->m_ringDarkAlphaToPropery[property];
if (prop) {
d_ptr->m_ringDarkAlphaToPropery.remove(prop);
delete prop;
}
d_ptr->m_properyToRingDarkAlpha.remove(property);
} }
#pragma endregion #pragma endregion

View File

@ -359,82 +359,93 @@ float QConeWaveComponentAttribute::GetRadius() const {
return object_->GetRadius(); return object_->GetRadius();
} }
void QConeWaveComponentAttribute::SetColor1(const QColor& c) { void QConeWaveComponentAttribute::SetBaseColor(const QColor& c) {
if (nullptr == object_) { if (nullptr == object_) {
return; return;
} }
osg::Vec4 vColor = object_->GetColor1(); osg::Vec4 vColor = object_->GetBaseColor();
QColor color; QColor color;
OsgUtils::Vec4ToQColor(vColor, &color); OsgUtils::Vec4ToQColor(vColor, &color);
if (c == color) { if (c == color) {
return; return;
} }
OsgUtils::QColorToVec4(color, &vColor); OsgUtils::QColorToVec4(c, &vColor);
object_->SetColor1(vColor); object_->SetBaseColor(vColor);
} }
QColor QConeWaveComponentAttribute::GetColor1() const { QColor QConeWaveComponentAttribute::GetBaseColor() const {
if (nullptr == object_) { if (nullptr == object_) {
return QColor(); return QColor();
} }
osg::Vec4 vColor = object_->GetColor1(); osg::Vec4 vColor = object_->GetBaseColor();
QColor color; QColor color;
OsgUtils::Vec4ToQColor(vColor, &color); OsgUtils::Vec4ToQColor(vColor, &color);
return color; return color;
} }
void QConeWaveComponentAttribute::SetColor2(const QColor& c) { void QConeWaveComponentAttribute::SetWaveColor(const QColor& c) {
if (nullptr == object_) { if (nullptr == object_) {
return; return;
} }
osg::Vec4 vColor = object_->GetColor2(); osg::Vec4 vColor = object_->GetWaveColor();
QColor color; QColor color;
OsgUtils::Vec4ToQColor(vColor, &color); OsgUtils::Vec4ToQColor(vColor, &color);
if (c == color) { if (c == color) {
return; return;
} }
OsgUtils::QColorToVec4(color, &vColor); OsgUtils::QColorToVec4(c, &vColor);
object_->SetColor2(vColor); object_->SetWaveColor(vColor);
} }
QColor QConeWaveComponentAttribute::GetColor2() const { QColor QConeWaveComponentAttribute::GetWaveColor() const {
if (nullptr == object_) { if (nullptr == object_) {
return QColor(); return QColor();
} }
osg::Vec4 vColor = object_->GetColor2(); osg::Vec4 vColor = object_->GetWaveColor();
QColor color; QColor color;
OsgUtils::Vec4ToQColor(vColor, &color); OsgUtils::Vec4ToQColor(vColor, &color);
return color; return color;
} }
void QConeWaveComponentAttribute::SetColor3(const QColor& c) { void QConeWaveComponentAttribute::SetRingBrightAlpha(float a) {
if (nullptr == object_) { if (nullptr == object_) {
return; return;
} }
osg::Vec4 vColor = object_->GetColor3(); if (a == object_->GetRingBrightAlpha()) {
QColor color;
OsgUtils::Vec4ToQColor(vColor, &color);
if (c == color) {
return; return;
} }
OsgUtils::QColorToVec4(color, &vColor); object_->SetRingBrightAlpha(a);
object_->SetColor3(vColor);
} }
QColor QConeWaveComponentAttribute::GetColor3() const { float QConeWaveComponentAttribute::GetRingBrightAlpha() const {
if (nullptr == object_) { if (nullptr == object_) {
return QColor(); return 0.5f;
} }
osg::Vec4 vColor = object_->GetColor3(); return object_->GetRingBrightAlpha();
QColor color; }
OsgUtils::Vec4ToQColor(vColor, &color);
return color; 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) { void QConeWaveComponentAttribute::SetHeight(float h) {
@ -456,42 +467,42 @@ float QConeWaveComponentAttribute::GetHeight() const {
return object_->GetHeight(); return object_->GetHeight();
} }
void QConeWaveComponentAttribute::SetLevelCount(int c) { void QConeWaveComponentAttribute::SetWaveCount(int c) {
if (nullptr == object_) { if (nullptr == object_) {
return; return;
} }
if (c == object_->GetLevelCount()) { if (c == object_->GetWaveCount()) {
return; return;
} }
object_->SetLevelCount(c); object_->SetWaveCount(c);
} }
int QConeWaveComponentAttribute::GetLevelCount() const { int QConeWaveComponentAttribute::GetWaveCount() const {
if (nullptr == object_) { if (nullptr == object_) {
return 4; return 4;
} }
return object_->GetLevelCount(); return object_->GetWaveCount();
} }
void QConeWaveComponentAttribute::SetLevelHeight(float h) { void QConeWaveComponentAttribute::SetWaveSpeed(float h) {
if (nullptr == object_) { if (nullptr == object_) {
return; return;
} }
if (h == object_->GetLevelHeight()) { if (h == object_->GetWaveSpeed()) {
return; return;
} }
object_->SetLevelHeight(h); object_->SetWaveSpeed(h);
} }
float QConeWaveComponentAttribute::GetLevelHeight() const { float QConeWaveComponentAttribute::GetWaveSpeed() const {
if (nullptr == object_) { if (nullptr == object_) {
return 500.0f; return 500.0f;
} }
return object_->GetLevelHeight(); return object_->GetWaveSpeed();
} }
bool QConeWaveComponentAttribute::operator==(const QConeWaveComponentAttribute& other) { bool QConeWaveComponentAttribute::operator==(const QConeWaveComponentAttribute& other) {

View File

@ -168,21 +168,24 @@ public:
void SetRadius(float r); void SetRadius(float r);
float GetRadius() const; float GetRadius() const;
void SetColor1(const QColor& c); void SetBaseColor(const QColor& c);
QColor GetColor1() const; QColor GetBaseColor() const;
void SetColor2(const QColor& c); void SetWaveColor(const QColor& c);
QColor GetColor2() const; QColor GetWaveColor() const;
void SetColor3(const QColor& c); void SetRingBrightAlpha(float a);
QColor GetColor3() const; float GetRingBrightAlpha() const;
void SetRingDarkAlpha(float a);
float GetRingDarkAlpha() const;
void SetHeight(float h); void SetHeight(float h);
float GetHeight() const; float GetHeight() const;
void SetLevelCount(int c); void SetWaveCount(int c);
int GetLevelCount() const; int GetWaveCount() const;
void SetWaveSpeed(float h);
float GetWaveSpeed() const;
void SetLevelHeight(float h);
float GetLevelHeight() const;
private: private: