From 8d957bbbb2987afc823083be9c16f470793630f4 Mon Sep 17 00:00:00 2001 From: brige Date: Thu, 26 Jun 2025 00:13:22 +0800 Subject: [PATCH] modify cone wave --- src/effects/ConeWave.cpp | 95 +++++++--- src/effects/ConeWave.h | 15 -- src/entities/ConeWaveComponent.cpp | 132 ++++--------- src/entities/ConeWaveComponent.h | 28 +-- src/translations/Dyt_zh_CN.ts | 43 +++-- src/ui/PropertyBrowser/qtpropertymanager.cpp | 179 ++++++++++-------- .../PropertyBrowser/qtworkspaceattribute.cpp | 81 ++++---- src/ui/PropertyBrowser/qtworkspaceattribute.h | 23 ++- 8 files changed, 294 insertions(+), 302 deletions(-) diff --git a/src/effects/ConeWave.cpp b/src/effects/ConeWave.cpp index 25445384..a61b3099 100644 --- a/src/effects/ConeWave.cpp +++ b/src/effects/ConeWave.cpp @@ -127,31 +127,66 @@ void ConeWave::Destory() { void ConeWave::SetHeight(float height) { height_ = height; - if (cone_) { + if (cone_.valid()) { cone_->setHeight(height_); + // 强制更新ShapeDrawable + if (coneDrawable_.valid()) { + coneDrawable_->dirtyDisplayList(); + coneDrawable_->dirtyBound(); + } } - //coneDrawable_->build(); -} - -void ConeWave::SetRadius(float radius) { - radius_ = radius; - if (cone_) { - cone_->setRadius(radius); + // 确保着色器已经初始化 + if (!levelHeightUniform_.valid() && coneDrawable_.valid()) { + CreateRadarShader(); + } + // 更新着色器中的高度uniform + if (levelHeightUniform_.valid()) { + levelHeightUniform_->set(height_ > 0 ? height_ : 100.0f); } - // coneDrawable_->build(); } void ConeWave::SetBaseColor(const osg::Vec4& 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(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) { waveRadius_ = radius; + // 确保着色器已经初始化 + if (!waveRadiusUniform_.valid() && coneDrawable_.valid()) { + CreateRadarShader(); + } if (waveRadiusUniform_.valid()) { 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(count)); - } -} - void ConeWave::SetWaveColor(const osg::Vec4& color) { waveColor_ = color; + // 确保着色器已经初始化 + if (!waveColorUniform_.valid() && coneDrawable_.valid()) { + CreateRadarShader(); + } if (waveColorUniform_.valid()) { - waveColorUniform_->set(color); + waveColorUniform_->set(waveColor_); } } // 透明度控制方法实现 void ConeWave::SetRingBrightAlpha(float alpha) { ringBrightAlpha_ = alpha; + // 确保着色器已经初始化 + if (!ringBrightAlphaUniform_.valid() && coneDrawable_.valid()) { + CreateRadarShader(); + } if (ringBrightAlphaUniform_.valid()) { ringBrightAlphaUniform_->set(alpha); } @@ -197,6 +226,10 @@ void ConeWave::SetRingBrightAlpha(float alpha) { void ConeWave::SetRingDarkAlpha(float alpha) { ringDarkAlpha_ = alpha; + // 确保着色器已经初始化 + if (!ringDarkAlphaUniform_.valid() && coneDrawable_.valid()) { + CreateRadarShader(); + } if (ringDarkAlphaUniform_.valid()) { ringDarkAlphaUniform_->set(alpha); } @@ -209,6 +242,9 @@ void ConeWave::SetConeAlpha(float alpha) { osg::Vec4 currentColor = coneDrawable_->getColor(); currentColor.a() = alpha; coneDrawable_->setColor(currentColor); + + // 强制更新ShapeDrawable以应用颜色变化 + coneDrawable_->dirtyDisplayList(); } } @@ -251,6 +287,11 @@ void ConeWave::CreateRadarScanWave() { } void ConeWave::CreateRadarShader() { + // 防止重复创建着色器 + if (waveTimeUniform_.valid()) { + return; + } + // 顶点着色器 - 使用简单的基于高度的条纹效果 static const char* vertexShaderSource = "varying vec3 pos;\n" diff --git a/src/effects/ConeWave.h b/src/effects/ConeWave.h index cef970ef..23b5e17e 100644 --- a/src/effects/ConeWave.h +++ b/src/effects/ConeWave.h @@ -40,26 +40,11 @@ public: return height_; } - void SetRadius(float radius); - float GetRadius() const { - return radius_; - } - void SetBaseColor(const osg::Vec4& color); const osg::Vec4 GetBaseColor() const { 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); float GetRingBrightAlpha() const { return ringBrightAlpha_; } diff --git a/src/entities/ConeWaveComponent.cpp b/src/entities/ConeWaveComponent.cpp index 6ee8e3fe..293d025e 100644 --- a/src/entities/ConeWaveComponent.cpp +++ b/src/entities/ConeWaveComponent.cpp @@ -15,14 +15,10 @@ ConeWaveComponent::ConeWaveComponent(SceneComponent* parent) : SceneComponent(parent) { coneWave_ = new ConeWave(); 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() { - // coneWave_->Destory(); + coneWave_->Destory(); } std::string ConeWaveComponent::GetTypeName() { @@ -30,22 +26,12 @@ std::string ConeWaveComponent::GetTypeName() { } bool ConeWaveComponent::SetAttribute(const char* name, const char* value) { - if (0 == strcmp("color1" ,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)) { + if (0 == strcmp("radius", name)) { SetRadius(atof(value)); } else if (0 == strcmp("height", name)) { SetHeight(atof(value)); } else if (0 == strcmp("event", name)) { 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)) { SetWaveRadius(atof(value)); } 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) { - 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("height", std::to_string(GetHeight()).c_str()); - element->SetAttribute("levelCount", std::to_string(GetLevelCount()).c_str()); - element->SetAttribute("levelHeihgt", std::to_string(GetLevelHeight()).c_str()); + element->SetAttribute("waveRadius", std::to_string(GetWaveRadius()).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()); return SceneComponent::SaveAttribute(element); } @@ -97,9 +70,9 @@ void ConeWaveComponent::Update(double dt) { void ConeWaveComponent::SetHeight(float height) { coneWave_->SetHeight(height); - if (nullptr != mt_) { - mt_->setMatrix(osg::Matrix::translate(osg::Vec3(0.0f, 0.0f, -coneWave_->GetHeght() * 0.75f))); - } + // if (nullptr != mt_) { + // mt_->setMatrix(osg::Matrix::translate(osg::Vec3(0.0f, 0.0f, -coneWave_->GetHeght() * 0.75f))); + // } } float ConeWaveComponent::GetHeight() const { @@ -107,27 +80,11 @@ float ConeWaveComponent::GetHeight() const { } void ConeWaveComponent::SetRadius(float radius) { - coneWave_->SetRadius(radius); + coneWave_->SetWaveRadius(radius); } float ConeWaveComponent::GetRadius() const { - return coneWave_->GetRadius(); -} - -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(); + return coneWave_->GetWaveRadius(); } void ConeWaveComponent::SetBaseColor(const osg::Vec4& color) { @@ -138,33 +95,6 @@ const osg::Vec4 ConeWaveComponent::GetBaseColor() const { 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) { if (nullptr != timeAction_) { timeAction_->deleteLater(); @@ -182,7 +112,6 @@ void ConeWaveComponent::AddToRender() { void ConeWaveComponent::Initialize() { mt_ = new osg::MatrixTransform; mt_->addChild(coneWave_); - mt_->setMatrix(osg::Matrix::translate(osg::Vec3(0.0f, 0.0f, -coneWave_->GetHeght() * 0.75f))); } void ConeWaveComponent::UpdateEvent() { @@ -204,15 +133,6 @@ void ConeWaveComponent::UpdateEvent() { return; } 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(); if (nullptr == timeStep) { @@ -228,11 +148,6 @@ void ConeWaveComponent::UpdateEvent() { 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; } +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; +} diff --git a/src/entities/ConeWaveComponent.h b/src/entities/ConeWaveComponent.h index c41ef42e..ac7f5c35 100644 --- a/src/entities/ConeWaveComponent.h +++ b/src/entities/ConeWaveComponent.h @@ -31,25 +31,11 @@ public: void SetRadius(float radius); float GetRadius() const; - void SetLevelCount(int count); - float GetLevelCount() const; - - void SetLevelHeight(float height); - float GetLevelHeight() const; - void SetBaseColor(const osg::Vec4& color); 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); float GetWaveRadius() const; @@ -58,9 +44,11 @@ public: void SetWaveCount(int count); int GetWaveCount() const; - - void SetWaveColor(const osg::Vec4& color); - const osg::Vec4& GetWaveColor() const; + + void SetRingBrightAlpha(float alpha); + float GetRingBrightAlpha() const; + void SetRingDarkAlpha(float alpha); + float GetRingDarkAlpha() const; void SetTimeAction(const QString& path); @@ -68,11 +56,9 @@ protected: void AddToRender() override; void Initialize(); void UpdateEvent(); - void AddColor(int32_t status, const osg::Vec4& color); protected: osg::ref_ptr coneWave_; - std::unordered_map colorMap_; class TimeAction* timeAction_{ nullptr }; int currentStatus_{ 0 }; }; diff --git a/src/translations/Dyt_zh_CN.ts b/src/translations/Dyt_zh_CN.ts index 2c2f586f..4336d47e 100644 --- a/src/translations/Dyt_zh_CN.ts +++ b/src/translations/Dyt_zh_CN.ts @@ -944,44 +944,49 @@ QtConeWaveComponentManager - - + + ConeWaveComponent - + Height - + Radius - - - levelCount - - - levelHeight + waveCount - Color1 + waveSpeed - Color2 + baseColor - Color3 + waveColor + + + + + ringBrightAlpha + + + + + ringDarkAlpha @@ -1086,28 +1091,28 @@ QtDashedLineComponentManager - - + + DashedLineComponent - + Start - + End - + Radius - + Color diff --git a/src/ui/PropertyBrowser/qtpropertymanager.cpp b/src/ui/PropertyBrowser/qtpropertymanager.cpp index 1c9bcb9b..aa8921f1 100644 --- a/src/ui/PropertyBrowser/qtpropertymanager.cpp +++ b/src/ui/PropertyBrowser/qtpropertymanager.cpp @@ -8726,19 +8726,21 @@ public: QMap m_properyToRadius; QMap m_properyToHeight; - QMap m_properyToLevelCount; - QMap m_properyToLevelHeight; - QMap m_properyToColor1; - QMap m_properyToColor2; - QMap m_properyToColor3; + QMap m_properyToWaveCount; + QMap m_properyToWaveSpeed; + QMap m_properyToBaseColor; + QMap m_properyToWaveColor; + QMap m_properyToRingBrightAlpha; + QMap m_properyToRingDarkAlpha; QMap m_radiusToPropery; QMap m_heightToPropery; - QMap m_levelCountToPropery; - QMap m_levelHeightToPropery; - QMap m_color1ToPropery; - QMap m_color2ToPropery; - QMap m_color3ToPropery; + QMap m_waveCountToPropery; + QMap m_waveSpeedToPropery; + QMap m_baseColorToPropery; + QMap m_waveColorToPropery; + QMap m_ringBrightAlphaToPropery; + QMap m_ringDarkAlphaToPropery; }; @@ -8751,35 +8753,39 @@ void QtConeWaveComponentManagerPrivate::slotDoubleChanged(QtProperty* property, QConeWaveComponentAttribute c = m_values[prop]; c.SetHeight(value); 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]; - 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); } } 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]; - c.SetLevelCount(value); + c.SetWaveCount(value); q_ptr->setValue(prop, c); } } 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]; - c.SetColor1(value); + c.SetBaseColor(value); 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]; - 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); - } + } } void QtConeWaveComponentManagerPrivate::slotPropertyDestroyed(QtProperty* property) { @@ -8791,26 +8797,26 @@ void QtConeWaveComponentManagerPrivate::slotPropertyDestroyed(QtProperty* proper m_heightToPropery[subProp] = 0; m_heightToPropery.remove(property); } - if (QtProperty* subProp = m_levelCountToPropery.value(property, nullptr)) { - m_levelCountToPropery[subProp] = 0; - m_levelCountToPropery.remove(property); + if (QtProperty* subProp = m_waveCountToPropery.value(property, nullptr)) { + m_waveCountToPropery[subProp] = 0; + m_waveCountToPropery.remove(property); } - if (QtProperty* subProp = m_levelHeightToPropery.value(property, nullptr)) { - m_levelHeightToPropery[subProp] = 0; - m_levelHeightToPropery.remove(property); + if (QtProperty* subProp = m_waveSpeedToPropery.value(property, nullptr)) { + m_waveSpeedToPropery[subProp] = 0; + m_waveSpeedToPropery.remove(property); } - if (QtProperty* subProp = m_color1ToPropery.value(property, nullptr)) { - m_color1ToPropery[subProp] = 0; - m_color1ToPropery.remove(property); + if (QtProperty* subProp = m_baseColorToPropery.value(property, nullptr)) { + m_baseColorToPropery[subProp] = 0; + m_baseColorToPropery.remove(property); } - if (QtProperty* subProp = m_color2ToPropery.value(property, nullptr)) { - m_color2ToPropery[subProp] = 0; - m_color2ToPropery.remove(property); + if (QtProperty* subProp = m_waveColorToPropery.value(property, nullptr)) { + m_waveColorToPropery[subProp] = 0; + m_waveColorToPropery.remove(property); } - if (QtProperty* subProp = m_color3ToPropery.value(property, nullptr)) { - m_color3ToPropery[subProp] = 0; - m_color3ToPropery.remove(property); + if (QtProperty* subProp = m_ringBrightAlphaToPropery.value(property, nullptr)) { + m_ringBrightAlphaToPropery[subProp] = 0; + 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_properyToHeight[property], value.GetHeight()); - d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToLevelHeight[property], value.GetLevelHeight()); - d_ptr->m_intProperyManager->setValue(d_ptr->m_properyToLevelCount[property], value.GetLevelCount()); - d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor1[property], value.GetColor1()); - d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor2[property], value.GetColor2()); - d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToColor3[property], value.GetColor3()); + d_ptr->m_doubleProperyManager->setValue(d_ptr->m_properyToWaveSpeed[property], value.GetWaveSpeed()); + d_ptr->m_intProperyManager->setValue(d_ptr->m_properyToWaveCount[property], value.GetWaveCount()); + d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToBaseColor[property], value.GetBaseColor()); + d_ptr->m_colorProperyManager->setValue(d_ptr->m_properyToWaveColor[property], value.GetWaveColor()); + 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 valueChanged(property, value); @@ -8955,38 +8962,45 @@ void QtConeWaveComponentManager::initializeProperty(QtProperty* property) { property->addSubProperty(prop); prop = d_ptr->m_intProperyManager->addProperty(); - prop->setPropertyName(tr("levelCount")); - d_ptr->m_intProperyManager->setValueOnly(prop, val.GetLevelCount()); - d_ptr->m_properyToLevelCount[property] = prop; - d_ptr->m_levelCountToPropery[prop] = property; + prop->setPropertyName(tr("waveCount")); + d_ptr->m_intProperyManager->setValueOnly(prop, val.GetWaveCount()); + d_ptr->m_properyToWaveCount[property] = prop; + d_ptr->m_waveCountToPropery[prop] = property; property->addSubProperty(prop); prop = d_ptr->m_doubleProperyManager->addProperty(); - prop->setPropertyName(tr("levelHeight")); - d_ptr->m_doubleProperyManager->setValueOnly(prop, val.GetLevelHeight()); - d_ptr->m_properyToLevelHeight[property] = prop; - d_ptr->m_levelHeightToPropery[prop] = property; + prop->setPropertyName(tr("waveSpeed")); + d_ptr->m_doubleProperyManager->setValueOnly(prop, val.GetWaveSpeed()); + d_ptr->m_properyToWaveSpeed[property] = prop; + d_ptr->m_waveSpeedToPropery[prop] = property; property->addSubProperty(prop); prop = d_ptr->m_colorProperyManager->addProperty(); - prop->setPropertyName(tr("Color1")); - d_ptr->m_colorProperyManager->setValue(prop, val.GetColor1()); - d_ptr->m_properyToColor1[property] = prop; - d_ptr->m_color1ToPropery[prop] = property; + prop->setPropertyName(tr("baseColor")); + d_ptr->m_colorProperyManager->setValue(prop, val.GetBaseColor()); + d_ptr->m_properyToBaseColor[property] = prop; + d_ptr->m_baseColorToPropery[prop] = property; property->addSubProperty(prop); prop = d_ptr->m_colorProperyManager->addProperty(); - prop->setPropertyName(tr("Color2")); - d_ptr->m_colorProperyManager->setValue(prop, val.GetColor2()); - d_ptr->m_properyToColor2[property] = prop; - d_ptr->m_color2ToPropery[prop] = property; + prop->setPropertyName(tr("waveColor")); + d_ptr->m_colorProperyManager->setValue(prop, val.GetWaveColor()); + d_ptr->m_properyToWaveColor[property] = prop; + d_ptr->m_waveColorToPropery[prop] = property; property->addSubProperty(prop); - prop = d_ptr->m_colorProperyManager->addProperty(); - prop->setPropertyName(tr("Color3")); - d_ptr->m_colorProperyManager->setValue(prop, val.GetColor3()); - d_ptr->m_properyToColor3[property] = prop; - d_ptr->m_color3ToPropery[prop] = property; + prop = d_ptr->m_doubleProperyManager->addProperty(); + prop->setPropertyName(tr("ringBrightAlpha")); + d_ptr->m_doubleProperyManager->setValue(prop, val.GetRingBrightAlpha()); + d_ptr->m_properyToRingBrightAlpha[property] = prop; + 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); } @@ -9008,40 +9022,47 @@ void QtConeWaveComponentManager::uninitializeProperty(QtProperty* property) { } d_ptr->m_properyToHeight.remove(property); - prop = d_ptr->m_levelCountToPropery[property]; + prop = d_ptr->m_waveCountToPropery[property]; if (prop) { - d_ptr->m_levelCountToPropery.remove(prop); + d_ptr->m_waveCountToPropery.remove(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) { - d_ptr->m_levelHeightToPropery.remove(prop); + d_ptr->m_waveSpeedToPropery.remove(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) { - d_ptr->m_color1ToPropery.remove(prop); + d_ptr->m_baseColorToPropery.remove(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) { - d_ptr->m_color2ToPropery.remove(prop); + d_ptr->m_waveColorToPropery.remove(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) { - d_ptr->m_color3ToPropery.remove(prop); + d_ptr->m_ringBrightAlphaToPropery.remove(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 diff --git a/src/ui/PropertyBrowser/qtworkspaceattribute.cpp b/src/ui/PropertyBrowser/qtworkspaceattribute.cpp index 45c705d2..2988312d 100644 --- a/src/ui/PropertyBrowser/qtworkspaceattribute.cpp +++ b/src/ui/PropertyBrowser/qtworkspaceattribute.cpp @@ -359,82 +359,93 @@ float QConeWaveComponentAttribute::GetRadius() const { return object_->GetRadius(); } -void QConeWaveComponentAttribute::SetColor1(const QColor& c) { +void QConeWaveComponentAttribute::SetBaseColor(const QColor& c) { if (nullptr == object_) { return; } - osg::Vec4 vColor = object_->GetColor1(); + osg::Vec4 vColor = object_->GetBaseColor(); QColor color; OsgUtils::Vec4ToQColor(vColor, &color); if (c == color) { return; } - OsgUtils::QColorToVec4(color, &vColor); - object_->SetColor1(vColor); + OsgUtils::QColorToVec4(c, &vColor); + object_->SetBaseColor(vColor); } -QColor QConeWaveComponentAttribute::GetColor1() const { +QColor QConeWaveComponentAttribute::GetBaseColor() const { if (nullptr == object_) { return QColor(); } - osg::Vec4 vColor = object_->GetColor1(); + osg::Vec4 vColor = object_->GetBaseColor(); QColor color; OsgUtils::Vec4ToQColor(vColor, &color); return color; } -void QConeWaveComponentAttribute::SetColor2(const QColor& c) { +void QConeWaveComponentAttribute::SetWaveColor(const QColor& c) { if (nullptr == object_) { return; } - osg::Vec4 vColor = object_->GetColor2(); + osg::Vec4 vColor = object_->GetWaveColor(); QColor color; OsgUtils::Vec4ToQColor(vColor, &color); if (c == color) { return; } - OsgUtils::QColorToVec4(color, &vColor); - object_->SetColor2(vColor); + OsgUtils::QColorToVec4(c, &vColor); + object_->SetWaveColor(vColor); } -QColor QConeWaveComponentAttribute::GetColor2() const { +QColor QConeWaveComponentAttribute::GetWaveColor() const { if (nullptr == object_) { return QColor(); } - osg::Vec4 vColor = object_->GetColor2(); + osg::Vec4 vColor = object_->GetWaveColor(); QColor color; OsgUtils::Vec4ToQColor(vColor, &color); return color; } -void QConeWaveComponentAttribute::SetColor3(const QColor& c) { +void QConeWaveComponentAttribute::SetRingBrightAlpha(float a) { if (nullptr == object_) { return; } - osg::Vec4 vColor = object_->GetColor3(); - QColor color; - OsgUtils::Vec4ToQColor(vColor, &color); - if (c == color) { + if (a == object_->GetRingBrightAlpha()) { return; } - OsgUtils::QColorToVec4(color, &vColor); - object_->SetColor3(vColor); + object_->SetRingBrightAlpha(a); } -QColor QConeWaveComponentAttribute::GetColor3() const { +float QConeWaveComponentAttribute::GetRingBrightAlpha() const { if (nullptr == object_) { - return QColor(); + return 0.5f; } - osg::Vec4 vColor = object_->GetColor3(); - QColor color; - OsgUtils::Vec4ToQColor(vColor, &color); - return color; + 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) { @@ -456,42 +467,42 @@ float QConeWaveComponentAttribute::GetHeight() const { return object_->GetHeight(); } -void QConeWaveComponentAttribute::SetLevelCount(int c) { +void QConeWaveComponentAttribute::SetWaveCount(int c) { if (nullptr == object_) { return; } - if (c == object_->GetLevelCount()) { + if (c == object_->GetWaveCount()) { return; } - object_->SetLevelCount(c); + object_->SetWaveCount(c); } -int QConeWaveComponentAttribute::GetLevelCount() const { +int QConeWaveComponentAttribute::GetWaveCount() const { if (nullptr == object_) { return 4; } - return object_->GetLevelCount(); + return object_->GetWaveCount(); } -void QConeWaveComponentAttribute::SetLevelHeight(float h) { +void QConeWaveComponentAttribute::SetWaveSpeed(float h) { if (nullptr == object_) { return; } - if (h == object_->GetLevelHeight()) { + if (h == object_->GetWaveSpeed()) { return; } - object_->SetLevelHeight(h); + object_->SetWaveSpeed(h); } -float QConeWaveComponentAttribute::GetLevelHeight() const { +float QConeWaveComponentAttribute::GetWaveSpeed() const { if (nullptr == object_) { return 500.0f; } - return object_->GetLevelHeight(); + return object_->GetWaveSpeed(); } bool QConeWaveComponentAttribute::operator==(const QConeWaveComponentAttribute& other) { diff --git a/src/ui/PropertyBrowser/qtworkspaceattribute.h b/src/ui/PropertyBrowser/qtworkspaceattribute.h index 49f8ff7d..23863dcc 100644 --- a/src/ui/PropertyBrowser/qtworkspaceattribute.h +++ b/src/ui/PropertyBrowser/qtworkspaceattribute.h @@ -168,21 +168,24 @@ public: void SetRadius(float r); float GetRadius() const; - void SetColor1(const QColor& c); - QColor GetColor1() const; - void SetColor2(const QColor& c); - QColor GetColor2() const; - void SetColor3(const QColor& c); - QColor GetColor3() const; + void SetBaseColor(const QColor& c); + QColor GetBaseColor() const; + void SetWaveColor(const QColor& c); + QColor GetWaveColor() const; + void SetRingBrightAlpha(float a); + float GetRingBrightAlpha() const; + void SetRingDarkAlpha(float a); + float GetRingDarkAlpha() const; void SetHeight(float h); float GetHeight() const; - void SetLevelCount(int c); - int GetLevelCount() const; + void SetWaveCount(int c); + int GetWaveCount() const; + + void SetWaveSpeed(float h); + float GetWaveSpeed() const; - void SetLevelHeight(float h); - float GetLevelHeight() const; private: