renamed History -> Graph
This commit is contained in:
parent
b4e1b88521
commit
c6eaf56cc5
@ -351,7 +351,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QGroupBox" name="gbHistory">
|
||||
<widget class="QGroupBox" name="gbGraph">
|
||||
<property name="title">
|
||||
<string>Pegelverlauf:</string>
|
||||
</property>
|
||||
@ -393,7 +393,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="slHistoryStation">
|
||||
<widget class="QComboBox" name="slGraphStation">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -406,7 +406,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnHistoryStationsRefresh">
|
||||
<widget class="QPushButton" name="btnGraphStationsRefresh">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -448,7 +448,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="numHistoryDays">
|
||||
<widget class="QSpinBox" name="numGraphDays">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -473,7 +473,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnHistoryGo">
|
||||
<widget class="QPushButton" name="btnGraphLoad">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbHistory">
|
||||
<widget class="QLabel" name="lbGraph">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
|
||||
128
po_runner.py
128
po_runner.py
@ -43,7 +43,7 @@ class PoRunner(object):
|
||||
self.local_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
# während dem Aktualisieren der Stationsliste treten change-signale auf, die werden so abgefangen
|
||||
self._history_stations_lock = True
|
||||
self._graph_stations_lock = True
|
||||
|
||||
# Layer
|
||||
self.stations = None
|
||||
@ -64,7 +64,7 @@ class PoRunner(object):
|
||||
self._basemap_connect_signals()
|
||||
self._stations_connect_signals()
|
||||
self._waterlevels_connect_signals()
|
||||
self._history_connect_signals()
|
||||
self._graph_connect_signals()
|
||||
|
||||
# basemap -----------------------------------------------------------------
|
||||
|
||||
@ -680,13 +680,13 @@ class PoRunner(object):
|
||||
if len(selected) == 1:
|
||||
# Juhu, nur ein Pegelstand ausgewählt → Graph laden
|
||||
|
||||
if self.ui.slHistoryStation.count() == 0:
|
||||
if self.ui.slGraphStation.count() == 0:
|
||||
# Wir haben aber noch keine Stationen geladen → machen wir zuerst
|
||||
self._history_load_stations()
|
||||
self._graph_load_stations()
|
||||
|
||||
selected_shortname = selected[0].attribute("shortname")
|
||||
print("_layer_selection_changed: Lade Pegelstandsverlauf zur Auswahl: %s" % (selected_shortname,))
|
||||
self._historyStation_set_by_shortname(selected_shortname)
|
||||
self._graphStation_set_by_shortname(selected_shortname)
|
||||
else:
|
||||
# Leider 0 oder mehrere Pegelstände ausgewählt → Abbruch
|
||||
print("_layer_selection_changed: Anzahl ausgewählter Elemente ist NICHT 1, lade Pegelstandsverlauf NICHT!")
|
||||
@ -753,91 +753,91 @@ class PoRunner(object):
|
||||
|
||||
self._layer_refresh(layer)
|
||||
|
||||
# history signals ---------------------------------------------------------
|
||||
# graph signals ---------------------------------------------------------
|
||||
|
||||
"""
|
||||
Verbindet alle GraphWidget-Signale mit der UI
|
||||
"""
|
||||
|
||||
def _history_connect_signals(self):
|
||||
print("_history_connect_signals")
|
||||
self.ui.slHistoryStation.currentTextChanged.connect(self._slHistoryStation_changed)
|
||||
self.ui.btnHistoryStationsRefresh.clicked.connect(self._btnHistoryStationsRefresh_clicked)
|
||||
self.ui.numHistoryDays.valueChanged.connect(self._numHistoryDays_changed)
|
||||
self.ui.btnHistoryGo.clicked.connect(self._history_load_graph)
|
||||
def _graph_connect_signals(self):
|
||||
print("_graph_connect_signals")
|
||||
self.ui.slGraphStation.currentTextChanged.connect(self._slGraphStation_changed)
|
||||
self.ui.btnGraphStationsRefresh.clicked.connect(self._btnGraphStationsRefresh_clicked)
|
||||
self.ui.numGraphDays.valueChanged.connect(self._numGraphDays_changed)
|
||||
self.ui.btnGraphLoad.clicked.connect(self._graph_load_graph)
|
||||
|
||||
"""
|
||||
Behandelt die Stations-Änderung und Lädt den Pegelstandsverlauf-Graph neu
|
||||
"""
|
||||
|
||||
def _slHistoryStation_changed(self):
|
||||
print("_slHistoryStation_changed: %s" % (self.ui.slHistoryStation.currentText(),))
|
||||
self._history_load_graph()
|
||||
def _slGraphStation_changed(self):
|
||||
print("_slGraphStation_changed: %s" % (self.ui.slGraphStation.currentText(),))
|
||||
self._graph_load_graph()
|
||||
|
||||
"""
|
||||
Klick auf Graph-Stations-Liste-Refresh:
|
||||
Lässt die Stations-Liste für den Graphen neu laden
|
||||
"""
|
||||
|
||||
def _btnHistoryStationsRefresh_clicked(self):
|
||||
print("_btnHistoryStationsRefresh_clicked")
|
||||
self._history_load_stations()
|
||||
def _btnGraphStationsRefresh_clicked(self):
|
||||
print("_btnGraphStationsRefresh_clicked")
|
||||
self._graph_load_stations()
|
||||
|
||||
"""
|
||||
Loggt lediglich die Graph-Tages-Änderung
|
||||
"""
|
||||
|
||||
def _numHistoryDays_changed(self):
|
||||
print("_numHistoryDays_changed: %s" % (self.ui.numHistoryDays.value(),))
|
||||
def _numGraphDays_changed(self):
|
||||
print("_numGraphDays_changed: %s" % (self.ui.numGraphDays.value(),))
|
||||
|
||||
"""
|
||||
Versucht den aktuell gewünschten Pegelstandsverlauf herunterzuladen und im GraphWidget anzuzeigen.
|
||||
"""
|
||||
|
||||
def _history_load_graph(self):
|
||||
print("_history_load_graph")
|
||||
def _graph_load_graph(self):
|
||||
print("_graph_load_graph")
|
||||
|
||||
if not self.ui.slHistoryStation.isEnabled():
|
||||
if not self.ui.slGraphStation.isEnabled():
|
||||
# während dem Aktualisieren der Stationsliste treten change-signale auf, die werden hier abgefangen
|
||||
print("_history_load_graph: Stationsliste ist aktuell gesperrt")
|
||||
print("_graph_load_graph: Stationsliste ist aktuell gesperrt")
|
||||
return
|
||||
|
||||
station = self.ui.slHistoryStation.currentText()
|
||||
days = self.ui.numHistoryDays.value()
|
||||
station = self.ui.slGraphStation.currentText()
|
||||
days = self.ui.numGraphDays.value()
|
||||
|
||||
print("_history_load_graph: station=%s days=%s" % (station, days))
|
||||
print("_graph_load_graph: station=%s days=%s" % (station, days))
|
||||
|
||||
self.graph.lbHistory.clear()
|
||||
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("_history_load_graph: Fehler: Ungültige Station: %s" % (station,))
|
||||
self.graph.lbHistory.setText("Bitte Station wählen...")
|
||||
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("_history_load_graph: Fehler: Ungültige Anzahl von Tagen: %s" % (days,))
|
||||
self.graph.lbHistory.setText("Bitte Tage [1, 30] wählen...")
|
||||
print("_graph_load_graph: Fehler: Ungültige Anzahl von Tagen: %s" % (days,))
|
||||
self.graph.lbGraph.setText("Bitte Tage [1, 30] wählen...")
|
||||
return
|
||||
|
||||
history = PoGraphReader(station, days)
|
||||
image_data = history.download()
|
||||
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("_history_load_graph: Fehler: Keine Daten erhalten")
|
||||
self.graph.lbHistory.setText("Fehler beim Download!")
|
||||
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.lbHistory.setPixmap(pixmap)
|
||||
self.graph.lbHistory.resize(pixmap.width(), pixmap.height())
|
||||
self.graph.lbGraph.setPixmap(pixmap)
|
||||
self.graph.lbGraph.resize(pixmap.width(), pixmap.height())
|
||||
|
||||
print("_history_load_graph: Bild erfolgreich geladen")
|
||||
print("_graph_load_graph: Bild erfolgreich geladen")
|
||||
|
||||
"""
|
||||
Lädt die Stations-Liste für den Graphen neu.
|
||||
@ -845,40 +845,40 @@ class PoRunner(object):
|
||||
Versucht die bisher ausgewählten Station in der neuen Liste wiederzufinden.
|
||||
"""
|
||||
|
||||
def _history_load_stations(self):
|
||||
print("_history_load_stations")
|
||||
self.ui.slHistoryStation.setEnabled(False)
|
||||
self.ui.btnHistoryGo.setEnabled(False)
|
||||
def _graph_load_stations(self):
|
||||
print("_graph_load_stations")
|
||||
self.ui.slGraphStation.setEnabled(False)
|
||||
self.ui.btnGraphLoad.setEnabled(False)
|
||||
|
||||
# behalte die aktuelle Station, um sie (mit eventuell neuem Index) wiederherzustellen
|
||||
current_station = self.ui.slHistoryStation.currentText()
|
||||
print("_history_load_stations: bisherige_station=%s" % (current_station,))
|
||||
current_station = self.ui.slGraphStation.currentText()
|
||||
print("_graph_load_stations: bisherige_station=%s" % (current_station,))
|
||||
|
||||
# leere die bisherige Auswahlliste
|
||||
self.ui.slHistoryStation.clear()
|
||||
self.ui.slGraphStation.clear()
|
||||
|
||||
# Lade aktuelle StationsListe herunter
|
||||
stations = PoStationReader().get_stations()
|
||||
if stations is None or len(stations) == 0:
|
||||
# Keine Stationen erhalte → Abbruch
|
||||
print("_history_load_stations: Fehler: Keine Stationen erhalten")
|
||||
print("_graph_load_stations: Fehler: Keine Stationen erhalten")
|
||||
return
|
||||
|
||||
for station in stations:
|
||||
# Füge ein Item je Station hinzu
|
||||
self.ui.slHistoryStation.addItem(station.shortname)
|
||||
self.ui.slGraphStation.addItem(station.shortname)
|
||||
|
||||
if self._historyStation_set_by_shortname(current_station):
|
||||
if self._graphStation_set_by_shortname(current_station):
|
||||
# Bisherige Station wiedergefunden → Wieder ausgewählt
|
||||
print("_history_load_stations: Bisherige Station \"%s\" wiederhergestellt" % (current_station,))
|
||||
print("_graph_load_stations: Bisherige Station \"%s\" wiederhergestellt" % (current_station,))
|
||||
else:
|
||||
# Bisherige Station nicht wiedergefunden → Wähle die erste Station aus der Liste
|
||||
self.ui.slHistoryStation.setCurrentIndex(0)
|
||||
station = self.ui.slHistoryStation.currentText()
|
||||
print("_history_load_stations: Bisherige Station \"%s\" nicht wiedergefunden. Nehme erste Station: %s" % (current_station, station))
|
||||
self.ui.slGraphStation.setCurrentIndex(0)
|
||||
station = self.ui.slGraphStation.currentText()
|
||||
print("_graph_load_stations: Bisherige Station \"%s\" nicht wiedergefunden. Nehme erste Station: %s" % (current_station, station))
|
||||
|
||||
self.ui.slHistoryStation.setEnabled(True)
|
||||
self.ui.btnHistoryGo.setEnabled(True)
|
||||
self.ui.slGraphStation.setEnabled(True)
|
||||
self.ui.btnGraphLoad.setEnabled(True)
|
||||
|
||||
"""
|
||||
Setzt eine Graph-Station anhand des gegebenen Kurznamens
|
||||
@ -886,11 +886,11 @@ class PoRunner(object):
|
||||
:type shortname: str
|
||||
"""
|
||||
|
||||
def _historyStation_set_by_shortname(self, shortname):
|
||||
index = self._historyStation_get_index_by_shortname(shortname)
|
||||
def _graphStation_set_by_shortname(self, shortname):
|
||||
index = self._graphStation_get_index_by_shortname(shortname)
|
||||
if index is None:
|
||||
return False
|
||||
self.ui.slHistoryStation.setCurrentIndex(index)
|
||||
self.ui.slGraphStation.setCurrentIndex(index)
|
||||
return True
|
||||
|
||||
"""
|
||||
@ -899,12 +899,12 @@ class PoRunner(object):
|
||||
:type shortname: str
|
||||
"""
|
||||
|
||||
def _historyStation_get_index_by_shortname(self, shortname):
|
||||
print("_historyStation_get_index_by_shortname: shortname=%s" % (shortname,))
|
||||
for index in range(self.ui.slHistoryStation.count()):
|
||||
text = self.ui.slHistoryStation.itemText(index)
|
||||
def _graphStation_get_index_by_shortname(self, shortname):
|
||||
print("_graphStation_get_index_by_shortname: shortname=%s" % (shortname,))
|
||||
for index in range(self.ui.slGraphStation.count()):
|
||||
text = self.ui.slGraphStation.itemText(index)
|
||||
if shortname == text:
|
||||
print("_historyStation_get_index_by_shortname: index=%d" % (index,))
|
||||
print("_graphStation_get_index_by_shortname: index=%d" % (index,))
|
||||
return index
|
||||
print("_historyStation_get_index_by_shortname: Nicht gefunden")
|
||||
print("_graphStation_get_index_by_shortname: Nicht gefunden")
|
||||
return None
|
||||
|
||||
Loading…
Reference in New Issue
Block a user