- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
132 lines
5.5 KiB
C++
Executable File
132 lines
5.5 KiB
C++
Executable File
/**
|
|
* Handler for the HMI language
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "effect_show_mine_area.h"
|
|
|
|
#include <QLineF>
|
|
|
|
namespace EffectShowManagement
|
|
{
|
|
EffectShowMineArea::EffectShowMineArea(const AreaEffectSimulation::MineArea &mineArea)
|
|
: m_mineArea(mineArea)
|
|
, m_segment(getEffectShowSegment(mineArea))
|
|
, m_utmZone(-1)
|
|
, m_rotation(0.0)
|
|
{
|
|
}
|
|
|
|
//=============================================================================
|
|
Database::EsmEffectShow EffectShowMineArea::getEffectShow()
|
|
{
|
|
calculatePositions();
|
|
|
|
Database::EsmEffectShow esmEffectShow;
|
|
esmEffectShow.id = 0;
|
|
esmEffectShow.name = QLatin1String("MIN");
|
|
esmEffectShow.startTime = m_mineArea.effectStart().is_set() ? m_mineArea.effectStart().get() : 0;
|
|
esmEffectShow.duration = m_mineArea.effectDuration();
|
|
esmEffectShow.centerPosition = m_centerPos.geographic();
|
|
esmEffectShow.idAreaEffectSimulation = m_mineArea.id();
|
|
esmEffectShow.nameAreaEfffectSimulation = QString::fromStdString(m_mineArea.name());
|
|
esmEffectShow.esmParticipantId = -1;
|
|
esmEffectShow.numOfVolley = 1; //Hardcode??
|
|
esmEffectShow.shotsPerVolley = 18;
|
|
esmEffectShow.lowerLeftPosition = m_lowerLeftPos.geographic();
|
|
esmEffectShow.areaWidth = getEffectAreaWidth();
|
|
esmEffectShow.areaDepth = getEffectAreaDepth();
|
|
esmEffectShow.areaRotation = m_rotation;
|
|
|
|
updateEffectShow(esmEffectShow);
|
|
|
|
for (const auto &seg : m_mineArea.segments())
|
|
{
|
|
const Core::GeoPosition2D &posGeo = seg.positionStart();
|
|
LtsCoordTrans::UtmCoordinate pos = LtsCoordTrans::UtmCoordinate::fromGeographic(posGeo.lon(), posGeo.lat(), m_utmZone);
|
|
DEBUG_LOG() << "Start Pos Segm.: " << pos.mgrs();
|
|
}
|
|
DEBUG_LOG() << "Center Pos Effect Show: " << LtsCoordTrans::mgrsFromGeographic(esmEffectShow.centerPosition.x(), esmEffectShow.centerPosition.y());
|
|
return esmEffectShow;
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
void EffectShowMineArea::updateEffectShow(Database::EsmEffectShow &data)
|
|
{
|
|
data.nameAreaEfffectSimulation = QString::fromStdString(m_mineArea.name());
|
|
data.duration = m_mineArea.effectDuration() / 10;
|
|
if (data.duration > (3600 * 1000))
|
|
data.duration = 3600 * 1000;
|
|
if (m_mineArea.effectStart().is_set())
|
|
data.startTime = m_mineArea.effectStart().get() + m_mineArea.effectDuration() - data.duration;
|
|
else
|
|
data.startTime = 0;
|
|
data.typeOfAmmunition = m_mineArea.chargeStruct().chargeTypeId();
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
void EffectShowMineArea::calculatePositions()
|
|
{
|
|
// start position of the segment
|
|
Core::GeoPosition2D geoPosStart = m_segment.positionStart();
|
|
Core::GeoPosition2D geoPosEnd = m_segment.positionEnd();
|
|
LtsCoordTrans::UtmCoordinate startPositionUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPosStart.lon(), geoPosStart.lat(), m_utmZone);
|
|
if (m_utmZone == -1)
|
|
m_utmZone = startPositionUtm.zone;
|
|
|
|
LtsCoordTrans::UtmCoordinate endPositionUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPosEnd.lon(), geoPosEnd.lat(), m_utmZone);
|
|
const QLineF line({startPositionUtm.x, startPositionUtm.y}, {endPositionUtm.x, endPositionUtm.y});
|
|
|
|
// length/2 of the segment
|
|
double halfSegmentLength = line.length() / 2.0;
|
|
|
|
// rotation angle
|
|
m_rotation = 90.0 - line.angle();
|
|
double angle = m_rotation * LtsCoordTrans::deg2rad();
|
|
|
|
// calculation center position
|
|
LtsCoordTrans::UtmCoordinate centerPos = startPositionUtm;
|
|
centerPos.x = centerPos.x + halfSegmentLength;
|
|
m_centerPos = rotate(centerPos, startPositionUtm, angle);
|
|
|
|
// calculation lower left position
|
|
LtsCoordTrans::UtmCoordinate lowerLeftPos = startPositionUtm;
|
|
lowerLeftPos.x = lowerLeftPos.x + halfSegmentLength - (getEffectAreaWidth() / 2.0);
|
|
lowerLeftPos.y = lowerLeftPos.y - (getEffectAreaDepth() / 2.0);
|
|
m_lowerLeftPos = rotate(lowerLeftPos, startPositionUtm, angle);
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
int EffectShowMineArea::getEffectAreaWidth() const
|
|
{
|
|
Core::GeoPosition2D geoPosStart = m_segment.positionStart();
|
|
Core::GeoPosition2D geoPosEnd = m_segment.positionEnd();
|
|
|
|
LtsCoordTrans::UtmCoordinate startPositionUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPosStart.lon(), geoPosStart.lat(), m_utmZone);
|
|
LtsCoordTrans::UtmCoordinate endPositionUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPosEnd.lon(), geoPosEnd.lat(), m_utmZone);
|
|
const QLineF line({startPositionUtm.x, startPositionUtm.y}, {endPositionUtm.x, endPositionUtm.y});
|
|
|
|
int segmentLength = line.length();
|
|
if (segmentLength <= 50) return 50;
|
|
if (segmentLength >= 300) return 300;
|
|
return (((segmentLength + 25) / 50) * 50);
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
int EffectShowMineArea::getEffectAreaDepth() const
|
|
{
|
|
int segmentWidth = qRound(m_mineArea.width());
|
|
if (segmentWidth <= 50) return 50;
|
|
if (segmentWidth >= 300) return 300;
|
|
return (((segmentWidth + 25) / 50) * 50);
|
|
}
|
|
//static ----------------------------------------------------------------------
|
|
LtsCoordTrans::UtmCoordinate EffectShowMineArea::rotate(const LtsCoordTrans::UtmCoordinate &p, const LtsCoordTrans::UtmCoordinate &c, double angle)
|
|
{
|
|
LtsCoordTrans::UtmCoordinate res = p; // copy zone, northp
|
|
res.x = ((p.x - c.x) * cos(angle)) - ((p.y - c.y) * sin(angle)) + c.x;
|
|
res.y = ((p.x - c.x) * sin(angle)) + ((p.y - c.y) * cos(angle)) + c.y;
|
|
return res;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
} // Namespace EffectShowManagement
|