Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/InfrastructureManagement/object_structure_element.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

167 lines
6.3 KiB
C++

/**
* @RDE_HEADER@
* ISM Object Structure Element
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLSE, 2016-11-26
*/
#include "main_handler.h"
#include "handler_main_structure_element.h"
#include "object_main_structure_element.h"
#include "object_structure_element.h"
#include "base.h"
#include "convert_db_to_dds.h"
#include <LtsCoordTrans/lts_coord_trans.h>
using namespace InfrastructureManagement;
// -------------------------------------------------------------------------------------------------------
ObjectStructureElement::ObjectStructureElement(MainHandler *mainHandler, ObjectMainStructureElement *objMse)
: Base(mainHandler, getLogger("ObjectStructureElement"))
, m_objMse(objMse)
{
m_data.mainStructureElementId(objMse->getId());
}
// -------------------------------------------------------------------------------------------------------
ObjectStructureElement::ObjectStructureElement(const StructureElement &data, MainHandler *mainHandler, ObjectMainStructureElement *objMse)
: Base(mainHandler, getLogger("ObjectStructureElement"))
, m_data(data)
, m_objMse(objMse)
{
m_data.mainStructureElementId(objMse->getId());
}
// -------------------------------------------------------------------------------------------------------
bool ObjectStructureElement::isValid() const
{
return m_data.id() > 0;
}
// -------------------------------------------------------------------------------------------------------
bool ObjectStructureElement::isUsed() const
{
return m_data.isUsed();
}
// -------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectStructureElement::createObject(const Database::IsmStructureElement &dbData)
{
m_data = Database::convert(dbData);
if (m_data.id() <= 0)
{
m_data.isUsed(false);
Database::IsmStructureElement dbData2(dbData);
if (!db()->insert(dbData2))
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IsmStructureElement-data into database"));
m_data.id(dbData2.id);
DEBUG_LOG(m_logger) << "New Id: " << m_data.id();
}
updateGeoPosition();
// Publish Data via DTS
//onPublishData();
return Core::FunctionReplyObject(m_data.id());
}
// -------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectStructureElement::updateObject(const StructureElement &data)
{
if (!isValid())
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
if (!db()->update(toDbData(data)))
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating StructureElement with id %1 in database")).arg(data.id());
m_data = data;
TRACE_LOG(m_logger) << "Data changed for Id: " << m_data.id();
updateGeoPosition();
// Publish Data via DTS
//onPublishData();
return Core::FunctionReplyObject(m_data.id());
}
// -------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectStructureElement::setUsed(bool isUsed)
{
if (!isValid())
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed IsmStructureElement object"));
m_data.isUsed(isUsed);
// Publish Data via DTS
//onPublishData();
return Core::FunctionReplyObject(m_data.id());
}
// -------------------------------------------------------------------------------------------------------
Core::FunctionReplyObject ObjectStructureElement::removeObject()
{
if (isUsed())
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "StructureElement still in use"));
if (!db()->removeIsmStructureElement(m_data.id()))
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "StructureElement with id %1 can not be removed from DB")).arg(m_data.id());
return Core::FunctionReplyObject(m_data.id());
}
// -------------------------------------------------------------------------------------------------------
void ObjectStructureElement::updateGeoPosition()
{
if (m_data.mainStructureElementId() <= 0)
return;
const Core::GeoPosition &geoPositionBase = m_objMse->getData().geoPosition();
const double angleDegree = m_objMse->getData().angle();
updateGeoPosition(LtsCoordTrans::UtmCoordinate::fromGeographic(geoPositionBase.lon(), geoPositionBase.lat()), geoPositionBase.z(), angleDegree);
}
// -------------------------------------------------------------------------------------------------------
void ObjectStructureElement::updateGeoPosition(const LtsCoordTrans::UtmCoordinate &basePoint, double zBase, double angleDeg)
{
const QPointF offset = rotatePoint(m_data.relPosition().offsetX(), m_data.relPosition().offsetY(), angleDeg);
const QPointF geoPos = basePoint.geographic(offset);
m_data.geoPosition() = Core::GeoPosition(geoPos.x(), geoPos.y(), m_data.relPosition().offsetZ() + zBase);
}
// -------------------------------------------------------------------------------------------------------
// convert methods
// -------------------------------------------------------------------------------------------------------
// InfrastructureManagement::StructureElement => Database::IsmStructureElement
Database::IsmStructureElement ObjectStructureElement::toDbData(const StructureElement &ddsData)
{
Database::IsmStructureElement dbData;
dbData.id = ddsData.id();
dbData.name = QString::fromStdString(ddsData.name());
dbData.displayName = QString::fromStdString(ddsData.displayName());
dbData.mainStructureElementId = ddsData.mainStructureElementId();
dbData.structureElementTypeId = ddsData.structureElementTypeId();
dbData.path = LtsUtils::IntArray(ddsData.path());
dbData.mountingPointId = ddsData.mountingPointId();
dbData.barcode = QString::fromStdString(ddsData.barcode());
dbData.relPosition = LtsUtils::QPoint3D(ddsData.relPosition());
dbData.mountingPointTypeId = ddsData.mountingPointTypeId();
dbData.orientation = LtsUtils::QPoint3D(ddsData.orientation().heave(),
ddsData.orientation().pitch(),
ddsData.orientation().roll());
dbData.properties = QString::fromStdString(ddsData.properties());
return dbData;
}
//-------------------------------------------------------------------------------------------------------------