29 , mPreferredWidth( 300 )
30 , mWidth( mPreferredWidth )
40 if ( mMapSettings == mapSettings )
46 disconnect( mMapSettings,
nullptr,
this,
nullptr );
97 int digits = int( floor( log10( ( dist ) ) ) );
98 double base = pow( 10, digits );
99 double first_digit = dist / base;
101 if ( first_digit < 2 )
103 else if ( first_digit < 5 )
108 mDistance = int( round_digit * base );
109 mWidth = int( mPreferredWidth * mDistance / dist );
void visibleExtentChanged()
Returns the actual extent derived from requested extent that takes takes output image size into accou...
Encapsulating the common utilies for QgsQuick library.
void extentChanged()
Geographical coordinates of the rectangle that should be rendered.
void preferredWidthChanged()
Preferred width of scalebar in pixels.
void setMapSettings(QgsQuickMapSettings *mapSettings)
Associated map settings.
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
static Q_INVOKABLE double screenUnitsToMeters(QgsQuickMapSettings *mapSettings, int baseLengthPixels)
Calculates the distance in meter representing baseLengthPixels pixels on the screen based on the curr...
void mapSettingsChanged()
Associated map settings.
void outputDpiChanged()
Output DPI used for conversion between real world units (e.g.
void mapUnitsPerPixelChanged()
Returns the distance in geographical coordinates that equals to one pixel in the map.
void updateScaleBar()
recalculate width, distance and units.
static Q_INVOKABLE QString toAbbreviatedString(QgsUnitTypes::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
static void humanReadableDistance(double srcDistance, QgsUnitTypes::DistanceUnit srcUnits, QgsUnitTypes::SystemOfMeasurement destSystem, double &destDistance, QgsUnitTypes::DistanceUnit &destUnits)
Converts distance to human readable distance in destination system of measurement.
void destinationCrsChanged()
CRS of destination coordinate reference system.
QgsQuickMapSettings mapSettings
Associated map settings.
QString units() const
Units of distance (e.g.
DistanceUnit
Units of distance.
void outputSizeChanged()
The size of the resulting map image.
int width() const
Calculated width of scalebar in pixels representing distance + units.
int distance() const
Units of distance (e.g.
void scaleBarChanged()
width, distance and/or units changed
QgsQuickScaleBarKit(QObject *parent=nullptr)
create new scale bar kit