def __init__(self, index, rect_motion, parent=None): if not isinstance(rect_motion, RectMotion): raise TypeError( "You tried to spawn a rectilinear motion widget in the timeline with a wrong object" ) if rect_motion is None: raise TypeError( "You tried to spawn a rectilinear 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("Rectilinear \nMotion ") self.label.setMinimumWidth(75) 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.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.addWidget(self.velocity_label) self.main_layout.addWidget(self.x_input) self.main_layout.addWidget(self.y_input) self.main_layout.addWidget(self.z_input) 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(rect_motion) self._init_connections()
def __init__(self, line_id, row): super().__init__() self.setContentsMargins(0, 0, 0, 0) self.root_layout: QtGui.QHBoxLayout = QtGui.QHBoxLayout() self.root_layout.setContentsMargins(5, 1, 5, 1) self.line_id = line_id self.row = row self.label: QtGui.QLabel = QtGui.QLabel("Line {}".format(self.line_id)) self.configure_button: QtGui.QPushButton = QtGui.QPushButton( __("Configure")) self.delete_button = QtGui.QPushButton(get_icon("trash.png"), None) self.root_layout.addWidget(self.label) self.root_layout.addStretch(1) self.root_layout.addWidget(self.configure_button) self.root_layout.addWidget(self.delete_button) self.configure_button.clicked.connect( lambda _=False, line_id=self.line_id: self.configure_clicked.emit( line_id)) self.delete_button.clicked.connect( lambda _=False, line_id=self.line_id: self.delete_clicked.emit( line_id)) self.setLayout(self.root_layout)
def __init__(self, parent=None): super().__init__(parent=parent) self.main_layout = QtGui.QHBoxLayout() self.main_layout.setSpacing(0) self.main_layout.setContentsMargins(0, 0, 0, 0) self.logo_label = QtGui.QLabel() self.logo_label.setPixmap( get_icon(file_name="logo.png", return_only_path=True)) self.help_button = QtGui.QPushButton("Help") self.help_button.setToolTip( __("Push this button to open a browser with help\non how to use this tool." )) self.help_button.setIcon(QtGui.QIcon.fromTheme("system-help")) self.help_button.clicked.connect( lambda: webbrowser.open(HelpURL.WIKI_HOME)) self.main_layout.addStretch(0.5) self.main_layout.addWidget(self.logo_label) self.main_layout.addStretch(0.5) self.main_layout.addWidget(self.help_button) self.setLayout(self.main_layout)
def __init__(self, index=999, object_name="No name", object_mk=-1, mktype="bound", up_disabled=False, down_disabled=False, parent=None): super().__init__(parent=parent) self.index = index self.object_name = object_name self.parent = parent self.main_layout = QtGui.QHBoxLayout() self.main_layout.setContentsMargins(10, 0, 10, 0) self.mk_label = QtGui.QLabel("<b>{}{}</b>".format( mktype[0].upper(), str(object_mk))) self.name_label = QtGui.QLabel(str(object_name)) self.up_button = QtGui.QPushButton(get_icon("up_arrow.png"), None) self.up_button.clicked.connect(self.on_up) self.down_button = QtGui.QPushButton(get_icon("down_arrow.png"), None) self.down_button.clicked.connect(self.on_down) self.main_layout.addWidget(self.mk_label) self.main_layout.addWidget(self.name_label) self.main_layout.addStretch(1) self.main_layout.addWidget(self.up_button) self.main_layout.addWidget(self.down_button) self.up_button.setEnabled(not up_disabled) self.down_button.setEnabled(not down_disabled) self.setLayout(self.main_layout) self.setToolTip("MK: {} ({})\n" "Name: {}\n" "{}".format(object_mk, mktype.lower().title(), object_name, __("Press up or down to reorder.")))
def __init__(self, index, use_checked, parent=None): super().__init__(parent=parent) self.index = index self.use_checkbox = QtGui.QCheckBox(__("Use")) self.use_checkbox.setChecked(use_checked) self.use_checkbox.stateChanged.connect(self.on_use) self.delete_button = QtGui.QPushButton(get_icon("trash.png"), None) self.delete_button.clicked.connect(self.on_delete) self.main_layout = QtGui.QHBoxLayout() self.main_layout.setContentsMargins(10, 0, 10, 0) self.main_layout.addWidget(self.use_checkbox) self.main_layout.addWidget(self.delete_button) self.setLayout(self.main_layout)
def __init__(self, parent=None): super().__init__(parent=parent) # Execution section scaffolding self.main_layout = QtGui.QVBoxLayout() self.main_layout.setContentsMargins(0, 0, 0, 0) self.title_label = QtGui.QLabel("<b>" + __("Simulation control") + "</b> ") self.title_label.setWordWrap(True) # Combobox for processor selection self.device_selector = QtGui.QComboBox() self.device_selector.addItem("CPU") self.device_selector.addItem("GPU") # Simulate case button self.execute_button = QtGui.QPushButton(__("Run")) self.execute_button.setStyleSheet("QPushButton {font-weight: bold; }") self.execute_button.setToolTip( __("Starts the case simulation. From the simulation\n" "window you can see the current progress and\n" "useful information.")) self.execute_button.setIcon(get_icon("run.png")) self.execute_button.setIconSize(QtCore.QSize(12, 12)) self.execute_button.clicked.connect(self.on_ex_simulate) # Additional parameters button self.additional_parameters_button = QtGui.QPushButton( __("Additional parameters")) self.additional_parameters_button.setToolTip( "__(Sets simulation additional parameters for execution.)") self.additional_parameters_button.clicked.connect( self.on_additional_parameters) self.button_layout = QtGui.QHBoxLayout() self.button_layout.addWidget(self.execute_button) self.button_layout.addWidget(self.device_selector) self.button_layout.addWidget(self.additional_parameters_button) self.main_layout.addWidget(self.title_label) self.main_layout.addLayout(self.button_layout) self.setLayout(self.main_layout)
def __init__(self, parent=None): super().__init__(parent=parent) self.currently_selected_movement = None self.setMinimumSize(1400, 650) self.setWindowTitle(__("Motion configuration")) self.ok_button = QtGui.QPushButton(__("Ok")) self.cancel_button = QtGui.QPushButton(__("Cancel")) self.notice_label = QtGui.QLabel("") self.notice_label.setStyleSheet("QLabel { color : red; }") self.target_mk = Case.the().get_simulation_object( FreeCADGui.Selection.getSelection()[0].Name).obj_mk self.mkbasedproperties = Case.the().get_mk_based_properties( ObjectType.BOUND, self.target_mk) self.movements_selected = self.mkbasedproperties.movements self.ok_button.clicked.connect(self.on_ok) self.cancel_button.clicked.connect(self.on_cancel) self.has_motion_layout = QtGui.QHBoxLayout() self.has_motion_label = QtGui.QLabel(__("Set motion: ")) self.has_motion_label.setToolTip( __("Enables motion for the selected MKBound")) self.has_motion_selector = QtGui.QComboBox() self.has_motion_selector.insertItems(0, ["True", "False"]) self.has_motion_selector.currentIndexChanged.connect( self.on_motion_change) ############################################################################## self.create_new_movement_button = QtGui.QToolButton() self.create_new_movement_button.setPopupMode( QtGui.QToolButton.MenuButtonPopup) self.create_new_movement_button.setText(" {}".format(__("Create New"))) self.create_new_movement_menu = QtGui.QMenu() self.create_new_movement_menu.addAction(get_icon("movement.png"), __("Movement")) self.create_new_movement_menu.addAction( get_icon("regular_wave.png"), __("Regular wave generator (Piston)")) self.create_new_movement_menu.addAction( get_icon("irregular_wave.png"), __("Irregular wave generator (Piston)")) self.create_new_movement_menu.addAction( get_icon("regular_wave.png"), __("Regular wave generator (Flap)")) self.create_new_movement_menu.addAction( get_icon("irregular_wave.png"), __("Irregular wave generator (Flap)")) self.create_new_movement_menu.addAction( get_icon("file_mov.png"), __("Linear motion from a file")) self.create_new_movement_menu.addAction(get_icon("file_mov.png"), __("Rotation from a file")) self.create_new_movement_button.setMenu(self.create_new_movement_menu) ############################################################################## self.has_motion_helplabel = QtGui.QLabel("<a href='{}'>{}</a>".format( HelpURL.MOTION_HELP, __("Movement Help"))) self.has_motion_helplabel.setTextFormat(QtCore.Qt.RichText) self.has_motion_helplabel.setTextInteractionFlags( QtCore.Qt.TextBrowserInteraction) self.has_motion_helplabel.setOpenExternalLinks(True) self.has_motion_targetlabel = QtGui.QLabel( __("Target MKBound: ") + str(self.target_mk)) self.has_motion_layout.addWidget(self.has_motion_label) self.has_motion_layout.addWidget(self.has_motion_selector) self.has_motion_layout.addStretch(1) self.has_motion_layout.addWidget(self.has_motion_helplabel) self.has_motion_layout.addWidget(self.has_motion_targetlabel) self.motion_features_layout = QtGui.QVBoxLayout() self.motion_features_splitter = QtGui.QSplitter() self.movement_list_groupbox = QtGui.QGroupBox(__("Global Movements")) self.movement_list_groupbox_layout = QtGui.QVBoxLayout() self.movement_list_table = QtGui.QTableWidget(1, 2) self.movement_list_table.setSelectionBehavior( QtGui.QAbstractItemView.SelectItems) self.movement_list_table.setSelectionMode( QtGui.QAbstractItemView.SingleSelection) self.movement_list_table.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.movement_list_table.horizontalHeader().setResizeMode( 0, QtGui.QHeaderView.Stretch) self.movement_list_table.horizontalHeader().setResizeMode( 1, QtGui.QHeaderView.ResizeToContents) self.movement_list_table.verticalHeader().setVisible(False) self.movement_list_table.horizontalHeader().setVisible(False) self.movement_list_groupbox_layout.addWidget( self.create_new_movement_button) self.movement_list_groupbox_layout.addWidget(self.movement_list_table) self.movement_list_groupbox.setLayout( self.movement_list_groupbox_layout) self.timeline_groupbox = QtGui.QGroupBox( __("Timeline for the selected movement")) self.timeline_groupbox_layout = QtGui.QVBoxLayout() self.timeline_list_table = QtGui.QTableWidget(0, 1) self.timeline_list_table.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.timeline_list_table.verticalHeader().setResizeMode( QtGui.QHeaderView.ResizeToContents) self.timeline_list_table.verticalHeader().setVisible(False) self.timeline_list_table.horizontalHeader().setVisible(False) self.timeline_list_table.resizeRowsToContents() self.timeline_groupbox_layout.addWidget(self.timeline_list_table) self.timeline_groupbox.setLayout(self.timeline_groupbox_layout) self.actions_groupbox = QtGui.QGroupBox(__("Available actions")) self.actions_groupbox_layout = QtGui.QVBoxLayout() self.actions_groupbox_table = QtGui.QTableWidget(0, 1) self.actions_groupbox_table.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.actions_groupbox_table.verticalHeader().setVisible(False) self.actions_groupbox_table.horizontalHeader().setVisible(False) self.actions_groupbox_layout.addWidget(self.actions_groupbox_table) self.actions_groupbox.setLayout(self.actions_groupbox_layout) self.motion_features_splitter.addWidget(self.movement_list_groupbox) self.motion_features_splitter.addWidget(self.timeline_groupbox) self.motion_features_splitter.addWidget(self.actions_groupbox) self.motion_features_splitter.setSizePolicy( QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.motion_features_layout.addWidget(self.motion_features_splitter) self.buttons_layout = QtGui.QHBoxLayout() self.buttons_layout.addWidget(self.notice_label) self.buttons_layout.addStretch(1) self.buttons_layout.addWidget(self.ok_button) self.buttons_layout.addWidget(self.cancel_button) self.motion_window_layout = QtGui.QVBoxLayout() self.motion_window_layout.addLayout(self.has_motion_layout) self.motion_window_layout.addLayout(self.motion_features_layout) self.motion_window_layout.addLayout(self.buttons_layout) self.setLayout(self.motion_window_layout) self.refresh_movements_table() self.movement_list_table.cellChanged.connect( self.on_movement_name_change) self.movement_list_table.cellClicked.connect(self.on_movement_selected) self.actions_groupbox_table.setRowCount(9) self.bt_to_add = QtGui.QPushButton(get_icon("left-arrow.png"), __("Add a delay")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_delay) self.actions_groupbox_table.setCellWidget(0, 0, self.bt_to_add) self.bt_to_add = QtGui.QPushButton(get_icon("left-arrow.png"), __("Add a rectilinear motion")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_rectilinear) self.actions_groupbox_table.setCellWidget(1, 0, self.bt_to_add) self.bt_to_add = QtGui.QPushButton( get_icon("left-arrow.png"), __("Add an accelerated rectilinear motion")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_accrectilinear) self.actions_groupbox_table.setCellWidget(2, 0, self.bt_to_add) self.bt_to_add = QtGui.QPushButton(get_icon("left-arrow.png"), __("Add a rotational motion")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_rotational) self.actions_groupbox_table.setCellWidget(3, 0, self.bt_to_add) self.bt_to_add = QtGui.QPushButton( get_icon("left-arrow.png"), __("Add an accelerated rotational motion")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_acc_rotational) self.actions_groupbox_table.setCellWidget(4, 0, self.bt_to_add) self.bt_to_add = QtGui.QPushButton( get_icon("left-arrow.png"), __("Add an accelerated circular motion")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_acc_circular) self.actions_groupbox_table.setCellWidget(5, 0, self.bt_to_add) self.bt_to_add = QtGui.QPushButton( get_icon("left-arrow.png"), __("Add a sinusoidal rotational motion")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_sinu_rot) self.actions_groupbox_table.setCellWidget(6, 0, self.bt_to_add) self.bt_to_add = QtGui.QPushButton( get_icon("left-arrow.png"), __("Add a sinusoidal circular motion")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_sinu_cir) self.actions_groupbox_table.setCellWidget(7, 0, self.bt_to_add) self.bt_to_add = QtGui.QPushButton( get_icon("left-arrow.png"), __("Add a sinusoidal rectilinear motion")) self.bt_to_add.setStyleSheet("text-align: left") self.bt_to_add.clicked.connect(self.on_add_sinu_rect) self.actions_groupbox_table.setCellWidget(8, 0, self.bt_to_add) # Set motion suscription for this mk self.has_motion_selector.setCurrentIndex( 0 if self.movements_selected else 1) self.exec_()
def __init__(self, index, acc_cir_motion, parent=None): if not isinstance(acc_cir_motion, AccCirMotion): raise TypeError( "You tried to spawn an accelerated circular " "motion widget in the timeline with a wrong object") if acc_cir_motion is None: raise TypeError( "You tried to spawn an accelerated circular " "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("Accelerated \nCircular \nMotion ") self.label.setMinimumWidth(75) self.vel_and_acc_layout = QtGui.QVBoxLayout() self.vel_layout = QtGui.QHBoxLayout() self.acc_layout = QtGui.QHBoxLayout() self.velocity_label = QtGui.QLabel("Vel: ") self.velocity_input = QtGui.QLineEdit() self.velocity_input.setStyleSheet("width: 5px;") self.acceleration_label = QtGui.QLabel("Acc: ") self.acceleration_input = QtGui.QLineEdit() self.acceleration_input.setStyleSheet("width: 5px;") 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.x1_input.setStyleSheet("width: 5px;") self.y1_input = QtGui.QLineEdit() self.y1_input.setStyleSheet("width: 5px;") self.z1_input = QtGui.QLineEdit() self.z1_input.setStyleSheet("width: 5px;") self.x2_input = QtGui.QLineEdit() self.x2_input.setStyleSheet("width: 5px;") self.y2_input = QtGui.QLineEdit() self.y2_input.setStyleSheet("width: 5px;") self.z2_input = QtGui.QLineEdit() self.z2_input.setStyleSheet("width: 5px;") self.reference_label = QtGui.QLabel("Ref (X, Y, Z): ") self.reference_x_input = QtGui.QLineEdit() self.reference_x_input.setStyleSheet("width: 5px;") self.reference_y_input = QtGui.QLineEdit() self.reference_y_input.setStyleSheet("width: 5px;") self.reference_z_input = QtGui.QLineEdit() self.reference_z_input.setStyleSheet("width: 5px;") 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.vel_layout.addWidget(self.velocity_label) self.vel_layout.addWidget(self.velocity_input) self.acc_layout.addWidget(self.acceleration_label) self.acc_layout.addWidget(self.acceleration_input) self.vel_and_acc_layout.addLayout(self.vel_layout) self.vel_and_acc_layout.addLayout(self.acc_layout) 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.vel_and_acc_layout) 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.addWidget(self.reference_label) self.main_layout.addWidget(self.reference_x_input) self.main_layout.addWidget(self.reference_y_input) self.main_layout.addWidget(self.reference_z_input) 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_cir_motion) self._init_connections()
def __init__(self, index, rect_sinu_motion, parent=None): if not isinstance(rect_sinu_motion, RectSinuMotion): raise TypeError( "You tried to spawn an accelerated circular motion widget in the timeline with a wrong object" ) if rect_sinu_motion is None: raise TypeError( "You tried to spawn an accelerated circular 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("Sinusoidal \nRectilinear \nMotion ") self.label.setMinimumWidth(75) self.freq_amp_layout = QtGui.QVBoxLayout() self.freq_amp_first_row_layout = QtGui.QHBoxLayout() self.freq_amp_second_row_layout = QtGui.QHBoxLayout() self.freq_label = QtGui.QLabel("Freq (X, Y, Z): ") self.amp_label = QtGui.QLabel("Amp (X, Y, Z): ") self.freq_x_input = QtGui.QLineEdit() self.freq_x_input.setStyleSheet("width: 5px;") self.freq_y_input = QtGui.QLineEdit() self.freq_y_input.setStyleSheet("width: 5px;") self.freq_z_input = QtGui.QLineEdit() self.freq_z_input.setStyleSheet("width: 5px;") self.amp_x_input = QtGui.QLineEdit() self.amp_x_input.setStyleSheet("width: 5px;") self.amp_y_input = QtGui.QLineEdit() self.amp_y_input.setStyleSheet("width: 5px;") self.amp_z_input = QtGui.QLineEdit() self.amp_z_input.setStyleSheet("width: 5px;") self.phase_label = QtGui.QLabel("Phase (X, Y, Z): ") self.phase_x_input = QtGui.QLineEdit() self.phase_x_input.setStyleSheet("width: 5px;") self.phase_y_input = QtGui.QLineEdit() self.phase_y_input.setStyleSheet("width: 5px;") self.phase_z_input = QtGui.QLineEdit() self.phase_z_input.setStyleSheet("width: 5px;") 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.freq_amp_first_row_layout.addWidget(self.freq_label) self.freq_amp_first_row_layout.addWidget(self.freq_x_input) self.freq_amp_first_row_layout.addWidget(self.freq_y_input) self.freq_amp_first_row_layout.addWidget(self.freq_z_input) self.freq_amp_second_row_layout.addWidget(self.amp_label) self.freq_amp_second_row_layout.addWidget(self.amp_x_input) self.freq_amp_second_row_layout.addWidget(self.amp_y_input) self.freq_amp_second_row_layout.addWidget(self.amp_z_input) self.freq_amp_layout.addLayout(self.freq_amp_first_row_layout) self.freq_amp_layout.addLayout(self.freq_amp_second_row_layout) self.main_layout.addLayout(self.freq_amp_layout) self.main_layout.addWidget(self.phase_label) self.main_layout.addWidget(self.phase_x_input) self.main_layout.addWidget(self.phase_y_input) self.main_layout.addWidget(self.phase_z_input) 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(rect_sinu_motion) self._init_connections()
def __init__(self, parent=None): super().__init__(parent=parent) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setContentsMargins(0, 0, 0, 0) self.label_layout = QtGui.QHBoxLayout() self.first_row_layout = QtGui.QHBoxLayout() self.second_row_layout = QtGui.QHBoxLayout() self.third_row_layout = QtGui.QHBoxLayout() self.fourth_row_layout = QtGui.QHBoxLayout() self.casecontrols_label = QtGui.QLabel("<b>{}</b>".format( __("Pre-processing"))) self.force_button = QtGui.QPushButton(__("Force Enable Panels")) self.force_button.setStyleSheet( "font-size: 8px; max-height: 10px; padding-bottom: 0; padding-top: 0; padding-left:2px; padding-right: 2px" ) self.new_case_button = QtGui.QToolButton() self.new_case_button.setPopupMode(QtGui.QToolButton.MenuButtonPopup) self.new_case_button.setToolButtonStyle( QtCore.Qt.ToolButtonTextBesideIcon) self.new_case_button.setText(" {}".format(__("New\n Case"))) self.new_case_button.setToolTip( __("Creates a new case. \nThe opened documents will be closed.")) self.new_case_button.setIcon( QtGui.QIcon.fromTheme("document-new", get_icon("new.png"))) self.new_case_button.setIconSize(QtCore.QSize(28, 28)) self.new_case_menu = QtGui.QMenu() self.new_case_menu.addAction( QtGui.QIcon.fromTheme("document-new", get_icon("new.png")), __("New")) self.new_case_menu.addAction( QtGui.QIcon.fromTheme("document-new", get_icon("new.png")), __("Import FreeCAD Document")) self.new_case_button.setMenu(self.new_case_menu) self.new_case_menu.resize(60, 60) self.save_button = QtGui.QToolButton() self.save_button.setPopupMode(QtGui.QToolButton.MenuButtonPopup) self.save_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.save_button.setText(" {}".format(__("Save\n Case"))) self.save_button.setToolTip(__("Saves the case.")) self.save_button.setIcon( QtGui.QIcon.fromTheme("document-save", get_icon("save.png"))) self.save_button.setIconSize(QtCore.QSize(28, 28)) self.save_menu = QtGui.QMenu() self.save_menu.addAction( QtGui.QIcon.fromTheme("document-save-as", get_icon("save.png")), __("Save as...")) self.save_button.setMenu(self.save_menu) self.load_button = QtGui.QToolButton() self.load_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.load_button.setText(" {}".format(__("Load\n Case"))) self.load_button.setToolTip( __("Loads a case from disk. All the current documents\nwill be closed." )) self.load_button.setIcon( QtGui.QIcon.fromTheme("document-open", get_icon("load.png"))) self.load_button.setIconSize(QtCore.QSize(28, 28)) self.add_fillbox_button = QtGui.QPushButton(__("Add fillbox")) self.add_fillbox_button.setToolTip( __("Adds a FillBox. A FillBox is able to fill an empty space\nwithin limits of geometry and a maximum bounding\nbox placed by the user." )) self.add_fillbox_button.setIcon(QtGui.QIcon.fromTheme("list-add")) self.add_geometry_button = QtGui.QPushButton("Import GEO") self.add_geometry_button.setToolTip( __("Imports a GEO object with postprocessing. This way you can set the scale of the imported object." )) self.add_geometry_button.setIcon(QtGui.QIcon.fromTheme("list-add")) self.import_xml_button = QtGui.QPushButton(__("Import XML")) self.import_xml_button.setToolTip( __("Imports an already created XML case from disk.")) self.case_summary_button = QtGui.QPushButton(__("Case summary")) self.case_summary_button.setToolTip( __("Shows a complete case summary with objects, configurations and settings in a brief view." )) self.case_summary_button.setIcon( QtGui.QIcon.fromTheme("document-properties")) self.toggle_2d_mode_button = QtGui.QPushButton(__("Change 3D/2D")) self.toggle_2d_mode_button.setToolTip( __("Changes the case mode between 2D and 3D mode, switching the Case Limits between a plane or a cube" )) self.toggle_2d_mode_button.setIcon( QtGui.QIcon.fromTheme("object-flip-horizontal")) self.special_button = QtGui.QPushButton(__("Special")) self.special_button.setToolTip(__("Special actions for the case.")) self.special_button.setIcon(QtGui.QIcon.fromTheme("window-new")) self.gencase_button = QtGui.QPushButton(__("Run GenCase")) self.gencase_button.setStyleSheet("QPushButton {font-weight: bold; }") self.gencase_button.setToolTip( __("This pre-processing tool creates the initial state of the particles (position, velocity and density) and defines the different SPH parameters for the simulation." )) self.gencase_button.setIcon(get_icon("run_gencase.png")) self.gencase_button.setIconSize(QtCore.QSize(12, 12)) self.force_button.clicked.connect(self.on_force_button) self.new_case_button.clicked.connect(lambda: self.on_new_case(True)) self.save_button.clicked.connect(self.on_save_case) self.gencase_button.clicked.connect(self.on_execute_gencase) self.new_case_menu.triggered.connect(self.on_newdoc_menu) self.save_menu.triggered.connect(self.on_save_menu) self.load_button.clicked.connect(self.on_load_button) self.add_fillbox_button.clicked.connect(self.on_add_fillbox) self.add_geometry_button.clicked.connect(self.on_add_geo) self.import_xml_button.clicked.connect(lambda: error_dialog( "XML Import is not available in this version.")) self.case_summary_button.clicked.connect(CaseSummary) self.toggle_2d_mode_button.clicked.connect(self.on_2d_toggle) self.special_button.clicked.connect(SpecialOptionsSelectorDialog) self.label_layout.addWidget(self.casecontrols_label) self.label_layout.addStretch(1) self.label_layout.addWidget(self.force_button) self.first_row_layout.addWidget(self.new_case_button) self.first_row_layout.addWidget(self.save_button) self.first_row_layout.addWidget(self.load_button) self.second_row_layout.addWidget(self.case_summary_button) self.second_row_layout.addWidget(self.toggle_2d_mode_button) self.third_row_layout.addWidget(self.add_fillbox_button) self.third_row_layout.addWidget(self.add_geometry_button) # self.third_row_layout.addWidget(self.import_xml_button) self.fourth_row_layout.addWidget(self.special_button) self.fourth_row_layout.addWidget(self.gencase_button) self.main_layout.addLayout(self.label_layout) self.main_layout.addLayout(self.first_row_layout) self.main_layout.addLayout(self.third_row_layout) self.main_layout.addLayout(self.second_row_layout) self.main_layout.addLayout(self.fourth_row_layout) self.setLayout(self.main_layout)
def __init__(self, box_id, parent=None): super().__init__(parent=parent) self.box_id = box_id self.box_edit_layout = QtGui.QVBoxLayout() # Find the box for which the button was pressed target_box = None for box in Case.the().flowtool_boxes: if box.id == self.box_id: target_box = box # This should not happen but if no box is found with reference id, it spawns an error. if target_box is None: error_dialog("There was an error opening the box to edit") return self.box_edit_name_layout = QtGui.QHBoxLayout() self.box_edit_name_label = QtGui.QLabel(__("Box Name")) self.box_edit_name_input = QtGui.QLineEdit(target_box.name) self.box_edit_name_layout.addWidget(self.box_edit_name_label) self.box_edit_name_layout.addWidget(self.box_edit_name_input) self.box_edit_description = QtGui.QLabel( __("Using multiple boxes with the same name will produce only one volume to measure.\n" "Use that to create prisms and complex forms. " "All points are specified in meters.")) self.box_edit_description.setAlignment(QtCore.Qt.AlignCenter) # Reference image self.box_edit_image = QtGui.QLabel() self.box_edit_image.setPixmap( get_icon("flowtool_template.jpg", return_only_path=True)) self.box_edit_image.setAlignment(QtCore.Qt.AlignCenter) # Point coords inputs self.box_edit_points_layout = QtGui.QVBoxLayout() self.box_edit_point_a_layout = QtGui.QHBoxLayout() self.box_edit_point_a_label = QtGui.QLabel(__("Point A (X, Y, Z)")) self.box_edit_point_a_x = QtGui.QLineEdit(str(target_box.point1[0])) self.box_edit_point_a_y = QtGui.QLineEdit(str(target_box.point1[1])) self.box_edit_point_a_z = QtGui.QLineEdit(str(target_box.point1[2])) self.box_edit_point_a_layout.addWidget(self.box_edit_point_a_label) self.box_edit_point_a_layout.addWidget(self.box_edit_point_a_x) self.box_edit_point_a_layout.addWidget(self.box_edit_point_a_y) self.box_edit_point_a_layout.addWidget(self.box_edit_point_a_z) self.box_edit_point_b_layout = QtGui.QHBoxLayout() self.box_edit_point_b_label = QtGui.QLabel(__("Point B (X, Y, Z)")) self.box_edit_point_b_x = QtGui.QLineEdit(str(target_box.point2[0])) self.box_edit_point_b_y = QtGui.QLineEdit(str(target_box.point2[1])) self.box_edit_point_b_z = QtGui.QLineEdit(str(target_box.point2[2])) self.box_edit_point_b_layout.addWidget(self.box_edit_point_b_label) self.box_edit_point_b_layout.addWidget(self.box_edit_point_b_x) self.box_edit_point_b_layout.addWidget(self.box_edit_point_b_y) self.box_edit_point_b_layout.addWidget(self.box_edit_point_b_z) self.box_edit_point_c_layout = QtGui.QHBoxLayout() self.box_edit_point_c_label = QtGui.QLabel(__("Point C (X, Y, Z)")) self.box_edit_point_c_x = QtGui.QLineEdit(str(target_box.point3[0])) self.box_edit_point_c_y = QtGui.QLineEdit(str(target_box.point3[1])) self.box_edit_point_c_z = QtGui.QLineEdit(str(target_box.point3[2])) self.box_edit_point_c_layout.addWidget(self.box_edit_point_c_label) self.box_edit_point_c_layout.addWidget(self.box_edit_point_c_x) self.box_edit_point_c_layout.addWidget(self.box_edit_point_c_y) self.box_edit_point_c_layout.addWidget(self.box_edit_point_c_z) self.box_edit_point_d_layout = QtGui.QHBoxLayout() self.box_edit_point_d_label = QtGui.QLabel(__("Point D (X, Y, Z)")) self.box_edit_point_d_x = QtGui.QLineEdit(str(target_box.point4[0])) self.box_edit_point_d_y = QtGui.QLineEdit(str(target_box.point4[1])) self.box_edit_point_d_z = QtGui.QLineEdit(str(target_box.point4[2])) self.box_edit_point_d_layout.addWidget(self.box_edit_point_d_label) self.box_edit_point_d_layout.addWidget(self.box_edit_point_d_x) self.box_edit_point_d_layout.addWidget(self.box_edit_point_d_y) self.box_edit_point_d_layout.addWidget(self.box_edit_point_d_z) self.box_edit_point_e_layout = QtGui.QHBoxLayout() self.box_edit_point_e_label = QtGui.QLabel(__("Point E (X, Y, Z)")) self.box_edit_point_e_x = QtGui.QLineEdit(str(target_box.point5[0])) self.box_edit_point_e_y = QtGui.QLineEdit(str(target_box.point5[1])) self.box_edit_point_e_z = QtGui.QLineEdit(str(target_box.point5[2])) self.box_edit_point_e_layout.addWidget(self.box_edit_point_e_label) self.box_edit_point_e_layout.addWidget(self.box_edit_point_e_x) self.box_edit_point_e_layout.addWidget(self.box_edit_point_e_y) self.box_edit_point_e_layout.addWidget(self.box_edit_point_e_z) self.box_edit_point_f_layout = QtGui.QHBoxLayout() self.box_edit_point_f_label = QtGui.QLabel(__("Point F (X, Y, Z)")) self.box_edit_point_f_x = QtGui.QLineEdit(str(target_box.point6[0])) self.box_edit_point_f_y = QtGui.QLineEdit(str(target_box.point6[1])) self.box_edit_point_f_z = QtGui.QLineEdit(str(target_box.point6[2])) self.box_edit_point_f_layout.addWidget(self.box_edit_point_f_label) self.box_edit_point_f_layout.addWidget(self.box_edit_point_f_x) self.box_edit_point_f_layout.addWidget(self.box_edit_point_f_y) self.box_edit_point_f_layout.addWidget(self.box_edit_point_f_z) self.box_edit_point_g_layout = QtGui.QHBoxLayout() self.box_edit_point_g_label = QtGui.QLabel(__("Point G (X, Y, Z)")) self.box_edit_point_g_x = QtGui.QLineEdit(str(target_box.point7[0])) self.box_edit_point_g_y = QtGui.QLineEdit(str(target_box.point7[1])) self.box_edit_point_g_z = QtGui.QLineEdit(str(target_box.point7[2])) self.box_edit_point_g_layout.addWidget(self.box_edit_point_g_label) self.box_edit_point_g_layout.addWidget(self.box_edit_point_g_x) self.box_edit_point_g_layout.addWidget(self.box_edit_point_g_y) self.box_edit_point_g_layout.addWidget(self.box_edit_point_g_z) self.box_edit_point_h_layout = QtGui.QHBoxLayout() self.box_edit_point_h_label = QtGui.QLabel(__("Point H (X, Y, Z)")) self.box_edit_point_h_x = QtGui.QLineEdit(str(target_box.point8[0])) self.box_edit_point_h_y = QtGui.QLineEdit(str(target_box.point8[1])) self.box_edit_point_h_z = QtGui.QLineEdit(str(target_box.point8[2])) self.box_edit_point_h_layout.addWidget(self.box_edit_point_h_label) self.box_edit_point_h_layout.addWidget(self.box_edit_point_h_x) self.box_edit_point_h_layout.addWidget(self.box_edit_point_h_y) self.box_edit_point_h_layout.addWidget(self.box_edit_point_h_z) self.box_edit_points_layout.addLayout(self.box_edit_point_a_layout) self.box_edit_points_layout.addLayout(self.box_edit_point_b_layout) self.box_edit_points_layout.addLayout(self.box_edit_point_c_layout) self.box_edit_points_layout.addLayout(self.box_edit_point_d_layout) self.box_edit_points_layout.addLayout(self.box_edit_point_e_layout) self.box_edit_points_layout.addLayout(self.box_edit_point_f_layout) self.box_edit_points_layout.addLayout(self.box_edit_point_g_layout) self.box_edit_points_layout.addLayout(self.box_edit_point_h_layout) # Ok and cancel buttons self.box_edit_button_layout = QtGui.QHBoxLayout() self.box_edit_button_ok = QtGui.QPushButton(__("OK")) self.box_edit_button_cancel = QtGui.QPushButton(__("Cancel")) self.box_edit_button_layout.addStretch(1) self.box_edit_button_layout.addWidget(self.box_edit_button_ok) self.box_edit_button_layout.addWidget(self.box_edit_button_cancel) self.box_edit_layout.addLayout(self.box_edit_name_layout) self.box_edit_layout.addWidget(self.box_edit_description) self.box_edit_layout.addWidget(self.box_edit_image) self.box_edit_layout.addStretch(1) self.box_edit_layout.addLayout(self.box_edit_points_layout) self.box_edit_layout.addLayout(self.box_edit_button_layout) self.setLayout(self.box_edit_layout) self.box_edit_button_ok.clicked.connect(self.on_ok) self.box_edit_button_cancel.clicked.connect(self.on_cancel) self.exec_()
def __init__(self, index, rot_sinu_motion, parent=None): if not isinstance(rot_sinu_motion, RotSinuMotion): raise TypeError( "You tried to spawn a sinusoidal rotational motion widget in the timeline with a wrong object" ) if rot_sinu_motion is None: raise TypeError( "You tried to spawn a sinusoidal 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("Sinusoidal \nRotational \nMotion ") self.label.setMinimumWidth(75) 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.freq_label = QtGui.QLabel("Freq (hz)") self.freq_input = QtGui.QLineEdit() self.ampl_label = QtGui.QLabel("Ampl (rad)") self.ampl_input = QtGui.QLineEdit() self.phase_label = QtGui.QLabel("Phase (rad)") self.phase_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.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.addWidget(self.freq_label) self.main_layout.addWidget(self.freq_input) self.main_layout.addWidget(self.ampl_label) self.main_layout.addWidget(self.ampl_input) self.main_layout.addWidget(self.phase_label) self.main_layout.addWidget(self.phase_input) 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_sinu_motion) self._init_connections()