Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Plugins/InfrastructureManagement/Shared/ism_mounting_point.cpp
T
torstenandCopilot b774f4035c Qt6 Migration: DDS-Stubs, Logger-Fixes, Export-Header Korrekturen
- 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>
2026-08-19 06:06:24 +02:00

256 lines
9.6 KiB
C++
Executable File

#include "ism_mounting_point.h"
#include <QFile>
#include <QPainter>
#include <QFont>
#include <QFontMetrics>
#include <QImageWriter>
#include <QJsonObject>
#include <QJsonDocument>
#include <QMap>
#include <QDebug>
namespace InfrastructureManagement
{
MountingPoint::MountingPoint()
: m_data()
, m_associatedAssetId(0)
, m_aimState(MountingPointState::Undefined)
, m_hasAssociatedAssetDefect(false)
, m_isValid(false)
, m_floor(-1)
{
}
MountingPoint::MountingPoint(const StructureElement &data, int floorId)
: m_data(data)
, m_associatedAssetId(0)
, m_aimState(MountingPointState::Undefined)
, m_hasAssociatedAssetDefect(false)
, m_isValid(true)
, m_floor(floorId)
{
}
void MountingPoint::init()
{
getImageTableInternal();
}
QString MountingPoint::name() const
{
return QString::fromStdString(m_data.displayName());
}
QString MountingPoint::fileName() const
{
return QString::fromStdString(m_data.name());
}
QImage MountingPoint::toImage(int32_t edgeLength) const
{
QImage img(edgeLength, edgeLength, QImage::Format_ARGB32);
img.fill(Qt::transparent);
QPainter painter(&img);
painter.setRenderHint(QPainter::Antialiasing);
// Zeichne basierend auf aimState
QColor color;
switch (m_aimState) {
case MountingPointState::Equipped:
color = Qt::green;
break;
case MountingPointState::Empty:
color = Qt::red;
break;
case MountingPointState::Idle:
color = Qt::gray;
break;
default:
color = Qt::blue;
break;
}
painter.setBrush(color);
painter.setPen(Qt::NoPen);
painter.drawEllipse(2, 2, edgeLength - 4, edgeLength - 4);
return img;
}
bool MountingPoint::writeFile(int32_t edgeLength) const
{
QImage img = toImage(edgeLength);
QString fileName = this->fileName();
if (fileName.isEmpty()) {
return false;
}
QImageWriter writer(fileName);
return writer.write(img);
}
void MountingPoint::setAssociatedAssetId(int32_t id)
{
m_associatedAssetId = id;
}
void MountingPoint::setHasAssociatedAssetDefect(bool hasDefect)
{
m_hasAssociatedAssetDefect = hasDefect;
}
MountingPointState MountingPoint::getNextMountingPointState(const MountingPointState currState)
{
switch (currState) {
case MountingPointState::Undefined:
return MountingPointState::Empty;
case MountingPointState::Equipped:
return MountingPointState::Empty;
case MountingPointState::Empty:
return MountingPointState::Idle;
case MountingPointState::Idle:
return MountingPointState::Equipped;
default:
return MountingPointState::Undefined;
}
}
QString MountingPoint::mpColorToString(MpColor mpColor)
{
switch (mpColor) {
case MpColor::GRAY: return QString::fromUtf8("gray");
case MpColor::BLUE: return QString::fromUtf8("blue");
case MpColor::RED: return QString::fromUtf8("red");
case MpColor::GREEN: return QString::fromUtf8("green");
case MpColor::ORANGE: return QString::fromUtf8("orange");
default: return QString::fromUtf8("unknown");
}
}
QString MountingPoint::mpColorToPostfix(MpColor mpColor)
{
switch (mpColor) {
case MpColor::GRAY: return QString::fromUtf8("_gray");
case MpColor::BLUE: return QString::fromUtf8("_blue");
case MpColor::RED: return QString::fromUtf8("_red");
case MpColor::GREEN: return QString::fromUtf8("_green");
case MpColor::ORANGE: return QString::fromUtf8("_orange");
default: return QString::fromUtf8("_unknown");
}
}
QMap<MountingPointType, MountingPoint::MpNameImageData> &MountingPoint::getImageTable()
{
return getImageTableInternal();
}
bool MountingPoint::getImageAttributePlanActivity(const MountingPoint& mp,
QImage &imgOut, QString &attribNameOut)
{
return getImageAttribute(mp, MpColor::BLUE, imgOut, attribNameOut);
}
bool MountingPoint::getImageAttributePlanDefinition(const MountingPoint& mp,
QImage &imgOut, QString &attribNameOut)
{
return getImageAttribute(mp, MpColor::GRAY, imgOut, attribNameOut);
}
bool MountingPoint::getImageAttribute(const MountingPoint& mp, MpColor mpColor,
QImage &img, QString &attribName)
{
const auto &table = getImageTable();
auto it = table.find(mp.type());
if (it == table.end()) {
return false;
}
const MpNameImageData &data = it.value();
switch (mpColor) {
case MpColor::GRAY:
img = data.nipGray.m_img;
attribName = data.nipGray.m_name;
break;
case MpColor::BLUE:
img = data.nipBlue.m_img;
attribName = data.nipBlue.m_name;
break;
case MpColor::RED:
img = data.nipRed.m_img;
attribName = data.nipRed.m_name;
break;
case MpColor::GREEN:
img = data.nipGreen.m_img;
attribName = data.nipGreen.m_name;
break;
case MpColor::ORANGE:
img = data.nipOrange.m_img;
attribName = data.nipOrange.m_name;
break;
}
return !img.isNull();
}
QMap<MountingPointType, MountingPoint::MpNameImageData> &MountingPoint::getImageTableInternal()
{
static QMap<MountingPointType, MpNameImageData> imageTable;
static bool initialized = false;
if (!initialized) {
// Initialisiere mit Platzhalter-Daten
insertHelper(MountingPointType::Generic, QString::fromUtf8("Generic"), QString::fromUtf8(":/gray/generic.png"),
QString::fromUtf8(":/green/generic.png"), QString::fromUtf8(":/red/generic.png"), QString::fromUtf8(":/orange/generic.png"));
insertHelper(MountingPointType::Sensor, QString::fromUtf8("Sensor"), QString::fromUtf8(":/gray/sensor.png"),
QString::fromUtf8(":/green/sensor.png"), QString::fromUtf8(":/red/sensor.png"), QString::fromUtf8(":/orange/sensor.png"));
insertHelper(MountingPointType::Actuator, QString::fromUtf8("Actuator"), QString::fromUtf8(":/gray/actuator.png"),
QString::fromUtf8(":/green/actuator.png"), QString::fromUtf8(":/red/actuator.png"), QString::fromUtf8(":/orange/actuator.png"));
insertHelper(MountingPointType::BuildingSensorModule, QString::fromUtf8("BSM"), QString::fromUtf8(":/gray/bsm.png"),
QString::fromUtf8(":/green/bsm.png"), QString::fromUtf8(":/red/bsm.png"), QString::fromUtf8(":/orange/bsm.png"));
insertHelper(MountingPointType::OutdoorCamera, QString::fromUtf8("OutdoorCamera"), QString::fromUtf8(":/gray/camera.png"),
QString::fromUtf8(":/green/camera.png"), QString::fromUtf8(":/red/camera.png"), QString::fromUtf8(":/orange/camera.png"));
insertHelper(MountingPointType::IndoorCamera, QString::fromUtf8("IndoorCamera"), QString::fromUtf8(":/gray/camera.png"),
QString::fromUtf8(":/green/camera.png"), QString::fromUtf8(":/red/camera.png"), QString::fromUtf8(":/orange/camera.png"));
insertHelper(MountingPointType::OutdoorIPS, QString::fromUtf8("OutdoorIPS"), QString::fromUtf8(":/gray/ips.png"),
QString::fromUtf8(":/green/ips.png"), QString::fromUtf8(":/red/ips.png"), QString::fromUtf8(":/orange/ips.png"));
insertHelper(MountingPointType::IndoorIPS, QString::fromUtf8("IndoorIPS"), QString::fromUtf8(":/gray/ips.png"),
QString::fromUtf8(":/green/ips.png"), QString::fromUtf8(":/red/ips.png"), QString::fromUtf8(":/orange/ips.png"));
insertHelper(MountingPointType::MeteoDataUnit, QString::fromUtf8("Meteo"), QString::fromUtf8(":/gray/meteo.png"),
QString::fromUtf8(":/green/meteo.png"), QString::fromUtf8(":/red/meteo.png"), QString::fromUtf8(":/orange/meteo.png"));
insertHelper(MountingPointType::AnnouncementUnit, QString::fromUtf8("Announcement"), QString::fromUtf8(":/gray/announcement.png"),
QString::fromUtf8(":/green/announcement.png"), QString::fromUtf8(":/red/announcement.png"), QString::fromUtf8(":/orange/announcement.png"));
insertHelper(MountingPointType::BuildingNetworkSwitch, QString::fromUtf8("Switch"), QString::fromUtf8(":/gray/switch.png"),
QString::fromUtf8(":/green/switch.png"), QString::fromUtf8(":/red/switch.png"), QString::fromUtf8(":/orange/switch.png"));
insertHelper(MountingPointType::EffectGenerationControlUnit, QString::fromUtf8("EGCU"), QString::fromUtf8(":/gray/egcu.png"),
QString::fromUtf8(":/green/egcu.png"), QString::fromUtf8(":/red/egcu.png"), QString::fromUtf8(":/orange/egcu.png"));
insertHelper(MountingPointType::Unknown, QString::fromUtf8("Unknown"), QString::fromUtf8(":/gray/unknown.png"),
QString::fromUtf8(":/green/unknown.png"), QString::fromUtf8(":/red/unknown.png"), QString::fromUtf8(":/orange/unknown.png"));
initialized = true;
}
return imageTable;
}
void MountingPoint::insertHelper(MountingPointType type,
const QString &name,
const QString &colorCodeGray,
const QString &colorCodeGreen,
const QString &colorCodeRed,
const QString &colorCodeOrange,
const QString &defName)
{
MpNameImageData data;
data.nipGray = NameImagePair(name.isEmpty() ? defName : name + u"_gray", QImage(colorCodeGray));
data.nipBlue = NameImagePair(name.isEmpty() ? defName : name + u"_blue", QImage(colorCodeGray)); // blau = grau als Platzhalter
data.nipGreen = NameImagePair(name.isEmpty() ? defName : name + u"_green", QImage(colorCodeGreen));
data.nipRed = NameImagePair(name.isEmpty() ? defName : name + u"_red", QImage(colorCodeRed));
data.nipOrange = NameImagePair(name.isEmpty() ? defName : name + u"_orange", QImage(colorCodeOrange));
getImageTableInternal()[type] = data;
}
} // namespace InfrastructureManagement