mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
BC: Add D50 and sigma edition for solid BC.
This commit is contained in:
1 parent
fb9c2a4308
commit
0c06b4cb2a
6 files changed
+213
-17
No files matched your search
@@ -18,33 +18,77 @@
|
||||
|
||||
from tools import timer, trace
|
||||
|
||||
from View.ASubWindow import ASubMainWindow
|
||||
from View.ASubWindow import ASubMainWindow, AWidget
|
||||
from View.ListedSubWindow import ListedSubWindow
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel, QCoreApplication,
|
||||
pyqtSlot, pyqtSignal,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QHeaderView,
|
||||
QHeaderView, QDoubleSpinBox, QVBoxLayout,
|
||||
)
|
||||
|
||||
from View.Plot.MplCanvas import MplCanvas
|
||||
from View.Plot.navigation_toolbar_2qt import PamHyrNavigationToolbar2QT
|
||||
|
||||
from View.BoundaryCondition.translate import long_types
|
||||
from View.BoundaryCondition.Edit.UndoCommand import SetMetaDataCommand
|
||||
from View.BoundaryCondition.Edit.Table import TableModel, ExTimeDelegate
|
||||
from View.BoundaryCondition.Edit.Plot import Plot
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
class WD50Sigma(AWidget):
|
||||
d50Changed = pyqtSignal(float)
|
||||
sigmaChanged = pyqtSignal(float)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(WD50Sigma, self).__init__(
|
||||
ui="d50sigma",
|
||||
parent=parent
|
||||
)
|
||||
self.parent = parent
|
||||
|
||||
self.spinBox_d50 = self.find(QDoubleSpinBox, "doubleSpinBox_d50")
|
||||
self.spinBox_sigma = self.find(QDoubleSpinBox, "doubleSpinBox_sigma")
|
||||
|
||||
self.spinBox_d50.valueChanged.connect(self.valueChangedD50)
|
||||
self.spinBox_sigma.valueChanged.connect(self.valueChangedSigma)
|
||||
|
||||
def set_d50(self, d50):
|
||||
self.spinBox_d50.valueChanged.disconnect(self.valueChangedD50)
|
||||
self.spinBox_d50.setValue(float(d50))
|
||||
self.spinBox_d50.valueChanged.connect(self.valueChangedD50)
|
||||
|
||||
def get_d50(self):
|
||||
return float(self.spinBox_d50.value())
|
||||
|
||||
def set_sigma(self, sigma):
|
||||
self.spinBox_sigma.valueChanged.disconnect(self.valueChangedSigma)
|
||||
self.spinBox_sigma.setValue(float(sigma))
|
||||
self.spinBox_sigma.valueChanged.connect(self.valueChangedSigma)
|
||||
|
||||
def get_sigma(self):
|
||||
return float(self.spinBox_sigma.value())
|
||||
|
||||
@QtCore.pyqtSlot(float)
|
||||
def valueChangedD50(self, value):
|
||||
self.d50Changed.emit(value)
|
||||
|
||||
@QtCore.pyqtSlot(float)
|
||||
def valueChangedSigma(self, value):
|
||||
self.sigmaChanged.emit(value)
|
||||
|
||||
class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def __init__(self, title="Edit boundary condition",
|
||||
data=None, study=None, parent=None):
|
||||
@@ -63,6 +107,7 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.setup_sc()
|
||||
self.setup_table()
|
||||
self.setup_plot()
|
||||
self.setup_data()
|
||||
self.setup_connections()
|
||||
|
||||
def compute_title(self):
|
||||
@@ -84,6 +129,17 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
self.copy_sc = QShortcut(QKeySequence.Copy, self)
|
||||
self.paste_sc = QShortcut(QKeySequence.Paste, self)
|
||||
|
||||
def setup_data(self):
|
||||
self._is_solid = self._data.bctype == "SL"
|
||||
|
||||
if self._is_solid:
|
||||
layout = self.find(QVBoxLayout, "verticalLayout_table")
|
||||
self._d50sigma = WD50Sigma(parent = self)
|
||||
layout.addWidget(self._d50sigma)
|
||||
|
||||
self._d50sigma.set_d50(self._data.d50)
|
||||
self._d50sigma.set_sigma(self._data.sigma)
|
||||
|
||||
def setup_table(self):
|
||||
table = self.find(QTableView, "tableView")
|
||||
self._table = TableModel(
|
||||
@@ -138,6 +194,31 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
|
||||
self._table.dataChanged.connect(self.update)
|
||||
|
||||
if self._is_solid:
|
||||
self._d50sigma.d50Changed.connect(self.d50_changed)
|
||||
self._d50sigma.sigmaChanged.connect(self.sigma_changed)
|
||||
|
||||
def d50_changed(self, value):
|
||||
self._undo_stack.push(
|
||||
SetMetaDataCommand(
|
||||
self._data,
|
||||
"d50", value
|
||||
)
|
||||
)
|
||||
|
||||
def sigma_changed(self, value):
|
||||
self._undo_stack.push(
|
||||
SetMetaDataCommand(
|
||||
self._data,
|
||||
"sigma", value
|
||||
)
|
||||
)
|
||||
|
||||
def widget_update(self):
|
||||
if self._is_solid:
|
||||
self._d50sigma.set_d50(self._data.d50)
|
||||
self._d50sigma.set_sigma(self._data.sigma)
|
||||
|
||||
def update(self):
|
||||
self.plot.update()
|
||||
|
||||
@@ -221,7 +302,9 @@ class EditBoundaryConditionWindow(ASubMainWindow, ListedSubWindow):
|
||||
def undo(self):
|
||||
self._table.undo()
|
||||
self.plot.update()
|
||||
self.widget_update()
|
||||
|
||||
def redo(self):
|
||||
self._table.redo()
|
||||
self.plot.update()
|
||||
self.widget_update()
|
||||
Reference in new issue
Block a user