mirror of https://gitlab.com/pamhyr/pamhyr2
View main window: keep zoom on the geographical graph after a change in the geometry
parent
fc40552d68
commit
bcc9dd1a0d
|
|
@ -27,6 +27,7 @@ class WidgetGraph(QWidget):
|
||||||
|
|
||||||
self._study = study
|
self._study = study
|
||||||
self._trad = trad
|
self._trad = trad
|
||||||
|
self._plot_river = None
|
||||||
|
|
||||||
layout = QHBoxLayout(self)
|
layout = QHBoxLayout(self)
|
||||||
self._splitter = QSplitter(Qt.Horizontal, self)
|
self._splitter = QSplitter(Qt.Horizontal, self)
|
||||||
|
|
@ -87,6 +88,14 @@ class WidgetGraph(QWidget):
|
||||||
)
|
)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
river = self._study.river if self._study is not None else None
|
||||||
|
view = None
|
||||||
|
if river is not None and river is self._plot_river:
|
||||||
|
axes = self.canvas.axes
|
||||||
|
if axes.has_data():
|
||||||
|
view = (axes.get_xlim(), axes.get_ylim(),
|
||||||
|
axes.get_aspect(), axes.get_adjustable())
|
||||||
|
|
||||||
self._update_graph_title()
|
self._update_graph_title()
|
||||||
if (self._graph_widget is not None
|
if (self._graph_widget is not None
|
||||||
and (self._study is None
|
and (self._study is None
|
||||||
|
|
@ -121,3 +130,10 @@ class WidgetGraph(QWidget):
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
self.plot.update()
|
self.plot.update()
|
||||||
|
self._plot_river = river
|
||||||
|
if view is not None:
|
||||||
|
x_limits, y_limits, aspect, adjustable = view
|
||||||
|
self.canvas.axes.set_aspect(aspect, adjustable=adjustable)
|
||||||
|
self.canvas.axes.set_xlim(x_limits)
|
||||||
|
self.canvas.axes.set_ylim(y_limits)
|
||||||
|
self.canvas.draw_idle()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue