/
qgslayoutrendercontext.cpp
133 lines (110 loc) · 3.64 KB
/
qgslayoutrendercontext.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
qgslayoutrendercontext.cpp
--------------------
begin : July 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgslayoutrendercontext.h"
#include "qgslayout.h"
QgsLayoutRenderContext::QgsLayoutRenderContext( QgsLayout *layout )
: QObject( layout )
, mFlags( FlagAntialiasing | FlagUseAdvancedEffects )
, mLayout( layout )
{
mSimplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
}
void QgsLayoutRenderContext::setFlags( const QgsLayoutRenderContext::Flags flags )
{
if ( flags == mFlags )
return;
mFlags = flags;
emit flagsChanged( mFlags );
}
void QgsLayoutRenderContext::setFlag( const QgsLayoutRenderContext::Flag flag, const bool on )
{
Flags newFlags = mFlags;
if ( on )
newFlags |= flag;
else
newFlags &= ~flag;
if ( newFlags == mFlags )
return;
mFlags = newFlags;
emit flagsChanged( mFlags );
}
QgsLayoutRenderContext::Flags QgsLayoutRenderContext::flags() const
{
return mFlags;
}
bool QgsLayoutRenderContext::testFlag( const QgsLayoutRenderContext::Flag flag ) const
{
return mFlags.testFlag( flag );
}
QgsRenderContext::Flags QgsLayoutRenderContext::renderContextFlags() const
{
QgsRenderContext::Flags flags = QgsRenderContext::Flags();
if ( mFlags & FlagAntialiasing )
flags = flags | QgsRenderContext::Antialiasing;
if ( mFlags & FlagUseAdvancedEffects )
flags = flags | QgsRenderContext::UseAdvancedEffects;
// TODO - expose as layout context flag?
flags |= QgsRenderContext::ForceVectorOutput;
return flags;
}
void QgsLayoutRenderContext::setDpi( double dpi )
{
if ( qgsDoubleNear( dpi, mMeasurementConverter.dpi() ) )
return;
mMeasurementConverter.setDpi( dpi );
emit dpiChanged();
}
double QgsLayoutRenderContext::dpi() const
{
return mMeasurementConverter.dpi();
}
bool QgsLayoutRenderContext::gridVisible() const
{
return mGridVisible;
}
void QgsLayoutRenderContext::setGridVisible( bool visible )
{
mGridVisible = visible;
}
bool QgsLayoutRenderContext::boundingBoxesVisible() const
{
return mBoundingBoxesVisible;
}
void QgsLayoutRenderContext::setBoundingBoxesVisible( bool visible )
{
mBoundingBoxesVisible = visible;
}
void QgsLayoutRenderContext::setPagesVisible( bool visible )
{
mPagesVisible = visible;
}
QStringList QgsLayoutRenderContext::exportThemes() const
{
return mExportThemes;
}
void QgsLayoutRenderContext::setExportThemes( const QStringList &exportThemes )
{
mExportThemes = exportThemes;
}
void QgsLayoutRenderContext::setPredefinedScales( const QVector<qreal> &scales )
{
if ( scales == mPredefinedScales )
return;
mPredefinedScales = scales;
// make sure the list is sorted
std::sort( mPredefinedScales.begin(), mPredefinedScales.end() ); // clazy:exclude=detaching-member
emit predefinedScalesChanged();
}