From 55da58f7fef14843c41f06e23a9910e3ef41b96a Mon Sep 17 00:00:00 2001 From: Wenchen Lie <438171766@qq.com> Date: Sun, 27 Oct 2024 02:06:09 +0800 Subject: [PATCH] =?UTF-8?q?V2.1=20=E4=BF=AE=E5=A4=8Dbug=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=BB=9F=E4=B8=80=E7=BC=A9=E6=94=BE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/win.py | 90 +++++++++++++++++------ ui/main_win.py | 8 ++- ui/main_win.ui | 21 +++++- ui/win_about.py | 2 +- ui/win_importGM.py | 2 +- ui/win_importGM.ui | 2 +- ui/win_scale.py | 104 +++++++++++++++++++++++++++ ui/win_scale.ui | 174 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 378 insertions(+), 25 deletions(-) create mode 100644 ui/win_scale.py create mode 100644 ui/win_scale.ui diff --git a/core/win.py b/core/win.py index b86e350..261ecfc 100644 --- a/core/win.py +++ b/core/win.py @@ -32,11 +32,12 @@ from ui.win_export import Ui_win_export from ui.win_about import Ui_win_about from ui.win_terminal import Ui_win_terminal +from ui.win_scale import Ui_win_scale SOFTWARE = '非线性多自由度时程分析软件' -VERSION = 'V2.0.2' -DATE = '2024.08.26' +VERSION = 'V2.1.0' +DATE = '2024.10.27' TEMP_PATH = Path(os.getenv('TEMP')).as_posix() ROOT = Path(__file__).parent.parent @@ -84,6 +85,7 @@ def init_ui(self): self.ui.setupUi(self) self.setWindowTitle(f'{SOFTWARE} {VERSION}') self.ui.pushButton.clicked.connect(self.open_win_select_gm) + self.ui.pushButton_23.clicked.connect(self.open_win_scale) self.ui.pushButton_2.clicked.connect(self.open_win_select_gm1) self.ui.pushButton_5.clicked.connect(self.delete_seleted) self.ui.pushButton_4.clicked.connect(self.delete_all) @@ -157,14 +159,14 @@ def init_ui(self): def init_gm_var(self): """初始化地震动变量""" - self.gm = [] # 加速度序列 - self.gm_name = [] - self.gm_N = 0 - self.gm_dt = [] - self.gm_NPTS = [] - self.gm_t = [] # 时间序列 - self.gm_duration = [] # 持时 - self.gm_unit = [] # 单位 + self.gm: list[np.ndarray] = [] # 加速度序列 + self.gm_name: list[str] = [] + self.gm_N: int = 0 + self.gm_dt: list[float] = [] + self.gm_NPTS: list[int] = [] + self.gm_t: list[np.ndarray] = [] # 时间序列 + self.gm_duration: list[float] = [] # 持时 + self.gm_unit: list[Literal['g', 'cm/s^2', 'm/s^2', 'mm/s^2']] = [] # 单位 self.gm_PGA = [] def init_var(self): @@ -275,6 +277,11 @@ def open_win_select_gm(self): win = Win_importGM(self) win.exec_() + def open_win_scale(self): + win = Win_scale(self) + win.exec_() + self.plot_gm(None, self.current_gm_idx) + def gm_list_update(self): """更新地震动列表""" self.ui.listWidget.clear() @@ -358,16 +365,15 @@ def update_gm(self): self.ui.lineEdit_4.setText('0.00001') if float(self.ui.lineEdit.text()) == 0: self.ui.lineEdit.setText('0.00001') + target_PGA = float(self.ui.lineEdit_4.text()) + target_dt = float(self.ui.lineEdit.text()) idx = self.current_gm_idx - self.gm_PGA[idx] = float(self.ui.lineEdit_4.text()) - self.gm_dt[idx] = float(self.ui.lineEdit.text()) + self.gm_PGA[idx] = target_PGA + self.gm_t[idx] *= float(self.ui.lineEdit.text()) / self.gm_dt[idx] + self.gm_dt[idx] = target_dt self.gm_unit[idx] = self.ui.comboBox.currentText() - self.gm_duration[idx] = self.gm_NPTS[idx] * float(self.ui.lineEdit.text()) - th_old = self.gm[idx] - th = th_old / max(abs(th_old)) * float(self.ui.lineEdit_4.text()) - t = np.linspace(0, self.gm_NPTS[idx] * float(self.ui.lineEdit.text()), self.gm_NPTS[idx] + 1) - self.gm[idx] = th - self.gm_t[idx] = t + self.gm_duration[idx] = self.gm_NPTS[idx] * target_dt + self.gm[idx] *= target_PGA / max(abs(self.gm[idx])) self.ui.label_5.setText(f'{self.gm_name[idx]}已更新') self.plot_gm(None, idx=idx) @@ -572,8 +578,8 @@ def model_is_complete(self): print('【MyWin, model_is_complete】质量数量与层数不等') return False print('【MyWin, model_is_complete】模型完备!') - print('【MyWin, model_is_complete】', self.mat_lib) - print('【MyWin, model_is_complete】', self.story_mat) + print('【MyWin, model_is_complete】材料定义:', self.mat_lib) + print('【MyWin, model_is_complete】楼层材料', self.story_mat) return True def mat_is_complete(self): @@ -2785,3 +2791,47 @@ def __init__(self, parent=None): self.ui.setupUi(self) sys.stdout = core.EmittingStream(self.ui.textEdit) sys.stderr = core.EmittingStream(self.ui.textEdit) + + +class Win_scale(QDialog): + """统一缩放地震动""" + def __init__(self, main: MyWin, parent=None): + super().__init__(parent) + self.main = main + self.ui = Ui_win_scale() + self.ui.setupUi(self) + self.init_ui() + + def init_ui(self): + validator = QDoubleValidator(0, 10000, 7) + validator.setNotation(QDoubleValidator.StandardNotation) + self.ui.lineEdit.setValidator(validator) + self.ui.lineEdit_4.setValidator(validator) + self.ui.pushButton.clicked.connect(self.confirmation) + self.ui.radioButton_5.toggled.connect(lambda: self.ui.lineEdit.setEnabled(self.ui.radioButton_5.isChecked())) + self.ui.radioButton_6.toggled.connect(lambda: self.ui.lineEdit_4.setEnabled(self.ui.radioButton_6.isChecked())) + + def confirmation(self): + """点击确认""" + print(f'【Win_scale, confirmation】进行地震动缩放') + if self.main.gm_N == 0: + self.accept() + return + if self.ui.radioButton_4.isChecked(): + # 归一化 + for idx in range(self.main.gm_N): + self.main.gm[idx] /= np.max(abs(self.main.gm[idx])) + elif self.ui.radioButton_5.isChecked(): + # 指定PGA + PGA = float(self.ui.lineEdit.text()) + for idx in range(self.main.gm_N): + self.main.gm[idx] *= PGA / np.max(abs(self.main.gm[idx])) + else: + # 指定缩放系数 + SF = float(self.ui.lineEdit_4.text()) + for idx in range(self.main.gm_N): + self.main.gm[idx] *= SF + self.main.ui.label_5.setText('已统一缩放') + self.accept() + + \ No newline at end of file diff --git a/ui/main_win.py b/ui/main_win.py index 09994ac..a5c540d 100644 --- a/ui/main_win.py +++ b/ui/main_win.py @@ -150,12 +150,17 @@ def setupUi(self, MainWindow): self.pushButton_3.setMaximumSize(QtCore.QSize(16777215, 30)) self.pushButton_3.setObjectName("pushButton_3") self.horizontalLayout_2.addWidget(self.pushButton_3) + self.pushButton_23 = QtWidgets.QPushButton(self.groupBox) + self.pushButton_23.setMinimumSize(QtCore.QSize(200, 30)) + self.pushButton_23.setMaximumSize(QtCore.QSize(16777215, 30)) + self.pushButton_23.setObjectName("pushButton_23") + self.horizontalLayout_2.addWidget(self.pushButton_23) self.label_5 = QtWidgets.QLabel(self.groupBox) self.label_5.setMaximumSize(QtCore.QSize(16777215, 40)) self.label_5.setText("") self.label_5.setObjectName("label_5") self.horizontalLayout_2.addWidget(self.label_5) - self.horizontalLayout_2.setStretch(1, 1) + self.horizontalLayout_2.setStretch(2, 1) self.verticalLayout.addLayout(self.horizontalLayout_2) self.verticalLayout.setStretch(0, 6) self.verticalLayout.setStretch(1, 1) @@ -621,6 +626,7 @@ def retranslateUi(self, MainWindow): self.comboBox.setItemText(2, _translate("MainWindow", "cm/s^2")) self.comboBox.setItemText(3, _translate("MainWindow", "m/s^2")) self.pushButton_3.setText(_translate("MainWindow", "更新")) + self.pushButton_23.setText(_translate("MainWindow", "统一缩放")) self.label_11.setText(_translate("MainWindow", "已导入地震动:(点击可绘制)")) self.pushButton_5.setText(_translate("MainWindow", "删除选中")) self.pushButton_4.setText(_translate("MainWindow", "删除全部")) diff --git a/ui/main_win.ui b/ui/main_win.ui index 8354e74..fd0248b 100644 --- a/ui/main_win.ui +++ b/ui/main_win.ui @@ -405,7 +405,7 @@ - + @@ -425,6 +425,25 @@ + + + + + 200 + 30 + + + + + 16777215 + 30 + + + + 统一缩放 + + + diff --git a/ui/win_about.py b/ui/win_about.py index 3961f3f..607ad01 100644 --- a/ui/win_about.py +++ b/ui/win_about.py @@ -36,7 +36,7 @@ def setupUi(self, win_about): self.frame.setLineWidth(1) self.frame.setObjectName("frame") self.label = QtWidgets.QLabel(self.frame) - self.label.setGeometry(QtCore.QRect(40, 40, 171, 150)) + self.label.setGeometry(QtCore.QRect(50, 40, 150, 150)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) diff --git a/ui/win_importGM.py b/ui/win_importGM.py index 6c96db8..db3e08d 100644 --- a/ui/win_importGM.py +++ b/ui/win_importGM.py @@ -144,7 +144,7 @@ def retranslateUi(self, win_importGM): self.radioButton_6.setText(_translate("win_importGM", "指定缩放系数:")) self.lineEdit_4.setText(_translate("win_importGM", "1")) self.groupBox_3.setTitle(_translate("win_importGM", "通过.records文件导入")) - self.checkBox_2.setText(_translate("win_importGM", "缩放")) + self.checkBox_2.setText(_translate("win_importGM", "采用内置缩放")) self.pushButton_2.setText(_translate("win_importGM", "选择.records")) self.pushButton.setText(_translate("win_importGM", "选择文件")) import resource_rc diff --git a/ui/win_importGM.ui b/ui/win_importGM.ui index 647f358..287e9d2 100644 --- a/ui/win_importGM.ui +++ b/ui/win_importGM.ui @@ -208,7 +208,7 @@ - 缩放 + 采用内置缩放 diff --git a/ui/win_scale.py b/ui/win_scale.py new file mode 100644 index 0000000..a5b0bed --- /dev/null +++ b/ui/win_scale.py @@ -0,0 +1,104 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'f:\Projects\NLMDOF\ui\win_scale.ui' +# +# Created by: PyQt5 UI code generator 5.15.9 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_win_scale(object): + def setupUi(self, win_scale): + win_scale.setObjectName("win_scale") + win_scale.resize(300, 214) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(win_scale.sizePolicy().hasHeightForWidth()) + win_scale.setSizePolicy(sizePolicy) + win_scale.setMinimumSize(QtCore.QSize(300, 200)) + win_scale.setMaximumSize(QtCore.QSize(300, 214)) + font = QtGui.QFont() + font.setFamily("宋体") + font.setPointSize(12) + win_scale.setFont(font) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(":/插图/N.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + win_scale.setWindowIcon(icon) + self.verticalLayout_3 = QtWidgets.QVBoxLayout(win_scale) + self.verticalLayout_3.setObjectName("verticalLayout_3") + self.groupBox_2 = QtWidgets.QGroupBox(win_scale) + self.groupBox_2.setObjectName("groupBox_2") + self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.groupBox_2) + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.radioButton_4 = QtWidgets.QRadioButton(self.groupBox_2) + self.radioButton_4.setChecked(True) + self.radioButton_4.setObjectName("radioButton_4") + self.verticalLayout_2.addWidget(self.radioButton_4) + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.radioButton_5 = QtWidgets.QRadioButton(self.groupBox_2) + self.radioButton_5.setObjectName("radioButton_5") + self.horizontalLayout_2.addWidget(self.radioButton_5) + self.lineEdit = QtWidgets.QLineEdit(self.groupBox_2) + self.lineEdit.setEnabled(False) + self.lineEdit.setMinimumSize(QtCore.QSize(0, 30)) + self.lineEdit.setObjectName("lineEdit") + self.horizontalLayout_2.addWidget(self.lineEdit) + self.verticalLayout_2.addLayout(self.horizontalLayout_2) + self.horizontalLayout_4 = QtWidgets.QHBoxLayout() + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.radioButton_6 = QtWidgets.QRadioButton(self.groupBox_2) + self.radioButton_6.setObjectName("radioButton_6") + self.horizontalLayout_4.addWidget(self.radioButton_6) + self.lineEdit_4 = QtWidgets.QLineEdit(self.groupBox_2) + self.lineEdit_4.setEnabled(False) + self.lineEdit_4.setMinimumSize(QtCore.QSize(0, 30)) + self.lineEdit_4.setObjectName("lineEdit_4") + self.horizontalLayout_4.addWidget(self.lineEdit_4) + self.verticalLayout_2.addLayout(self.horizontalLayout_4) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.pushButton = QtWidgets.QPushButton(self.groupBox_2) + self.pushButton.setMinimumSize(QtCore.QSize(0, 30)) + self.pushButton.setCheckable(False) + self.pushButton.setObjectName("pushButton") + self.horizontalLayout.addWidget(self.pushButton) + self.pushButton_2 = QtWidgets.QPushButton(self.groupBox_2) + self.pushButton_2.setMinimumSize(QtCore.QSize(0, 30)) + self.pushButton_2.setObjectName("pushButton_2") + self.horizontalLayout.addWidget(self.pushButton_2) + self.verticalLayout_2.addLayout(self.horizontalLayout) + self.verticalLayout_3.addWidget(self.groupBox_2) + self.verticalLayout_3.setStretch(0, 5) + + self.retranslateUi(win_scale) + self.pushButton_2.clicked.connect(win_scale.accept) # type: ignore + QtCore.QMetaObject.connectSlotsByName(win_scale) + + def retranslateUi(self, win_scale): + _translate = QtCore.QCoreApplication.translate + win_scale.setWindowTitle(_translate("win_scale", "缩放")) + self.groupBox_2.setTitle(_translate("win_scale", "缩放所有地震动")) + self.radioButton_4.setText(_translate("win_scale", "归一化")) + self.radioButton_5.setText(_translate("win_scale", "指定PGA(g):")) + self.lineEdit.setText(_translate("win_scale", "0.4")) + self.radioButton_6.setText(_translate("win_scale", "指定缩放系数:")) + self.lineEdit_4.setText(_translate("win_scale", "1")) + self.pushButton.setText(_translate("win_scale", "确认")) + self.pushButton_2.setText(_translate("win_scale", "返回")) +import resource_rc + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + win_scale = QtWidgets.QDialog() + ui = Ui_win_scale() + ui.setupUi(win_scale) + win_scale.show() + sys.exit(app.exec_()) diff --git a/ui/win_scale.ui b/ui/win_scale.ui new file mode 100644 index 0000000..3a326db --- /dev/null +++ b/ui/win_scale.ui @@ -0,0 +1,174 @@ + + + win_scale + + + + 0 + 0 + 300 + 214 + + + + + 0 + 0 + + + + + 300 + 200 + + + + + 300 + 214 + + + + + 宋体 + 12 + + + + 缩放 + + + + :/插图/N.png:/插图/N.png + + + + + + 缩放所有地震动 + + + + + + 归一化 + + + true + + + + + + + + + 指定PGA(g): + + + + + + + false + + + + 0 + 30 + + + + 0.4 + + + + + + + + + + + 指定缩放系数: + + + + + + + false + + + + 0 + 30 + + + + 1 + + + + + + + + + + + + 0 + 30 + + + + 确认 + + + false + + + + + + + + 0 + 30 + + + + 返回 + + + + + + + + + + + + + + + + pushButton_2 + clicked() + win_scale + accept() + + + 228 + 172 + + + 79 + -9 + + + + +