/** * @RDE_HEADER@ * Interface-Implementation of EsriDictionaryProcessor * $Id$ * $HeadURL$ * $Author$ */ #pragma once // Own #include // Our interface "SymbolDictionary" #include "advanced_symbology_logging.h" #include #include // Qt #include // Esri #include //---------------------------------------------------------------------------- namespace AdvancedSymbology { struct createSwatchParameter { static constexpr int m_width = 128; static constexpr int m_height = 64; static constexpr float m_screenScale = 2; }; static constexpr createSwatchParameter CREATE_SWATCH_PARAMETER = createSwatchParameter(); static constexpr float CREATE_SWATCH_SCREEN_SCALE = 5; QImage scaleImage(const QImage &image, int sizeL = 100); /** * @brief The EsriDictionaryProcessor class analyses the stylx files of ESRI. * The process is seperated: * Setup: The EsriDictionaryProcessor has to be set up with the desired * SymbologyType and initialized with the loaded raw Esri::ArcGISRuntime::DictionarySymbolStyle. * Step 1: * Search all from esri_dictionary (prepare) * When this is finished, * Step 2: * For all results the associated Esri::ArcGISRuntime:Symbol has to be retrieved. * This has to be done in the mainThread (syncTableWithinMainThread). * Step 3: * The single jobs can be triggered and performed in seperate threads: * Job 1: startBaseSymbolCodeToPropertyTable(); * Job 2: startModifierTable(); * And the end of each job it´s checked if all jobs are finished (checkIfAllAreDone). * If so the signal allIsDone is emitted. * * Now the BaseSymbolCodeToPropertyTableFinished and the ModifierTable is prepared. */ class EsriDictionaryProcessor : public QObject { Q_OBJECT public: /*! \name Construction, Destruction */ //@{ explicit EsriDictionaryProcessor(SymbologyType symbologyType); virtual ~EsriDictionaryProcessor(); void cancel(); void waitForFinished(); //@} virtual bool searchResultIsValid(const QHash &key8LookupTable, const Esri::ArcGISRuntime::SymbolStyleSearchResult &resultItem, QString *toBeRemovedFromName = nullptr) = 0; // // Common: // /*! \name Common */ //@{ void init(Esri::ArcGISRuntime::DictionarySymbolStyle *loaded_esri_dictionary); void prepare(); protected: //@} // // Job 1: BaseSymbolCodeToPropertyTable // public: /*! \name Job 1: BaseSymbolCodeToPropertyTable */ //@{ void startBaseSymbolCodeToPropertyTable(); virtual bool processBaseSymbolCodeToPropertyTable() = 0; bool baseSymbolCodeToPropertyTableFinished() { return m_baseSymbolCodeToSymbolPropertyTableFilled; } const SidcCodec::SidcHashTable baseSymbolCodeToSymbolPropertyTable() const { return m_baseSymbolCodeToSymbolPropertyTable; } //@} // // Job 2: ModifierTable // public: /*! \name Job 2: ModifierTable */ //@{ void startModifierTable(); virtual bool processModifierTable() = 0; bool modifierTableFinished() { return m_modifierTableFilled; } QStringList symbolModifierKeys() const; bool symbolModifierData(const QString &key, ModifierData &data) const; QVector symbolModifierList(SidcDefinitions::SymbolSet symbolSet, unsigned int modifierSector) const; //@} // // Job n: // public: // // common final: // public: bool allJobsDone() const; Q_SIGNALS: void allIsDone(); void baseSymbolCodeToPropertyTableDone(); void modifierTableDone(); protected Q_SLOTS: void onSearchSymbolsCompletedPropertyTable(QUuid /*ssTaskId*/, Esri::ArcGISRuntime::SymbolStyleSearchResultListModel *searchResults); void onEsriSymbolSwatchCompleted(const QUuid &csTaskId, const QImage &image); protected: void checkIfAllAreDone(); void searchSymbols(); void syncTableWithinMainThread(); // // Common // LOGGER_T m_logger; ///< Interface of the Logging-Facility Esri::ArcGISRuntime::DictionarySymbolStyle *m_esri_dictionary = nullptr; QList m_searchResultList; QList m_searchResultListValid; // originalKey struct EsriSymbol { Esri::ArcGISRuntime::SymbolStyleSearchResult m_sssResult; mutable Esri::ArcGISRuntime::Symbol *esriSymbol = nullptr; mutable QImage swatchImage; }; QHash m_originalKeyToEsriSymbol; // symbolPropertyImage-Uuid -> SymbolResult mutable QMap> m_symbolPropertyImage2symbolResult; public: bool symbolPropertyImageContains(const QString &originalKey) const; QSharedPointer symbolPropertyImage(QSharedPointer symResult, const QString &originalKey) const; const QList & getSearchResultList() const { return m_searchResultList; } const QList & getSearchResultListValid() const { return m_searchResultListValid; } protected: // // Job 1: baseSymbolCodeToSymbolPropertyTable: // SidcCodec::SidcHashTable m_baseSymbolCodeToSymbolPropertyTable; bool m_baseSymbolCodeToSymbolPropertyTableFilled = false; QFuture m_baseSymbolCodeToSymbolPropertyTableWatcher; // // Job 2: // QMap m_modifierTable; bool m_modifierTableFilled = false; QFuture m_modifierTableWatcher; // // Job n: // }; } // namespace AdvancedSymbology