QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
qgsscalebarsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsscalebarsettings.cpp
3  -----------------------
4  begin : January 2020
5  copyright : (C) 2020 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgsscalebarsettings.h"
18 #include "qgsapplication.h"
19 #include "qgsnumericformat.h"
20 #include "qgsbasicnumericformat.h"
21 
23 {
24  mPen = QPen( mLineColor );
25  mPen.setJoinStyle( mLineJoinStyle );
26  mPen.setCapStyle( mLineCapStyle );
27  mPen.setWidthF( mLineWidth );
28 
29  mBrush.setColor( mFillColor );
30  mBrush.setStyle( Qt::SolidPattern );
31 
32  mBrush2.setColor( mFillColor2 );
33  mBrush2.setStyle( Qt::SolidPattern );
34 
35  mTextFormat.setSize( 12.0 );
37  mTextFormat.setColor( QColor( 0, 0, 0 ) );
38 
39  mNumericFormat = qgis::make_unique< QgsBasicNumericFormat >();
40 }
41 
43  : mNumSegments( other.mNumSegments )
44  , mNumSegmentsLeft( other.mNumSegmentsLeft )
45  , mNumUnitsPerSegment( other.mNumUnitsPerSegment )
46  , mNumMapUnitsPerScaleBarUnit( other.mNumMapUnitsPerScaleBarUnit )
47  , mSegmentSizeMode( other.mSegmentSizeMode )
48  , mMinBarWidth( other.mMinBarWidth )
49  , mMaxBarWidth( other.mMaxBarWidth )
50  , mUnitLabeling( other.mUnitLabeling )
51  , mTextFormat( other.mTextFormat )
52  , mFillColor( other.mFillColor )
53  , mFillColor2( other.mFillColor2 )
54  , mLineColor( other.mLineColor )
55  , mLineWidth( other.mLineWidth )
56  , mPen( other.mPen )
57  , mBrush( other.mBrush )
58  , mBrush2( other.mBrush2 )
59  , mHeight( other.mHeight )
60  , mLabelBarSpace( other.mLabelBarSpace )
61  , mLabelVerticalPlacement( other.mLabelVerticalPlacement )
62  , mLabelHorizontalPlacement( other.mLabelHorizontalPlacement )
63  , mBoxContentSpace( other.mBoxContentSpace )
64  , mAlignment( other.mAlignment )
65  , mUnits( other.mUnits )
66  , mLineJoinStyle( other.mLineJoinStyle )
67  , mLineCapStyle( other.mLineCapStyle )
68  , mNumericFormat( other.mNumericFormat->clone() )
69 {
70 
71 }
72 
74 {
75  mNumSegments = other.mNumSegments;
76  mNumSegmentsLeft = other.mNumSegmentsLeft;
77  mNumUnitsPerSegment = other.mNumUnitsPerSegment;
78  mNumMapUnitsPerScaleBarUnit = other.mNumMapUnitsPerScaleBarUnit;
79  mSegmentSizeMode = other.mSegmentSizeMode;
80  mMinBarWidth = other.mMinBarWidth;
81  mMaxBarWidth = other.mMaxBarWidth;
82  mUnitLabeling = other.mUnitLabeling;
83  mTextFormat = other.mTextFormat;
84  mFillColor = other.mFillColor;
85  mFillColor2 = other.mFillColor2;
86  mLineColor = other.mLineColor;
87  mLineWidth = other.mLineWidth;
88  mPen = other.mPen;
89  mBrush = other.mBrush;
90  mBrush2 = other.mBrush2;
91  mHeight = other.mHeight;
92  mLabelBarSpace = other.mLabelBarSpace;
93  mLabelVerticalPlacement = other.mLabelVerticalPlacement;
94  mLabelHorizontalPlacement = other.mLabelHorizontalPlacement;
95  mBoxContentSpace = other.mBoxContentSpace;
96  mAlignment = other.mAlignment;
97  mUnits = other.mUnits;
98  mLineJoinStyle = other.mLineJoinStyle;
99  mLineCapStyle = other.mLineCapStyle;
100  mNumericFormat.reset( other.mNumericFormat->clone() );
101  return *this;
102 }
103 
105 {
106  return mNumericFormat.get();
107 }
108 
110 {
111  mNumericFormat.reset( format );
112 }
113 
115 
void setNumericFormat(QgsNumericFormat *format)
Sets the numeric format used for numbers in the scalebar.
const QgsNumericFormat * numericFormat() const
Returns the numeric format used for numbers in the scalebar.
QgsScaleBarSettings & operator=(const QgsScaleBarSettings &other)
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
void setSize(double size)
Sets the size for rendered text.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
QgsScaleBarSettings()
Constructor for QgsScaleBarSettings.
Points (e.g., for font sizes)
Definition: qgsunittypes.h:151
The QgsScaleBarSettings class stores the appearance and layout settings for scalebar drawing with Qgs...