add lamp status and attribute ui
This commit is contained in:
parent
53b8bb5099
commit
734ab428cd
@ -8,6 +8,7 @@
|
|||||||
#include "entities/Entity.h"
|
#include "entities/Entity.h"
|
||||||
#include "workspace/WorkSpace.h"
|
#include "workspace/WorkSpace.h"
|
||||||
#include "workspace/Timestep.h"
|
#include "workspace/Timestep.h"
|
||||||
|
#include "workspace/LampStatus.h"
|
||||||
|
|
||||||
|
|
||||||
ConeWaveComponent::ConeWaveComponent(SceneComponent* parent)
|
ConeWaveComponent::ConeWaveComponent(SceneComponent* parent)
|
||||||
@ -15,6 +16,10 @@ ConeWaveComponent::ConeWaveComponent(SceneComponent* parent)
|
|||||||
const QString txturePath = RecourceHelper::Get().GetBasePath() + "/resources/textures/stripes_h.png";
|
const QString txturePath = RecourceHelper::Get().GetBasePath() + "/resources/textures/stripes_h.png";
|
||||||
coneWave_ = new ConeWave(txturePath.toStdString());
|
coneWave_ = new ConeWave(txturePath.toStdString());
|
||||||
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() {
|
||||||
@ -26,8 +31,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("color" ,name)) {
|
if (0 == strcmp("color1" ,name)) {
|
||||||
SetBaseColor(StringUtils::StringToVec4(value));
|
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)) {
|
} else if (0 == strcmp("radius", name)) {
|
||||||
SetRadius(atof(value));
|
SetRadius(atof(value));
|
||||||
} else if (0 == strcmp("height", name)) {
|
} else if (0 == strcmp("height", name)) {
|
||||||
@ -40,7 +49,21 @@ bool ConeWaveComponent::SetAttribute(const char* name, const char* value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ConeWaveComponent::SaveAttribute(tinyxml2::XMLElement* element) {
|
bool ConeWaveComponent::SaveAttribute(tinyxml2::XMLElement* element) {
|
||||||
element->SetAttribute("color", StringUtils::Vec4ToString(GetBaseColor()).c_str());
|
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("event", timeAction_ == nullptr ? "" : timeAction_->GetPath().toStdString().c_str());
|
element->SetAttribute("event", timeAction_ == nullptr ? "" : timeAction_->GetPath().toStdString().c_str());
|
||||||
@ -82,6 +105,33 @@ 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();
|
||||||
@ -112,18 +162,43 @@ void ConeWaveComponent::UpdateEvent() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestep* timeStep = workspace->GetTimestep();
|
LampStatus* lampStatus = workspace->GetLampStatus();
|
||||||
if (nullptr == timeStep) {
|
if (nullptr == lampStatus) {
|
||||||
LOG_WARN("timeStep is nullptr");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double dt = timeStep->GetCurrent();
|
if (currentStatus_ == lampStatus->GetCurrent()) {
|
||||||
int value = timeAction_->GetValue(dt);
|
return;
|
||||||
if (-1 == value) {
|
}
|
||||||
|
currentStatus_ = lampStatus->GetCurrent();
|
||||||
|
if (colorMap_.find(currentStatus_) == colorMap_.end()) {
|
||||||
|
coneWave_->setNodeMask(0x0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
coneWave_->setNodeMask(value == 0 ? 0x0 : 0xff);
|
osg::Vec4& color = colorMap_[currentStatus_];
|
||||||
|
coneWave_->SetBaseColor(color);
|
||||||
|
coneWave_->setNodeMask(0xff);
|
||||||
|
|
||||||
|
|
||||||
|
//Timestep* timeStep = workspace->GetTimestep();
|
||||||
|
//if (nullptr == timeStep) {
|
||||||
|
// LOG_WARN("timeStep is nullptr");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//double dt = timeStep->GetCurrent();
|
||||||
|
//int value = timeAction_->GetValue(dt);
|
||||||
|
//if (-1 == value) {
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
|
||||||
|
//coneWave_->setNodeMask(value == 0 ? 0x0 : 0xff);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConeWaveComponent::AddColor(int32_t status, const osg::Vec4& color) {
|
||||||
|
colorMap_[status] = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "entities/SceneComponent.h"
|
#include "entities/SceneComponent.h"
|
||||||
|
|
||||||
#include "osg/Vec3"
|
#include "osg/Vec3"
|
||||||
@ -32,14 +34,26 @@ public:
|
|||||||
void SetBaseColor(const osg::Vec4& color);
|
void SetBaseColor(const osg::Vec4& color);
|
||||||
const osg::Vec4 GetBaseColor() const;
|
const osg::Vec4 GetBaseColor() 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 SetTimeAction(const QString& path);
|
void SetTimeAction(const QString& path);
|
||||||
|
|
||||||
protected:
|
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 };
|
||||||
};
|
};
|
||||||
|
@ -322,52 +322,52 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="66"/>
|
<location filename="../ui/MainWindow.cpp" line="67"/>
|
||||||
<source>model elements</source>
|
<source>model elements</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="72"/>
|
<location filename="../ui/MainWindow.cpp" line="73"/>
|
||||||
<source>attribte</source>
|
<source>attribte</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="88"/>
|
<location filename="../ui/MainWindow.cpp" line="89"/>
|
||||||
<source>Wave Curve</source>
|
<source>Wave Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="98"/>
|
<location filename="../ui/MainWindow.cpp" line="99"/>
|
||||||
<source>Speed Curve</source>
|
<source>Speed Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="108"/>
|
<location filename="../ui/MainWindow.cpp" line="109"/>
|
||||||
<source>3D Curve</source>
|
<source>3D Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="136"/>
|
<location filename="../ui/MainWindow.cpp" line="137"/>
|
||||||
<source>Report Table</source>
|
<source>Report Table</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="162"/>
|
<location filename="../ui/MainWindow.cpp" line="163"/>
|
||||||
<source>Report</source>
|
<source>Report</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="173"/>
|
<location filename="../ui/MainWindow.cpp" line="174"/>
|
||||||
<source>Signal Indicator Lamp</source>
|
<source>Signal Indicator Lamp</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="182"/>
|
<location filename="../ui/MainWindow.cpp" line="183"/>
|
||||||
<source>name: 5year 0412</source>
|
<source>name: 5year 0412</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="183"/>
|
<location filename="../ui/MainWindow.cpp" line="184"/>
|
||||||
<source>start: no start</source>
|
<source>start: no start</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -690,24 +690,34 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QtConeWaveComponentManager</name>
|
<name>QtConeWaveComponentManager</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8326"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8347"/>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8335"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8356"/>
|
||||||
<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="8414"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8437"/>
|
||||||
<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="8421"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8444"/>
|
||||||
<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="8428"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8451"/>
|
||||||
<source>Color</source>
|
<source>Color1</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8458"/>
|
||||||
|
<source>Color2</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8465"/>
|
||||||
|
<source>Color3</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
@ -812,28 +822,28 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QtDashedLineComponentManager</name>
|
<name>QtDashedLineComponentManager</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8585"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8636"/>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8594"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8645"/>
|
||||||
<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="8663"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8714"/>
|
||||||
<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="8670"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8721"/>
|
||||||
<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="8677"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8728"/>
|
||||||
<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="8684"/>
|
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8735"/>
|
||||||
<source>Color</source>
|
<source>Color</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -213,6 +213,21 @@ void SignalIndicatorLampUI::slotUpdateTime(double dTime)
|
|||||||
SetLampState(vecStatus);
|
SetLampState(vecStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SignalIndicatorLampUI::onStatusChanged(int status) {
|
||||||
|
if ((status) >= m_lampStatus.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> vecStatus;
|
||||||
|
for (size_t i = 0; i < m_iLampCount; i++) {
|
||||||
|
vecStatus.push_back(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vecStatus[status - 1] = 1;
|
||||||
|
|
||||||
|
SetLampState(vecStatus);
|
||||||
|
}
|
||||||
|
|
||||||
void SignalIndicatorLampUI::paintEvent(QPaintEvent* event)
|
void SignalIndicatorLampUI::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotUpdateTime(double dTime);
|
void slotUpdateTime(double dTime);
|
||||||
|
void onStatusChanged(int status);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent* event);
|
void paintEvent(QPaintEvent* event);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "../workspace/WorkSpaceManager.h"
|
#include "../workspace/WorkSpaceManager.h"
|
||||||
#include "../workspace/WorkSpace.h"
|
#include "../workspace/WorkSpace.h"
|
||||||
#include "../workspace/Timestep.h"
|
#include "../workspace/Timestep.h"
|
||||||
|
#include "../workspace/LampStatus.h"
|
||||||
|
|
||||||
#include "ui_MainWindow.h"
|
#include "ui_MainWindow.h"
|
||||||
|
|
||||||
@ -174,7 +175,7 @@ void MainWindow::InitUI() {
|
|||||||
signalIndicatorLampUI_ = new SignalIndicatorLampUI;
|
signalIndicatorLampUI_ = new SignalIndicatorLampUI;
|
||||||
signalIndicatorLampUI_->AttachDock(signalIndicatorLampDock);
|
signalIndicatorLampUI_->AttachDock(signalIndicatorLampDock);
|
||||||
signalIndicatorLampUI_->InitLamp(lampPath);
|
signalIndicatorLampUI_->InitLamp(lampPath);
|
||||||
connect(WorkSpaceManager::Get().GetCurrent()->GetTimestep(), SIGNAL(TimeChanged(double)), signalIndicatorLampUI_, SLOT(slotUpdateTime(double)));
|
connect(WorkSpaceManager::Get().GetCurrent()->GetLampStatus(), SIGNAL(StatusChanged(int)), signalIndicatorLampUI_, SLOT(onStatusChanged(int)));
|
||||||
|
|
||||||
m_mapDockWidget.insert("SignalIndicatorLampUI", signalIndicatorLampDock);
|
m_mapDockWidget.insert("SignalIndicatorLampUI", signalIndicatorLampDock);
|
||||||
|
|
||||||
|
@ -8254,11 +8254,15 @@ 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_properyToColor;
|
QMap<const QtProperty*, QtProperty*> m_properyToColor1;
|
||||||
|
QMap<const QtProperty*, QtProperty*> m_properyToColor2;
|
||||||
|
QMap<const QtProperty*, QtProperty*> m_properyToColor3;
|
||||||
|
|
||||||
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_colorToPropery;
|
QMap<const QtProperty*, QtProperty*> m_color1ToPropery;
|
||||||
|
QMap<const QtProperty*, QtProperty*> m_color2ToPropery;
|
||||||
|
QMap<const QtProperty*, QtProperty*> m_color3ToPropery;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -8276,9 +8280,17 @@ void QtConeWaveComponentManagerPrivate::slotDoubleChanged(QtProperty* property,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QtConeWaveComponentManagerPrivate::slotColorChanged(QtProperty* property, const QColor& value) {
|
void QtConeWaveComponentManagerPrivate::slotColorChanged(QtProperty* property, const QColor& value) {
|
||||||
if (QtProperty* prop = m_colorToPropery.value(property, 0)) {
|
if (QtProperty* prop = m_color1ToPropery.value(property, 0)) {
|
||||||
QConeWaveComponentAttribute c = m_values[prop];
|
QConeWaveComponentAttribute c = m_values[prop];
|
||||||
c.SetColor(value);
|
c.SetColor1(value);
|
||||||
|
q_ptr->setValue(prop, c);
|
||||||
|
} else if (QtProperty* prop = m_color2ToPropery.value(property, 0)) {
|
||||||
|
QConeWaveComponentAttribute c = m_values[prop];
|
||||||
|
c.SetColor2(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8292,9 +8304,18 @@ 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_colorToPropery.value(property, nullptr)) {
|
if (QtProperty* subProp = m_color1ToPropery.value(property, nullptr)) {
|
||||||
m_colorToPropery[subProp] = 0;
|
m_color1ToPropery[subProp] = 0;
|
||||||
m_colorToPropery.remove(property);
|
m_color1ToPropery.remove(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QtProperty* subProp = m_color2ToPropery.value(property, nullptr)) {
|
||||||
|
m_color2ToPropery[subProp] = 0;
|
||||||
|
m_color2ToPropery.remove(property);
|
||||||
|
}
|
||||||
|
if (QtProperty* subProp = m_color3ToPropery.value(property, nullptr)) {
|
||||||
|
m_color3ToPropery[subProp] = 0;
|
||||||
|
m_color3ToPropery.remove(property);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8397,7 +8418,9 @@ 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_colorProperyManager->setValue(d_ptr->m_properyToColor[property], value.GetColor());
|
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());
|
||||||
|
|
||||||
emit propertyChanged(property);
|
emit propertyChanged(property);
|
||||||
emit valueChanged(property, value);
|
emit valueChanged(property, value);
|
||||||
@ -8425,10 +8448,24 @@ void QtConeWaveComponentManager::initializeProperty(QtProperty* property) {
|
|||||||
property->addSubProperty(prop);
|
property->addSubProperty(prop);
|
||||||
|
|
||||||
prop = d_ptr->m_colorProperyManager->addProperty();
|
prop = d_ptr->m_colorProperyManager->addProperty();
|
||||||
prop->setPropertyName(tr("Color"));
|
prop->setPropertyName(tr("Color1"));
|
||||||
d_ptr->m_colorProperyManager->setValue(prop, val.GetColor());
|
d_ptr->m_colorProperyManager->setValue(prop, val.GetColor1());
|
||||||
d_ptr->m_properyToColor[property] = prop;
|
d_ptr->m_properyToColor1[property] = prop;
|
||||||
d_ptr->m_colorToPropery[prop] = property;
|
d_ptr->m_color1ToPropery[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;
|
||||||
|
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;
|
||||||
property->addSubProperty(prop);
|
property->addSubProperty(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8450,12 +8487,26 @@ void QtConeWaveComponentManager::uninitializeProperty(QtProperty* property) {
|
|||||||
}
|
}
|
||||||
d_ptr->m_properyToHeight.remove(property);
|
d_ptr->m_properyToHeight.remove(property);
|
||||||
|
|
||||||
prop = d_ptr->m_colorToPropery[property];
|
prop = d_ptr->m_color1ToPropery[property];
|
||||||
if (prop) {
|
if (prop) {
|
||||||
d_ptr->m_colorToPropery.remove(prop);
|
d_ptr->m_color1ToPropery.remove(prop);
|
||||||
delete prop;
|
delete prop;
|
||||||
}
|
}
|
||||||
d_ptr->m_properyToColor.remove(property);
|
d_ptr->m_properyToColor1.remove(property);
|
||||||
|
|
||||||
|
prop = d_ptr->m_color2ToPropery[property];
|
||||||
|
if (prop) {
|
||||||
|
d_ptr->m_color2ToPropery.remove(prop);
|
||||||
|
delete prop;
|
||||||
|
}
|
||||||
|
d_ptr->m_properyToColor2.remove(property);
|
||||||
|
|
||||||
|
prop = d_ptr->m_color3ToPropery[property];
|
||||||
|
if (prop) {
|
||||||
|
d_ptr->m_color3ToPropery.remove(prop);
|
||||||
|
delete prop;
|
||||||
|
}
|
||||||
|
d_ptr->m_properyToColor3.remove(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
@ -265,12 +265,12 @@ float QConeWaveComponentAttribute::GetRadius() const {
|
|||||||
return object_->GetRadius();
|
return object_->GetRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QConeWaveComponentAttribute::SetColor(const QColor& c) {
|
void QConeWaveComponentAttribute::SetColor1(const QColor& c) {
|
||||||
if (nullptr == object_) {
|
if (nullptr == object_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Vec4 vColor = object_->GetBaseColor();
|
osg::Vec4 vColor = object_->GetColor1();
|
||||||
QColor color;
|
QColor color;
|
||||||
OsgUtils::Vec4ToQColor(vColor, &color);
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
||||||
if (c == color) {
|
if (c == color) {
|
||||||
@ -278,14 +278,66 @@ void QConeWaveComponentAttribute::SetColor(const QColor& c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OsgUtils::QColorToVec4(color, &vColor);
|
OsgUtils::QColorToVec4(color, &vColor);
|
||||||
object_->SetBaseColor(vColor);
|
object_->SetColor1(vColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QConeWaveComponentAttribute::GetColor() const {
|
QColor QConeWaveComponentAttribute::GetColor1() const {
|
||||||
if (nullptr == object_) {
|
if (nullptr == object_) {
|
||||||
return QColor();
|
return QColor();
|
||||||
}
|
}
|
||||||
osg::Vec4 vColor = object_->GetBaseColor();
|
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;
|
QColor color;
|
||||||
OsgUtils::Vec4ToQColor(vColor, &color);
|
OsgUtils::Vec4ToQColor(vColor, &color);
|
||||||
return color;
|
return color;
|
||||||
|
@ -154,8 +154,12 @@ public:
|
|||||||
void SetRadius(float r);
|
void SetRadius(float r);
|
||||||
float GetRadius() const;
|
float GetRadius() const;
|
||||||
|
|
||||||
void SetColor(const QColor& c);
|
void SetColor1(const QColor& c);
|
||||||
QColor GetColor() const;
|
QColor GetColor1() const;
|
||||||
|
void SetColor2(const QColor& c);
|
||||||
|
QColor GetColor2() const;
|
||||||
|
void SetColor3(const QColor& c);
|
||||||
|
QColor GetColor3() const;
|
||||||
|
|
||||||
void SetHeight(float h);
|
void SetHeight(float h);
|
||||||
float GetHeight() const;
|
float GetHeight() const;
|
||||||
|
57
Source/src/workspace/LampStatus.cpp
Normal file
57
Source/src/workspace/LampStatus.cpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#include "workspace/LampStatus.h"
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
|
#include "workspace/WorkSpace.h"
|
||||||
|
|
||||||
|
#include "common/RecourceHelper.h"
|
||||||
|
#include "common/SpdLogger.h"
|
||||||
|
|
||||||
|
LampStatus::LampStatus(const std::vector<int>& status, const QString& path, WorkSpace* parent /*= nullptr*/) noexcept
|
||||||
|
: QObject((QObject*)parent)
|
||||||
|
, status_(status)
|
||||||
|
, path_(path)
|
||||||
|
, workSpace_(parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
LampStatus* LampStatus::Load(const QString& path, WorkSpace* parent) {
|
||||||
|
const QString filePath = QString("%1/%2").arg(RecourceHelper::Get().GetBasePath()).arg(path);
|
||||||
|
LOG_INFO("Load LampStatus: {}", filePath.toStdString());
|
||||||
|
|
||||||
|
QFile file(filePath);
|
||||||
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
LOG_WARN("Cannot open file for reading: {}", file.errorString().toStdString());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream in(&file);
|
||||||
|
std::vector<int> numbers;
|
||||||
|
|
||||||
|
while (!in.atEnd()) {
|
||||||
|
QString line = in.readLine();
|
||||||
|
bool ok;
|
||||||
|
double value = line.toDouble(&ok);
|
||||||
|
if (ok) {
|
||||||
|
int status = static_cast<int>(value);
|
||||||
|
numbers.push_back(status);
|
||||||
|
} else {
|
||||||
|
LOG_WARN("Cannot open file for reading: {}", line.toStdString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
LampStatus* lampStatus = new LampStatus(numbers, path, parent);
|
||||||
|
return lampStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LampStatus::OnFrame(double dt) {
|
||||||
|
int status = static_cast<int>(dt);
|
||||||
|
if (status >= status_.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_ = status;
|
||||||
|
emit StatusChanged(GetCurrent());
|
||||||
|
}
|
48
Source/src/workspace/LampStatus.h
Normal file
48
Source/src/workspace/LampStatus.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class WorkSpace;
|
||||||
|
|
||||||
|
class LampStatus : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
enum class PlayStatus : uint8_t {
|
||||||
|
PS_Started,
|
||||||
|
PS_Stoped,
|
||||||
|
PS_Suspended,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LampStatus(const std::vector<int>& status, const QString& path, WorkSpace* parent = nullptr) noexcept;
|
||||||
|
~LampStatus() override = default;
|
||||||
|
|
||||||
|
static LampStatus* Load(const QString& path, WorkSpace* parent = nullptr);
|
||||||
|
|
||||||
|
void OnFrame(double dt);
|
||||||
|
const QString& GetPath() const {
|
||||||
|
return path_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t GetCurrent() const {
|
||||||
|
if (current_ < 0 || current_ >= status_.size()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return status_[current_];
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void StatusChanged(int);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<int> status_;
|
||||||
|
QString path_;
|
||||||
|
int32_t current_{ 0 };
|
||||||
|
|
||||||
|
WorkSpace* workSpace_{ nullptr };
|
||||||
|
};
|
||||||
|
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "workspace/WorkSpaceItem.h"
|
#include "workspace/WorkSpaceItem.h"
|
||||||
#include "workspace/Timestep.h"
|
#include "workspace/Timestep.h"
|
||||||
|
#include "workspace/LampStatus.h"
|
||||||
|
|
||||||
#include "xml/tinyxml2.h"
|
#include "xml/tinyxml2.h"
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
@ -107,6 +108,25 @@ bool WorkSpace::SetTimestepPath(const QString& path) {
|
|||||||
return SetTimestep(timestep);
|
return SetTimestep(timestep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WorkSpace::SetLampStatus(class LampStatus* lampStatus) {
|
||||||
|
if (!lampStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nullptr != lampStatus_ && lampStatus_ != lampStatus) {
|
||||||
|
lampStatus_->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
lampStatus_ = lampStatus;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorkSpace::SetLampPath(const QString& path) {
|
||||||
|
LampStatus* timestep = LampStatus::Load(path, this);
|
||||||
|
|
||||||
|
return SetLampStatus(timestep);
|
||||||
|
}
|
||||||
|
|
||||||
bool WorkSpace::Save(const QString& path) {
|
bool WorkSpace::Save(const QString& path) {
|
||||||
path_ = path;
|
path_ = path;
|
||||||
return Save();
|
return Save();
|
||||||
@ -151,6 +171,11 @@ void WorkSpace::Begin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorkSpace::OnFrame(double dt) {
|
void WorkSpace::OnFrame(double dt) {
|
||||||
|
if (nullptr != lampStatus_) {
|
||||||
|
double current = timestep_->GetCurrent();
|
||||||
|
lampStatus_->OnFrame(current);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto item : entities_) {
|
for (auto item : entities_) {
|
||||||
item->Update(dt);
|
item->Update(dt);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,13 @@ public:
|
|||||||
bool SetTimestepPath(const QString& path);
|
bool SetTimestepPath(const QString& path);
|
||||||
class Timestep* GetTimestep() const {
|
class Timestep* GetTimestep() const {
|
||||||
return timestep_;
|
return timestep_;
|
||||||
;}
|
}
|
||||||
|
|
||||||
|
bool SetLampStatus(class LampStatus* timestep);
|
||||||
|
bool SetLampPath(const QString& path);
|
||||||
|
class LampStatus* GetLampStatus() const {
|
||||||
|
return lampStatus_;
|
||||||
|
}
|
||||||
|
|
||||||
void AddEntity(class Entity* entity);
|
void AddEntity(class Entity* entity);
|
||||||
void RemoveEntity(class Entity* entity);
|
void RemoveEntity(class Entity* entity);
|
||||||
@ -81,10 +87,6 @@ private:
|
|||||||
osg::ref_ptr<OsgScene> activeScene_;
|
osg::ref_ptr<OsgScene> activeScene_;
|
||||||
class OsgView* view_{ nullptr };
|
class OsgView* view_{ nullptr };
|
||||||
class Timestep* timestep_{ nullptr };
|
class Timestep* timestep_{ nullptr };
|
||||||
|
class LampStatus* lampStatus_{ nullptr };
|
||||||
/*class DYTChart* curveChart2D_{ nullptr };
|
|
||||||
class DYTChart* curveChart2DLg_{ nullptr };
|
|
||||||
class DYTChart* curveChart3D_{ nullptr };*/
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,6 +57,21 @@ bool WorkSpaceXMLParse::ParseTimestep(const tinyxml2::XMLElement* element) {
|
|||||||
return workSpace_->SetTimestepPath(path);
|
return workSpace_->SetTimestepPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WorkSpaceXMLParse::ParseLamp(const tinyxml2::XMLElement* element) {
|
||||||
|
if (nullptr == element) {
|
||||||
|
LOG_WARN("element is nullptr");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* path = element->Attribute("path");
|
||||||
|
if (nullptr == path) {
|
||||||
|
LOG_WARN("element not has path");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return workSpace_->SetLampPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
bool WorkSpaceXMLParse::ParseEntities(const tinyxml2::XMLElement* element) {
|
bool WorkSpaceXMLParse::ParseEntities(const tinyxml2::XMLElement* element) {
|
||||||
if (nullptr == element) {
|
if (nullptr == element) {
|
||||||
LOG_WARN("element is nullptr");
|
LOG_WARN("element is nullptr");
|
||||||
@ -201,6 +216,8 @@ bool WorkSpaceXMLParse::Load(const QString& dyt) {
|
|||||||
ParseEntities(xmlElement);
|
ParseEntities(xmlElement);
|
||||||
} else if (0 == strcmp(name, "timestep")) {
|
} else if (0 == strcmp(name, "timestep")) {
|
||||||
ParseTimestep(xmlElement);
|
ParseTimestep(xmlElement);
|
||||||
|
} else if (0 == strcmp(name, "lamp")) {
|
||||||
|
ParseLamp(xmlElement);
|
||||||
}
|
}
|
||||||
else if (0 == strcmp(name, "charts")) {
|
else if (0 == strcmp(name, "charts")) {
|
||||||
ParseChart(xmlElement);
|
ParseChart(xmlElement);
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool ParseScene(const tinyxml2::XMLElement* element);
|
bool ParseScene(const tinyxml2::XMLElement* element);
|
||||||
bool ParseTimestep(const tinyxml2::XMLElement* element);
|
bool ParseTimestep(const tinyxml2::XMLElement* element);
|
||||||
|
bool ParseLamp(const tinyxml2::XMLElement* element);
|
||||||
bool ParseEntities(const tinyxml2::XMLElement* element);
|
bool ParseEntities(const tinyxml2::XMLElement* element);
|
||||||
bool ParseChart(const tinyxml2::XMLElement* element);
|
bool ParseChart(const tinyxml2::XMLElement* element);
|
||||||
bool ParseReport(const tinyxml2::XMLElement* element);
|
bool ParseReport(const tinyxml2::XMLElement* element);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "entities/EntitiesManager.h"
|
#include "entities/EntitiesManager.h"
|
||||||
#include "entities/Entity.h"
|
#include "entities/Entity.h"
|
||||||
#include "workspace/Timestep.h"
|
#include "workspace/Timestep.h"
|
||||||
|
#include "workspace/LampStatus.h"
|
||||||
|
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
|
|
||||||
@ -66,6 +67,16 @@ bool WorkSpaceXMLWrite::SaveTimeStep(tinyxml2::XMLElement* scene) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WorkSpaceXMLWrite::SaveLamp(tinyxml2::XMLElement* scene) {
|
||||||
|
LampStatus* lampStatus = workSpace_->GetLampStatus();
|
||||||
|
if (nullptr == lampStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
tinyxml2::XMLElement* timestepXml = scene->InsertNewChildElement("lamp");
|
||||||
|
timestepXml->SetAttribute("path", lampStatus->GetPath().toStdString().c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool WorkSpaceXMLWrite::SaveEntities(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) {
|
bool WorkSpaceXMLWrite::SaveEntities(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) {
|
||||||
tinyxml2::XMLElement* entitics = doc->NewElement("entities");
|
tinyxml2::XMLElement* entitics = doc->NewElement("entities");
|
||||||
scene->LinkEndChild(entitics);
|
scene->LinkEndChild(entitics);
|
||||||
|
@ -18,6 +18,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
bool SaveScene(tinyxml2::XMLElement* scene);
|
bool SaveScene(tinyxml2::XMLElement* scene);
|
||||||
bool SaveTimeStep(tinyxml2::XMLElement* scene);
|
bool SaveTimeStep(tinyxml2::XMLElement* scene);
|
||||||
|
bool SaveLamp(tinyxml2::XMLElement* scene);
|
||||||
bool SaveEntities(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc);
|
bool SaveEntities(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc);
|
||||||
bool SaveChart(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc);
|
bool SaveChart(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc);
|
||||||
bool SaveTargetList(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc);
|
bool SaveTargetList(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<chart3D/>
|
<chart3D/>
|
||||||
</charts>
|
</charts>
|
||||||
<timestep path="workspace/Timestep.txt"/>
|
<timestep path="workspace/Timestep.txt"/>
|
||||||
|
<lamp path="workspace/Lamp.txt"/>
|
||||||
<entities>
|
<entities>
|
||||||
<Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9881a3d}" name="船1">
|
<Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9881a3d}" name="船1">
|
||||||
<MeshComponent mesh="boke/boke.ive" location="50.000000,80.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="5.000000,5.000000,5.000000">
|
<MeshComponent mesh="boke/boke.ive" location="50.000000,80.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="5.000000,5.000000,5.000000">
|
||||||
@ -29,7 +30,7 @@
|
|||||||
</Entity>
|
</Entity>
|
||||||
<Entity uuid="{b99a4401-9cc6-493e-a42e-655b81997eb3}" name="卫星">
|
<Entity uuid="{b99a4401-9cc6-493e-a42e-655b81997eb3}" name="卫星">
|
||||||
<MeshComponent mesh="satellite/satellite.ive" location="0.000000,0.000000,100.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{5b764fc4-89ad-4bac-b961-abf310a552fd}">
|
<MeshComponent mesh="satellite/satellite.ive" location="0.000000,0.000000,100.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{5b764fc4-89ad-4bac-b961-abf310a552fd}">
|
||||||
<ConeWaveComponent color="0.000000,0.200000,0.500000,0.200000" radius="70.000000" height="100.000000" event="workspace/jiaof.evnet.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{7a962b9c-e572-48f4-9e64-fb1742010bf6}"/>
|
<ConeWaveComponent color1="1.000000,0.200000,0.500000,0.200000" color2="0.000000,0.200000,0.500000,0.200000" color3="0.000000,1.000000,0.500000,1.000000" radius="70.000000" height="100.000000" event="workspace/jiaof.evnet.txt" location="0.000000,0.000000,0.000000" rotation="0.000000,0.000000,0.000000" scale="1.000000,1.000000,1.000000" uuid="{7a962b9c-e572-48f4-9e64-fb1742010bf6}"/>
|
||||||
</MeshComponent>
|
</MeshComponent>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9881a46}" name="反射通信1">
|
<Entity uuid="{3c48c04e-a1ac-485d-9ab8-4436b9881a46}" name="反射通信1">
|
||||||
|
Loading…
Reference in New Issue
Block a user