1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #include "KChartPrintingParameters.h"
21 
22 using namespace KChart;
23 
PrintingParameters()24 PrintingParameters::PrintingParameters()
25     : m_scaleFactor( 1.0 )
26 {
27 }
28 
instance()29 PrintingParameters* PrintingParameters::instance()
30 {
31     static PrintingParameters instance;
32     return &instance;
33 }
34 
scaleFactor()35 qreal PrintingParameters::scaleFactor()
36 {
37     return instance()->m_scaleFactor;
38 }
39 
setScaleFactor(const qreal scaleFactor)40 void PrintingParameters::setScaleFactor( const qreal scaleFactor )
41 {
42     instance()->m_scaleFactor = scaleFactor;
43 }
44 
resetScaleFactor()45 void PrintingParameters::resetScaleFactor()
46 {
47     instance()->m_scaleFactor = 1.0;
48 }
49 
scalePen(const QPen & pen)50 QPen PrintingParameters::scalePen( const QPen& pen )
51 {
52     if ( instance()->m_scaleFactor == 1.0 )
53         return pen;
54 
55     QPen resultPen = pen;
56     resultPen.setWidthF( resultPen.widthF() * instance()->m_scaleFactor );
57     if ( resultPen.widthF() == 0.0 )
58         resultPen.setWidthF( instance()->m_scaleFactor );
59 
60     return resultPen;
61 }
62