QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
39class CORE_EXPORT QgsScaleBarSettings
40{
41 public:
42
47 {
48 AlignLeft = 0,
51 };
52
57 {
58 SegmentSizeFixed = 0,
59 SegmentSizeFitWidth = 1
60 };
61
66 {
67 LabelAboveSegment = 0,
69 };
70
75 {
76 LabelCenteredEdge = 0,
78 };
79
84
86
91
92 QgsScaleBarSettings &operator=( const QgsScaleBarSettings &other );
93
99 int numberOfSegments() const { return mNumSegments; }
100
106 void setNumberOfSegments( int segments ) { mNumSegments = segments; }
107
113 int numberOfSegmentsLeft() const { return mNumSegmentsLeft; }
114
120 void setNumberOfSegmentsLeft( int segments ) { mNumSegmentsLeft = segments; }
121
131 int numberOfSubdivisions() const { return mNumSubdivisions; }
132
142 void setNumberOfSubdivisions( int subdivisions ) { mNumSubdivisions = subdivisions; }
143
149 double subdivisionsHeight() const { return mSubdivisionsHeight; }
150
156 void setSubdivisionsHeight( double height ) { mSubdivisionsHeight = height; }
157
162 double unitsPerSegment() const { return mNumUnitsPerSegment; }
163
168 void setUnitsPerSegment( double units ) { mNumUnitsPerSegment = units; }
169
176 SegmentSizeMode segmentSizeMode() const { return mSegmentSizeMode; }
177
184 void setSegmentSizeMode( SegmentSizeMode mode ) { mSegmentSizeMode = mode; }
185
194 double minimumBarWidth() const { return mMinBarWidth; }
195
204 void setMinimumBarWidth( double width ) { mMinBarWidth = width; }
205
214 double maximumBarWidth() const { return mMaxBarWidth; }
215
224 void setMaximumBarWidth( double width ) { mMaxBarWidth = width; }
225
230 Qgis::DistanceUnit units() const { return mUnits; }
231
236 void setUnits( Qgis::DistanceUnit units ) { mUnits = units; }
237
242 double mapUnitsPerScaleBarUnit() const { return mNumMapUnitsPerScaleBarUnit; }
243
248 void setMapUnitsPerScaleBarUnit( double units ) { mNumMapUnitsPerScaleBarUnit = units; }
249
254 QString unitLabel() const { return mUnitLabeling; }
255
260 void setUnitLabel( const QString &label ) { mUnitLabeling = label; }
261
267 QgsTextFormat &textFormat() { return mTextFormat; }
268
274 QgsTextFormat textFormat() const SIP_SKIP { return mTextFormat; }
275
281 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
282
288 Q_DECL_DEPRECATED QFont font() const SIP_DEPRECATED { return mTextFormat.font(); }
289
295 Q_DECL_DEPRECATED void setFont( const QFont &font ) SIP_DEPRECATED
296 {
297 mTextFormat.setFont( font );
298 if ( font.pointSizeF() > 0 )
299 {
300 mTextFormat.setSize( font.pointSizeF() );
301 mTextFormat.setSizeUnit( Qgis::RenderUnit::Points );
302 }
303 else if ( font.pixelSize() > 0 )
304 {
305 mTextFormat.setSize( font.pixelSize() );
306 mTextFormat.setSizeUnit( Qgis::RenderUnit::Pixels );
307 }
308 }
309
316 Q_DECL_DEPRECATED QColor fontColor() const SIP_DEPRECATED { return mTextFormat.color(); }
317
324 Q_DECL_DEPRECATED void setFontColor( const QColor &color ) SIP_DEPRECATED { mTextFormat.setColor( color ); }
325
332 Q_DECL_DEPRECATED QColor fillColor() const SIP_DEPRECATED;
333
340 Q_DECL_DEPRECATED void setFillColor( const QColor &color ) SIP_DEPRECATED;
341
348 Q_DECL_DEPRECATED QColor fillColor2() const SIP_DEPRECATED;
349
356 Q_DECL_DEPRECATED void setFillColor2( const QColor &color ) SIP_DEPRECATED;
357
363 Q_DECL_DEPRECATED QColor lineColor() const SIP_DEPRECATED;
364
370 Q_DECL_DEPRECATED void setLineColor( const QColor &color ) SIP_DEPRECATED;
371
377 Q_DECL_DEPRECATED double lineWidth() const SIP_DEPRECATED;
378
384 Q_DECL_DEPRECATED void setLineWidth( double width ) SIP_DEPRECATED;
385
392 Q_DECL_DEPRECATED QPen pen() const SIP_DEPRECATED;
393
399 Q_DECL_DEPRECATED void setPen( const QPen &pen ) SIP_DEPRECATED;
400
411 QgsLineSymbol *lineSymbol() const;
412
422 void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
423
434 QgsLineSymbol *divisionLineSymbol() const;
435
445 void setDivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
446
457 QgsLineSymbol *subdivisionLineSymbol() const;
458
468 void setSubdivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
469
479 QgsFillSymbol *fillSymbol() const;
480
489 void setFillSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
490
491
501 QgsFillSymbol *alternateFillSymbol() const;
502
511 void setAlternateFillSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
512
520 Q_DECL_DEPRECATED QBrush brush() const SIP_DEPRECATED;
521
527 Q_DECL_DEPRECATED void setBrush( const QBrush &brush ) SIP_DEPRECATED;
528
536 Q_DECL_DEPRECATED QBrush brush2() const SIP_DEPRECATED;
537
543 Q_DECL_DEPRECATED void setBrush2( const QBrush &brush ) SIP_DEPRECATED;
544
549 double height() const { return mHeight; }
550
555 void setHeight( double height ) { mHeight = height; }
556
561 double labelBarSpace() const { return mLabelBarSpace; }
562
567 void setLabelBarSpace( double space ) { mLabelBarSpace = space; }
568
574 LabelVerticalPlacement labelVerticalPlacement() const { return mLabelVerticalPlacement; }
575
581 void setLabelVerticalPlacement( LabelVerticalPlacement placement ) { mLabelVerticalPlacement = placement; }
582
588 LabelHorizontalPlacement labelHorizontalPlacement() const { return mLabelHorizontalPlacement; }
589
595 void setLabelHorizontalPlacement( LabelHorizontalPlacement placement ) { mLabelHorizontalPlacement = placement; }
596
601 double boxContentSpace() const { return mBoxContentSpace; }
602
607 void setBoxContentSpace( double space ) { mBoxContentSpace = space; }
608
613 Alignment alignment() const { return mAlignment; }
614
619 void setAlignment( Alignment alignment ) { mAlignment = alignment; }
620
626 Q_DECL_DEPRECATED Qt::PenJoinStyle lineJoinStyle() const SIP_DEPRECATED;
627
633 Q_DECL_DEPRECATED void setLineJoinStyle( Qt::PenJoinStyle style ) SIP_DEPRECATED;
634
640 Q_DECL_DEPRECATED Qt::PenCapStyle lineCapStyle() const SIP_DEPRECATED;
641
647 Q_DECL_DEPRECATED void setLineCapStyle( Qt::PenCapStyle style ) SIP_DEPRECATED;
648
655 const QgsNumericFormat *numericFormat() const;
656
665 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
666
667 private:
668
670 int mNumSegments = 2;
672 int mNumSegmentsLeft = 0;
674 int mNumSubdivisions = 1;
676 double mSubdivisionsHeight = 1.5;
678 double mNumUnitsPerSegment = 0;
680 double mNumMapUnitsPerScaleBarUnit = 1.0;
682 SegmentSizeMode mSegmentSizeMode = SegmentSizeFixed;
684 double mMinBarWidth = 50.0;
686 double mMaxBarWidth = 150.0;
687
689 QString mUnitLabeling;
690
692 QgsTextFormat mTextFormat;
693
695 double mHeight = 3.0;
696
697 std::unique_ptr< QgsLineSymbol > mLineSymbol;
698 std::unique_ptr< QgsLineSymbol > mDivisionLineSymbol;
699 std::unique_ptr< QgsLineSymbol > mSubdivisionLineSymbol;
700 std::unique_ptr< QgsFillSymbol > mFillSymbol;
701 std::unique_ptr< QgsFillSymbol > mAlternateFillSymbol;
702
704 double mLabelBarSpace = 3.0;
706 LabelVerticalPlacement mLabelVerticalPlacement = LabelAboveSegment;
708 LabelHorizontalPlacement mLabelHorizontalPlacement = LabelCenteredEdge;
709
711 double mBoxContentSpace = 1.0;
712
713 Alignment mAlignment = AlignLeft;
714
715 Qgis::DistanceUnit mUnits = Qgis::DistanceUnit::Meters;
716
717
718 std::unique_ptr< QgsNumericFormat > mNumericFormat;
719
720};
721
722#endif // QGSSCALEBARSETTINGS_H
723
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:55
DistanceUnit
Units of distance.
Definition: qgis.h:3047
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
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...
double subdivisionsHeight() const
Returns the scalebar subdivisions height (in millimeters) for segments included in the right part of ...
void setAlignment(Alignment alignment)
Sets the scalebar alignment.
SegmentSizeMode segmentSizeMode() const
Returns the size mode for the scale bar segments.
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.
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 setLabelVerticalPlacement(LabelVerticalPlacement placement)
Sets the vertical placement of text labels.
void setUnitLabel(const QString &label)
Sets the label for units.
LabelHorizontalPlacement labelHorizontalPlacement() const
Returns the horizontal placement of text labels.
void setBoxContentSpace(double space)
Sets the space (margin) between the scalebar box and content in millimeters.
Alignment alignment() const
Returns the scalebar alignment.
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).
Q_DECL_DEPRECATED void setFontColor(const QColor &color)
Sets the color used for drawing text in the scalebar.
Alignment
Scalebar alignment.
@ AlignMiddle
Center aligned.
@ AlignRight
Right aligned.
void setNumberOfSubdivisions(int subdivisions)
Sets the number of subdivisions for segments included in the right part of the scalebar (only used fo...
LabelVerticalPlacement labelVerticalPlacement() const
Returns the vertical placement of text labels.
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...
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.
LabelHorizontalPlacement
Label horizontal placement.
@ LabelCenteredSegment
Labels are drawn centered relative to segment.
void setLabelBarSpace(double space)
Sets the spacing (in millimeters) between labels and the scalebar.
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.
LabelVerticalPlacement
Label vertical placement.
@ LabelBelowSegment
Labels are drawn below the scalebar.
void setLabelHorizontalPlacement(LabelHorizontalPlacement placement)
Sets the horizontal placement of text labels.
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.
SegmentSizeMode
Modes for setting size for scale bar segments.
void setNumberOfSegmentsLeft(int segments)
Sets the number of segments included in the left part of the scalebar.
void setSegmentSizeMode(SegmentSizeMode mode)
Sets the size mode for scale bar segments.
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.
Definition: qgstextformat.h:41
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:74
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36