17#include "moc_qgsprojectdisplaysettings.cpp" 
   33  if ( 
QgsProject *project = qobject_cast< QgsProject * >( parent ) )
 
 
   53  updateCoordinateCrs();
 
 
   64  mBearingFormat.reset( format );
 
 
   70  return mBearingFormat.get();
 
 
   75  mGeographicCoordinateFormat.reset( format );
 
 
   81  return mGeographicCoordinateFormat.get();
 
 
   86  if ( mCoordinateType == type )
 
   89  mCoordinateType = type;
 
   90  updateCoordinateCrs();
 
 
   97  if ( mCoordinateAxisOrder == order )
 
  100  mCoordinateAxisOrder = order;
 
 
  106  if ( mCoordinateCustomCrs == 
crs )
 
  109  mCoordinateCustomCrs = 
crs;
 
  112    updateCoordinateCrs();
 
 
  117void QgsProjectDisplaySettings::updateCoordinateCrs()
 
  119  if ( 
QgsProject *project = qobject_cast< QgsProject * >( parent() ) )
 
  123    switch ( mCoordinateType )
 
  134        crs = mCoordinateCustomCrs;
 
  138    if ( mCoordinateCrs != 
crs )
 
  140      mCoordinateCrs = 
crs;
 
  149    const QDomElement bearingElement = element.firstChildElement( QStringLiteral( 
"BearingFormat" ) );
 
  154  QgsProject *project = qobject_cast< QgsProject * >( parent() );
 
  157    const QDomElement geographicElement = element.firstChildElement( QStringLiteral( 
"GeographicCoordinateFormat" ) );
 
  158    if ( !geographicElement.isNull() )
 
  166      const QString format = project->
readEntry( QStringLiteral( 
"PositionPrecision" ), QStringLiteral( 
"/DegreeFormat" ), QString(), &ok );
 
  169        mGeographicCoordinateFormat = std::make_unique< QgsGeographicCoordinateNumericFormat >();
 
  170        mGeographicCoordinateFormat->setShowDirectionalSuffix( 
true );
 
  171        if ( format == QLatin1String( 
"DM" ) )
 
  173        else if ( format == QLatin1String( 
"DMS" ) )
 
  191    if ( element.hasAttribute( QStringLiteral( 
"CoordinateType" ) ) )
 
  197      const QString format = project->
readEntry( QStringLiteral( 
"PositionPrecision" ), QStringLiteral( 
"/DegreeFormat" ), QString() );
 
  198      if ( !format.isEmpty() )
 
  200        if ( format != QLatin1String( 
"MU" ) && !project->
crs().
isGeographic() )
 
  211    QDomNodeList crsNodeList = element.elementsByTagName( QStringLiteral( 
"CoordinateCustomCrs" ) );
 
  212    if ( !crsNodeList.isEmpty() )
 
  214      QDomElement crsElem = crsNodeList.at( 0 ).toElement();
 
  215      mCoordinateCustomCrs.
readXml( crsElem );
 
  221  if ( element.hasAttribute( QStringLiteral( 
"CoordinateAxisOrder" ) ) )
 
 
  235  QDomElement element = doc.createElement( QStringLiteral( 
"ProjectDisplaySettings" ) );
 
  238    QDomElement bearingElement =  doc.createElement( QStringLiteral( 
"BearingFormat" ) );
 
  239    mBearingFormat->writeXml( bearingElement, doc, context );
 
  240    element.appendChild( bearingElement );
 
  244    QDomElement geographicElement =  doc.createElement( QStringLiteral( 
"GeographicCoordinateFormat" ) );
 
  245    mGeographicCoordinateFormat->writeXml( geographicElement, doc, context );
 
  246    element.appendChild( geographicElement );
 
  249  element.setAttribute( QStringLiteral( 
"CoordinateType" ), 
qgsEnumValueToKey( mCoordinateType ) );
 
  250  if ( mCoordinateCustomCrs.
isValid() )
 
  252    QDomElement crsElem = doc.createElement( QStringLiteral( 
"CoordinateCustomCrs" ) );
 
  253    mCoordinateCustomCrs.
writeXml( crsElem, doc );
 
  254    element.appendChild( crsElem );
 
  257  element.setAttribute( QStringLiteral( 
"CoordinateAxisOrder" ), 
qgsEnumValueToKey( mCoordinateAxisOrder ) );
 
 
CoordinateDisplayType
Formats for displaying coordinates.
 
@ MapGeographic
Map Geographic CRS equivalent (stays unchanged if the map CRS is geographic)
 
CoordinateOrder
Order of coordinates.
 
@ Default
Respect the default axis ordering for the CRS, as defined in the CRS's parameters.
 
static QgsNumericFormatRegistry * numericFormatRegistry()
Gets the registry of available numeric formats.
 
Represents a coordinate reference system (CRS).
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
 
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
 
QgsCoordinateReferenceSystem toGeographicCrs() const
Returns the geographic CRS associated with this CRS object.
 
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
 
static QgsGeographicCoordinateNumericFormat * geographicCoordinateFormat()
Returns the default geographic coordinate format, which controls how geographic coordinates are displ...
 
static QgsBearingNumericFormat * bearingFormat()
Returns the default bearing format, which controls how angular bearings are displayed.
 
const QgsGeographicCoordinateNumericFormat * geographicCoordinateFormat() const
Returns the project's geographic coordinate format, which controls how geographic coordinates associa...
 
void geographicCoordinateFormatChanged()
Emitted when the geographic coordinate format changes.
 
void setCoordinateAxisOrder(Qgis::CoordinateOrder order)
Sets the default coordinate axis order to use when displaying coordinates for the project.
 
void setCoordinateCustomCrs(const QgsCoordinateReferenceSystem &crs)
Sets the coordinate custom CRS used when the project coordinate type is set to Qgis....
 
void coordinateAxisOrderChanged()
Emitted when the default coordinate axis order changes.
 
void reset()
Resets the settings to a default state.
 
const QgsBearingNumericFormat * bearingFormat() const
Returns the project bearing's format, which controls how bearings associated with the project are dis...
 
void bearingFormatChanged()
Emitted when the bearing format changes.
 
void coordinateCrsChanged()
Emitted when the coordinate CRS changes.
 
void coordinateTypeChanged()
Emitted when the default coordinate format changes.
 
QgsProjectDisplaySettings(QObject *parent=nullptr)
Constructor for QgsProjectDisplaySettings with the specified parent object.
 
void coordinateCustomCrsChanged()
Emitted when the coordinate custom CRS changes.
 
void setCoordinateType(Qgis::CoordinateDisplayType type)
Sets the default coordinate type for the project.
 
bool readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads the settings's state from a DOM element.
 
void setGeographicCoordinateFormat(QgsGeographicCoordinateNumericFormat *format)
Sets the project geographic coordinate format, which controls how geographic coordinates associated w...
 
~QgsProjectDisplaySettings() override
 
void setBearingFormat(QgsBearingNumericFormat *format)
Sets the project bearing format, which controls how bearings associated with the project are displaye...
 
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Returns a DOM element representing the settings.
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
void crsChanged()
Emitted when the crs() of the project has changed.
 
QString readEntry(const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const
Reads a string from the specified scope and key.
 
QgsCoordinateReferenceSystem crs
 
A container for the context for various read/write operations on objects.
 
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
 
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
 
const QgsCoordinateReferenceSystem & crs