Druck-refactor
This commit is contained in:
@@ -97,6 +97,7 @@ class PrintLayoutBaufreigabe(PrintLayout):
|
||||
plotmassstab: float,
|
||||
thema: str = "",
|
||||
fit_extent_to_map: bool = True,
|
||||
atlas_driven: bool = True,
|
||||
) -> Any:
|
||||
"""Erstellt ein Baufreigabe-Layout mit fester DIN A3/A4 Querformat-Groesse.
|
||||
|
||||
@@ -108,7 +109,7 @@ class PrintLayoutBaufreigabe(PrintLayout):
|
||||
extent: QgsRectangle der Kartenausdehnung
|
||||
plotmassstab: Plotmassstab (z.B. 5000 fuer 1:5000)
|
||||
thema: Name des Visibility-Presets (optional)
|
||||
fit_extent_to_map: Wird fuer Baufreigabe ignoriert (feste Kartenflaeche)
|
||||
fit_extent_to_map: Extent bei Bedarf auf das Karten-Seitenverhaeltnis erweitern
|
||||
|
||||
Returns:
|
||||
QgsPrintLayout objektInstance (wird im Layout-Dialog geoeffnet)
|
||||
@@ -152,10 +153,17 @@ class PrintLayoutBaufreigabe(PrintLayout):
|
||||
map_height_mm,
|
||||
)
|
||||
|
||||
_ = fit_extent_to_map
|
||||
if extent is not None and hasattr(extent, "isNull") and callable(extent.isNull) and not extent.isNull():
|
||||
fitted_extent = extent
|
||||
if fit_extent_to_map:
|
||||
fitted_extent = self._fit_extent_to_map_item(extent, map_width_mm, map_height_mm)
|
||||
|
||||
if fitted_extent is not None and hasattr(fitted_extent, "isNull") and callable(fitted_extent.isNull) and not fitted_extent.isNull():
|
||||
try:
|
||||
hauptkarte.zoomToExtent(extent)
|
||||
set_extent = getattr(hauptkarte, "setExtent", None)
|
||||
if callable(set_extent):
|
||||
set_extent(fitted_extent)
|
||||
else:
|
||||
hauptkarte.zoomToExtent(fitted_extent)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -165,31 +173,30 @@ class PrintLayoutBaufreigabe(PrintLayout):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Hauptkarte standardmaessig Atlas-gesteuert:
|
||||
# - Extent folgt aktuellem Atlas-Objekt
|
||||
# - Skalierung automatisch
|
||||
# - Margin entspricht ca. 1 cm Rand innerhalb der Kartenflaeche
|
||||
set_atlas_driven = getattr(hauptkarte, "setAtlasDriven", None)
|
||||
if callable(set_atlas_driven):
|
||||
try:
|
||||
set_atlas_driven(True)
|
||||
except Exception:
|
||||
pass
|
||||
# Atlas-Steuerung nur aktivieren, wenn Atlas tatsaechlich genutzt wird.
|
||||
# Andernfalls bleiben Extent/Scale unveraendert (z.B. Canvas-Ausschnitt).
|
||||
if atlas_driven:
|
||||
set_atlas_driven_fn = getattr(hauptkarte, "setAtlasDriven", None)
|
||||
if callable(set_atlas_driven_fn):
|
||||
try:
|
||||
set_atlas_driven_fn(True)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
set_atlas_scaling_mode = getattr(hauptkarte, "setAtlasScalingMode", None)
|
||||
atlas_mode_auto = getattr(getattr(QgsLayoutItemMap, "AtlasScalingMode", object), "Auto", None)
|
||||
if callable(set_atlas_scaling_mode) and atlas_mode_auto is not None:
|
||||
try:
|
||||
set_atlas_scaling_mode(atlas_mode_auto)
|
||||
except Exception:
|
||||
pass
|
||||
set_atlas_scaling_mode = getattr(hauptkarte, "setAtlasScalingMode", None)
|
||||
atlas_mode_auto = getattr(getattr(QgsLayoutItemMap, "AtlasScalingMode", object), "Auto", None)
|
||||
if callable(set_atlas_scaling_mode) and atlas_mode_auto is not None:
|
||||
try:
|
||||
set_atlas_scaling_mode(atlas_mode_auto)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
set_atlas_margin = getattr(hauptkarte, "setAtlasMargin", None)
|
||||
if callable(set_atlas_margin):
|
||||
try:
|
||||
set_atlas_margin(self._calc_atlas_margin_percent(map_width_mm, map_height_mm))
|
||||
except Exception:
|
||||
pass
|
||||
set_atlas_margin = getattr(hauptkarte, "setAtlasMargin", None)
|
||||
if callable(set_atlas_margin):
|
||||
try:
|
||||
set_atlas_margin(self._calc_atlas_margin_percent(map_width_mm, map_height_mm))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
set_frame_enabled = getattr(hauptkarte, "setFrameEnabled", None)
|
||||
if callable(set_frame_enabled):
|
||||
|
||||
Reference in New Issue
Block a user