mirror of
https://github.com/qgis/QGIS.git
synced 2025-07-04 00:02:42 -04:00
Compare commits
9 Commits
5b6f9208c4
...
a8a3fd8395
Author | SHA1 | Date | |
---|---|---|---|
|
a8a3fd8395 | ||
|
4c7ae43e46 | ||
|
56e5fa40cc | ||
|
4a01df3c39 | ||
|
6aa165ade6 | ||
|
161de03c78 | ||
|
58e6943ec4 | ||
|
b484c77e35 | ||
|
df7ad50b17 |
@ -95,6 +95,22 @@ should be calculated based on the layers in the project.
|
||||
.. seealso:: :py:func:`fullExtent`
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void setRestoreProjectExtentOnProjectLoad( bool state );
|
||||
%Docstring
|
||||
Sets whether the project's preset full extent should be restored when
|
||||
the project is loaded.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
||||
bool mainCanvasOpensAtProjectExtent();
|
||||
%Docstring
|
||||
Returns whether the project's preset full extent should be restored when
|
||||
the project is loaded.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
||||
QgsReferencedRectangle fullExtent() const;
|
||||
|
@ -95,6 +95,22 @@ should be calculated based on the layers in the project.
|
||||
.. seealso:: :py:func:`fullExtent`
|
||||
|
||||
.. versionadded:: 3.18
|
||||
%End
|
||||
|
||||
void setRestoreProjectExtentOnProjectLoad( bool state );
|
||||
%Docstring
|
||||
Sets whether the project's preset full extent should be restored when
|
||||
the project is loaded.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
||||
bool mainCanvasOpensAtProjectExtent();
|
||||
%Docstring
|
||||
Returns whether the project's preset full extent should be restored when
|
||||
the project is loaded.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
||||
QgsReferencedRectangle fullExtent() const;
|
||||
|
@ -98,8 +98,17 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
|
||||
|
||||
setupUi( this );
|
||||
|
||||
mExtentGroupBox->setTitleBase( tr( "Set Project Full Extent" ) );
|
||||
mExtentGroupBox->setMapCanvas( mapCanvas, false );
|
||||
mExtentGroupBox->setObjectName( "mExtentGroupBox" );
|
||||
mExtentGroupBox->setCheckable( true );
|
||||
|
||||
|
||||
mExtentWidget = new QgsExtentWidget( parent, QgsExtentWidget::ExpandedStyle );
|
||||
QVBoxLayout *mExtentGroupBoxLayout = qobject_cast<QVBoxLayout *>( mExtentGroupBox->layout() );
|
||||
mExtentGroupBoxLayout->insertWidget( 0, mExtentWidget );
|
||||
|
||||
mExtentWidget->setMapCanvas( mapCanvas, false );
|
||||
|
||||
mCheckBoxLoadProjectExtent->setObjectName( "mCheckBoxLoadProjectExtent" );
|
||||
|
||||
mAdvertisedExtentServer->setOutputCrs( QgsProject::instance()->crs() );
|
||||
mAdvertisedExtentServer->setMapCanvas( mapCanvas, false );
|
||||
@ -476,12 +485,13 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
|
||||
grpProjectScales->setChecked( QgsProject::instance()->viewSettings()->useProjectScales() );
|
||||
|
||||
const QgsReferencedRectangle presetExtent = QgsProject::instance()->viewSettings()->presetFullExtent();
|
||||
mExtentGroupBox->setOutputCrs( QgsProject::instance()->crs() );
|
||||
mExtentWidget->setOutputCrs( QgsProject::instance()->crs() );
|
||||
if ( presetExtent.isNull() )
|
||||
mExtentGroupBox->setOutputExtentFromUser( QgsProject::instance()->viewSettings()->fullExtent(), QgsProject::instance()->crs() );
|
||||
mExtentWidget->setOutputExtentFromUser( QgsProject::instance()->viewSettings()->fullExtent(), QgsProject::instance()->crs() );
|
||||
else
|
||||
mExtentGroupBox->setOutputExtentFromUser( presetExtent, presetExtent.crs() );
|
||||
mExtentWidget->setOutputExtentFromUser( presetExtent, presetExtent.crs() );
|
||||
mExtentGroupBox->setChecked( !presetExtent.isNull() );
|
||||
mCheckBoxLoadProjectExtent->setChecked( QgsProject::instance()->viewSettings()->mainCanvasOpensAtProjectExtent() );
|
||||
|
||||
mLayerCapabilitiesModel = new QgsLayerCapabilitiesModel( QgsProject::instance(), this );
|
||||
mLayerCapabilitiesModel->setLayerTreeModel( new QgsLayerTreeModel( QgsProject::instance()->layerTreeRoot(), mLayerCapabilitiesModel ) );
|
||||
@ -1209,6 +1219,7 @@ void QgsProjectProperties::apply()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mMapCanvas->enableMapTileRendering( mMapTileRenderingCheckBox->isChecked() );
|
||||
QgsProject::instance()->writeEntry( QStringLiteral( "RenderMapTile" ), QStringLiteral( "/" ), mMapTileRenderingCheckBox->isChecked() );
|
||||
|
||||
@ -1350,13 +1361,15 @@ void QgsProjectProperties::apply()
|
||||
|
||||
if ( mExtentGroupBox->isChecked() )
|
||||
{
|
||||
QgsProject::instance()->viewSettings()->setPresetFullExtent( QgsReferencedRectangle( mExtentGroupBox->outputExtent(), mExtentGroupBox->outputCrs() ) );
|
||||
QgsProject::instance()->viewSettings()->setPresetFullExtent( QgsReferencedRectangle( mExtentWidget->outputExtent(), mExtentWidget->outputCrs() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsProject::instance()->viewSettings()->setPresetFullExtent( QgsReferencedRectangle() );
|
||||
}
|
||||
|
||||
QgsProject::instance()->viewSettings()->setRestoreProjectExtentOnProjectLoad( mCheckBoxLoadProjectExtent->isChecked() );
|
||||
|
||||
bool isDirty = false;
|
||||
const QMap<QString, QgsMapLayer *> &mapLayers = QgsProject::instance()->mapLayers();
|
||||
for ( QMap<QString, QgsMapLayer *>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); ++it )
|
||||
@ -2043,7 +2056,7 @@ void QgsProjectProperties::crsChanged( const QgsCoordinateReferenceSystem &crs )
|
||||
cmbEllipsoid->setEnabled( false );
|
||||
}
|
||||
|
||||
mExtentGroupBox->setOutputCrs( crs );
|
||||
mExtentWidget->setOutputCrs( crs );
|
||||
mAdvertisedExtentServer->setOutputCrs( crs );
|
||||
}
|
||||
|
||||
|
@ -250,6 +250,8 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
|
||||
|
||||
QDoubleSpinBox *mWMSDefaultMapUnitsPerMm = nullptr;
|
||||
QgsScaleWidget *mWMSDefaultMapUnitScale = nullptr;
|
||||
QgsExtentWidget *mExtentWidget;
|
||||
|
||||
|
||||
QgsCoordinateReferenceSystem mCrs;
|
||||
|
||||
|
@ -20,10 +20,13 @@
|
||||
#include "qgsmaplayerutils.h"
|
||||
#include "qgscoordinatetransform.h"
|
||||
#include <QDomElement>
|
||||
#include "qgsmessagelog.h"
|
||||
|
||||
|
||||
QgsProjectViewSettings::QgsProjectViewSettings( QgsProject *project )
|
||||
: QObject( project )
|
||||
, mProject( project )
|
||||
, mRestoreProjectExtentOnProjectLoad( false )
|
||||
{
|
||||
|
||||
}
|
||||
@ -71,6 +74,17 @@ void QgsProjectViewSettings::setPresetFullExtent( const QgsReferencedRectangle &
|
||||
emit presetFullExtentChanged();
|
||||
}
|
||||
|
||||
void QgsProjectViewSettings::setRestoreProjectExtentOnProjectLoad( bool projectExtentCheckboxState )
|
||||
{
|
||||
mRestoreProjectExtentOnProjectLoad = projectExtentCheckboxState;
|
||||
}
|
||||
|
||||
bool QgsProjectViewSettings::mainCanvasOpensAtProjectExtent( )
|
||||
{
|
||||
return mRestoreProjectExtentOnProjectLoad;
|
||||
}
|
||||
|
||||
|
||||
QgsReferencedRectangle QgsProjectViewSettings::fullExtent() const
|
||||
{
|
||||
if ( !mProject )
|
||||
@ -198,6 +212,7 @@ bool QgsProjectViewSettings::readXml( const QDomElement &element, const QgsReadW
|
||||
}
|
||||
|
||||
mDefaultRotation = element.attribute( QStringLiteral( "rotation" ), QStringLiteral( "0" ) ).toDouble();
|
||||
mRestoreProjectExtentOnProjectLoad = element.attribute( QStringLiteral( "LoadProjectExtent" ), QStringLiteral( "0" ) ).toInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -207,6 +222,8 @@ QDomElement QgsProjectViewSettings::writeXml( QDomDocument &doc, const QgsReadWr
|
||||
QDomElement element = doc.createElement( QStringLiteral( "ProjectViewSettings" ) );
|
||||
element.setAttribute( QStringLiteral( "UseProjectScales" ), mUseProjectScales ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
|
||||
|
||||
element.setAttribute( QStringLiteral( "LoadProjectExtent" ), mRestoreProjectExtentOnProjectLoad ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
|
||||
|
||||
element.setAttribute( QStringLiteral( "rotation" ), qgsDoubleToString( mDefaultRotation ) );
|
||||
|
||||
QDomElement scales = doc.createElement( QStringLiteral( "Scales" ) );
|
||||
|
@ -104,6 +104,20 @@ class CORE_EXPORT QgsProjectViewSettings : public QObject
|
||||
*/
|
||||
void setPresetFullExtent( const QgsReferencedRectangle &extent );
|
||||
|
||||
/**
|
||||
* Sets whether the project's preset full extent should be restored when the project is loaded.
|
||||
*
|
||||
* \since QGIS 3.44
|
||||
*/
|
||||
void setRestoreProjectExtentOnProjectLoad( bool state );
|
||||
|
||||
/**
|
||||
* Returns whether the project's preset full extent should be restored when the project is loaded.
|
||||
*
|
||||
* \since QGIS 3.44
|
||||
*/
|
||||
bool mainCanvasOpensAtProjectExtent();
|
||||
|
||||
/**
|
||||
* Returns the full extent of the project, which represents the maximal limits of the project.
|
||||
*
|
||||
@ -228,6 +242,7 @@ class CORE_EXPORT QgsProjectViewSettings : public QObject
|
||||
bool mUseProjectScales = false;
|
||||
QgsReferencedRectangle mDefaultViewExtent;
|
||||
QgsReferencedRectangle mPresetFullExtent;
|
||||
bool mRestoreProjectExtentOnProjectLoad;
|
||||
double mDefaultRotation = 0;
|
||||
};
|
||||
|
||||
|
@ -3271,7 +3271,14 @@ void QgsMapCanvas::readProject( const QDomDocument &doc )
|
||||
// never manually set the crs for the main canvas - this is instead connected to the project CRS
|
||||
setDestinationCrs( tmpSettings.destinationCrs() );
|
||||
}
|
||||
if ( QgsProject::instance()->viewSettings()->mainCanvasOpensAtProjectExtent() && objectName() == QLatin1String( "theMapCanvas" ) )
|
||||
{
|
||||
zoomToProjectExtent();
|
||||
}
|
||||
else
|
||||
{
|
||||
setExtent( tmpSettings.extent() );
|
||||
}
|
||||
setRotation( tmpSettings.rotation() );
|
||||
enableMapTileRendering( tmpSettings.testFlag( Qgis::MapSettingsFlag::RenderMapTile ) );
|
||||
|
||||
|
@ -1010,21 +1010,21 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsExtentGroupBox" name="mExtentGroupBox">
|
||||
<property name="toolTip">
|
||||
<string>If checked the preset extent will be used as the full extent of the project. If unchecked, the project's full extent will be calculated using the full extent of all layers in the project.</string>
|
||||
</property>
|
||||
<widget class="QgsCollapsibleGroupBox" name="mExtentGroupBox">
|
||||
<property name="title">
|
||||
<string>Extent (current: none)</string>
|
||||
<string>Set Project Full Extent</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_30">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mCheckBoxLoadProjectExtent">
|
||||
<property name="text">
|
||||
<string>Use as extent for the main canvas when opening the project</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
@ -1132,8 +1132,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>528</width>
|
||||
<height>85</height>
|
||||
<width>685</width>
|
||||
<height>791</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
@ -3601,12 +3601,6 @@
|
||||
<extends>QDateTimeEdit</extends>
|
||||
<header>qgsdatetimeedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsExtentGroupBox</class>
|
||||
<extends>QgsCollapsibleGroupBox</extends>
|
||||
<header>qgsextentgroupbox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsFontButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
@ -3699,7 +3693,6 @@
|
||||
<tabstop>pbnRemoveScale</tabstop>
|
||||
<tabstop>pbnImportScales</tabstop>
|
||||
<tabstop>pbnExportScales</tabstop>
|
||||
<tabstop>mExtentGroupBox</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>scrollArea_3</tabstop>
|
||||
<tabstop>mShowDatumTransformDialogCheckBox</tabstop>
|
||||
|
Loading…
x
Reference in New Issue
Block a user