QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
vectorfield
qgsvectorfieldarrowsettings.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsvectorfieldarrowsettings.cpp
3
---------------------
4
begin : September 2026
5
copyright : (C) 2026 by Stefanos Natsis
6
email : uclaros 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 "
qgsvectorfieldarrowsettings.h
"
17
18
#include <QString>
19
20
using namespace
Qt::StringLiterals;
21
22
Qgis::VectorFieldArrowScalingMethod
QgsVectorFieldArrowSettings::shaftLengthMethod
()
const
23
{
24
return
mShaftLengthMethod;
25
}
26
27
void
QgsVectorFieldArrowSettings::setShaftLengthMethod
(
Qgis::VectorFieldArrowScalingMethod
shaftLengthMethod
)
28
{
29
mShaftLengthMethod =
shaftLengthMethod
;
30
}
31
32
double
QgsVectorFieldArrowSettings::minShaftLength
()
const
33
{
34
return
mMinShaftLength;
35
}
36
37
void
QgsVectorFieldArrowSettings::setMinShaftLength
(
double
minShaftLength
)
38
{
39
mMinShaftLength =
minShaftLength
;
40
}
41
42
double
QgsVectorFieldArrowSettings::maxShaftLength
()
const
43
{
44
return
mMaxShaftLength;
45
}
46
47
void
QgsVectorFieldArrowSettings::setMaxShaftLength
(
double
maxShaftLength
)
48
{
49
mMaxShaftLength =
maxShaftLength
;
50
}
51
52
double
QgsVectorFieldArrowSettings::scaleFactor
()
const
53
{
54
return
mScaleFactor;
55
}
56
57
void
QgsVectorFieldArrowSettings::setScaleFactor
(
double
scaleFactor
)
58
{
59
mScaleFactor =
scaleFactor
;
60
}
61
62
double
QgsVectorFieldArrowSettings::fixedShaftLength
()
const
63
{
64
return
mFixedShaftLength;
65
}
66
67
void
QgsVectorFieldArrowSettings::setFixedShaftLength
(
double
fixedShaftLength
)
68
{
69
mFixedShaftLength =
fixedShaftLength
;
70
}
71
72
double
QgsVectorFieldArrowSettings::arrowHeadWidthRatio
()
const
73
{
74
return
mArrowHeadWidthRatio;
75
}
76
77
void
QgsVectorFieldArrowSettings::setArrowHeadWidthRatio
(
double
vectorHeadWidthRatio )
78
{
79
mArrowHeadWidthRatio = vectorHeadWidthRatio;
80
}
81
82
double
QgsVectorFieldArrowSettings::arrowHeadLengthRatio
()
const
83
{
84
return
mArrowHeadLengthRatio;
85
}
86
87
void
QgsVectorFieldArrowSettings::setArrowHeadLengthRatio
(
double
vectorHeadLengthRatio )
88
{
89
mArrowHeadLengthRatio = vectorHeadLengthRatio;
90
}
91
92
QDomElement
QgsVectorFieldArrowSettings::writeXml
( QDomDocument &doc )
const
93
{
94
QDomElement elem = doc.createElement( u
"vector-arrow-settings"
_s );
95
elem.setAttribute( u
"arrow-head-width-ratio"
_s, mArrowHeadWidthRatio );
96
elem.setAttribute( u
"arrow-head-length-ratio"
_s, mArrowHeadLengthRatio );
97
98
QDomElement elemShaft = doc.createElement( u
"shaft-length"
_s );
99
QString methodTxt;
100
switch
( mShaftLengthMethod )
101
{
102
case
Qgis::VectorFieldArrowScalingMethod::MinMax
:
103
methodTxt = u
"minmax"
_s;
104
elemShaft.setAttribute( u
"min"
_s, mMinShaftLength );
105
elemShaft.setAttribute( u
"max"
_s, mMaxShaftLength );
106
break
;
107
case
Qgis::VectorFieldArrowScalingMethod::Scaled
:
108
methodTxt = u
"scaled"
_s;
109
elemShaft.setAttribute( u
"scale-factor"
_s, mScaleFactor );
110
break
;
111
case
Qgis::VectorFieldArrowScalingMethod::Fixed
:
112
methodTxt = u
"fixed"
_s;
113
elemShaft.setAttribute( u
"fixed-length"
_s, mFixedShaftLength );
114
break
;
115
}
116
elemShaft.setAttribute( u
"method"
_s, methodTxt );
117
elem.appendChild( elemShaft );
118
return
elem;
119
}
120
121
void
QgsVectorFieldArrowSettings::readXml
(
const
QDomElement &elem )
122
{
123
mArrowHeadWidthRatio = elem.attribute( u
"arrow-head-width-ratio"
_s ).toDouble();
124
mArrowHeadLengthRatio = elem.attribute( u
"arrow-head-length-ratio"
_s ).toDouble();
125
126
const
QDomElement elemShaft = elem.firstChildElement( u
"shaft-length"
_s );
127
const
QString methodTxt = elemShaft.attribute( u
"method"
_s );
128
if
( u
"minmax"
_s == methodTxt )
129
{
130
mShaftLengthMethod =
Qgis::VectorFieldArrowScalingMethod::MinMax
;
131
mMinShaftLength = elemShaft.attribute( u
"min"
_s ).toDouble();
132
mMaxShaftLength = elemShaft.attribute( u
"max"
_s ).toDouble();
133
}
134
else
if
( u
"scaled"
_s == methodTxt )
135
{
136
mShaftLengthMethod =
Qgis::VectorFieldArrowScalingMethod::Scaled
;
137
mScaleFactor = elemShaft.attribute( u
"scale-factor"
_s ).toDouble();
138
}
139
else
// fixed
140
{
141
mShaftLengthMethod =
Qgis::VectorFieldArrowScalingMethod::Fixed
;
142
mFixedShaftLength = elemShaft.attribute( u
"fixed-length"
_s ).toDouble();
143
}
144
}
Qgis::VectorFieldArrowScalingMethod
VectorFieldArrowScalingMethod
Algorithm to transform vector magnitude to length of arrow on the device in pixels.
Definition
qgis.h:7219
Qgis::VectorFieldArrowScalingMethod::Fixed
@ Fixed
Use fixed length fixedShaftLength() regardless of vector's magnitude.
Definition
qgis.h:7222
Qgis::VectorFieldArrowScalingMethod::Scaled
@ Scaled
Scale vector magnitude by factor scaleFactor().
Definition
qgis.h:7221
Qgis::VectorFieldArrowScalingMethod::MinMax
@ MinMax
Scale vector magnitude linearly to fit in range of vectorFilterMin() and vectorFilterMax().
Definition
qgis.h:7220
QgsVectorFieldArrowSettings::writeXml
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
Definition
qgsvectorfieldarrowsettings.cpp:92
QgsVectorFieldArrowSettings::setFixedShaftLength
void setFixedShaftLength(double fixedShaftLength)
Sets fixed length (in millimeters).
Definition
qgsvectorfieldarrowsettings.cpp:67
QgsVectorFieldArrowSettings::minShaftLength
double minShaftLength() const
Returns mininimum shaft length (in millimeters).
Definition
qgsvectorfieldarrowsettings.cpp:32
QgsVectorFieldArrowSettings::shaftLengthMethod
Qgis::VectorFieldArrowScalingMethod shaftLengthMethod() const
Returns method used for drawing arrows.
Definition
qgsvectorfieldarrowsettings.cpp:22
QgsVectorFieldArrowSettings::readXml
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
Definition
qgsvectorfieldarrowsettings.cpp:121
QgsVectorFieldArrowSettings::setMinShaftLength
void setMinShaftLength(double minShaftLength)
Sets mininimum shaft length (in millimeters).
Definition
qgsvectorfieldarrowsettings.cpp:37
QgsVectorFieldArrowSettings::arrowHeadLengthRatio
double arrowHeadLengthRatio() const
Returns ratio of the head length of the arrow (range 0-1).
Definition
qgsvectorfieldarrowsettings.cpp:82
QgsVectorFieldArrowSettings::setShaftLengthMethod
void setShaftLengthMethod(Qgis::VectorFieldArrowScalingMethod shaftLengthMethod)
Sets method used for drawing arrows.
Definition
qgsvectorfieldarrowsettings.cpp:27
QgsVectorFieldArrowSettings::setScaleFactor
void setScaleFactor(double scaleFactor)
Sets scale factor.
Definition
qgsvectorfieldarrowsettings.cpp:57
QgsVectorFieldArrowSettings::fixedShaftLength
double fixedShaftLength() const
Returns fixed arrow length (in millimeters).
Definition
qgsvectorfieldarrowsettings.cpp:62
QgsVectorFieldArrowSettings::setArrowHeadWidthRatio
void setArrowHeadWidthRatio(double arrowHeadWidthRatio)
Sets ratio of the head width of the arrow (range 0-1).
Definition
qgsvectorfieldarrowsettings.cpp:77
QgsVectorFieldArrowSettings::setMaxShaftLength
void setMaxShaftLength(double maxShaftLength)
Sets maximum shaft length (in millimeters).
Definition
qgsvectorfieldarrowsettings.cpp:47
QgsVectorFieldArrowSettings::arrowHeadWidthRatio
double arrowHeadWidthRatio() const
Returns ratio of the head width of the arrow (range 0-1).
Definition
qgsvectorfieldarrowsettings.cpp:72
QgsVectorFieldArrowSettings::maxShaftLength
double maxShaftLength() const
Returns maximum shaft length (in millimeters).
Definition
qgsvectorfieldarrowsettings.cpp:42
QgsVectorFieldArrowSettings::scaleFactor
double scaleFactor() const
Returns scale factor.
Definition
qgsvectorfieldarrowsettings.cpp:52
QgsVectorFieldArrowSettings::setArrowHeadLengthRatio
void setArrowHeadLengthRatio(double arrowHeadLengthRatio)
Sets ratio of the head length of the arrow (range 0-1).
Definition
qgsvectorfieldarrowsettings.cpp:87
qgsvectorfieldarrowsettings.h
Generated on
for QGIS API Documentation by
1.17.0