QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
symbology
converters
qgssymbolconverterogrstyle.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgssymbolconverterogrstyle.cpp
3
----------------------
4
begin : February 2026
5
copyright : (C) 2026 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
#include "
qgssymbolconverterogrstyle.h
"
17
18
#include "
qgsogrutils.h
"
19
#include "
qgssymbol.h
"
20
#include "
qgssymbollayerutils.h
"
21
22
#include <QObject>
23
#include <QString>
24
#include <QVariant>
25
26
using namespace
Qt::StringLiterals;
27
28
Qgis::SymbolConverterCapabilities
QgsSymbolConverterOgrStyle::capabilities
()
const
29
{
30
return
Qgis::SymbolConverterCapability::ReadSymbol
;
31
}
32
33
QString
QgsSymbolConverterOgrStyle::name
()
const
34
{
35
return
u
"ogr"
_s;
36
}
37
38
QString
QgsSymbolConverterOgrStyle::formatName
()
const
39
{
40
return
QObject::tr(
"OGR Style String"
);
41
}
42
43
QVariant
QgsSymbolConverterOgrStyle::toVariant
(
const
QgsSymbol
*,
QgsSymbolConverterContext
& )
const
44
{
45
throw
QgsNotSupportedException
( u
"This symbol converter does not support serialization of symbols"
_s );
46
}
47
48
std::unique_ptr< QgsSymbol >
QgsSymbolConverterOgrStyle::createSymbol
(
const
QVariant &variant,
QgsSymbolConverterContext
&context )
const
49
{
50
const
QString styleString = variant.toString();
51
if
( styleString.isEmpty() )
52
return
nullptr
;
53
54
const
Qgis::SymbolType
typeHint = context.
typeHint
();
55
if
( typeHint ==
Qgis::SymbolType::Hybrid
)
56
{
57
context.
pushError
( QObject::tr(
"Hybrid symbol types are not supported by the OGR converter."
) );
58
return
nullptr
;
59
}
60
61
return
QgsOgrUtils::symbolFromStyleString
( styleString, typeHint );
62
}
Qgis::SymbolConverterCapabilities
QFlags< SymbolConverterCapability > SymbolConverterCapabilities
Symbol converter capabilities.
Definition
qgis.h:859
Qgis::SymbolType
SymbolType
Symbol types.
Definition
qgis.h:671
Qgis::SymbolType::Hybrid
@ Hybrid
Hybrid symbol.
Definition
qgis.h:675
Qgis::SymbolConverterCapability::ReadSymbol
@ ReadSymbol
Allows reading symbols from variants.
Definition
qgis.h:848
QgsNotSupportedException
Custom exception class which is raised when an operation is not supported.
Definition
qgsexception.h:111
QgsOgrUtils::symbolFromStyleString
static std::unique_ptr< QgsSymbol > symbolFromStyleString(const QString &string, Qgis::SymbolType type)
Creates a new QgsSymbol matching an OGR style string.
Definition
qgsogrutils.cpp:1599
QgsSymbolConverterContext
Represents the context in which a QgsSymbolConverter conversion occurs.
Definition
qgssymbolconverter.h:35
QgsSymbolConverterContext::typeHint
Qgis::SymbolType typeHint() const
Returns the symbol type hint, or Qgis::SymbolType::Hybrid if unknown.
Definition
qgssymbolconverter.h:86
QgsSymbolConverterContext::pushError
void pushError(const QString &error)
Pushes a error message generated during the conversion.
Definition
qgssymbolconverter.h:63
QgsSymbolConverterOgrStyle::capabilities
Qgis::SymbolConverterCapabilities capabilities() const override
Returns the capabilities of the converter.
Definition
qgssymbolconverterogrstyle.cpp:28
QgsSymbolConverterOgrStyle::createSymbol
std::unique_ptr< QgsSymbol > createSymbol(const QVariant &variant, QgsSymbolConverterContext &context) const override
Creates a new QgsSymbol from a QVariant representation.
Definition
qgssymbolconverterogrstyle.cpp:48
QgsSymbolConverterOgrStyle::name
QString name() const override
Returns the unique name for the converter.
Definition
qgssymbolconverterogrstyle.cpp:33
QgsSymbolConverterOgrStyle::toVariant
QVariant toVariant(const QgsSymbol *symbol, QgsSymbolConverterContext &context) const override
Converts a symbol into a QVariant representation.
Definition
qgssymbolconverterogrstyle.cpp:43
QgsSymbolConverterOgrStyle::formatName
QString formatName() const override
Returns a translated, user-friendly name for the converter's data format.
Definition
qgssymbolconverterogrstyle.cpp:38
QgsSymbol
Abstract base class for all rendered symbols.
Definition
qgssymbol.h:227
qgsogrutils.h
qgssymbol.h
qgssymbolconverterogrstyle.h
qgssymbollayerutils.h
Generated on
for QGIS API Documentation by
1.17.0