Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Viewer/SituationMap/SymbologyXML/symbol_reader.h
T
torstenandCopilot 4c9861a469 BUILD_RTI conditional fixes and Qt6 API updates
- cmake/FindRTI.cmake: Add INTERFACE placeholder targets when RTI not found
- cmake/FindRTI.cmake: Force BUILD_RTI=OFF when RTI not installed
- Lts/Common/LtsSession/CMakeLists.txt: Make LtsSessionDataDds conditional on BUILD_RTI
- Lts/Viewer/CMakeLists.txt: Make LtsDataView conditional on BUILD_RTI
- Lts/Plugins/*/CMakeLists.txt: 97 plugin files wrapped in BUILD_RTI conditionals
- cmake/NGLMacros.cmake: Fix NGL_ADD_BIG_RESOURCES macro (removed premature return())
- Multiple Qt6 API fixes: QLinkedList→std::list, QStringRef→QStringView, etc.
- BUILD_RTI_FIXES_SUMMARY.md: Comprehensive documentation of all fixes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 09:24:50 +02:00

227 lines
6.8 KiB
C++
Executable File

/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include "symbology_xml_export.h"
#include "symbol.h"
#include "primitive.h"
#include <QColor>
#include <QString>
#include <QXmlStreamReader>
#include <NGLLogger/INGLLogger.h>
class QBuffer;
class QFile;
namespace SymbologyXML
{
/**
\brief Read a Symbol from a XML-File or XML-String.
Symbols are stored as XML-Files on HD or in a database. This class reads a
XML-Description of a Symbol and writes the data into a given Symbol. To export
a Symbol to XML, use SymbolWriter.
@author Stephan Kuhagen <stephan.kuhagen@rheinmetall.com>
*/
class SYMBOLOGY_XML_EXPORT SymbolReader : public QXmlStreamReader {
public:
SymbolReader();
~SymbolReader();
/**
Read a symbol from a file
\param xml: The file containing the XML-description of the symbol
\param target: The symbol, where the data should go
\return true on success, false otherwise
*/
bool read(QFile *xml, Symbol &target);
/**
Read a symbol from a string
\param xml: The file containing the XML-description of the symbol
\param target: The symbol, where the data should go
\return true on success, false otherwise
*/
bool read(const QString &xml, Symbol &target);
/**
Read a symbol from a string
\param xml: The file containing the XML-description of the symbol
\param target: The symbol, where the data should go
\return true on success, false otherwise
*/
bool read(const QByteArray &xml, Symbol &target);
private:
//! NGLLogger
NGL::INGLLogger& logger;
/**
Read a symbol from the current IODevice. The IODevice is set and created
the string of file of the public read()-methods
\return true on success, false otherwise
*/
bool read();
//! Read an unknown element until a close-tag is found
void readUnknownElement();
//! Read a symbol-element
void readSymbol();
//! Read a name-element
void readName();
//! Read a branch-element
void readBranch();
//! Read the APP6-Classification
void readApp6Class();
//! Read a misc-element
void readMisc();
//! Read a text-element
void readText(unsigned int lines);
//! Read a graphic-element
void readGraphic();
/**
Read a data-element
\param align: Pointer to a t_alignment-variable
\return The data as a string
*/
QString readData(Symbol::t_alignment* align);
//! Read a ellipse-element
void readGEllipse();
//! Read a line-element
void readGLine();
//! Read a polygon-element
void readGPolygon();
//! Read a rect-element
void readGRect();
//! Read a icon-element
void readGIcon();
//! Read a text-element
void readGText();
//! Read a point-element
QPointF readGPoint();
/**
Parse a bool-attribute
\param name: The name of the Attribute
\param def: The default-value, if implied==true and the Attribute is not
in the XML-Data.
\param implied: If true, then the Attribute is implied and if not present
in the XML-Data, then default is returned.
*/
bool getAttribBool(const char *name, bool def = false, bool implied = false);
/**
Parse a double-attribute
\param name: The name of the Attribute
\param def: The default-value, if implied==true and the Attribute is not
in the XML-Data.
\param implied: If true, then the Attribute is implied and if not present
in the XML-Data, then default is returned.
*/
double getAttribDouble(const char *name, double def = 0.0, bool implied = false);
/**
Parse a int-attribute
\param name: The name of the Attribute
\param def: The default-value, if implied==true and the Attribute is not
in the XML-Data.
\param implied: If true, then the Attribute is implied and if not present
in the XML-Data, then default is returned.
*/
int getAttribInt(const char *name, int def = 0, bool implied = false);
/**
Parse a linestyle-attribute
\param default: The default-value, if implied==true and the Attribute is not
in the XML-Data.
\param implied: If true, then the Attribute is implied and if not present
in the XML-Data, then default is returned.
*/
Primitive::t_linestyle getAttribLineStyle();
/**
Parse a Position-attribute
\param default: The default-value, if implied==true and the Attribute is not
in the XML-Data.
\param implied: If true, then the Attribute is implied and if not present
in the XML-Data, then default is returned.
*/
SymbolTypes::t_sector_position getAttribPosition(SymbolTypes::t_sector_position def = SymbolTypes::SECTOR_POSITION_UNDEFINED);
/**
Parse a Rectpos-attribute
\param default: The default-value, if implied==true and the Attribute is not
in the XML-Data.
\param implied: If true, then the Attribute is implied and if not present
in the XML-Data, then default is returned.
*/
SymbolTypes::t_sector_rectpos getAttribRectpos(SymbolTypes::t_sector_rectpos def = SymbolTypes::SECTOR_RECTPOS_DEFAULT);
/**
Parse a scalemode-attribute
\param default: The default-value, if implied==true and the Attribute is not
in the XML-Data.
\param implied: If true, then the Attribute is implied and if not present
in the XML-Data, then default is returned.
*/
Primitive::t_scalemode getAttribScalemode(Primitive::t_scalemode def = Primitive::Scalemode_Proport);
/**
Parse a linestyle-attribute
\param default: The default-value, if implied==true and the Attribute is not
in the XML-Data.
\param implied: If true, then the Attribute is implied and if not present
in the XML-Data, then default is returned.
*/
QString getAttribString(const char *name);
/**
Parse a color-attribute
\param default: The default-value, if implied==true and the Attribute is not
in the XML-Data.
*/
QColor getAttribColor(const QColor &def = QColor());
/**
Concatinate filename and symbol id for debug-output.
\return filename and symbol for debug
*/
QString getDebugInfo() const;
/**
Creates a primitive ICON
\return primitive
*/
Primitive *newPrimitiveICON(SymbolTypes::t_icon_type iconType,
SymbolTypes::t_sector_position pos, SymbolTypes::t_sector_rectpos rectpos,
int id);
Primitive *newMiscPrimitiveICON(const QStringView &attrib);
//! Buffer containing the QString from read() with QString
QBuffer* _buffer;
//! Pointer to the symbol, where the data should go
Symbol* _symbol;
//! Save the symbols transformed-flag until parsing is complete
bool _transformed;
//! Save the filename for debuuging
QString _filename;
}; // class SymbolReader : public QXmlStreamReader
}; // namespace SymologyXML