29 , mPreferredWidth( 300 )
30 , mWidth( mPreferredWidth )
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 );
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
void extentChanged()
Geographical coordinates of the rectangle that should be rendered.
void outputSizeChanged()
The size of the resulting map image.
void outputDpiChanged()
Output DPI used for conversion between real world units (e.g.
void destinationCrsChanged()
CRS of destination coordinate reference system.
void visibleExtentChanged()
Returns the actual extent derived from requested extent that takes takes output image size into accou...
void mapUnitsPerPixelChanged()
Returns the distance in geographical coordinates that equals to one pixel in the map.
void updateScaleBar()
recalculate width, distance and units.
QgsQuickScaleBarKit(QObject *parent=nullptr)
create new scale bar kit
void scaleBarChanged()
width, distance and/or units changed
void setMapSettings(QgsQuickMapSettings *mapSettings)
Associated map settings.
QString units
Units of distance (e.g.
int distance
Distance rounded to "nice" number (e.g.
void preferredWidthChanged()
Preferred width of scalebar in pixels.
QgsQuickMapSettings * mapSettings
Associated map settings.
int width
Calculated width of scalebar in pixels representing distance + units.
void mapSettingsChanged()
Associated map settings.
Encapsulating the common utilities for QgsQuick library.
static Q_INVOKABLE double screenUnitsToMeters(QgsQuickMapSettings *mapSettings, int baseLengthPixels)
Calculates the distance in meter representing baseLengthPixels pixels on the screen based on the curr...
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.
DistanceUnit
Units of distance.
static Q_INVOKABLE QString toAbbreviatedString(QgsUnitTypes::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.