new_docker_build.sh gains Group 12 (212 GUI/Data plugins); fixes LtsUtilsGuiDds visibility (LTO-stripped exports), LtsProjectionWorkstation unity name shadow, 6 unity-off dirs (dup file-scope statics, ddsftc INTERFACE sources) and reconfigures BUILD_FILTERMANAGEMENT/BUILD_PLUGINS_SERVICEMONITOR=ON
174 lines
5.6 KiB
C++
Executable File
174 lines
5.6 KiB
C++
Executable File
/**
|
|
* Handler ShootbackAreas (L400)
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by N. Thoden, NLE, 06.04.2020
|
|
*/
|
|
|
|
#include "object_shootback_area.h"
|
|
#include "main_handler.h"
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
namespace TargetManagement
|
|
{
|
|
ObjectShootbackArea::ObjectShootbackArea(MainHandler *mainHandler)
|
|
: m_mainHandler(mainHandler)
|
|
, m_logger(getLogger("ObjectShootbackArea"))
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
ObjectShootbackArea::~ObjectShootbackArea()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
if (isValid())
|
|
m_mainHandler->dds()->dtsTgt()->removeShootbackAreaByKey(m_data.id);
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
bool ObjectShootbackArea::isValid() const
|
|
{
|
|
return m_data.id > 0;
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
bool ObjectShootbackArea::isUsed() const
|
|
{
|
|
return m_data.isUsed;
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectShootbackArea::createObject(const ShootbackArea &data)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
m_data = data;
|
|
|
|
if (m_data.id <= 0)
|
|
{
|
|
m_data.isUsed = false;
|
|
|
|
Database::TgtShootbackArea dbData(toDbData(data));
|
|
|
|
if (!m_mainHandler->db()->insert(dbData))
|
|
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting ShootbackArea-data into database"));
|
|
|
|
m_data.id = dbData.id;
|
|
DEBUG_LOG(m_logger) << "New TgtShootbackArea: " << m_data.id;
|
|
}
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
return Core::FunctionReplyObject(m_data.id);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectShootbackArea::updateObject(const ShootbackArea &data)
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
if (!isValid())
|
|
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Object not valid/blocked"));
|
|
|
|
Database::TgtShootbackArea dbData;
|
|
dbData = toDbData(data);
|
|
|
|
if (!m_mainHandler->db()->update(dbData))
|
|
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating ShootbackArea-data into database"));
|
|
|
|
m_data = data;
|
|
DEBUG_LOG(m_logger) << "Data changed for ShootbackAreaId: " << m_data.id;
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
return Core::FunctionReplyObject(m_data.id);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectShootbackArea::setUsed(bool isUsed)
|
|
{
|
|
if (!isValid())
|
|
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed ShootbackArea object"));
|
|
|
|
m_data.isUsed = isUsed;
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
return Core::FunctionReplyObject(m_data.id);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectShootbackArea::removeObject()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
if (isUsed())
|
|
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "ShootbackArea still in use"));
|
|
|
|
if (!m_mainHandler->db()->removeTgtShootbackArea(m_data.id))
|
|
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "ShootbackArea with id %1 can not be removed from DB")).arg(m_data.id);
|
|
|
|
if (!m_mainHandler->dds()->dtsTgt()->removeShootbackAreaByKey(m_data.id))
|
|
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "ShootbackArea with id %1 can not be removed from DDS")).arg(m_data.id);
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
return Core::FunctionReplyObject(m_data.id);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
void ObjectShootbackArea::onPublishData()
|
|
{
|
|
TRACE_LOG(m_logger) << "Publish ShootbackArea-data to dds (" << m_data.id << ") ...";
|
|
|
|
if (!m_mainHandler->dds()->dtsTgt()->publish(m_data))
|
|
ERROR_LOG(m_logger) << "Error publishing ShootbackArea-data to dds";
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
// convert methods
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
// TargetManagement::ShootbackArea => Database::TgtShootbackArea
|
|
Database::TgtShootbackArea ObjectShootbackArea::toDbData(const ShootbackArea &ddsData)
|
|
{
|
|
Database::TgtShootbackArea dbData;
|
|
|
|
dbData.id = ddsData.id;
|
|
dbData.name = QString::fromStdString(ddsData.name);
|
|
dbData.position = QPointF(ddsData.position.lon, ddsData.position.lat);
|
|
dbData.width = ddsData.width;
|
|
dbData.height = ddsData.height;
|
|
|
|
return dbData;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
// Database::TgtShootbackArea => TargetManagement::ShootbackArea
|
|
ShootbackArea ObjectShootbackArea::toDdsData(const Database::TgtShootbackArea &dbData)
|
|
{
|
|
ShootbackArea ddsData;
|
|
|
|
ddsData.id = dbData.id;
|
|
ddsData.name = dbData.name.toStdString();
|
|
ddsData.position = Core::GeoPosition2D(dbData.position.x(), dbData.position.y());
|
|
ddsData.width = dbData.width;
|
|
ddsData.height = dbData.height;
|
|
|
|
// init data not in db
|
|
ddsData.isDeleted = false;
|
|
ddsData.isUsed = false;
|
|
|
|
return ddsData;
|
|
}
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
} // Namespace TargetManagement
|