class RunDialog(QtGui.QDialog): """ Defines run window dialog """ WINDOW_TITLE_TEMPLATE = __("DualSPHysics Simulation: {}%") PARTICLES_OUT_TEMPLATE = __("Total particles out: {}") ETA_TEMPLATE = __("Estimated time to complete simulation: {}") MIN_WIDTH = 600 cancelled = QtCore.Signal() def __init__(self, case_name: str, processor: str, number_of_particles: int, cmd_string="", parent=None): super().__init__(parent=parent) self.run_watcher = QtCore.QFileSystemWatcher() self.cmd_string = cmd_string # Title and size self.setModal(False) self.setWindowTitle(__("DualSPHysics Simulation: {}%").format("0")) self.run_dialog_layout = QtGui.QVBoxLayout() # Information GroupBox self.run_group = QtGui.QGroupBox(__("Simulation Data")) self.run_group_layout = QtGui.QVBoxLayout() self.run_group_label_case = QtGui.QLabel( __("Case name: {}").format(case_name)) self.run_group_label_proc = QtGui.QLabel( __("Simulation processor: {}").format(processor)) self.run_group_label_part = QtGui.QLabel( __("Number of particles: {}").format(number_of_particles)) self.run_group_label_partsout = QtGui.QLabel( self.PARTICLES_OUT_TEMPLATE.format(0)) self.run_group_label_eta = QtGui.QLabel(self) self.run_group_label_eta.setText( self.ETA_TEMPLATE.format("Calculating...")) self.run_group_label_completed = QtGui.QLabel("<b>{}</b>".format( __("Simulation is complete."))) self.run_group_label_completed.setVisible(False) self.run_group_layout.addWidget(self.run_group_label_case) self.run_group_layout.addWidget(self.run_group_label_proc) self.run_group_layout.addWidget(self.run_group_label_part) self.run_group_layout.addWidget(self.run_group_label_partsout) self.run_group_layout.addWidget(self.run_group_label_eta) self.run_group_layout.addWidget(self.run_group_label_completed) self.run_group_layout.addStretch(1) self.run_group.setLayout(self.run_group_layout) # Progress Bar self.run_progbar_layout = QtGui.QHBoxLayout() self.run_progbar_bar = QtGui.QProgressBar() self.run_progbar_bar.setRange(0, 100) self.run_progbar_bar.setTextVisible(False) self.run_progbar_layout.addWidget(self.run_progbar_bar) # Buttons self.run_button_layout = QtGui.QHBoxLayout() self.run_button_warnings = QtGui.QPushButton(__("Show Warnings")) self.run_button_warnings.hide() self.run_button_details = QtGui.QPushButton(__("Details")) self.run_button_cancel = QtGui.QPushButton(__("Cancel Simulation")) self.run_button_layout.addWidget(self.run_button_warnings) self.run_button_layout.addStretch(1) self.run_button_layout.addWidget(self.run_button_details) self.run_button_layout.addWidget(self.run_button_cancel) # Defines run details self.run_details = QtGui.QWidget() self.run_details.setWindowTitle(__("Simulation details")) self.run_details_layout = QtGui.QVBoxLayout() self.run_details_layout.setContentsMargins(0, 0, 0, 0) self.run_details_text = QtGui.QTextEdit() self.run_details_text.setReadOnly(True) self.run_details_layout.addWidget(h_line_generator()) self.run_details_layout.addWidget(self.run_details_text) self.run_details.hide() self.run_button_cancel.clicked.connect(self.cancelled.emit) self.run_button_details.clicked.connect(self.toggle_run_details) self.run_details.setLayout(self.run_details_layout) self.run_dialog_layout.addWidget(self.run_group) self.run_dialog_layout.addLayout(self.run_progbar_layout) self.run_dialog_layout.addLayout(self.run_button_layout) self.run_dialog_layout.addWidget(self.run_details) self.setLayout(self.run_dialog_layout) self.setMinimumWidth(self.MIN_WIDTH) self.adjustSize() def hide_all(self) -> None: """ Hides both the run details and this dialog. """ self.run_details.hide() self.hide() def set_value(self, value: int) -> None: """ Sets the value for the run dialog progress bar. """ self.run_progbar_bar.setValue(value) def run_update(self, percentage: float, particles_out: int, estimated_time: str) -> None: """ Updates the run dialog with information about the execution. """ if percentage: self.setWindowTitle( self.WINDOW_TITLE_TEMPLATE.format( "{0:.2f}".format(percentage))) self.set_value(percentage) self.run_group_label_partsout.setText( self.PARTICLES_OUT_TEMPLATE.format(str(particles_out))) if estimated_time: self.run_group_label_eta.setText( self.ETA_TEMPLATE.format(estimated_time)) def run_complete(self) -> None: """ Modifies the dialog accordingly with a complete simulation. """ self.setWindowTitle(__("DualSPHysics Simulation: Complete")) self.run_progbar_bar.setValue(100) self.run_button_cancel.setText(__("Close")) self.run_group_label_completed.setVisible(True) self.run_details_text.setPlainText("{}: {}\n{}".format( __("The executed command line was"), self.cmd_string, self.run_details_text.toPlainText())) self.run_details_text.moveCursor(QtGui.QTextCursor.Start) self.compute_warnings() def compute_warnings(self) -> None: """ Checks the resulting output for a [Warnings] tab and adds a button to see them. """ details_text: str = self.run_details_text.toPlainText() if "[WARNINGS]" not in details_text: return warning_list: list = details_text.split("[WARNINGS]\n")[-1].split( "\n\n")[0].split("[")[0].split("\n") self.run_group_label_completed.setText( "<b style='color: #ABA400'>{}</b>".format( __("Simulation completed with warnings."))) try: self.run_button_warnings.clicked.disconnect() except RuntimeError: # If nothing is yet connected it will throw an exception. pass self.run_button_warnings.clicked.connect(lambda _=False, text=( LINE_END * 2).join(warning_list): warning_dialog(text)) self.run_button_warnings.show() def toggle_run_details(self) -> None: """ Toggles the run details dialog panel. """ self.run_details.setVisible(not self.run_details.isVisible()) self.adjustSize() def set_detail_text(self, details: str) -> None: """ Sets the details text contents and scrolls it to the bottom. """ self.run_details_text.setPlainText(details.replace("\\n", "\n")) self.run_details_text.moveCursor(QtGui.QTextCursor.End)
def on_cfces_csv_browse(self): file_name, _ = QtGui.QFileDialog().getOpenFileName( self, __("Select csv path")) self.cfces_csv_path.setText(file_name) Case.the().custom.cfces_csv_path = self.cfces_csv_path.text()
def __init__(self, relaxationzone=None, parent=None): super().__init__(parent=parent) self.temp_relaxationzone = relaxationzone if relaxationzone is not None else RelaxationZoneFile( ) self.relaxationzone = relaxationzone self.main_layout = QtGui.QVBoxLayout() self.data_layout = QtGui.QVBoxLayout() self.button_layout = QtGui.QHBoxLayout() self.start_layout = QtGui.QHBoxLayout() self.start_label = QtGui.QLabel(__("Start time (s):")) self.start_input = QtGui.QLineEdit() for x in [self.start_label, self.start_input]: self.start_layout.addWidget(x) self.duration_layout = QtGui.QHBoxLayout() self.duration_label = QtGui.QLabel( __("Movement duration (0 for end of simulation):")) self.duration_input = QtGui.QLineEdit() for x in [self.duration_label, self.duration_input]: self.duration_layout.addWidget(x) self.depth_layout = QtGui.QHBoxLayout() self.depth_label = QtGui.QLabel(__("Water depth:")) self.depth_input = QtGui.QLineEdit() for x in [self.depth_label, self.depth_input]: self.depth_layout.addWidget(x) self.swl_layout = QtGui.QHBoxLayout() self.swl_label = QtGui.QLabel(__("Still water level:")) self.swl_input = QtGui.QLineEdit() for x in [self.swl_label, self.swl_input]: self.swl_layout.addWidget(x) self.filesvel_layout = QtGui.QHBoxLayout() self.filesvel_label = QtGui.QLabel( __("Name of the file with velocity to use:")) self.filesvel_input = QtGui.QLineEdit() self.filesvel_browse = QtGui.QPushButton("...") for x in [ self.filesvel_label, self.filesvel_input, self.filesvel_browse ]: self.filesvel_layout.addWidget(x) self.filesvelx_initial_layout = QtGui.QHBoxLayout() self.filesvelx_initial_label = QtGui.QLabel(__("First file:")) self.filesvelx_initial_input = QtGui.QLineEdit() for x in [self.filesvelx_initial_label, self.filesvelx_initial_input]: self.filesvelx_initial_layout.addWidget(x) self.filesvelx_count_layout = QtGui.QHBoxLayout() self.filesvelx_count_label = QtGui.QLabel(__("File count:")) self.filesvelx_count_input = QtGui.QLineEdit() for x in [self.filesvelx_count_label, self.filesvelx_count_input]: self.filesvelx_count_layout.addWidget(x) self.usevelz_check = QtGui.QCheckBox(__("Use velocity in Z")) self.movedata_layout = QtGui.QHBoxLayout() self.movedata_label = QtGui.QLabel( __("Movement of data in CSV files (X, Y, Z):")) self.movedata_x = QtGui.QLineEdit() self.movedata_y = QtGui.QLineEdit() self.movedata_z = QtGui.QLineEdit() for x in [ self.movedata_label, self.movedata_x, self.movedata_y, self.movedata_z ]: self.movedata_layout.addWidget(x) self.dpz_layout = QtGui.QHBoxLayout() self.dpz_label = QtGui.QLabel( __("Distance between key points in Z (dp):")) self.dpz_input = QtGui.QLineEdit() for x in [self.dpz_label, self.dpz_input]: self.dpz_layout.addWidget(x) self.smooth_layout = QtGui.QHBoxLayout() self.smooth_label = QtGui.QLabel(__("Smooth motion level:")) self.smooth_input = QtGui.QLineEdit() for x in [self.smooth_label, self.smooth_input]: self.smooth_layout.addWidget(x) self.center_layout = QtGui.QHBoxLayout() self.center_label = QtGui.QLabel(__("Central point (X, Y, Z):")) self.center_x = QtGui.QLineEdit() self.center_y = QtGui.QLineEdit() self.center_z = QtGui.QLineEdit() for x in [ self.center_label, self.center_x, self.center_y, self.center_z ]: self.center_layout.addWidget(x) self.width_layout = QtGui.QHBoxLayout() self.width_label = QtGui.QLabel(__("Width for generation:")) self.width_input = QtGui.QLineEdit() for x in [self.width_label, self.width_input]: self.width_layout.addWidget(x) self.coefdir_layout = QtGui.QHBoxLayout() self.coefdir_label = QtGui.QLabel( __("Coefficient for each direction (X, Y, Z):")) self.coefdir_x = QtGui.QLineEdit() self.coefdir_x.setEnabled(False) self.coefdir_y = QtGui.QLineEdit() self.coefdir_y.setEnabled(False) self.coefdir_z = QtGui.QLineEdit() self.coefdir_z.setEnabled(False) for x in [ self.coefdir_label, self.coefdir_x, self.coefdir_y, self.coefdir_z ]: self.coefdir_layout.addWidget(x) self.coefdt_layout = QtGui.QHBoxLayout() self.coefdt_label = QtGui.QLabel( __("Multiplier for dt value in each direction:")) self.coefdt_input = QtGui.QLineEdit() self.coefdt_input.setEnabled(False) for x in [self.coefdt_label, self.coefdt_input]: self.coefdt_layout.addWidget(x) self.function_layout = QtGui.QHBoxLayout() self.function_label = QtGui.QLabel( __("Coefficients in function for velocity ->")) self.function_psi_label = QtGui.QLabel(__("Psi: ")) self.function_psi_input = QtGui.QLineEdit() self.function_beta_label = QtGui.QLabel(__("Beta: ")) self.function_beta_input = QtGui.QLineEdit() for x in [ self.function_label, self.function_psi_label, self.function_psi_input, self.function_beta_label, self.function_beta_input ]: self.function_layout.addWidget(x) self.driftcorrection_layout = QtGui.QHBoxLayout() self.driftcorrection_label = QtGui.QLabel( __("Coefficient of drift correction (for X):")) self.driftcorrection_input = QtGui.QLineEdit() for x in [self.driftcorrection_label, self.driftcorrection_input]: self.driftcorrection_layout.addWidget(x) self.driftinitialramp_layout = QtGui.QHBoxLayout() self.driftinitialramp_label = QtGui.QLabel( __("Time to ignore waves from external data (s):")) self.driftinitialramp_input = QtGui.QLineEdit() for x in [self.driftinitialramp_label, self.driftinitialramp_input]: self.driftinitialramp_layout.addWidget(x) for x in [ self.start_layout, self.duration_layout, self.depth_layout, self.swl_layout, self.filesvel_layout, self.filesvelx_initial_layout, self.filesvelx_count_layout ]: self.data_layout.addLayout(x) self.data_layout.addWidget(self.usevelz_check) for x in [ self.movedata_layout, self.dpz_layout, self.smooth_layout, self.center_layout, self.width_layout, self.coefdir_layout, self.coefdt_layout, self.function_layout, self.driftcorrection_layout, self.driftinitialramp_layout ]: self.data_layout.addLayout(x) self.delete_button = QtGui.QPushButton(__("Delete RZ configuration")) self.apply_button = QtGui.QPushButton(__("Apply this configuration")) self.button_layout.addStretch(1) self.button_layout.addWidget(self.delete_button) self.button_layout.addWidget(self.apply_button) self.main_layout.addLayout(self.data_layout) self.main_layout.addStretch(1) self.main_layout.addLayout(self.button_layout) self.apply_button.clicked.connect(self.on_apply) self.delete_button.clicked.connect(self.on_delete) self.filesvel_browse.clicked.connect(self.on_browse) self.setLayout(self.main_layout) self.fill_data() self.exec_()
def __init__(self, parent=None): super().__init__(parent=parent) # Reference to the inlet outlet configuration on the case data self.inlet_outlet: InletOutletConfig = Case.the().inlet_outlet # Creates a dialog self.setWindowTitle("Inlet/Outlet configuration") self.setModal(False) self.setMinimumWidth(self.MINIMUM_WIDTH) self.setMinimumHeight(self.MINIMUM_HEIGHT) self.main_layout = QtGui.QVBoxLayout() # Creates layout for content first options self.io_options_layout = QtGui.QVBoxLayout() # Creates memory_resize option self.memory_resize_layout = QtGui.QHBoxLayout() self.memory_resize_size0_option = QtGui.QLabel(__("Initial Memory Resize: ")) self.memory_resize_size0_line_edit = QtGui.QLineEdit(str(self.inlet_outlet.memoryresize_size0)) self.memory_resize_size_option = QtGui.QLabel(__("Following Memory Resizes: ")) self.memory_resize_size_line_edit = QtGui.QLineEdit(str(self.inlet_outlet.memoryresize_size)) self.memory_resize_layout.addWidget(self.memory_resize_size0_option) self.memory_resize_layout.addWidget(self.memory_resize_size0_line_edit) self.memory_resize_layout.addWidget(self.memory_resize_size_option) self.memory_resize_layout.addWidget(self.memory_resize_size_line_edit) # Creates extrapolate mode selector self.useboxlimit_layout = QtGui.QHBoxLayout() self.useboxlimit_option = QtGui.QLabel(__("Use BoxLimit: ")) self.useboxlimit_check = QtGui.QCheckBox() self.useboxlimit_check.setChecked(self.inlet_outlet.useboxlimit_enabled) self.useboxlimit_layout.addWidget(self.useboxlimit_option) self.useboxlimit_layout.addWidget(self.useboxlimit_check) self.useboxlimit_layout.addStretch(1) # Creates extrapolate mode selector self.extrapolatemode_layout = QtGui.QHBoxLayout() self.extrapolatemode_option = QtGui.QLabel(__("Extrapolate mode: ")) self.extrapolatemode_combobox = QtGui.QComboBox() self.extrapolatemode_combobox.insertItems(0, [__("Fast-Single"), __("Single"), __("Double")]) self.extrapolatemode_combobox.setCurrentIndex(self.inlet_outlet.extrapolatemode - 1) self.extrapolatemode_layout.addWidget(self.extrapolatemode_option) self.extrapolatemode_layout.addWidget(self.extrapolatemode_combobox) self.extrapolatemode_layout.addStretch(1) # Creates use determlimit option self.determlimit_layout = QtGui.QHBoxLayout() self.determlimit_option = QtGui.QLabel(__("Determlimit: ")) self.determlimit_combobox = QtGui.QComboBox() self.determlimit_combobox.insertItems(0, [__("1e+3"), __("1e-3")]) self.determlimit_combobox.setCurrentIndex(0 if self.inlet_outlet.determlimit == InletOutletDetermLimit.ZEROTH_ORDER else 1) self.determlimit_layout.addWidget(self.determlimit_option) self.determlimit_layout.addWidget(self.determlimit_combobox) self.determlimit_layout.addStretch(1) self.first_row_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.first_row_layout.addLayout(self.extrapolatemode_layout) self.first_row_layout.addLayout(self.determlimit_layout) self.first_row_layout.addLayout(self.useboxlimit_layout) # Creates 2 main buttons self.finish_button = QtGui.QPushButton(__("Close")) self.button_layout = QtGui.QHBoxLayout() self.finish_button.clicked.connect(self.on_finish) self.button_layout.addStretch(1) self.button_layout.addWidget(self.finish_button) # Create the list for zones self.zones_groupbox = QtGui.QGroupBox(__("Inlet/Outlet zones")) self.zones_groupbox_layout = QtGui.QVBoxLayout() self.io_zones_table = QtGui.QTableWidget() self.io_zones_table.setColumnCount(1) self.io_zones_table.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch) self.io_zones_table.verticalHeader().setDefaultSectionSize(self.MINIMUM_TABLE_SECTION_HEIGHT) self.io_zones_table.horizontalHeader().setVisible(False) self.io_zones_table.verticalHeader().setVisible(False) # Add button self.add_button_layout = QtGui.QHBoxLayout() self.add_zone_button = QtGui.QPushButton(__("Add a new zone...")) self.add_button_layout.addStretch(1) self.add_button_layout.addWidget(self.add_zone_button) self.add_zone_button.clicked.connect(self.on_add_zone) self.zones_groupbox_layout.addLayout(self.add_button_layout) self.zones_groupbox_layout.addWidget(self.io_zones_table) self.zones_groupbox.setLayout(self.zones_groupbox_layout) # Adds options to option layout self.io_options_layout.addLayout(self.memory_resize_layout) self.io_options_layout.addLayout(self.first_row_layout) # Adds options to main self.main_layout.addLayout(self.io_options_layout) self.main_layout.addWidget(self.zones_groupbox) self.main_layout.addLayout(self.button_layout) self.setLayout(self.main_layout) self.refresh_zones() self.finish_button.setFocus() self.exec_()
def __init__(self, index, rot_motion, parent=None): if not isinstance(rot_motion, RotMotion): raise TypeError( "You tried to spawn a rotational motion widget in the timeline with a wrong object" ) if rot_motion is None: raise TypeError( "You tried to spawn a rotational motion widget in the timeline without a motion object" ) super().__init__(parent=parent) self.index = index self.main_layout = QtGui.QHBoxLayout() self.main_layout.setContentsMargins(10, 0, 10, 0) self.label = QtGui.QLabel("Rotational \nMotion ") self.label.setMinimumWidth(75) self.velocity_label = QtGui.QLabel("Vel: ") self.velocity_input = QtGui.QLineEdit() self.axis_label = QtGui.QLabel( "Axis 1 (X, Y, Z): \n\nAxis 2 (X, Y, Z): ") self.axis_layout = QtGui.QVBoxLayout() self.axis_first_row_layout = QtGui.QHBoxLayout() self.axis_second_row_layout = QtGui.QHBoxLayout() self.x1_input = QtGui.QLineEdit() self.y1_input = QtGui.QLineEdit() self.z1_input = QtGui.QLineEdit() self.x2_input = QtGui.QLineEdit() self.y2_input = QtGui.QLineEdit() self.z2_input = QtGui.QLineEdit() self.time_label = QtGui.QLabel(__("Duration (s): ")) self.time_input = QtGui.QLineEdit() self.delete_button = QtGui.QPushButton(get_icon("trash.png"), None) self.order_button_layout = QtGui.QVBoxLayout() self.order_button_layout.setContentsMargins(0, 0, 0, 0) self.order_button_layout.setSpacing(0) self.order_up_button = QtGui.QPushButton(get_icon("up_arrow.png"), None) self.order_down_button = QtGui.QPushButton(get_icon("down_arrow.png"), None) self.order_button_layout.addWidget(self.order_up_button) self.order_button_layout.addWidget(self.order_down_button) self.main_layout.addWidget(self.label) self.main_layout.addWidget(self.velocity_label) self.main_layout.addWidget(self.velocity_input) self.main_layout.addWidget(self.axis_label) self.axis_first_row_layout.addWidget(self.x1_input) self.axis_first_row_layout.addWidget(self.y1_input) self.axis_first_row_layout.addWidget(self.z1_input) self.axis_second_row_layout.addWidget(self.x2_input) self.axis_second_row_layout.addWidget(self.y2_input) self.axis_second_row_layout.addWidget(self.z2_input) self.axis_layout.addLayout(self.axis_first_row_layout) self.axis_layout.addLayout(self.axis_second_row_layout) self.main_layout.addLayout(self.axis_layout) self.main_layout.addStretch(1) self.main_layout.addWidget(self.time_label) self.main_layout.addWidget(self.time_input) self.main_layout.addWidget(self.delete_button) self.main_layout.addLayout(self.order_button_layout) self.setLayout(self.main_layout) self.fill_values(rot_motion) self._init_connections()
def on_relaxationzone_menu(self, action): """ Defines Relaxation Zone menu behaviour.""" # Check which type of relaxationzone it is if action.text() == __("Regular waves"): if Case.the().relaxation_zone is not None: if not isinstance(Case.the().relaxation_zone, RelaxationZoneRegular): overwrite_warn = ok_cancel_dialog( __("Relaxation Zone"), __("There's already another type of Relaxation Zone defined. Continuing will overwrite it. Are you sure?" )) if overwrite_warn == QtGui.QMessageBox.Cancel: return Case.the().relaxation_zone = RelaxationZoneRegular() config_dialog = RelaxationZoneRegularConfigDialog( Case.the().relaxation_zone, parent=get_fc_main_window()) # Set the relaxation zone. Can be an object or be None Case.the().relaxation_zone = config_dialog.relaxationzone if action.text() == __("Irregular waves"): if Case.the().relaxation_zone is not None: if not isinstance(Case.the().relaxation_zone, RelaxationZoneIrregular): overwrite_warn = ok_cancel_dialog( __("Relaxation Zone"), __("There's already another type of Relaxation Zone defined. Continuing will overwrite it. Are you sure?" )) if overwrite_warn == QtGui.QMessageBox.Cancel: return Case.the().relaxation_zone = RelaxationZoneIrregular() config_dialog = RelaxationZoneIrregularConfigDialog( Case.the().relaxation_zone, parent=get_fc_main_window()) # Set the relaxation zone. Can be an object or be None Case.the().relaxation_zone = config_dialog.relaxationzone if action.text() == __("External Input"): if Case.the().relaxation_zone is not None: if not isinstance(Case.the().relaxation_zone, RelaxationZoneFile): overwrite_warn = ok_cancel_dialog( __("Relaxation Zone"), __("There's already another type of Relaxation Zone defined. Continuing will overwrite it. Are you sure?" )) if overwrite_warn == QtGui.QMessageBox.Cancel: return Case.the().relaxation_zone = RelaxationZoneFile() config_dialog = RelaxationZoneFileConfigDialog( Case.the().relaxation_zone, parent=get_fc_main_window()) # Set the relaxation zone. Can be an object or be None Case.the().relaxation_zone = config_dialog.relaxationzone if action.text() == __("Uniform velocity"): if Case.the().relaxation_zone is not None: if not isinstance(Case.the().relaxation_zone, RelaxationZoneUniform): overwrite_warn = ok_cancel_dialog( __("Relaxation Zone"), __("There's already another type of Relaxation Zone defined. Continuing will overwrite it. Are you sure?" )) if overwrite_warn == QtGui.QMessageBox.Cancel: return Case.the().relaxation_zone = RelaxationZoneUniform() config_dialog = RelaxationZoneUniformConfigDialog( Case.the().relaxation_zone, parent=get_fc_main_window()) # Set the relaxation zone. Can be an object or be None Case.the().relaxation_zone = config_dialog.relaxationzone self.accept()
def __init__(self, mk=None, mlpiston2d=None, parent=None): super().__init__(parent=parent) self.mk = mk self.temp_mlpiston2d = mlpiston2d if mlpiston2d else MLPiston2D() self.mlpiston2d = mlpiston2d self.main_layout = QtGui.QVBoxLayout() self.data_layout = QtGui.QVBoxLayout() self.button_layout = QtGui.QHBoxLayout() self.mk_label = QtGui.QLabel(__("MK to use: {}").format(self.mk)) self.incz_layout = QtGui.QHBoxLayout() self.incz_label = QtGui.QLabel(__("Z offset (m):")) self.incz_input = QtGui.QLineEdit() for x in [self.incz_label, self.incz_input]: self.incz_layout.addWidget(x) self.smooth_layout = QtGui.QHBoxLayout() self.smooth_label = QtGui.QLabel(__("Smooth motion level (Z, Y):")) self.smooth_z = QtGui.QLineEdit() self.smooth_y = QtGui.QLineEdit() for x in [self.smooth_label, self.smooth_z, self.smooth_y]: self.smooth_layout.addWidget(x) self.veldata_groupbox = QtGui.QGroupBox(__("Velocity data")) self.veldata_groupbox_layout = QtGui.QVBoxLayout() self.veldata_filevelx_layout = QtGui.QHBoxLayout() self.veldata_filevelx_label = QtGui.QLabel(__("File series")) self.veldata_filevelx_input = QtGui.QLineEdit() self.veldata_filevelx_browse = QtGui.QPushButton("...") for x in [ self.veldata_filevelx_label, self.veldata_filevelx_input, self.veldata_filevelx_browse ]: self.veldata_filevelx_layout.addWidget(x) self.veldata_files_label = QtGui.QLabel(__("No files selected")) self.veldata_posy_layout = QtGui.QHBoxLayout() self.veldata_posy_label = QtGui.QLabel( __("Y positions (separated by commas):")) self.veldata_posy_input = QtGui.QLineEdit() for x in [self.veldata_posy_label, self.veldata_posy_input]: self.veldata_posy_layout.addWidget(x) self.veldata_timedataini_layout = QtGui.QHBoxLayout() self.veldata_timedataini_label = QtGui.QLabel( __("Time offsets (separated by commas):")) self.veldata_timedataini_input = QtGui.QLineEdit() for x in [ self.veldata_timedataini_label, self.veldata_timedataini_input ]: self.veldata_timedataini_layout.addWidget(x) self.veldata_groupbox_layout.addLayout(self.veldata_filevelx_layout) self.veldata_groupbox_layout.addWidget(self.veldata_files_label) self.veldata_groupbox_layout.addLayout(self.veldata_posy_layout) self.veldata_groupbox_layout.addLayout(self.veldata_timedataini_layout) self.veldata_groupbox.setLayout(self.veldata_groupbox_layout) for x in [self.incz_layout, self.smooth_layout]: self.data_layout.addLayout(x) self.data_layout.addWidget(self.veldata_groupbox) self.delete_button = QtGui.QPushButton( __("Delete piston configuration")) self.apply_button = QtGui.QPushButton(__("Apply this configuration")) self.button_layout.addStretch(1) self.button_layout.addWidget(self.delete_button) self.button_layout.addWidget(self.apply_button) self.main_layout.addWidget(self.mk_label) self.main_layout.addWidget(h_line_generator()) self.main_layout.addLayout(self.data_layout) self.main_layout.addStretch(1) self.main_layout.addLayout(self.button_layout) self.apply_button.clicked.connect(self.on_apply) self.delete_button.clicked.connect(self.on_delete) self.veldata_filevelx_browse.clicked.connect(self.on_browse) self.setLayout(self.main_layout) self.fill_data() self.exec_()
def __init__(self, link_coulombdamping_id, bodies_widgets, parent=None): super().__init__(parent=parent) self.case = Case.the() self.link_coulombdamping_id = link_coulombdamping_id # Title self.setWindowTitle(__("Link coulombdamping configuration")) self.link_coulombdamping_edit_layout = QtGui.QVBoxLayout() # Find the link coulombdamping for which the button was pressed target_link_coulombdamping = None for link_coulombdamping in self.case.chrono.link_coulombdamping: if link_coulombdamping.id == self.link_coulombdamping_id: target_link_coulombdamping = link_coulombdamping # This should not happen but if no link coulombdamping is found with reference id, it spawns an error. if target_link_coulombdamping is None: error_dialog( "There was an error opnening the link coulombdamping to edit") return # Elements that interact self.body_layout = QtGui.QHBoxLayout() self.body_one_label = QtGui.QLabel(__("Body 1: ")) self.body_one_line_edit = QtGui.QComboBox() self.body_one_line_edit.insertItems( 0, [str(target_link_coulombdamping.idbody1)]) for body in bodies_widgets: if body.object_check.isChecked() and body.object_name != str( target_link_coulombdamping.idbody1): self.body_one_line_edit.insertItems(0, [body.object_name]) self.body_two_label = QtGui.QLabel(__("Body 2: ")) self.body_two_line_edit = QtGui.QComboBox() self.body_two_line_edit.insertItems( 0, [str(target_link_coulombdamping.idbody2)]) for body in bodies_widgets: if body.object_check.isChecked() and body.object_name != str( target_link_coulombdamping.idbody2): self.body_two_line_edit.insertItems(0, [body.object_name]) self.body_to_body_label = QtGui.QLabel(__("to")) self.body_layout.addWidget(self.body_one_label) self.body_layout.addWidget(self.body_one_line_edit) self.body_layout.addWidget(self.body_to_body_label) self.body_layout.addWidget(self.body_two_label) self.body_layout.addWidget(self.body_two_line_edit) self.body_layout.addStretch(1) self.link_coulombdamping_edit_layout.addLayout(self.body_layout) # Points where the elements interact in body 1 self.points_b1_layout = QtGui.QHBoxLayout() self.points_b1_label = QtGui.QLabel(__("Points in body 1: ")) self.point_b1_x_label = QtGui.QLabel(__("X")) self.point_b1_x_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.point_fb1[0])) self.point_b1_y_label = QtGui.QLabel(__("Y")) self.point_b1_y_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.point_fb1[1])) self.point_b1_z_label = QtGui.QLabel(__("Z")) self.point_b1_z_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.point_fb1[2])) self.points_b1_layout.addWidget(self.points_b1_label) self.points_b1_layout.addWidget(self.point_b1_x_label) self.points_b1_layout.addWidget(self.point_b1_x_line_edit) self.points_b1_layout.addWidget(self.point_b1_y_label) self.points_b1_layout.addWidget(self.point_b1_y_line_edit) self.points_b1_layout.addWidget(self.point_b1_z_label) self.points_b1_layout.addWidget(self.point_b1_z_line_edit) self.link_coulombdamping_edit_layout.addLayout(self.points_b1_layout) # Points where the elements interact in body 2 self.points_b2_layout = QtGui.QHBoxLayout() self.points_b2_label = QtGui.QLabel(__("Points in body 2: ")) self.point_b2_x_label = QtGui.QLabel(__("X")) self.point_b2_x_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.point_fb2[0])) self.point_b2_y_label = QtGui.QLabel(__("Y")) self.point_b2_y_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.point_fb2[1])) self.point_b2_z_label = QtGui.QLabel(__("Z")) self.point_b2_z_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.point_fb2[2])) self.points_b2_layout.addWidget(self.points_b2_label) self.points_b2_layout.addWidget(self.point_b2_x_label) self.points_b2_layout.addWidget(self.point_b2_x_line_edit) self.points_b2_layout.addWidget(self.point_b2_y_label) self.points_b2_layout.addWidget(self.point_b2_y_line_edit) self.points_b2_layout.addWidget(self.point_b2_z_label) self.points_b2_layout.addWidget(self.point_b2_z_line_edit) self.link_coulombdamping_edit_layout.addLayout(self.points_b2_layout) # Torsion options self.rest_length_layout = QtGui.QHBoxLayout() self.damping_layout = QtGui.QHBoxLayout() self.rest_length_label = QtGui.QLabel(__("Rest length (m):")) self.rest_length_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.rest_length)) self.damping_label = QtGui.QLabel(__("Damping (N):")) self.damping_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.damping)) self.rest_length_layout.addWidget(self.rest_length_label) self.rest_length_layout.addWidget(self.rest_length_line_edit) self.damping_layout.addWidget(self.damping_label) self.damping_layout.addWidget(self.damping_line_edit) self.link_coulombdamping_edit_layout.addLayout(self.rest_length_layout) self.link_coulombdamping_edit_layout.addLayout(self.damping_layout) # vtk self.visualization_options_groupbox = QtGui.QGroupBox( __("Visualization Options")) self.vtk_layout = QtGui.QHBoxLayout() self.vtk_nside_label = QtGui.QLabel(__("Number of sections: ")) self.vtk_nside_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.nside)) self.vtk_radius_label = QtGui.QLabel(__("Spring radius: ")) self.vtk_radius_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.radius)) self.vtk_length_label = QtGui.QLabel(__("Length for revolution: ")) self.vtk_length_line_edit = QtGui.QLineEdit( str(target_link_coulombdamping.length)) self.vtk_layout.addWidget(self.vtk_nside_label) self.vtk_layout.addWidget(self.vtk_nside_line_edit) self.vtk_layout.addWidget(self.vtk_radius_label) self.vtk_layout.addWidget(self.vtk_radius_line_edit) self.vtk_layout.addWidget(self.vtk_length_label) self.vtk_layout.addWidget(self.vtk_length_line_edit) self.visualization_options_groupbox.setLayout(self.vtk_layout) self.link_coulombdamping_edit_layout.addWidget( self.visualization_options_groupbox) # Buttons self.ok_button = QtGui.QPushButton("Save") self.ok_button.clicked.connect(self.on_save) self.cancel_button = QtGui.QPushButton("Cancel") self.cancel_button.clicked.connect(self.on_cancel) self.button_layout = QtGui.QHBoxLayout() self.button_layout.addStretch(1) self.button_layout.addWidget(self.ok_button) self.button_layout.addWidget(self.cancel_button) self.link_coulombdamping_edit_layout.addLayout(self.button_layout) # Add the elements to the window self.setLayout(self.link_coulombdamping_edit_layout) self.exec_()
class HelpText: """ Help strings for different zones of the application GUIs. """ GRAVITYX = __("Gravitational acceleration in X direction.") GRAVITYY = __("Gravitational acceleration in Y direction.") GRAVITYZ = __("Gravitational acceleration in Z direction.") RHOP0 = __("Reference density of the fluid.") HSWL = __("Maximum still water level to calculate speedofsound as the celerity during dam-break propagation.") GAMMA = __("Polytropic constant for ocean water used in the state equation.") SPEEDSYSTEM = __("Maximum speed system (by default the celerity during dam-break propagation).") COEFSOUND = __("Coefficient to multiply speedsystem") SPEEDSOUND = __("Speed of sound (by default speedofsound=coefsound*speedsystem). ") COEFH = __("Coefficient to calculate the smoothing length (h=coefh*sqrt(3*dp^2) in 3D).") CFLNUMBER = __("Coefficient to multiply variable dt.") XMIN = __("The domain is fixed in the specified limit (default=not applied)") XMAX = __("The domain is fixed in the specified limit (default=not applied)") YMIN = __("The domain is fixed in the specified limit (default=not applied)") YMAX = __("The domain is fixed in the specified limit (default=not applied)") ZMIN = __("The domain is fixed in the specified limit (default=not applied)") ZMAX = __("The domain is fixed in the specified limit (default=not applied)") SAVEPOSDOUBLE = __("Saves particle position using double precision (default=0).") POSDOUBLE = __("Precision in particle interaction 0:Simple, 1:Double, 2:Uses and saves double (default=0).") STEPALGORITHM = __("Time-integrator algorithm 1:Verlet, 2:Symplectic (default=1).") VERLETSTEPS = __("Verlet only: Number of steps to apply Euler timestepping (default=40).") KERNEL = __("Interaction Kernel 1:Cubic Spline, 2:Wendland, 3:Gaussian (default=2)") VISCOTREATMENT = __("Viscosity formulation 1:Artificial, 2:Laminar+SPS (default=1)") VISCO = __("Viscosity value (apha when VISCOTREATMENT=1 and kinematic viscosity when VISCOTREATMENT=2).") VISCOBOUNDFACTOR = __("Multiply viscosity value for fluid-boundary interaction (default=1).") DELTASPH = __("DeltaSPH value, 0.1 is the typical value, with 0 disabled (default=0).") DENSITYDT = __("DDT value (default=0.1).") SHIFTING = __("Shifting mode 0:None, 1:Ignore bound, 2:Ignore fixed, 3:Full (default=0).") SHIFTINGCOEF = __("Coefficient for shifting computation (default=-2).") SHIFTINGTFS = __("Threshold to detect free surface. Typically 1.5 for 2D and 2.75 for 3D (default=0).") RIGIDALGORITHM = __("Rigid Algorithm 1:SPH, 2:DEM, 3:Chrono (default=1).") FTPAUSE = __("Time to freeze the floating objects at beginning of simulation (default=0).") DTINI = __("Initial time step (default=h/speedsound).") DTMIN = __("Minimum time step (default=coefdtmin*h/speedsound).") COEFDTMIN = __("Coefficient to calculate minimum time step dtmin=coefdtmin*h/speedsound (default=0.05).") TIMEMAX = __("Time of simulation.") TIMEOUT = __("Time to save output data.") INCZ = __("Increase of Z+ (%) (default=0).") PARTSOUTMAX = __("%%/100 of fluid particles allowed to be excluded from domain (default=1).") RHOPOUTMIN = __("Minimum rhop valid (default=700).") RHOPOUTMAX = __("Maximum rhop valid (default=1300).") DOMAINFIXED = __("The domain is fixed with the specified values (xmin:ymin:zmin:xmax:ymax:zmax).") YINCREMENTX = __("") ZINCREMENTX = __("") XINCREMENTY = __("") ZINCREMENTY = __("") XINCREMENTZ = __("") YINCREMENTZ = __("") POSMINX = __("") POSMINY = __("") POSMINZ = __("") POSMAXX = __("") POSMAXY = __("") POSMAXZ = __("")
def __init__(self, inlet_object_id, parent=None): super().__init__(parent=parent) # Find the zone for which button was pressed self.target_io_zone: InletOutletZone = Case.the( ).inlet_outlet.get_io_zone_for_id(inlet_object_id) # Creates a dialog self.setWindowTitle("Inlet/Outlet object edit") self.main_layout = QtGui.QVBoxLayout() # Add Layers option self.layers_layout = QtGui.QHBoxLayout() self.layers_option = QtGui.QLabel(__("Layers: ")) self.layers_line_edit = QtGui.QLineEdit(str( self.target_io_zone.layers)) self.layers_layout.addWidget(self.layers_option) self.layers_layout.addWidget(self.layers_line_edit) # Add refilling option selector self.refilling_layout = QtGui.QHBoxLayout() self.refilling_label = QtGui.QLabel(__("Refilling mode:")) self.refilling_selector = QtGui.QComboBox() self.refilling_selector.insertItems(0, [ __("Simple full"), __("Simple below Z Surface"), __("Advanced for reverse flows") ]) self.refilling_selector.setCurrentIndex(self.target_io_zone.refilling) self.refilling_layout.addWidget(self.refilling_label) self.refilling_layout.addWidget(self.refilling_selector) # Add inputtreatment option selector self.inputtreatment_layout = QtGui.QHBoxLayout() self.inputtreatment_label = QtGui.QLabel(__("Input Treatment mode:")) self.inputtreatment_selector = QtGui.QComboBox() self.inputtreatment_selector.insertItems( 0, [__("No changes"), __("Convert Fluid"), __("Remove fluid")]) self.inputtreatment_selector.setCurrentIndex( self.target_io_zone.inputtreatment) self.inputtreatment_layout.addWidget(self.inputtreatment_label) self.inputtreatment_layout.addWidget(self.inputtreatment_selector) # Add Zone 2d or 3d self.zone2d3d_main_layout = QtGui.QGroupBox("Zone 2D/3D") self.zone2d3d_layout = QtGui.QVBoxLayout() self.zone2d3d_zones_layout = QtGui.QHBoxLayout() self.zone2d3d_mk_layout = QtGui.QHBoxLayout() self.zone2d3d_combobox_layout = QtGui.QHBoxLayout() self.zone2d_option = QtGui.QCheckBox("Zone 2D") self.zone3d_option = QtGui.QCheckBox("Zone 3D") self.zone2d3d_mk_label = QtGui.QLabel("MK fluid: ") self.zone2d3d_mk_line_edit = QtGui.QLineEdit( str(self.target_io_zone.zone_info.mkfluid)) self.zone2d3d_mk_line_edit.setEnabled(False) self.zone2d3d_combobox_label = QtGui.QLabel(__("Direction: ")) self.zone2d3d_combobox = QtGui.QComboBox() self.zone2d3d_combobox.setEnabled(False) self.zone2d3d_combobox.insertItems(0, [ __("Left"), __("Right"), __("Front"), __("Back"), __("Top"), __("Bottom") ]) self.zone2d_option.toggled.connect(self.on_zone_check) self.zone3d_option.toggled.connect(self.on_zone_check) if self.target_io_zone.zone_info.zone_type == "zone2d": self.zone2d_option.setCheckState(QtCore.Qt.Checked) else: self.zone3d_option.setCheckState(QtCore.Qt.Checked) index_to_put = 0 for index, direction in self.DIRECTION_MAPPING.items(): if direction == self.target_io_zone.zone_info.direction: index_to_put = index self.zone2d3d_combobox.setCurrentIndex(index_to_put) self.zone2d3d_zones_layout.addWidget(self.zone2d_option) self.zone2d3d_zones_layout.addWidget(self.zone3d_option) self.zone2d3d_zones_layout.addStretch(1) self.zone2d3d_mk_layout.addWidget(self.zone2d3d_mk_label) self.zone2d3d_mk_layout.addWidget(self.zone2d3d_mk_line_edit) self.zone2d3d_combobox_layout.addWidget(self.zone2d3d_combobox_label) self.zone2d3d_combobox_layout.addWidget(self.zone2d3d_combobox) self.zone2d3d_combobox_layout.addStretch(1) self.zone2d3d_layout.addLayout(self.zone2d3d_zones_layout) self.zone2d3d_layout.addLayout(self.zone2d3d_mk_layout) self.zone2d3d_layout.addLayout(self.zone2d3d_combobox_layout) self.zone2d3d_main_layout.setLayout(self.zone2d3d_layout) # Add Imposed velocity option self.imposevelocity_layout = QtGui.QGroupBox("Velocity") self.imposevelocity_options_layout = QtGui.QVBoxLayout() self.imposevelocity_velocity_layout = QtGui.QHBoxLayout() self.imposevelocity_value_layout = QtGui.QHBoxLayout() self.imposevelocity_combobox_label = QtGui.QLabel(__("Velocity: ")) self.imposevelocity_combobox = QtGui.QComboBox() self.imposevelocity_combobox.insertItems(0, [ __("Fixed"), __("Variable"), __("Extrapolated"), __("Interpolated") ]) self.imposevelocity_velocity_label = QtGui.QLabel("Value: ") self.imposevelocity_velocity_line_edit = QtGui.QLineEdit( str(self.target_io_zone.velocity_info.value)) self.imposevelocity_velocity_units = QtGui.QLabel(__("m/s")) self.imposevelocity_combobox.currentIndexChanged.connect( self.on_imposevelocity_change) self.imposevelocity_combobox.setCurrentIndex( self.target_io_zone.velocity_info.velocity_type) self.imposevelocity_velocity_layout.addWidget( self.imposevelocity_combobox_label) self.imposevelocity_velocity_layout.addWidget( self.imposevelocity_combobox) self.imposevelocity_velocity_layout.addStretch(1) self.imposevelocity_value_layout.addWidget( self.imposevelocity_velocity_label) self.imposevelocity_value_layout.addWidget( self.imposevelocity_velocity_line_edit) self.imposevelocity_value_layout.addWidget( self.imposevelocity_velocity_units) self.imposevelocity_options_layout.addLayout( self.imposevelocity_velocity_layout) self.imposevelocity_options_layout.addLayout( self.imposevelocity_value_layout) self.imposevelocity_layout.setLayout( self.imposevelocity_options_layout) # Add Inlet density option self.density_groupbox = QtGui.QGroupBox("Density") self.density_options_layout = QtGui.QVBoxLayout() self.imposerhop_layout = QtGui.QHBoxLayout() self.imposerhop_label = QtGui.QLabel(__("Density mode:")) self.imposerhop_selector = QtGui.QComboBox() self.imposerhop_selector.insertItems(0, [ __("Fixed value"), __("Hydrostatic"), __("Extrapolated from ghost nodes") ]) self.imposerhop_selector.setCurrentIndex( self.target_io_zone.density_info.density_type) self.imposerhop_layout.addWidget(self.imposerhop_label) self.imposerhop_layout.addWidget(self.imposerhop_selector) self.density_options_layout.addLayout(self.imposerhop_layout) self.density_groupbox.setLayout(self.density_options_layout) # Add Inlet Z-surface option self.imposezsurf_layout = QtGui.QGroupBox("Elevation") self.imposezsurf_options_layout = QtGui.QVBoxLayout() self.imposezsurf_combobox_layout = QtGui.QHBoxLayout() self.imposezsurf_fixed_layout = QtGui.QHBoxLayout() self.imposezsurf_combobox_label = QtGui.QLabel("Elevation: ") self.imposezsurf_combobox = QtGui.QComboBox() self.imposezsurf_combobox.insertItems( 0, [__("Fixed"), __("Variable"), __("Automatic")]) self.imposezsurf_fixed_zbottom_label = QtGui.QLabel("Zbottom: ") self.imposezsurf_fixed_zbottom = QtGui.QLineEdit( str(self.target_io_zone.elevation_info.zbottom)) self.imposezsurf_fixed_zbottom_units = QtGui.QLabel("m") self.imposezsurf_fixed_zsurf_label = QtGui.QLabel("Zsurf: ") self.imposezsurf_fixed_zsurf = QtGui.QLineEdit( str(self.target_io_zone.elevation_info.zsurf)) self.imposezsurf_fixed_zsurf_units = QtGui.QLabel("m") self.imposezsurf_fixed_zbottom.setEnabled(True) self.imposezsurf_fixed_zsurf.setEnabled(True) self.imposezsurf_combobox.currentIndexChanged.connect( self.on_imposezsurf_change) self.imposezsurf_combobox.setCurrentIndex( self.target_io_zone.elevation_info.elevation_type) self.imposezsurf_combobox_layout.addWidget( self.imposezsurf_combobox_label) self.imposezsurf_combobox_layout.addWidget(self.imposezsurf_combobox) self.imposezsurf_combobox_layout.addStretch(1) self.imposezsurf_fixed_layout.addWidget( self.imposezsurf_fixed_zbottom_label) self.imposezsurf_fixed_layout.addWidget(self.imposezsurf_fixed_zbottom) self.imposezsurf_fixed_layout.addWidget( self.imposezsurf_fixed_zbottom_units) self.imposezsurf_fixed_layout.addStretch(1) self.imposezsurf_fixed_layout.addWidget( self.imposezsurf_fixed_zsurf_label) self.imposezsurf_fixed_layout.addWidget(self.imposezsurf_fixed_zsurf) self.imposezsurf_fixed_layout.addWidget( self.imposezsurf_fixed_zsurf_units) self.imposezsurf_options_layout.addLayout( self.imposezsurf_combobox_layout) self.imposezsurf_options_layout.addLayout( self.imposezsurf_fixed_layout) self.imposezsurf_layout.setLayout(self.imposezsurf_options_layout) # Creates 2 main buttons self.ok_button = QtGui.QPushButton("Save") self.cancel_button = QtGui.QPushButton("Cancel") self.button_layout = QtGui.QHBoxLayout() self.button_layout.addStretch(1) self.ok_button.clicked.connect(self.on_ok) self.cancel_button.clicked.connect(self.on_cancel) self.button_layout.addWidget(self.ok_button) self.button_layout.addWidget(self.cancel_button) self.main_layout.addLayout(self.layers_layout) self.main_layout.addLayout(self.refilling_layout) self.main_layout.addLayout(self.inputtreatment_layout) self.main_layout.addWidget(self.zone2d3d_main_layout) self.main_layout.addWidget(self.imposevelocity_layout) self.main_layout.addWidget(self.density_groupbox) self.main_layout.addWidget(self.imposezsurf_layout) self.main_layout.addLayout(self.button_layout) self.setLayout(self.main_layout) self.exec_()
if not exit_code: info_dialog(info_text=__("ComputeForces finished successfully"), detailed_text=detailed_text) if case.custom.cfces_plot: ComputeForcesPlotDialog( parent=post_processing_widget, paths=[ "{out_path}{file_name}.csv".format( out_path=case.get_out_folder_path(), file_name=options["filename"]), case.custom.cfces_csv_path ]) else: error_dialog(__( "There was an error on the post-processing. Show details to view the errors." ), detailed_text=detailed_text) export_dialog.on_cancel.connect(on_cancel) export_process = QtCore.QProcess(get_fc_main_window()) export_process.finished.connect(on_export_finished) export_process.readyReadStandardOutput.connect(on_stdout_ready) ensure_process_is_executable_or_fail(case.executable_paths.computeforces) export_process.start(case.executable_paths.computeforces, executable_parameters) def measuretool_export(options, case, post_processing_widget) -> None: """ MeasureTool tool export. """ post_processing_widget.adapt_to_export_start()
def __init__(self, line, stored_configuration): super().__init__() self.line: MoorDynLine = line self.stored_configuration = stored_configuration self.setWindowTitle(__("MoorDyn Line Configuration")) self.setMinimumWidth(440) self.root_layout: QtGui.QVBoxLayout = QtGui.QVBoxLayout() # Label self.reference_label: QtGui.QLabel = QtGui.QLabel( __("Editing settings for line: <b>{}</b>").format(line.line_id)) # Basic configuration group self.basic_configuration_groupbox: QtGui.QGroupBox = QtGui.QGroupBox( __("Basic configuration")) self.basic_configuration_groupbox_layout: QtGui.QFormLayout = QtGui.QFormLayout( ) self.connection_type_combobox: QtGui.QComboBox = QtGui.QComboBox() self.connection_type_combobox.addItems( ["Vessel to Fix connection", "Vessel to Vessel connection"]) self.vessel_connection_label: QtGui.QLabel = QtGui.QLabel( __("Vessel Connection: ")) self.vessel_connection_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.vessel_connection_body_combo: QtGui.QComboBox = QtGui.QComboBox() self.vessel_connection_point_label: QtGui.QLabel = QtGui.QLabel( __("Point (X, Y, Z):")) self.vessel_connection_point_x: QtGui.QLineEdit = QtGui.QLineEdit() self.vessel_connection_point_y: QtGui.QLineEdit = QtGui.QLineEdit() self.vessel_connection_point_z: QtGui.QLineEdit = QtGui.QLineEdit() self.vessel_connection_layout.addWidget( self.vessel_connection_body_combo) self.vessel_connection_layout.addWidget( self.vessel_connection_point_label) self.vessel_connection_layout.addWidget(self.vessel_connection_point_x) self.vessel_connection_layout.addWidget(self.vessel_connection_point_y) self.vessel_connection_layout.addWidget(self.vessel_connection_point_z) self.vessel2_connection_label: QtGui.QLabel = QtGui.QLabel( __("Vessel Connection (2nd): ")) self.vessel2_connection_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.vessel2_connection_body_combo: QtGui.QComboBox = QtGui.QComboBox() self.vessel2_connection_point_label: QtGui.QLabel = QtGui.QLabel( __("Point (X, Y, Z):")) self.vessel2_connection_point_x: QtGui.QLineEdit = QtGui.QLineEdit() self.vessel2_connection_point_y: QtGui.QLineEdit = QtGui.QLineEdit() self.vessel2_connection_point_z: QtGui.QLineEdit = QtGui.QLineEdit() self.vessel2_connection_layout.addWidget( self.vessel2_connection_body_combo) self.vessel2_connection_layout.addWidget( self.vessel2_connection_point_label) self.vessel2_connection_layout.addWidget( self.vessel2_connection_point_x) self.vessel2_connection_layout.addWidget( self.vessel2_connection_point_y) self.vessel2_connection_layout.addWidget( self.vessel2_connection_point_z) self.fix_connection_label: QtGui.QLabel = QtGui.QLabel( __("Fix Connection (X, Y, Z): ")) self.fix_connection_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.fix_connection_point_x: QtGui.QLineEdit = QtGui.QLineEdit() self.fix_connection_point_y: QtGui.QLineEdit = QtGui.QLineEdit() self.fix_connection_point_z: QtGui.QLineEdit = QtGui.QLineEdit() self.fix_connection_layout.addWidget(self.fix_connection_point_x) self.fix_connection_layout.addWidget(self.fix_connection_point_y) self.fix_connection_layout.addWidget(self.fix_connection_point_z) self.length_input: QtGui.QLineEdit = QtGui.QLineEdit() self.segments_input: QtGui.QLineEdit = QtGui.QLineEdit() self.basic_configuration_groupbox_layout.addRow( __("Type of connection: "), self.connection_type_combobox) self.basic_configuration_groupbox_layout.addRow( self.vessel_connection_label, self.vessel_connection_layout) self.basic_configuration_groupbox_layout.addRow( self.vessel2_connection_label, self.vessel2_connection_layout) self.basic_configuration_groupbox_layout.addRow( self.fix_connection_label, self.fix_connection_layout) self.basic_configuration_groupbox_layout.addRow(h_line_generator()) self.basic_configuration_groupbox_layout.addRow( __("Line Length (m):"), self.length_input) self.basic_configuration_groupbox_layout.addRow( __("Number of Segments:"), self.segments_input) self.basic_configuration_groupbox.setLayout( self.basic_configuration_groupbox_layout) # Override configuration group self.override_configuration_groupbox: QtGui.QGroupBox = QtGui.QGroupBox( __("Configuration Overrides")) self.override_configuration_groupbox_layout: QtGui.QFormLayout = QtGui.QFormLayout( ) self.ea_input: QtGui.QLineEdit = QtGui.QLineEdit() self.ea_input_check: QtGui.QCheckBox = QtGui.QCheckBox() self.ea_input_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.ea_input_layout.addWidget(self.ea_input) self.ea_input_layout.addWidget(self.ea_input_check) self.diameter_input: QtGui.QLineEdit = QtGui.QLineEdit() self.diameter_input_check: QtGui.QCheckBox = QtGui.QCheckBox() self.diameter_input_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.diameter_input_layout.addWidget(self.diameter_input) self.diameter_input_layout.addWidget(self.diameter_input_check) self.massDenInAir_input: QtGui.QLineEdit = QtGui.QLineEdit() self.massDenInAir_input_check: QtGui.QCheckBox = QtGui.QCheckBox() self.massDenInAir_input_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.massDenInAir_input_layout.addWidget(self.massDenInAir_input) self.massDenInAir_input_layout.addWidget(self.massDenInAir_input_check) self.ba_input: QtGui.QLineEdit = QtGui.QLineEdit() self.ba_input_check: QtGui.QCheckBox = QtGui.QCheckBox() self.ba_input_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.ba_input_layout.addWidget(self.ba_input) self.ba_input_layout.addWidget(self.ba_input_check) self.override_configuration_groupbox_layout.addRow( __("Stiffness (N):"), self.ea_input_layout) self.override_configuration_groupbox_layout.addRow( __("Diameter (m):"), self.diameter_input_layout) self.override_configuration_groupbox_layout.addRow( __("Mass in Air (kg/m):"), self.massDenInAir_input_layout) self.override_configuration_groupbox_layout.addRow( __("Line internal damping (Ns):"), self.ba_input_layout) self.override_configuration_groupbox.setLayout( self.override_configuration_groupbox_layout) # Bottom button row self.button_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.ok_button: QtGui.QPushButton = QtGui.QPushButton(__("OK")) self.button_layout.addStretch(1) self.button_layout.addWidget(self.ok_button) # Main layout composition self.root_layout.addWidget(self.reference_label) self.root_layout.addWidget(h_line_generator()) self.root_layout.addWidget(self.basic_configuration_groupbox) # self.root_layout.addWidget(self.override_configuration_groupbox) self.root_layout.addStretch(1) self.root_layout.addLayout(self.button_layout) self.setLayout(self.root_layout) # Connections self.ok_button.clicked.connect(self._on_ok) self.ea_input_check.stateChanged.connect(self._on_ea_check) self.diameter_input_check.stateChanged.connect(self._on_diameter_check) self.massDenInAir_input_check.stateChanged.connect( self._on_massDenInAir_check) self.ba_input_check.stateChanged.connect(self._on_ba_check) self.connection_type_combobox.currentIndexChanged.connect( self._on_type_of_connection_change) self._fill_data() self._on_type_of_connection_change( self.connection_type_combobox.currentIndex()) self.exec_()
def __init__(self, index, acc_rect_motion, parent=None): if not isinstance(acc_rect_motion, AccRectMotion): raise TypeError( "You tried to spawn an accelerated rectilinear " "motion widget in the timeline with a wrong object") if acc_rect_motion is None: raise TypeError( "You tried to spawn an accelerated rectilinear " "motion widget in the timeline without a motion object") super().__init__(parent=parent) self.index = index self.setMinimumHeight(50) self.main_layout = QtGui.QHBoxLayout() self.main_layout.setContentsMargins(10, 0, 10, 0) self.label = QtGui.QLabel("Accelerated \nRectilinear \nMotion ") self.label.setMinimumWidth(75) self.data_layout = QtGui.QVBoxLayout() self.data_layout.setContentsMargins(0, 0, 0, 0) self.data_velocity_layout = QtGui.QHBoxLayout() self.data_velocity_layout.setContentsMargins(0, 0, 0, 0) self.data_acceleration_layout = QtGui.QHBoxLayout() self.data_acceleration_layout.setContentsMargins(0, 0, 0, 0) self.velocity_label = QtGui.QLabel("Vel (X, Y, Z): ") self.x_input = QtGui.QLineEdit() self.x_input.setStyleSheet("width: 5px;") self.y_input = QtGui.QLineEdit() self.y_input.setStyleSheet("width: 5px;") self.z_input = QtGui.QLineEdit() self.z_input.setStyleSheet("width: 5px;") self.acceleration_label = QtGui.QLabel("Acc (X, Y, Z): ") self.xa_input = QtGui.QLineEdit() self.xa_input.setStyleSheet("width: 5px;") self.ya_input = QtGui.QLineEdit() self.ya_input.setStyleSheet("width: 5px;") self.za_input = QtGui.QLineEdit() self.za_input.setStyleSheet("width: 5px;") self.data_velocity_layout.addWidget(self.velocity_label) self.data_velocity_layout.addWidget(self.x_input) self.data_velocity_layout.addWidget(self.y_input) self.data_velocity_layout.addWidget(self.z_input) self.data_acceleration_layout.addWidget(self.acceleration_label) self.data_acceleration_layout.addWidget(self.xa_input) self.data_acceleration_layout.addWidget(self.ya_input) self.data_acceleration_layout.addWidget(self.za_input) self.data_layout.addLayout(self.data_velocity_layout) self.data_layout.addLayout(self.data_acceleration_layout) self.time_label = QtGui.QLabel(__("Duration (s): ")) self.time_input = QtGui.QLineEdit() self.time_input.setStyleSheet("width: 5px;") self.delete_button = QtGui.QPushButton(get_icon("trash.png"), None) self.order_button_layout = QtGui.QVBoxLayout() self.order_button_layout.setContentsMargins(0, 0, 0, 0) self.order_button_layout.setSpacing(0) self.order_up_button = QtGui.QPushButton(get_icon("up_arrow.png"), None) self.order_down_button = QtGui.QPushButton(get_icon("down_arrow.png"), None) self.order_button_layout.addWidget(self.order_up_button) self.order_button_layout.addWidget(self.order_down_button) self.main_layout.addWidget(self.label) self.main_layout.addLayout(self.data_layout) self.main_layout.addStretch(1) self.main_layout.addWidget(self.time_label) self.main_layout.addWidget(self.time_input) self.main_layout.addWidget(self.delete_button) self.main_layout.addLayout(self.order_button_layout) self.setLayout(self.main_layout) self.fill_values(acc_rect_motion) self._init_connections()
def __init__(self, case_name: str, processor: str, number_of_particles: int, cmd_string="", parent=None): super().__init__(parent=parent) self.run_watcher = QtCore.QFileSystemWatcher() self.cmd_string = cmd_string # Title and size self.setModal(False) self.setWindowTitle(__("DualSPHysics Simulation: {}%").format("0")) self.run_dialog_layout = QtGui.QVBoxLayout() # Information GroupBox self.run_group = QtGui.QGroupBox(__("Simulation Data")) self.run_group_layout = QtGui.QVBoxLayout() self.run_group_label_case = QtGui.QLabel( __("Case name: {}").format(case_name)) self.run_group_label_proc = QtGui.QLabel( __("Simulation processor: {}").format(processor)) self.run_group_label_part = QtGui.QLabel( __("Number of particles: {}").format(number_of_particles)) self.run_group_label_partsout = QtGui.QLabel( self.PARTICLES_OUT_TEMPLATE.format(0)) self.run_group_label_eta = QtGui.QLabel(self) self.run_group_label_eta.setText( self.ETA_TEMPLATE.format("Calculating...")) self.run_group_label_completed = QtGui.QLabel("<b>{}</b>".format( __("Simulation is complete."))) self.run_group_label_completed.setVisible(False) self.run_group_layout.addWidget(self.run_group_label_case) self.run_group_layout.addWidget(self.run_group_label_proc) self.run_group_layout.addWidget(self.run_group_label_part) self.run_group_layout.addWidget(self.run_group_label_partsout) self.run_group_layout.addWidget(self.run_group_label_eta) self.run_group_layout.addWidget(self.run_group_label_completed) self.run_group_layout.addStretch(1) self.run_group.setLayout(self.run_group_layout) # Progress Bar self.run_progbar_layout = QtGui.QHBoxLayout() self.run_progbar_bar = QtGui.QProgressBar() self.run_progbar_bar.setRange(0, 100) self.run_progbar_bar.setTextVisible(False) self.run_progbar_layout.addWidget(self.run_progbar_bar) # Buttons self.run_button_layout = QtGui.QHBoxLayout() self.run_button_warnings = QtGui.QPushButton(__("Show Warnings")) self.run_button_warnings.hide() self.run_button_details = QtGui.QPushButton(__("Details")) self.run_button_cancel = QtGui.QPushButton(__("Cancel Simulation")) self.run_button_layout.addWidget(self.run_button_warnings) self.run_button_layout.addStretch(1) self.run_button_layout.addWidget(self.run_button_details) self.run_button_layout.addWidget(self.run_button_cancel) # Defines run details self.run_details = QtGui.QWidget() self.run_details.setWindowTitle(__("Simulation details")) self.run_details_layout = QtGui.QVBoxLayout() self.run_details_layout.setContentsMargins(0, 0, 0, 0) self.run_details_text = QtGui.QTextEdit() self.run_details_text.setReadOnly(True) self.run_details_layout.addWidget(h_line_generator()) self.run_details_layout.addWidget(self.run_details_text) self.run_details.hide() self.run_button_cancel.clicked.connect(self.cancelled.emit) self.run_button_details.clicked.connect(self.toggle_run_details) self.run_details.setLayout(self.run_details_layout) self.run_dialog_layout.addWidget(self.run_group) self.run_dialog_layout.addLayout(self.run_progbar_layout) self.run_dialog_layout.addLayout(self.run_button_layout) self.run_dialog_layout.addWidget(self.run_details) self.setLayout(self.run_dialog_layout) self.setMinimumWidth(self.MIN_WIDTH) self.adjustSize()
def __init__(self, parent=None): super().__init__(parent=parent) # Reference to the inlet outlet configuration on the case data self.inlet_outlet: InletOutletConfig = Case.the().inlet_outlet # TODO: Redo this dialog with new inlet options # Creates a dialog self.setWindowTitle("Inlet/Outlet configuration") self.setModal(False) self.setMinimumWidth(800) self.setMinimumHeight(600) self.main_layout = QtGui.QVBoxLayout() # Creates layout for content first options self.io_options_layout = QtGui.QHBoxLayout() # Creates reuseids option self.reuseids_layout = QtGui.QHBoxLayout() self.reuseids_option = QtGui.QLabel(__("Reuseids: ")) self.reuseids_combobox = QtGui.QComboBox() self.reuseids_combobox.insertItems(0, [__("False"), __("True")]) self.reuseids_combobox.setCurrentIndex( 1 if self.inlet_outlet.reuseids else 0) self.reuseids_layout.addWidget(self.reuseids_option) self.reuseids_layout.addWidget(self.reuseids_combobox) # Creates resizetime option self.resizetime_layout = QtGui.QHBoxLayout() self.resizetime_option = QtGui.QLabel(__("Resizetime: ")) self.resizetime_line_edit = QtGui.QLineEdit( str(self.inlet_outlet.resizetime)) self.resizetime_layout.addWidget(self.resizetime_option) self.resizetime_layout.addWidget(self.resizetime_line_edit) # Creates use refilling option self.refilling_layout = QtGui.QHBoxLayout() self.refilling_option = QtGui.QLabel(__("Refilling: ")) self.refilling_combobox = QtGui.QComboBox() self.refilling_combobox.insertItems(0, [__("False"), __("True")]) self.refilling_combobox.setCurrentIndex( 1 if self.inlet_outlet.userefilling else 0) self.refilling_layout.addWidget(self.refilling_option) self.refilling_layout.addWidget(self.refilling_combobox) # Creates use determlimit option self.determlimit_layout = QtGui.QHBoxLayout() self.determlimit_option = QtGui.QLabel(__("Determlimit: ")) self.determlimit_combobox = QtGui.QComboBox() self.determlimit_combobox.insertItems(0, [__("1e+3"), __("1e-3")]) self.determlimit_combobox.setCurrentIndex( 0 if self.inlet_outlet.determlimit == InletOutletDetermLimit.ZEROTH_ORDER else 1) self.determlimit_layout.addWidget(self.determlimit_option) self.determlimit_layout.addWidget(self.determlimit_combobox) # Creates 2 main buttons self.finish_button = QtGui.QPushButton("Finish") self.button_layout = QtGui.QHBoxLayout() self.finish_button.clicked.connect(self.on_finish) self.button_layout.addStretch(1) self.button_layout.addWidget(self.finish_button) # Create the list for zones self.zones_groupbox = QtGui.QGroupBox("Inlet/Outlet zones") self.zones_groupbox_layout = QtGui.QVBoxLayout() self.io_zones_list_layout = QtGui.QVBoxLayout() # Add button self.add_button_layout = QtGui.QHBoxLayout() self.add_zone_button = QtGui.QPushButton("Add Zone") self.add_button_layout.addStretch(1) self.add_button_layout.addWidget(self.add_zone_button) self.add_zone_button.clicked.connect(self.on_add_zone) self.zones_groupbox_layout.addLayout(self.add_button_layout) self.zones_groupbox_layout.addLayout(self.io_zones_list_layout) self.zones_groupbox.setLayout(self.zones_groupbox_layout) # Adds options to option layout # self.io_options_layout.addLayout(self.reuseids_layout) self.io_options_layout.addLayout(self.resizetime_layout) # self.io_options_layout.addLayout(self.refilling_layout) self.io_options_layout.addLayout(self.determlimit_layout) # Adds options to main self.main_layout.addLayout(self.io_options_layout) self.main_layout.addWidget(self.zones_groupbox) # Adds scroll area self.main_layout_dialog = QtGui.QVBoxLayout() self.main_layout_scroll = QtGui.QScrollArea() self.main_layout_scroll.setMinimumWidth(400) self.main_layout_scroll.setWidgetResizable(True) self.main_layout_scroll_widget = QtGui.QWidget() self.main_layout_scroll_widget.setMinimumWidth(400) self.main_layout_scroll_widget.setLayout(self.main_layout) self.main_layout_scroll.setWidget(self.main_layout_scroll_widget) self.main_layout_scroll.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.main_layout_dialog.addWidget(self.main_layout_scroll) self.main_layout_dialog.addLayout(self.button_layout) self.setLayout(self.main_layout_dialog) self.refresh_zones() self.finish_button.setFocus() self.exec_()
def __init__(self, parent=None): super().__init__(parent=parent) # Creates a dialog and 2 main buttons self.setWindowTitle(__("Execution Parameters")) self.help_label = QtGui.QLabel(self.LABEL_DEFAULT_TEXT) self.ok_button = QtGui.QPushButton(__("OK")) self.cancel_button = QtGui.QPushButton(__("Cancel")) self.saveposdouble_layout = QtGui.QHBoxLayout() self.saveposdouble_label = QtGui.QLabel( __("Save particle position with double precision:")) self.saveposdouble_input = FocusableComboBox() self.saveposdouble_input.insertItems(0, [__("No"), __("Yes")]) self.saveposdouble_input.setCurrentIndex( int(Case.the().execution_parameters.saveposdouble)) self.saveposdouble_input.set_help_text(HelpText.SAVEPOSDOUBLE) self.saveposdouble_input.focus.connect(self.on_help_focus) self.saveposdouble_layout.addWidget(self.saveposdouble_label) self.saveposdouble_layout.addWidget(self.saveposdouble_input) self.saveposdouble_layout.addStretch(1) self.boundary_layout = QtGui.QHBoxLayout() self.boundary_label = QtGui.QLabel(__("Boundary Method:")) self.boundary_input = FocusableComboBox() self.boundary_input.insertItems(0, [__("DBC"), __("mDBC")]) self.boundary_input.setCurrentIndex( int(Case.the().execution_parameters.boundary) - 1) self.boundary_input.set_help_text(HelpText.BOUNDARY) self.boundary_input.focus.connect(self.on_help_focus) self.boundary_layout.addWidget(self.boundary_label) self.boundary_layout.addWidget(self.boundary_input) self.boundary_layout.addStretch(1) self.stepalgorithm_layout = QtGui.QHBoxLayout() self.stepalgorithm_label = QtGui.QLabel(__("Step Algorithm:")) self.stepalgorithm_input = FocusableComboBox() self.stepalgorithm_input.insertItems( 0, [__("Verlet"), __("Symplectic")]) self.stepalgorithm_input.setCurrentIndex( int(Case.the().execution_parameters.stepalgorithm) - 1) self.stepalgorithm_input.set_help_text(HelpText.STEPALGORITHM) self.stepalgorithm_input.focus.connect(self.on_help_focus) self.stepalgorithm_input.currentIndexChanged.connect( self.on_step_change) self.stepalgorithm_layout.addWidget(self.stepalgorithm_label) self.stepalgorithm_layout.addWidget(self.stepalgorithm_input) self.stepalgorithm_layout.addStretch(1) # Verlet steps self.verletsteps_layout = QtGui.QHBoxLayout() self.verletsteps_label = QtGui.QLabel(__("Verlet Steps:")) self.verletsteps_input = QtGui.QLineEdit() self.verletsteps_input = FocusableLineEdit() self.verletsteps_input.set_help_text(HelpText.VERLETSTEPS) self.verletsteps_input.setMaxLength(4) self.verletsteps_input.focus.connect(self.on_help_focus) self.verletsteps_validator = QtGui.QIntValidator( 0, 9999, self.verletsteps_input) self.verletsteps_input.setText( str(Case.the().execution_parameters.verletsteps)) self.verletsteps_input.setValidator(self.verletsteps_validator) self.verletsteps_layout.addWidget(self.verletsteps_label) self.verletsteps_layout.addWidget(self.verletsteps_input) # Enable/Disable fields depending on selection self.on_step_change(self.stepalgorithm_input.currentIndex) # Kernel self.kernel_layout = QtGui.QHBoxLayout() self.kernel_label = QtGui.QLabel(__("Interaction kernel:")) self.kernel_input = FocusableComboBox() self.kernel_input.insertItems(0, [__("Cubic spline"), __("Wendland")]) self.kernel_input.set_help_text(HelpText.KERNEL) self.kernel_input.setCurrentIndex( int(Case.the().execution_parameters.kernel) - 1) self.kernel_input.focus.connect(self.on_help_focus) self.kernel_layout.addWidget(self.kernel_label) self.kernel_layout.addWidget(self.kernel_input) self.kernel_layout.addStretch(1) # Viscosity formulation self.viscotreatment_layout = QtGui.QHBoxLayout() self.viscotreatment_label = QtGui.QLabel(__("Viscosity Formulation:")) self.viscotreatment_input = FocusableComboBox() self.viscotreatment_input.insertItems( 0, [__("Artificial"), __("Laminar + SPS")]) self.viscotreatment_input.set_help_text(HelpText.VISCOTREATMENT) self.viscotreatment_input.setCurrentIndex( int(Case.the().execution_parameters.viscotreatment) - 1) self.viscotreatment_input.focus.connect(self.on_help_focus) self.viscotreatment_layout.addWidget(self.viscotreatment_label) self.viscotreatment_layout.addWidget(self.viscotreatment_input) self.viscotreatment_layout.addStretch(1) # Viscosity value self.visco_layout = QtGui.QHBoxLayout() self.visco_label = QtGui.QLabel(__("Viscosity value:")) self.visco_input = FocusableLineEdit() self.visco_input.set_help_text(HelpText.VISCO) self.visco_input.setMaxLength(10) self.visco_input.focus.connect(self.on_help_focus) self.visco_units_label = QtGui.QLabel(__("")) self.visco_layout.addWidget(self.visco_label) self.visco_layout.addWidget(self.visco_input) self.visco_layout.addWidget(self.visco_units_label) self.on_viscotreatment_change( int(Case.the().execution_parameters.viscotreatment) - 1) self.visco_input.setText(str(Case.the().execution_parameters.visco)) self.viscotreatment_input.currentIndexChanged.connect( self.on_viscotreatment_change) # Viscosity with boundary self.viscoboundfactor_layout = QtGui.QHBoxLayout() self.viscoboundfactor_label = QtGui.QLabel( __("Viscosity factor with boundary: ")) self.viscoboundfactor_input = FocusableLineEdit() self.viscoboundfactor_input.set_help_text(HelpText.VISCOBOUNDFACTOR) self.viscoboundfactor_input.setMaxLength(10) self.viscoboundfactor_input.focus.connect(self.on_help_focus) self.viscoboundfactor_input.setText( str(Case.the().execution_parameters.viscoboundfactor)) self.viscoboundfactor_layout.addWidget(self.viscoboundfactor_label) self.viscoboundfactor_layout.addWidget(self.viscoboundfactor_input) self.densitydt_type_layout = QtGui.QHBoxLayout() self.densitydt_type_label = QtGui.QLabel(__("Density Diffusion Term:")) self.densitydt_type_input = QtGui.QComboBox() densitydt_option_list = [ __('None'), __('Molteni'), __('Fourtakas'), __('Fourtakas (Full)') ] if Case.the().executable_paths.supports_ddt_fourtakas() else [ 'None', 'Molteni' ] self.densitydt_type_input.insertItems(0, densitydt_option_list) self.densitydt_type_input.setCurrentIndex( Case.the().execution_parameters.densitydt_type) self.densitydt_type_input.currentIndexChanged.connect( self.on_densitydt_type_change) self.densitydt_type_layout.addWidget(self.densitydt_type_label) self.densitydt_type_layout.addWidget(self.densitydt_type_input) self.densitydt_type_layout.addStretch(1) # densitydt value self.densitydt_layout = QtGui.QHBoxLayout() self.densitydt_label = QtGui.QLabel(__("DDT value:")) self.densitydt_input = FocusableLineEdit() self.densitydt_input.set_help_text(HelpText.DENSITYDT) self.densitydt_input.setMaxLength(10) self.densitydt_input.focus.connect(self.on_help_focus) self.densitydt_input.setText( str(Case.the().execution_parameters.densitydt_value)) self.densitydt_layout.addWidget(self.densitydt_label) self.densitydt_layout.addWidget(self.densitydt_input) if self.densitydt_type_input.currentIndex() == 0: self.densitydt_input.setEnabled(False) else: self.densitydt_input.setEnabled(True) self.shifting_layout = QtGui.QHBoxLayout() self.shifting_label = QtGui.QLabel(__("Shifting mode:")) self.shifting_input = FocusableComboBox() self.shifting_input.insertItems( 0, [__("None"), __("Ignore bound"), __("Ignore fixed"), __("Full")]) self.shifting_input.set_help_text(HelpText.SHIFTING) self.shifting_input.focus.connect(self.on_help_focus) self.shifting_input.setCurrentIndex( int(Case.the().execution_parameters.shifting)) self.shifting_input.currentIndexChanged.connect( self.on_shifting_change) self.shifting_layout.addWidget(self.shifting_label) self.shifting_layout.addWidget(self.shifting_input) self.shifting_layout.addStretch(1) # Coefficient for shifting self.shiftcoef_layout = QtGui.QHBoxLayout() self.shiftcoef_label = QtGui.QLabel(__("Coefficient for shifting:")) self.shiftcoef_input = FocusableLineEdit() self.shiftcoef_input.set_help_text(HelpText.SHIFTINGCOEF) self.shiftcoef_input.setMaxLength(10) self.shiftcoef_input.focus.connect(self.on_help_focus) self.shiftcoef_input.setText( str(Case.the().execution_parameters.shiftcoef)) self.shiftcoef_layout.addWidget(self.shiftcoef_label) self.shiftcoef_layout.addWidget(self.shiftcoef_input) # Free surface detection threshold self.shifttfs_layout = QtGui.QHBoxLayout() self.shifttfs_label = QtGui.QLabel( __("Free surface detection threshold:")) self.shifttfs_input = FocusableLineEdit() self.shifttfs_input.set_help_text(HelpText.SHIFTINGTFS) self.shifttfs_input.setMaxLength(10) self.shifttfs_input.focus.connect(self.on_help_focus) self.shifttfs_input.setText( str(Case.the().execution_parameters.shifttfs)) self.shifttfs_layout.addWidget(self.shifttfs_label) self.shifttfs_layout.addWidget(self.shifttfs_input) # Enable/Disable fields depending on Shifting mode on window creation. self.on_shifting_change(self.shifting_input.currentIndex()) # Rigid algorithm self.rigidalgorithm_layout = QtGui.QHBoxLayout() self.rigidalgorithm_label = QtGui.QLabel( __("Solid-solid interaction:")) self.rigidalgorithm_input = FocusableComboBox() self.rigidalgorithm_input.insertItems(0, ["SPH", "DEM", "CHRONO"]) self.rigidalgorithm_input.set_help_text(HelpText.RIGIDALGORITHM) self.rigidalgorithm_input.setCurrentIndex( int(Case.the().execution_parameters.rigidalgorithm) - 1) self.rigidalgorithm_input.focus.connect(self.on_help_focus) self.rigidalgorithm_layout.addWidget(self.rigidalgorithm_label) self.rigidalgorithm_layout.addWidget(self.rigidalgorithm_input) self.rigidalgorithm_layout.addStretch(1) # Sim start freeze time self.ftpause_layout = QtGui.QHBoxLayout() self.ftpause_label = QtGui.QLabel(__("Floating freeze time:")) self.ftpause_input = FocusableLineEdit() self.ftpause_input.set_help_text(HelpText.FTPAUSE) self.ftpause_input.setMaxLength(10) self.ftpause_input.focus.connect(self.on_help_focus) self.ftpause_input.setText(str( Case.the().execution_parameters.ftpause)) self.ftpause_label2 = QtGui.QLabel(__("seconds")) self.ftpause_layout.addWidget(self.ftpause_label) self.ftpause_layout.addWidget(self.ftpause_input) self.ftpause_layout.addWidget(self.ftpause_label2) # Coefficient to calculate DT self.coefdtmin_layout = QtGui.QHBoxLayout() self.coefdtmin_label = QtGui.QLabel( __("Coefficient for minimum time step:")) self.coefdtmin_input = FocusableLineEdit() self.coefdtmin_input.set_help_text(HelpText.COEFDTMIN) self.coefdtmin_input.setMaxLength(10) self.coefdtmin_input.focus.connect(self.on_help_focus) self.coefdtmin_input.setText( str(Case.the().execution_parameters.coefdtmin)) self.coefdtmin_layout.addWidget(self.coefdtmin_label) self.coefdtmin_layout.addWidget(self.coefdtmin_input) # Initial time step self.dtiniauto_layout = QtGui.QHBoxLayout() self.dtiniauto_chk = QtGui.QCheckBox(__("Initial time step auto")) if Case.the().execution_parameters.dtini_auto: self.dtiniauto_chk.setCheckState(QtCore.Qt.Checked) else: self.dtiniauto_chk.setCheckState(QtCore.Qt.Unchecked) self.dtiniauto_chk.toggled.connect(self.on_dtiniauto_check) self.dtiniauto_layout.addWidget(self.dtiniauto_chk) self.dtini_layout = QtGui.QHBoxLayout() self.dtini_label = QtGui.QLabel(__("Initial time step:")) self.dtini_input = FocusableLineEdit() self.dtini_input.set_help_text(HelpText.DTINI) self.dtini_input.setMaxLength(10) self.dtini_input.focus.connect(self.on_help_focus) self.dtini_input.setText(str(Case.the().execution_parameters.dtini)) self.dtini_label2 = QtGui.QLabel(__("seconds")) self.dtini_layout.addWidget(self.dtini_label) self.dtini_layout.addWidget(self.dtini_input) self.dtini_layout.addWidget(self.dtini_label2) self.on_dtiniauto_check() # Minimum time step self.dtminauto_layout = QtGui.QHBoxLayout() self.dtminauto_chk = QtGui.QCheckBox(__("Minimum time step:")) if Case.the().execution_parameters.dtmin_auto: self.dtminauto_chk.setCheckState(QtCore.Qt.Checked) else: self.dtminauto_chk.setCheckState(QtCore.Qt.Unchecked) self.dtminauto_chk.toggled.connect(self.on_dtminauto_check) self.dtminauto_layout.addWidget(self.dtminauto_chk) self.dtmin_layout = QtGui.QHBoxLayout() self.dtmin_label = QtGui.QLabel(__("Minimum time step:")) self.dtmin_input = FocusableLineEdit() self.dtmin_input.set_help_text(HelpText.DTMIN) self.dtmin_input.setMaxLength(10) self.dtmin_input.focus.connect(self.on_help_focus) self.dtmin_input.setText(str(Case.the().execution_parameters.dtmin)) self.dtmin_label2 = QtGui.QLabel(__("seconds")) self.dtmin_layout.addWidget(self.dtmin_label) self.dtmin_layout.addWidget(self.dtmin_input) self.dtmin_layout.addWidget(self.dtmin_label2) self.on_dtminauto_check() # Fixed DT file self.dtfixed_layout = QtGui.QHBoxLayout() self.dtfixed_label = QtGui.QLabel(__("Fixed DT file: ")) self.dtfixed_input = QtGui.QLineEdit() self.dtfixed_input.setText(str( Case.the().execution_parameters.dtfixed)) self.dtfixed_label2 = QtGui.QLabel(__("file")) self.dtfixed_layout.addWidget(self.dtfixed_label) self.dtfixed_layout.addWidget(self.dtfixed_input) self.dtfixed_layout.addWidget(self.dtfixed_label2) # Velocity of particles self.dtallparticles_layout = QtGui.QHBoxLayout() self.dtallparticles_label = QtGui.QLabel(__("Velocity of particles: ")) self.dtallparticles_input = QtGui.QLineEdit() self.dtallparticles_input.setMaxLength(1) self.dtallparticles_validator = QtGui.QIntValidator( 0, 1, self.dtallparticles_input) self.dtallparticles_input.setText( str(Case.the().execution_parameters.dtallparticles)) self.dtallparticles_input.setValidator(self.dtallparticles_validator) self.dtallparticles_label2 = QtGui.QLabel("[0, 1]") self.dtallparticles_layout.addWidget(self.dtallparticles_label) self.dtallparticles_layout.addWidget(self.dtallparticles_input) self.dtallparticles_layout.addWidget(self.dtallparticles_label2) # Time of simulation self.timemax_layout = QtGui.QHBoxLayout() self.timemax_label = QtGui.QLabel(__("Time of simulation: ")) self.timemax_input = FocusableLineEdit() self.timemax_input.set_help_text(HelpText.TIMEMAX) self.timemax_input.setMaxLength(10) self.timemax_input.focus.connect(self.on_help_focus) self.timemax_input.setText(str( Case.the().execution_parameters.timemax)) self.timemax_label2 = QtGui.QLabel(__("seconds")) self.timemax_layout.addWidget(self.timemax_label) self.timemax_layout.addWidget(self.timemax_input) self.timemax_layout.addWidget(self.timemax_label2) # Time out data self.timeout_layout = QtGui.QHBoxLayout() self.timeout_label = QtGui.QLabel(__("Time out data: ")) self.timeout_input = FocusableLineEdit() self.timeout_input.set_help_text(HelpText.TIMEOUT) self.timeout_input.setMaxLength(10) self.timeout_input.focus.connect(self.on_help_focus) self.timeout_input.setText(str( Case.the().execution_parameters.timeout)) self.timeout_label2 = QtGui.QLabel(__("seconds")) self.timeout_layout.addWidget(self.timeout_label) self.timeout_layout.addWidget(self.timeout_input) self.timeout_layout.addWidget(self.timeout_label2) # Max parts out allowed self.partsoutmax_layout = QtGui.QHBoxLayout() self.partsoutmax_label = QtGui.QLabel(__("Max parts out allowed (%):")) self.partsoutmax_input = FocusableLineEdit() self.partsoutmax_input.set_help_text(HelpText.PARTSOUTMAX) self.partsoutmax_input.setMaxLength(10) self.partsoutmax_input.focus.connect(self.on_help_focus) self.partsoutmax_input.setText( str(float(Case.the().execution_parameters.partsoutmax) * 100)) self.partsoutmax_layout.addWidget(self.partsoutmax_label) self.partsoutmax_layout.addWidget(self.partsoutmax_input) # Minimum rhop valid self.rhopoutmin_layout = QtGui.QHBoxLayout() self.rhopoutmin_label = QtGui.QLabel(__("Minimum rhop valid:")) self.rhopoutmin_input = FocusableLineEdit() self.rhopoutmin_input.set_help_text(HelpText.RHOPOUTMIN) self.rhopoutmin_input.setMaxLength(10) self.rhopoutmin_input.focus.connect(self.on_help_focus) self.rhopoutmin_input.setText( str(Case.the().execution_parameters.rhopoutmin)) self.rhopoutmin_label2 = QtGui.QLabel( "kg/m<span style='vertical-align:super'>3</span>") self.rhopoutmin_layout.addWidget(self.rhopoutmin_label) self.rhopoutmin_layout.addWidget(self.rhopoutmin_input) self.rhopoutmin_layout.addWidget(self.rhopoutmin_label2) # Maximum rhop valid self.rhopoutmax_layout = QtGui.QHBoxLayout() self.rhopoutmax_label = QtGui.QLabel(__("Maximum rhop valid:")) self.rhopoutmax_input = FocusableLineEdit() self.rhopoutmax_input.set_help_text(HelpText.RHOPOUTMAX) self.rhopoutmax_input.setMaxLength(10) self.rhopoutmax_input.focus.connect(self.on_help_focus) self.rhopoutmax_input.setText( str(Case.the().execution_parameters.rhopoutmax)) self.rhopoutmax_label2 = QtGui.QLabel( "kg/m<span style='vertical-align:super'>3</span>") self.rhopoutmax_layout.addWidget(self.rhopoutmax_label) self.rhopoutmax_layout.addWidget(self.rhopoutmax_input) self.rhopoutmax_layout.addWidget(self.rhopoutmax_label2) self.period_x_layout = QtGui.QVBoxLayout() self.period_x_chk = QtGui.QCheckBox(__("X periodicity")) self.period_x_inc_layout = QtGui.QHBoxLayout() self.period_x_inc_x_label = QtGui.QLabel(__("X Increment")) self.period_x_inc_x_input = FocusableLineEdit() self.period_x_inc_y_label = QtGui.QLabel(__("Y Increment")) self.period_x_inc_y_input = FocusableLineEdit() self.period_x_inc_y_input.set_help_text(HelpText.YINCREMENTX) self.period_x_inc_y_input.focus.connect(self.on_help_focus) self.period_x_inc_z_label = QtGui.QLabel(__("Z Increment")) self.period_x_inc_z_input = FocusableLineEdit() self.period_x_inc_z_input.set_help_text(HelpText.ZINCREMENTX) self.period_x_inc_z_input.focus.connect(self.on_help_focus) self.period_x_inc_layout.addWidget(self.period_x_inc_x_label) self.period_x_inc_layout.addWidget(self.period_x_inc_x_input) self.period_x_inc_layout.addWidget(self.period_x_inc_y_label) self.period_x_inc_layout.addWidget(self.period_x_inc_y_input) self.period_x_inc_layout.addWidget(self.period_x_inc_z_label) self.period_x_inc_layout.addWidget(self.period_x_inc_z_input) self.period_x_layout.addWidget(self.period_x_chk) self.period_x_layout.addLayout(self.period_x_inc_layout) self.period_x_chk.stateChanged.connect(self.on_period_x_chk) self.period_x_chk.setChecked( Case.the().periodicity.x_periodicity.enabled) self.period_x_inc_x_input.setText( str(Case.the().periodicity.x_periodicity.x_increment)) self.period_x_inc_y_input.setText( str(Case.the().periodicity.x_periodicity.y_increment)) self.period_x_inc_z_input.setText( str(Case.the().periodicity.x_periodicity.z_increment)) # Change the state of periodicity input on window open self.on_period_x_chk() self.period_y_layout = QtGui.QVBoxLayout() self.period_y_chk = QtGui.QCheckBox(__("Y periodicity")) self.period_y_inc_layout = QtGui.QHBoxLayout() self.period_y_inc_x_label = QtGui.QLabel(__("X Increment")) self.period_y_inc_x_input = FocusableLineEdit() self.period_y_inc_x_input.set_help_text(HelpText.XINCREMENTY) self.period_y_inc_x_input.focus.connect(self.on_help_focus) self.period_y_inc_y_label = QtGui.QLabel(__("Y Increment")) self.period_y_inc_y_input = FocusableLineEdit() self.period_y_inc_z_label = QtGui.QLabel(__("Z Increment")) self.period_y_inc_z_input = FocusableLineEdit() self.period_y_inc_z_input.set_help_text(HelpText.ZINCREMENTY) self.period_y_inc_z_input.focus.connect(self.on_help_focus) self.period_y_inc_layout.addWidget(self.period_y_inc_x_label) self.period_y_inc_layout.addWidget(self.period_y_inc_x_input) self.period_y_inc_layout.addWidget(self.period_y_inc_y_label) self.period_y_inc_layout.addWidget(self.period_y_inc_y_input) self.period_y_inc_layout.addWidget(self.period_y_inc_z_label) self.period_y_inc_layout.addWidget(self.period_y_inc_z_input) self.period_y_layout.addWidget(self.period_y_chk) self.period_y_layout.addLayout(self.period_y_inc_layout) self.period_y_chk.stateChanged.connect(self.on_period_y_chk) self.period_y_chk.setChecked( Case.the().periodicity.y_periodicity.enabled) self.period_y_inc_x_input.setText( str(Case.the().periodicity.y_periodicity.x_increment)) self.period_y_inc_y_input.setText( str(Case.the().periodicity.y_periodicity.y_increment)) self.period_y_inc_z_input.setText( str(Case.the().periodicity.y_periodicity.z_increment)) # Change the state of periodicity input on window open self.on_period_y_chk() self.period_z_layout = QtGui.QVBoxLayout() self.period_z_chk = QtGui.QCheckBox(__("Z periodicity")) self.period_z_inc_layout = QtGui.QHBoxLayout() self.period_z_inc_x_label = QtGui.QLabel(__("X Increment")) self.period_z_inc_x_input = FocusableLineEdit() self.period_z_inc_x_input.set_help_text(HelpText.XINCREMENTZ) self.period_z_inc_x_input.focus.connect(self.on_help_focus) self.period_z_inc_y_label = QtGui.QLabel(__("Y Increment")) self.period_z_inc_y_input = FocusableLineEdit() self.period_z_inc_y_input.set_help_text(HelpText.YINCREMENTZ) self.period_z_inc_y_input.focus.connect(self.on_help_focus) self.period_z_inc_z_label = QtGui.QLabel(__("Z Increment")) self.period_z_inc_z_input = FocusableLineEdit() self.period_z_inc_layout.addWidget(self.period_z_inc_x_label) self.period_z_inc_layout.addWidget(self.period_z_inc_x_input) self.period_z_inc_layout.addWidget(self.period_z_inc_y_label) self.period_z_inc_layout.addWidget(self.period_z_inc_y_input) self.period_z_inc_layout.addWidget(self.period_z_inc_z_label) self.period_z_inc_layout.addWidget(self.period_z_inc_z_input) self.period_z_layout.addWidget(self.period_z_chk) self.period_z_layout.addLayout(self.period_z_inc_layout) self.period_z_chk.stateChanged.connect(self.on_period_z_chk) self.period_z_chk.setChecked( Case.the().periodicity.z_periodicity.enabled) self.period_z_inc_x_input.setText( str(Case.the().periodicity.z_periodicity.x_increment)) self.period_z_inc_y_input.setText( str(Case.the().periodicity.z_periodicity.y_increment)) self.period_z_inc_z_input.setText( str(Case.the().periodicity.z_periodicity.z_increment)) # Change the state of periodicity input on window open self.on_period_z_chk() # Simulation domain self.simdomain_layout = QtGui.QVBoxLayout() self.simdomain_chk = QtGui.QCheckBox(__("Simulation Domain")) self.simdomain_chk.setChecked(Case.the().domain.enabled) self.simdomain_posmin_layout = QtGui.QHBoxLayout() self.simdomain_posminx_layout = QtGui.QVBoxLayout() self.simdomain_posminy_layout = QtGui.QVBoxLayout() self.simdomain_posminz_layout = QtGui.QVBoxLayout() self.simdomain_posmax_layout = QtGui.QHBoxLayout() self.simdomain_posmaxx_layout = QtGui.QVBoxLayout() self.simdomain_posmaxy_layout = QtGui.QVBoxLayout() self.simdomain_posmaxz_layout = QtGui.QVBoxLayout() self.simdomain_posmin_label = QtGui.QLabel( __("Minimum position(x, y, z):")) self.simdomain_posminx_combobox = QtGui.QComboBox() self.simdomain_posminx_combobox.insertItems(0, [ __("Default"), __("Value"), __("Default - value"), __("Default + %") ]) self.simdomain_posminx_line_edit = FocusableLineEdit() self.simdomain_posminx_line_edit.set_help_text(HelpText.POSMINX) self.simdomain_posminx_line_edit.focus.connect(self.on_help_focus) self.simdomain_posminx_line_edit.setText( str(Case.the().domain.posmin_x.value)) self.simdomain_posminy_combobox = QtGui.QComboBox() self.simdomain_posminy_combobox.insertItems(0, [ __("Default"), __("Value"), __("Default - value"), __("Default + %") ]) self.simdomain_posminy_line_edit = FocusableLineEdit() self.simdomain_posminy_line_edit.set_help_text(HelpText.POSMINY) self.simdomain_posminy_line_edit.focus.connect(self.on_help_focus) self.simdomain_posminy_line_edit.setText( str(Case.the().domain.posmin_y.value)) self.simdomain_posminz_combobox = QtGui.QComboBox() self.simdomain_posminz_combobox.insertItems(0, [ __("Default"), __("Value"), __("Default - value"), __("Default + %") ]) self.simdomain_posminz_line_edit = FocusableLineEdit() self.simdomain_posminz_line_edit.set_help_text(HelpText.POSMINZ) self.simdomain_posminz_line_edit.focus.connect(self.on_help_focus) self.simdomain_posminz_line_edit.setText( str(Case.the().domain.posmin_z.value)) self.simdomain_posminx_layout.addWidget( self.simdomain_posminx_combobox) self.simdomain_posminx_layout.addWidget( self.simdomain_posminx_line_edit) self.simdomain_posminy_layout.addWidget( self.simdomain_posminy_combobox) self.simdomain_posminy_layout.addWidget( self.simdomain_posminy_line_edit) self.simdomain_posminz_layout.addWidget( self.simdomain_posminz_combobox) self.simdomain_posminz_layout.addWidget( self.simdomain_posminz_line_edit) self.simdomain_posmin_layout.addWidget(self.simdomain_posmin_label) self.simdomain_posmin_layout.addLayout(self.simdomain_posminx_layout) self.simdomain_posmin_layout.addLayout(self.simdomain_posminy_layout) self.simdomain_posmin_layout.addLayout(self.simdomain_posminz_layout) self.simdomain_posmax_label = QtGui.QLabel( __("Maximum position(x, y, z):")) self.simdomain_posmaxx_combobox = QtGui.QComboBox() self.simdomain_posmaxx_combobox.insertItems(0, [ __("Default"), __("Value"), __("Default + value"), __("Default + %") ]) self.simdomain_posmaxx_line_edit = FocusableLineEdit() self.simdomain_posmaxx_line_edit.set_help_text(HelpText.POSMAXX) self.simdomain_posmaxx_line_edit.focus.connect(self.on_help_focus) self.simdomain_posmaxx_line_edit.setText( str(Case.the().domain.posmax_x.value)) self.simdomain_posmaxy_combobox = QtGui.QComboBox() self.simdomain_posmaxy_combobox.insertItems(0, [ __("Default"), __("Value"), __("Default + value"), __("Default + %") ]) self.simdomain_posmaxy_line_edit = FocusableLineEdit() self.simdomain_posmaxy_line_edit.set_help_text(HelpText.POSMAXY) self.simdomain_posmaxy_line_edit.focus.connect(self.on_help_focus) self.simdomain_posmaxy_line_edit.setText( str(Case.the().domain.posmax_y.value)) self.simdomain_posmaxz_combobox = QtGui.QComboBox() self.simdomain_posmaxz_combobox.insertItems(0, [ __("Default"), __("Value"), __("Default + value"), __("Default + %") ]) self.simdomain_posmaxz_line_edit = FocusableLineEdit() self.simdomain_posmaxz_line_edit.set_help_text(HelpText.POSMAXZ) self.simdomain_posmaxz_line_edit.focus.connect(self.on_help_focus) self.simdomain_posmaxz_line_edit.setText( str(Case.the().domain.posmax_z.value)) self.simdomain_posmaxx_layout.addWidget( self.simdomain_posmaxx_combobox) self.simdomain_posmaxx_layout.addWidget( self.simdomain_posmaxx_line_edit) self.simdomain_posmaxy_layout.addWidget( self.simdomain_posmaxy_combobox) self.simdomain_posmaxy_layout.addWidget( self.simdomain_posmaxy_line_edit) self.simdomain_posmaxz_layout.addWidget( self.simdomain_posmaxz_combobox) self.simdomain_posmaxz_layout.addWidget( self.simdomain_posmaxz_line_edit) self.simdomain_posmax_layout.addWidget(self.simdomain_posmax_label) self.simdomain_posmax_layout.addLayout(self.simdomain_posmaxx_layout) self.simdomain_posmax_layout.addLayout(self.simdomain_posmaxy_layout) self.simdomain_posmax_layout.addLayout(self.simdomain_posmaxz_layout) self.simdomain_posminx_combobox.setCurrentIndex( Case.the().domain.posmin_x.type) self.simdomain_posminy_combobox.setCurrentIndex( Case.the().domain.posmin_y.type) self.simdomain_posminz_combobox.setCurrentIndex( Case.the().domain.posmin_z.type) self.simdomain_posmaxx_combobox.setCurrentIndex( Case.the().domain.posmax_x.type) self.simdomain_posmaxy_combobox.setCurrentIndex( Case.the().domain.posmax_y.type) self.simdomain_posmaxz_combobox.setCurrentIndex( Case.the().domain.posmax_z.type) self.simdomain_layout.addWidget(self.simdomain_chk) self.simdomain_layout.addLayout(self.simdomain_posmin_layout) self.simdomain_layout.addLayout(self.simdomain_posmax_layout) self.simdomain_chk.stateChanged.connect(self.on_simdomain_chk) self.simdomain_posmaxx_combobox.currentIndexChanged.connect( self.on_posmaxx_changed) self.simdomain_posmaxy_combobox.currentIndexChanged.connect( self.on_posmaxy_changed) self.simdomain_posmaxz_combobox.currentIndexChanged.connect( self.on_posmaxz_changed) self.simdomain_posminx_combobox.currentIndexChanged.connect( self.on_posminx_changed) self.simdomain_posminy_combobox.currentIndexChanged.connect( self.on_posminy_changed) self.simdomain_posminz_combobox.currentIndexChanged.connect( self.on_posminz_changed) self.on_simdomain_chk() self.on_posmaxx_changed() self.on_posmaxy_changed() self.on_posmaxz_changed() self.on_posminx_changed() self.on_posminy_changed() self.on_posminz_changed() self.ok_button.clicked.connect(self.on_ok) self.cancel_button.clicked.connect(self.on_cancel) # Button layout definition self.ep_button_layout = QtGui.QHBoxLayout() self.ep_button_layout.addStretch(1) self.ep_button_layout.addWidget(self.ok_button) self.ep_button_layout.addWidget(self.cancel_button) # START Main layout definition and composition. self.ep_main_layout_scroll = QtGui.QScrollArea() self.ep_main_layout_scroll.setWidgetResizable(True) self.ep_main_layout_scroll_widget = QtGui.QWidget() self.ep_main_layout = QtGui.QVBoxLayout() self.ep_main_layout.addLayout(self.saveposdouble_layout) self.ep_main_layout.addLayout(self.boundary_layout) self.ep_main_layout.addLayout(self.stepalgorithm_layout) self.ep_main_layout.addLayout(self.verletsteps_layout) self.ep_main_layout.addLayout(self.kernel_layout) self.ep_main_layout.addLayout(self.viscotreatment_layout) self.ep_main_layout.addLayout(self.visco_layout) self.ep_main_layout.addLayout(self.viscoboundfactor_layout) self.ep_main_layout.addLayout(self.densitydt_type_layout) self.ep_main_layout.addLayout(self.densitydt_layout) self.ep_main_layout.addLayout(self.shifting_layout) self.ep_main_layout.addLayout(self.shiftcoef_layout) self.ep_main_layout.addLayout(self.shifttfs_layout) self.ep_main_layout.addLayout(self.rigidalgorithm_layout) self.ep_main_layout.addLayout(self.ftpause_layout) self.ep_main_layout.addLayout(self.dtiniauto_layout) self.ep_main_layout.addLayout(self.dtini_layout) self.ep_main_layout.addLayout(self.dtminauto_layout) self.ep_main_layout.addLayout(self.dtmin_layout) self.ep_main_layout.addLayout(self.coefdtmin_layout) self.ep_main_layout.addLayout(self.timemax_layout) self.ep_main_layout.addLayout(self.timeout_layout) self.ep_main_layout.addLayout(self.partsoutmax_layout) self.ep_main_layout.addLayout(self.rhopoutmin_layout) self.ep_main_layout.addLayout(self.rhopoutmax_layout) self.ep_main_layout.addLayout(self.period_x_layout) self.ep_main_layout.addLayout(self.period_y_layout) self.ep_main_layout.addLayout(self.period_z_layout) self.ep_main_layout.addLayout(self.simdomain_layout) self.ep_main_layout_scroll_widget.setLayout(self.ep_main_layout) self.ep_main_layout_scroll.setWidget(self.ep_main_layout_scroll_widget) self.ep_main_layout_scroll.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.execparams_window_layout = QtGui.QVBoxLayout() self.execparams_window_layout.addWidget(self.ep_main_layout_scroll) self.execparams_window_layout.addWidget(self.help_label) self.execparams_window_layout.addLayout(self.ep_button_layout) self.setLayout(self.execparams_window_layout) self.setMinimumWidth(self.MINIMUM_WIDTH) self.setMinimumHeight(self.MINIMUM_HEIGHT) self.resize(self.MINIMUM_WIDTH, self.MINIMUM_HEIGHT) self.exec_()
def __init__(self, post_processing_widget, parent=None): super().__init__(parent=parent) self.post_processing_widget = post_processing_widget self.setModal(False) self.setWindowTitle(__("MeasureTool")) self.measuretool_tool_layout = QtGui.QVBoxLayout() self.mtool_format_layout = QtGui.QHBoxLayout() self.mtool_types_groupbox = QtGui.QGroupBox(__("Variables to export")) self.mtool_filename_layout = QtGui.QHBoxLayout() self.mtool_parameters_layout = QtGui.QHBoxLayout() self.mtool_buttons_layout = QtGui.QHBoxLayout() self.outformat_label = QtGui.QLabel(__("Output format")) self.outformat_combobox = QtGui.QComboBox() self.outformat_combobox.insertItems(0, ["VTK", "CSV", "ASCII"]) self.outformat_combobox.setCurrentIndex(1) self.mtool_format_layout.addWidget(self.outformat_label) self.mtool_format_layout.addStretch(1) self.mtool_format_layout.addWidget(self.outformat_combobox) self.mtool_types_groupbox_layout = QtGui.QVBoxLayout() self.mtool_types_chk_all = QtGui.QCheckBox(__("All")) self.mtool_types_chk_all.setCheckState(QtCore.Qt.Checked) self.mtool_types_chk_vel = QtGui.QCheckBox(__("Velocity")) self.mtool_types_chk_rhop = QtGui.QCheckBox(__("Density")) self.mtool_types_chk_press = QtGui.QCheckBox(__("Pressure")) self.mtool_types_chk_mass = QtGui.QCheckBox(__("Mass")) self.mtool_types_chk_vol = QtGui.QCheckBox(__("Volume")) self.mtool_types_chk_idp = QtGui.QCheckBox(__("Particle ID")) self.mtool_types_chk_ace = QtGui.QCheckBox(__("Acceleration")) self.mtool_types_chk_vor = QtGui.QCheckBox(__("Vorticity")) self.mtool_types_chk_kcorr = QtGui.QCheckBox(__("KCorr")) for x in [ self.mtool_types_chk_all, self.mtool_types_chk_vel, self.mtool_types_chk_rhop, self.mtool_types_chk_press, self.mtool_types_chk_mass, self.mtool_types_chk_vol, self.mtool_types_chk_idp, self.mtool_types_chk_ace, self.mtool_types_chk_vor, self.mtool_types_chk_kcorr ]: self.mtool_types_groupbox_layout.addWidget(x) self.mtool_types_groupbox.setLayout(self.mtool_types_groupbox_layout) self.mtool_calculate_elevation = QtGui.QCheckBox( __("Calculate water elevation")) self.mtool_set_points_layout = QtGui.QHBoxLayout() self.mtool_set_points = QtGui.QPushButton("List of points") self.mtool_set_grid = QtGui.QPushButton("Grid of points") self.mtool_set_points_layout.addWidget(self.mtool_set_points) self.mtool_set_points_layout.addWidget(self.mtool_set_grid) self.mtool_file_name_label = QtGui.QLabel(__("File name")) self.mtool_file_name_text = QtGui.QLineEdit() self.mtool_file_name_text.setText("MeasurePart") self.mtool_filename_layout.addWidget(self.mtool_file_name_label) self.mtool_filename_layout.addWidget(self.mtool_file_name_text) self.mtool_parameters_label = QtGui.QLabel(__("Additional Parameters")) self.mtool_parameters_text = QtGui.QLineEdit() self.mtool_parameters_layout.addWidget(self.mtool_parameters_label) self.mtool_parameters_layout.addWidget(self.mtool_parameters_text) self.mtool_export_button = QtGui.QPushButton(__("Export")) self.mtool_cancel_button = QtGui.QPushButton(__("Cancel")) self.mtool_buttons_layout.addWidget(self.mtool_export_button) self.mtool_buttons_layout.addWidget(self.mtool_cancel_button) self.measuretool_tool_layout.addLayout(self.mtool_format_layout) self.measuretool_tool_layout.addWidget(self.mtool_types_groupbox) self.measuretool_tool_layout.addStretch(1) self.measuretool_tool_layout.addWidget(self.mtool_calculate_elevation) self.measuretool_tool_layout.addLayout(self.mtool_set_points_layout) self.measuretool_tool_layout.addLayout(self.mtool_filename_layout) self.measuretool_tool_layout.addLayout(self.mtool_parameters_layout) self.measuretool_tool_layout.addLayout(self.mtool_buttons_layout) self.setLayout(self.measuretool_tool_layout) self.mtool_types_chk_all.stateChanged.connect( self.on_mtool_measure_all_change) self.mtool_types_chk_vel.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_types_chk_rhop.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_types_chk_press.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_types_chk_mass.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_types_chk_vol.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_types_chk_idp.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_types_chk_ace.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_types_chk_vor.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_types_chk_kcorr.stateChanged.connect( self.on_mtool_measure_single_change) self.mtool_set_points.clicked.connect(self.on_mtool_set_points) self.mtool_set_grid.clicked.connect(self.on_mtool_set_grid) self.mtool_export_button.clicked.connect(self.on_mtool_export) self.mtool_cancel_button.clicked.connect(self.on_mtool_cancel) self.exec_()
def on_help_focus(self, help_text): """ Reacts to focusing the help setting the corresponding help text. """ self.help_label.setText("<b>{}: </b>{}".format(__("Help"), help_text))
def __init__(self, parent=None): super().__init__(parent=parent) self.setWindowTitle(__("Special")) self.setMinimumWidth(200) self.sp_window_layout = QtGui.QVBoxLayout() self.sp_damping_button = QtGui.QPushButton(__("Damping Zone")) self.sp_inlet_button = QtGui.QPushButton(__("Inlet/Outlet")) self.sp_chrono_button = QtGui.QPushButton(__("Project Chrono")) self.sp_multilayeredmb_button = QtGui.QPushButton( __("Multi-layered Piston")) self.sp_multilayeredmb_menu = QtGui.QMenu() self.sp_multilayeredmb_menu.addAction(__("1 Dimension")) self.sp_multilayeredmb_menu.addAction(__("2 Dimensions")) self.sp_multilayeredmb_button.setMenu(self.sp_multilayeredmb_menu) self.sp_relaxationzone_button = QtGui.QPushButton( __("Relaxation Zone")) self.sp_relaxationzone_menu = QtGui.QMenu() self.sp_relaxationzone_menu.addAction(__("Regular waves")) self.sp_relaxationzone_menu.addAction(__("Irregular waves")) self.sp_relaxationzone_menu.addAction(__("External Input")) self.sp_relaxationzone_menu.addAction(__("Uniform velocity")) self.sp_relaxationzone_button.setMenu(self.sp_relaxationzone_menu) self.sp_accinput_button = QtGui.QPushButton(__("Acceleration Inputs")) self.sp_moorings_button = QtGui.QPushButton(__("Moorings")) self.sp_damping_button.clicked.connect(self.on_damping_option) self.sp_inlet_button.clicked.connect(self.on_inlet_option) self.sp_chrono_button.clicked.connect(self.on_chrono_option) self.sp_multilayeredmb_menu.triggered.connect( self.on_multilayeredmb_menu) self.sp_relaxationzone_menu.triggered.connect( self.on_relaxationzone_menu) self.sp_accinput_button.clicked.connect(self.on_accinput_button) self.sp_moorings_button.clicked.connect(self.on_moorings_button) # Add buttons to the special window self.sp_window_layout.addWidget(self.sp_inlet_button) self.sp_window_layout.addWidget(self.sp_accinput_button) self.sp_window_layout.addWidget(self.sp_chrono_button) self.sp_window_layout.addWidget(self.sp_moorings_button) self.sp_window_layout.addWidget(self.sp_damping_button) self.sp_window_layout.addWidget(self.sp_multilayeredmb_button) self.sp_window_layout.addWidget(self.sp_relaxationzone_button) self.setLayout(self.sp_window_layout) if not Case.the().executable_paths.supports_chrono(): self.sp_chrono_button.hide() if not Case.the().executable_paths.supports_moorings( ) and not ApplicationSettings.the().force_moordyn_support_enabled: self.sp_moorings_button.hide() self.exec_()
def __init__(self, parent=None): super().__init__(parent=parent) # Reference to avoid calling instance every time self.case = Case.the() # Creates a dialog self.setWindowTitle("Chrono configuration") self.setMinimumWidth(500) self.setMinimumHeight(600) self.main_layout = QtGui.QVBoxLayout() # Option for saves CSV with data exchange for each time interval self.csv_option_layout = QtGui.QHBoxLayout() self.csv_intervals_checkbox = QtGui.QCheckBox() self.csv_intervals_checkbox.setCheckState(QtCore.Qt.Checked if self.case.chrono.csv_intervals.enabled else QtCore.Qt.Unchecked) self.csv_intervals_checkbox.toggled.connect(self.on_csv_intervals_check) self.csv_intervals_option = QtGui.QLabel(__("CSV intervals:")) self.csv_intervals_line_edit = QtGui.QLineEdit(str(self.case.chrono.csv_intervals.value)) self.csv_option_layout.addWidget(self.csv_intervals_checkbox) self.csv_option_layout.addWidget(self.csv_intervals_option) self.csv_option_layout.addWidget(self.csv_intervals_line_edit) # Option for define scale used to create the initial scheme of Chrono objects self.scale_scheme_option_layout = QtGui.QHBoxLayout() self.scale_scheme_checkbox = QtGui.QCheckBox() self.scale_scheme_checkbox.setCheckState(QtCore.Qt.Checked if self.case.chrono.scale_scheme.enabled else QtCore.Qt.Unchecked) self.scale_scheme_checkbox.toggled.connect(self.on_scale_scheme_checkbox) self.scale_scheme_option = QtGui.QLabel(__("Scale for scheme:")) self.scale_scheme_line_edit = QtGui.QLineEdit(str(self.case.chrono.scale_scheme.value)) self.scale_scheme_option_layout.addWidget(self.scale_scheme_checkbox) self.scale_scheme_option_layout.addWidget(self.scale_scheme_option) self.scale_scheme_option_layout.addWidget(self.scale_scheme_line_edit) # Option for allow collision overlap according Dp self.collisiondp_option_layout = QtGui.QHBoxLayout() self.collisiondp_checkbox = QtGui.QCheckBox() if self.case.chrono.collisiondp.enabled: self.collisiondp_checkbox.setCheckState(QtCore.Qt.Checked) else: self.collisiondp_checkbox.setCheckState(QtCore.Qt.Unchecked) self.collisiondp_checkbox.toggled.connect(self.on_collisiondp_checkbox) self.collisiondp_option = QtGui.QLabel(__("Collision Dp:")) self.collisiondp_line_edit = QtGui.QLineEdit(str(self.case.chrono.collisiondp.value)) self.collisiondp_option_layout.addWidget(self.collisiondp_checkbox) self.collisiondp_option_layout.addWidget(self.collisiondp_option) self.collisiondp_option_layout.addWidget(self.collisiondp_line_edit) # Create the list for chrono objects self.main_chrono = QtGui.QGroupBox("Chrono objects") self.main_chrono.setMinimumHeight(150) self.chrono_layout = QtGui.QVBoxLayout() self.objectlist_table = QtGui.QTableWidget(0, 1) self.objectlist_table.setObjectName("Chrono objects table") self.objectlist_table.verticalHeader().setVisible(False) self.objectlist_table.horizontalHeader().setVisible(False) self.objectlist_table.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.Stretch) self.objectlist_table.setEnabled(True) # Create the necessary spaces in the list self.count = 0 self.objectlist_table.setRowCount(len(self.case.get_all_bound_objects())) self.current_row = 0 self.objects_with_parent = list() self.is_floating = "" self.chrono_object_options_widgets = list() # Select the objects that are going to be listed for sim_object in self.case.get_all_bound_objects(): freecad_object = get_fc_object(sim_object.name) self.is_floating = "bodyfloating" if self.case.get_mk_based_properties(sim_object.type, sim_object.obj_mk).float_property else "bodyfixed" # Collects the information of the object self.target_widget = ChronoObjectCheckOptions( key=sim_object.name, object_mk=sim_object.obj_mk, mktype=sim_object.type, object_name=freecad_object.Label, is_floating=self.is_floating, parent=get_fc_main_window() ) # Updates the state of list options if self.case.chrono.objects: for elem in self.case.chrono.objects: if elem.id == sim_object.name: self.target_widget.object_check.setCheckState(QtCore.Qt.Checked) self.target_widget.geometry_check.setCheckState(QtCore.Qt.Checked if elem.modelnormal_enabled else QtCore.Qt.Unchecked) self.target_widget.modelnormal_input.setCurrentIndex({ChronoModelNormalType.ORIGINAL: 0, ChronoModelNormalType.INVERT: 1, ChronoModelNormalType.TWOFACE: 2}[elem.modelnormal_type]) # Saves the information about object for being process later self.chrono_object_options_widgets.append(self.target_widget) # Shows the object in table self.objectlist_table.setCellWidget(self.current_row, 0, self.target_widget) self.current_row += 1 # Add table to the layout self.chrono_layout.addWidget(self.objectlist_table) # Creates 2 main buttons self.ok_button = QtGui.QPushButton("Save") self.cancel_button = QtGui.QPushButton("Cancel") self.button_layout = QtGui.QHBoxLayout() self.button_layout.addStretch(1) self.ok_button.clicked.connect(self.on_ok) self.cancel_button.clicked.connect(self.on_cancel) # Link Linearspring option list self.main_link_linearspring = QtGui.QGroupBox("Linearspring") self.link_linearspring_layout = QtGui.QVBoxLayout() self.link_linearspring_layout2 = QtGui.QVBoxLayout() self.link_linearspring_button_layout = QtGui.QHBoxLayout() self.button_link_linearspring = QtGui.QPushButton("Add") self.link_linearspring_button_layout.addStretch(1) self.link_linearspring_button_layout.addWidget(self.button_link_linearspring) self.button_link_linearspring.clicked.connect(self.on_link_linearspring_add) self.link_linearspring_layout.addLayout(self.link_linearspring_button_layout) self.link_linearspring_layout.addLayout(self.link_linearspring_layout2) self.main_link_linearspring.setLayout(self.link_linearspring_layout) self.refresh_link_linearspring() # Link hinge option list self.main_link_hinge = QtGui.QGroupBox("Hinge") self.link_hinge_layout = QtGui.QVBoxLayout() self.link_hinge_layout2 = QtGui.QVBoxLayout() self.link_hinge_button_layout = QtGui.QHBoxLayout() self.button_link_hinge = QtGui.QPushButton("Add") self.link_hinge_button_layout.addStretch(1) self.link_hinge_button_layout.addWidget(self.button_link_hinge) self.button_link_hinge.clicked.connect(self.on_link_hinge_add) self.link_hinge_layout.addLayout(self.link_hinge_button_layout) self.link_hinge_layout.addLayout(self.link_hinge_layout2) self.main_link_hinge.setLayout(self.link_hinge_layout) self.refresh_link_hinge() # Link Spheric option list self.main_link_spheric = QtGui.QGroupBox("Spheric") self.link_spheric_layout = QtGui.QVBoxLayout() self.link_spheric_layout2 = QtGui.QVBoxLayout() self.link_spheric_button_layout = QtGui.QHBoxLayout() self.button_link_spheric = QtGui.QPushButton("Add") self.link_spheric_button_layout.addStretch(1) self.link_spheric_button_layout.addWidget(self.button_link_spheric) self.button_link_spheric.clicked.connect(self.on_link_spheric_add) self.link_spheric_layout.addLayout(self.link_spheric_button_layout) self.link_spheric_layout.addLayout(self.link_spheric_layout2) self.main_link_spheric.setLayout(self.link_spheric_layout) self.refresh_link_spheric() # Link Pointline option list self.main_link_pointline = QtGui.QGroupBox("Pointline") self.link_pointline_layout = QtGui.QVBoxLayout() self.link_pointline_layout2 = QtGui.QVBoxLayout() self.link_pointline_button_layout = QtGui.QHBoxLayout() self.button_link_pointline = QtGui.QPushButton("Add") self.link_pointline_button_layout.addStretch(1) self.link_pointline_button_layout.addWidget(self.button_link_pointline) self.button_link_pointline.clicked.connect(self.on_link_pointline_add) self.link_pointline_layout.addLayout(self.link_pointline_button_layout) self.link_pointline_layout.addLayout(self.link_pointline_layout2) self.main_link_pointline.setLayout(self.link_pointline_layout) self.refresh_link_pointline() # Adds all layouts to main self.main_layout.addLayout(self.csv_option_layout) self.main_layout.addLayout(self.scale_scheme_option_layout) self.main_layout.addLayout(self.collisiondp_option_layout) self.main_chrono.setLayout(self.chrono_layout) self.main_layout.addWidget(self.main_chrono) self.main_layout.addWidget(self.main_link_linearspring) self.main_layout.addWidget(self.main_link_hinge) self.main_layout.addWidget(self.main_link_spheric) self.main_layout.addWidget(self.main_link_pointline) self.button_layout.addWidget(self.ok_button) self.button_layout.addWidget(self.cancel_button) # Adds scroll area self.main_layout_dialog = QtGui.QVBoxLayout() self.main_layout_scroll = QtGui.QScrollArea() self.main_layout_scroll.setMinimumWidth(400) self.main_layout_scroll.setWidgetResizable(True) self.main_layout_scroll_widget = QtGui.QWidget() self.main_layout_scroll_widget.setMinimumWidth(400) self.main_layout_scroll_widget.setLayout(self.main_layout) self.main_layout_scroll.setWidget(self.main_layout_scroll_widget) self.main_layout_scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.main_layout_dialog.addWidget(self.main_layout_scroll) self.main_layout_dialog.addLayout(self.button_layout) self.on_scale_scheme_checkbox() self.on_csv_intervals_check() self.on_collisiondp_checkbox() self.setLayout(self.main_layout_dialog) self.ok_button.setFocus() self.exec_()
pass except IOError: error("Unable to copy {} into {}".format(filename, save_name)) # Dumps all the case data to an XML file. XMLExporter().save_to_disk(save_name, case) case.version = VERSION # Save data array on disk. It is saved as a binary file with Pickle. try: with open(save_name + "/casedata.dsphdata", "wb") as picklefile: pickle.dump(case, picklefile, PICKLE_PROTOCOL) except Exception: print_exc() error_dialog( __("There was a problem saving the DSPH information file (casedata.dsphdata)." )) refocus_cwd() def get_default_config_file(): """ Gets the default-config.json from disk """ current_script_folder = path.dirname(path.realpath(__file__)) with open("{}/../default-config.json".format(current_script_folder), encoding="utf-8") as data_file: loaded_data = json.load(data_file) if "win" in platform: to_ret = loaded_data["windows"] elif "linux" in platform: to_ret = loaded_data["linux"]
def __init__(self, post_processing_widget, parent=None): super().__init__(parent=parent) self.post_processing_widget = post_processing_widget self.setModal(False) self.setWindowTitle(__("PartVTK Tool")) self.partvtk_tool_layout = QtGui.QVBoxLayout() self.pvtk_format_layout = QtGui.QHBoxLayout() self.pvtk_types_groupbox = QtGui.QGroupBox(__("Types to export")) self.pvtk_filename_layout = QtGui.QHBoxLayout() self.pvtk_parameters_layout = QtGui.QHBoxLayout() self.pvtk_buttons_layout = QtGui.QHBoxLayout() self.outformat_label = QtGui.QLabel(__("Output format")) self.outformat_combobox = QtGui.QComboBox() self.outformat_combobox.insertItems(0, ["VTK", "CSV", "ASCII"]) self.pvtk_format_layout.addWidget(self.outformat_label) self.pvtk_format_layout.addStretch(1) self.pvtk_format_layout.addWidget(self.outformat_combobox) self.pvtk_types_groupbox_layout = QtGui.QVBoxLayout() self.pvtk_types_chk_all = QtGui.QCheckBox(__("All")) self.pvtk_types_chk_all.setCheckState(QtCore.Qt.Checked) self.pvtk_types_chk_bound = QtGui.QCheckBox(__("Bound")) self.pvtk_types_chk_fluid = QtGui.QCheckBox(__("Fluid")) self.pvtk_types_chk_fixed = QtGui.QCheckBox(__("Fixed")) self.pvtk_types_chk_moving = QtGui.QCheckBox(__("Moving")) self.pvtk_types_chk_floating = QtGui.QCheckBox(__("Floating")) for x in [self.pvtk_types_chk_all, self.pvtk_types_chk_bound, self.pvtk_types_chk_fluid, self.pvtk_types_chk_fixed, self.pvtk_types_chk_moving, self.pvtk_types_chk_floating]: self.pvtk_types_groupbox_layout.addWidget(x) self.pvtk_types_groupbox.setLayout(self.pvtk_types_groupbox_layout) self.pvtk_file_name_label = QtGui.QLabel(__("File name")) self.pvtk_file_name_text = QtGui.QLineEdit() self.pvtk_file_name_text.setText(self.DEFAULT_NAMES[0]) self.pvtk_filename_layout.addWidget(self.pvtk_file_name_label) self.pvtk_filename_layout.addWidget(self.pvtk_file_name_text) self.pvtk_parameters_label = QtGui.QLabel(__("Additional Parameters")) self.pvtk_parameters_text = QtGui.QLineEdit() self.pvtk_parameters_layout.addWidget(self.pvtk_parameters_label) self.pvtk_parameters_layout.addWidget(self.pvtk_parameters_text) self.pvtk_open_at_end = QtGui.QCheckBox("Open with ParaView") self.pvtk_open_at_end.setEnabled(Case.the().executable_paths.paraview != "") self.pvtk_export_button = QtGui.QPushButton(__("Export")) self.pvtk_cancel_button = QtGui.QPushButton(__("Cancel")) self.pvtk_buttons_layout.addWidget(self.pvtk_export_button) self.pvtk_buttons_layout.addWidget(self.pvtk_cancel_button) self.partvtk_tool_layout.addLayout(self.pvtk_format_layout) self.partvtk_tool_layout.addWidget(self.pvtk_types_groupbox) self.partvtk_tool_layout.addStretch(1) self.partvtk_tool_layout.addLayout(self.pvtk_filename_layout) self.partvtk_tool_layout.addLayout(self.pvtk_parameters_layout) self.partvtk_tool_layout.addWidget(self.pvtk_open_at_end) self.partvtk_tool_layout.addLayout(self.pvtk_buttons_layout) self.setLayout(self.partvtk_tool_layout) self.outformat_combobox.currentIndexChanged.connect(self.on_pvtk_export_format_change) self.pvtk_types_chk_all.stateChanged.connect(self.on_pvtk_type_all_change) self.pvtk_types_chk_bound.stateChanged.connect(self.on_pvtk_type_bound_change) self.pvtk_types_chk_fluid.stateChanged.connect(self.on_pvtk_type_fluid_change) self.pvtk_types_chk_fixed.stateChanged.connect(self.on_pvtk_type_fixed_change) self.pvtk_types_chk_moving.stateChanged.connect(self.on_pvtk_type_moving_change) self.pvtk_types_chk_floating.stateChanged.connect(self.on_pvtk_type_floating_change) self.pvtk_export_button.clicked.connect(self.on_pvtk_export) self.pvtk_cancel_button.clicked.connect(self.on_pvtk_cancel) self.exec_()
def __init__(self, particle_count=0, detail_text="No details", cmd_string="", parent=None): super().__init__(parent=parent) # Window Creation self.setWindowModality(QtCore.Qt.NonModal) self.setWindowTitle(__("Save & GenCase")) self.setMinimumSize(400, 100) # Main Layout creation self.main_layout = QtGui.QVBoxLayout() # Main Layout elements self.info_message = QtGui.QLabel( __("Gencase exported <b>{}</b> particles.<br/>" "Press the <i>Details</i> button to check the output.").format( str(particle_count))) self.button_layout = QtGui.QHBoxLayout() self.bt_open_with_paraview = QtGui.QPushButton( __("Open with Paraview")) self.open_menu = QtGui.QMenu() self.open_menu.addAction("{}_MkCells.vtk".format(Case.the().name)) self.open_menu.addAction("{}_All.vtk".format(Case.the().name)) self.open_menu.addAction("{}_Fluid.vtk".format(Case.the().name)) self.open_menu.addAction("{}_Bound.vtk".format(Case.the().name)) self.bt_open_with_paraview.setMenu(self.open_menu) self.bt_details = QtGui.QPushButton(__("Details")) self.bt_ok = QtGui.QPushButton(__("OK")) self.button_layout.addWidget(self.bt_open_with_paraview) self.button_layout.addStretch(1) self.button_layout.addWidget(self.bt_details) self.button_layout.addWidget(self.bt_ok) # Details widget self.detail_text_widget = QtGui.QWidget() self.detail_text_widget.setContentsMargins(0, 0, 0, 0) self.detail_text_widget_layout = QtGui.QVBoxLayout() self.detail_text_widget_layout.setContentsMargins(0, 0, 0, 0) self.detail_text_area = QtGui.QTextEdit() self.detail_text_area.setText( "<b>{}:</b> <tt>{}</tt><br><pre>{}</pre>".format( __("The executed command line was"), cmd_string, detail_text)) self.detail_text_widget_layout.addWidget(h_line_generator()) self.detail_text_widget_layout.addWidget(self.detail_text_area) self.detail_text_widget.setLayout(self.detail_text_widget_layout) # Main Layout scaffolding self.main_layout.addWidget(self.info_message) self.main_layout.addStretch(1) self.main_layout.addLayout(self.button_layout) self.main_layout.addWidget(self.detail_text_widget) # Window logic self.detail_text_widget.hide() if Case.the().executable_paths.paraview: self.bt_open_with_paraview.show() else: self.bt_open_with_paraview.hide() self.bt_ok.clicked.connect(self.on_ok) self.bt_details.clicked.connect(self.on_view_details) self.open_menu.triggered.connect(self.on_open_paraview_menu) # Window scaffolding and execution self.setLayout(self.main_layout) self.setMinimumWidth(self.DETAILS_MIN_WIDTH)
def on_file_browse(self): """ Opens a file dialog to open the filename, then puts it into the widget. """ filename, _ = QtGui.QFileDialog.getOpenFileName(self, __("Open file"), Case.the().info.last_used_directory) Case.the().info.update_last_used_directory(filename) self.filename_input.setText(filename)
def __init__(self, link_hinge_id, bodies_widgets, parent=None): super().__init__(parent=parent) self.link_hinge_id = link_hinge_id self.case = Case.the() # Title self.setWindowTitle(__("Link hinge configuration")) self.link_hinge_edit_layout = QtGui.QVBoxLayout() # Find the link hinge for which the button was pressed target_link_hinge = None for link_hinge in self.case.chrono.link_hinge: if link_hinge.id == self.link_hinge_id: target_link_hinge = link_hinge # This should not happen but if no link hinge is found with reference id, it spawns an error. if target_link_hinge is None: error_dialog("There was an error opnening the link hinge to edit") return # Elements that interact self.body_layout = QtGui.QHBoxLayout() self.body_one_label = QtGui.QLabel(__("Body 1: ")) self.body_one_line_edit = QtGui.QComboBox() self.body_one_line_edit.insertItems(0, [str(target_link_hinge.idbody1)]) for body in bodies_widgets: if body.object_check.isChecked() and body.object_name != str( target_link_hinge.idbody1): self.body_one_line_edit.insertItems(0, [body.object_name]) self.body_two_label = QtGui.QLabel(__("Body 2: ")) self.body_two_line_edit = QtGui.QComboBox() self.body_two_line_edit.insertItems(0, [str(target_link_hinge.idbody2)]) for body in bodies_widgets: if body.object_check.isChecked() and body.object_name != str( target_link_hinge.idbody2): self.body_two_line_edit.insertItems(0, [body.object_name]) self.body_to_body_label = QtGui.QLabel(__("to")) self.body_layout.addWidget(self.body_one_label) self.body_layout.addWidget(self.body_one_line_edit) self.body_layout.addWidget(self.body_to_body_label) self.body_layout.addWidget(self.body_two_label) self.body_layout.addWidget(self.body_two_line_edit) self.body_layout.addStretch(1) self.link_hinge_edit_layout.addLayout(self.body_layout) # Points for rotation self.rotpoints_layout = QtGui.QHBoxLayout() self.rotpoints_label = QtGui.QLabel(__("Points for rotation: ")) self.rotpoints_x_label = QtGui.QLabel(__("X")) self.rotpoints_x_line_edit = QtGui.QLineEdit( str(target_link_hinge.rotpoint[0])) self.rotpoints_y_label = QtGui.QLabel(__("Y")) self.rotpoints_y_line_edit = QtGui.QLineEdit( str(target_link_hinge.rotpoint[1])) self.rotpoints_z_label = QtGui.QLabel(__("Z")) self.rotpoints_z_line_edit = QtGui.QLineEdit( str(target_link_hinge.rotpoint[2])) self.rotpoints_layout.addWidget(self.rotpoints_label) self.rotpoints_layout.addWidget(self.rotpoints_x_label) self.rotpoints_layout.addWidget(self.rotpoints_x_line_edit) self.rotpoints_layout.addWidget(self.rotpoints_y_label) self.rotpoints_layout.addWidget(self.rotpoints_y_line_edit) self.rotpoints_layout.addWidget(self.rotpoints_z_label) self.rotpoints_layout.addWidget(self.rotpoints_z_line_edit) self.link_hinge_edit_layout.addLayout(self.rotpoints_layout) # Vector direction for rotation self.rotvector_layout = QtGui.QHBoxLayout() self.rotvector_label = QtGui.QLabel(__("Vector direction: ")) self.rotvector_x_label = QtGui.QLabel(__("X")) self.rotvector_x_line_edit = QtGui.QLineEdit( str(target_link_hinge.rotvector[0])) self.rotvector_y_label = QtGui.QLabel(__("Y")) self.rotvector_y_line_edit = QtGui.QLineEdit( str(target_link_hinge.rotvector[1])) self.rotvector_z_label = QtGui.QLabel(__("Z")) self.rotvector_z_line_edit = QtGui.QLineEdit( str(target_link_hinge.rotvector[2])) self.rotvector_layout.addWidget(self.rotvector_label) self.rotvector_layout.addWidget(self.rotvector_x_label) self.rotvector_layout.addWidget(self.rotvector_x_line_edit) self.rotvector_layout.addWidget(self.rotvector_y_label) self.rotvector_layout.addWidget(self.rotvector_y_line_edit) self.rotvector_layout.addWidget(self.rotvector_z_label) self.rotvector_layout.addWidget(self.rotvector_z_line_edit) self.link_hinge_edit_layout.addLayout(self.rotvector_layout) # Torsion options self.torsion_stiffness_layout = QtGui.QHBoxLayout() self.torsion_damping_layout = QtGui.QHBoxLayout() self.stiffness_label = QtGui.QLabel(__("Stiffness (Nm/rad):")) self.stiffness_line_edit = QtGui.QLineEdit( str(target_link_hinge.stiffness)) self.damping_label = QtGui.QLabel(__("Damping (Nms/rad):")) self.damping_line_edit = QtGui.QLineEdit(str( target_link_hinge.damping)) self.torsion_stiffness_layout.addWidget(self.stiffness_label) self.torsion_stiffness_layout.addWidget(self.stiffness_line_edit) self.torsion_damping_layout.addWidget(self.damping_label) self.torsion_damping_layout.addWidget(self.damping_line_edit) self.link_hinge_edit_layout.addLayout(self.torsion_stiffness_layout) self.link_hinge_edit_layout.addLayout(self.torsion_damping_layout) # Buttons self.ok_button = QtGui.QPushButton("Save") self.ok_button.clicked.connect(self.on_save) self.cancel_button = QtGui.QPushButton("Cancel") self.cancel_button.clicked.connect(self.on_cancel) self.button_layout = QtGui.QHBoxLayout() self.button_layout.addStretch(1) self.button_layout.addWidget(self.ok_button) self.button_layout.addWidget(self.cancel_button) self.link_hinge_edit_layout.addLayout(self.button_layout) # Add the elements to the window self.setLayout(self.link_hinge_edit_layout) self.exec_()
def __init__(self, rot_file_gen, project_folder_path, parent=None): if not isinstance(rot_file_gen, RotationFileGen): raise TypeError("You tried to spawn a rotation file generator " "motion widget in the timeline with a wrong object") if rot_file_gen is None: raise TypeError("You tried to spawn a rotation file generator " "motion widget in the timeline without a motion object") super().__init__(parent=parent) # Needed for copying movement file to root of the case. self.project_folder_path = project_folder_path self.main_layout = QtGui.QVBoxLayout() self.main_layout.setContentsMargins(10, 10, 10, 10) self.root_label = QtGui.QLabel(__("Rotation file movement")) self.duration_label = QtGui.QLabel(__("Duration (s): ")) self.duration_input = QtGui.QLineEdit() self.filename_label = QtGui.QLabel(__("File name: ")) self.filename_input = QtGui.QLineEdit() self.filename_browse = QtGui.QPushButton(__("Browse")) self.anglesunits_label = QtGui.QLabel(__("Angle Units: ")) self.anglesunits_selector = QtGui.QComboBox() self.anglesunits_selector.insertItems( 0, [__("Degrees"), __("Radians")]) self.axisp1x_label = QtGui.QLabel(__("Axis 1 X: ")) self.axisp1x_input = QtGui.QLineEdit() self.axisp1y_label = QtGui.QLabel(__("Axis 1 Y: ")) self.axisp1y_input = QtGui.QLineEdit() self.axisp1z_label = QtGui.QLabel(__("Axis 1 Z: ")) self.axisp1z_input = QtGui.QLineEdit() self.axisp2x_label = QtGui.QLabel(__("Axis 2 X: ")) self.axisp2x_input = QtGui.QLineEdit() self.axisp2y_label = QtGui.QLabel(__("Axis 2 Y: ")) self.axisp2y_input = QtGui.QLineEdit() self.axisp2z_label = QtGui.QLabel(__("Axis 2 Z: ")) self.axisp2z_input = QtGui.QLineEdit() self.root_layout = QtGui.QHBoxLayout() self.root_layout.addWidget(self.root_label) self.root_layout.addStretch(1) self.root_layout.addWidget(self.anglesunits_label) self.root_layout.addWidget(self.anglesunits_selector) self.root_layout.addWidget(self.duration_label) self.root_layout.addWidget(self.duration_input) self.first_row_layout = QtGui.QHBoxLayout() self.first_row_layout.addWidget(self.filename_label) self.first_row_layout.addWidget(self.filename_input) self.first_row_layout.addWidget(self.filename_browse) self.second_row_layout = QtGui.QHBoxLayout() for x in [self.axisp1x_label, self.axisp1x_input, self.axisp1y_label, self.axisp1y_input, self.axisp1z_label, self.axisp1z_input]: self.second_row_layout.addWidget(x) self.third_row_layout = QtGui.QHBoxLayout() for x in [self.axisp2x_label, self.axisp2x_input, self.axisp2y_label, self.axisp2y_input, self.axisp2z_label, self.axisp2z_input]: self.third_row_layout.addWidget(x) self.main_layout.addLayout(self.root_layout) self.main_layout.addWidget(h_line_generator()) for x in [self.first_row_layout, self.second_row_layout, self.third_row_layout]: self.main_layout.addLayout(x) self.setLayout(self.main_layout) self.fill_values(rot_file_gen) self._init_connections()
def __init__(self, post_processing_widget, parent=None): super().__init__(parent=parent) self.post_processing_widget = post_processing_widget self.setModal(False) self.setWindowTitle(__("ComputeForces Tool")) self.compforces_tool_layout = QtGui.QVBoxLayout() self.cfces_format_layout = QtGui.QHBoxLayout() self.cfces_onlyprocess_layout = QtGui.QHBoxLayout() self.cfces_filename_layout = QtGui.QHBoxLayout() self.cfces_additional_parameters_layout = QtGui.QHBoxLayout() self.cfces_buttons_layout = QtGui.QHBoxLayout() self.outformat_label = QtGui.QLabel(__("Output format")) self.outformat_combobox = QtGui.QComboBox() self.outformat_combobox.insertItems(0, ["VTK", "CSV", "ASCII"]) self.outformat_combobox.setCurrentIndex(1) self.outformat_combobox.currentIndexChanged.connect( self.on_outformat_changed) self.cfces_format_layout.addWidget(self.outformat_label) self.cfces_format_layout.addStretch(1) self.cfces_format_layout.addWidget(self.outformat_combobox) self.cfces_onlyprocess_selector = QtGui.QComboBox() self.cfces_onlyprocess_selector.insertItems(0, ["MK", "id", "position"]) self.cfces_onlyprocess_label = QtGui.QLabel( __("to process (empty for all)")) self.cfces_onlyprocess_text = QtGui.QLineEdit( Case.the().custom.moment_mk) self.cfces_onlyprocess_text.setPlaceholderText("1,2,3 or 1-30") self.cfces_onlyprocess_layout.addWidget( self.cfces_onlyprocess_selector) self.cfces_onlyprocess_layout.addWidget(self.cfces_onlyprocess_label) self.cfces_onlyprocess_layout.addWidget(self.cfces_onlyprocess_text) self.cfces_filename_label = QtGui.QLabel(__("File Name")) self.cfces_filename_text = QtGui.QLineEdit() self.cfces_filename_text.setText("Forces") self.cfces_filename_layout.addWidget(self.cfces_filename_label) self.cfces_filename_layout.addWidget(self.cfces_filename_text) self.cfces_additional_parameters_label = QtGui.QLabel( __("Additional Parameters")) self.cfces_additional_parameters_text = QtGui.QLineEdit( Case.the().custom.cfces_additional_parameters) self.cfces_additional_parameters_layout.addWidget( self.cfces_additional_parameters_label) self.cfces_additional_parameters_layout.addWidget( self.cfces_additional_parameters_text) self.cfces_export_button = QtGui.QPushButton(__("Export")) self.cfces_cancel_button = QtGui.QPushButton(__("Cancel")) self.cfces_buttons_layout.addWidget(self.cfces_export_button) self.cfces_buttons_layout.addWidget(self.cfces_cancel_button) self.moment_group_box = QtGui.QGroupBox('Moment axis') self.moment_group_box.setCheckable(True) self.moment_group_box.setChecked(Case.the().custom.moment_checked) self.moment_group_box_layout = QtGui.QGridLayout() self.moment_group_box_layout.addWidget(QtGui.QLabel('P1'), 0, 1, 1, 1) self.moment_group_box_layout.addWidget(QtGui.QLabel('P2'), 0, 2, 1, 1) self.moment_group_box_layout.addWidget(QtGui.QLabel('x'), 1, 0, 1, 1) self.moment_group_box_layout.addWidget(QtGui.QLabel('y'), 2, 0, 1, 1) self.moment_group_box_layout.addWidget(QtGui.QLabel('z'), 3, 0, 1, 1) self.moment_x1_line_edit = QtGui.QLineEdit(Case.the().custom.moment_x1) self.moment_x2_line_edit = QtGui.QLineEdit(Case.the().custom.moment_x2) self.moment_y1_line_edit = QtGui.QLineEdit(Case.the().custom.moment_y1) self.moment_y2_line_edit = QtGui.QLineEdit(Case.the().custom.moment_y2) self.moment_z1_line_edit = QtGui.QLineEdit(Case.the().custom.moment_z1) self.moment_z2_line_edit = QtGui.QLineEdit(Case.the().custom.moment_z2) self.moment_group_box_layout.addWidget(self.moment_x1_line_edit, 1, 1, 1, 1) self.moment_group_box_layout.addWidget(self.moment_x2_line_edit, 1, 2, 1, 1) self.moment_group_box_layout.addWidget(self.moment_y1_line_edit, 2, 1, 1, 1) self.moment_group_box_layout.addWidget(self.moment_y2_line_edit, 2, 2, 1, 1) self.moment_group_box_layout.addWidget(self.moment_z1_line_edit, 3, 1, 1, 1) self.moment_group_box_layout.addWidget(self.moment_z2_line_edit, 3, 2, 1, 1) self.moment_group_box.setLayout(self.moment_group_box_layout) self.cfces_plot = QtGui.QCheckBox('Plot exported data') self.cfces_plot.setToolTip( 'Plot exported data and csv (optional)\non operation completed') self.cfces_plot.setChecked(Case.the().custom.cfces_plot) self.cfces_plot_button = QtGui.QPushButton('Plot') self.cfces_plot_button.clicked.connect(self.on_cfces_plot) self.cfces_plot_layout = QtGui.QHBoxLayout() self.cfces_plot_layout.addWidget(self.cfces_plot) self.cfces_plot_layout.addWidget(self.cfces_plot_button) self.cfces_csv_path = QtGui.QLineEdit(Case.the().custom.cfces_csv_path) self.cfces_csv_path.setPlaceholderText( 'Put here a csv path to compare with exported data') self.cfces_csv_path.setToolTip( 'Two columns will be read, first one for time in s, second\none for torque in N*m. Delimiter has to be coma' ) self.cfces_csv_path.editingFinished.connect( self.on_cfces_csv_path_edit) self.cfces_csv_browse = QtGui.QPushButton('...') self.cfces_csv_browse.clicked.connect(self.on_cfces_csv_browse) self.cfces_csv_layout = QtGui.QHBoxLayout() self.cfces_csv_layout.addWidget(QtGui.QLabel('CSV')) self.cfces_csv_layout.addWidget(self.cfces_csv_path) self.cfces_csv_layout.addWidget(self.cfces_csv_browse) self.compforces_tool_layout.addLayout(self.cfces_format_layout) self.compforces_tool_layout.addLayout(self.cfces_onlyprocess_layout) self.compforces_tool_layout.addLayout(self.cfces_filename_layout) self.compforces_tool_layout.addLayout( self.cfces_additional_parameters_layout) self.compforces_tool_layout.addStretch(1) self.compforces_tool_layout.addLayout(self.cfces_buttons_layout) self.compforces_tool_layout.addWidget(self.moment_group_box) self.compforces_tool_layout.addLayout(self.cfces_plot_layout) self.compforces_tool_layout.addLayout(self.cfces_csv_layout) self.setLayout(self.compforces_tool_layout) self.cfces_onlyprocess_selector.currentIndexChanged.connect( self.on_cfces_onlyprocess_changed) self.cfces_export_button.clicked.connect(self.on_cfces_export) self.cfces_cancel_button.clicked.connect(self.on_cfces_cancel) self.exec_()
def __init__(self, irreg_wave_gen, parent=None): if not isinstance(irreg_wave_gen, IrregularFlapWaveGen): raise TypeError( "You tried to spawn an irregular flap wave generator " "motion widget in the timeline with a wrong object") if irreg_wave_gen is None: raise TypeError( "You tried to spawn an irregular flap wave generator " "motion widget in the timeline without a motion object") super().__init__(parent=parent) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setContentsMargins(10, 10, 10, 10) self.root_label = QtGui.QLabel( __("Irregular flap wave generator (Flap)")) self.duration_label = QtGui.QLabel(__("Duration")) self.duration_input = QtGui.QLineEdit() self.wave_order_label = QtGui.QLabel(__("Wave Order")) self.wave_order_selector = QtGui.QComboBox() self.wave_order_selector.insertItems( 0, [__("1st Order"), __("2nd Order")]) self.depth_label = QtGui.QLabel(__("Depth (m): ")) self.depth_input = QtGui.QLineEdit() self.flap_axis_0_label = QtGui.QLabel(__("Flap axis 0 (X, Y, Z): ")) self.flap_axis_0_x = QtGui.QLineEdit() self.flap_axis_0_y = QtGui.QLineEdit() self.flap_axis_0_z = QtGui.QLineEdit() self.flap_axis_1_label = QtGui.QLabel(__("Flap axis 1 (X, Y, Z): ")) self.flap_axis_1_x = QtGui.QLineEdit() self.flap_axis_1_y = QtGui.QLineEdit() self.flap_axis_1_z = QtGui.QLineEdit() self.wave_height_label = QtGui.QLabel(__("Wave height (m): ")) self.wave_height_input = QtGui.QLineEdit() self.wave_period_label = QtGui.QLabel(__("Wave period (s): ")) self.wave_period_input = QtGui.QLineEdit() self.variable_draft_label = QtGui.QLabel(__("Variable Draft (m): ")) self.variable_draft_input = QtGui.QLineEdit() self.spectrum_label = QtGui.QLabel(__("Spectrum")) self.spectrum_selector = QtGui.QComboBox() # Index numbers match IrregularSpectrum static values self.spectrum_selector.insertItems(0, ["Jonswap", "Pierson-Moskowitz"]) self.discretization_label = QtGui.QLabel(__("Discretization")) self.discretization_selector = QtGui.QComboBox() # Index numbers match IrregularDiscretization static values self.discretization_selector.insertItems( 0, ["Regular", "Random", "Stretched", "Crosstreched"]) self.peak_coef_label = QtGui.QLabel(__("Peak Coeff")) self.peak_coef_input = QtGui.QLineEdit() self.waves_label = QtGui.QLabel(__("Number of waves")) self.waves_input = QtGui.QLineEdit() self.randomseed_label = QtGui.QLabel(__("Random Seed")) self.randomseed_input = QtGui.QLineEdit() self.serieini_label = QtGui.QLabel( __("Initial time in wave serie (s): ")) self.serieini_input = QtGui.QLineEdit() self.serieini_autofit = QtGui.QCheckBox("Auto fit") self.ramptime_label = QtGui.QLabel(__("Time of ramp (s): ")) self.ramptime_input = QtGui.QLineEdit() self.savemotion_label = QtGui.QLabel(__("Motion saving > ")) self.savemotion_time_input = QtGui.QLineEdit() self.savemotion_time_label = QtGui.QLabel(__("Time (s): ")) self.savemotion_timedt_input = QtGui.QLineEdit() self.savemotion_timedt_label = QtGui.QLabel(__("DT Time (s): ")) self.savemotion_xpos_input = QtGui.QLineEdit() self.savemotion_xpos_label = QtGui.QLabel(__("X Pos (m): ")) self.savemotion_zpos_input = QtGui.QLineEdit() self.savemotion_zpos_label = QtGui.QLabel(__("Z Pos (m): ")) self.saveserie_label = QtGui.QLabel(__("Save serie > ")) self.saveserie_timemin_input = QtGui.QLineEdit() self.saveserie_timemin_label = QtGui.QLabel(__("Min. Time (s): ")) self.saveserie_timemax_input = QtGui.QLineEdit() self.saveserie_timemax_label = QtGui.QLabel(__("Max. Time (s): ")) self.saveserie_timedt_input = QtGui.QLineEdit() self.saveserie_timedt_label = QtGui.QLabel(__("DT Time (s): ")) self.saveserie_xpos_input = QtGui.QLineEdit() self.saveserie_xpos_label = QtGui.QLabel(__("X Pos (m): ")) self.saveseriewaves_label = QtGui.QLabel(__("Save serie waves > ")) self.saveseriewaves_timemin_input = QtGui.QLineEdit() self.saveseriewaves_timemin_label = QtGui.QLabel(__("Min. Time (s): ")) self.saveseriewaves_timemax_input = QtGui.QLineEdit() self.saveseriewaves_timemax_label = QtGui.QLabel(__("Max. Time (s): ")) self.saveseriewaves_xpos_input = QtGui.QLineEdit() self.saveseriewaves_xpos_label = QtGui.QLabel(__("X Pos (m): ")) self.root_layout = QtGui.QHBoxLayout() self.root_layout.addWidget(self.root_label) self.root_layout.addStretch(1) for x in [self.duration_label, self.duration_input]: self.root_layout.addWidget(x) self.first_row_layout = QtGui.QHBoxLayout() for x in [ self.wave_order_label, self.wave_order_selector, self.depth_label, self.depth_input ]: self.first_row_layout.addWidget(x) self.second_row_layout = QtGui.QHBoxLayout() for x in [ self.flap_axis_0_label, self.flap_axis_0_x, self.flap_axis_0_y, self.flap_axis_0_z ]: self.second_row_layout.addWidget(x) self.third_row_layout = QtGui.QHBoxLayout() for x in [ self.flap_axis_1_label, self.flap_axis_1_x, self.flap_axis_1_y, self.flap_axis_1_z ]: self.third_row_layout.addWidget(x) self.fourth_row_layout = QtGui.QHBoxLayout() for x in [ self.wave_height_label, self.wave_height_input, self.wave_period_label, self.wave_period_input, self.variable_draft_label, self.variable_draft_input ]: self.fourth_row_layout.addWidget(x) self.fifth_row_layout = QtGui.QHBoxLayout() for x in [ self.spectrum_label, self.spectrum_selector, self.discretization_label, self.discretization_selector, self.peak_coef_label, self.peak_coef_input ]: self.fifth_row_layout.addWidget(x) self.sixth_row_layout = QtGui.QHBoxLayout() for x in [ self.waves_label, self.waves_input, self.randomseed_label, self.randomseed_input ]: self.sixth_row_layout.addWidget(x) self.seventh_row_layout = QtGui.QHBoxLayout() for x in [ self.serieini_label, self.serieini_input, self.serieini_autofit ]: self.seventh_row_layout.addWidget(x) self.eighth_row_layout = QtGui.QHBoxLayout() for x in [self.ramptime_label, self.ramptime_input]: self.eighth_row_layout.addWidget(x) self.ninth_row_layout = QtGui.QHBoxLayout() for x in [ self.savemotion_label, self.savemotion_time_label, self.savemotion_time_input, self.savemotion_timedt_label, self.savemotion_timedt_input, self.savemotion_xpos_label, self.savemotion_xpos_input, self.savemotion_zpos_label, self.savemotion_zpos_input ]: self.ninth_row_layout.addWidget(x) self.tenth_row_layout = QtGui.QHBoxLayout() for x in [ self.saveserie_label, self.saveserie_timemin_label, self.saveserie_timemin_input, self.saveserie_timemax_label, self.saveserie_timemax_input, self.saveserie_timedt_label, self.saveserie_timedt_input, self.saveserie_xpos_label, self.saveserie_xpos_input ]: self.tenth_row_layout.addWidget(x) self.eleventh_row_layout = QtGui.QHBoxLayout() for x in [ self.saveseriewaves_label, self.saveseriewaves_timemin_label, self.saveseriewaves_timemin_input, self.saveseriewaves_timemax_label, self.saveseriewaves_timemax_input, self.saveseriewaves_xpos_label, self.saveseriewaves_xpos_input ]: self.eleventh_row_layout.addWidget(x) self.main_layout.addLayout(self.root_layout) self.main_layout.addWidget(h_line_generator()) for x in [ self.first_row_layout, self.second_row_layout, self.third_row_layout, self.fourth_row_layout, self.fifth_row_layout, self.sixth_row_layout, self.seventh_row_layout, self.eighth_row_layout, self.ninth_row_layout, self.tenth_row_layout, self.eleventh_row_layout ]: self.main_layout.addLayout(x) self.setLayout(self.main_layout) self.fill_values(irreg_wave_gen) self._init_connections()
def on_multilayeredmb_menu(self, action): """ Defines MLPiston menu behaviour""" # Get currently selected object try: selection = FreeCADGui.Selection.getSelection()[0] except IndexError: error_dialog(__("You must select an object")) return # Check if object is in the simulation if not Case.the().is_object_in_simulation(selection.Name): error_dialog( __("The selected object must be added to the simulation")) return # Check if it is fluid and warn the user. if Case.the().get_simulation_object( selection.Name).type == ObjectType.FLUID: error_dialog( __("You can't apply a piston movement to a fluid.\nPlease select a boundary and try again" )) return # Get selection mk selection_obj = Case.the().get_simulation_object(selection.Name) selection_mk: int = selection_obj.obj_mk mk_properties: MKBasedProperties = Case.the().get_mk_based_properties( selection_obj.type, selection_mk) # Check that this mk has no other motions applied if mk_properties.has_movements(): # MK has motions applied. Warn the user and delete them motion_delete_warning = ok_cancel_dialog( APP_NAME, __("This mk already has motions applied. Setting a Multi-layered piston will delete all of its movement. Are you sure?" )) if motion_delete_warning == QtGui.QMessageBox.Cancel: return mk_properties.remove_all_movements() # 1D or 2D piston if __("1 Dimension") in action.text(): if mk_properties.mlayerpiston and not isinstance( mk_properties.mlayerpiston, MLPiston1D): overwrite_warn = ok_cancel_dialog( APP_NAME, __("You're about to overwrite a previous coupling movement for this mk. Are you sure?" )) if overwrite_warn == QtGui.QMessageBox.Cancel: return config_dialog = MLPiston1DConfigDialog(selection_mk, mk_properties.mlayerpiston, parent=get_fc_main_window()) if config_dialog.result() == QtGui.QDialog.Accepted: warning_dialog( __("All changes have been applied for mk = {}").format( selection_mk)) mk_properties.mlayerpiston = config_dialog.mlpiston1d if __("2 Dimensions") in action.text(): # Check that there's no other multilayered piston for this mk if mk_properties.mlayerpiston and not isinstance( mk_properties.mlayerpiston, MLPiston2D): overwrite_warn = ok_cancel_dialog( APP_NAME, __("You're about to overwrite a previous coupling movement for this mk. Are you sure?" )) if overwrite_warn == QtGui.QMessageBox.Cancel: return config_dialog = MLPiston2DConfigDialog(selection_mk, mk_properties.mlayerpiston, parent=get_fc_main_window()) if config_dialog.result() == QtGui.QDialog.Accepted: warning_dialog( __("All changes have been applied for mk = {}").format( selection_mk)) mk_properties.mlayerpiston = config_dialog.mlpiston2d self.accept()
def on_ok(self): """ Saves the material data and closes the dialog. """ info_dialog(__("This will apply the motion properties to all objects with mkbound = ") + str(self.target_object.obj_mk)) self.target_mkbasedproperties.property = None if self.material_combo.currentIndex() == 0 else Case.the().info.global_materials[self.material_combo.currentIndex() - 1] self.accept()