I ended up writing a custom python Script to achieve what i was looking for:
from qgis.core import *
import math
layer = qgis.utils.iface.activeLayer()
def addHeight(fromPoint, newHeight, angle):
newX = fromPoint.x() - math.sin(math.radians(angle)) * newHeight
newY = fromPoint.y() + math.cos(math.radians(angle)) * newHeight
return QgsPointXY(newX,newY)
def addWidth(fromPoint, newWidth, angle):
newX = fromPoint.x() + math.cos(math.radians(angle)) * newWidth
newY = fromPoint.y() + math.sin(math.radians(angle)) * newWidth
return QgsPointXY(newX,newY)
def createNewRectangle(oldGeom, newHeight, newWidth, angle):
lowerLeft = oldGeom[0][0]
lowerRight = addWidth(lowerLeft, newWidth, angle)
uperRight = addHeight(lowerRight, newHeight, angle)
upperLeft = addHeight(lowerLeft, newHeight, angle)
newGeom = []
newGeom.append(lowerLeft)
newGeom.append(lowerRight)
newGeom.append(uperRight)
newGeom.append(upperLeft)
return [newGeom]
def update(fid, idx, value):
attribute = layer.attributeDisplayName(idx)
print(f"fid = {fid}, attribute = {attribute}, value = {value}")
feature = layer.getFeature(fid)
ansicht_hoehe_neu = \
(float(feature["seite_hoehe"]) \
- feature["seitenrand_oben"] \
- feature["seitenrand_unten"]) \
* feature["massstab"] / 1000.0
ansicht_breite_neu = \
(float(feature["seite_breite"]) \
- feature["seitenrand_links"] \
- feature["seitenrand_rechts"] \
- feature["breite_schriftfeld"]) \
* feature["massstab"] / 1000.0
winkel = feature["winkel"]
oldRectangle = feature.geometry().asPolygon()
newRectangle = createNewRectangle(oldRectangle, ansicht_hoehe_neu, ansicht_breite_neu, winkel)
if newRectangle != oldRectangle:
newGeom = QgsGeometry.fromPolygonXY(newRectangle)
layer.changeGeometry(fid, newGeom)
layer.attributeValueChanged.connect(update)
This script only works for rectangles. It basically connects attribute changes of the active layer (meaning the layer which is selected layer at the time the script is started) and connects attribute changes of that layer to the update
-function.
It is assumed, that the layer has the following attributes (attribute names are in german - english translation is given in brackets)
seite_hoehe
(page height)
seite_breite
(page width)
seitenrand_links
(page margin left)
seitenrand_rechts
(page margin right)
seitenrand_oben
(page margin top)
seitenrand_unten
(page margin bottom)
massstab
(scale)
winkel
(angle)
The attributes are used to calculate the resulting width and height of the world view and then (using the angle) to create a new rectangle to represent said world view and assign that rectangle as geometry of the corresponding object.
All in all this is a very "plan-centric" approach. The attributes representing angle, page width etc. have the advantage, that they can be "reused" to control the page layout of every single plan using a layout with atlas-functionality and heavy us of data driven overrides.
So basically in the end multiple plans with varying scales, rotations, page width and heights can be created using a single vector layer and a corresponding layout with atlas functionality.