File tree Expand file tree Collapse file tree 5 files changed +70
-2
lines changed Expand file tree Collapse file tree 5 files changed +70
-2
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,28 @@ class QgsLayoutContext
97
97
.. seealso:: layer()
98
98
%End
99
99
100
+ void setDpi( double dpi );
101
+ %Docstring
102
+ Sets the ``dpi`` for outputting the layout. This also sets the
103
+ corresponding DPI for the context's measurementConverter().
104
+ .. seealso:: dpi()
105
+ %End
106
+
107
+ double dpi() const;
108
+ %Docstring
109
+ Returns the ``dpi`` for outputting the layout.
110
+ .. seealso:: setDpi()
111
+ :rtype: float
112
+ %End
113
+
114
+
115
+ QgsLayoutMeasurementConverter &measurementConverter();
116
+ %Docstring
117
+ Returns the layout measurement converter to be used in the layout. This converter is used
118
+ for translating between other measurement units and the layout's native unit.
119
+ :rtype: QgsLayoutMeasurementConverter
120
+ %End
121
+
100
122
};
101
123
102
124
Original file line number Diff line number Diff line change @@ -672,7 +672,6 @@ SET(QGIS_CORE_MOC_HDRS
672
672
gps/qgsgpsdconnection.h
673
673
674
674
layout/qgslayout.h
675
- layout/qgslayoutcontext.h
676
675
layout/qgslayoutitem.h
677
676
layout/qgslayoutitemregistry.h
678
677
layout/qgslayoutobject.h
@@ -918,7 +917,7 @@ SET(QGIS_CORE_HDRS
918
917
composer/qgscomposertexttable.h
919
918
composer/qgspaperitem.h
920
919
921
- layout/qgslayout .h
920
+ layout/qgslayoutcontext .h
922
921
layout/qgslayoutmeasurement.h
923
922
layout/qgslayoutmeasurementconverter.h
924
923
layout/qgspagesizeregistry.h
Original file line number Diff line number Diff line change @@ -54,3 +54,13 @@ void QgsLayoutContext::setLayer( QgsVectorLayer *layer )
54
54
{
55
55
mLayer = layer;
56
56
}
57
+
58
+ void QgsLayoutContext::setDpi ( double dpi )
59
+ {
60
+ mMeasurementConverter .setDpi ( dpi );
61
+ }
62
+
63
+ double QgsLayoutContext::dpi () const
64
+ {
65
+ return mMeasurementConverter .dpi ();
66
+ }
Original file line number Diff line number Diff line change 19
19
#include " qgis_core.h"
20
20
#include " qgsfeature.h"
21
21
#include " qgsvectorlayer.h"
22
+ #include " qgslayoutmeasurementconverter.h"
22
23
#include < QtGlobal>
23
24
24
25
class QgsFeature ;
@@ -108,13 +109,40 @@ class CORE_EXPORT QgsLayoutContext
108
109
*/
109
110
void setLayer ( QgsVectorLayer *layer );
110
111
112
+ /* *
113
+ * Sets the \a dpi for outputting the layout. This also sets the
114
+ * corresponding DPI for the context's measurementConverter().
115
+ * \see dpi()
116
+ */
117
+ void setDpi ( double dpi );
118
+
119
+ /* *
120
+ * Returns the \a dpi for outputting the layout.
121
+ * \see setDpi()
122
+ */
123
+ double dpi () const ;
124
+
125
+ /* *
126
+ * Returns the layout measurement converter to be used in the layout. This converter is used
127
+ * for translating between other measurement units and the layout's native unit.
128
+ */
129
+ SIP_SKIP const QgsLayoutMeasurementConverter &measurementConverter () const { return mMeasurementConverter ; }
130
+
131
+ /* *
132
+ * Returns the layout measurement converter to be used in the layout. This converter is used
133
+ * for translating between other measurement units and the layout's native unit.
134
+ */
135
+ QgsLayoutMeasurementConverter &measurementConverter () { return mMeasurementConverter ; }
136
+
111
137
private:
112
138
113
139
Flags mFlags = 0 ;
114
140
115
141
QgsFeature mFeature ;
116
142
QPointer< QgsVectorLayer > mLayer ;
117
143
144
+ QgsLayoutMeasurementConverter mMeasurementConverter ;
145
+
118
146
};
119
147
120
148
#endif // QGSLAYOUTCONTEXT_H
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ class TestQgsLayoutContext: public QObject
35
35
void flags (); // test QgsLayout flags
36
36
void feature ();
37
37
void layer ();
38
+ void dpi ();
38
39
39
40
private:
40
41
QString mReport ;
@@ -126,5 +127,13 @@ void TestQgsLayoutContext::layer()
126
127
delete layer;
127
128
}
128
129
130
+ void TestQgsLayoutContext::dpi ()
131
+ {
132
+ QgsLayoutContext context;
133
+ context.setDpi ( 600 );
134
+ QCOMPARE ( context.dpi (), 600.0 );
135
+ QCOMPARE ( context.measurementConverter ().dpi (), 600.0 );
136
+ }
137
+
129
138
QGSTEST_MAIN ( TestQgsLayoutContext )
130
139
#include " testqgslayoutcontext.moc"
You can’t perform that action at this time.
0 commit comments