qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.52k stars 2.99k forks source link

Print Layout - Map postion based on expression ignores field "Page" #50396

Open pathmapper opened 2 years ago

pathmapper commented 2 years ago

What is the bug or the crash?

Print Layout - Map postion based on expression ignores field "Page", instead the position is only calculated from reference point on page 1.

grafik

Steps to reproduce the issue

  1. Open sample project: bug_layout_position.zip
  2. Open layout "test".
  3. Click on map on page 2.
  4. Item Properties -> Position and Size
  5. For field Y create expression: 0
  6. See error: the position is only calculated from reference point on page 1, field Page is ignored.

https://user-images.githubusercontent.com/20856381/192968306-67ef6ded-c657-4997-820d-4e593cbf352d.mp4

Versions

QGIS version 3.26.3-Buenos Aires QGIS code revision 65e4edfdada
Qt version 5.15.3
Python version 3.9.5
GDAL/OGR version 3.5.1
PROJ version 9.1.0
EPSG Registry database version v10.074 (2022-08-01)
GEOS version 3.10.3-CAPI-1.16.1
SQLite version 3.38.1
PDAL version 2.4.3
PostgreSQL client version unknown
SpatiaLite version 5.0.1
QWT version 6.1.6
QScintilla2 version 2.13.1
OS version Windows 10 Version 1809
       

Active Python plugins db_manager | 0.1.20 grassprovider | 2.12.99 MetaSearch | 0.3.6 processing | 2.12.99 sagaprovider | 2.12.99

Supported QGIS version

New profile

Additional context

No response

roya0045 commented 2 years ago

Yeah and there's not way to get the attributes of a given page and if I recall we can't get the position of items, which is a missing feature.

Though in the meantime you can possibly used the variable @layout_pageoffsets to get the top of the page you want.

agiudiceandrea commented 2 years ago

It seems to me the issue may be in https://github.com/qgis/QGIS/blob/6af23a67be78a04c1c6c46cf4f7fd0b38cb61e37/src/core/layout/qgslayoutitem.cpp#L467-L509 where the conversion of the position relative to the page to a an absolute position based on the page number https://github.com/qgis/QGIS/blob/6af23a67be78a04c1c6c46cf4f7fd0b38cb61e37/src/core/layout/qgslayoutitem.cpp#L477-L480 is made before the data defined values are applyed and not after as it probably should be.

pathmapper commented 2 years ago

Thanks @roya0045, @agiudiceandrea - @layout_pageoffsets is indeed a good workaround.