Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

+120
View File
@@ -0,0 +1,120 @@
#
# $Id$
# $HeadURL$
# $Author$
#
# LIBRARY
SET(Symbology_SRCS
sidc_codec.cpp
symbol_dictionary.cpp
property_result.cpp
symbol_data_to_render.cpp
symbol_result.cpp
symbol_properties.cpp
sidc_definitions.cpp
sidc_builder_base.cpp
sidc_builder.cpp
# sidc2525_delta.cpp
)
SET(Symbology_HDRS
advanced_symbology_export.h
bulk_renderer.h
symbology_type.h
symbol_dictionary_types.h
symbol_dictionary.h
property_result.h
symbol_data_to_render.h
symbol_result.h
symbol_properties.h
sidc_codec.h
sidc_definitions.h
sidc_builder_base.h
sidc_builder.h
# sidc2525_delta.h
result_watcher.h
)
SET(SymbologyImpl_SRCS
../SymbologyImpl/advanced_symbology_logging.cpp
../SymbologyImpl/symbol_extension_renderer.cpp
../SymbologyImpl/symbol_dictionary_impl.cpp
../SymbologyImpl/esri_dictionary_processor.cpp
../SymbologyImpl/esri_dictionary_processor_mil2525d.cpp
../SymbologyImpl/esri_dictionary_processor_app6.cpp
../SymbologyImpl/esri_dictionary_processor_app6d.cpp
../SymbologyImpl/base_symbol_model.cpp
)
SET(SymbologyImpl_HDRS
../SymbologyImpl/advanced_symbology_logging.h
../SymbologyImpl/symbol_extension_renderer.h
../SymbologyImpl/symbol_dictionary_impl.h
../SymbologyImpl/esri_dictionary_processor.h
../SymbologyImpl/esri_dictionary_processor_mil2525d.h
../SymbologyImpl/esri_dictionary_processor_app6.h
../SymbologyImpl/esri_dictionary_processor_app6d.h
../SymbologyImpl/base_symbol_model.h
)
QT5_ADD_RESOURCES(Symbology_SRCS ../SymbologyImpl/Resources/symbols.qrc)
SOURCE_GROUP(Symbology FILES ${Symbology_SRCS} ${Symbology_HDRS} ${SymbologyImpl_SRCS} ${SymbologyImpl_HDRS})
NGL_ADD_LIBRARY(WS advancedSymbology SHARED ${Symbology_SRCS} ${Symbology_HDRS} ${SymbologyImpl_SRCS} ${SymbologyImpl_HDRS})
NGL_TARGET_INCLUDE_DIRECTORIES(advancedSymbology
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/..
)
NGL_TARGET_LINK_LIBRARIES(advancedSymbology
PRIVATE
ArcGIS::ArcGIS
Qt5::Concurrent
ngltools # DTG
situationMapCommon
LtsDataView
LtsSessionData
LtsUtilsCoreHeaderOnly
PUBLIC
advancedSymbologyXML
NGLLogger
Qt5::Core
Qt5::Widgets
)
IF(BUILD_TESTING AND BUILD_SITMAP_UNIT_TESTS AND TARGET situationMapCommon)
NGL_ADD_LIBRARY(WS NO_TRANSLATION advancedSymbology_static STATIC ${Symbology_SRCS} ${Symbology_HDRS} ${SymbologyImpl_SRCS} ${SymbologyImpl_HDRS})
NGL_TARGET_COMPILE_DEFINITIONS(advancedSymbology_static PUBLIC "ADVANCED_SYMBOLOGY_EXPORT=")
NGL_TARGET_INCLUDE_DIRECTORIES(advancedSymbology_static
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/..
# INTERFACE
# ${CMAKE_CURRENT_SOURCE_DIR}
)
NGL_TARGET_LINK_LIBRARIES(advancedSymbology_static
PRIVATE
NGLLogger
ArcGIS::ArcGIS
Qt5::Concurrent
PUBLIC
advancedSymbologyXML
Qt5::Core
Qt5::Widgets
LtsDataView
LtsSessionData
LtsUtilsCoreHeaderOnly
)
ENDIF()
NGL_INSTALL_TARGET(advancedSymbology)
@@ -0,0 +1,21 @@
/**
* Export definitions
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <qglobal.h>
#ifndef ADVANCED_SYMBOLOGY_EXPORT
# ifdef BUILD_STATIC_LIBRARIES
# define ADVANCED_SYMBOLOGY_EXPORT
# else
# if defined(MAKE_ADVANCEDSYMBOLOGY_LIB)
# define ADVANCED_SYMBOLOGY_EXPORT Q_DECL_EXPORT
# else
# define ADVANCED_SYMBOLOGY_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif
+225
View File
@@ -0,0 +1,225 @@
/**
* @RDE_HEADER@
* BulkRenderer
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "symbol_dictionary.h"
#include "symbol_result.h"
// Qt
#include <QSharedPointer>
#include <QVector>
#include <QString>
// Forward
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
//----------------------------------------------------------------------------
class ADVANCED_SYMBOLOGY_EXPORT BulkRendererBase : public QObject
{
Q_OBJECT
public:
BulkRendererBase() = default;
virtual ~BulkRendererBase() = default;
public Q_SLOTS:
void onSingleResultReady()
{
++m_resultReadyCounter;
if (m_resultReadyCounter >= m_requestCount)
emit resultsReady();
}
Q_SIGNALS:
/// Signal emits when all results are ready
void resultsReady();
protected:
uint m_resultReadyCounter = 0;
uint m_requestCount = 0;
};
//----------------------------------------------------------------------------
template<class INPUT_TYPE>
class BulkRenderer : public BulkRendererBase
{
public:
using RequestResult = QPair<INPUT_TYPE, QSharedPointer<SymbolResultWatcher>>;
using RequestResultVector = QVector<RequestResult>;
explicit BulkRenderer(SymbologyType symbologyType)
: m_symbologyType(symbologyType)
{}
virtual ~BulkRenderer() = default;
void addRequest(const INPUT_TYPE &request)
{
m_requestResultVector.append(RequestResult(request, QSharedPointer<AdvancedSymbology::SymbolResultWatcher>(new AdvancedSymbology::SymbolResultWatcher(this))));
}
int size() { return m_requestResultVector.size(); }
virtual void run() = 0;
void cancel()
{
for (RequestResult &requestResult : m_requestResultVector)
{
QSharedPointer<SymbolResultWatcher> watcher = requestResult.second;
if (watcher)
watcher->cancel();
} // for
}
void reset()
{
// will destroy the associated SymbolResults if the shdPtr has last reference.
// In that case waitForFinished will be called.
m_requestResultVector.clear();
// to be complete:
m_resultReadyCounter = 0;
m_requestCount = 0;
}
const RequestResultVector &results() const
{
return m_requestResultVector;
}
QSharedPointer<SymbolResultWatcher> getResult(const INPUT_TYPE &request)
{
for (const RequestResult &requestResult : m_requestResultVector)
{
if (requestResult.first == request)
return requestResult.second;
}
return nullptr;
}
protected:
void setupWatcher()
{
m_resultReadyCounter = 0;
m_requestCount = m_requestResultVector.size();
// start every single render request:
for (RequestResult &requestResult : m_requestResultVector)
{
// requestResult.second =
// QSharedPointer<SymbolResultWatcher> (new SymbolResultWatcher());
connect(requestResult.second.data(), &SymbolResultWatcher::resultReady,
this, &BulkRendererBase::onSingleResultReady, Qt::QueuedConnection);
} // for
}
protected:
SymbologyType m_symbologyType = SymbologyType::None;
RequestResultVector m_requestResultVector;
};
//----------------------------------------------------------------------------
class ADVANCED_SYMBOLOGY_EXPORT BulkRendererFindImage : public BulkRenderer<SymbolDataToRender>
{
public:
explicit BulkRendererFindImage(SymbologyType symbologyType)
: BulkRenderer<SymbolDataToRender>(symbologyType)
{}
virtual ~BulkRendererFindImage() = default;
void run() override
{
setupWatcher();
const SymbolDictionary &dict = SymbolDictionary::dictionary(m_symbologyType);
// start every single render request:
for (RequestResult &requestResult : m_requestResultVector)
{
// 1st
const SymbolDataToRender &input = requestResult.first;
// 2nd
QSharedPointer<SymbolResultWatcher> watcher = requestResult.second;
if (watcher)
watcher->setSymbolResult(dict.findImage(input));
} // for
}
};
//----------------------------------------------------------------------------
class ADVANCED_SYMBOLOGY_EXPORT BulkRendererFindBaseSymbol : public BulkRenderer<QString>
{
public:
explicit BulkRendererFindBaseSymbol(SymbologyType symbologyType)
: BulkRenderer<QString>(symbologyType)
{}
virtual ~BulkRendererFindBaseSymbol() = default;
void run() override
{
setupWatcher();
const SymbolDictionary &dict = SymbolDictionary::dictionary(m_symbologyType);
// start every single render request:
for (RequestResult &requestResult : m_requestResultVector)
{
// 1st
const QString &input = requestResult.first;
// 2nd
QSharedPointer<SymbolResultWatcher> watcher = requestResult.second;
if (watcher)
watcher->setSymbolResult(dict.findBaseSymbol(input));
} // for
}
};
//----------------------------------------------------------------------------
class ADVANCED_SYMBOLOGY_EXPORT BulkRendererFindPreview : public BulkRenderer<QString>
{
public:
explicit BulkRendererFindPreview(SymbologyType symbologyType)
: BulkRenderer<QString>(symbologyType)
{}
void run() override
{
setupWatcher();
const SymbolDictionary &dict = SymbolDictionary::dictionary(m_symbologyType);
// start every single render request:
for (RequestResult &requestResult : m_requestResultVector)
{
// 1st
const QString &input = requestResult.first;
// 2nd
QSharedPointer<SymbolResultWatcher> watcher = requestResult.second;
if (watcher)
watcher->setSymbolResult(dict.findPreview(input));
} // for
}
};
} // namespace AdvancedSymbology
+37
View File
@@ -0,0 +1,37 @@
//
symbol: Reference to Symbol (SIDC)
LOGIC: dimension (WITHIN SIDC)
LOGIC: affiliation (WITHIN SIDC)
LOGIC: teamID: ID of the team associated with this Symbol. If no team is
needed for this Symbol, use 0, which is the "Default Team".
LOGIC: useLightColor: Use either the dark or the light color of the given forceID
TECHN: lineColor
TECHN: fillColor
LOGIC: vbg
TECHN: SIZE: The reference size 'L' of the image to create (!= resulting image)
TECHN: antialias: If true (default), use antialiasing for drawing the symbol.
[[ TECHN: useSymbolZoom: If true, use the scale-factor from the symbol (default is false). ]]
AdditionalSymbolData:
t_filltype m_filltype { FILLTYPE_OUTLINED, FILLTYPE_FILLED, FILLTYPE_ICONONLY,}
t_state m_state; { STATE_PRESENT, STATE_ANTICIPATED} -> dashed line (Prio 2)
t_uncertainty m_uncertainty; { UNCERTAINTY_CERTAIN, UNCERTAINTY_UNCERTAIN} -> dotted line (Prio 1)
double m_scale; UserScale (+symbolScale)
//// vbg_struct m_vbg; {EINSATZBEREIT, BEWEGUNGSUNFAEHIG, AUSFALL_WAFFENANLAGE, TOTALAUSFALL...}
modifier_struct m_modifier; {bool manipulation, noPosition, byteError;}
int m_rotationAngle; // degree, counterclockwise (used for Heading of symbols)
File diff suppressed because it is too large. Load diff
+452
View File
@@ -0,0 +1,452 @@
/**
* @RDE_HEADER@
* Class Sidc2525Delta
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "../SymbologyImpl/advanced_symbology_logging.h" // ToDo
// Qt
#include <QString>
#include <QVector>
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
//
// Version : digit 1,2
//
//
// StandardIdentity : digit 3,4
//
enum class ShapeType
{
UNDEFINED,
CIRCLE,
CLOVER,
CURVE,
DIAMOND,
RECTANGLE,
SQUARE
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(ShapeType value);
// StandardIdentity, 1st digit
enum class Context
{
Reality, ///< 0
Exercise, ///< 1
Simulation ///< 2
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(Context value);
QVector<Context> ADVANCED_SYMBOLOGY_EXPORT contexts();
// StandardIdentity, 2nd digit
enum class Identity
{
Pending, ///< 0
Unknown, ///< 1
AssumedFriend, ///< 2
Friend, ///< 3
Neutral, ///< 4
SuspectJoker, ///< 5
HostileFaker ///< 6
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(Identity value);
QVector<Identity> ADVANCED_SYMBOLOGY_EXPORT identities();
struct ADVANCED_SYMBOLOGY_EXPORT StandardIdentity
{
Context context = Context::Reality; ///< 1st digit
Identity identity = Identity::Unknown; ///< 2nd digit
void init();
ShapeType getShape() const; // BattleDimension missing!!!!!!!
};
//
// : StandardIdentity
//
//
// Symbol Set : digit 5,6
//
enum class SymbolSet
{
Unknown, ///< 0
Air,
AirMissle,
Space = 5,
SpaceMissle,
LandUnit = 10,
LandCivilian_UnitOrganisation,
LandEquipment = 15,
LandInstallation = 20,
ControlMeasure = 25,
SeaSurface = 30,
SeaSubSurface = 35,
MineWarfare,
Activities = 40,
Atmospheric = 45,
Oceanographic,
MeteorologicalSpace = 50,
SignalsIntelligence_Space,
SignalsIntelligence_Air,
SignalsIntelligence_Land,
SignalsIntelligence_Surface,
SignalsIntelligence_Subsurface,
Cyberspace = 60
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(SymbolSet value);
QVector<SymbolSet> ADVANCED_SYMBOLOGY_EXPORT symbolSets();
template<typename T> SymbolSet castToSymbolSet(T value)
{
SymbolSet symbolSet = static_cast<SymbolSet>(value);
if (!symbolSets().contains(symbolSet)) symbolSet = SymbolSet::Unknown;
return symbolSet;
} // template<typename T> SymbolSet castToSymbolSet(T value)
//
// Status : digit 7
//
enum class Status
{
Present = 0, ///< exeption, no Unknown
Planned_Anticipated_Suspect = 1,
Present_FullCapable = 2,
Present_Damaged = 3,
Present_Destroyed = 4,
Present_FullToCapacity = 5
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(Status value);
QVector<Status> ADVANCED_SYMBOLOGY_EXPORT statuss();
//
// HQ TF Dummy : digit 8
//
enum class HQTFDummy
{
Unknown, ///< 0
FeintDummy, ///< 1
Headquarters, ///< 2
FeintDummy_Headquarters, ///< 3
TaskForce, ///< 4
FeintDummy_TaskForce, ///< 5
TaskForce_Headquarters, ///< 6
FeintDummy_TaskForce_Headquarters, ///< 7
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(HQTFDummy value);
QVector<HQTFDummy> ADVANCED_SYMBOLOGY_EXPORT hQTFDummy();
//
// Amplifier : digit 9,10
//
// Amplifier-Group : 1st digit
enum class AmplifierGroup
{
Unknown,
Echelon_BrigadeAndBelow,
Echelon_DivisionAndAbove,
Mobility_OnLand,
Mobility_OnSnow,
Mobility_OnWater,
Naval_TowedArry,
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(AmplifierGroup value);
QVector<AmplifierGroup> ADVANCED_SYMBOLOGY_EXPORT amplifierGroups();
// Depending on AmplifierGroup :
// Amplifier-Echelon/Mobility/Naval - 2nd digit
enum class EchelonBrigadeAndBelow
{
Unknown = 0,
TeamCrew,
Squad,
Section,
PlatoonDetachment,
BattalionSquadron,
CompanyBatteryTroop,
RegimentGroup,
Brigade
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(EchelonBrigadeAndBelow value);
QVector<EchelonBrigadeAndBelow> ADVANCED_SYMBOLOGY_EXPORT echelonBrigadeAndBelows();
// OR
enum class EchelonDivisionAndAbove
{
Unknown = 0,
Division,
CorpsMEF,
Army,
Army_GroupFront,
RegionTheater,
Command
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(EchelonDivisionAndAbove value);
QVector<EchelonDivisionAndAbove> ADVANCED_SYMBOLOGY_EXPORT echelonDivisionAndAboves();
// OR
enum class MobilityOnLand
{
Unknown = 0,
WheeledLimitedCrossCountry,
WheeledCrossCountry,
Tracked,
WheeledAndTrackedCombination,
Towed,
Rail,
PackAnimal
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(MobilityOnLand value);
QVector<MobilityOnLand> ADVANCED_SYMBOLOGY_EXPORT mobilityOnLands();
// OR
enum class MobilityOnSnow
{
Unknown = 0,
OverSnow,
Sled
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(MobilityOnSnow value);
QVector<MobilityOnSnow> ADVANCED_SYMBOLOGY_EXPORT mobilityOnSnows();
// OR
enum class MobilityOnWater
{
Unknown = 0,
Barge,
Amphibious
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(MobilityOnWater value);
QVector<MobilityOnWater> ADVANCED_SYMBOLOGY_EXPORT mobilityOnWaters();
// OR
enum class NavalTowedArray
{
Unknown = 0,
ShortTowedArray,
LongTowedArray
};
QLatin1String ADVANCED_SYMBOLOGY_EXPORT toString(NavalTowedArray value);
QVector<NavalTowedArray> ADVANCED_SYMBOLOGY_EXPORT navalTowedArrays();
//
// : Amplifier
//
/**
* @brief The Sidc2525Delta class
*
* Support functions:
* Digit Name enum toString Contnr set/getXY Converter
* XYs() toChar/fromChar
* // SET A
* 1,2 Version + + + + irrelevant
* 3,4 StdIdentity + + + + +
* 5,6 SymbolSet + + + + -
* 7 Status + + + + -
* 8 HqTfDummy + + + + + (to be cont.)
* 9 AmplifierGrp + + + + (to be cont.)
* 10 Amplifier... + + + - -
* // SET B
* ...
*
* -> toSidc will evaluate: StdIdentity, hqTfFd(execpt Amplifier)
*/
class ADVANCED_SYMBOLOGY_EXPORT Sidc2525Delta final
{
public:
Sidc2525Delta(qint32 partA = _specialPartA, qint32 partB = _invalidPartB);
void setSidc(const QString &sidcMIL2525D)
{
initFromMil2525D(sidcMIL2525D);
}
bool initFromMil2525D(const QString &sidcMIL2525D);
bool initFromMil2525DBaseSymbolCode(const QString &sidcMIL2525D_baseSymbolCode);
void setLegacySidc(const QString &legacySidcMIL2525);
~Sidc2525Delta() = default;
bool analyzeLegacySidc();
static StandardIdentity legacyToStandardIdentity(const QChar &ch);
bool legacySymbolModifier(const QChar &c1, const QChar &c2);
bool legacySymbolModifier(const QString &str);
QString toSidc() const;
// !!! Attention: digit count starts with 1, not with 0!!!
//
// Set A, digit 1,2
//
// Version
//
// Set A, digit 3,4
//
// StandardIdentity
StandardIdentity standardIdentity() const; // 1st and 2nd
void setStandardIdentity(const StandardIdentity &standardIdentity);
//
// Set A, digit 5,6
//
// SymbolSet
SymbolSet symbolSet() const;
void setSymbolSet(const SymbolSet &symbolSet);
// QChar symbolSetString() const;
//
// Set A, digit 7
//
// Status
Status status() const;
void setStatus(const Status &status);
// QChar statusString() const;
//
// Set A, digit 8
//
// HQTFDummy
HQTFDummy hqTfFd() const;
uint hqTfFd_UInt() const;
void setHqTfFd(const HQTFDummy &hqTfFd);
bool headquarters() const;
bool taskForce() const;
bool feintDummy() const;
// bool installation() const
// {
// return m_installation;
// }
// void setInstallation(bool installation)
// {
// m_installation = installation;
// }
//
// Set A, digit 9, 10
//
AmplifierGroup amplifierGroup() const; // digit 9
void setAmplifierGroup(const AmplifierGroup &amplifierGroup);
unsigned int amplifier2ndDigit() const;
void setAmplifier2ndDigit(unsigned int amplifierSecondDigit);
// quint32 amplifier_UInt(QString *str = nullptr) const; // digit 9,10
// QString amplifier_String() const; // digit 9,10
unsigned int sectorModifier1Digit();
unsigned int sectorModifier2Digit();
void setSectorModifier1Digit( unsigned int );
void setSectorModifier2Digit( unsigned int );
private:
void init();
void initAmplifier();
QString m_first10;
QString m_second10;
//
// SET A :
//
// HQTFFD
// bool m_installation; ///< Installation
// Amplifier (Echelon/Mobility/TowedArray)
AmplifierGroup m_amplifierGroup;
EchelonBrigadeAndBelow m_e_BrigadeAndBelow;
EchelonDivisionAndAbove m_e_DivisionAndAbove;
MobilityOnLand m_e_MobilityOnLand;
MobilityOnSnow m_e_MobilityOnSnow;
MobilityOnWater m_e_MobilityOnWater;
NavalTowedArray m_e_NavalTowedArray;
//
// : SET A
//
//
// SET B :
//
//
// : SET B
//
QString m_legacySidc; //to be removed ///< Based on MIL2525C
static qint32 _smallest;
static qint32 _specialPartA;
static qint32 _invalidPartB;
static qint32 _retiredPartB;
LOGGER_T m_logger; ///< Interface of the Logging-Facility
};
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::ShapeType &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::Identity &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SymbolSet &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::Status &value);
} // namespace AdvancedSymbology
+129
View File
@@ -0,0 +1,129 @@
/**
* @RDE_HEADER@
* Class PropertyResult
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "property_result.h"
// Qt
#include <QUuid>
namespace AdvancedSymbology
{
class PropertyResult::Private
{
public:
Private() = default;
~Private() = default;
// Input data:
// process data:
QUuid m_taskIdFindSymbol; // of esriDict::findSymbol
// Result data:
bool m_resultReady = false;
SymbolPropertyList m_symbolPropertyList;
// For debugging:
static unsigned long m_counter;
};
unsigned long PropertyResult::Private::m_counter = 0;
PropertyResult::PropertyResult()
: QObject()
, d(new Private)
, m_logger(getLogger("PropertyResult"))
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START, m_counter=" << d->m_counter;
++d->m_counter;
TRACE_LOG(m_logger) << LOGFUNCTION << " END, m_counter=" << d->m_counter;
}
PropertyResult::~PropertyResult()
{
LOGGER_T m_logger = getLogger("PropertyResult");
TRACE_LOG(m_logger) << LOGFUNCTION << " START, m_counter=" << d->m_counter;
--d->m_counter;
delete d;
TRACE_LOG(m_logger) << LOGFUNCTION << " END, m_counter=" << Private::m_counter;
}
void PropertyResult::fireResultReady()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
// (this bool don`t has to be reset.
// a new request will return a new instance of this class...)
d->m_resultReady = true;
emit resultReadyInternal();
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
void PropertyResult::setTaskId(const QUuid &uuid)
{
d->m_taskIdFindSymbol = uuid;
}
const QUuid &PropertyResult::taskId() const
{
return d->m_taskIdFindSymbol;
}
void PropertyResult::setProperties(const SymbolPropertyList &properties)
{
d->m_symbolPropertyList = properties;
}
bool PropertyResult::isResultReady() const
{
return d->m_resultReady;
}
SymbolPropertyList PropertyResult::properties() const
{
return d->m_symbolPropertyList;
}
//------------------------------------------------------------------------------
// PropertyResultWatcher
//------------------------------------------------------------------------------
PropertyResultWatcher::PropertyResultWatcher(QObject *parent)
: BaseClass(parent)
, m_logger(getLogger("PropertyResultWatcher"))
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
QSharedPointer<PropertyResult> PropertyResultWatcher::propertyResult() const
{
return BaseClass::result();
}
void PropertyResultWatcher::setPropertyResult(const QSharedPointer<PropertyResult> &propertyResult)
{
BaseClass::setResult(propertyResult);
}
} // namespace AdvancedSymbology
+137
View File
@@ -0,0 +1,137 @@
/**
* @RDE_HEADER@
* Class PropertyResult
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbol_dictionary_types.h"
#include "symbol_properties.h"
#include "result_watcher.h"
#include <SymbologyImpl/advanced_symbology_logging.h>
// Qt
#include <QObject>
// forward
class QUuid;
//----------------------------------------------------------------------------
/**
* Store PropertyResult
*/
namespace AdvancedSymbology
{
using SymbolPropertyList = QList<SymbolProperties>;
/**
* @brief The PropertyResult class
*/
/**
* @brief The PropertyResult class mainly contains a SymbolPropertyList.
* It´s based on the future pattern. So the real result can only be retrieved if
* the asynchron operation has finished (and the result is ready).
* To standardize this you should use a propper watcher: PropertyResultWatcher.
*
* \sa \ref secResultWatcherExample
*/
class ADVANCED_SYMBOLOGY_EXPORT PropertyResult : public QObject
{
Q_OBJECT
/*! \name Construction, Destruction */
//@{
public:
///< Constructor
explicit PropertyResult();
///< Destructor
virtual ~PropertyResult();
//@}
/*! \name Data regarding requested */
//@{
//@}
/*! \name Data regarding processing*/
//@{
/**
* @brief taskId internal taskId
* @return internal taskId
*/
const QUuid &taskId() const;
/*! \name Data regarding result*/
//@{
/**
* @brief Get SymbolPropertyList
* @return SymbolPropertyList
*/
SymbolPropertyList properties() const;
//@}
Q_SIGNALS:
/// This signal is for internal usage only. Use PropertyResultWatcher!
void resultReadyInternal();
protected:
friend class SymbolDictionaryImpl;
void fireResultReady();
friend class ResultWatcher<PropertyResult>;
bool isResultReady() const;
void setTaskId(const QUuid &uuid);
void setProperties(const SymbolPropertyList &properties);
private:
class Private;
/**
* The private d->pointer to not break BC when changing internals of this class
*/
Private *d = nullptr;
LOGGER_T m_logger; ///< Interface of the Logging-Facility
};
//------------------------------------------------------------------------------
/**
* @brief The PropertyResultWatcher class takes one PropertyResult using setPropertyResult.
* If the background operation has finished, the signal resultReady is emitted exactly one time.
*
* \sa \ref secResultWatcherExample
*/
class ADVANCED_SYMBOLOGY_EXPORT PropertyResultWatcher : public ResultWatcher<PropertyResult>
{
Q_OBJECT
using BaseClass = ResultWatcher<PropertyResult>;
public:
///< Constructor
explicit PropertyResultWatcher(QObject *parent = nullptr);
///< Destructor
~PropertyResultWatcher() = default;
QSharedPointer<PropertyResult> propertyResult() const;
void setPropertyResult(const QSharedPointer<PropertyResult> &propertyResult);
protected:
LOGGER_T m_logger; ///< Interface of the Logging-Facility
};
} // namespace AdvancedSymbology
+170
View File
@@ -0,0 +1,170 @@
/**
* @RDE_HEADER@
* Class ResultWatcherBase, ResultWatcher
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbol_dictionary_types.h"
#include <SymbologyImpl/advanced_symbology_logging.h>
// Qt
#include <QObject>
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
//----------------------------------------------------------------------------
// - ResultWatcherBase (containing the Q_OBJECT for signal/slot)
// - ResultWatcher (containing template)
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// ResultWatcherBase (containing the Q_OBJECT for signal/slot)
//----------------------------------------------------------------------------
/**
* @brief The ResultWatcherBase class is a simple base class of ResultWatcher
* and contain the signal resultReady, since a template class can`t.
*/
class ADVANCED_SYMBOLOGY_EXPORT ResultWatcherBase : public QObject
{
Q_OBJECT
public:
///< Constructor
explicit ResultWatcherBase(QObject *parent = nullptr)
: QObject(parent)
{}
///< Destructor
~ResultWatcherBase() = default;
Q_SIGNALS:
/// Signal emits when result is ready
void resultReady();
protected Q_SLOTS:
void onResultReadyInternal()
{
// to avoid emitting signal twice:
if (! m_alreadyEmitted)
emit resultReady();
m_alreadyEmitted = true;
}
protected:
bool m_alreadyEmitted = false;
};
//----------------------------------------------------------------------------
// ResultWatcher (containing template)
//----------------------------------------------------------------------------
/**
* @brief The ResultWatcher class takes a result and will emit resultReady exactly one time.
*
* \section secResultWatcherExample Using the ResultWatcher
* Here is an example of using the ResultWatcher
*
* \code
* AdvancedSymbology::SymbolDictionary &dict = AdvancedSymbology::SymbolDictionary::dictionary(AdvancedSymbology::MIL2525D);
*
* AdvancedSymbology::SymbolResultWatcher symbolResultWatcher;
*
* // FIRST connect:
* connect(&symbolResultWatcher, &AdvancedSymbology::SymbolResultWatcher::resultReady, this, [](){
*
* QSharedPointer<AdvancedSymbology::SymbolResult> symResult = symbolResultWatcher.symbolResult();
* if (! symResult)
* return; // should NEVER happen! (Which object should have triggered the signal???)
*
* if (this->m_targetObject)
* {
* this->m_targetObject->setImage(symResult->symbolImage().image());
* }
* });
*
* // SECOND setResult (starting the asynchronous operation)
* symbolResultWatcher.setSymbolResult( dict.findSymbol("mySidc") );
* \endcode
*
* There is an convenience class: SymbolResultWatcherComboxBox
*
* @note
* Template classes can not contain signals why this is moved to the base class ResultWatcherBase.
*
*/
template <typename RESULT_TYPE>
class ResultWatcher : public ResultWatcherBase
{
public:
///< Constructor
explicit ResultWatcher(QObject *parent = nullptr)
: ResultWatcherBase(parent)
{}
///< Destructor
virtual ~ResultWatcher() = default;
bool resultIsValid() const
{
return ! m_result.isNull();
}
void cancel()
{
m_result.clear();
}
protected:
QSharedPointer<RESULT_TYPE> result() const
{
return m_result;
}
void setResult(const QSharedPointer<RESULT_TYPE> &result)
{
// 2017-11-13, N.Thoden :
// With rev 36928 the SymbolResult of two identical request (identical SymbolDataToRender)
// will shared ONE SymbolResult!
// This szenario happens while showing a snapshot.
// So we have to disconnect explicitly:
// make sure, that we won`t be called by the 'old' object:
// so disconnect:
if (m_result)
m_result->disconnect(this);
// : 2017-11-13, N.Thoden
m_result = result;
m_alreadyEmitted = false;
if (m_result)
{
// Handle race condition:
// 1. connect
connect(m_result.data(), &RESULT_TYPE::resultReadyInternal, this, &ResultWatcher::onResultReadyInternal);
// 2. maybe result was ready before?
if (m_result->isResultReady())
onResultReadyInternal();
}
}
QSharedPointer<RESULT_TYPE> m_result;
};
} // namespace AdvancedSymbology
+479
View File
@@ -0,0 +1,479 @@
/**
* @RDE_HEADER@
* Class SidcBuilder
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "sidc_builder.h"
#include "sidc_codec.h"
// 1234567890
qint32 AdvancedSymbology::SidcBuilder::_smallest = 1000000000;
qint32 AdvancedSymbology::SidcBuilder::_specialPartA = 1001980000;
qint32 AdvancedSymbology::SidcBuilder::_invalidPartB = 1000000000;
qint32 AdvancedSymbology::SidcBuilder::_retiredPartB = 1100000000;
namespace AdvancedSymbology
{
//-----------------------------------------------------------------------------
// SidcBuilder
//-----------------------------------------------------------------------------
SidcBuilder::SidcBuilder(AdvancedSymbology::SymbolDictionary *symbolDictionary)
: SidcBuilderBase(symbolDictionary, "SidcBuilder")
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
init();
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
void SidcBuilder::init()
{
m_first10_mil2525D = QString::number(_specialPartA);
m_second10_mil2525D = QString::number(_invalidPartB);
initAmplifier();
}
void SidcBuilder::initAmplifier()
{
m_amplifierGroup = AmplifierGroup::Unknown;
m_e_BrigadeAndBelow = EchelonBrigadeAndBelow::Unknown;
m_e_DivisionAndAbove = EchelonDivisionAndAbove::Unknown;
m_e_MobilityOnLand = MobilityOnLand::Unknown;
m_e_MobilityOnSnow = MobilityOnSnow::Unknown;
m_e_MobilityOnWater = MobilityOnWater::Unknown;
m_e_NavalTowedArray = NavalTowedArray::Unknown;
}
SidcDefinitions::StandardIdentity SidcBuilder::standardIdentity() const
{
StandardIdentity si;
si.context = context();
si.identity = identity();
return si;
}
void SidcBuilder::setStandardIdentity(const SidcDefinitions::StandardIdentity &standardIdentity)
{
setContext(standardIdentity.context);
setIdentity(standardIdentity.identity);
}
SidcDefinitions::Context SidcBuilder::context() const
{
return static_cast<Context>(QStringRef(&m_first10_mil2525D, 2, 1).toInt());
}
void SidcBuilder::setContext(SidcDefinitions::Context context)
{
m_first10_mil2525D.replace(2, 1, QString::number((int)context));
}
SidcDefinitions::Identity SidcBuilder::identity() const
{
return static_cast<Identity>(QStringRef(&m_first10_mil2525D, 3, 1).toInt());
}
void SidcBuilder::setIdentity(SidcDefinitions::Identity identity)
{
m_first10_mil2525D.replace(3, 1, QString::number((int)identity));
}
bool SidcBuilder::isIdentityAssumed() const
{
const SidcDefinitions::Identity identityValue = identity();
switch (identityValue) {
case SidcDefinitions::Identity::Pending:
return true;
case SidcDefinitions::Identity::AssumedFriend:
return true;
case SidcDefinitions::Identity::SuspectJoker:
return true;
break;
default:
// empty
break;
}
return false;
}
SidcDefinitions::SymbolSet SidcBuilder::symbolSet() const
{
SymbolSet sset = static_cast<SymbolSet>(QStringRef(&m_first10_mil2525D, 4, 2).toString().toInt());
return sset;
}
void SidcBuilder::setSymbolSet(const SymbolSet &symbolSet)
{
m_first10_mil2525D.replace(4, 2, QStringLiteral("%1").arg((int)symbolSet, 2, 10, QLatin1Char('0')));
}
SidcDefinitions::Status SidcBuilder::status() const
{
Status status = static_cast<Status>(QStringRef(&m_first10_mil2525D, 6, 1).toInt());
return status;
}
void SidcBuilder::setStatus(const Status &status)
{
m_first10_mil2525D.replace(6, 1, QString::number((int)status));
}
QString SidcBuilder::symbolEntityCode() const
{
SymbologyType symbologyType = m_symbolDictionary->symbologyType();
switch (symbologyType)
{
case SymbologyType::APP6B : return SidcCodec::decodeRawSidc(concreteSidcToBaseSymbolCode(SidcCodec::encodeComplete(symbologyType,m_app6bRawSidc)));
case SymbologyType::APP6D : return m_second10_mil2525D.left(6);
case SymbologyType::MIL2525C : return QString();
case SymbologyType::MIL2525D : return m_second10_mil2525D.left(6);
case SymbologyType::None : return QString();
}
return QString();
}
void SidcBuilder::setSymbolEntityCode(const QString &entityCode)
{
if (entityCode.size() == 6) m_second10_mil2525D.replace(0, 6, entityCode);
}
SidcDefinitions::HQTFDummy SidcBuilder::hqTfFd() const
{
HQTFDummy hdtffd = static_cast<HQTFDummy>(QStringRef(&m_first10_mil2525D, 7, 1).toInt());
return hdtffd;
}
uint SidcBuilder::hqTfFd_UInt() const
{
return static_cast<int>(hqTfFd());
}
void SidcBuilder::setHqTfFd(const HQTFDummy &hqTfFd)
{
m_first10_mil2525D.replace(7, 1, QString::number((int)hqTfFd));
}
bool SidcBuilder::headquarters() const
{
bool headquarters;
bool taskForce;
bool feintDummy;
SidcDefinitions::HQTFDummyConverter::toBool(hqTfFd(), headquarters, taskForce, feintDummy);
return headquarters;
}
bool SidcBuilder::taskForce() const
{
bool headquarters;
bool taskForce;
bool feintDummy;
SidcDefinitions::HQTFDummyConverter::toBool(hqTfFd(), headquarters, taskForce, feintDummy);
return taskForce;
}
bool SidcBuilder::feintDummy() const
{
bool headquarters;
bool taskForce;
bool feintDummy;
SidcDefinitions::HQTFDummyConverter::toBool(hqTfFd(), headquarters, taskForce, feintDummy);
return feintDummy;
}
SidcDefinitions::AmplifierGroup SidcBuilder::amplifierGroup() const
{
AmplifierGroup amplifierGroup = static_cast<AmplifierGroup>(QStringRef(&m_first10_mil2525D, 8, 1).toInt());
return amplifierGroup;
}
void SidcBuilder::setAmplifierGroup(const AmplifierGroup &amplifierGroup)
{
m_first10_mil2525D.replace(8, 1, QString::number((int)amplifierGroup));
}
unsigned int SidcBuilder::amplifier2ndDigit() const
{
return QStringRef(&m_first10_mil2525D, 9, 1).toUInt();
} // unsigned int SidcBuilder::amplifier2ndDigit() const
void SidcBuilder::setAmplifier2ndDigit(unsigned int amplifierSecondDigit)
{
if (amplifierSecondDigit > 9) return; // ToDo error message
m_first10_mil2525D.replace(9, 1, QString::number(amplifierSecondDigit));
}
unsigned int SidcBuilder::sectorModifier1Digit()
{
return QStringRef(&m_second10_mil2525D, 6, 2).toUInt();
} // unsigned int SidcBuilder::sectorModifier1Digit()
unsigned int SidcBuilder::sectorModifier2Digit()
{
return QStringRef(&m_second10_mil2525D, 8, 2).toUInt();
} // unsigned int SidcBuilder::sectorModifier2Digit()
void SidcBuilder::setSectorModifier1Digit(unsigned int digit)
{
if (digit > 99) return; // ToDo error message
m_second10_mil2525D.replace(6, 2, QStringLiteral("%1").arg(digit, 2, 10, QLatin1Char('0')));
} // void SidcBuilder::setSectorModifier1Digit( unsigned int )
void SidcBuilder::setSectorModifier2Digit(unsigned int digit)
{
if (digit > 99) return; // ToDo error message
m_second10_mil2525D.replace(8, 2, QStringLiteral("%1").arg(digit, 2, 10, QLatin1Char('0')));
} // void SidcBuilder::setSectorModifier2Digit( unsigned int digit )
QString SidcBuilder::toRawSidc() const
{
if (!m_symbolDictionary)
return QString();
switch (m_symbolDictionary->symbologyType())
{
case SymbologyType::APP6B : return m_app6bRawSidc;
case SymbologyType::APP6D : return m_first10_mil2525D + m_second10_mil2525D;
case SymbologyType::MIL2525C : return QString();
case SymbologyType::MIL2525D : return m_first10_mil2525D + m_second10_mil2525D;
case SymbologyType::None : return QString();
}
return QString();
}
QString SidcBuilder::toSidc() const
{
if (!m_symbolDictionary)
return QString();
const QString &rawSidc = toRawSidc();
return (rawSidc.isEmpty()) ? QString() : SidcCodec::encodeComplete(m_symbolDictionary->symbologyType(), rawSidc);
} // QString SidcBuilder::toSidc() const
bool SidcBuilder::initFromSymbologyType(SymbologyType symbologyType, const QString &sidc)
{
QString rawSidc(sidc);
if (SidcCodec::isEncoded(sidc))
{
SymbologyType sidcSymbolType = SidcCodec::decodeSymbologyType(sidc);
SidcCodec::SidcType sidcType = SidcCodec::decodeSidcType(sidc);
rawSidc = SidcCodec::decodeRawSidc(sidc);
if (symbologyType != sidcSymbolType)
{
ERROR_LOG(m_logger) << LOGFUNCTION
<< " sidc='" << sidc << "'"
<< ", wrong symbology type";
return false;
}
if (SidcCodec::SidcType::Complete != sidcType)
{
ERROR_LOG(m_logger) << LOGFUNCTION
<< " sidcMIL2525D='" << sidc << "'"
<< ", wrong sidc type";
return false;
}
}
// check size
if (rawSidc.size() != 20)
{
ERROR_LOG(m_logger) << LOGFUNCTION
<< " sidc='" << sidc << "'"
<< ", size failed";
return false;
}
// check version
if (QStringRef(&rawSidc, 0, 2) != QLatin1String("10"))
{
ERROR_LOG(m_logger) << LOGFUNCTION
<< " sidc='" << sidc << "'"
<< ", wrong version";
return false;
}
init();
m_first10_mil2525D = rawSidc.mid( 0, 10);
m_second10_mil2525D = rawSidc.mid(10, 10);
DEBUG_LOG(m_logger) << LOGFUNCTION
<< " m_first10='" << m_first10_mil2525D << "'"
<< " m_second10='" << m_second10_mil2525D << "'";
return true;
}
bool SidcBuilder::initFromSymbologyTypeBaseSymbolCode(SymbologyType symbologyType, const QString &baseSymbolCode)
{
QString rawBaseSymbolCode(baseSymbolCode);
if (SidcCodec::isEncoded(baseSymbolCode))
{
if (SidcCodec::decodeSymbologyType(baseSymbolCode) != symbologyType)
{
ERROR_LOG(m_logger) << LOGFUNCTION
<< " sidc='" << baseSymbolCode << "'"
<< ", wrong symbology type";
return false;
}
if (SidcCodec::decodeSidcType(baseSymbolCode) != SidcCodec::SidcType::Base)
{
ERROR_LOG(m_logger) << LOGFUNCTION
<< " sidc='" << baseSymbolCode << "'"
<< ", wrong sidc type";
return false;
}
rawBaseSymbolCode = SidcCodec::decodeRawSidc(baseSymbolCode);
}
// check size
if (rawBaseSymbolCode.size() != 8)
{
ERROR_LOG(m_logger) << LOGFUNCTION
<< " baseSymbolCode='" << baseSymbolCode << "'"
<< ", size failed";
return false;
}
init();
// set SymbolSet:
SymbolSet sSet = static_cast<SymbolSet>(QStringRef(&rawBaseSymbolCode, 0, 2).toInt());
this->setSymbolSet(sSet);
// set Entity:
const QString &entityChars = rawBaseSymbolCode.mid(2, 6);
// merge into second10:
m_second10_mil2525D.replace(0, 6, entityChars);
return true;
} // bool SidcBuilder::initFromSymbologyTypeBaseSymbolCode(SymbologyType symbologyType, const QString &baseSymbolCode)
bool SidcBuilder::initFromMil2525D(const QString &sidcMil2525D)
{
return SidcBuilder::initFromSymbologyType(SymbologyType::MIL2525D,sidcMil2525D);
}
bool SidcBuilder::initFromMil2525DBaseSymbolCode(const QString &sidcMil2525D_baseSymbolCode)
{
return initFromSymbologyTypeBaseSymbolCode(SymbologyType::MIL2525D, sidcMil2525D_baseSymbolCode);
}
bool SidcBuilder::initFromApp6B(const QString &sidcApp6B)
{
m_app6bRawSidc = SidcCodec::decodeRawSidc(sidcApp6B);
return true;
}
bool SidcBuilder::initFromApp6BBaseSymbolCode(const QString &sidcApp6B_baseSymbolCode)
{
m_app6bRawSidc = SidcCodec::decodeRawSidc(baseSymbolCodeToSidc( sidcApp6B_baseSymbolCode ));
return false;
}
bool SidcBuilder::initFromApp6D(const QString &sidcAPP6D)
{
return SidcBuilder::initFromSymbologyType(SymbologyType::APP6D,sidcAPP6D);
}
bool SidcBuilder::initFromApp6DBaseSymbolCode(const QString &sidcAPP6D_baseSymbolCode)
{
return initFromSymbologyTypeBaseSymbolCode(SymbologyType::APP6D, sidcAPP6D_baseSymbolCode);
}
/*
private void _BuildSIDC()
{
// Builds a current (2525D) SIDC from the JMSML Library elements currently associated
// with this symbol.
if (_version != null && _context != null &&
_standardIdentity != null && _symbolSet != null && _status != null &&
_hqTFDummy != null && _amplifierGroup != null && _amplifier != null)
{
_sidc.PartAUInt = (uint)_version.VersionCode.DigitOne * 1000000000 +
(uint)_version.VersionCode.DigitTwo * 100000000 +
(uint)_context.ContextCode * 10000000 +
(uint)_standardIdentity.StandardIdentityCode * 1000000 +
(uint)_symbolSet.SymbolSetCode.DigitOne * 100000 +
(uint)_symbolSet.SymbolSetCode.DigitTwo * 10000 +
(uint)_status.StatusCode * 1000 +
(uint)_hqTFDummy.HQTFDummyCode * 100 +
(uint)_amplifierGroup.AmplifierGroupCode * 10 +
(uint)_amplifier.AmplifierCode;
}
if (_entity != null)
{
_sidc.PartBUInt = (uint)_entity.EntityCode.DigitOne * 1000000000 +
(uint)_entity.EntityCode.DigitTwo * 100000000;
}
if (_entityType != null)
{
_sidc.PartBUInt = _sidc.PartBUInt + (uint)_entityType.EntityTypeCode.DigitOne * 10000000 +
(uint)_entityType.EntityTypeCode.DigitTwo * 1000000;
}
if (_entitySubType != null)
{
_sidc.PartBUInt = _sidc.PartBUInt + (uint)_entitySubType.EntitySubTypeCode.DigitOne * 100000 +
(uint)_entitySubType.EntitySubTypeCode.DigitTwo * 10000;
}
if (_modifierOne != null)
{
_sidc.PartBUInt = _sidc.PartBUInt + (uint)_modifierOne.ModifierCode.DigitOne * 1000 +
(uint)_modifierOne.ModifierCode.DigitTwo * 100;
}
if (_modifierTwo != null)
{
_sidc.PartBUInt = _sidc.PartBUInt + (uint)_modifierTwo.ModifierCode.DigitOne * 10 +
(uint)_modifierTwo.ModifierCode.DigitTwo;
}
}
*/
} // namespace AdvancedSymbology
+198
View File
@@ -0,0 +1,198 @@
/**
* @RDE_HEADER@
* Class SidcBuilder
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "sidc_builder_base.h"
#include "sidc_codec.h"
#include "symbol_dictionary.h"
// Qt
#include <QString>
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
class ADVANCED_SYMBOLOGY_EXPORT SidcBuilder : SidcBuilderBase
{
public:
explicit SidcBuilder(AdvancedSymbology::SymbolDictionary *symbolDictionary = nullptr);
bool setSidc(const QString &sidc)
{
if (SidcCodec::isEncoded(sidc))
{
switch (SidcCodec::decodeSymbologyType(sidc))
{
case SymbologyType::APP6B : return initFromApp6B(sidc);
case SymbologyType::APP6D : return initFromApp6D(sidc);
case SymbologyType::MIL2525C : return false; // return initFromMil2525C(sidc);
case SymbologyType::MIL2525D : return initFromMil2525D(sidc);
case SymbologyType::None : return false;
}
}
else
{
if (m_symbolDictionary)
{
switch (m_symbolDictionary->symbologyType())
{
case SymbologyType::APP6B : return initFromApp6B(SidcCodec::encodeComplete(SymbologyType::APP6B, sidc));
case SymbologyType::APP6D : return initFromApp6D(SidcCodec::encodeComplete(SymbologyType::APP6D, sidc));
case SymbologyType::MIL2525C : return false; // return initFromMil2525C(sidc);
case SymbologyType::MIL2525D : return initFromMil2525D(SidcCodec::encodeComplete(SymbologyType::MIL2525D, sidc));
case SymbologyType::None : return false;
}
}
return initFromMil2525D(SidcCodec::encodeComplete(SymbologyType::MIL2525D, sidc));
}
return false;
} // setSidc
bool initFromSymbologyType(SymbologyType symbologyType, const QString &sidc);
bool initFromSymbologyTypeBaseSymbolCode(SymbologyType symbologyType, const QString &baseSymbolCode);
bool initFromMil2525D(const QString &sidcMil2525D);
bool initFromMil2525DBaseSymbolCode(const QString &sidcMil2525D_baseSymbolCode);
bool initFromApp6B(const QString &sidcApp6B);
bool initFromApp6BBaseSymbolCode(const QString &sidcApp6B_baseSymbolCode);
bool initFromApp6D(const QString &sidcAPP6D);
bool initFromApp6DBaseSymbolCode(const QString &sidcAPP6D_baseSymbolCode);
~SidcBuilder() = default;
QString toSidc() const;
QString toRawSidc() const;
// !!! Attention: digit count starts with 1, not with 0!!!
//
// Set A, digit 1,2
//
// Version
//
// Set A, digit 3,4
//
// StandardIdentity
SidcDefinitions::StandardIdentity standardIdentity() const; // 1st and 2nd
void setStandardIdentity(const SidcDefinitions::StandardIdentity &standardIdentity);
SidcDefinitions::Context context() const;
void setContext(SidcDefinitions::Context context);
SidcDefinitions::Identity identity() const;
void setIdentity(SidcDefinitions::Identity identity);
bool isIdentityAssumed() const;
//
// Set A, digit 5,6
//
// SymbolSet
SidcDefinitions::SymbolSet symbolSet() const;
void setSymbolSet(const SidcDefinitions::SymbolSet &symbolSet);
//
// Set A, digit 7
//
// Status
SidcDefinitions::Status status() const;
void setStatus(const SidcDefinitions::Status &status);
//
// Set A, digit 8
//
// HQTFDummy
SidcDefinitions::HQTFDummy hqTfFd() const;
uint hqTfFd_UInt() const;
void setHqTfFd(const SidcDefinitions::HQTFDummy &hqTfFd);
bool headquarters() const;
bool taskForce() const;
bool feintDummy() const;
//
// Set A, digit 9, 10
//
SidcDefinitions::AmplifierGroup amplifierGroup() const; // digit 9
void setAmplifierGroup(const SidcDefinitions::AmplifierGroup &amplifierGroup);
unsigned int amplifier2ndDigit() const; // digit 10
void setAmplifier2ndDigit(unsigned int amplifierSecondDigit);
//
// Set B, digit 11 - 16
//
QString symbolEntityCode() const;
void setSymbolEntityCode(const QString &);
unsigned int sectorModifier1Digit(); // Set B, digit 17 - 18
unsigned int sectorModifier2Digit(); // set B, digit 19 - 20
void setSectorModifier1Digit(unsigned int); // Set B, digit 17 - 18
void setSectorModifier2Digit(unsigned int); // set B, digit 19 - 20
private:
void init();
void initAmplifier();
QString m_first10_mil2525D;
QString m_second10_mil2525D;
QString m_app6bRawSidc;
//
// SET A :
//
// Amplifier (Echelon/Mobility/TowedArray)
SidcDefinitions::AmplifierGroup m_amplifierGroup;
SidcDefinitions::EchelonBrigadeAndBelow m_e_BrigadeAndBelow;
SidcDefinitions::EchelonDivisionAndAbove m_e_DivisionAndAbove;
SidcDefinitions::MobilityOnLand m_e_MobilityOnLand;
SidcDefinitions::MobilityOnSnow m_e_MobilityOnSnow;
SidcDefinitions::MobilityOnWater m_e_MobilityOnWater;
SidcDefinitions::NavalTowedArray m_e_NavalTowedArray;
//
// : SET A
//
//
// SET B :
//
// not implemented yes
//
// : SET B
//
static qint32 _smallest;
static qint32 _specialPartA;
static qint32 _invalidPartB;
static qint32 _retiredPartB;
};
} // namespace AdvancedSymbology
+195
View File
@@ -0,0 +1,195 @@
/**
* @RDE_HEADER@
* Class SidcBuilderBase
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "sidc_builder_base.h"
#include "sidc_codec.h"
// ESRI
// Qt
#include <QtCore/QDebug>
namespace AdvancedSymbology
{
SidcBuilderBase::SidcBuilderBase(SymbolDictionary *symbolDictionary, const char *loggerName)
: SidcDefinitions(symbolDictionary, loggerName)
{
}
QString SidcBuilderBase::baseSymbolCodeToSidc(const QString &baseSymbolCodeCodec)
{
if (!SidcCodec::isEncoded(baseSymbolCodeCodec))
{
qCritical() << LOGFUNCTION << " baseSymbolCodeCodec input parameter isn't encoded: " << baseSymbolCodeCodec;
return QString();
}
switch (SidcCodec::decodeSidcType(baseSymbolCodeCodec))
{
case SidcCodec::SidcType::CivilEts:
case SidcCodec::SidcType::CivilXml:
return baseSymbolCodeCodec;
case SidcCodec::SidcType::Base:
break;
default :
{
qCritical() << LOGFUNCTION << " baseSymbolCodeCodec is not a base symbol code: " << baseSymbolCodeCodec;
return QString();
}
} // switch
QString sidc;
QString baseSymbolCode = SidcCodec::decodeRawSidc(baseSymbolCodeCodec);
SymbologyType symbologyType = SidcCodec::decodeSymbologyType(baseSymbolCodeCodec);
if ((SymbologyType::MIL2525D == symbologyType) || (SymbologyType::APP6D == symbologyType))
{
//
// its MIL2525D or APP6D
//
if ((baseSymbolCode.size() != 8) && (baseSymbolCode.size() != 10))
{
return QString(); // failure !!
}
QRegExp sidcTemplate(QStringLiteral("^[0-9]{8}(_[0-9])?$"));
if (!sidcTemplate.exactMatch(baseSymbolCode))
{
return QString(); // Failure
}
// Version
sidc += QLatin1Char('1');
sidc += QLatin1Char('0');
// Standard Identity
sidc += QLatin1Char('0');
if (baseSymbolCode.size() == 10) sidc += baseSymbolCode[9];
else sidc += QLatin1Char('1');
// SymbolSet
sidc += baseSymbolCode[0];
sidc += baseSymbolCode[1];
// Status
sidc += QLatin1Char('0');
// HeadQuarter, TaskForce, Dummy
sidc += QLatin1Char('0');
// Amplifier/Descriptor
sidc += QLatin1Char('0');
sidc += QLatin1Char('0');
sidc += baseSymbolCode[2];
sidc += baseSymbolCode[3];
sidc += baseSymbolCode[4];
sidc += baseSymbolCode[5];
sidc += baseSymbolCode[6];
sidc += baseSymbolCode[7];
sidc = sidc.leftJustified(20, QLatin1Char('0'));
return SidcCodec::encodeComplete(symbologyType, sidc);
}
if (SymbologyType::APP6B == symbologyType)
{
sidc = baseSymbolCode;
sidc[1] = QLatin1Char('U');
sidc[3] = QLatin1Char('P');
return SidcCodec::encodeComplete(symbologyType, sidc);
}
return QString();
} // QString SidcBuilderBase::baseSymbolCodeToSidc(const QString &baseSymbolCodeCodec)
QString SidcBuilderBase::concreteSidcToBaseSymbolCode(const QString &sidcCodec)
{
if (!SidcCodec::isEncoded(sidcCodec))
{
qCritical() << LOGFUNCTION << " sidcCodec is not a complete sidc: " << sidcCodec;
return QString();
}
switch (SidcCodec::decodeSidcType(sidcCodec))
{
case SidcCodec::SidcType::CivilEts:
case SidcCodec::SidcType::CivilXml:
return sidcCodec;
break;
case SidcCodec::SidcType::Complete:
break;
default :
{
qCritical() << LOGFUNCTION << " sidcCodec is not a complete sidc: " << sidcCodec;
return QString();
}
} // switch
const QString &rawSidc = SidcCodec::decodeRawSidc(sidcCodec);
SymbologyType symbologyType = SidcCodec::decodeSymbologyType(sidcCodec);
switch (symbologyType)
{
case SymbologyType::APP6B :
{
const QString & baseSymbolCode = normalizeAPP6BaseSymbolCode(rawSidc);
return SidcCodec::encodeBaseSymbolCode(symbologyType, baseSymbolCode);
}
case SymbologyType::MIL2525C : return QString();
case SymbologyType::APP6D : // it's same as MIL2525D
case SymbologyType::MIL2525D :
{
if (rawSidc.count() != 20)
return QString();
QString baseSymbolCode(
QStringRef(&rawSidc, 4, 2).toString() +
QStringRef(&rawSidc, 10, 6).toString());
return SidcCodec::encodeBaseSymbolCode(symbologyType, baseSymbolCode);
} break;
case SymbologyType::None: return QString();
}
return QString();
} // QString SidcBuilderBase::concreteSidcToBaseSymbolCode(const QString &sidcCodec)
QString SidcBuilderBase::normalizeAPP6BaseSymbolCode(const QString & baseSymbolCode)
{
QString baseNorm = baseSymbolCode;
baseNorm.resize(15, QLatin1Char('*'));
baseNorm[1] = QLatin1Char('*');
baseNorm[3] = QLatin1Char('*');
if (QLatin1Char('*') != baseNorm[10]) baseNorm[10] = QLatin1Char('-');
if (QLatin1Char('*') != baseNorm[11]) baseNorm[11] = QLatin1Char('-');
if (QLatin1Char('*') != baseNorm[14]) baseNorm[14] = QLatin1Char('-');
return baseNorm;
} // QString SidcBuilderBase::normalizeAPP6BaseSymbolCode(const QString & baseSymbolCode)
} // namespace AdvancedSymbology
+65
View File
@@ -0,0 +1,65 @@
/**
* @RDE_HEADER@
* Class SidcBuilderBase
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbol_dictionary_types.h"
#include "sidc_definitions.h"
// Qt
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
// forward:
class ADVANCED_SYMBOLOGY_EXPORT SidcBuilderBase : public SidcDefinitions
{
public:
/*! \name Construction, Destruction */
//@{
///< Constructor
explicit SidcBuilderBase(AdvancedSymbology::SymbolDictionary *symbolDictionary, const char *loggerName);
///< Destructor
virtual ~SidcBuilderBase() = default;
//@}
/*! \name Convert */
//@{
/**
* @brief baseSymbolCodeToSidc
* @param baseSymbolCode ????????? -> Joerg TODO!!!
* @param identity
* @return
*/
static QString baseSymbolCodeToSidc(const QString &baseSymbolCodeCodec); // 25270100 --> 20 digit code
/**
* @brief concreteSidcToBaseSymbolCode
* @param sidc sidc to convert.
* @return if MIL: 20 digit code -> 8 digits like 25270100, if civil: return identical sidc.
*/
static QString concreteSidcToBaseSymbolCode(const QString &sidcCodec);
//@}
static QString normalizeAPP6BaseSymbolCode(const QString & baseSymbolCode);
}; // class SidcBuilderBase
} // namespace AdvancedSymbology
+221
View File
@@ -0,0 +1,221 @@
/**
* @RDE_HEADER@
* SidcCodec for internal handling of SIDCs
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "sidc_codec.h" // enbles highlighting and is harmless since 'pragma once'
#include "sidc_definitions.h"
#include <SymbologyXML/xml_symbol_codec.h>
// Qt
#include <QRegExp>
namespace AdvancedSymbology
{
//
// SidcCodecHelper
//
namespace SidcCodecHelper
{
QString encode(SymbologyType symbologyType)
{
switch (symbologyType)
{
case SymbologyType::None: return QStringLiteral("NONE"); break;
case SymbologyType::APP6B: return QStringLiteral("AP6B"); break;
case SymbologyType::APP6D: return QStringLiteral("AP6D"); break;
case SymbologyType::MIL2525C: return QStringLiteral("M25C"); break;
case SymbologyType::MIL2525D: return QStringLiteral("M25D"); break;
};
return QLatin1String("EROR");
}
SymbologyType decodeSymbology(const QStringRef &symbologyTypeStr)
{
SymbologyType symbologyType = SymbologyType::None;
if (symbologyTypeStr.compare(QLatin1String("NONE")) == 0) symbologyType = SymbologyType::None;
else if (symbologyTypeStr.compare(QLatin1String("AP6B")) == 0) symbologyType = SymbologyType::APP6B;
else if (symbologyTypeStr.compare(QLatin1String("AP6D")) == 0) symbologyType = SymbologyType::APP6D;
else if (symbologyTypeStr.compare(QLatin1String("M25C")) == 0) symbologyType = SymbologyType::MIL2525C;
else if (symbologyTypeStr.compare(QLatin1String("M25D")) == 0) symbologyType = SymbologyType::MIL2525D;
return symbologyType;
}
QString encode(SidcCodec::SidcType sidcType)
{
switch (sidcType)
{
case SidcCodec::SidcType::None: return QStringLiteral("NONE"); break;
case SidcCodec::SidcType::Base: return QStringLiteral("BASE"); break;
case SidcCodec::SidcType::Complete: return QStringLiteral("CMPL"); break;
case SidcCodec::SidcType::CivilEts: return QStringLiteral("CVLE"); break;
case SidcCodec::SidcType::CivilXml: return QStringLiteral("CVLX"); break;
}
return QLatin1String("EROR");
}
SidcCodec::SidcType decodeSidc(const QStringRef &sidcTypeStr)
{
SidcCodec::SidcType symbologyType = SidcCodec::SidcType::None;
if ( sidcTypeStr.compare(QLatin1String("NONE")) == 0) symbologyType = SidcCodec::SidcType::None;
else if (sidcTypeStr.compare(QLatin1String("BASE")) == 0) symbologyType = SidcCodec::SidcType::Base;
else if (sidcTypeStr.compare(QLatin1String("CMPL")) == 0) symbologyType = SidcCodec::SidcType::Complete;
else if (sidcTypeStr.compare(QLatin1String("CVLE")) == 0) symbologyType = SidcCodec::SidcType::CivilEts;
else if (sidcTypeStr.compare(QLatin1String("CVLX")) == 0) symbologyType = SidcCodec::SidcType::CivilXml;
return symbologyType;
}
} // SidcCodecHelper
unsigned int SidcCodec::rawSidcOffset() { return 10; }
//
// isEncoded
//
bool SidcCodec::isEncoded(const QString &encodedSidc)
{
const QChar separator(QLatin1Char('|'));
return ((encodedSidc.size() > 9) && (encodedSidc.at(4) == separator) && (encodedSidc.at(9) == separator));
}
bool SidcCodec::checkSidcSyntax(const QString &encodedSidc)
{
if (!isEncoded(encodedSidc)) return false;
SidcCodec::SidcType sidcType = SidcCodecHelper::decodeSidc(QStringRef(&encodedSidc, 5, 4));
const QStringRef symbologyTypeStr(&encodedSidc, 0, 4);
if (symbologyTypeStr.compare(QLatin1String("NONE")) == 0) return true;
else if (symbologyTypeStr.compare(QLatin1String("AP6B")) == 0) return true;
else if (symbologyTypeStr.compare(QLatin1String("AP6D")) == 0) return true;
else if (symbologyTypeStr.compare(QLatin1String("M25C")) == 0) return true;
else if ((symbologyTypeStr.compare(QLatin1String("M25D")) == 0) || (symbologyTypeStr.compare(QLatin1String("AP6D")) == 0))
{
const QString &rawSidcStr(encodedSidc.mid(10));
QRegExp isDigit(QStringLiteral("^[0..9]*$"));
if (isDigit.exactMatch(rawSidcStr))
{
switch (sidcType)
{
case SidcCodec::SidcType::Base : return (rawSidcStr.size() == 8); break;
case SidcCodec::SidcType::Complete : return (rawSidcStr.size() == 20); break;
default: break;
}
}
}
return false;
}
bool SidcCodec::isCivil(const QString &encodedSidc)
{
SidcCodec::SidcType sidcType = SidcCodec::decodeSidcType(encodedSidc);
return ((sidcType == SidcCodec::SidcType::CivilEts) || (sidcType == SidcCodec::SidcType::CivilXml));
}
//
// ENCODE
//
QString SidcCodec::encodeBaseSymbolCode(SymbologyType symbologyType, const QString &baseSymboCodeSidc)
{
return QStringLiteral("%1|BASE|%3").arg(SidcCodecHelper::encode(symbologyType), baseSymboCodeSidc);
}
QString SidcCodec::encodeComplete(SymbologyType symbologyType, const QString &completeSidc)
{
return QStringLiteral("%1|CMPL|%3").arg(SidcCodecHelper::encode(symbologyType), completeSidc);
}
QString SidcCodec::encodeCivilEts(const QString &civilSidc)
{
return QStringLiteral("NONE|CVLE|%1").arg(civilSidc);
}
QString SidcCodec::encodeCivilXml(const QString &civilSidc)
{
return QStringLiteral("NONE|CVLX|%1").arg(civilSidc);
}
int SidcCodec::decodeCivilXml(const QString &civilSidc)
{
return decodeRawSidc(civilSidc).toInt();
}
//
// DECODE
//
// QStringRef(const QString *string, int position, int size);
// QString mid(int position, int n = -1) const Q_REQUIRED_RESULT;
//
SymbologyType SidcCodec::decodeSymbologyType(const QString &encodedSidc)
{
return SidcCodecHelper::decodeSymbology(QStringRef(&encodedSidc, 0, 4));
}
SidcCodec::SidcType SidcCodec::decodeSidcType(const QString &encodedSidc)
{
return SidcCodecHelper::decodeSidc(QStringRef(&encodedSidc, 5, 4));
}
QString SidcCodec::decodeRawSidc(const QString &encodedSidc)
{
return (isEncoded(encodedSidc)) ? encodedSidc.mid(rawSidcOffset()) : encodedSidc;
}
QString SidcCodec::encodeCivilXmlSymbolId( uint symbolId )
{
const QString &rawSidc = QString::number(symbolId);
return encodeCivilXml(rawSidc);
} // QString SidcCodec::encodeCivilXmlSymbolId( uint symbolId )
QString SidcCodec::encodeCivilXmlSymbolId( uint symbolId
, SymbologyXML::SymbolTypes::t_state state
, SymbologyXML::SymbolTypes::t_uncertainty uncertainty
, SymbologyXML::SymbolTypes::t_affil affil
, SymbologyXML::SymbolTypes::t_mob mob )
{
const QString &rawSidc = SymbologyXML::xmlSymbolEncodeId(symbolId,state,uncertainty,affil,mob);
return encodeCivilXml(rawSidc);
} // QString SidcCodec::encodeCivilXmlSymbolId(...)
QString SidcCodec::extractCivilXmlBaseSidc( const QString &sidc )
{
return SymbologyXML::xmlSymbolExtractBaseSidc(sidc);
} // QString SidcCodec::extractCivilXmlBaseSidc( const QString &sidc )
//
// Some convenience functions
QString SidcCodec::encodeBaseSymbolCode(SymbologyType symbologyType, const QStringRef &baseSymboCodeSidc) { return encodeBaseSymbolCode(symbologyType, *baseSymboCodeSidc.string()); }
QString SidcCodec::encodeBaseSymbolCode(SymbologyType symbologyType, const std::string &baseSymboCodeSidc) { return encodeBaseSymbolCode(symbologyType, QString::fromStdString(baseSymboCodeSidc));}
QString SidcCodec::encodeBaseSymbolCode(SymbologyType symbologyType, const char *baseSymboCodeSidc) { return encodeBaseSymbolCode(symbologyType, QString::fromLatin1(baseSymboCodeSidc));}
QString SidcCodec::encodeComplete(SymbologyType symbologyType, const QStringRef &completeSidc) { return encodeComplete(symbologyType, *completeSidc.string());}
QString SidcCodec::encodeComplete(SymbologyType symbologyType, const std::string &completeSidc) { return encodeComplete(symbologyType, QString::fromStdString(completeSidc)); }
QString SidcCodec::encodeComplete(SymbologyType symbologyType, const char *completeSidc) { return encodeComplete(symbologyType, QString::fromLatin1(completeSidc)); }
QString SidcCodec::encodeCivilEts(const QStringRef &civilSidc) { return encodeCivilEts(*civilSidc.string());}
QString SidcCodec::encodeCivilEts(const std::string &civilSidc) { return encodeCivilEts(QString::fromStdString(civilSidc)); }
QString SidcCodec::encodeCivilEts(const char *civilSidc) { return encodeCivilEts(QString::fromLatin1(civilSidc)); }
QString SidcCodec::encodeCivilXml(const QStringRef &civilSidc) { return encodeCivilXml(*civilSidc.string());}
QString SidcCodec::encodeCivilXml(const std::string &civilSidc) { return encodeCivilXml(QString::fromStdString(civilSidc)); }
QString SidcCodec::encodeCivilXml(const char *civilSidc) { return encodeCivilXml(QString::fromLatin1(civilSidc)); }
} // namespace AdvancedSymbology
+222
View File
@@ -0,0 +1,222 @@
/**
* @RDE_HEADER@
* SidcCodec for internal handling of SIDCs
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "symbology_type.h"
#include "advanced_symbology_export.h"
#include <SymbologyXML/symbol_types.h>
// Qt
#include <QHash>
#include <QString>
#include <QStringRef>
namespace AdvancedSymbology
{
/**
* \brief The SidcCodec namespace enables the encoding and decoding of a (raw) sidc (SymbolIdCode)
* The BaseSymbolCode describes the base symbol, the *Typ* like 'soldier', 'tank'
* WITHOUT the affiliation (membership to a party) and so on.
* Only the complete SIDC (WITH affiliation and so on) describes a concrete instanciation,
* examples:
*
* - APP6D / MIL2525D
* + M25D|BASE|25271300 - abstract/Typ (Context "template": assign symbol)
* + M25D|CMPL|10012500002713000000 - concrete (message from Training Area)
*
* - APP6C / MIL2525C
* Here a abstract (Base) and concrete (Complete) are existing also:
* M25C|BASE|S*A*MFUM--*****
* M25C|CMPL|SNAAMFUM--AL***
* - Extra / Civil / ETS / XML:
* NONE|CIVE|PlanStelle
* NONE|CIVX|<Dateiname alter XML-basierter SymbolEditor>
* @note This namespace uses a QString (and not QLatin1String) since maybe a chinese operator create a symbol and uses a name in his first language.
*/
namespace SidcCodec
{
/**
* Type of SIDC code or symbol
*/
enum class SidcType
{
None, ///< NONE
Base, ///< base symbol without frame, modifier or amplifier coded as "BASE"
Complete, ///< concrete symbol with complete definition coded as "CMPL"
CivilEts, ///< Civil Ets coded as "CVLE"
CivilXml ///< Civil XML coded as "CVLX"
};
/**
* Check if sidc string is encoded.
* @param encodedSidc sidc string to check
* @return Returns true if encoded, otherwise false.
*/
ADVANCED_SYMBOLOGY_EXPORT bool isEncoded(const QString &encodedSidc);
/**
* Check if sidc syntax is correct.
* @param encodedSidc sidc string to check
* @return Returns true if syntax is correct, otherwise false.
*/
ADVANCED_SYMBOLOGY_EXPORT bool checkSidcSyntax(const QString &encodedSidc);
/**
* Check an encode sidc string if it's a civil symbol.
* @param encodedSidc Encoded sidc string
* @return Return value is true in case of civil symbols, otherwise false
*/
ADVANCED_SYMBOLOGY_EXPORT bool isCivil(const QString &encodedSidc);
/**
* Check an encode sidc string if the syntax is correctly.
* @param encodedSidc Encoded sidc string
* @return Return value is true if \c encodeSidc builded correctly. In case of wrong syntax the return value is false.
*/
ADVANCED_SYMBOLOGY_EXPORT bool checkSidcSyntax(const QString &encodedSidc);
ADVANCED_SYMBOLOGY_EXPORT unsigned int rawSidcOffset();
/**
* Functions to encode and decode a SIDC from or to raw string codes. These functions are really simple and
* can not convert between SidcType::Base and SidcType::Complete. This purposes are handled by class \c SidcBuilder.
* @see SidcBuilder
* @{
*/
ADVANCED_SYMBOLOGY_EXPORT QString encodeBaseSymbolCode(SymbologyType symbologyType, const QString &baseSymboCodeSidc); /**< Encode base symbol. Example: M25D|BASE|25271300 */
ADVANCED_SYMBOLOGY_EXPORT QString encodeComplete(SymbologyType symbologyType, const QString &completeSidc); /**< Encode comlete symbol. Example: M25D|CMPL|10012500002713000000 */
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilEts(const QString &civilSidc); /**< Encode ETS civil symbol. Example: NONE|CVLE|PlanStelle */
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilXml(const QString &civilSidc); /**< Encode XML civil symbol. Example: NONE|CVLX|PlanStelle */
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilXmlSymbolId( uint symbolId );
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilXmlSymbolId( uint symbolId
, SymbologyXML::SymbolTypes::t_state state
, SymbologyXML::SymbolTypes::t_uncertainty uncertainty
, SymbologyXML::SymbolTypes::t_affil affil
, SymbologyXML::SymbolTypes::t_mob mob );
ADVANCED_SYMBOLOGY_EXPORT QString extractCivilXmlBaseSidc( const QString &sidc );
ADVANCED_SYMBOLOGY_EXPORT SymbologyType decodeSymbologyType(const QString &encodedSidc); /**< Decode symbology type */
ADVANCED_SYMBOLOGY_EXPORT SidcType decodeSidcType(const QString &encodedSidc); /**< Decode sidc type */
ADVANCED_SYMBOLOGY_EXPORT QString decodeRawSidc(const QString &encodedSidc); /**< Decode raw sidc */
ADVANCED_SYMBOLOGY_EXPORT int decodeCivilXml(const QString &civilSidc);
/** @} */
/**
* Some convience functions ...
* @{
*/
ADVANCED_SYMBOLOGY_EXPORT QString encodeBaseSymbolCode(SymbologyType symbologyType, const QStringRef &baseSymboCodeSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeComplete(SymbologyType symbologyType, const QStringRef &completeSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilEts(const QStringRef &civilSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilXml(const QStringRef &civilSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeBaseSymbolCode(SymbologyType symbologyType, const std::string &baseSymboCodeSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeComplete(SymbologyType symbologyType, const std::string &completeSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilEts(const std::string &civilSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilXml(const std::string &civilSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeBaseSymbolCode(SymbologyType symbologyType, const char *baseSymboCodeSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeComplete(SymbologyType symbologyType, const char *completeSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilEts(const char *civilSidc);
ADVANCED_SYMBOLOGY_EXPORT QString encodeCivilXml(const char *civilSidc);
/** @} */
/**
* @brief Helper class to store information appropriate to a sidc.
* In symbol dictionary symbols are stored with a key to get access to complete set of symbol's data. This key is
* equal with base or complete symbol code. The class \c SidcHashTable stores information appropriate to a sidc
* in a QHashTable. The hash tabke index here is the encoded sidc.
*/
template<class Storage> class SidcHashTable
{
QHash<QString, Storage> m_hashTable;
SymbologyType m_symbologyType = SymbologyType::None;
SidcType m_sidcType = SidcType::None;
QString buildSidc(const QString &key) const
{
if (isEncoded(key)) return key;
switch (m_sidcType)
{
case SidcType::Base : return SidcCodec::encodeBaseSymbolCode(m_symbologyType, key);
case SidcType::Complete : return SidcCodec::encodeComplete(m_symbologyType, key);
case SidcType::CivilEts : return SidcCodec::encodeCivilEts(key);
case SidcType::CivilXml : return SidcCodec::encodeCivilXml(key);
case SidcType::None :
default : break;
}
return QString();
} // QString buildSidc(const QString & key) const
public:
SidcHashTable() = default;
explicit SidcHashTable(SymbologyType symbologyType) : m_symbologyType(symbologyType) {}
explicit SidcHashTable(SymbologyType symbologyType, SidcType sidcType) : m_symbologyType(symbologyType), m_sidcType(sidcType) {}
SymbologyType symbologyType() const { return m_symbologyType; }
SidcType sidcType() const { return m_sidcType; }
void clear() { m_hashTable.clear(); }
bool empty() const { return m_hashTable.empty(); }
int count() const { return m_hashTable.count(); }
int size() const { return m_hashTable.size(); }
QStringList keys() const { return m_hashTable.keys(); }
bool contains(const QString &key) const { return m_hashTable.contains(buildSidc(key)); }
bool containsSidc(const QString &sidc) const
{
if (decodeSymbologyType(sidc) == m_symbologyType)
{
if (decodeSidcType(sidc) == m_sidcType) return m_hashTable.contains(sidc);
}
return false;
} // bool containSidc( const QString & sidc ) const
typename QHash<QString, Storage>::iterator find(const QString &key) { return m_hashTable.find(buildSidc(key)); }
typename QHash<QString, Storage>::iterator begin() { return m_hashTable.begin(); }
typename QHash<QString, Storage>::iterator end() { return m_hashTable.end(); }
typename QHash<QString, Storage>::const_iterator find(const QString &key) const { return m_hashTable.find(buildSidc(key)); }
typename QHash<QString, Storage>::const_iterator begin() const { return m_hashTable.begin(); }
typename QHash<QString, Storage>::const_iterator end() const { return m_hashTable.end(); }
Storage &operator[](const QString &key) { return m_hashTable[buildSidc(key)]; }
Storage operator[](const QString &key) const { return m_hashTable[buildSidc(key)]; }
void remove(const QString &sidc)
{
isEncoded(sidc) ? m_hashTable.remove(sidc) : m_hashTable.remove(buildSidc(sidc));
} // void remove(const QString & sidc)
}; // SidcHashTable
} // namespace SidcCodec
} // namespace AdvancedSymbology
// #include "sidc_codec.inl"
+805
View File
@@ -0,0 +1,805 @@
/**
* @RDE_HEADER@
* Class SidcDefinitions
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "sidc_definitions.h"
#include <SymbologyImpl/symbol_dictionary_impl.h>
#ifdef XML_SYMBOL_ICONS
#include <SymbologyXML/symbol.h>
#include <SymbologyXML/symbol_reader.h>
#include <SymbologyXML/symbol_exporter.h>
#endif
#include <QtCore/QFile>
#include <QtGui/QPainter>
#include <QtGui/QPixmap>
#include <QtWidgets/QGraphicsScene>
//
//#include <sstream>
namespace AdvancedSymbology
{
SidcDefinitions::SidcDefinitions(SymbolDictionary *symbolDictionary, const char *loggerName)
: m_symbolDictionary(symbolDictionary)
, m_logger(getLogger(loggerName))
{
if (m_symbolDictionary)
{
if (m_symbolDictionary->isLoaded())
{
SymbolDictionaryImpl *symDicImpl = static_cast<SymbolDictionaryImpl *>(m_symbolDictionary);
m_esriDictProcessor = symDicImpl->getEsriDictionaryProcessor();
}
else
ERROR_LOG(m_logger) << LOGFUNCTION << " symbolDictionary not loaded";
}
else
ERROR_LOG(m_logger) << LOGFUNCTION << " no symbolDictionary";
}
QLatin1String SidcDefinitions::toString(ShapeType value)
{
switch (value)
{
case ShapeType::Undefined:
return QLatin1String("Undefined");
case ShapeType::Circle:
return QLatin1String("Circle");
case ShapeType::Clover:
return QLatin1String("Clover");
case ShapeType::Curve:
return QLatin1String("Curve");
case ShapeType::Diamond:
return QLatin1String("Diamond");
case ShapeType::Rectangle:
return QLatin1String("Rectangle");
case ShapeType::Square:
return QLatin1String("Square");
}
return QLatin1String("ERROR-ShapeType");
}
QLatin1String SidcDefinitions::toString(Context value)
{
switch (value)
{
case Context::Reality:
return QLatin1String("Reality");
case Context::Exercise:
return QLatin1String("Exercise");
case Context::Simulation:
return QLatin1String("Simulation");
}
return QLatin1String("ERROR-Context");
}
QPixmap SidcDefinitions::toPixmap(Context value)
{
Q_UNUSED(value)
return QPixmap();
}
QLatin1String SidcDefinitions::toString(Identity value)
{
switch (value)
{
case Identity::Pending:
return QLatin1String("Pending");
case Identity::Unknown:
return QLatin1String("Unknown");
case Identity::AssumedFriend:
return QLatin1String("AssumedFriend");
case Identity::Friend:
return QLatin1String("Friend");
case Identity::Neutral:
return QLatin1String("Neutral");
case Identity::SuspectJoker:
return QLatin1String("SuspectJoker");
case Identity::HostileFaker:
return QLatin1String("HostileFaker");
} // switch
return QLatin1String("ERROR-Identity");
}
QPixmap SidcDefinitions::toPixmap(Identity value)
{
Q_UNUSED(value);
return QPixmap(); // render XML symbol frame not activated yet
#ifdef XML_SYMBOL_ICONS
QGraphicsScene scene;
QString frameXml;
QString frameResource;
SymbologyXML::Symbol symbol;
SymbologyXML::SymbolReader symbolReader;
QColor fillColor;
SymbologyXML::SymbolTypes::t_affil affil;
static QMap<Identity,QImage*> frameImageMap;
if (frameImageMap[value]) return QPixmap::fromImage(*frameImageMap[value]);
scene.setSceneRect( QRectF(-2.0, -2.0, 4.0, 4.0) );
switch (value)
{
case Identity::Pending :
{
affil = SymbologyXML::SymbolTypes::t_affil::PENDING;
fillColor = QColor(QStringLiteral("yellow"));
frameResource = QStringLiteral(":/Symbole/Attributes/symbolframes/frame_landunits_unknown.xml");
} break;
case Identity::Unknown :
{
affil = SymbologyXML::SymbolTypes::t_affil::UNKNOWN;
fillColor = QColor(QStringLiteral("yellow"));
frameResource = QStringLiteral(":/Symbole/Attributes/symbolframes/frame_landunits_unknown.xml");
} break;
case Identity::AssumedFriend :
{
affil = SymbologyXML::SymbolTypes::t_affil::ASSUMED_FRIEND;
fillColor = QColor(QStringLiteral("light blue"));
frameResource = QStringLiteral(":/Symbole/Attributes/symbolframes/frame_landunits_friend.xml");
} break;
case Identity::Friend :
{
affil = SymbologyXML::SymbolTypes::t_affil::FRIEND;
fillColor = QColor(QStringLiteral("light blue"));
frameResource = QStringLiteral(":/Symbole/Attributes/symbolframes/frame_landunits_friend.xml");
} break;
case Identity::Neutral :
{
affil = SymbologyXML::SymbolTypes::t_affil::NEUTRAL;
fillColor = QColor(QStringLiteral("darkseagreen"));
frameResource = QStringLiteral(":/Symbole/Attributes/symbolframes/frame_landunits_neutral.xml");
} break;
case Identity::SuspectJoker :
{
affil = SymbologyXML::SymbolTypes::t_affil::SUSPECT;
fillColor = QColor(QStringLiteral("orange"));
frameResource = QStringLiteral(":/Symbole/Attributes/symbolframes/frame_landunits_enemy.xml");
} break;
case Identity::HostileFaker :
{
affil = SymbologyXML::SymbolTypes::t_affil::ENEMY;
fillColor = QColor(QStringLiteral("red"));
frameResource = QStringLiteral(":/Symbole/Attributes/symbolframes/frame_landunits_enemy.xml");
} break;
} //switch
if (frameResource.isEmpty()) return QPixmap();
QFile fileXml(frameResource);
if (!fileXml.exists()) return QPixmap();
if (!fileXml.open(QIODevice::ReadOnly | QIODevice::Text)) return QPixmap();
frameXml = QString::fromLocal8Bit( fileXml.readAll() );
fileXml.close();
if (frameXml.isEmpty()) return QPixmap();
if (!symbolReader.read(frameXml,symbol)) return QPixmap();
symbol.setAffil(affil);
symbol.setDimen(SymbologyXML::SymbolTypes::t_dimen::LAND_UNITS);
symbol.setHeadquarter(false);
QImage *frameImage = new QImage(40,40,QImage::Format::Format_ARGB32);
QPainter painter(frameImage);
painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
frameImage->fill(QColor(255,255,255,0));
SymbologyXML::SymbolTypes::AdditionalSymbolData options;
options.m_filltype = SymbologyXML::SymbolTypes::FILLTYPE_FILLED;
SymbologyXML::SymbolExporter::drawFrameSymbol( symbol, options, &scene, QColor(0,0,0,255), fillColor, 0.0, true);
scene.render(&painter);
frameImageMap[value] = frameImage;
return QPixmap::fromImage(*frameImage);
#endif
}
SidcDefinitions::ShapeType SidcDefinitions::StandardIdentity::getShape() const
{
switch (identity)
{
case Identity::Unknown:
case Identity::Pending:
return ShapeType::Clover;
case Identity::Friend:
case Identity::AssumedFriend:
return ShapeType::Rectangle;
case Identity::Neutral:
return ShapeType::Square;
case Identity::HostileFaker:
case Identity::SuspectJoker:
return ShapeType::Diamond;
} // switch
return ShapeType::Undefined;
}
QVector<SidcDefinitions::Context> SidcDefinitions::contexts()
{
return { Context::Reality, Context::Exercise, Context::Simulation };
}
QVector<SidcDefinitions::Identity> SidcDefinitions::identities()
{
return {Identity::Pending,
Identity::Unknown,
Identity::AssumedFriend,
Identity::Friend,
Identity::Neutral,
Identity::SuspectJoker,
Identity::HostileFaker};
}
QLatin1String SidcDefinitions::toString(HQTFDummy value)
{
switch (value)
{
case HQTFDummy::Unknown:
return QLatin1String("Unknown");
case HQTFDummy::FeintDummy:
return QLatin1String("FeintDummy");
case HQTFDummy::Headquarters:
return QLatin1String("Headquarters");
case HQTFDummy::FeintDummy_Headquarters:
return QLatin1String("FeintDummy_Headquarters");
case HQTFDummy::TaskForce:
return QLatin1String("TaskForce");
case HQTFDummy::FeintDummy_TaskForce:
return QLatin1String("FeintDummy_TaskForce");
case HQTFDummy::TaskForce_Headquarters:
return QLatin1String("TaskForce_Headquarters");
case HQTFDummy::FeintDummy_TaskForce_Headquarters:
return QLatin1String("FeintDummy_TaskForce_Headquarters");
} // switch
return QLatin1String("ERROR-HQTFDummy");
}
QPixmap SidcDefinitions::toPixmap(HQTFDummy value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::HQTFDummy> SidcDefinitions::hQTFDummy()
{
return {HQTFDummy::Unknown,
HQTFDummy::FeintDummy,
HQTFDummy::Headquarters,
HQTFDummy::FeintDummy_Headquarters,
HQTFDummy::TaskForce,
HQTFDummy::FeintDummy_TaskForce,
HQTFDummy::TaskForce_Headquarters,
HQTFDummy::FeintDummy_TaskForce_Headquarters
};
}
void SidcDefinitions::HQTFDummyConverter::toBool(const SidcDefinitions::HQTFDummy &hqTfDummy, bool &headquarters, bool &taskForce, bool &feintDummy)
{
uint asInt = static_cast<uint>(hqTfDummy);
headquarters = asInt & 2; // mask
taskForce = asInt & 4; // mask
feintDummy = asInt & 1; // mask
}
uint SidcDefinitions::HQTFDummyConverter::toHqTfDummyAsInt(bool headquarters, bool taskForce, bool feintDummy)
{
uint hdtffd = 0;
if (headquarters) hdtffd += 2;
if (taskForce) hdtffd += 4;
if (feintDummy) ++hdtffd;
return hdtffd;
}
SidcDefinitions::HQTFDummy SidcDefinitions::HQTFDummyConverter::toHqTfDummy(bool headquarters, bool taskForce, bool feintDummy)
{
return static_cast<HQTFDummy>(toHqTfDummyAsInt(headquarters,
taskForce,
feintDummy));
}
QLatin1String SidcDefinitions::toString(AmplifierGroup value)
{
switch (value)
{
case AmplifierGroup::Unknown:
return QLatin1String("Unknown");
case AmplifierGroup::Echelon_BrigadeAndBelow:
return QLatin1String("Echelon_BrigadeAndBelow");
case AmplifierGroup::Echelon_DivisionAndAbove:
return QLatin1String("Echelon_DivisionAndAbove");
case AmplifierGroup::Mobility_OnLand:
return QLatin1String("Mobility_OnLand");
case AmplifierGroup::Mobility_OnSnow:
return QLatin1String("Mobility_OnSnow");
case AmplifierGroup::Mobility_OnWater:
return QLatin1String("Mobility_OnWater");
case AmplifierGroup::Naval_TowedArry:
return QLatin1String("Naval_TowedArry");
} // switch
return QLatin1String("ERROR-AmplifierGroup");
}
QPixmap SidcDefinitions::toPixmap(AmplifierGroup value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::AmplifierGroup> SidcDefinitions::amplifierGroups()
{
return { AmplifierGroup::Unknown,
AmplifierGroup::Echelon_BrigadeAndBelow,
AmplifierGroup::Echelon_DivisionAndAbove,
AmplifierGroup::Mobility_OnLand,
AmplifierGroup::Mobility_OnSnow,
AmplifierGroup::Mobility_OnWater,
AmplifierGroup::Naval_TowedArry
};
}
QLatin1String SidcDefinitions::toString(EchelonBrigadeAndBelow value)
{
switch (value)
{
case EchelonBrigadeAndBelow::Unknown:
return QLatin1String("Unknown");
case EchelonBrigadeAndBelow::TeamCrew:
return QLatin1String("TeamCrew");
case EchelonBrigadeAndBelow::Squad:
return QLatin1String("Squad");
case EchelonBrigadeAndBelow::Section:
return QLatin1String("Section");
case EchelonBrigadeAndBelow::PlatoonDetachment:
return QLatin1String("PlatoonDetachment");
case EchelonBrigadeAndBelow::BattalionSquadron:
return QLatin1String("BattalionSquadron");
case EchelonBrigadeAndBelow::CompanyBatteryTroop:
return QLatin1String("CompanyBatteryTroop");
case EchelonBrigadeAndBelow::RegimentGroup:
return QLatin1String("RegimentGroup");
case EchelonBrigadeAndBelow::Brigade:
return QLatin1String("Brigade");
} // switch
return QLatin1String("ERROR-EchelonBrigadeAndBelow");
}
QPixmap SidcDefinitions::toPixmap(EchelonBrigadeAndBelow value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::EchelonBrigadeAndBelow> SidcDefinitions::echelonBrigadeAndBelows()
{
return { EchelonBrigadeAndBelow::Unknown,
EchelonBrigadeAndBelow::TeamCrew,
EchelonBrigadeAndBelow::Squad,
EchelonBrigadeAndBelow::Section,
EchelonBrigadeAndBelow::PlatoonDetachment,
EchelonBrigadeAndBelow::CompanyBatteryTroop,
EchelonBrigadeAndBelow::BattalionSquadron,
EchelonBrigadeAndBelow::RegimentGroup,
EchelonBrigadeAndBelow::Brigade
};
}
QLatin1String SidcDefinitions::toString(EchelonDivisionAndAbove value)
{
switch (value)
{
case EchelonDivisionAndAbove::Unknown:
return QLatin1String("Unknown");
case EchelonDivisionAndAbove::Division:
return QLatin1String("Division");
case EchelonDivisionAndAbove::CorpsMEF:
return QLatin1String("CorpsMEF");
case EchelonDivisionAndAbove::Army:
return QLatin1String("Army");
case EchelonDivisionAndAbove::Army_GroupFront:
return QLatin1String("Army_GroupFront");
case EchelonDivisionAndAbove::RegionTheater:
return QLatin1String("RegionTheater");
case EchelonDivisionAndAbove::Command:
return QLatin1String("Command");
} // switch
return QLatin1String("ERROR-EchelonDivisionAndAbove");
}
QVector<SidcDefinitions::EchelonDivisionAndAbove> SidcDefinitions::echelonDivisionAndAboves()
{
return {EchelonDivisionAndAbove::Unknown,
EchelonDivisionAndAbove::Division,
EchelonDivisionAndAbove::CorpsMEF,
EchelonDivisionAndAbove::Army,
EchelonDivisionAndAbove::Army_GroupFront,
EchelonDivisionAndAbove::RegionTheater,
EchelonDivisionAndAbove::Command,
};
}
QLatin1String SidcDefinitions::toString(MobilityOnLand value)
{
switch (value)
{
case MobilityOnLand::Unknown:
return QLatin1String("Unknown");
case MobilityOnLand::WheeledLimitedCrossCountry:
return QLatin1String("WheeledLimitedCrossCountry");
case MobilityOnLand::WheeledCrossCountry:
return QLatin1String("WheeledCrossCountry");
case MobilityOnLand::Tracked:
return QLatin1String("Tracked");
case MobilityOnLand::WheeledAndTrackedCombination:
return QLatin1String("WheeledAndTrackedCombination");
case MobilityOnLand::Towed:
return QLatin1String("Towed");
case MobilityOnLand::Rail:
return QLatin1String("Rail");
case MobilityOnLand::PackAnimal:
return QLatin1String("PackAnimal");
} // switch
return QLatin1String("ERROR-MobilityOnLand");
}
QPixmap SidcDefinitions::toPixmap(MobilityOnLand value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::MobilityOnLand> SidcDefinitions::mobilityOnLands()
{
return { MobilityOnLand::Unknown,
MobilityOnLand::WheeledLimitedCrossCountry,
MobilityOnLand::WheeledCrossCountry,
MobilityOnLand::Tracked,
MobilityOnLand::WheeledAndTrackedCombination,
MobilityOnLand::Towed,
MobilityOnLand::Rail,
MobilityOnLand::PackAnimal
};
}
QLatin1String SidcDefinitions::toString(MobilityOnSnow value)
{
switch (value)
{
case MobilityOnSnow::Unknown:
return QLatin1String("Unknown");
case MobilityOnSnow::OverSnow:
return QLatin1String("OverSnow");
case MobilityOnSnow::Sled:
return QLatin1String("Sled");
} // switch
return QLatin1String("ERROR-MobilityOnSnow");
}
QPixmap SidcDefinitions::toPixmap(MobilityOnSnow value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::MobilityOnSnow> SidcDefinitions::mobilityOnSnows()
{
return { MobilityOnSnow::Unknown,
MobilityOnSnow::OverSnow,
MobilityOnSnow::Sled
};
}
QLatin1String SidcDefinitions::toString(MobilityOnWater value)
{
switch (value)
{
case MobilityOnWater::Unknown:
return QLatin1String("Unknown");
case MobilityOnWater::Barge:
return QLatin1String("Barge");
case MobilityOnWater::Amphibious:
return QLatin1String("Amphibious");
} // switch
return QLatin1String("ERROR-MobilityOnWater");
}
QPixmap SidcDefinitions::toPixmap(MobilityOnWater value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::MobilityOnWater> SidcDefinitions::mobilityOnWaters()
{
return { MobilityOnWater::Unknown,
MobilityOnWater::Barge,
MobilityOnWater::Amphibious
};
}
QLatin1String SidcDefinitions::toString(NavalTowedArray value)
{
switch (value)
{
case NavalTowedArray::Unknown:
return QLatin1String("Unknown");
case NavalTowedArray::ShortTowedArray:
return QLatin1String("ShortTowedArray");
case NavalTowedArray::LongTowedArray:
return QLatin1String("LongTowedArray");
} // switch
return QLatin1String("ERROR-NavalTowedArray");
}
QPixmap SidcDefinitions::toPixmap(NavalTowedArray value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::NavalTowedArray> SidcDefinitions::navalTowedArrays()
{
return {NavalTowedArray::Unknown,
NavalTowedArray::ShortTowedArray,
NavalTowedArray::LongTowedArray
};
}
QLatin1String SidcDefinitions::toString(SymbolSet value)
{
switch (value)
{
case SymbolSet::Unknown:
return QLatin1String("Unknown");
case SymbolSet::Air:
return QLatin1String("Air");
case SymbolSet::AirMissle:
return QLatin1String("AirMissle");
case SymbolSet::Space:
return QLatin1String("Space");
case SymbolSet::SpaceMissle:
return QLatin1String("SpaceMissle");
case SymbolSet::LandUnit:
return QLatin1String("LandUnit");
case SymbolSet::LandCivilian_UnitOrganisation:
return QLatin1String("LandCivilian_UnitOrganisation");
case SymbolSet::LandEquipment:
return QLatin1String("LandEquipment");
case SymbolSet::LandInstallation:
return QLatin1String("LandInstallation");
case SymbolSet::ControlMeasure:
return QLatin1String("ControlMeasure");
case SymbolSet::DismountedIndividual:
return QLatin1String("DismountedIndividual");
case SymbolSet::SeaSurface:
return QLatin1String("SeaSurface");
case SymbolSet::SeaSubSurface:
return QLatin1String("SeaSubSurface");
case SymbolSet::MineWarfare:
return QLatin1String("MineWarfare");
case SymbolSet::Activities:
return QLatin1String("Activities");
case SymbolSet::Atmospheric:
return QLatin1String("Atmospheric");
case SymbolSet::Oceanographic:
return QLatin1String("Oceanographic");
case SymbolSet::MeteorologicalSpace:
return QLatin1String("MeteorologicalSpace");
case SymbolSet::SignalsIntelligence_Space:
return QLatin1String("SignalsIntelligence_Space");
case SymbolSet::SignalsIntelligence_Air:
return QLatin1String("SignalsIntelligence_Air");
case SymbolSet::SignalsIntelligence_Land:
return QLatin1String("SignalsIntelligence_Land");
case SymbolSet::SignalsIntelligence_Surface:
return QLatin1String("SignalsIntelligence_Surface");
case SymbolSet::SignalsIntelligence_Subsurface:
return QLatin1String("SignalsIntelligence_Subsurface");
case SymbolSet::Cyberspace:
return QLatin1String("Cyberspace");
} // switch
return QLatin1String("ERROR-SymbolSet");
}
QPixmap SidcDefinitions::toPixmap(SymbolSet value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::SymbolSet> SidcDefinitions::symbolSets()
{
return {SymbolSet::Unknown,
SymbolSet::Air,
SymbolSet::AirMissle,
SymbolSet::Space,
SymbolSet::SpaceMissle,
SymbolSet::LandUnit,
SymbolSet::LandCivilian_UnitOrganisation,
SymbolSet::LandEquipment,
SymbolSet::LandInstallation,
SymbolSet::ControlMeasure,
SymbolSet::DismountedIndividual,
SymbolSet::SeaSurface,
SymbolSet::SeaSubSurface,
SymbolSet::MineWarfare,
SymbolSet::Activities,
SymbolSet::Atmospheric,
SymbolSet::Oceanographic,
SymbolSet::MeteorologicalSpace,
SymbolSet::SignalsIntelligence_Space,
SymbolSet::SignalsIntelligence_Air,
SymbolSet::SignalsIntelligence_Land,
SymbolSet::SignalsIntelligence_Surface,
SymbolSet::SignalsIntelligence_Subsurface,
SymbolSet::Cyberspace
};
}
QLatin1String SidcDefinitions::toString(Status value)
{
switch (value)
{
case Status::Present:
return QLatin1String("Present");
case Status::Planned_Anticipated_Suspect:
return QLatin1String("Planned_Anticipated_Suspect");
case Status::Present_FullCapable:
return QLatin1String("Present_FullCapable");
case Status::Present_Damaged:
return QLatin1String("Present_Damaged");
case Status::Present_Destroyed:
return QLatin1String("Present_Destroyed");
case Status::Present_FullToCapacity:
return QLatin1String("Present_FullToCapacity");
} // switch
return QLatin1String("ERROR-Status");
}
QPixmap SidcDefinitions::toPixmap(Status value)
{
Q_UNUSED(value);
return QPixmap();
}
QVector<SidcDefinitions::Status> SidcDefinitions::statuss()
{
return
{
Status::Present,
Status::Planned_Anticipated_Suspect,
Status::Present_FullCapable,
Status::Present_Damaged,
Status::Present_Destroyed,
Status::Present_FullToCapacity
};
}
QStringList SidcDefinitions::modifierKeys() const
{
if (!m_esriDictProcessor)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " no m_esriDictProcessor";
return QStringList();
}
return m_esriDictProcessor->symbolModifierKeys();
}
QVector<ModifierData> SidcDefinitions::modifierList(SidcDefinitions::SymbolSet symbolSet, unsigned int modifierSector) const
{
if (!m_esriDictProcessor)
{
ERROR_LOG(m_logger) << LOGFUNCTION << " no m_esriDictProcessor";
return QVector<ModifierData>();
}
return m_esriDictProcessor->symbolModifierList(symbolSet, modifierSector);
}
//----------------------------------------------------------------------------
std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SidcDefinitions::ShapeType &value)
{
stream << "ShapeType(" << AdvancedSymbology::SidcDefinitions::toString(value)
<< ")";
return stream;
}
std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SidcDefinitions::Identity &value)
{
stream << "Identity(" << AdvancedSymbology::SidcDefinitions::toString(value)
<< ")";
return stream;
}
std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SidcDefinitions::SymbolSet &value)
{
stream << "SymbolSet(" << AdvancedSymbology::SidcDefinitions::toString(value)
<< ")";
return stream;
}
std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SidcDefinitions::Status &value)
{
stream << "Status(" << AdvancedSymbology::SidcDefinitions::toString(value)
<< ")";
return stream;
}
} // namespace AdvancedSymbology
+396
View File
@@ -0,0 +1,396 @@
/**
* @RDE_HEADER@
* Class SidcDefinitions
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbol_dictionary_types.h"
#include "../SymbologyImpl/advanced_symbology_logging.h" // ToDo
// Qt
#include <QString>
#include <QVector>
#include <QPixmap>
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
static const QLatin1String ETS_SYMBOL_KEYWORD("ETS");
// forward:
class SymbolDictionary;
class EsriDictionaryProcessor;
struct ModifierData;
/**
* @brief The SidcDefinitions class contains a row of enum definitions common to the AdvancedSymbology.
* A couple (like SidcDefinitions::modifierList) require a loaded SymbolDictionary.
*/
class ADVANCED_SYMBOLOGY_EXPORT SidcDefinitions
{
public:
/*! \name Construction, Destruction */
//@{
///< Constructor
explicit SidcDefinitions(AdvancedSymbology::SymbolDictionary *symbolDictionary, const char *loggerName = "SidcDefinitions");
///< Destructor
virtual ~SidcDefinitions() = default;
//@}
//
// Counting startw with 1
//
//
// Version : digit 1,2
//
//
// StandardIdentity : digit 3,4
//
enum class ShapeType
{
Undefined,
Circle,
Clover,
Curve,
Diamond,
Rectangle,
Square
};
static QLatin1String toString(ShapeType value);
// StandardIdentity, 1st digit
enum class Context
{
Reality, ///< 0
Exercise, ///< 1
Simulation ///< 2
};
static QLatin1String toString(Context value);
static QPixmap toPixmap(Context value);
static QVector<Context> contexts();
// StandardIdentity, 2nd digit
enum class Identity
{
Pending, ///< 0
Unknown, ///< 1
AssumedFriend, ///< 2
Friend, ///< 3
Neutral, ///< 4
SuspectJoker, ///< 5
HostileFaker ///< 6
};
static QLatin1String toString(Identity value);
static QPixmap toPixmap(Identity value);
static QVector<Identity> identities();
struct ADVANCED_SYMBOLOGY_EXPORT StandardIdentity
{
Context context = Context::Reality; ///< 1st digit
Identity identity = Identity::Unknown; ///< 2nd digit
ShapeType getShape() const; // BattleDimension missing!!!!!!!
};
//
// : StandardIdentity
//
//
// Symbol Set : digit 5,6 TODO: maybe generated out of esri stylx file, becasuse it depends on MIL/APP ???
//
enum class SymbolSet
{
Unknown, ///< 0
Air,
AirMissle,
Space = 5,
SpaceMissle,
LandUnit = 10,
LandCivilian_UnitOrganisation,
LandEquipment = 15,
LandInstallation = 20,
ControlMeasure = 25,
DismountedIndividual = 27, // APP6D, not MIL2525D
SeaSurface = 30,
SeaSubSurface = 35,
MineWarfare,
Activities = 40,
Atmospheric = 45,
Oceanographic,
MeteorologicalSpace = 50,
SignalsIntelligence_Space,
SignalsIntelligence_Air,
SignalsIntelligence_Land,
SignalsIntelligence_Surface,
SignalsIntelligence_Subsurface,
Cyberspace = 60
};
static QLatin1String toString(SymbolSet value);
static QPixmap toPixmap(SymbolSet value);
static QVector<SymbolSet> symbolSets();
template<typename T> static SymbolSet castToSymbolSet(T value)
{
SymbolSet symbolSet = static_cast<SymbolSet>(value);
if (!symbolSets().contains(symbolSet))
symbolSet = SymbolSet::Unknown;
return symbolSet;
} // template<typename T> SymbolSet castToSymbolSet(T value)
//
// Status : digit 7
//
enum class Status
{
Present = 0, ///< exeption, no Unknown
Planned_Anticipated_Suspect = 1,
Present_FullCapable = 2,
Present_Damaged = 3,
Present_Destroyed = 4,
Present_FullToCapacity = 5
};
static QLatin1String toString(Status value);
static QPixmap toPixmap(Status value);
static QVector<Status> statuss();
//
// HQ TF Dummy : digit 8
//
enum class HQTFDummy
{
Unknown, ///< 0
FeintDummy, ///< 1
Headquarters, ///< 2
FeintDummy_Headquarters, ///< 3
TaskForce, ///< 4
FeintDummy_TaskForce, ///< 5
TaskForce_Headquarters, ///< 6
FeintDummy_TaskForce_Headquarters, ///< 7
};
static QLatin1String toString(HQTFDummy value);
static QPixmap toPixmap(HQTFDummy value);
static QVector<HQTFDummy> hQTFDummy();
// some helper functions:
struct HQTFDummyConverter
{
static void toBool(const HQTFDummy &hqTfDummy,
bool &headquarters,
bool &taskForce,
bool &feintDummy);
static uint toHqTfDummyAsInt(bool headquarters,
bool taskForce,
bool feintDummy);
static HQTFDummy toHqTfDummy(bool headquarters,
bool taskForce,
bool feintDummy);
};
//
// Amplifier : digit 9,10
//
// Amplifier-Group : 1st digit
enum class AmplifierGroup
{
Unknown,
Echelon_BrigadeAndBelow,
Echelon_DivisionAndAbove,
Mobility_OnLand,
Mobility_OnSnow,
Mobility_OnWater,
Naval_TowedArry,
};
static QLatin1String toString(AmplifierGroup value);
static QPixmap toPixmap(AmplifierGroup value);
static QVector<AmplifierGroup> amplifierGroups();
// Depending on AmplifierGroup :
// Amplifier-Echelon/Mobility/Naval - 2nd digit
enum class EchelonBrigadeAndBelow
{
Unknown = 0,
TeamCrew,
Squad,
Section,
PlatoonDetachment,
CompanyBatteryTroop,
BattalionSquadron,
RegimentGroup,
Brigade
};
static QLatin1String toString(EchelonBrigadeAndBelow value);
static QPixmap toPixmap(EchelonBrigadeAndBelow value);
static QVector<EchelonBrigadeAndBelow> echelonBrigadeAndBelows();
// OR
enum class EchelonDivisionAndAbove
{
Unknown = 0,
Division,
CorpsMEF,
Army,
Army_GroupFront,
RegionTheater,
Command
};
static QLatin1String toString(EchelonDivisionAndAbove value);
static QVector<EchelonDivisionAndAbove> echelonDivisionAndAboves();
// OR
enum class MobilityOnLand
{
Unknown = 0,
WheeledLimitedCrossCountry,
WheeledCrossCountry,
Tracked,
WheeledAndTrackedCombination,
Towed,
Rail,
PackAnimal
};
static QLatin1String toString(MobilityOnLand value);
static QPixmap toPixmap(MobilityOnLand value);
static QVector<MobilityOnLand> mobilityOnLands();
// OR
enum class MobilityOnSnow
{
Unknown = 0,
OverSnow,
Sled
};
static QLatin1String toString(MobilityOnSnow value);
static QPixmap toPixmap(MobilityOnSnow value);
static QVector<MobilityOnSnow> mobilityOnSnows();
// OR
enum class MobilityOnWater
{
Unknown = 0,
Barge,
Amphibious
};
static QLatin1String toString(MobilityOnWater value);
static QPixmap toPixmap(MobilityOnWater value);
static QVector<MobilityOnWater> mobilityOnWaters();
// OR
enum class NavalTowedArray
{
Unknown = 0,
ShortTowedArray,
LongTowedArray
};
static QLatin1String toString(NavalTowedArray value);
static QPixmap toPixmap(NavalTowedArray value);
static QVector<NavalTowedArray> navalTowedArrays();
//
// : Amplifier
//
/*! \name Methods requiring a loaded SymbolDictionary*/
//@{
//
// Modifier
//
/**
* @brief Provides a list of all modifier keys
*/
QStringList modifierKeys() const;
/**
* @brief A List of all modifiers of a symbolSet
* @param symbolSet symbol set
* @param modifierSector sector of the modifier, range of values [1,2]
* @see SymbolSet
*/
QVector<ModifierData> modifierList(SidcDefinitions::SymbolSet symbolSet, unsigned int modifierSector) const;
//@}
protected:
SymbolDictionary *m_symbolDictionary = nullptr;
const EsriDictionaryProcessor *m_esriDictProcessor = nullptr;
LOGGER_T m_logger; ///< Interface of the Logging-Facility
}; // class SidcDefinitions
// move to different place!?!? Todo check
/**
* Stores data to each symbol modifier. Each symbol can have a list of sector 1 and sector 2 modifiers
*/
struct ModifierData
{
QString m_modifierKey; /*!< 5 digits key from ESRI stylx : SymbolSet<2>ModifierValue<2>ModifierSector<1> */
SidcDefinitions::SymbolSet m_symbolSet; /*!< Symbol set matching to the modifier */
unsigned int m_modifierSector; /*!< Modifier sector, can be 1 or 2 */
unsigned int m_modifierValue; /*!< Value of modifier depending on symbol set and modifier sector */
QString m_modifierName; /*!< Name of modifier to show at GUI */
QPixmap m_modifierIcon; /*!< Icon of the modifier */
};
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SidcDefinitions::ShapeType &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SidcDefinitions::Identity &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SidcDefinitions::SymbolSet &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream, const AdvancedSymbology::SidcDefinitions::Status &value);
} // namespace AdvancedSymbology
+192
View File
@@ -0,0 +1,192 @@
/**
* @RDE_HEADER@
* ViewshedParameter
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "symbol_data_to_render.h"
#include <SymbologyImpl/advanced_symbology_logging.h>
#include <Symbology/sidc_codec.h>
#include <Symbology/sidc_builder.h>
//Qt
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
//----------------------------------------------------------------------------
SymbolDataToRender::SymbolDataToRender(const QString &_sidc, int _sizeL)
{
init();
sidc = _sidc;
sizeL = _sizeL;
}
void SymbolDataToRender::init()
{
sidc.clear();
role = Role::Unknown;
sizeL = 100;
fillColor = Qt::magenta;
fillColorReplace = false;
marking = false;
injury = Injury::NoInjury; // NoInjury, Hit, MobilityKill, WeaponKill, TotalKill
injuryColor = Qt::gray;
additionalSymbols.clear();
spiOriginalKey.clear();
spiSizeL = 100;
renderJustCoreImage = false;
}
QString SymbolDataToRender::sidcAccordingRole() const
{
if (!SidcCodec::isEncoded(sidc))
return sidc;
const SymbologyType symType = SidcCodec::decodeSymbologyType(sidc);
if ((symType != SymbologyType::MIL2525D) && (symType != SymbologyType::APP6D))
return sidc;
AdvancedSymbology::SidcBuilder sidcBuilder(&AdvancedSymbology::SymbolDictionary::dictionary(symType));
if (!sidcBuilder.setSidc(sidc))
return sidc;
sidcBuilder.setIdentity(static_cast<SidcDefinitions::Identity>(role)); // This works just for MIL2525D, APP6D symbols...
// // This works just for MIL2525D symbols :
// QString sidcToBeModified = sidc;
// sidcToBeModified.replace(13, 1, QString::number((int)role)); // enum role is (at least now) identical to Identity
// // : This works just for MIL2525D symbols
return sidcBuilder.toSidc();
}
bool SymbolDataToRender::operator==(const SymbolDataToRender &o) const
{
return sidc == o.sidc &&
role == o.role &&
sizeL == o.sizeL &&
fillColor == o.fillColor &&
fillColorReplace == o.fillColorReplace &&
marking == o.marking &&
injury == o.injury &&
injuryColor == o.injuryColor &&
additionalSymbols == o.additionalSymbols;
}
bool SymbolDataToRender::operator!=(const SymbolDataToRender &o) const
{
return !operator ==(o);
}
//-----------------------------------------------------------------------------
QString toString(AdditionalSymbolType value)
{
switch (value)
{
case AdditionalSymbolType::BiteError:
return QLatin1String("BiteError");
case AdditionalSymbolType::Manipulation:
return QLatin1String("Manipulation");
case AdditionalSymbolType::NoPosition:
return QLatin1String("NoPosition");
case AdditionalSymbolType::NbcProtection:
return QLatin1String("NbcProtection");
} // switch
return QLatin1String("additionalSymbolTypeToStringERROR");
}
std::ostream &operator<<(std::ostream &stream, const AdditionalSymbolType &value)
{
stream << toString(value);
return stream;
}
std::ostream &operator<<(std::ostream &stream, const AdditionalSymbolTypeCont &value)
{
stream << "AST_Cont(" << value.size() << ") ";
for (const AdditionalSymbolType &item : value)
stream << toString(item) << ";";
return stream;
}
//-----------------------------------------------------------------------------
QString toString(Injury value)
{
switch (value)
{
case Injury::NoInjury:
return QLatin1String("NoInjury");
case Injury::Hit:
return QLatin1String("Hit");
case Injury::MobilityKill:
return QLatin1String("MobilityKill");
case Injury::WeaponKill:
return QLatin1String("WeaponKill");
case Injury::TotalKill:
return QLatin1String("TotalKill");
} // switch
return QLatin1String("InjuryToStringERROR");
}
std::ostream &operator<<(std::ostream &stream, const Injury &value)
{
stream << toString(value);
return stream;
}
std::ostream &operator<<(std::ostream &stream, const SymbolDataToRender &value)
{
stream << value.toString().constData();
return stream;
}
QString SymbolDataToRender::toString() const
{
QString str;
str = QStringLiteral("sidc='%1'").arg(sidc) +
QStringLiteral(" role=%1").arg(AdvancedSymbology::toString(role)) +
QStringLiteral(" sizeL=%1").arg(sizeL) +
// QStringLiteral(" lineColor=%1")).arg(lineColor.name(QColor::HexArgb)) +
QStringLiteral(" fillColor=%1").arg(fillColor.name(QColor::HexArgb)) +
QStringLiteral(" fillColorReplace=%1").arg(fillColorReplace) +
QStringLiteral(" marking=%1").arg(marking) +
QStringLiteral(" injury=%1").arg(AdvancedSymbology::toString(injury)) +
QStringLiteral(" injuryColor=%1").arg(injuryColor.name(QColor::HexArgb)) +
QStringLiteral(" spiOriginalKey=%1").arg(spiOriginalKey) +
QStringLiteral(" spiSizeL=%1").arg(spiSizeL) +
QStringLiteral(" renderJustCoreImage=%1").arg(renderJustCoreImage);
std::stringstream stream;
stream << additionalSymbols;
str += QStringLiteral(" additionalSymbols=%1").arg(QLatin1String(stream.str().c_str()));
return str;
}
} // namespace AdvancedSymbology
+136
View File
@@ -0,0 +1,136 @@
/**
* @RDE_HEADER@
* ViewshedParameter
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "symbol_dictionary_types.h"
#include "advanced_symbology_export.h"
// Qt
#include <QString>
#include <QColor>
#include <QSet>
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
//----------------------------------------------------------------------------
/**
* @brief The AdditionalSymbolType enum
*/
enum class AdditionalSymbolType
{
NbcProtection, ///< Line at top left.
Manipulation, ///< Black and white dashed lines at bottom (1st of three)
NoPosition, ///< Red line at bottom (2nd of three)
BiteError ///< Yellow line at bottom. (3rd of three)
};
QString ADVANCED_SYMBOLOGY_EXPORT toString(AdditionalSymbolType);
// enable usage as key (e.g. QSet<AdditionalSymbolType>)
inline uint qHash(AdditionalSymbolType type)
{
return ::qHash(static_cast<int>(type));
}
using AdditionalSymbolTypeCont = QSet<AdditionalSymbolType>;
//----------------------------------------------------------------------------
/**
* @brief The injury enum
*/
enum class Injury
{
NoInjury, ///< ""
Hit, ///< "-"
MobilityKill, ///< "\"
WeaponKill, ///< "/"
TotalKill ///< "/\"
};
QString toString(Injury value);
//----------------------------------------------------------------------------
/**
* @brief The SymbolDataToRender struct contains all data usefull to render
* an advanced symbol.
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolDataToRender
{
public:
explicit SymbolDataToRender(const QString &_sidc = QString(), int _sizeL = 100);
void init();
QString sidcAccordingRole() const;
public:
QString sidc;
Role role;
int sizeL;
// QColor lineColor = Qt::black; // not supported by esri yet
QColor fillColor;
bool fillColorReplace;
bool marking;
Injury injury;
QColor injuryColor;
AdditionalSymbolTypeCont additionalSymbols; // noPos, Manip...
static QColor unknownColor()
{
return QColor(255, 255, 0); // 10012500002108000000@Mil2525D: color = QColor(255, 255, 0);
}
QString toString() const;
bool operator==(const SymbolDataToRender &o) const;
bool operator!=(const SymbolDataToRender &o) const;
// just for internal use :
friend class SymbolDictionaryImpl;
friend class EsriDictionaryProcessor;
private:
QString spiOriginalKey; // spi = symbolPropertyImage
int spiSizeL = 100; // spi = symbolPropertyImage
bool renderJustCoreImage = false;
// : just for internal use
};
//-----------------------------------------------------------------------------
// output operator:
//-----------------------------------------------------------------------------
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::AdditionalSymbolType &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::AdditionalSymbolTypeCont &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::Injury &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::SymbolDataToRender &value);
} // namespace AdvancedSymbology
@@ -0,0 +1,49 @@
/**
* @RDE_HEADER@
* ViewshedParameter
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include <Symbology/symbol_dictionary_types.h>
// Qt
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
// forwarding of enum which is declared within a class is not possible:
// enum class ParticipantManagement::Role;
template<class PARTICIPANT_ROLE_TYPE = ParticipantManagement::Role>
AdvancedSymbology::Role roleToRole(const PARTICIPANT_ROLE_TYPE role)
{
switch (role.underlying())
{
case ParticipantManagement::Role_def::Unknown:
return AdvancedSymbology::Role::Unknown;
case ParticipantManagement::Role_def::Friend:
return AdvancedSymbology::Role::Friend;
case ParticipantManagement::Role_def::Neutral:
return AdvancedSymbology::Role::Neutral;
case ParticipantManagement::Role_def::Enemy:
return AdvancedSymbology::Role::HostileFaker;
case ParticipantManagement::Role_def::Pending:
return AdvancedSymbology::Role::Pending;
case ParticipantManagement::Role_def::AssumedFriend:
return AdvancedSymbology::Role::AssumedFriend;
case ParticipantManagement::Role_def::Suspect:
return AdvancedSymbology::Role::SuspectJoker;
} // switch
return AdvancedSymbology::Role::Unknown;
}
} // namespace AdvancedSymbology
+242
View File
@@ -0,0 +1,242 @@
/**
* @RDE_HEADER@
* Interface of SymbolDictionary
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "symbol_dictionary.h"
#include <Common/resource_path.h>
#include <SymbologyImpl/symbol_dictionary_impl.h>
#include "sidc_codec.h"
// Qt
#include <QCoreApplication>
#include <QMap>
#include <QProcessEnvironment>
void initResource()
{
Q_INIT_RESOURCE(symbols);
}
namespace AdvancedSymbology
{
bool SymbolDictionary::doParanoiaChecks()
{
static bool s_read = false;
static bool s_doParanoiaChecks = false;
if (!s_read)
{
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString val = env.value(QStringLiteral("DO_SITMAP_CHECKS"), QStringLiteral("1"));
s_read = true;
s_doParanoiaChecks = (val.compare(QStringLiteral("1"))==0);
if (s_doParanoiaChecks)
qCritical() << " paranoiaChecks are ON (via DO_SITMAP_CHECKS)";
else
qCritical() << " paranoiaChecks are OFF (via DO_SITMAP_CHECKS)";
}
return s_doParanoiaChecks;
}
static QMap<SymbologyType, QString> &s_symbologyResourcePaths()
{
static QMap<SymbologyType, QString> map;
return map;
} // QMap<SymbologyType, QString> &s_symbologyResourcePaths()
static QMap<SymbologyType, SymbolDictionary *> &s_symbologyDictionaries()
{
static QMap<SymbologyType, SymbolDictionary *> map;
return map;
} // QMap<SymbologyType, SymbolDictionary *> &s_symbologyDictionaries
static void cleanupDictionary()
{
qDeleteAll(s_symbologyDictionaries());
s_symbologyDictionaries().clear();
}
bool SearchParameters::isEmpty() const
{
return keys.isEmpty() &&
names.isEmpty() &&
categories.isEmpty() &&
symbolClasses.isEmpty() &&
tags.isEmpty();
}
int SearchParameters::numberOfParameter() const
{
int count = 0;
if (!keys.isEmpty()) ++count;
if (!names.isEmpty()) ++count;
if (!categories.isEmpty()) ++count;
if (!symbolClasses.isEmpty()) ++count;
if (!tags.isEmpty()) ++count;
return count;
}
SymbolDictionary::SymbolDictionary(QObject *parent)
: QObject(parent)
{
LOGGER_T m_logger = getLogger("SymbolDictionary");
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
initResource();
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
static SymbologyType _defaultSymbologyType = SymbologyType::None;
SymbologyType SymbolDictionary::defaultSymbologyType()
{
return _defaultSymbologyType;
} // SymbologyType SymbolDictionary::defaultSymbologyType()
void SymbolDictionary::setDefaultSymbologyType( SymbologyType symbologyType )
{
if (SymbologyType::None == _defaultSymbologyType)
{
// set default only once
_defaultSymbologyType = symbologyType;
}
} // void SymbolDictionary::setDefaultSymbologyType( SymbologyType symbologyType )
QString SymbolDictionary::initializeSymbologyResourcePath(SymbologyType symbologyType)
{
LOGGER_T m_logger = getLogger("SymbolDictionary");
TRACE_LOG(m_logger) << LOGFUNCTION << " START"
<< " symbologyType=" << symbologyType;
if (s_symbologyResourcePaths()[symbologyType].isEmpty())
{
#ifdef USE_ARCADE_SYMBOLOGY
QString finalSymbologyResourcePath = SituationMap::getResourcePath() + QLatin1String("symbols_arcade/");
#else
QString finalSymbologyResourcePath = SituationMap::getResourcePath() + QLatin1String("symbols/");
#endif // USE_ARCADE_SYMBOLOGY
switch (symbologyType)
{
case AdvancedSymbology::SymbologyType::MIL2525D:
finalSymbologyResourcePath.append(QLatin1String("mil2525d/mil2525d.stylx")); // like /arcgis/runtime_sdk/qt100.0/resources/symbols/mil2525d/mil2525d.stylx
break;
case AdvancedSymbology::SymbologyType::MIL2525C:
finalSymbologyResourcePath.append(QLatin1String("mil2525c_b2/mil2525c_2b.stylX"));
break;
case AdvancedSymbology::SymbologyType::APP6B:
finalSymbologyResourcePath.append(QLatin1String("app6b/app6b.stylx"));
break;
case AdvancedSymbology::SymbologyType::APP6D:
finalSymbologyResourcePath.append(QLatin1String("app6d/app6d.stylx"));
break;
case AdvancedSymbology::SymbologyType::None:
finalSymbologyResourcePath.clear();
break;
} // switch
s_symbologyResourcePaths()[symbologyType] = finalSymbologyResourcePath;
}
DEBUG_LOG(m_logger) << LOGFUNCTION << " dict of type/path:"
<< " symbologyType=" << symbologyType
<< ", symbologyResourcePath='" << s_symbologyResourcePaths()[symbologyType] << "'";
TRACE_LOG(m_logger) << LOGFUNCTION << " END"
<< " symbologyType=" << symbologyType
<< ", symbologyResourcePath='" << s_symbologyResourcePaths()[symbologyType] << "'";
return s_symbologyResourcePaths()[symbologyType];
}
SymbolDictionary &SymbolDictionary::dictionary(SymbologyType symbologyType)
{
LOGGER_T m_logger = getLogger("SymbolDictionary");
TRACE_LOG(m_logger) << LOGFUNCTION << " START"
<< " symbologyType=" << symbologyType;
if (!s_symbologyDictionaries().contains(symbologyType))
{
// store and get final path:
const QString &resPath = initializeSymbologyResourcePath(symbologyType);
// Do NOT removed this message!!!
NOTICE_LOG(m_logger) << LOGFUNCTION << " dictionary path: '" << resPath << "'"
<< ", symbologyType " << symbologyType;
// Do NOT removed this message!!!
// create dict:
AdvancedSymbology::SymbolDictionaryImpl *dict =
new AdvancedSymbology::SymbolDictionaryImpl(symbologyType, resPath);
// store dict:
s_symbologyDictionaries()[symbologyType] = dict;
qAddPostRoutine(cleanupDictionary);
}
TRACE_LOG(m_logger) << LOGFUNCTION << " END"
<< " symbologyType=" << symbologyType;
return *(s_symbologyDictionaries()[symbologyType]);
}
bool SymbolDictionary::alreadyExists(SymbologyType symbologyType)
{
return s_symbologyDictionaries().contains(symbologyType);
}
QImage SymbolDictionary::temporaryImage(int sizeL)
{
return SymbolDictionaryImpl::temporaryImage(sizeL);
}
void cleanupSymbolDictionaryInternal()
{
LOGGER_T m_logger = getLogger("SymbolDictionary");
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
cleanupDictionary();
if (! s_symbologyDictionaries().isEmpty())
FATAL_LOG(m_logger) << LOGFUNCTION << " s_symbologyDictionaries NOT empty";
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
} // namespace AdvancedSymbology
+418
View File
@@ -0,0 +1,418 @@
/**
* @RDE_HEADER@
* Interface of SymbolDictionary
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbol_dictionary_types.h"
#include "property_result.h"
#include "symbol_result.h"
#include "../SymbologyXML/symbol.h"
// Qt
#include <QImage>
#include <QString>
#include <QStringList>
// Forward
class QValidator;
# include <arcgis/arcgisversion.h> // This file is created by RME, not ESRI
#if ACRGIS_VERSION >= 0x640600 // 100.6.0 / Update 6
//# define USE_ARCADE_SYMBOLOGY
#endif
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
/**
* @brief The SymbolDictionary class is the main class in this namespace.
* \section secCommon Common
* To create an instance
* - use static method SymbolDictionary::dictionary() (one instance per AdvancedSymbology::SymbologyType).
* - load the dictionary (on finish the signal loaded is emitted.)
*
* To support symbol independent from an official symbology standard you can add extra symbols: insertExtraSymbol.
*
* To get symbol information there are different approaches: search, find and fetch \n
* - searchSymbol() is looking for symbol by defining some strings or stringLists as definded at SearchParameters. \n
* The result contains one or more SymbolProperties in a list (SymbolPropertyList)
*
* - find... to get an QImage
* - findImage(), findPreview() is looking using a complete sidc. \n
* \sa \ref secfindImageExplanation
*
* - findBaseSymbol() is looking using the baseSymboCode (SymbolSet and Entity). \n
* If a abtract symbol is requested the first overload should be used. \n
*
* - fetchSymbol() is looking using a complete sidc for internal use. \n
*
* Most methods are using the future pattern.
* The result value (like PropertyResult and SymbolResult) will contain the real result - when available.
* To get a (ready)signal, a propper watcher is prepared: PropertyResultWatcher or SymbolResultWatcher.
*
* This is explained at the base class ResultWatcher.
*
*
* \section secfindImageExplanation Use proper find method
*
* There are following use cases:
*
* - PlayerInfoWindow \n
* PointSymbol with frame, modifier, injury; multiPointSymbol (maybe with concrete geometry) \n
* (THE tank of a concrete party/color with concrete modifier, injury...)
*
* - PlayerTree (SymbolSelectionDlg) \n
* (A tank of party 'Unknown', (with modifier like platoon, but no space for injury))
*
* - Favourites at PlanEditor \n
* (A tank, no party (black - just the baseSymbol)
*
* To get a suitable image for your use case youd should pay attention to following table:
*
| UseCase | Method | SinglePointSymbol | MultiPointSymbol |
| :----------------------------------------------------| : ---------------| : ---------------------------|: ------------------- |
| concrete Obj with partyColor,Frame,Modifier, Injury | findImage() | fetch | lookupTable (search) |
| abstract Obj with Frame (Unknown) | findPreview() | fetch | lookupTable (search) |
| abstract Obj without Frame/Modifier | findBaseSymbol() | lookupTable (search) | lookupTable (search) |
* (lookupTable == m_baseSymbolCodeToSymbolPropertyTable & m_originalKeyToEsriSymbol)
*
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolDictionary : public QObject
{
Q_OBJECT
public:
static bool doParanoiaChecks();
protected:
/*! \name Construction, Destruction */
//@{
/**
* @brief Constructor.
* @param parent
*/
explicit SymbolDictionary(QObject *parent = nullptr);
public:
/**
* @brief Initialize the SymbologyResourcePath.
* @param symbologyType Type of symbology to initialize.
* @return resulting symbologyResourcePath
*/
static QString initializeSymbologyResourcePath(SymbologyType symbologyType);
/**
* @brief Get access to dictionary of a SymbologyType (singleton per SymbologyType)
* @param symbologyType The SymbologyType the Dictionary should base on.
* @param symbologyResourcePath ResourcePath to be set (e.g. /opt/EXTFW/resources/symbols/app6b).
* @return Reference to requested SymbolDictionary.
*/
static SymbolDictionary &dictionary(SymbologyType symbologyType);
/**
* @brief Does the requested SymbolDictionary already exists?
* @param symbologyType requested SymbologyType
* @return true if already existing, otherwise false
*/
static bool alreadyExists(SymbologyType symbologyType);
/**
* @brief Provide default SymbologyType
*/
static SymbologyType defaultSymbologyType();
/**
* @brief Defines default SymbologyType. Is been called while situation map is loading map settings.
* @param symbologyType SymbologyType to set as default
*/
static void setDefaultSymbologyType( SymbologyType symbologyType );
/**
* Returns state of dictionary. In case of failure the return value is false and in other case true.
*/
virtual bool isOk() const = 0;
/**
* @brief load
* Object can load data asynchronously.
* Call load() to initiate loading.
* If loading has finished the signal loaded is emitted.
*/
virtual void load() = 0;
/**
* @brief Information about Loading.
* @return true if loaded, otherwise false.
*/
virtual bool isLoaded() const = 0;
/**
* @brief Get current loadStatus
* @return
*/
virtual LoadStatus loadStatus() const = 0;
virtual ~SymbolDictionary() = default; ///< Destructor
//@}
/** \name Ets symbols
* To support symbol independent from an official symbology standard you can add ets symbols:
*/
//@{
/**
* @brief Insert (add/update) (own) ETS symbol to dictionary.
* @param sidc Symbol Id Code to add. If sidc is already in use, the entry (properties and image) is updated.
* @param properties To be associated to sidc.
* @param image To be associated to sidc.
* @return True on success, otherwise false.
*/
virtual bool setEtsSymbol(int fileId,
const QString &sidc,
const SymbolProperties &properties,
const QImage &image) = 0;
///< remove Extra symbol
virtual void removeEtsSymbol(int fileId) = 0;
virtual void removeEtsSymbol(const QString &sidc) = 0;
///< clear all Extra symbols
virtual void clearEtsSymbols() = 0;
///< add complete directory recursively with Extra symbols.
virtual int addEtsSymbols(const QString &path = QString()) = 0;
///< complete list of all Extra symbols.
virtual QStringList etsSymbols() const = 0;
/**
* @brief Number of Extra symbols
* @return number of Extra symbols
*/
virtual int etsSymbolCount() const = 0;
//@}
/** \name Xml symbols
* To support symbol independent from ESRI symbology standard you can add symbols base on symbol editor XML based format
*/
//@{
virtual bool containsXmlSymbol(const QString &sidc) const = 0; /**< Returns true in case of symbol is in dictionary, otherwise false. */
virtual bool setXmlSymbol(int fileId, const QString &name, const QString &operatorName, qint64 lastModified, const QString &xmlSymbol, const SymbolProperties &properties) = 0; /**< Inserts (add/update) a symbol from XML format and returns true on success. */
virtual bool setXmlSymbol(int fileId, const QString &name, const QString &operatorName, qint64 lastModified, const SymbologyXML::Symbol &symbol, const SymbolProperties &properties) = 0; /**< Inserts (add/update) a symbol from SymbologyXML::Symbol and returns true on success. */
virtual void removeXmlSymbol(int fileId) = 0; /**< Remove symbol from dictionary */
virtual void removeXmlSymbol(const QString &sidc) = 0; /**< Remove symbol from dictionary */
virtual void clearXmlSymbols() = 0; /**< Remove all symbols from dictionary */
virtual void clearXmlSymbolCache() = 0; /**< Clear internal Cache for XML-Symbols */
virtual int xmlSymbolCount() const = 0; /**< Pass back the number of XML symbols in dictonary */
virtual QStringList xmlSymbols() const = 0; /**< Returns a list of all XML symbol sidc's in dictionary */
virtual QString xmlSidc(const QString &xmlSymbol) const = 0; /**< Returns the sidc of a symbol */
virtual QString xmlSidc(const SymbologyXML::Symbol &symbol) const = 0; /**< Returns the sidc of a symbol */
virtual SymbologyXML::Symbol xmlSymbol(const QString &sidc) const = 0; /**< Pass back the SymbologyXML::Symbol of sidc */
virtual SymbolProperties xmlSymbolProps(const QString &sidc) const = 0; /**< Pass back the SymbolProperties of sidc */
//@}
public:
SymbolDictionary(const SymbolDictionary &other) = delete;
SymbolDictionary &operator=(const SymbolDictionary &other) = delete;
virtual SymbologyType symbologyType() const = 0;
virtual QString specificationType() const = 0;
virtual QString symbologyResourcePath() const = 0;
virtual int symbologySpecificCount() const = 0;
static QImage temporaryImage(int sizeL = 100);
/**
* @brief Get all known attribute keys which are interpreted by rendering process
*/
virtual QStringList symbologyAttributeKeyList() const = 0;
/** \name Search */
//@{
/**
* @brief Get a list of all cached symbol codes
*/
virtual QStringList cachedBaseSymbolCodes() const = 0;
/**
* @brief Get properties (like geometry) of one symbol.
* @param baseSymbolCode like '25270100' (2 digits symbol set and 6 digits entity), see SymbolProperties::concreteSidcToBaseSymbolCode
* @return SymbolProperties
* @see SymbolProperties
*/
virtual SymbolProperties symbolProperties(const QString &baseSymbolCode) const = 0;
virtual QSharedPointer<SymbolResult> symbolPropertyImage(const SymbolProperties &symbolProperties, int sizeL = 100) const = 0;
//@}
/*! \name Render symbol: findImage, findPreview, findBaseSymbol*/
//@{
/**
* @brief findImage returns a 'concrete' symbol containing mainIcon, frame, echelon, noPosition etc.
* This is also valid for extraSymbols.
* @param symDataToRender data to render
* @return Instance of class SymbolResult (based on the FuturePattern).
* @internal fullImage containing a coreImage and additionalSymbols
*/
virtual QSharedPointer<SymbolResult> findImage(const SymbolDataToRender &symDataToRender) const = 0;
/**
* @brief findPreview returns an 'abstract' / 'typical' symbol containing mainIcon and frame but no echelon noPosition etc.
* This is also valid for extraSymbols.
* @param sidc sidc to render
* @param sizeL referenceSize to render
* @return Instance of class SymbolResult (based on the FuturePattern).
*/
virtual QSharedPointer<SymbolResult> findPreview(const QString &sidc, int sizeL = 100) const = 0;
/**
* @brief findBaseSymbol returns an 'abstract' / 'typical' symbol containing the and nothing more.
* @param sidc_8or20chars sidc to render
* @return Instance of class SymbolResult (based on the FuturePattern).
*/
virtual QSharedPointer<SymbolResult> findBaseSymbol(const QString &sidc_8or20chars) const = 0;
//@}
/*! \name Fetch
* Similar to findImage, except that fetchSymbol returns a different baseSymbolIcon for multiPoint sidcs.
* In most cases you should prefer findImage, findPreview, findBaseSymbol
*/
//@{
/**
* @brief fetchSymbol for abstract symbols. Use a sidc a input
* Similar to findImage, except that fetchSymbol returns a different baseSymbolIcon for multiPoint sidcs.
* @param sidc to find
* @param sizeL specify the reference size. Named 'L' within the standard.
* @return Instance of class SymbolResult (based on the FuturePattern).
*/
virtual QSharedPointer<SymbolResult> fetchSymbol(const QString &sidc, int sizeL = 100) const = 0;
/**
* @brief fetchSymbol for concrete symbols. Use a sidc a input as well a specific color, injury...
* Similar to findImage, except that fetchSymbol returns a different baseSymbolIcon for multiPoint sidcs.
* @param symDataToRender specify the render hints.
* @return Instance of class SymbolResult (based on the FuturePattern).
*/
virtual QSharedPointer<SymbolResult> fetchSymbol(const SymbolDataToRender &symDataToRender) const = 0;
//@}
/*! \name Handling symbol modifier */
//@{
/**
* @brief Provides a list of all modifier keys
*/
virtual QStringList symbolModifierKeys() const = 0;
/**
* @brief Get modifier data according to a modifier key
* @param key One modifier key returned from symbolModifierKeys()
* @param modifierData Reference to return symbol set of the modifier
* @return true on success in other case false
*/
virtual bool symbolModifierData(const QString &key, ModifierData &data) const = 0;
/**
* @brief Provides a list of all modifiers matching to a symbolSet
* @param symbolSet symbol set
* @param modifierSector sector of the modifier, range of values [1,2]
* @see SymbolSet
*/
virtual QList<ModifierData> symbolModifierList(SidcDefinitions::SymbolSet symbolSet, unsigned int modifierSector) const = 0;
/**
* @brief Overloads the function symbolModifierList( SymbolSet ... ) to provide a list of all modifiers matching to a symbol. The symbol set is
* determined from baseSymbolCode
* @param baseSymbolCode baseSymbolCode like '25270100' (2 digits symbol set and 6 digits entity), see SymbolProperties::concreteSidcToBaseSymbolCode
* @param modifierSector sector of the modifier, range of values [1,2]
* @see SymbolProperties
*/
virtual QList<ModifierData> symbolModifierList(const QString &baseSymbolCode, unsigned int modifierSector) const = 0;
//@}
// virtual QValidator *buildSidcPatternValidator(QObject *parent) const = 0;
/**
* @brief Test one XML symbol
*/
virtual bool insertXmlTestSymbol(const SymbolProperties &symbolProps) = 0;
virtual bool insertXmlComplexTestSymbol(const SymbolProperties &symbolProps) = 0;
//-------------------------------
virtual int count() const = 0;
// virtual const QStringList &sidcList() const = 0;
/**
* @brief createSidc in: abtract sidc, out: concrete sidc:
* @param sidc_inOut
* @param identity
* @param state
*/
// virtual void createSidc(QString &sidc_inOut,
// SymbolTypes::t_affil identity, // friend, neutral... (position 2)
// SymbolTypes::t_state state) const = 0; // present, anticipated (position 4)
// virtual bool contains(const QString &sidc) const = 0;
// virtual SymbolProperties symbolProperties(const QString &sidc) = 0;
// virtual int minNumberOfPoints(const QString &sidc) = 0;
virtual QString toString() const = 0;
Q_SIGNALS:
/// Signal emits when content changed
void changed();
void changedDelayed(); // to avoid multiple signals (delayed for ~500ms)
/// Signal emits when dictionay is loaded
void loaded();
};
void cleanupSymbolDictionaryInternal();
} // namespace AdvancedSymbology
+175
View File
@@ -0,0 +1,175 @@
/**
* @RDE_HEADER@
* Type definition of namespace AdvancedSymbology
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbology_type.h"
#include "sidc_definitions.h"
// Qt
#include <QColor>
#include <QImage>
#include <QPixmap>
class QValidator;
class QUuid;
//----------------------------------------------------------------------------
/**
* Support Advanced Symbology (MIL2525D).
* Some extensions like injury/damage are added to the standard.
* (It is related to SituationMap, but is an independent library.)
*/
namespace AdvancedSymbology
{
//----------------------------------------------------------------------------
enum class Role
{
Pending, ///< 0
Unknown, ///< 1
AssumedFriend, ///< 2
Friend, ///< 3
Neutral, ///< 4
SuspectJoker, ///< 5
HostileFaker ///< 6
};
QString ADVANCED_SYMBOLOGY_EXPORT toString(AdvancedSymbology::Role);
/**
* @brief Enumerates possible load status for a resource (like Dictionary).
*/
enum class LoadStatus
{
Loaded = 0,
Loading = 1,
FailedToLoad = 2,
NotLoaded = 3,
Unknown = -1
};
QString ADVANCED_SYMBOLOGY_EXPORT toString(LoadStatus type);
/**
* @brief Define GeometryType
*/
enum class GeometryType
{
Undefined,
Point,
Polyline,
Polygon
};
inline uint qHash(GeometryType t, uint seed)
{
return ::qHash(static_cast<int>(t), seed);
}
QString ADVANCED_SYMBOLOGY_EXPORT toString(GeometryType gt);
/**
* @brief Constructor.
* @param requested geometry type
* @return min number of points for geometry type
* @note point -> 1 ; line -> 2 ; polygone -> 3
*/
int minNumberOfPoints(GeometryType gt);
/**
* @brief The SearchParameters struct is used for the method searchSymbol.
*/
struct SearchParameters
{
QStringList keys;
bool keysStrictMatch = false;
QStringList names;
bool namesStrictMatch = false;
QStringList categories;
bool categoriesStrictMatch = false;
QStringList symbolClasses;
bool symbolClassesStrictMatch = false;
QStringList tags;
bool tagsStrictMatch = false;
bool isEmpty() const;
int numberOfParameter() const;
};
/**
* @brief The SymbolImage class
* @note QImage has implicit data sharing :-)
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolImage
{
public:
bool isValid() const
{
return m_isValid;
}
void setValid(bool valid)
{
m_isValid = valid;
}
void setImage(const QImage &img)
{
m_image = img;
}
const QImage &image() const
{
return m_image;
}
void reset()
{
m_isValid = false;
m_image = QImage();
}
private:
bool m_isValid = false;
QImage m_image;
// HotSpot can added if required :-)
};
//-----------------------------------------------------------------------------
// output operator:
//-----------------------------------------------------------------------------
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::Role &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::LoadStatus &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::SymbologyType &value);
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::GeometryType &value);
} // namespace AdvancedSymbology
#include "symbol_data_to_render.h"
+156
View File
@@ -0,0 +1,156 @@
/**
* @RDE_HEADER@
* SymbolProperties
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "symbol_properties.h"
#include <SymbologyImpl/advanced_symbology_logging.h> // to get operator<< (std::ostream& stream, const QString& string_ref)
// ESRI
// Qt
#include <QStringRef>
namespace AdvancedSymbology
{
QString SymbolProperties::key() const
{
return m_key;
}
void SymbolProperties::setKey(const QString &key)
{
m_key = key;
}
QString SymbolProperties::name() const
{
return m_name;
}
void SymbolProperties::setName(const QString &name)
{
m_name = name;
}
QString SymbolProperties::category() const
{
return m_category;
}
void SymbolProperties::setCategory(const QString &category)
{
m_category = category;
}
QString SymbolProperties::symbolClass() const
{
return m_symbolClass;
}
void SymbolProperties::setSymbolClass(const QString &symbolClass)
{
m_symbolClass = symbolClass;
}
QStringList SymbolProperties::tags() const
{
return m_tags;
}
QString SymbolProperties::gctString() const
{
for (const QString &tag : m_tags)
{
if (tag.startsWith(QLatin1String("gct_")))
return tag;
} // foreach
return QString();
}
void SymbolProperties::setTags(const QStringList &tags)
{
m_tags = tags;
}
GeometryType SymbolProperties::geometryType() const
{
return m_geometryType;
}
void SymbolProperties::setGeometryType(const GeometryType &geometryType)
{
m_geometryType = geometryType;
}
QString SymbolProperties::sidc() const
{
return m_sidc;
}
void SymbolProperties::setSidc(const QString &sidc)
{
m_sidc = sidc;
}
QString SymbolProperties::originalKey() const
{
return m_originalKey;
}
void SymbolProperties::setOriginalKey(const QString &originalKey)
{
m_originalKey = originalKey;
}
QString SymbolProperties::key_SymbolSet() const
{
if (m_key.count() < 8)
return QString();
return QStringRef(&m_key, 0, 2).toString();
}
QString SymbolProperties::key_Entity() const
{
if (m_key.count() < 8)
return QString();
return QStringRef(&m_key, 2, 6).toString();
}
QString SymbolProperties::key_SymbolSetEntity() const
{
if (m_key.count() < 8)
return QString();
return key_SymbolSet() + key_Entity();
}
QColor SymbolProperties::colorToBeReplaced() const
{
return m_colorToBeReplaced;
}
void SymbolProperties::setColorToBeReplaced(const QColor &colorToBeReplaced)
{
m_colorToBeReplaced = colorToBeReplaced;
}
//-----------------------------------------------------------------------------
} // namespace AdvancedSymbology
+145
View File
@@ -0,0 +1,145 @@
/**
* @RDE_HEADER@
* SymbolProperties
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbol_dictionary_types.h"
// Qt
#include <QStringList>
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
/**
* @brief The SymbolProperties class stores some symbol properties like name, keywords etc.
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolProperties
{
public:
SymbolProperties() = default;
// TODO: sidc: lowerCase vs. upperCase
/*! \name Basic functions*/
//@{
QString key() const;
void setKey(const QString &key);
QString name() const;
void setName(const QString &name);
QString category() const;
void setCategory(const QString &category);
QString symbolClass() const;
void setSymbolClass(const QString &symbolClass);
QStringList tags() const;
QString gctString() const;
void setTags(const QStringList &tags);
GeometryType geometryType() const;
void setGeometryType(const GeometryType &geometryType);
QString sidc() const;
void setSidc(const QString &sidc);
//@}
QString originalKey() const;
void setOriginalKey(const QString &originalKey);
/*! \name Convenience functions*/
//@{
QString key_SymbolSet() const;
QString key_Entity() const;
QString key_SymbolSetEntity() const;
//@}
/*! \name ColorToBeReplaced
* \note Some symbols (like ETS symbols) may have a certain color.
* This is to be replaced by concrete partyColor */
//@{
/**
* @brief colorToBeReplaced
* @return colorToBeReplaced
*/
QColor colorToBeReplaced() const;
/**
* @brief setColorToBeReplaced
* @param colorToBeReplaced
*/
void setColorToBeReplaced(const QColor &colorToBeReplaced);
//@}
// int minNumberOfPoints() const;
/**
* @brief operator== Compare two objects
* @param other to be compared with
* @return true if identical, otherwise false.
*/
bool operator==(const SymbolProperties &other) const
{
return ((this->m_key == other.m_key) &&
(this->m_name == other.m_name) &&
(this->m_category == other.m_category) &&
(this->m_symbolClass == other.m_symbolClass) &&
(this->m_tags == other.m_tags) &&
(this->m_geometryType == other.m_geometryType) &&
(this->m_sidc == other.m_sidc) &&
(this->m_originalKey == other.m_originalKey) &&
(this->m_colorToBeReplaced == other.m_colorToBeReplaced)
);
}
/**
* @brief operator!= Compare two objects
* @param other to be compared with
* @return true if NOT identical, otherwise false.
*/
bool operator!=(const SymbolProperties &other) const
{
return !(*this == other);
}
private :
QString m_key;
QString m_name;
QString m_category;
QString m_symbolClass;
QStringList m_tags;
GeometryType m_geometryType = GeometryType::Undefined;
QString m_sidc;
QString m_originalKey;
QColor m_colorToBeReplaced; // color of ETS symbols to be replaced by concrete partyColor
};
//-----------------------------------------------------------------------------
// output operator:
//-----------------------------------------------------------------------------
} // namespace AdvancedSymbology
+279
View File
@@ -0,0 +1,279 @@
/**
* @RDE_HEADER@
* Class SymbolResult
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "symbol_result.h"
// Qt
#include <QUuid>
#include <QComboBox>
#include <QFutureWatcher>
#include <QTimer>
namespace AdvancedSymbology
{
class SymbolResult::Private
{
public:
Private() = default;
~Private() = default;
// Input data:
SymbolDataToRender m_symDataToRender;
// process data:
QUuid m_taskIdFindSymbol; // of esriDict::findSymbol
QFutureWatcher<QImage> m_futureWatcher;
bool m_isReady = false;
// Result data:
GeometryType m_geometryType = GeometryType::Undefined;
SymbolImage m_symbolImage;
// For debugging:
static unsigned long m_counter;
};
unsigned long SymbolResult::Private::m_counter = 0;
SymbolResult::SymbolResult()
: QObject()
, d(new Private)
, m_logger(getLogger("SymbolResult"))
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START, m_counter=" << d->m_counter;
++Private::m_counter;
connect(&d->m_futureWatcher, &QFutureWatcherBase::finished, this, &SymbolResult::onFinished);
TRACE_LOG(m_logger) << LOGFUNCTION << " END, m_counter=" << d->m_counter;
}
SymbolResult::~SymbolResult()
{
LOGGER_T m_logger = getLogger("SymbolResult");
TRACE_LOG(m_logger) << LOGFUNCTION << " START, m_counter=" << d->m_counter;
--Private::m_counter;
d->m_futureWatcher.disconnect(this);
d->m_futureWatcher.cancel();
d->m_futureWatcher.waitForFinished();
delete d;
TRACE_LOG(m_logger) << LOGFUNCTION << " END, m_counter=" << Private::m_counter;
}
void SymbolResult::onFinished()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
const QImage &image = d->m_futureWatcher.future().result();
d->m_symbolImage.setImage(image);
d->m_symbolImage.setValid(true);
fireResultReady();
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
void SymbolResult::fireResultReady()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
d->m_isReady = true; // Future can`t manually be set to 'ready' :-(
emit resultReadyInternal();
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
void SymbolResult::setSymbolDataToRender(const SymbolDataToRender &symDataToRender)
{
d->m_symDataToRender = symDataToRender;
}
const SymbolDataToRender &SymbolResult::symbolDataToRender() const
{
return d->m_symDataToRender;
}
void SymbolResult::setTaskId(const QUuid &uuid)
{
d->m_taskIdFindSymbol = uuid;
}
const QUuid &SymbolResult::taskId() const
{
return d->m_taskIdFindSymbol;
}
void SymbolResult::setFuture(const QFuture<QImage> &future)
{
d->m_isReady = false;
d->m_futureWatcher.setFuture(future);
}
void SymbolResult::setGeometryType(GeometryType geometryType)
{
d->m_geometryType = geometryType;
}
GeometryType SymbolResult::geometryType() const
{
return d->m_geometryType;
}
void SymbolResult::setSymbolImage(const SymbolImage &symbolImage)
{
d->m_symbolImage = symbolImage;
}
SymbolImage SymbolResult::symbolImage() const
{
return d->m_symbolImage;
}
bool SymbolResult::isResultReady() const
{
// Do not or 'd->m_futureWatcher.future().isResultReadyAt(0)' will lead to timing problems
// When d->m_futureWatcher.future() is ready, the according slot will set d->m_isReady.
return d->m_isReady;
}
//------------------------------------------------------------------------------
// SymbolResultWatcher
//------------------------------------------------------------------------------
SymbolResultWatcher::SymbolResultWatcher(QObject *parent)
: BaseClass(parent)
, m_logger(getLogger("SymbolResultWatcher"))
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
QSharedPointer<SymbolResult> SymbolResultWatcher::symbolResult() const
{
return BaseClass::result();
}
void SymbolResultWatcher::setSymbolResult(const QSharedPointer<SymbolResult> &symbolResult)
{
BaseClass::setResult(symbolResult);
}
//------------------------------------------------------------------------------
// SymbolResultWatcherComboxBox
//------------------------------------------------------------------------------
SymbolResultWatcherComboxBox::SymbolResultWatcherComboxBox(QComboBox *comboBox, int role)
: QObject(comboBox),
m_comboBox(comboBox),
m_role(role)
{
connect(&m_watcher, &AdvancedSymbology::SymbolResultWatcher::resultReady,
this, &SymbolResultWatcherComboxBox::onResultReady);
}
void SymbolResultWatcherComboxBox::setSymbolResult(const QSharedPointer<AdvancedSymbology::SymbolResult> &symbolResult)
{
m_watcher.setSymbolResult(symbolResult);
}
void SymbolResultWatcherComboxBox::onResultReady()
{
QSharedPointer<AdvancedSymbology::SymbolResult> symResult = m_watcher.symbolResult();
if (! symResult)
return; // should NEVER happen! (Which object should have triggered the signal???)
int idx = m_comboBox->findData(QVariant::fromValue(this), m_role);
const QImage &img = symResult->symbolImage().image();
m_comboBox->setItemIcon(idx, QPixmap::fromImage(img));
if (m_enableToolTip && !img.isNull())
{
QString tooltip(QStringLiteral("<html>"));
// without a temporary file:
QByteArray baData;
QBuffer buffer(&baData);
img.save(&buffer, "PNG", 100);
tooltip.append(QStringLiteral("<center><img src='data:image/png;base64,%1'></center>").arg(QString::fromLatin1(baData.toBase64()))); // how can i center the image?
tooltip.append(QStringLiteral("</html>"));
m_comboBox->setItemData(idx, tooltip, Qt::ToolTipRole);
}
}
//------------------------------------------------------------------------------
// for convenience (QWidget)
//------------------------------------------------------------------------------
SymbolResultWatcherQWidgetBase::SymbolResultWatcherQWidgetBase(QObject *widget)
: BaseClass(widget)
{
connect(&m_watcher, &AdvancedSymbology::SymbolResultWatcher::resultReady,
this, &SymbolResultWatcherQWidgetBase::onResultReady);
}
void SymbolResultWatcherQWidgetBase::setSymbolResult(const QSharedPointer<AdvancedSymbology::SymbolResult> &symbolResult)
{
m_watcher.setSymbolResult(symbolResult);
}
QSharedPointer<SymbolResult> SymbolResultWatcherQWidgetBase::symbolResult() const
{
return m_watcher.symbolResult();
}
void SymbolResultWatcherQWidgetBase::onResultReady()
{
this->onResultReadyImpl();
emit resultReady();
}
//------------------------------------------------------------------------------
// SymbolResultWatcherLabel
//------------------------------------------------------------------------------
SymbolResultWatcherLabel::SymbolResultWatcherLabel(QLabel *label, const QSize &size)
: QObject(label)
, m_size(size)
, m_label(label)
{
connect(&m_watcher, &AdvancedSymbology::SymbolResultWatcher::resultReady,
this, &SymbolResultWatcherLabel::onResultReady);
}
void SymbolResultWatcherLabel::setSymbolResult(const QSharedPointer<AdvancedSymbology::SymbolResult> &symbolResult)
{
m_watcher.setSymbolResult(symbolResult);
}
void SymbolResultWatcherLabel::onResultReady()
{
QSharedPointer<AdvancedSymbology::SymbolResult> symResult = m_watcher.symbolResult();
if (!symResult)
return; // should NEVER happen! (Which object should have triggered the signal???)
const SymbolImage &symImage = symResult->symbolImage();
const auto dpr = m_label->devicePixelRatioF();
QImage image = symImage.image().scaled(m_size * dpr, Qt::KeepAspectRatio, Qt::SmoothTransformation);
image.setDevicePixelRatio(dpr);
m_label->setPixmap(QPixmap::fromImage(std::move(image)));
}
} // namespace AdvancedSymbology
+343
View File
@@ -0,0 +1,343 @@
/**
* @RDE_HEADER@
* Class SymbolResult
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
#include "symbol_dictionary_types.h"
#include <SymbologyImpl/advanced_symbology_logging.h>
#include "result_watcher.h"
// Qt
#include <QObject>
#include <QImage>
#include <QLabel>
#include <QFuture>
#include <QSize>
#include <QBuffer>
#include <QElapsedTimer>
// forward
class QUuid;
class QComboBox;
//----------------------------------------------------------------------------
namespace AdvancedSymbology
{
/**
* @brief The SymbolResult class mainly contains a GeometryType and a SymbolImage.
* It´s based on the future pattern. So the real result can only be retrieved if
* the asynchron operation has finished (and the result is ready).
* To standardize this you should use a propper watcher: SymbolResultWatcher.
*
* \sa \ref secResultWatcherExample
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolResult : public QObject
{
Q_OBJECT
/*! \name Construction, Destruction */
//@{
public:
/**
* @brief Constructor / Destructor.
*/
explicit SymbolResult();
virtual ~SymbolResult();
//@}
/*! \name Data regarding requested */
//@{
/**
* @brief symbolDataToRender What was requested?
* @return Requested data
*/
const SymbolDataToRender &symbolDataToRender() const;
//@}
/*! \name Data regarding processing*/
//@{
/**
* @brief taskId internal taskId
* @return internal taskId
*/
const QUuid &taskId() const;
/*! \name Data regarding result*/
//@{
/**
* @brief Get geometryType of request
* @return Geometry type
*/
GeometryType geometryType() const;
/**
* @brief Get symbol image
* @return symbol image
*/
SymbolImage symbolImage() const;
//@}
bool isResultReady() const;
Q_SIGNALS:
/// This signal is for internal usage only. Use SymbolResultWatcher!
void resultReadyInternal();
protected:
friend class SymbolDictionaryImpl;
friend class EsriDictionaryProcessor;
friend class BaseSymbolModel;
void fireResultReady();
friend class ResultWatcher<SymbolResult>;
friend class SymbolResultWatcher;
void setSymbolDataToRender(const SymbolDataToRender &symDataToRender);
void setTaskId(const QUuid &uuid);
void setFuture(const QFuture<QImage> &future);
void setGeometryType(GeometryType geometryType);
void setSymbolImage(const SymbolImage &symbolImage);
protected Q_SLOTS:
void onFinished();
private:
class Private;
/**
* The private d->pointer to not break BC when changing internals of this class
*/
Private *d = nullptr;
LOGGER_T m_logger; ///< Interface of the Logging-Facility
};
//------------------------------------------------------------------------------
/**
* @brief The SymbolResultWatcher class can watch one SymbolResult using setSymbolResult.
* If the background operation has finished, the signal resultReady is emitted exactly one time.
*
* \sa \ref secResultWatcherExample
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolResultWatcher : public ResultWatcher<SymbolResult>
{
Q_OBJECT
using BaseClass = ResultWatcher<SymbolResult>;
public:
explicit SymbolResultWatcher(QObject *parent = nullptr);
~SymbolResultWatcher() = default;
QSharedPointer<SymbolResult> symbolResult() const;
void setSymbolResult(const QSharedPointer<SymbolResult> &symbolResult);
QElapsedTimer *m_et { nullptr };
protected:
LOGGER_T m_logger; ///< Interface of the Logging-Facility
};
//------------------------------------------------------------------------------
// for convenience (ComboxBox)
//------------------------------------------------------------------------------
/**
* @brief The SymbolResultWatcherComboxBox class can be used to combine a comboBox
* and an infinite number of item containing an icon.
*
* Here is an example:
*
* \code
* AdvancedSymbology::SymbolResultWatcherComboxBox *srwCb;
foreach(auto sidc, sidcs)
{
// SymbolResultWatcherComboxBox is stored as userData at every item.
// The lifetime is limited to the lifetime of the comboBox since it`s the parent.
d->m_cbRubSidc->addItem(sidc, QVariant::fromValue(srwCb = new AdvancedSymbology::SymbolResultWatcherComboxBox(d->m_cbRubSidc)) );
srwCb->setSymbolResult(dict.fetchSymbol(sidc));
}
* \endcode
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolResultWatcherComboxBox : public QObject
{
Q_OBJECT
public:
explicit SymbolResultWatcherComboxBox(QComboBox *comboBox, int role = Qt::UserRole);
void setSymbolResult(const QSharedPointer<SymbolResult> &symbolResult);
/**
* @brief enableToolTip of each entry
* @param on
*/
void enableToolTip(bool on = true) { m_enableToolTip = on; }
bool isToolTipEnabled() { return m_enableToolTip; }
private slots:
void onResultReady();
private:
QComboBox *m_comboBox{nullptr};
AdvancedSymbology::SymbolResultWatcher m_watcher;
int m_role{Qt::UserRole};
bool m_enableToolTip{true};
};
//------------------------------------------------------------------------------
// for convenience (QWidget)
//------------------------------------------------------------------------------
/**
* @brief The SymbolResultWatcherQWidgetBase class can be used with a QWidget,
* most of the time a LtsWidgets::LtsDragIcon.
* Required is a method 'setIcon(const QPixmap &pixmap)'
*
* Here is an example:
*
* \code
LtsWidgets::LtsDragIcon *dummyIcon = new LtsWidgets::LtsDragIcon(this);
AdvancedSymbology::SymbolResultWatcherQWidgetBase *dummyIconSibling =
new AdvancedSymbology::SymbolResultWatcherQWidget<LtsWidgets::LtsDragIcon>(dummyIcon);
AdvancedSymbology::SymbolDictionary &dict = d->m_mapImpl->symbolDictionary();
dummyIconSibling->setSymbolResult(dict.fetchSymbol(SidcCodec::encodeComplete(SymbologyType::MIL2525D,"10042500001401040000")));
* \endcode
* This sibling define the lifetime.
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolResultWatcherQWidgetBase : public QObject
{
Q_OBJECT
using BaseClass = QObject;
public:
explicit SymbolResultWatcherQWidgetBase(QObject *widget);
void setSymbolResult(const QSharedPointer<SymbolResult> &symbolResult);
QSharedPointer<AdvancedSymbology::SymbolResult> symbolResult() const;
private slots:
void onResultReady();
signals:
void resultReady();
protected:
virtual void onResultReadyImpl() = 0;
AdvancedSymbology::SymbolResultWatcher m_watcher;
};
template <typename PARENT_TYPE>
class SymbolResultWatcherQWidget : public SymbolResultWatcherQWidgetBase
{
using BaseClass = SymbolResultWatcherQWidgetBase;
public:
explicit SymbolResultWatcherQWidget(PARENT_TYPE *parentWidget, const QSize &size = QSize())
: BaseClass(parentWidget)
, m_size(size)
, m_parentWidget(parentWidget)
{}
private:
void onResultReadyImpl() override
{
if (!m_parentWidget)
return;
QSharedPointer<AdvancedSymbology::SymbolResult> symResult = m_watcher.symbolResult();
if (!symResult)
return; // should NEVER happen! (Which object should have triggered the signal???)
const SymbolImage &symImage = symResult->symbolImage();
const auto dpr = m_parentWidget->devicePixelRatioF();
QImage imgCopy;
if (m_size.isValid())
imgCopy = symImage.image().scaled(m_size * dpr, Qt::KeepAspectRatio, Qt::SmoothTransformation);
else
imgCopy = symImage.image();
imgCopy.setDevicePixelRatio(dpr);
m_parentWidget->setIcon(QPixmap::fromImage(std::move(imgCopy)));
{
QString tooltip;
QByteArray data;
QBuffer buffer(&data);
// XML-Symbol with scale = 4 will produce huge images. Limit the size:
symImage.image().scaled(QSize(300, 300), Qt::KeepAspectRatio, Qt::SmoothTransformation).save(&buffer, "PNG", 100);
tooltip = QStringLiteral("<html>");
tooltip += QStringLiteral("<center>");
tooltip += QStringLiteral("<img src='data:image/png;base64,%1'>").arg(QString::fromLatin1(data.toBase64()));
tooltip += QStringLiteral("</center>");
tooltip += QStringLiteral("<center>");
tooltip += symResult->symbolDataToRender().sidc;
tooltip += QStringLiteral("</center>");
tooltip += QStringLiteral("<hr>");
tooltip += QStringLiteral("</html>");
m_parentWidget->setToolTip(tooltip);
}
}
QSize m_size;
PARENT_TYPE *m_parentWidget;
};
//------------------------------------------------------------------------------
// for convenience (QLabel)
//------------------------------------------------------------------------------
/**
* @brief The SymbolResultWatcherLabel class can be used to combine a QLabel
* Here is an example:
*
* \code
* QLabel *label = new QLabel(this);
* AdvancedSymbology::SymbolResultWatcherLabel *symbolLabelWatcher(label);
*
*
*
* \endcode
*/
class ADVANCED_SYMBOLOGY_EXPORT SymbolResultWatcherLabel : public QObject
{
Q_OBJECT
public:
explicit SymbolResultWatcherLabel(QLabel *label, const QSize &size = QSize(45, 45));
void setSymbolResult(const QSharedPointer<AdvancedSymbology::SymbolResult> &symbolResult);
private slots:
void onResultReady();
private:
QSize m_size;
QLabel *m_label{nullptr};
AdvancedSymbology::SymbolResultWatcher m_watcher;
};
} // namespace AdvancedSymbology
Q_DECLARE_METATYPE_TEMPLATE_1ARG(AdvancedSymbology::ResultWatcher)
+50
View File
@@ -0,0 +1,50 @@
/**
* @RDE_HEADER@
* Declaration of symbology_type
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
// Own
#include "advanced_symbology_export.h"
// Qt
#include <QObject>
#include <QString>
namespace AdvancedSymbology
{
/*!
* \addtogroup AdvancedSymbology
* Handle the symbology based on MIL2525 and APP6 standard
*/
enum class SymbologyType
{
None,
APP6B = 10,
APP6D = 12,
MIL2525C = 20,
MIL2525D,
};
QString ADVANCED_SYMBOLOGY_EXPORT toString(SymbologyType type);
bool ADVANCED_SYMBOLOGY_EXPORT fromString(SymbologyType &symbologyType, const QString &str);
//-----------------------------------------------------------------------------
// output operator:
//-----------------------------------------------------------------------------
ADVANCED_SYMBOLOGY_EXPORT std::ostream &operator<< (std::ostream &stream,
const AdvancedSymbology::SymbologyType &value);
} // namespace AdvancedSymbology
Q_DECLARE_METATYPE(AdvancedSymbology::SymbologyType)