QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgsscalebarsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsscalebarsettings.h
3 ---------------------
4 begin : April 2017
5 copyright : (C) 2017 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#ifndef QGSSCALEBARSETTINGS_H
18#define QGSSCALEBARSETTINGS_H
19
20#include "qgis_core.h"
21#include "qgis.h"
22#include "qgstextformat.h"
23#include <QColor>
24#include <QFont>
25#include <QPen>
26#include <QBrush>
27
29class QgsLineSymbol;
30class QgsFillSymbol;
31
38class CORE_EXPORT QgsScaleBarSettings
39{
40 public:
41
43
45
47
48 QgsScaleBarSettings &operator=( const QgsScaleBarSettings &other );
49
55 int numberOfSegments() const { return mNumSegments; }
56
62 void setNumberOfSegments( int segments ) { mNumSegments = segments; }
63
69 int numberOfSegmentsLeft() const { return mNumSegmentsLeft; }
70
76 void setNumberOfSegmentsLeft( int segments ) { mNumSegmentsLeft = segments; }
77
87 int numberOfSubdivisions() const { return mNumSubdivisions; }
88
98 void setNumberOfSubdivisions( int subdivisions ) { mNumSubdivisions = subdivisions; }
99
105 double subdivisionsHeight() const { return mSubdivisionsHeight; }
106
112 void setSubdivisionsHeight( double height ) { mSubdivisionsHeight = height; }
113
118 double unitsPerSegment() const { return mNumUnitsPerSegment; }
119
124 void setUnitsPerSegment( double units ) { mNumUnitsPerSegment = units; }
125
132 Qgis::ScaleBarSegmentSizeMode segmentSizeMode() const { return mSegmentSizeMode; }
133
140 void setSegmentSizeMode( Qgis::ScaleBarSegmentSizeMode mode ) { mSegmentSizeMode = mode; }
141
150 double minimumBarWidth() const { return mMinBarWidth; }
151
160 void setMinimumBarWidth( double width ) { mMinBarWidth = width; }
161
170 double maximumBarWidth() const { return mMaxBarWidth; }
171
180 void setMaximumBarWidth( double width ) { mMaxBarWidth = width; }
181
186 Qgis::DistanceUnit units() const { return mUnits; }
187
192 void setUnits( Qgis::DistanceUnit units ) { mUnits = units; }
193
198 double mapUnitsPerScaleBarUnit() const { return mNumMapUnitsPerScaleBarUnit; }
199
204 void setMapUnitsPerScaleBarUnit( double units ) { mNumMapUnitsPerScaleBarUnit = units; }
205
210 QString unitLabel() const { return mUnitLabeling; }
211
216 void setUnitLabel( const QString &label ) { mUnitLabeling = label; }
217
223 QgsTextFormat &textFormat() { return mTextFormat; }
224
230 QgsTextFormat textFormat() const SIP_SKIP { return mTextFormat; }
231
237 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
238
244 Q_DECL_DEPRECATED QFont font() const SIP_DEPRECATED { return mTextFormat.font(); }
245
251 Q_DECL_DEPRECATED void setFont( const QFont &font ) SIP_DEPRECATED
252 {
253 mTextFormat.setFont( font );
254 if ( font.pointSizeF() > 0 )
255 {
256 mTextFormat.setSize( font.pointSizeF() );
257 mTextFormat.setSizeUnit( Qgis::RenderUnit::Points );
258 }
259 else if ( font.pixelSize() > 0 )
260 {
261 mTextFormat.setSize( font.pixelSize() );
262 mTextFormat.setSizeUnit( Qgis::RenderUnit::Pixels );
263 }
264 }
265
272 Q_DECL_DEPRECATED QColor fontColor() const SIP_DEPRECATED { return mTextFormat.color(); }
273
280 Q_DECL_DEPRECATED void setFontColor( const QColor &color ) SIP_DEPRECATED { mTextFormat.setColor( color ); }
281
288 Q_DECL_DEPRECATED QColor fillColor() const SIP_DEPRECATED;
289
296 Q_DECL_DEPRECATED void setFillColor( const QColor &color ) SIP_DEPRECATED;
297
304 Q_DECL_DEPRECATED QColor fillColor2() const SIP_DEPRECATED;
305
312 Q_DECL_DEPRECATED void setFillColor2( const QColor &color ) SIP_DEPRECATED;
313
319 Q_DECL_DEPRECATED QColor lineColor() const SIP_DEPRECATED;
320
326 Q_DECL_DEPRECATED void setLineColor( const QColor &color ) SIP_DEPRECATED;
327
333 Q_DECL_DEPRECATED double lineWidth() const SIP_DEPRECATED;
334
340 Q_DECL_DEPRECATED void setLineWidth( double width ) SIP_DEPRECATED;
341
348 Q_DECL_DEPRECATED QPen pen() const SIP_DEPRECATED;
349
355 Q_DECL_DEPRECATED void setPen( const QPen &pen ) SIP_DEPRECATED;
356
367 QgsLineSymbol *lineSymbol() const;
368
378 void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
379
390 QgsLineSymbol *divisionLineSymbol() const;
391
401 void setDivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
402
413 QgsLineSymbol *subdivisionLineSymbol() const;
414
424 void setSubdivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
425
435 QgsFillSymbol *fillSymbol() const;
436
445 void setFillSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
446
447
457 QgsFillSymbol *alternateFillSymbol() const;
458
467 void setAlternateFillSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
468
476 Q_DECL_DEPRECATED QBrush brush() const SIP_DEPRECATED;
477
483 Q_DECL_DEPRECATED void setBrush( const QBrush &brush ) SIP_DEPRECATED;
484
492 Q_DECL_DEPRECATED QBrush brush2() const SIP_DEPRECATED;
493
499 Q_DECL_DEPRECATED void setBrush2( const QBrush &brush ) SIP_DEPRECATED;
500
505 double height() const { return mHeight; }
506
511 void setHeight( double height ) { mHeight = height; }
512
517 double labelBarSpace() const { return mLabelBarSpace; }
518
523 void setLabelBarSpace( double space ) { mLabelBarSpace = space; }
524
531
537 void setLabelVerticalPlacement( Qgis::ScaleBarDistanceLabelVerticalPlacement placement ) { mLabelVerticalPlacement = placement; }
538
545
551 void setLabelHorizontalPlacement( Qgis::ScaleBarDistanceLabelHorizontalPlacement placement ) { mLabelHorizontalPlacement = placement; }
552
557 double boxContentSpace() const { return mBoxContentSpace; }
558
563 void setBoxContentSpace( double space ) { mBoxContentSpace = space; }
564
569 Qgis::ScaleBarAlignment alignment() const { return mAlignment; }
570
575 void setAlignment( Qgis::ScaleBarAlignment alignment ) { mAlignment = alignment; }
576
582 Q_DECL_DEPRECATED Qt::PenJoinStyle lineJoinStyle() const SIP_DEPRECATED;
583
589 Q_DECL_DEPRECATED void setLineJoinStyle( Qt::PenJoinStyle style ) SIP_DEPRECATED;
590
596 Q_DECL_DEPRECATED Qt::PenCapStyle lineCapStyle() const SIP_DEPRECATED;
597
603 Q_DECL_DEPRECATED void setLineCapStyle( Qt::PenCapStyle style ) SIP_DEPRECATED;
604
611 const QgsNumericFormat *numericFormat() const;
612
621 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
622
623 private:
624
626 int mNumSegments = 2;
628 int mNumSegmentsLeft = 0;
630 int mNumSubdivisions = 1;
632 double mSubdivisionsHeight = 1.5;
634 double mNumUnitsPerSegment = 0;
636 double mNumMapUnitsPerScaleBarUnit = 1.0;
638 Qgis::ScaleBarSegmentSizeMode mSegmentSizeMode = Qgis::ScaleBarSegmentSizeMode::Fixed;
640 double mMinBarWidth = 50.0;
642 double mMaxBarWidth = 150.0;
643
645 QString mUnitLabeling;
646
648 QgsTextFormat mTextFormat;
649
651 double mHeight = 3.0;
652
653 std::unique_ptr< QgsLineSymbol > mLineSymbol;
654 std::unique_ptr< QgsLineSymbol > mDivisionLineSymbol;
655 std::unique_ptr< QgsLineSymbol > mSubdivisionLineSymbol;
656 std::unique_ptr< QgsFillSymbol > mFillSymbol;
657 std::unique_ptr< QgsFillSymbol > mAlternateFillSymbol;
658
660 double mLabelBarSpace = 3.0;
662 Qgis::ScaleBarDistanceLabelVerticalPlacement mLabelVerticalPlacement = Qgis::ScaleBarDistanceLabelVerticalPlacement::AboveSegment;
664 Qgis::ScaleBarDistanceLabelHorizontalPlacement mLabelHorizontalPlacement = Qgis::ScaleBarDistanceLabelHorizontalPlacement::CenteredEdge;
665
667 double mBoxContentSpace = 1.0;
668
669 Qgis::ScaleBarAlignment mAlignment = Qgis::ScaleBarAlignment::Left;
670
671 Qgis::DistanceUnit mUnits = Qgis::DistanceUnit::Meters;
672
673 std::unique_ptr< QgsNumericFormat > mNumericFormat;
674
675};
676
677#endif // QGSSCALEBARSETTINGS_H
678
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
ScaleBarDistanceLabelHorizontalPlacement
Scale bar distance label horizontal placement.
Definition qgis.h:4973
ScaleBarDistanceLabelVerticalPlacement
Scale bar distance label vertical placement.
Definition qgis.h:4959
ScaleBarAlignment
Scalebar alignment.
Definition qgis.h:4930
DistanceUnit
Units of distance.
Definition qgis.h:4677
@ Points
Points (e.g., for font sizes)
ScaleBarSegmentSizeMode
Modes for setting size for scale bar segments.
Definition qgis.h:4945
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
The QgsScaleBarSettings class stores the appearance and layout settings for scalebar drawing with Qgs...
Qgis::ScaleBarAlignment alignment() const
Returns the scalebar alignment.
double subdivisionsHeight() const
Returns the scalebar subdivisions height (in millimeters) for segments included in the right part of ...
int numberOfSegments() const
Returns the number of segments included in the scalebar.
double maximumBarWidth() const
Returns the maximum width (in millimeters) for scale bar segments.
void setLabelHorizontalPlacement(Qgis::ScaleBarDistanceLabelHorizontalPlacement placement)
Sets the horizontal placement of text labels.
Qgis::ScaleBarDistanceLabelVerticalPlacement labelVerticalPlacement() const
Returns the vertical placement of text labels.
double unitsPerSegment() const
Returns the number of scalebar units per segment.
Q_DECL_DEPRECATED QColor fontColor() const
Returns the color used for drawing text in the scalebar.
QgsTextFormat & textFormat()
Returns the text format used for drawing text in the scalebar.
void setUnitLabel(const QString &label)
Sets the label for units.
void setSegmentSizeMode(Qgis::ScaleBarSegmentSizeMode mode)
Sets the size mode for scale bar segments.
void setBoxContentSpace(double space)
Sets the space (margin) between the scalebar box and content in millimeters.
double boxContentSpace() const
Returns the spacing (margin) between the scalebar box and content in millimeters.
void setHeight(double height)
Sets the scalebar height (in millimeters).
Qgis::ScaleBarSegmentSizeMode segmentSizeMode() const
Returns the size mode for the scale bar segments.
void setLabelVerticalPlacement(Qgis::ScaleBarDistanceLabelVerticalPlacement placement)
Sets the vertical placement of text labels.
Q_DECL_DEPRECATED void setFontColor(const QColor &color)
Sets the color used for drawing text in the scalebar.
void setNumberOfSubdivisions(int subdivisions)
Sets the number of subdivisions for segments included in the right part of the scalebar (only used fo...
QgsTextFormat textFormat() const
Returns the text format used for drawing text in the scalebar.
void setTextFormat(const QgsTextFormat &format)
Sets the text format used for drawing text in the scalebar.
double minimumBarWidth() const
Returns the minimum width (in millimeters) for scale bar segments.
QString unitLabel() const
Returns the label for units.
int numberOfSubdivisions() const
Returns the number of subdivisions for segments included in the right part of the scalebar (only used...
Qgis::ScaleBarDistanceLabelHorizontalPlacement labelHorizontalPlacement() const
Returns the horizontal placement of text labels.
Q_DECL_DEPRECATED QFont font() const
Returns the font used for drawing text in the scalebar.
Qgis::DistanceUnit units() const
Returns the distance units used by the scalebar.
void setLabelBarSpace(double space)
Sets the spacing (in millimeters) between labels and the scalebar.
void setAlignment(Qgis::ScaleBarAlignment alignment)
Sets the scalebar alignment.
void setNumberOfSegments(int segments)
Sets the number of segments included in the scalebar.
void setUnitsPerSegment(double units)
Sets the number of scalebar units per segment.
void setSubdivisionsHeight(double height)
Sets the scalebar subdivisions height (in millimeters) for segments included in the right part of the...
double labelBarSpace() const
Returns the spacing (in millimeters) between labels and the scalebar.
int numberOfSegmentsLeft() const
Returns the number of segments included in the left part of the scalebar.
Q_DECL_DEPRECATED void setFont(const QFont &font)
Sets the font used for drawing text in the scalebar.
void setNumberOfSegmentsLeft(int segments)
Sets the number of segments included in the left part of the scalebar.
void setMapUnitsPerScaleBarUnit(double units)
Sets the number of map units per scale bar unit used by the scalebar.
void setUnits(Qgis::DistanceUnit units)
Sets the distance units used by the scalebar.
double mapUnitsPerScaleBarUnit() const
Returns the number of map units per scale bar unit used by the scalebar.
void setMinimumBarWidth(double width)
Sets the minimum width (in millimeters) for scale bar segments.
void setMaximumBarWidth(double width)
Sets the maximum width (in millimeters) for scale bar segments.
Container for all settings relating to text rendering.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36