Files
qt5-legatus-legacy/Lts/Viewer/SituationMap/Symbology/symbol_dictionary.h
T
2026-08-13 18:33:10 +02:00

419 lines
15 KiB
C++
Executable File

/**
* @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