QGIS API Documentation 3.38.0-Grenoble (exported)
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
46 {
47 AlignLeft = 0,
50 };
51
56 {
57 SegmentSizeFixed = 0,
58 SegmentSizeFitWidth = 1
59 };
60
65 {
66 LabelAboveSegment = 0,
68 };
69
74 {
75 LabelCenteredEdge = 0,
77 };
78
83
85
90
91 QgsScaleBarSettings &operator=( const QgsScaleBarSettings &other );
92
98 int numberOfSegments() const { return mNumSegments; }
99
105 void setNumberOfSegments( int segments ) { mNumSegments = segments; }
106
112 int numberOfSegmentsLeft() const { return mNumSegmentsLeft; }
113
119 void setNumberOfSegmentsLeft( int segments ) { mNumSegmentsLeft = segments; }
120
130 int numberOfSubdivisions() const { return mNumSubdivisions; }
131
141 void setNumberOfSubdivisions( int subdivisions ) { mNumSubdivisions = subdivisions; }
142
148 double subdivisionsHeight() const { return mSubdivisionsHeight; }
149
155 void setSubdivisionsHeight( double height ) { mSubdivisionsHeight = height; }
156
161 double unitsPerSegment() const { return mNumUnitsPerSegment; }
162
167 void setUnitsPerSegment( double units ) { mNumUnitsPerSegment = units; }
168
175 SegmentSizeMode segmentSizeMode() const { return mSegmentSizeMode; }
176
183 void setSegmentSizeMode( SegmentSizeMode mode ) { mSegmentSizeMode = mode; }
184
193 double minimumBarWidth() const { return mMinBarWidth; }
194
203 void setMinimumBarWidth( double width ) { mMinBarWidth = width; }
204
213 double maximumBarWidth() const { return mMaxBarWidth; }
214
223 void setMaximumBarWidth( double width ) { mMaxBarWidth = width; }
224
229 Qgis::DistanceUnit units() const { return mUnits; }
230
235 void setUnits( Qgis::DistanceUnit units ) { mUnits = units; }
236
241 double mapUnitsPerScaleBarUnit() const { return mNumMapUnitsPerScaleBarUnit; }
242
247 void setMapUnitsPerScaleBarUnit( double units ) { mNumMapUnitsPerScaleBarUnit = units; }
248
253 QString unitLabel() const { return mUnitLabeling; }
254
259 void setUnitLabel( const QString &label ) { mUnitLabeling = label; }
260
266 QgsTextFormat &textFormat() { return mTextFormat; }
267
273 QgsTextFormat textFormat() const SIP_SKIP { return mTextFormat; }
274
280 void setTextFormat( const QgsTextFormat &format ) { mTextFormat = format; }
281
287 Q_DECL_DEPRECATED QFont font() const SIP_DEPRECATED { return mTextFormat.font(); }
288
294 Q_DECL_DEPRECATED void setFont( const QFont &font ) SIP_DEPRECATED
295 {
296 mTextFormat.setFont( font );
297 if ( font.pointSizeF() > 0 )
298 {
299 mTextFormat.setSize( font.pointSizeF() );
300 mTextFormat.setSizeUnit( Qgis::RenderUnit::Points );
301 }
302 else if ( font.pixelSize() > 0 )
303 {
304 mTextFormat.setSize( font.pixelSize() );
305 mTextFormat.setSizeUnit( Qgis::RenderUnit::Pixels );
306 }
307 }
308
315 Q_DECL_DEPRECATED QColor fontColor() const SIP_DEPRECATED { return mTextFormat.color(); }
316
323 Q_DECL_DEPRECATED void setFontColor( const QColor &color ) SIP_DEPRECATED { mTextFormat.setColor( color ); }
324
331 Q_DECL_DEPRECATED QColor fillColor() const SIP_DEPRECATED;
332
339 Q_DECL_DEPRECATED void setFillColor( const QColor &color ) SIP_DEPRECATED;
340
347 Q_DECL_DEPRECATED QColor fillColor2() const SIP_DEPRECATED;
348
355 Q_DECL_DEPRECATED void setFillColor2( const QColor &color ) SIP_DEPRECATED;
356
362 Q_DECL_DEPRECATED QColor lineColor() const SIP_DEPRECATED;
363
369 Q_DECL_DEPRECATED void setLineColor( const QColor &color ) SIP_DEPRECATED;
370
376 Q_DECL_DEPRECATED double lineWidth() const SIP_DEPRECATED;
377
383 Q_DECL_DEPRECATED void setLineWidth( double width ) SIP_DEPRECATED;
384
391 Q_DECL_DEPRECATED QPen pen() const SIP_DEPRECATED;
392
398 Q_DECL_DEPRECATED void setPen( const QPen &pen ) SIP_DEPRECATED;
399
410 QgsLineSymbol *lineSymbol() const;
411
421 void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
422
433 QgsLineSymbol *divisionLineSymbol() const;
434
444 void setDivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
445
456 QgsLineSymbol *subdivisionLineSymbol() const;
457
467 void setSubdivisionLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
468
478 QgsFillSymbol *fillSymbol() const;
479
488 void setFillSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
489
490
500 QgsFillSymbol *alternateFillSymbol() const;
501
510 void setAlternateFillSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
511
519 Q_DECL_DEPRECATED QBrush brush() const SIP_DEPRECATED;
520
526 Q_DECL_DEPRECATED void setBrush( const QBrush &brush ) SIP_DEPRECATED;
527
535 Q_DECL_DEPRECATED QBrush brush2() const SIP_DEPRECATED;
536
542 Q_DECL_DEPRECATED void setBrush2( const QBrush &brush ) SIP_DEPRECATED;
543
548 double height() const { return mHeight; }
549
554 void setHeight( double height ) { mHeight = height; }
555
560 double labelBarSpace() const { return mLabelBarSpace; }
561
566 void setLabelBarSpace( double space ) { mLabelBarSpace = space; }
567
573 LabelVerticalPlacement labelVerticalPlacement() const { return mLabelVerticalPlacement; }
574
580 void setLabelVerticalPlacement( LabelVerticalPlacement placement ) { mLabelVerticalPlacement = placement; }
581
587 LabelHorizontalPlacement labelHorizontalPlacement() const { return mLabelHorizontalPlacement; }
588
594 void setLabelHorizontalPlacement( LabelHorizontalPlacement placement ) { mLabelHorizontalPlacement = placement; }
595
600 double boxContentSpace() const { return mBoxContentSpace; }
601
606 void setBoxContentSpace( double space ) { mBoxContentSpace = space; }
607
612 Alignment alignment() const { return mAlignment; }
613
618 void setAlignment( Alignment alignment ) { mAlignment = alignment; }
619
625 Q_DECL_DEPRECATED Qt::PenJoinStyle lineJoinStyle() const SIP_DEPRECATED;
626
632 Q_DECL_DEPRECATED void setLineJoinStyle( Qt::PenJoinStyle style ) SIP_DEPRECATED;
633
639 Q_DECL_DEPRECATED Qt::PenCapStyle lineCapStyle() const SIP_DEPRECATED;
640
646 Q_DECL_DEPRECATED void setLineCapStyle( Qt::PenCapStyle style ) SIP_DEPRECATED;
647
654 const QgsNumericFormat *numericFormat() const;
655
664 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
665
666 private:
667
669 int mNumSegments = 2;
671 int mNumSegmentsLeft = 0;
673 int mNumSubdivisions = 1;
675 double mSubdivisionsHeight = 1.5;
677 double mNumUnitsPerSegment = 0;
679 double mNumMapUnitsPerScaleBarUnit = 1.0;
681 SegmentSizeMode mSegmentSizeMode = SegmentSizeFixed;
683 double mMinBarWidth = 50.0;
685 double mMaxBarWidth = 150.0;
686
688 QString mUnitLabeling;
689
691 QgsTextFormat mTextFormat;
692
694 double mHeight = 3.0;
695
696 std::unique_ptr< QgsLineSymbol > mLineSymbol;
697 std::unique_ptr< QgsLineSymbol > mDivisionLineSymbol;
698 std::unique_ptr< QgsLineSymbol > mSubdivisionLineSymbol;
699 std::unique_ptr< QgsFillSymbol > mFillSymbol;
700 std::unique_ptr< QgsFillSymbol > mAlternateFillSymbol;
701
703 double mLabelBarSpace = 3.0;
705 LabelVerticalPlacement mLabelVerticalPlacement = LabelAboveSegment;
707 LabelHorizontalPlacement mLabelHorizontalPlacement = LabelCenteredEdge;
708
710 double mBoxContentSpace = 1.0;
711
712 Alignment mAlignment = AlignLeft;
713
714 Qgis::DistanceUnit mUnits = Qgis::DistanceUnit::Meters;
715
716
717 std::unique_ptr< QgsNumericFormat > mNumericFormat;
718
719};
720
721#endif // QGSSCALEBARSETTINGS_H
722
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
DistanceUnit
Units of distance.
Definition qgis.h:4358
@ Points
Points (e.g., for font sizes)
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...
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.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36