nach PegelonlineDockWidgetGraph.load ausgelagert
This commit is contained in:
parent
1c9c863d1d
commit
29c2608d05
@ -24,9 +24,11 @@
|
||||
|
||||
import os
|
||||
|
||||
from qgis.PyQt import QtWidgets, uic
|
||||
from qgis.PyQt import QtWidgets, uic, QtGui
|
||||
from qgis.PyQt.QtCore import pyqtSignal
|
||||
|
||||
from .po_modules.po_graph_reader import PoGraphReader
|
||||
|
||||
FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'pegelonline_dockwidget_graph.ui'))
|
||||
|
||||
|
||||
@ -34,15 +36,52 @@ class PegelonlineDockWidgetGraph(QtWidgets.QDockWidget, FORM_CLASS):
|
||||
closingPlugin = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
"""Constructor."""
|
||||
super(PegelonlineDockWidgetGraph, self).__init__(parent)
|
||||
# Set up the user interface from Designer.
|
||||
# After setupUI you can access any designer object by doing
|
||||
# self.<objectname>, and you can use autoconnect slots - see
|
||||
# http://doc.qt.io/qt-5/designer-using-a-ui-file.html
|
||||
# #widgets-and-dialogs-with-auto-connect
|
||||
self.setupUi(self)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.closingPlugin.emit()
|
||||
event.accept()
|
||||
|
||||
"""
|
||||
Versucht den aktuell gewünschten Pegelstandsverlauf herunterzuladen und im GraphWidget anzuzeigen.
|
||||
:param station: Der 'Kurzname' der gewünschten Station
|
||||
:type station: str
|
||||
:param days: Anzahl der gewünschten vergangenen Tage
|
||||
:type days: int
|
||||
"""
|
||||
|
||||
def load(self, station, days):
|
||||
print("PegelonlineDockWidgetGraph::load: station=%s days=%s" % (station, days))
|
||||
|
||||
self.lbGraph.clear()
|
||||
self.setWindowTitle("%s / %d Tag(e)" % (station, days))
|
||||
self.show()
|
||||
|
||||
if station == '' or station is None:
|
||||
# Keine Station ausgewählt → Abbruch
|
||||
print("PegelonlineDockWidgetGraph::load: Fehler: Ungültige Station: %s" % (station,))
|
||||
self.lbGraph.setText("Bitte Station wählen...")
|
||||
return
|
||||
|
||||
if days is None or days < 1 or days > 30:
|
||||
# Ungültige Anzahl an Tagen ausgewählt → Abbruch
|
||||
print("PegelonlineDockWidgetGraph::load: Fehler: Ungültige Anzahl von Tagen: %s" % (days,))
|
||||
self.lbGraph.setText("Bitte Tage [1, 30] wählen...")
|
||||
return
|
||||
|
||||
graph = PoGraphReader(station, days)
|
||||
image_data = graph.download()
|
||||
|
||||
if image_data is None or len(image_data) == 0:
|
||||
# Keine Bild-Daten beim Herunterladen erhalten → Abbruch
|
||||
print("PegelonlineDockWidgetGraph::load: Fehler: Keine Daten erhalten")
|
||||
self.lbGraph.setText("Fehler beim Download!")
|
||||
return
|
||||
|
||||
pixmap = QtGui.QPixmap()
|
||||
pixmap.loadFromData(image_data)
|
||||
self.lbGraph.setPixmap(pixmap)
|
||||
self.lbGraph.resize(pixmap.width(), pixmap.height())
|
||||
|
||||
print("PegelonlineDockWidgetGraph::load: Bild erfolgreich geladen")
|
||||
40
po_runner.py
40
po_runner.py
@ -1,14 +1,12 @@
|
||||
import os.path
|
||||
from typing import Callable
|
||||
|
||||
from PyQt5 import QtGui
|
||||
from PyQt5.QtWidgets import QAction, QCheckBox
|
||||
from qgis._core import QgsVectorLayer, QgsProject, QgsLayerTreeLayer, QgsPalLayerSettings, QgsVectorLayerSimpleLabeling, QgsStyle, QgsSymbol, QgsRendererCategory, QgsCategorizedSymbolRenderer
|
||||
|
||||
from .map_tips import WATERLEVELS_MAP_TIPS, STATIONS_MAP_TIPS, BASEMAP_MAP_TIPS
|
||||
from .pegelonline_dockwidget import PegelonlineDockWidget
|
||||
from .pegelonline_dockwidget_graph import PegelonlineDockWidgetGraph
|
||||
from .po_modules.po_graph_reader import PoGraphReader
|
||||
from .po_modules.po_station_reader import PoStationReader
|
||||
from .po_modules.po_stations_reader_qgs import PoStationReaderQgs
|
||||
from .po_modules.po_waterlevels_reader_qgs import PoWaterlevelReaderQgs
|
||||
@ -859,39 +857,7 @@ class PoRunner(object):
|
||||
station = self.ui.slGraphStation.currentText()
|
||||
days = self.ui.numGraphDays.value()
|
||||
|
||||
print("_graph_load_graph: station=%s days=%s" % (station, days))
|
||||
|
||||
self.graph.lbGraph.clear()
|
||||
self.graph.setWindowTitle("%s / %d Tag(e)" % (station, days))
|
||||
self.graph.show()
|
||||
|
||||
if station == '' or station is None:
|
||||
# Keine Station ausgewählt → Abbruch
|
||||
print("_graph_load_graph: Fehler: Ungültige Station: %s" % (station,))
|
||||
self.graph.lbGraph.setText("Bitte Station wählen...")
|
||||
return
|
||||
|
||||
if days is None or days < 1 or days > 30:
|
||||
# Ungültige Anzahl an Tagen ausgewählt → Abbruch
|
||||
print("_graph_load_graph: Fehler: Ungültige Anzahl von Tagen: %s" % (days,))
|
||||
self.graph.lbGraph.setText("Bitte Tage [1, 30] wählen...")
|
||||
return
|
||||
|
||||
graph = PoGraphReader(station, days)
|
||||
image_data = graph.download()
|
||||
|
||||
if image_data is None or len(image_data) == 0:
|
||||
# Keine Bild-Daten beim Herunterladen erhalten → Abbruch
|
||||
print("_graph_load_graph: Fehler: Keine Daten erhalten")
|
||||
self.graph.lbGraph.setText("Fehler beim Download!")
|
||||
return
|
||||
|
||||
pixmap = QtGui.QPixmap()
|
||||
pixmap.loadFromData(image_data)
|
||||
self.graph.lbGraph.setPixmap(pixmap)
|
||||
self.graph.lbGraph.resize(pixmap.width(), pixmap.height())
|
||||
|
||||
print("_graph_load_graph: Bild erfolgreich geladen")
|
||||
self.graph.load(station, days)
|
||||
|
||||
"""
|
||||
Lädt die Stations-Liste für den Graphen neu.
|
||||
@ -943,7 +909,9 @@ class PoRunner(object):
|
||||
def _graphStation_set_by_shortname(self, shortname):
|
||||
index = self._graphStation_get_index_by_shortname(shortname)
|
||||
if index is None:
|
||||
# Station nicht gefunden → Abbruch
|
||||
return False
|
||||
|
||||
self.ui.slGraphStation.setCurrentIndex(index)
|
||||
return True
|
||||
|
||||
@ -958,7 +926,9 @@ class PoRunner(object):
|
||||
for index in range(self.ui.slGraphStation.count()):
|
||||
text = self.ui.slGraphStation.itemText(index)
|
||||
if shortname == text:
|
||||
# Station nicht gefunden → Abbruch
|
||||
print("_graphStation_get_index_by_shortname: index=%d" % (index,))
|
||||
return index
|
||||
|
||||
print("_graphStation_get_index_by_shortname: Nicht gefunden")
|
||||
return None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user