TrainingAreaBase: - Add BUILD_RTI guards to dds_handler.cpp (entire file) - Add BUILD_RTI guards to recv_from_dds_aes.h for tab_db.h include - Add BUILD_RTI guards to main_handler.h for tab_db.h include - Remove duplicate m_logger declaration in main_handler.h - Add stub headers for RTI types (tab_db_stub.hpp, tab_enums_stub.hpp, etc.) VideoOverlayManagement: - Fix member initialization order in handler_overlays.h - Fix member initialization order in avs_interface.h - Fix member initialization order in main_handler.h - Change logger.cpp include from NGLLogger.h to INGLLogger.h - Add BUILD_RTI guard to handler_overlays.cpp for RTI signal connection Plugins: - Migrate QDesktopWidget → QScreen in Light/Dark style plugins - Fix CMakeLists.txt for SituationReplayManagement (BUILD_RTI guards) - Fix CMakeLists.txt for CombatNetRadio (Qt6::Core linking) - Remove QDesktopWidget includes in multiple plugin files Infrastructure: - Remove duplicate INGLLogger.h include directory - Add stub headers for ProjectDataManagement (pdm.hpp, etc.) - Add stub headers for RoutingServiceNG BUILD_RTI=OFF build now compiles successfully (1112 targets).
242 lines
8.7 KiB
C++
Executable File
242 lines
8.7 KiB
C++
Executable File
/**
|
|
* Handler for Video Overlays
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by hjl, SLSE, 2016-07-07
|
|
*/
|
|
|
|
#include "handler_overlays.h"
|
|
#include <utility>
|
|
#include "handler_participant_data.h"
|
|
#include "settings.h"
|
|
|
|
#include <QtCore/QByteArray>
|
|
|
|
using namespace VideoOverlayManagement;
|
|
|
|
HandlerOverlays::HandlerOverlays(AvsInterface *avsIf,
|
|
const std::shared_ptr<HandlerParticipantData> &handlerParticipantData,
|
|
const std::shared_ptr<HandlerInfrastructureData> &handlerInfrastructureData,
|
|
int exerciseId,
|
|
QObject *parent) : QObject(parent)
|
|
, m_avsIf(avsIf)
|
|
, m_handlerParticipantData(handlerParticipantData)
|
|
, m_handlerInfrastructureData(handlerInfrastructureData)
|
|
, m_exerciseId(exerciseId),
|
|
m_logger(NGL::getMemoryLogger()) {
|
|
} // end of ctor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
HandlerOverlays::~HandlerOverlays()
|
|
{
|
|
} // end of dtor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool HandlerOverlays::init()
|
|
{
|
|
INFO_LOG(m_logger) << "Start VideoOverlay Handler.";
|
|
|
|
// internal Signal/Slot connection (must be done before calling initParticipantsInRoomMap() !)
|
|
connect(this, &HandlerOverlays::participantsInRoomMapChanged,
|
|
this, &HandlerOverlays::onParticipantsInRoomMapChanged);
|
|
|
|
// Get assigned participants to roomId data from Player Management ...
|
|
initParticipantsInRoomMap();
|
|
#if BUILD_RTI
|
|
// Subscribe for external changes
|
|
connect(m_handlerParticipantData.get(), &HandlerParticipantData::participantPositionChanged,
|
|
this, &HandlerOverlays::onParticipantPositionChanged);
|
|
#endif
|
|
|
|
INFO_LOG(m_logger) << "VOM Handler initialized. ";
|
|
|
|
return true;
|
|
} // end of init()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void HandlerOverlays::onParticipantPositionChanged(int oldRoomId, int newRoomId, int participantId)
|
|
{
|
|
DEBUG_LOG(m_logger) << "onParticipantPositionChanged() "
|
|
<< " oldRoomId: " << oldRoomId
|
|
<< " newRoomId: " << newRoomId
|
|
<< " participantId: " << participantId
|
|
;
|
|
|
|
if (oldRoomId > 0) // is valid
|
|
removePartIdFromParticipantsInRoomMap(oldRoomId, participantId);
|
|
|
|
if (newRoomId > 0)
|
|
addPartIdToParticipantsInRoomMap(newRoomId, participantId);
|
|
} // end of onParticipantPositionChanged()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void HandlerOverlays::onParticipantsInRoomMapChanged(int roomId, const QSet<int> &participants)
|
|
{
|
|
DEBUG_LOG(m_logger) << "onParticipantsInRoomMapChanged() "
|
|
<< " roomId: " << roomId
|
|
<< " partId: " << getAllEquipmentNumbers(participants, false)
|
|
<< " eqNo: " << getAllEquipmentNumbers(participants, true)
|
|
<< " participants.size(): " << participants.size()
|
|
;
|
|
|
|
if (!m_handlerInfrastructureData->isCameraAvailable(roomId))
|
|
{
|
|
WARNING_LOG(m_logger) << "onParticipantsInRoomMapChanged() Non camera available in roomId: " << roomId << " No data will be send to AVS.";
|
|
return;
|
|
}
|
|
|
|
// SetStreamOverlayText Command String zusammenstellen
|
|
QString cmd;
|
|
QString contextName = getContextName();
|
|
QString streamName = m_handlerInfrastructureData->getStreamNameFromRoomId(roomId);
|
|
QString overlayTemplateName = getOverlayTemplateName();
|
|
|
|
if (streamName.isEmpty())
|
|
{
|
|
ERROR_LOG(m_logger) << "onParticipantsInRoomMapChanged() No streamName found for roomId: " << roomId << " No data will be send to AVS.";
|
|
return;
|
|
}
|
|
|
|
cmd.append(QLatin1String("SetStreamOverlayText "));
|
|
cmd.append(contextName);
|
|
cmd.append(QLatin1String(" "));
|
|
cmd.append(streamName);
|
|
cmd.append(QLatin1String(" "));
|
|
cmd.append(overlayTemplateName);
|
|
cmd.append(QLatin1String(" "));
|
|
cmd.append(QLatin1String("0 "));
|
|
cmd.append(QLatin1String("\""));
|
|
|
|
cmd.append(QLatin1String("Participants(EqNo) in roomId "));
|
|
cmd.append((QString::number(roomId)));
|
|
cmd.append(QLatin1String(": "));
|
|
cmd.append(getAllEquipmentNumbers(participants, true));
|
|
cmd.append(QLatin1String("\""));
|
|
|
|
QByteArray qba = cmd.toLatin1();
|
|
qba += "\r\n";
|
|
|
|
INFO_LOG(m_logger) << "onParticipantsInRoomMapChanged() sendCommand: " << qba ;
|
|
m_avsIf->sendCommand(qba);
|
|
|
|
// room entry der keine participants enthaelt loeschen
|
|
if (participants.isEmpty())
|
|
m_participantsInRoomMap.remove(roomId);
|
|
} // end of onParticipantsInRoomMapChanged()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void HandlerOverlays::initParticipantsInRoomMap()
|
|
{
|
|
// QMap<participantId, roomId>
|
|
const QMap<int, int> qm = m_handlerParticipantData->getAllAssignedParticipants();
|
|
|
|
for (auto i = qm.begin(); i != qm.end(); ++i)
|
|
onParticipantPositionChanged(0, i.value(), i.key());
|
|
} // end of initParticipantsInRoomMap()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void HandlerOverlays::addPartIdToParticipantsInRoomMap(int roomId, int participantId)
|
|
{
|
|
DEBUG_LOG(m_logger) << "addPartIdToParticipantsInRoomMap() "
|
|
<< " roomId: " << roomId
|
|
<< " participantId: " << participantId
|
|
;
|
|
|
|
QSet<int> participants;
|
|
|
|
if (m_participantsInRoomMap.contains(roomId))
|
|
{
|
|
QMap<int, QSet<int>>::const_iterator i = m_participantsInRoomMap.constFind(roomId);
|
|
participants = i.value();
|
|
}
|
|
|
|
participants.insert(participantId);
|
|
m_participantsInRoomMap.insert(roomId, participants);
|
|
|
|
///
|
|
DEBUG_LOG(m_logger) << "emit participantsInRoomMapChanged()"
|
|
<< " roomId: " << roomId
|
|
<< " partId: " << getAllEquipmentNumbers(participants, false)
|
|
<< " eqNo: " << getAllEquipmentNumbers(participants, true)
|
|
<< " participants.size(): " << participants.size()
|
|
;
|
|
|
|
emit participantsInRoomMapChanged(roomId, participants);
|
|
} // end of addPartIdToParticipantsInRoomMap()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void HandlerOverlays::removePartIdFromParticipantsInRoomMap(int roomId, int participantId)
|
|
{
|
|
DEBUG_LOG(m_logger) << "removePartIdFromParticipantsInRoomMap() "
|
|
<< " roomId: " << roomId
|
|
<< " participantId: " << participantId
|
|
;
|
|
|
|
if (m_participantsInRoomMap.contains(roomId))
|
|
{
|
|
QMap<int, QSet<int>>::const_iterator i = m_participantsInRoomMap.constFind(roomId);
|
|
QSet<int> participants = i.value();
|
|
|
|
// remove participant from the set
|
|
participants.remove(participantId);
|
|
m_participantsInRoomMap.insert(roomId, participants);
|
|
|
|
DEBUG_LOG(m_logger) << "emit participantsInRoomMapChanged()"
|
|
<< " roomId: " << roomId
|
|
<< " partId: " << getAllEquipmentNumbers(participants, false)
|
|
<< " eqNo: " << getAllEquipmentNumbers(participants, true)
|
|
<< " participants.size(): " << participants.size()
|
|
;
|
|
|
|
emit participantsInRoomMapChanged(roomId, participants);
|
|
}
|
|
} // end of removePartIdFromParticipantsInRoomMap()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
QString HandlerOverlays::getContextName() const
|
|
{
|
|
QString qs(Settings::getContextName());
|
|
qs.append(QString::number(m_exerciseId));
|
|
return qs;
|
|
} // end of getContextName()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
QString HandlerOverlays::getOverlayTemplateName() const
|
|
{
|
|
return Settings::getOverlayTemplateName();
|
|
} // end of getOverlayTemplateName()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
QSet<int> HandlerOverlays::convertParticipantIdsToEquipmentNo(const QSet<int> &participants) const
|
|
{
|
|
QSet<int> equipmentNumbers;
|
|
|
|
for (int currentParticipantId : participants)
|
|
{
|
|
int equipmentNumber = m_handlerParticipantData->getEquipmentNumber(currentParticipantId);
|
|
equipmentNumbers.insert(equipmentNumber);
|
|
}
|
|
return equipmentNumbers;
|
|
} // end of convertParticipantIdsToEquipmentNo()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
QString HandlerOverlays::getAllEquipmentNumbers(QSet<int> data, bool isParticipantIds) const
|
|
{
|
|
QString qs;
|
|
|
|
if (isParticipantIds)
|
|
data = convertParticipantIdsToEquipmentNo(data);
|
|
|
|
for (int currentDataId : std::as_const(data))
|
|
{
|
|
qs.append(QString::number(currentDataId));
|
|
qs.append(QLatin1String(", "));
|
|
}
|
|
// remove last ", "
|
|
if (!qs.isEmpty())
|
|
qs.chop(2);
|
|
return qs;
|
|
} // end of getAllEquipmentNumbers()
|
|
//-----------------------------------------------------------------------------
|