288 lines
11 KiB
C++
Executable File
288 lines
11 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Helper class for SoundAreas.
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Filip Biedziak, NLE, 2020-08-10
|
|
*/
|
|
|
|
#include "efm_sound_area_helper.h"
|
|
#include "../logger.h"
|
|
|
|
#include <QVector>
|
|
#include <QColor>
|
|
|
|
|
|
namespace EffectManagement
|
|
{
|
|
|
|
//=============================================================================================================================
|
|
// SOUNDMANAGEMENTHELPER
|
|
//=============================================================================================================================
|
|
|
|
SoundAreaHelper::SoundAreaHelper(SoundAreaHelper *helper)
|
|
: m_ismDtc(helper->ismDtc())
|
|
, m_somDtc(helper->somDtc())
|
|
, m_logger(getLogger("Plugins.Gui.SoundArea.Helper"))
|
|
{
|
|
QMap<int32_t, InfrastructureManagement::InstrumentationAsset> assets = m_ismDtc->instrumentationAssets();
|
|
for (const auto &asset : qAsConst(assets))
|
|
if (asset.mountingPointTypeId() == InfrastructureManagement::MountingPointType_def::EffectGenerationControlUnit)
|
|
m_egcuNames.insert(asset.id(), QString::fromStdString(asset.name()));
|
|
|
|
SoundManagement::Sounds sounds = m_somDtc->sounds();
|
|
for (const auto &sound : qAsConst(sounds.sounds()))
|
|
m_soundDuration.insert(SoundKey(sound.category().underlying(), sound.soundId()), sound.duration());
|
|
}
|
|
|
|
SoundAreaHelper::SoundAreaHelper(std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
|
std::shared_ptr<SoundManagement::Interface::Dtc> &somDtc)
|
|
: m_ismDtc(ismDtc)
|
|
, m_somDtc(somDtc)
|
|
, m_logger(getLogger("Plugins.Gui.SoundArea.Helper"))
|
|
{
|
|
QMap<int32_t, InfrastructureManagement::InstrumentationAsset> assets = m_ismDtc->instrumentationAssets();
|
|
for (const auto &asset : qAsConst(assets))
|
|
if (asset.mountingPointTypeId() == InfrastructureManagement::MountingPointType_def::EffectGenerationControlUnit)
|
|
m_egcuNames.insert(asset.id(), QString::fromStdString(asset.name()));
|
|
|
|
SoundManagement::Sounds sounds = m_somDtc->sounds();
|
|
for (const auto &sound : qAsConst(sounds.sounds()))
|
|
m_soundDuration.insert(SoundKey(sound.category().underlying(), sound.soundId()), sound.duration());
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------------------
|
|
// PUBLIC MEMBER FUNCTIONS
|
|
//-----------------------------------------------------------------------------------------------------------------------------
|
|
|
|
QVector<SoundManagement::SoundCategory> SoundAreaHelper::soundCategories()
|
|
{
|
|
QVector<SoundManagement::SoundCategory> categories = QVector<SoundManagement::SoundCategory>
|
|
{
|
|
SoundManagement::SoundCategory_def::Aircraft,
|
|
SoundManagement::SoundCategory_def::Battlefield,
|
|
SoundManagement::SoundCategory_def::Boat,
|
|
SoundManagement::SoundCategory_def::Explosion,
|
|
SoundManagement::SoundCategory_def::Helicopter,
|
|
SoundManagement::SoundCategory_def::MotorsAndUrbanTraffic,
|
|
SoundManagement::SoundCategory_def::Vehicle,
|
|
SoundManagement::SoundCategory_def::InsideBuilding
|
|
};
|
|
return categories;
|
|
}
|
|
|
|
|
|
QString SoundAreaHelper::categoryName(SoundManagement::SoundCategory category)
|
|
{
|
|
switch (category.underlying())
|
|
{
|
|
case SoundManagement::SoundCategory_def::Aircraft: return QStringLiteral("Aircraft");
|
|
case SoundManagement::SoundCategory_def::Battlefield: return QStringLiteral("Battlefield");
|
|
case SoundManagement::SoundCategory_def::Boat: return QStringLiteral("Boat");
|
|
case SoundManagement::SoundCategory_def::Explosion: return QStringLiteral("Explosion");
|
|
case SoundManagement::SoundCategory_def::Helicopter: return QStringLiteral("Helicopter");
|
|
case SoundManagement::SoundCategory_def::MotorsAndUrbanTraffic: return QStringLiteral("MotorsAndUrbanTraffic");
|
|
case SoundManagement::SoundCategory_def::Vehicle: return QStringLiteral("Vehicle");
|
|
case SoundManagement::SoundCategory_def::InsideBuilding: return QStringLiteral("InsideBuilding");
|
|
case SoundManagement::SoundCategory_def::Unknown: return QStringLiteral("Unknown");
|
|
default:
|
|
return QString();
|
|
} // switch
|
|
}
|
|
|
|
QString SoundAreaHelper::categoryName(const int32_t &category)
|
|
{
|
|
return categoryName(soundCategory(category));
|
|
}
|
|
|
|
|
|
QString SoundAreaHelper::soundName(SoundManagement::SoundCategory category, const int &id)
|
|
{
|
|
switch (category.underlying())
|
|
{
|
|
case SoundManagement::SoundCategory_def::Aircraft:
|
|
switch (id)
|
|
{
|
|
case 1: return QStringLiteral("Jet_Pass_by_Military");
|
|
case 2: return QStringLiteral("Military_Aircraft_Fires");
|
|
case 3: return QStringLiteral("Military_Aircraft_Fly_By");
|
|
case 4: return QStringLiteral("Military_Airplane_Drops");
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
case SoundManagement::SoundCategory_def::Battlefield:
|
|
switch (id)
|
|
{
|
|
case 1: return QStringLiteral("Battlefield_Ambience_Noise");
|
|
case 2: return QStringLiteral("Battlefield_Ambience_Tank");
|
|
case 3: return QStringLiteral("Battlefield_Ambience_War");
|
|
case 4: return QStringLiteral("Explosions_Battlefield");
|
|
case 5: return QStringLiteral("Explosions_Battlefield_1");
|
|
case 6: return QStringLiteral("Ground_Battle_with_Machine_Guns");
|
|
case 7: return QStringLiteral("Modern_Battlefield");
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
case SoundManagement::SoundCategory_def::Boat:
|
|
switch (id)
|
|
{
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
case SoundManagement::SoundCategory_def::Explosion:
|
|
switch (id)
|
|
{
|
|
case 1: return QStringLiteral("Explosion_Building_Crash");
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
case SoundManagement::SoundCategory_def::Helicopter:
|
|
switch (id)
|
|
{
|
|
case 1: return QStringLiteral("Helicopter_Crash");
|
|
case 2: return QStringLiteral("Helicopter_Fly_Overhead");
|
|
case 3: return QStringLiteral("Helicopter_Landing");
|
|
case 4: return QStringLiteral("Helicopter_Pass_by_Military");
|
|
case 5: return QStringLiteral("Helicopter_Take_off");
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
case SoundManagement::SoundCategory_def::MotorsAndUrbanTraffic:
|
|
switch (id)
|
|
{
|
|
case 1: return QStringLiteral("Big_City_Street_Traffic");
|
|
case 2: return QStringLiteral("City_Crossroads_Traffic");
|
|
case 3: return QStringLiteral("City_Street_Heavy_Traffic");
|
|
case 4: return QStringLiteral("City_Street_Noisy_Walking");
|
|
case 5: return QStringLiteral("Construction_Building_Ambient");
|
|
case 6: return QStringLiteral("Demonstration_and_Rioting");
|
|
case 7: return QStringLiteral("Noisy_City_Street");
|
|
case 8: return QStringLiteral("Stadium_Crowd_Ambient");
|
|
case 9: return QStringLiteral("Stadium_Crowd_Applause");
|
|
case 10: return QStringLiteral("Traffic_from_Car");
|
|
case 11: return QStringLiteral("Muezzincalling");
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
case SoundManagement::SoundCategory_def::Vehicle:
|
|
switch (id)
|
|
{
|
|
case 1: return QStringLiteral("Tank_Starting_and_Stopping");
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
case SoundManagement::SoundCategory_def::InsideBuilding:
|
|
switch (id)
|
|
{
|
|
case 1: return QStringLiteral("Fire_quietly");
|
|
case 2: return QStringLiteral("Fire_a_little_louder");
|
|
case 3: return QStringLiteral("Fire_louder");
|
|
case 4: return QStringLiteral("Fire_loud");
|
|
case 5: return QStringLiteral("Extinguishing_Noise");
|
|
case 7: return QStringLiteral("This_Room_is_Destroyed");
|
|
case 8: return QStringLiteral("This_Building_is_Destroyed");
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
case SoundManagement::SoundCategory_def::Unknown:
|
|
switch(id)
|
|
{
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
|
|
default:
|
|
return QStringLiteral("Error");
|
|
} // switch
|
|
}
|
|
|
|
QString SoundAreaHelper::soundName(const int &category, const int &id)
|
|
{
|
|
return soundName(soundCategory(category), id);
|
|
}
|
|
|
|
|
|
int SoundAreaHelper::soundDuration(SoundManagement::SoundCategory category, const int &id) const
|
|
{
|
|
return soundDuration(static_cast<int>(category.underlying()), id);
|
|
}
|
|
|
|
int SoundAreaHelper::soundDuration(const int &category, const int &id) const
|
|
{
|
|
SoundKey key{category, id};
|
|
return m_soundDuration.contains(key) ? m_soundDuration.value(key) : 0;
|
|
}
|
|
|
|
|
|
QString SoundAreaHelper::egcuName(const int &id) const
|
|
{
|
|
return m_egcuNames.contains(id) ? m_egcuNames.value(id) : QString();
|
|
}
|
|
|
|
|
|
QColor SoundAreaHelper::soundCategoryTextColor(const int32_t &category)
|
|
{
|
|
switch (category)
|
|
{
|
|
case SoundManagement::SoundCategory_def::Aircraft: return {Qt::white};
|
|
case SoundManagement::SoundCategory_def::Battlefield: return {Qt::white};
|
|
case SoundManagement::SoundCategory_def::Boat: return {Qt::black};
|
|
case SoundManagement::SoundCategory_def::Explosion: return {Qt::white};
|
|
case SoundManagement::SoundCategory_def::Helicopter: return {Qt::white};
|
|
case SoundManagement::SoundCategory_def::MotorsAndUrbanTraffic: return {Qt::white};
|
|
case SoundManagement::SoundCategory_def::Vehicle: return {Qt::black};
|
|
case SoundManagement::SoundCategory_def::InsideBuilding: return {Qt::black};
|
|
case SoundManagement::SoundCategory_def::Unknown: return {Qt::white};
|
|
default:
|
|
return {Qt::black};
|
|
} // switch
|
|
}
|
|
|
|
QColor SoundAreaHelper::soundCategoryBackgroundColor(const int32_t &category)
|
|
{
|
|
switch (category)
|
|
{
|
|
case SoundManagement::SoundCategory_def::Aircraft: return QColor::fromRgb( 25, 25, 112);
|
|
case SoundManagement::SoundCategory_def::Battlefield: return QColor::fromRgb(160, 82, 45);
|
|
case SoundManagement::SoundCategory_def::Boat: return QColor::fromRgb(127, 255, 212);
|
|
case SoundManagement::SoundCategory_def::Explosion: return QColor::fromRgb(255, 0, 0);
|
|
case SoundManagement::SoundCategory_def::Helicopter: return QColor::fromRgb(153, 50, 204);
|
|
case SoundManagement::SoundCategory_def::MotorsAndUrbanTraffic: return QColor::fromRgb( 85, 107, 47);
|
|
case SoundManagement::SoundCategory_def::Vehicle: return QColor::fromRgb(255, 255, 0);
|
|
case SoundManagement::SoundCategory_def::InsideBuilding: return QColor::fromRgb(255, 160, 122);
|
|
case SoundManagement::SoundCategory_def::Unknown: return QColor::fromRgb(119, 136, 153);
|
|
default:
|
|
return {Qt::white};
|
|
} // switch
|
|
}
|
|
|
|
|
|
SoundManagement::SoundCategory SoundAreaHelper::soundCategory(const int &i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 1: return SoundManagement::SoundCategory_def::Aircraft;
|
|
case 2: return SoundManagement::SoundCategory_def::Battlefield;
|
|
case 3: return SoundManagement::SoundCategory_def::Boat;
|
|
case 4: return SoundManagement::SoundCategory_def::Explosion;
|
|
case 5: return SoundManagement::SoundCategory_def::Helicopter;
|
|
case 6: return SoundManagement::SoundCategory_def::MotorsAndUrbanTraffic;
|
|
case 7: return SoundManagement::SoundCategory_def::Vehicle;
|
|
case 8: return SoundManagement::SoundCategory_def::InsideBuilding;
|
|
case 9:
|
|
default:
|
|
return SoundManagement::SoundCategory_def::Unknown;
|
|
} // switch
|
|
}
|
|
|
|
} // namespace EffectManagement
|