Initial condition: Fix discharge generator undo.

mesh
Pierre-Antoine Rouby 2023-06-23 15:17:48 +02:00
parent 93a4b885e4
commit 826dfaf72e
3 changed files with 28 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from copy import copy
from copy import copy, deepcopy
from tools import trace, timer
from functools import reduce
@ -21,6 +21,19 @@ class Data(object):
self._elevation = 0.0
self._height = 0.0
def copy(self):
new = Data(self._reach, self._status)
new._name = self._name
new._comment = self._comment
new._kp = self._kp
new._discharge = self._discharge
new._speed = self._speed
new._elevation = self._elevation
new._height = self._height
return new
@property
def name(self):
return self._name
@ -228,5 +241,11 @@ class InitialConditions(object):
)
def generate_discharge(self, discharge:float):
self._new = []
for d in self._data:
d['discharge'] = discharge
n = d.copy()
n['discharge'] = discharge
self._new.append(n)
self._data = self._new

View File

@ -9,9 +9,9 @@ from PyQt5.QtCore import (
_translate = QCoreApplication.translate
class PlotFlow(APlot):
class PlotDischarge(APlot):
def __init__(self, canvas=None, data=None, toolbar=None):
super(PlotFlow, self).__init__(
super(PlotDischarge, self).__init__(
canvas=canvas,
data=data,
toolbar=toolbar
@ -26,7 +26,7 @@ class PlotFlow(APlot):
return
self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Flow (m^3/s)"),
_translate("MainWindow_reach", "Discharge (m^3/s)"),
color='green', fontsize=11
)
self.canvas.axes.set_xlabel(
@ -42,10 +42,10 @@ class PlotFlow(APlot):
if len(self.data) != 0:
kp = self.data.get_kp()
flow = self.data.get_flow()
discharge = self.data.get_discharge()
self.line_kp_zmin = self.canvas.axes.plot(
kp, flow,
kp, discharge,
color='r', lw=1.
)

View File

@ -32,7 +32,7 @@ from View.InitialConditions.Table import TableModel, ComboBoxDelegate
from View.Plot.MplCanvas import MplCanvas
from View.InitialConditions.PlotDKP import PlotDKP
from View.InitialConditions.PlotFlow import PlotFlow
from View.InitialConditions.PlotDischarge import PlotDischarge
from View.InitialConditions.translate import *
from View.InitialConditions.DialogHeight import HeightDialog
from View.InitialConditions.DialogDischarge import DischargeDialog
@ -116,7 +116,7 @@ class InitialConditionsWindow(ASubMainWindow, ListedSubWindow):
self.plot_layout_2 = self.find(QVBoxLayout, "verticalLayout_2")
self.plot_layout_2.addWidget(self.canvas_2)
self.plot_2 = PlotFlow(
self.plot_2 = PlotDischarge(
canvas = self.canvas_2,
data = self._ics,
toolbar = None,