Compare commits
8 Commits
82d5dcd6a3
...
25.11.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f69ee89a3c | ||
|
|
e8cc531a6a | ||
|
|
b665998da6 | ||
|
|
8a5adb05f3 | ||
|
|
d702b251d7 | ||
|
|
1eeb31e9ae | ||
| 09729cdc60 | |||
|
|
ea2fd48ea3 |
28
__init__.py
28
__init__.py
@@ -1,31 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# import debugpy
|
||||
|
||||
# _debugger_started = False
|
||||
|
||||
def classFactory(iface):
|
||||
from .main import Verfahrensgebiet
|
||||
# start_debugger()
|
||||
return Verfahrensgebiet(iface)
|
||||
|
||||
# def start_debugger():
|
||||
# global _debugger_started
|
||||
|
||||
# if _debugger_started:
|
||||
# return # Schon gestartet – nichts tun
|
||||
|
||||
# try:
|
||||
# debugpy.listen(5678)
|
||||
# _debugger_started = True
|
||||
# print("Debugger wartet auf Verbindung...")
|
||||
# except RuntimeError:
|
||||
# print("Debugger läuft bereits – Verbindung wird erwartet...")
|
||||
|
||||
# if debugpy.is_client_connected():
|
||||
# print("Debugger verbunden – Plugin läuft")
|
||||
# else:
|
||||
# try:
|
||||
# debugpy.wait_for_client()
|
||||
# print("Debugger verbunden – Plugin läuft")
|
||||
# except RuntimeError as e:
|
||||
# print(f"Fehler beim Warten auf Debugger: {e}")
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
BIN
icons/icon.png
BIN
icons/icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 607 B |
85
logic/alkis_verfahrensgebiet.py
Normal file
85
logic/alkis_verfahrensgebiet.py
Normal file
@@ -0,0 +1,85 @@
|
||||
import os
|
||||
from qgis.core import (
|
||||
QgsVectorLayer, QgsProject, QgsFeature, QgsField,
|
||||
QgsFeatureRequest, QgsGeometry
|
||||
)
|
||||
from qgis.PyQt.QtWidgets import QMessageBox
|
||||
from qgis.PyQt.QtCore import QVariant
|
||||
from sn_basis import get_variable
|
||||
|
||||
alkis_NAS_url = "https://geodienste.sachsen.de/aaa/public_alkis/nas/wfs"
|
||||
typename = "adv:AX_BauRaumOderBodenordnungsrecht"
|
||||
|
||||
|
||||
def alkis_verfahrensgebiet(tab_widget):
|
||||
verfahrensnummer = get_variable("verfahrensnummer")
|
||||
if not verfahrensnummer:
|
||||
QMessageBox.critical(tab_widget, "Fehler",
|
||||
"Die Projektvariable 'sn_verfahrensnummer' ist nicht gesetzt.")
|
||||
tab_widget.setze_haken(tab_widget.haken1, False)
|
||||
return None, False
|
||||
|
||||
project = QgsProject.instance()
|
||||
existing_layers = project.mapLayersByName("Verfahrensgebiet")
|
||||
if existing_layers:
|
||||
reply = QMessageBox.question(
|
||||
tab_widget,
|
||||
"Layer bereits vorhanden",
|
||||
"Der Layer 'Verfahrensgebiet' existiert bereits.\n"
|
||||
"Möchten Sie ihn löschen und neu laden?",
|
||||
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
|
||||
QMessageBox.StandardButton.No
|
||||
)
|
||||
if reply == QMessageBox.StandardButton.Yes:
|
||||
for lyr in existing_layers:
|
||||
project.removeMapLayer(lyr.id())
|
||||
else:
|
||||
# Vorhandenen Layer zurückgeben, kein Neu-Laden
|
||||
return existing_layers[0], False
|
||||
|
||||
# WFS mit Filter laden
|
||||
wfs_uri_find = (
|
||||
f"url='{alkis_NAS_url}' typename='{typename}' srsname='EPSG:25833' "
|
||||
f"sql=SELECT * FROM AX_BauRaumOderBodenordnungsrecht "
|
||||
f"WHERE bezeichnung LIKE '{verfahrensnummer}%'"
|
||||
)
|
||||
temp_layer = QgsVectorLayer(wfs_uri_find, "TempVerfahrensgebiet", "WFS")
|
||||
|
||||
if not temp_layer.isValid():
|
||||
QMessageBox.critical(tab_widget, "Fehler", "Layer konnte nicht geladen werden.")
|
||||
return None, False
|
||||
|
||||
features = list(temp_layer.getFeatures())
|
||||
if not features:
|
||||
QMessageBox.critical(tab_widget, "Fehler",
|
||||
f"Verfahrenskennzeichen {verfahrensnummer} nicht im WFS gefunden.")
|
||||
return None, False
|
||||
|
||||
# Geometrie bestimmen
|
||||
if len(features) == 1:
|
||||
union_geom = features[0].geometry()
|
||||
else:
|
||||
geoms = [f.geometry() for f in features]
|
||||
union_geom = QgsGeometry.unaryUnion(geoms)
|
||||
|
||||
if union_geom is None or union_geom.isEmpty():
|
||||
QMessageBox.critical(tab_widget, "Fehler", "Keine Geometrien zum Verschmelzen gefunden.")
|
||||
return None, False
|
||||
|
||||
# Memory-Layer mit festem Namen "Verfahrensgebiet"
|
||||
crs = temp_layer.crs().authid()
|
||||
memory_layer = QgsVectorLayer(f"Polygon?crs={crs}", "Verfahrensgebiet", "memory")
|
||||
pr = memory_layer.dataProvider()
|
||||
|
||||
# Feld "VKZ" hinzufügen
|
||||
pr.addAttributes([QgsField("VKZ", QVariant.String)])
|
||||
memory_layer.updateFields()
|
||||
|
||||
# Feature mit Geometrie erstellen
|
||||
feat_union = QgsFeature()
|
||||
feat_union.setGeometry(union_geom)
|
||||
feat_union.setAttributes([verfahrensnummer])
|
||||
pr.addFeatures([feat_union])
|
||||
memory_layer.updateExtents()
|
||||
|
||||
return memory_layer, True
|
||||
101
main.py
101
main.py
@@ -1,81 +1,52 @@
|
||||
# Import grundlegender Qt- und QGIS-Komponenten
|
||||
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication, Qt
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
from qgis.PyQt.QtWidgets import QAction, QMessageBox
|
||||
from qgis.utils import plugins
|
||||
from sn_basis.ui.dockmanager import DockManager
|
||||
from .ui.dockwidget import DockWidget
|
||||
|
||||
# Import der generierten Ressourcen (z. B. Icons)
|
||||
from .resources import *
|
||||
|
||||
# Import der gemeinsamen UI-Klasse für Menü und Symbolleiste
|
||||
from .shared import UI
|
||||
# from .shared import DockManager
|
||||
|
||||
# Import des Dockwidgets, das beim Ausführen des Plugins angezeigt wird
|
||||
from .ui.sn_verfahrensgebiet_dockwidget import VerfahrensgebietDockWidget
|
||||
import os.path
|
||||
|
||||
class Verfahrensgebiet:
|
||||
"""
|
||||
Hauptklasse des Plugins. Verwaltet die Initialisierung, GUI-Integration und das Dockwidget.
|
||||
"""
|
||||
|
||||
def __init__(self, iface):
|
||||
# iface: QGIS-Schnittstelle zur Interaktion mit der Anwendung
|
||||
self.iface = iface
|
||||
self.plugin_dir = os.path.dirname(__file__) # Pfad zum Plugin-Verzeichnis
|
||||
self.action = None
|
||||
self.dockwidget = None
|
||||
|
||||
self.actions = [] # Platzhalter für spätere Aktionsverwaltung (optional)
|
||||
self.pluginIsActive = False # Statusflag, ob das Plugin aktiv ist
|
||||
self.dockwidget = None # Referenz auf das Dockwidget
|
||||
# Namen automatisch aus Klassennamen ableiten
|
||||
self.plugin_name = self.__class__.__name__
|
||||
self.dock_name = f"sn_dock_{self.plugin_name.lower()}"
|
||||
|
||||
def initGui(self):
|
||||
"""
|
||||
Wird beim Laden des Plugins aufgerufen. Fügt Menüeintrag und Symbolleistenaktion hinzu.
|
||||
"""
|
||||
self.action_text = "Verfahrensgebiet" # Einheitlicher Text für Menü und Toolbar
|
||||
icon = QIcon(":/sn_plugin1/icons/icon.png") # Icon aus Ressourcen laden
|
||||
self.ui = UI() # Gemeinsame UI-Instanz für Menü und Toolbar
|
||||
self.ui.add_action(self.action_text, self.run, icon, tooltip="Öffnet Verfahrensgebiet")
|
||||
|
||||
def onClosePlugin(self):
|
||||
"""
|
||||
Wird aufgerufen, wenn das Dockwidget geschlossen wird. Setzt den Aktivitätsstatus zurück.
|
||||
"""
|
||||
self.dockwidget.closingPlugin.disconnect(self.onClosePlugin)
|
||||
self.pluginIsActive = False
|
||||
basis = plugins.get("sn_basis")
|
||||
if basis and basis.ui:
|
||||
self.action = basis.ui.add_action(
|
||||
self.plugin_name,
|
||||
self.run,
|
||||
tooltip=f"Öffnet {self.plugin_name}",
|
||||
priority=10
|
||||
)
|
||||
basis.ui.finalize_menu_and_toolbar()
|
||||
|
||||
def unload(self):
|
||||
"""
|
||||
Wird beim Deaktivieren des Plugins aufgerufen. Entfernt Menü- und Toolbar-Eintrag.
|
||||
"""
|
||||
self.ui.remove_action(self.action_text)
|
||||
if self.dockwidget:
|
||||
self.iface.removeDockWidget(self.dockwidget)
|
||||
self.dockwidget.deleteLater()
|
||||
self.dockwidget = None
|
||||
|
||||
if self.action:
|
||||
basis = plugins.get("sn_basis")
|
||||
if basis and basis.ui:
|
||||
# Action aus Menü und Toolbar entfernen
|
||||
basis.ui.remove_action(self.action)
|
||||
self.action = None
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Wird beim Klick auf Menüeintrag oder Symbolleistenaktion ausgeführt.
|
||||
Zeigt das Dockwidget an.
|
||||
"""
|
||||
if 'sn_basis' not in plugins:
|
||||
QMessageBox.warning(None, "Abhängigkeit fehlt",
|
||||
"Das Plugin 'LNO Sachsen | Basisfunktionen' ist nicht installiert oder nicht aktiviert.\nBitte installieren und aktivieren, um fortzufahren.")
|
||||
return # Plugin nicht starten
|
||||
|
||||
# Prüfen, ob das eigene Dockwidget existiert und aktuell sichtbar ist
|
||||
dock_visible = self.dockwidget is not None and self.dockwidget.isVisible()
|
||||
self.dockwidget = DockWidget(self.iface.mainWindow(), subtitle=self.plugin_name)
|
||||
self.dockwidget.setObjectName(self.dock_name)
|
||||
|
||||
if not dock_visible:
|
||||
# Pluginstatus setzen, damit z. B. beim Schließen korrekt zurückgesetzt werden kann
|
||||
self.pluginIsActive = True
|
||||
# Action-Referenz im Dock speichern
|
||||
self.dockwidget.action = self.action
|
||||
|
||||
# Falls noch kein Dockwidget existiert, wird es jetzt erzeugt
|
||||
if self.dockwidget is None:
|
||||
self.dockwidget = VerfahrensgebietDockWidget()
|
||||
self.dockwidget.closingPlugin.connect(self.onClosePlugin)
|
||||
DockManager.show(self.dockwidget)
|
||||
|
||||
# Dock anzeigen und ggf. andere Docks schließen
|
||||
from sn_basis.ui.dockmanager import DockManager
|
||||
DockManager.show(self.dockwidget)
|
||||
else:
|
||||
# Falls das eigene Dock bereits sichtbar ist, wird keine Aktion ausgeführt
|
||||
pass
|
||||
# Toolbar-Button als aktiv markieren
|
||||
basis = plugins.get("sn_basis")
|
||||
if basis and basis.ui:
|
||||
basis.ui.set_active_plugin(self.action)
|
||||
|
||||
22
metadata.txt
22
metadata.txt
@@ -1,21 +1,13 @@
|
||||
[general]
|
||||
name=LNO Sachsen | Verfahrensgebiet
|
||||
qgisMinimumVersion=3.0
|
||||
description=Dieses Plugin ist ein Test
|
||||
version=25.10.1
|
||||
description=Plugin zum Erzeugen eines Objektes "Verfahrensgebiet"
|
||||
version=25.11.3
|
||||
author=Michael Otto
|
||||
email=michael.otto@landkreis-mittelsachsen.de
|
||||
|
||||
about=Provide a brief description of the plugin and its purpose.
|
||||
|
||||
hasProcessingProvider=no
|
||||
tags=python
|
||||
|
||||
about=Plugin zum Erzeugen eines Objektes "Verfahrensgebiet"
|
||||
category=Plugins
|
||||
icon=icon.png
|
||||
experimental=True
|
||||
|
||||
deprecated=False
|
||||
|
||||
server=False
|
||||
|
||||
homepage=https://entwicklung.vln-sn.de/AG_QGIS/Plugin_SN_Verfahrensgebiet
|
||||
repository=https://entwicklung.vln-sn.de/AG_QGIS/Repository
|
||||
supportsQt6=true
|
||||
experimental=true
|
||||
101
resources.py
101
resources.py
@@ -1,101 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Resource object code
|
||||
#
|
||||
# Created by: The Resource Compiler for PyQt5 (Qt v5.15.2)
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt5 import QtCore
|
||||
|
||||
qt_resource_data = b"\
|
||||
\x00\x00\x02\x5f\
|
||||
\x89\
|
||||
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
|
||||
\x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\
|
||||
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0e\xc3\x00\x00\x0e\xc3\
|
||||
\x01\xc7\x6f\xa8\x64\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6f\x66\
|
||||
\x74\x77\x61\x72\x65\x00\x77\x77\x77\x2e\x69\x6e\x6b\x73\x63\x61\
|
||||
\x70\x65\x2e\x6f\x72\x67\x9b\xee\x3c\x1a\x00\x00\x01\xec\x49\x44\
|
||||
\x41\x54\x58\x85\xed\x96\x4f\x4b\x54\x51\x18\xc6\x7f\x8f\xdc\x60\
|
||||
\x5c\x95\x21\x8c\x90\xe4\xd4\xa2\x75\x9b\x5c\xe7\x4a\x23\x62\x08\
|
||||
\xdc\xda\xa6\x0f\x20\x41\x0b\x21\x68\x53\x8b\x96\x2e\x12\xa1\x6d\
|
||||
\xa0\x5f\x20\x12\xbf\x80\x6e\x5a\x24\x09\x6e\x24\xff\x20\xa1\x09\
|
||||
\xb3\xc9\x9c\x19\x32\xde\x16\xf7\x1d\x3a\x5c\xef\xf5\xde\x1c\x1d\
|
||||
\x25\xe6\x85\xcb\xb9\xf7\x37\xef\xb9\xef\x73\xce\x79\xce\x99\x2b\
|
||||
\xe0\x07\x50\xe2\x62\xa2\x1e\x01\x57\x80\x3e\xa0\xd9\xe1\xe2\x25\
|
||||
\xe0\x7b\xe4\x0f\x47\x66\xf6\xab\x93\xd5\x25\x45\x00\x3d\x9d\x2c\
|
||||
\x9a\x16\x5d\x01\x97\x5f\x80\xa4\x3e\x49\x6f\x25\x55\x03\x56\x96\
|
||||
\x34\x23\x69\xec\x84\x7e\x77\x24\xcd\x4a\x7a\x93\x57\xa3\x01\x94\
|
||||
\xcc\x8c\xb4\x0b\xb8\x0f\x18\xf0\x22\x60\x0f\x9d\x3d\x4b\xc9\x8f\
|
||||
\x80\x49\xe0\xc0\x73\xf6\x33\xde\xdb\x0b\xd4\x8b\x2c\xc1\x2d\x6f\
|
||||
\x37\x02\x36\xe4\xed\x66\x62\xd4\x77\x81\x4f\xc0\x34\xf0\xb9\xc0\
|
||||
\xbb\x89\xf2\x53\xa8\x14\x15\x00\xbc\x06\xae\x02\x8f\x81\x65\x60\
|
||||
\xf7\xd4\x02\x24\x8d\x00\xa3\x40\x6b\x9d\x9f\x04\x3e\x78\xe0\xed\
|
||||
\x53\x49\x4b\x66\x36\xe7\xcf\x2f\x81\x35\x33\xab\x4b\x2a\xe7\x15\
|
||||
\x6f\x45\xaa\x07\x80\x57\x40\x0d\x38\x02\x7e\xfb\x7d\x2d\x85\x7d\
|
||||
\xc8\x58\xe3\x32\x05\x3c\x90\x29\x20\x48\xdc\xf4\x51\x85\xec\x1b\
|
||||
\xb0\x92\xd5\xe7\x5f\x04\x9c\x68\x42\x3f\xaf\x6f\x00\x5b\x01\x2b\
|
||||
\x01\x03\x21\x6b\x27\xf2\x76\xc1\x20\xb1\x4f\xb6\x03\x56\x01\x94\
|
||||
\x60\xa7\x8e\x54\x13\x4a\xea\xf1\x42\xf7\x1c\xfd\x94\x74\xdb\xef\
|
||||
\x87\x03\x36\x64\x66\x6d\xcf\xc4\x31\x0f\x78\x61\x2b\x78\x55\xda\
|
||||
\xf1\x40\xd6\x36\xfc\x02\x8c\x03\x13\x40\x15\x98\x02\xbe\xfa\x6f\
|
||||
\x13\xc0\x23\xe0\x39\xb1\x41\x77\xce\x7c\x06\x02\x95\xef\x7d\x14\
|
||||
\x03\x01\x9b\x77\x76\xfd\xdc\x77\x01\xf1\x89\xd7\x04\xf6\x12\xec\
|
||||
\xc0\xcc\x6a\xed\x8e\x1c\xf2\x77\xc1\x4d\x60\xdb\x5c\x72\x20\x20\
|
||||
\xd5\x78\x92\xde\x49\x32\x49\xc6\xdf\x63\xb8\xbf\xc5\x24\x35\x25\
|
||||
\xf5\x86\x7d\xf2\xfe\x0b\x16\x80\xf5\x04\xfb\x08\xac\x66\xe4\x2f\
|
||||
\x12\x4f\x7b\x56\x1c\x92\xf8\xf8\x15\xb1\x07\xae\x99\x59\x23\x47\
|
||||
\xcc\x99\x86\xcf\x44\xed\xf2\x7f\x11\x75\x05\x74\x05\xfc\xf7\x02\
|
||||
\x5a\x07\x51\x5d\xd2\x45\xd4\x6f\xfc\x01\xf3\xb6\x83\x46\x54\x23\
|
||||
\xdb\x20\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
|
||||
"
|
||||
|
||||
qt_resource_name = b"\
|
||||
\x00\x0a\
|
||||
\x07\x34\x98\xd1\
|
||||
\x00\x73\
|
||||
\x00\x6e\x00\x5f\x00\x70\x00\x6c\x00\x75\x00\x67\x00\x69\x00\x6e\x00\x31\
|
||||
\x00\x05\
|
||||
\x00\x6f\xa6\x53\
|
||||
\x00\x69\
|
||||
\x00\x63\x00\x6f\x00\x6e\x00\x73\
|
||||
\x00\x08\
|
||||
\x0a\x61\x5a\xa7\
|
||||
\x00\x69\
|
||||
\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
|
||||
"
|
||||
|
||||
qt_resource_struct_v1 = b"\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
|
||||
\x00\x00\x00\x1a\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
|
||||
\x00\x00\x00\x2a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
|
||||
"
|
||||
|
||||
qt_resource_struct_v2 = b"\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
|
||||
\x00\x00\x00\x00\x00\x00\x00\x00\
|
||||
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
|
||||
\x00\x00\x00\x00\x00\x00\x00\x00\
|
||||
\x00\x00\x00\x1a\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
|
||||
\x00\x00\x00\x00\x00\x00\x00\x00\
|
||||
\x00\x00\x00\x2a\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
|
||||
\x00\x00\x01\x99\x28\x6e\x23\x10\
|
||||
"
|
||||
|
||||
qt_version = [int(v) for v in QtCore.qVersion().split('.')]
|
||||
if qt_version < [5, 8, 0]:
|
||||
rcc_version = 1
|
||||
qt_resource_struct = qt_resource_struct_v1
|
||||
else:
|
||||
rcc_version = 2
|
||||
qt_resource_struct = qt_resource_struct_v2
|
||||
|
||||
def qInitResources():
|
||||
QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||
|
||||
def qCleanupResources():
|
||||
QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||
|
||||
qInitResources()
|
||||
@@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/sn_plugin1" >
|
||||
<file>icons/icon.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,11 +0,0 @@
|
||||
@echo off
|
||||
REM Wechsle ins Plugin-Hauptverzeichnis (eine Ebene über /scripts)
|
||||
cd /d %~dp0\..
|
||||
|
||||
call "C:\Program Files\QGIS 3.34.5\bin\o4w_env.bat"
|
||||
|
||||
REM Kompiliere die Ressourcen-Datei
|
||||
pyrcc5 resources.qrc -o resources.py
|
||||
|
||||
@echo on
|
||||
echo Ressourcen wurden erfolgreich kompiliert.
|
||||
@@ -1,2 +0,0 @@
|
||||
from .ui import UI
|
||||
|
||||
75
shared/ui.py
75
shared/ui.py
@@ -1,75 +0,0 @@
|
||||
from qgis.PyQt.QtWidgets import QMenu, QToolBar, QAction
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
from qgis.utils import iface
|
||||
|
||||
_shared_toolbar = None # globale Toolbar-Instanz
|
||||
_shared_menu = None # globale Menü-Instanz
|
||||
|
||||
class UI:
|
||||
TITLE = "LNO Sachsen"
|
||||
|
||||
def __init__(self):
|
||||
self.menu = self._get_or_create_menu()
|
||||
self.toolbar = self._get_or_create_toolbar()
|
||||
|
||||
def _get_or_create_menu(self):
|
||||
global _shared_menu
|
||||
if _shared_menu:
|
||||
return _shared_menu
|
||||
|
||||
menubar = iface.mainWindow().menuBar()
|
||||
for action in menubar.actions():
|
||||
if action.menu() and action.text() == self.TITLE:
|
||||
_shared_menu = action.menu()
|
||||
return _shared_menu
|
||||
|
||||
menu = QMenu(self.TITLE, iface.mainWindow())
|
||||
menu.setObjectName(self.TITLE)
|
||||
menubar.addMenu(menu)
|
||||
_shared_menu = menu
|
||||
return menu
|
||||
|
||||
def _get_or_create_toolbar(self):
|
||||
global _shared_toolbar
|
||||
if _shared_toolbar:
|
||||
return _shared_toolbar
|
||||
|
||||
main_window = iface.mainWindow()
|
||||
toolbar = main_window.findChild(QToolBar, self.TITLE)
|
||||
if not toolbar:
|
||||
toolbar = QToolBar(self.TITLE, main_window)
|
||||
toolbar.setObjectName(self.TITLE)
|
||||
main_window.addToolBar(toolbar)
|
||||
|
||||
_shared_toolbar = toolbar
|
||||
return toolbar
|
||||
|
||||
def add_action(self, text, callback, icon=None, tooltip=None):
|
||||
# Menüeintrag
|
||||
if not any(a.text() == text for a in self.menu.actions()):
|
||||
action = QAction(icon, text, iface.mainWindow()) if icon else QAction(text, iface.mainWindow())
|
||||
if tooltip:
|
||||
action.setToolTip(tooltip)
|
||||
action.triggered.connect(callback)
|
||||
self.menu.addAction(action)
|
||||
|
||||
# Symbolleistenaktion
|
||||
if not any(a.text() == text for a in self.toolbar.actions()):
|
||||
action = QAction(icon, text, iface.mainWindow()) if icon else QAction(text, iface.mainWindow())
|
||||
if tooltip:
|
||||
action.setToolTip(tooltip)
|
||||
action.triggered.connect(callback)
|
||||
self.toolbar.addAction(action)
|
||||
|
||||
def remove_action(self, text):
|
||||
# Menüeintrag entfernen
|
||||
for act in self.menu.actions():
|
||||
if act.text() == text:
|
||||
self.menu.removeAction(act)
|
||||
break
|
||||
|
||||
# Symbolleistenaktion entfernen
|
||||
for act in self.toolbar.actions():
|
||||
if act.text() == text:
|
||||
self.toolbar.removeAction(act)
|
||||
break
|
||||
@@ -1 +0,0 @@
|
||||
from .tab_verfahrensgebiet import TabVerfahrensgebietWidget
|
||||
8
ui/dockwidget.py
Normal file
8
ui/dockwidget.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from sn_basis.ui.tabs.settings_tab import SettingsTab
|
||||
from sn_verfahrensgebiet.ui.tabs.tab_a import TabA
|
||||
from sn_verfahrensgebiet.ui.tabs.tab_b import TabB
|
||||
from sn_basis.ui.base_dockwidget import BaseDockWidget
|
||||
|
||||
|
||||
class DockWidget(BaseDockWidget):
|
||||
tabs = [TabA, SettingsTab]
|
||||
@@ -1,31 +0,0 @@
|
||||
from qgis.PyQt.QtWidgets import QDockWidget, QTabWidget, QVBoxLayout, QWidget
|
||||
from qgis.PyQt.QtCore import pyqtSignal
|
||||
|
||||
from sn_basis.ui.tab_projekt import TabProjektWidget
|
||||
|
||||
from ..ui import TabVerfahrensgebietWidget
|
||||
|
||||
class VerfahrensgebietDockWidget(QDockWidget):
|
||||
|
||||
closingPlugin = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setWindowTitle("LNO Sachsen | Verfahrensgebiet")
|
||||
|
||||
container = QWidget()
|
||||
layout = QVBoxLayout(container)
|
||||
|
||||
self.tabWidget = QTabWidget()
|
||||
layout.addWidget(self.tabWidget)
|
||||
|
||||
self.setWidget(container)
|
||||
|
||||
# Tabs hinzufügen
|
||||
self.tabWidget.addTab(TabVerfahrensgebietWidget(self), "Verfahrensgebiet")
|
||||
self.tabWidget.addTab(TabProjektWidget(self), "Projekt")
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.closingPlugin.emit()
|
||||
event.accept()
|
||||
@@ -1,12 +0,0 @@
|
||||
# tab_info.py
|
||||
from qgis.PyQt import uic
|
||||
from qgis.PyQt.QtWidgets import QWidget
|
||||
import os
|
||||
|
||||
FORM_CLASS, _ = uic.loadUiType(os.path.join(
|
||||
os.path.dirname(__file__), 'tab_verfahrensgebiet.ui'))
|
||||
|
||||
class TabVerfahrensgebietWidget(QWidget, FORM_CLASS):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>538</width>
|
||||
<height>295</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>50</y>
|
||||
<width>47</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tab 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
140
ui/tabs/Verfahrensgebiet.qml
Normal file
140
ui/tabs/Verfahrensgebiet.qml
Normal file
@@ -0,0 +1,140 @@
|
||||
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
|
||||
<qgis version="3.40.7-Bratislava" styleCategories="Symbology">
|
||||
<renderer-v2 referencescale="-1" forceraster="0" enableorderby="0" type="singleSymbol" symbollevels="0">
|
||||
<symbols>
|
||||
<symbol is_animated="0" frame_rate="10" clip_to_extent="1" type="fill" alpha="1" force_rhr="0" name="0">
|
||||
<data_defined_properties>
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="" name="name"/>
|
||||
<Option name="properties"/>
|
||||
<Option type="QString" value="collection" name="type"/>
|
||||
</Option>
|
||||
</data_defined_properties>
|
||||
<layer locked="0" id="{feca00b2-500a-4c9a-b285-67ba2d99d8f6}" enabled="1" class="SimpleLine" pass="0">
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="0" name="align_dash_pattern"/>
|
||||
<Option type="QString" value="square" name="capstyle"/>
|
||||
<Option type="QString" value="5;2" name="customdash"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="customdash_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="customdash_unit"/>
|
||||
<Option type="QString" value="0" name="dash_pattern_offset"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="dash_pattern_offset_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="dash_pattern_offset_unit"/>
|
||||
<Option type="QString" value="0" name="draw_inside_polygon"/>
|
||||
<Option type="QString" value="round" name="joinstyle"/>
|
||||
<Option type="QString" value="215,168,255,255,rgb:0.84313725490196079,0.6588235294117647,1,1" name="line_color"/>
|
||||
<Option type="QString" value="solid" name="line_style"/>
|
||||
<Option type="QString" value="1.5" name="line_width"/>
|
||||
<Option type="QString" value="MM" name="line_width_unit"/>
|
||||
<Option type="QString" value="-0.75" name="offset"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="offset_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="offset_unit"/>
|
||||
<Option type="QString" value="0" name="ring_filter"/>
|
||||
<Option type="QString" value="0" name="trim_distance_end"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="trim_distance_end_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="trim_distance_end_unit"/>
|
||||
<Option type="QString" value="0" name="trim_distance_start"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="trim_distance_start_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="trim_distance_start_unit"/>
|
||||
<Option type="QString" value="0" name="tweak_dash_pattern_on_corners"/>
|
||||
<Option type="QString" value="0" name="use_custom_dash"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="width_map_unit_scale"/>
|
||||
</Option>
|
||||
<data_defined_properties>
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="" name="name"/>
|
||||
<Option name="properties"/>
|
||||
<Option type="QString" value="collection" name="type"/>
|
||||
</Option>
|
||||
</data_defined_properties>
|
||||
</layer>
|
||||
<layer locked="0" id="{fdc4d6fd-0995-41df-bbfb-19970b4fc2cc}" enabled="1" class="SimpleLine" pass="0">
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="0" name="align_dash_pattern"/>
|
||||
<Option type="QString" value="square" name="capstyle"/>
|
||||
<Option type="QString" value="5;2" name="customdash"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="customdash_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="customdash_unit"/>
|
||||
<Option type="QString" value="0" name="dash_pattern_offset"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="dash_pattern_offset_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="dash_pattern_offset_unit"/>
|
||||
<Option type="QString" value="0" name="draw_inside_polygon"/>
|
||||
<Option type="QString" value="round" name="joinstyle"/>
|
||||
<Option type="QString" value="204,174,137,255,rgb:0.80000000000000004,0.68235294117647061,0.53725490196078429,1" name="line_color"/>
|
||||
<Option type="QString" value="solid" name="line_style"/>
|
||||
<Option type="QString" value="0.5" name="line_width"/>
|
||||
<Option type="QString" value="MM" name="line_width_unit"/>
|
||||
<Option type="QString" value="0" name="offset"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="offset_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="offset_unit"/>
|
||||
<Option type="QString" value="0" name="ring_filter"/>
|
||||
<Option type="QString" value="0" name="trim_distance_end"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="trim_distance_end_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="trim_distance_end_unit"/>
|
||||
<Option type="QString" value="0" name="trim_distance_start"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="trim_distance_start_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="trim_distance_start_unit"/>
|
||||
<Option type="QString" value="0" name="tweak_dash_pattern_on_corners"/>
|
||||
<Option type="QString" value="0" name="use_custom_dash"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="width_map_unit_scale"/>
|
||||
</Option>
|
||||
<data_defined_properties>
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="" name="name"/>
|
||||
<Option name="properties"/>
|
||||
<Option type="QString" value="collection" name="type"/>
|
||||
</Option>
|
||||
</data_defined_properties>
|
||||
</layer>
|
||||
</symbol>
|
||||
</symbols>
|
||||
<rotation/>
|
||||
<sizescale/>
|
||||
<data-defined-properties>
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="" name="name"/>
|
||||
<Option name="properties"/>
|
||||
<Option type="QString" value="collection" name="type"/>
|
||||
</Option>
|
||||
</data-defined-properties>
|
||||
</renderer-v2>
|
||||
<selection mode="Default">
|
||||
<selectionColor invalid="1"/>
|
||||
<selectionSymbol>
|
||||
<symbol is_animated="0" frame_rate="10" clip_to_extent="1" type="fill" alpha="1" force_rhr="0" name="">
|
||||
<data_defined_properties>
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="" name="name"/>
|
||||
<Option name="properties"/>
|
||||
<Option type="QString" value="collection" name="type"/>
|
||||
</Option>
|
||||
</data_defined_properties>
|
||||
<layer locked="0" id="{f18003f5-220a-487f-8a6d-b24facc4c1a5}" enabled="1" class="SimpleFill" pass="0">
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="border_width_map_unit_scale"/>
|
||||
<Option type="QString" value="0,0,255,255,rgb:0,0,1,1" name="color"/>
|
||||
<Option type="QString" value="bevel" name="joinstyle"/>
|
||||
<Option type="QString" value="0,0" name="offset"/>
|
||||
<Option type="QString" value="3x:0,0,0,0,0,0" name="offset_map_unit_scale"/>
|
||||
<Option type="QString" value="MM" name="offset_unit"/>
|
||||
<Option type="QString" value="35,35,35,255,rgb:0.13725490196078433,0.13725490196078433,0.13725490196078433,1" name="outline_color"/>
|
||||
<Option type="QString" value="solid" name="outline_style"/>
|
||||
<Option type="QString" value="0.26" name="outline_width"/>
|
||||
<Option type="QString" value="MM" name="outline_width_unit"/>
|
||||
<Option type="QString" value="solid" name="style"/>
|
||||
</Option>
|
||||
<data_defined_properties>
|
||||
<Option type="Map">
|
||||
<Option type="QString" value="" name="name"/>
|
||||
<Option name="properties"/>
|
||||
<Option type="QString" value="collection" name="type"/>
|
||||
</Option>
|
||||
</data_defined_properties>
|
||||
</layer>
|
||||
</symbol>
|
||||
</selectionSymbol>
|
||||
</selection>
|
||||
<blendMode>0</blendMode>
|
||||
<featureBlendMode>0</featureBlendMode>
|
||||
<layerGeometryType>2</layerGeometryType>
|
||||
</qgis>
|
||||
98
ui/tabs/tab_a.py
Normal file
98
ui/tabs/tab_a.py
Normal file
@@ -0,0 +1,98 @@
|
||||
from qgis.PyQt.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QMessageBox
|
||||
from qgis.PyQt.QtGui import QIcon, QPixmap
|
||||
from qgis.PyQt.QtCore import Qt, QTimer
|
||||
from qgis.core import Qgis, QgsProject, QgsMessageLog
|
||||
from qgis.utils import iface
|
||||
import os
|
||||
|
||||
from sn_verfahrensgebiet.logic.alkis_verfahrensgebiet import alkis_verfahrensgebiet
|
||||
from sn_basis.logic.utils import zoom_to_layer
|
||||
|
||||
class TabA(QWidget):
|
||||
tab_title = "Bearbeitung"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.setAlignment(Qt.AlignmentFlag.AlignTop)
|
||||
|
||||
# Abschnitt 1: Verfahrensgebiet
|
||||
row_verf_header = QHBoxLayout()
|
||||
lbl_verf = QLabel("<b>Verfahrensgebiet</b>")
|
||||
self.haken1 = self._haken_label()
|
||||
row_verf_header.addWidget(lbl_verf)
|
||||
row_verf_header.addWidget(self.haken1)
|
||||
row_verf_header.addStretch()
|
||||
layout.addLayout(row_verf_header)
|
||||
|
||||
row_verf_buttons = QHBoxLayout()
|
||||
self.btn_verf_alkis = QPushButton("Aus ALKIS laden")
|
||||
self.btn_verf_shape = QPushButton("Aus Shape laden")
|
||||
row_verf_buttons.addWidget(self.btn_verf_alkis)
|
||||
row_verf_buttons.addWidget(self.btn_verf_shape)
|
||||
layout.addLayout(row_verf_buttons)
|
||||
|
||||
# Abschnitt 2: Flurstücke
|
||||
row_flurst_header = QHBoxLayout()
|
||||
lbl_flurst = QLabel("<b>Flurstücke</b>")
|
||||
self.haken2 = self._haken_label()
|
||||
row_flurst_header.addWidget(lbl_flurst)
|
||||
row_flurst_header.addWidget(self.haken2)
|
||||
row_flurst_header.addStretch()
|
||||
layout.addLayout(row_flurst_header)
|
||||
|
||||
row_flurst_buttons = QHBoxLayout()
|
||||
self.btn_flurst_alkis = QPushButton("Aus ALKIS laden")
|
||||
self.btn_flurst_shape = QPushButton("Aus Shape laden")
|
||||
row_flurst_buttons.addWidget(self.btn_flurst_alkis)
|
||||
row_flurst_buttons.addWidget(self.btn_flurst_shape)
|
||||
layout.addLayout(row_flurst_buttons)
|
||||
|
||||
layout.addStretch()
|
||||
self.setLayout(layout)
|
||||
|
||||
# Beispiel: Haken anzeigen nach Klick
|
||||
# self.button1.clicked.connect(lambda: alkis_verfahrensgebiet(self))
|
||||
self.btn_verf_alkis.clicked.connect(lambda: self.handle_button1())
|
||||
|
||||
#self.button2.clicked.connect(lambda: self.setze_haken(self.haken2, True))
|
||||
|
||||
def handle_button1(self):
|
||||
layer, neu_geladen = alkis_verfahrensgebiet(self)
|
||||
|
||||
if not layer or not layer.isValid():
|
||||
return
|
||||
|
||||
if neu_geladen:
|
||||
QgsProject.instance().addMapLayer(layer)
|
||||
iface.mapCanvas().setExtent(layer.extent())
|
||||
iface.mapCanvas().refresh()
|
||||
# Beispiel: Haken setzen oder Meldung ausgeben
|
||||
self.setze_haken(self.haken1, True)
|
||||
# QMessageBox.information(self, "Info", "Layer 'Verfahrensgebiet' wurde neu geladen.")
|
||||
else:
|
||||
# Kein Zoom, kein Neu-Laden
|
||||
QgsMessageLog.logMessage("Vorhandener Layer behalten.", "sn_verfahrensgebiet", level=Qgis.Info)
|
||||
|
||||
|
||||
def _haken_label(self):
|
||||
label = QLabel()
|
||||
label.setFixedSize(20, 20)
|
||||
# label.setAlignment(Qt.AlignCenter)
|
||||
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
label.setScaledContents(False)
|
||||
label.setText("")
|
||||
return label
|
||||
|
||||
def setze_haken(self, label: QLabel, aktiv: bool):
|
||||
"""Zeigt oder entfernt den grünen Haken."""
|
||||
if aktiv:
|
||||
# grünes Unicode-Häkchen
|
||||
label.setPixmap(QPixmap())
|
||||
label.setText("✓")
|
||||
label.setStyleSheet("color: #2ea043; font-weight: bold;")
|
||||
else:
|
||||
label.setPixmap(QPixmap())
|
||||
label.setText("")
|
||||
label.setStyleSheet("")
|
||||
11
ui/tabs/tab_b.py
Normal file
11
ui/tabs/tab_b.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from qgis.PyQt.QtWidgets import QWidget, QVBoxLayout, QLabel, QTextEdit
|
||||
|
||||
class TabB(QWidget):
|
||||
tab_title = "Tab B"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(QLabel("Plugin1 – Tab B"))
|
||||
layout.addWidget(QTextEdit("Mehrzeiliger Text für Plugin1"))
|
||||
self.setLayout(layout)
|
||||
Reference in New Issue
Block a user