def on_export_finished(exit_code): """ Closes and displays info/error about the process. """ post_processing_widget.adapt_to_export_finished() export_dialog.accept() detailed_text = "The executed command line was: {} {}\n\n{}".format( case.executable_paths.partvtk, " ".join(executable_parameters), case.info.current_output) if not exit_code: info_dialog(info_text=__("PartVTK finished successfully"), detailed_text=detailed_text) else: error_dialog(__( "There was an error on the post-processing. Show details to view the errors." ), detailed_text=detailed_text) if options["open_paraview"]: subprocess.Popen([ case.executable_paths.paraview, "--data={}\\{}\\{}_..{}".format( case.get_out_folder_path(), options["file_name"], options["file_name"], save_extension) ], stdout=subprocess.PIPE)
def on_ok(self): """ Composes floating options and saves them into the appropriate data structure. """ info_dialog(__("This will apply the floating properties to all objects with mkbound = ") + str(self.target_mk)) if self.is_floating_selector.currentIndex() == 1: # Remove Floating Case.the().get_mk_based_properties(ObjectType.BOUND, self.target_mk).float_property = None self.accept() return # Floating is true fp = FloatProperty() # FloatProperty to be inserted fp.mk = self.target_mk fp.mass_density_type = self.floating_props_massrhop_selector.currentIndex() fp.mass_density_value = float(self.floating_props_massrhop_input.text()) fp.gravity_center = list() if self.floating_center_auto.isChecked() else [float(self.floating_center_input_x.text()), float(self.floating_center_input_y.text()), float(self.floating_center_input_z.text())] fp.inertia = list() if self.floating_inertia_auto.isChecked() else [float(self.floating_inertia_input_x.text()), float(self.floating_inertia_input_y.text()), float(self.floating_inertia_input_z.text())] fp.initial_linear_velocity = list() if self.floating_velini_auto.isChecked() else [float(self.floating_velini_input_x.text()), float(self.floating_velini_input_y.text()), float(self.floating_velini_input_z.text())] fp.initial_angular_velocity = list() if self.floating_omegaini_auto.isChecked() else [float(self.floating_omegaini_input_x.text()), float(self.floating_omegaini_input_y.text()), float(self.floating_omegaini_input_z.text())] fp.translation_restriction = list() if self.floating_translation_auto.isChecked() else [int(self.floating_translation_input_x.currentIndex()), int(self.floating_translation_input_y.currentIndex()), int(self.floating_translation_input_z.currentIndex())] fp.rotation_restriction = list() if self.floating_rotation_auto.isChecked() else [int(self.floating_rotation_input_x.currentIndex()), int(self.floating_rotation_input_y.currentIndex()), int(self.floating_rotation_input_z.currentIndex())] fp.material = "" if self.floating_material_auto.isChecked() else str(self.floating_material_line_edit.text()) Case.the().get_mk_based_properties(ObjectType.BOUND, self.target_mk).float_property = fp self.accept()
def on_ok(self): """ Saves the dialog settings on the data structure. """ info_dialog( __("This will apply the initials properties to all objects with mkfluid = " ) + str(self.target_mk)) if self.has_initials_selector.currentIndex() == 1: # Initials false Case.the().get_mk_based_properties(ObjectType.FLUID, self.target_mk).initials = None else: # Initials true # Structure: InitialsProperty Object force_vector: list = [ float(self.initials_vector_input_x.text()), float(self.initials_vector_input_y.text()), float(self.initials_vector_input_z.text()) ] Case.the().get_mk_based_properties( ObjectType.FLUID, self.target_mk).initials = InitialsProperty( mk=self.target_mk, force=force_vector, initials_type=self.initials_type_selector.currentIndex(), v1=float(self.initials_velocities_v1_input.text()), v2=float(self.initials_velocities_v2_input.text()), v3=float(self.initials_velocities_v3_input.text()), z1=float(self.initials_velocities_z1_input.text()), z2=float(self.initials_velocities_z2_input.text()), z3=float(self.initials_velocities_z3_input.text())) 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()
def on_export_finished(exit_code): """ Closes and displays info/error about the process. """ post_processing_widget.adapt_to_export_finished() export_dialog.accept() detailed_text = "The executed command line was: {} {}\n\n{}".format(case.executable_paths.flowtool, " ".join(executable_parameters), case.info.current_output) if not exit_code: info_dialog(info_text=__("FlowTool finished successfully"), detailed_text=detailed_text) else: error_dialog(__("There was an error on the post-processing. Show details to view the errors."), detailed_text=detailed_text)
def on_ok(self): """ Applies the current dialog data on the data structure. """ info_dialog( __("This will apply the motion properties to all objects with mkbound = " ) + str(self.target_mk)) if self.has_motion_selector.currentIndex() == 0: # True has been selected # Reinstance the list and copy every movement selected to avoid referencing problems. self.mkbasedproperties.movements = list() for movement in self.movements_selected: self.mkbasedproperties.movements.append(movement) elif self.has_motion_selector.currentIndex() == 1: # False has been selected self.mkbasedproperties.movements = list() self.accept()
def on_export_finished(exit_code): """ Closes and displays info/error about the process. """ post_processing_widget.adapt_to_export_finished() export_dialog.accept() detailed_text = "The executed command line was: {} {}\n\n{}".format( case.custom.mksmixing, " ".join(executable_parameters), case.info.current_output) if not exit_code: info_dialog(info_text=__("MKsMixing finished successfully"), detailed_text=detailed_text) if case.custom.mksmixing_plot: MKsMixingPlotDialog( parent=post_processing_widget, paths=[ "{out_path}{file_name}.csv".format( out_path=case.get_out_folder_path(), file_name="MKsMixing") ])
def boot(): """ Boots the application. """ print_license() check_compatibility() try: master_branch_version = str( urlopen(GITHUB_MASTER_CONSTANTS_URL).read()).split( "VERSION = \"")[-1].split("\"")[0] if VERSION < master_branch_version and NOTIFY_ON_OUTDATED_VERSION: info_dialog( __("Your version of DesignSPHyiscs is outdated. Please go to the Addon Manager and update it. New versions include bug fixes, new features and new DualSPHysics executables, among other things." ), __("The version you're using is {} while the version that you can update to is {}" ).format(VERSION, master_branch_version)) except URLError: log("No network connection or Git repo is down. Skipping version check." ) if document_count() > 0: success = prompt_close_all_documents() if not success: debug( "User chose not to close the currently opened documents. Aborting startup" ) quit() # Tries to delete docks created by a previous execution of DesignSPHysics delete_existing_docks() designsphysics_dock = DesignSPHysicsDock(get_fc_main_window()) properties_widget = PropertiesDockWidget(parent=get_fc_main_window()) get_fc_main_window().addDockWidget(QtCore.Qt.RightDockWidgetArea, designsphysics_dock) get_fc_main_window().addDockWidget(QtCore.Qt.LeftDockWidgetArea, properties_widget) # Subscribe the FreeCAD Objects tree to the item selection change function. # This helps FreeCAD notify DesignSPHysics for the deleted and changed objects to get updated correctly. fc_object_tree: QtGui.QTreeWidget = get_fc_main_window().findChildren( QtGui.QSplitter)[0].findChildren(QtGui.QTreeWidget)[0] fc_object_tree.itemSelectionChanged.connect( lambda p=properties_widget, d=designsphysics_dock: on_tree_item_selection_change(p, d)) debug( "Subscribing selection change monitor handler to freecad object tree item changed." ) properties_widget.need_refresh.connect( lambda p=properties_widget, d=designsphysics_dock: on_tree_item_selection_change(p, d)) designsphysics_dock.need_refresh.connect( lambda p=properties_widget, d=designsphysics_dock: on_tree_item_selection_change(p, d)) # Launch a monitor thread that ensures some things are not changed. monitor_thread = threading.Thread( target=lambda p=properties_widget, d=designsphysics_dock: selection_monitor(p, d)) monitor_thread.start() FreeCADGui.activateWorkbench(DEFAULT_WORKBENCH) log(__("Initialization finished for {} v{}").format(APP_NAME, VERSION))