1 /*************************************************************************** 2 qgsmapinfosymbolconverter.h 3 -------------------------------------- 4 Date : March 2021 5 Copyright : (C) 2021 by Nyall Dawson 6 Email : nyall dot dawson at gmail dot com 7 *************************************************************************** 8 * * 9 * This program is free software; you can redistribute it and/or modify * 10 * it under the terms of the GNU General Public License as published by * 11 * the Free Software Foundation; either version 2 of the License, or * 12 * (at your option) any later version. * 13 * * 14 ***************************************************************************/ 15 16 #ifndef QGSMAPINFOSYMBOLCONVERTER_H 17 #define QGSMAPINFOSYMBOLCONVERTER_H 18 19 #include "qgis_core.h" 20 #include "qgis_sip.h" 21 #include "qgsunittypes.h" 22 #include <QStringList> 23 #include <QColor> 24 25 class QgsLineSymbol; 26 class QgsFillSymbol; 27 class QgsMarkerSymbol; 28 29 /** 30 * Context for a MapInfo symbol conversion operation. 31 * \warning This is private API only, and may change in future QGIS versions 32 * \ingroup core 33 * \since QGIS 3.20 34 */ 35 class CORE_EXPORT QgsMapInfoSymbolConversionContext 36 { 37 public: 38 39 /** 40 * Pushes a \a warning message generated during the conversion. 41 */ 42 void pushWarning( const QString &warning ); 43 44 /** 45 * Returns a list of warning messages generated during the conversion. 46 */ warnings()47 QStringList warnings() const { return mWarnings; } 48 49 /** 50 * Clears the list of warning messages. 51 */ clearWarnings()52 void clearWarnings() { mWarnings.clear(); } 53 54 private: 55 56 QStringList mWarnings; 57 58 }; 59 60 /** 61 * \ingroup core 62 * \brief Handles conversion of MapInfo symbols to QGIS symbology. 63 * 64 * \since QGIS 3.20 65 */ 66 class CORE_EXPORT QgsMapInfoSymbolConverter 67 { 68 public: 69 70 /** 71 * Converts the MapInfo line symbol with the specified \a identifier to a QgsLineSymbol. 72 * 73 * The caller takes ownership of the returned symbol. 74 */ 75 static QgsLineSymbol *convertLineSymbol( int identifier, QgsMapInfoSymbolConversionContext &context, const QColor &foreColor, double size, QgsUnitTypes::RenderUnit sizeUnit, bool interleaved = false ) SIP_FACTORY; 76 77 /** 78 * Converts the MapInfo fill symbol with the specified \a identifier to a QgsFillSymbol. 79 * 80 * The caller takes ownership of the returned symbol. 81 */ 82 static QgsFillSymbol *convertFillSymbol( int identifier, QgsMapInfoSymbolConversionContext &context, const QColor &foreColor, const QColor &backColor = QColor() ) SIP_FACTORY; 83 84 /** 85 * Converts the MapInfo marker symbol with the specified \a identifier to a QgsMarkerSymbol. 86 * 87 * This method will convert a MapInfo "MapInfo 3.0 Compatible" symbol with a specific \a identifier to a QgsMarkerSymbol. 88 * 89 * The caller takes ownership of the returned symbol. 90 */ 91 static QgsMarkerSymbol *convertMarkerSymbol( int identifier, QgsMapInfoSymbolConversionContext &context, const QColor &color, double size, QgsUnitTypes::RenderUnit sizeUnit ) SIP_FACTORY; 92 93 }; 94 95 #endif // QGSMAPINFOSYMBOLCONVERTER_H 96