mirror of https://gitlab.com/pamhyr/pamhyr2
Initial condition: Fix discharge generator undo.
parent
93a4b885e4
commit
826dfaf72e
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from copy import copy
|
from copy import copy, deepcopy
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
|
|
@ -21,6 +21,19 @@ class Data(object):
|
||||||
self._elevation = 0.0
|
self._elevation = 0.0
|
||||||
self._height = 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
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
@ -228,5 +241,11 @@ class InitialConditions(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
def generate_discharge(self, discharge:float):
|
def generate_discharge(self, discharge:float):
|
||||||
|
self._new = []
|
||||||
|
|
||||||
for d in self._data:
|
for d in self._data:
|
||||||
d['discharge'] = discharge
|
n = d.copy()
|
||||||
|
n['discharge'] = discharge
|
||||||
|
self._new.append(n)
|
||||||
|
|
||||||
|
self._data = self._new
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ from PyQt5.QtCore import (
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
class PlotFlow(APlot):
|
class PlotDischarge(APlot):
|
||||||
def __init__(self, canvas=None, data=None, toolbar=None):
|
def __init__(self, canvas=None, data=None, toolbar=None):
|
||||||
super(PlotFlow, self).__init__(
|
super(PlotDischarge, self).__init__(
|
||||||
canvas=canvas,
|
canvas=canvas,
|
||||||
data=data,
|
data=data,
|
||||||
toolbar=toolbar
|
toolbar=toolbar
|
||||||
|
|
@ -26,7 +26,7 @@ class PlotFlow(APlot):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.canvas.axes.set_ylabel(
|
self.canvas.axes.set_ylabel(
|
||||||
_translate("MainWindow_reach", "Flow (m^3/s)"),
|
_translate("MainWindow_reach", "Discharge (m^3/s)"),
|
||||||
color='green', fontsize=11
|
color='green', fontsize=11
|
||||||
)
|
)
|
||||||
self.canvas.axes.set_xlabel(
|
self.canvas.axes.set_xlabel(
|
||||||
|
|
@ -42,10 +42,10 @@ class PlotFlow(APlot):
|
||||||
|
|
||||||
if len(self.data) != 0:
|
if len(self.data) != 0:
|
||||||
kp = self.data.get_kp()
|
kp = self.data.get_kp()
|
||||||
flow = self.data.get_flow()
|
discharge = self.data.get_discharge()
|
||||||
|
|
||||||
self.line_kp_zmin = self.canvas.axes.plot(
|
self.line_kp_zmin = self.canvas.axes.plot(
|
||||||
kp, flow,
|
kp, discharge,
|
||||||
color='r', lw=1.
|
color='r', lw=1.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ from View.InitialConditions.Table import TableModel, ComboBoxDelegate
|
||||||
|
|
||||||
from View.Plot.MplCanvas import MplCanvas
|
from View.Plot.MplCanvas import MplCanvas
|
||||||
from View.InitialConditions.PlotDKP import PlotDKP
|
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.translate import *
|
||||||
from View.InitialConditions.DialogHeight import HeightDialog
|
from View.InitialConditions.DialogHeight import HeightDialog
|
||||||
from View.InitialConditions.DialogDischarge import DischargeDialog
|
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 = self.find(QVBoxLayout, "verticalLayout_2")
|
||||||
self.plot_layout_2.addWidget(self.canvas_2)
|
self.plot_layout_2.addWidget(self.canvas_2)
|
||||||
|
|
||||||
self.plot_2 = PlotFlow(
|
self.plot_2 = PlotDischarge(
|
||||||
canvas = self.canvas_2,
|
canvas = self.canvas_2,
|
||||||
data = self._ics,
|
data = self._ics,
|
||||||
toolbar = None,
|
toolbar = None,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue