class RadialForcePropertiesWidget(QWidget):
    """
    This widget modifies properties of a radial force
    """

    # noinspection PyUnresolvedReferences
    def __init__(self, parent=None):
        super(RadialForcePropertiesWidget, self).__init__(parent)
        self.radial_force = None

        self.name_editor = QLineEdit()
        self.name_editor_groupbox = QGroupBox("Name")
        self.name_editor_groupbox_layout = QHBoxLayout()
        self.name_editor_groupbox.setLayout(self.name_editor_groupbox_layout)
        self.name_editor_groupbox_layout.addWidget(self.name_editor)
        self.name_editor_groupbox_layout.addStretch()

        self.explicit_bezier_curve_widget = ExplicitBezierCurveWidget()

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.name_editor_groupbox)
        main_layout.addWidget(self.explicit_bezier_curve_widget)
        main_layout.addStretch()
        self.setLayout(main_layout)

        self.name_editor.textChanged.connect(self.name_editor_text_changed)
        self.explicit_bezier_curve_widget.bezier_curve_changed.connect(self.bezier_curve_changed)

        self.setDisabled(True)

    def switch_to_radial_force(self, radial_force):
        """
        This method initializes widget with current state of radial force
        provided and keeps and eye on specific radial force by writing changes
        to RadialForce object as far as properties are modified in graphical
        interface
        :param radial_force: a radial force in concern
        :type radial_force: engine.RadialForce
        :return: Nothing
        """
        self.radial_force = radial_force
        self.name_editor.setText(self.radial_force.name)
        self.explicit_bezier_curve_widget.deserialize(self.radial_force.bezier_curve)

        self.setEnabled(True)

    def name_editor_text_changed(self, value):
        self.radial_force.name = value

    def bezier_curve_changed(self, bezier_curve):
        self.radial_force.bezier_curve = bezier_curve

    def invalidate(self):
        self.switch_to_radial_force(self.radial_force)
Example #2
0
    def __init__(self, editor, layout=None, *args, **kw):
        super(_FilterTableView, self).__init__(editor, *args, **kw)
        # layout = QVBoxLayout()
        # layout.setSpacing(1)
        # self.table = table = _TableView(parent)

        hl = QHBoxLayout()
        # hl.setSpacing(10)
        #
        self.button = button = QPushButton()
        button.setIcon(icon('delete').create_icon())
        button.setEnabled(False)
        button.setFlat(True)
        button.setSizePolicy(QSizePolicy.Fixed,
                             QSizePolicy.Fixed)
        button.setFixedWidth(15)
        button.setFixedHeight(15)

        self.text = text = QLineEdit()
        self.cb = cb = QCheckBox()
        #
        text.setEnabled(False)
        button.setEnabled(False)
        # table.setEnabled(False)
        # cb.setSizePolicy(QSizePolicy.Fixed,
        # QSizePolicy.Fixed)
        # cb.setFixedWidth(20)
        # cb.setFixedHeight(20)
        #
        hl.addWidget(cb)
        hl.addWidget(text)
        hl.addWidget(button)
        layout.addLayout(hl)
class AtomPropertiesWidget(QWidget):
    """
    This widget modifies properties of a specific atom
    """

    def __init__(self, parent=None):
        super(AtomPropertiesWidget, self).__init__(parent)
        self.atom = None

        self.name_editor = QLineEdit()
        self.name_editor_groupbox = QGroupBox("Name")
        self.name_editor_groupbox_layout = QHBoxLayout()
        self.name_editor_groupbox.setLayout(self.name_editor_groupbox_layout)
        self.name_editor_groupbox_layout.addWidget(self.name_editor)
        self.name_editor_groupbox_layout.addStretch()

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.name_editor_groupbox)
        main_layout.addStretch()
        self.setLayout(main_layout)

        self.name_editor.textChanged.connect(self.name_editor_text_changed)

        self.setDisabled(True)

    def switch_to_atom(self, atom):
        """
        This method initializes widget with current state of atom provided
        and keeps and eye on specific atom writing changes to atom object
        as far as properties are modified in graphical interface
        :param atom: an atom in concern
        :type atom: engine.atom
        :return: Nothing
        """
        self.atom = atom
        self.name_editor.setText(self.atom.name)

        self.setEnabled(True)

    def name_editor_text_changed(self, value):
        self.atom.name = value

    def invalidate(self):
        self.switch_to_atom(self.atom)
    def __init__(self, parent=None):
        super(AtomPropertiesWidget, self).__init__(parent)
        self.atom = None

        self.name_editor = QLineEdit()
        self.name_editor_groupbox = QGroupBox("Name")
        self.name_editor_groupbox_layout = QHBoxLayout()
        self.name_editor_groupbox.setLayout(self.name_editor_groupbox_layout)
        self.name_editor_groupbox_layout.addWidget(self.name_editor)
        self.name_editor_groupbox_layout.addStretch()

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.name_editor_groupbox)
        main_layout.addStretch()
        self.setLayout(main_layout)

        self.name_editor.textChanged.connect(self.name_editor_text_changed)

        self.setDisabled(True)
    def __init__(self, parent=None):
        super(RadialForcePropertiesWidget, self).__init__(parent)
        self.radial_force = None

        self.name_editor = QLineEdit()
        self.name_editor_groupbox = QGroupBox("Name")
        self.name_editor_groupbox_layout = QHBoxLayout()
        self.name_editor_groupbox.setLayout(self.name_editor_groupbox_layout)
        self.name_editor_groupbox_layout.addWidget(self.name_editor)
        self.name_editor_groupbox_layout.addStretch()

        self.explicit_bezier_curve_widget = ExplicitBezierCurveWidget()

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.name_editor_groupbox)
        main_layout.addWidget(self.explicit_bezier_curve_widget)
        main_layout.addStretch()
        self.setLayout(main_layout)

        self.name_editor.textChanged.connect(self.name_editor_text_changed)
        self.explicit_bezier_curve_widget.bezier_curve_changed.connect(self.bezier_curve_changed)

        self.setDisabled(True)
Example #6
0
 def _create_control(self, parent):
     """ Create the toolkit-specific control that represents the widget. """
     control = QLineEdit(parent)
     return control
    def __init__(self, universe, parent=None):
        super(NaturalLawPropertiesWidget, self).__init__(parent)
        self.natural_law = None
        self.universe = universe

        self.name_editor = QLineEdit()
        self.name_editor_groupbox = QGroupBox("Name")
        self.name_editor_groupbox_layout = QHBoxLayout()
        self.name_editor_groupbox.setLayout(self.name_editor_groupbox_layout)
        self.name_editor_groupbox_layout.addWidget(self.name_editor)
        self.name_editor_groupbox_layout.addStretch()

        self.force_combo_box = QComboBox()
        self.force_combo_box.setModel(ForcesInUniverseListModel(universe))
        self.atom_in_combo_box = QComboBox()
        self.atom_in_combo_box.setModel(AtomsInUniverseListModel(universe))
        self.atom_out_combo_box = QComboBox()
        self.atom_out_combo_box.setModel(AtomsInUniverseListModel(universe))
        self.transformation_label = QLabel()

        self.conversion_scheme_groupbox = QGroupBox("Conversion scheme")
        self.conversion_scheme_groupbox.setVisible(False)
        self.conversion_scheme_groupbox_layout = QGridLayout()
        self.conversion_scheme_groupbox.setLayout(self.conversion_scheme_groupbox_layout)
        self.conversion_scheme_groupbox_layout.addWidget(self.atom_in_combo_box, 1, 0)
        self.conversion_scheme_groupbox_layout.addWidget(self.force_combo_box, 0, 1)
        self.conversion_scheme_groupbox_layout.addWidget(self.atom_out_combo_box, 1, 2)
        self.conversion_scheme_groupbox_layout.addWidget(self.transformation_label, 1, 1)

        self.conversion_rate_formula_label = LatexLabelWidget()

        self.multiplicative_component_label = QLabel(u"υ = ")
        self.multiplicative_component_label.setFont(QFont("Times New Roman", 15, italic=True))
        self.multiplicative_component_double_spinbox = QDoubleSpinBox()

        self.additive_component_label = QLabel(u"s = ")
        self.additive_component_label.setFont(QFont("Times New Roman", 15, italic=True))
        self.additive_component_double_spinbox = QDoubleSpinBox()

        self.conversion_rate_groupbox = QGroupBox("Conversion rate")
        self.conversion_rate_groupbox_layout = QGridLayout()
        self.conversion_rate_groupbox.setLayout(self.conversion_rate_groupbox_layout)
        self.conversion_rate_groupbox_layout.addWidget(self.conversion_rate_formula_label, 0, 0, 1, 2)
        self.conversion_rate_groupbox_layout.addWidget(self.multiplicative_component_label, 1, 0)
        self.conversion_rate_groupbox_layout.addWidget(self.multiplicative_component_double_spinbox, 1, 1)
        self.conversion_rate_groupbox_layout.addWidget(self.additive_component_label, 2, 0)
        self.conversion_rate_groupbox_layout.addWidget(self.additive_component_double_spinbox, 2, 1)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.name_editor_groupbox)
        main_layout.addWidget(self.conversion_scheme_groupbox)
        main_layout.addWidget(self.conversion_rate_groupbox)
        main_layout.addStretch()

        self.setLayout(main_layout)

        self.name_editor.textChanged.connect(self.name_editor_text_changed)
        self.multiplicative_component_double_spinbox.valueChanged.connect(self.multiplicative_component_value_changed)
        self.additive_component_double_spinbox.valueChanged.connect(self.additive_component_value_changed)

        self.atom_in_combo_box.currentIndexChanged.connect(self.atom_in_combo_box_current_index_changed)

        self.setDisabled(True)
class NaturalLawPropertiesWidget(QWidget):
    """
    This widget modifies properties of a natural law
    """

    def __init__(self, universe, parent=None):
        super(NaturalLawPropertiesWidget, self).__init__(parent)
        self.natural_law = None
        self.universe = universe

        self.name_editor = QLineEdit()
        self.name_editor_groupbox = QGroupBox("Name")
        self.name_editor_groupbox_layout = QHBoxLayout()
        self.name_editor_groupbox.setLayout(self.name_editor_groupbox_layout)
        self.name_editor_groupbox_layout.addWidget(self.name_editor)
        self.name_editor_groupbox_layout.addStretch()

        self.force_combo_box = QComboBox()
        self.force_combo_box.setModel(ForcesInUniverseListModel(universe))
        self.atom_in_combo_box = QComboBox()
        self.atom_in_combo_box.setModel(AtomsInUniverseListModel(universe))
        self.atom_out_combo_box = QComboBox()
        self.atom_out_combo_box.setModel(AtomsInUniverseListModel(universe))
        self.transformation_label = QLabel()

        self.conversion_scheme_groupbox = QGroupBox("Conversion scheme")
        self.conversion_scheme_groupbox.setVisible(False)
        self.conversion_scheme_groupbox_layout = QGridLayout()
        self.conversion_scheme_groupbox.setLayout(self.conversion_scheme_groupbox_layout)
        self.conversion_scheme_groupbox_layout.addWidget(self.atom_in_combo_box, 1, 0)
        self.conversion_scheme_groupbox_layout.addWidget(self.force_combo_box, 0, 1)
        self.conversion_scheme_groupbox_layout.addWidget(self.atom_out_combo_box, 1, 2)
        self.conversion_scheme_groupbox_layout.addWidget(self.transformation_label, 1, 1)

        self.conversion_rate_formula_label = LatexLabelWidget()

        self.multiplicative_component_label = QLabel(u"υ = ")
        self.multiplicative_component_label.setFont(QFont("Times New Roman", 15, italic=True))
        self.multiplicative_component_double_spinbox = QDoubleSpinBox()

        self.additive_component_label = QLabel(u"s = ")
        self.additive_component_label.setFont(QFont("Times New Roman", 15, italic=True))
        self.additive_component_double_spinbox = QDoubleSpinBox()

        self.conversion_rate_groupbox = QGroupBox("Conversion rate")
        self.conversion_rate_groupbox_layout = QGridLayout()
        self.conversion_rate_groupbox.setLayout(self.conversion_rate_groupbox_layout)
        self.conversion_rate_groupbox_layout.addWidget(self.conversion_rate_formula_label, 0, 0, 1, 2)
        self.conversion_rate_groupbox_layout.addWidget(self.multiplicative_component_label, 1, 0)
        self.conversion_rate_groupbox_layout.addWidget(self.multiplicative_component_double_spinbox, 1, 1)
        self.conversion_rate_groupbox_layout.addWidget(self.additive_component_label, 2, 0)
        self.conversion_rate_groupbox_layout.addWidget(self.additive_component_double_spinbox, 2, 1)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.name_editor_groupbox)
        main_layout.addWidget(self.conversion_scheme_groupbox)
        main_layout.addWidget(self.conversion_rate_groupbox)
        main_layout.addStretch()

        self.setLayout(main_layout)

        self.name_editor.textChanged.connect(self.name_editor_text_changed)
        self.multiplicative_component_double_spinbox.valueChanged.connect(self.multiplicative_component_value_changed)
        self.additive_component_double_spinbox.valueChanged.connect(self.additive_component_value_changed)

        self.atom_in_combo_box.currentIndexChanged.connect(self.atom_in_combo_box_current_index_changed)

        self.setDisabled(True)

    def switch_to_natural_law(self, natural_law):
        """
        This method initializes widget with current state of natural law
        provided and keeps and eye on specific natural law by writing changes
        to NaturalLaw object as far as properties are modified in graphical
        interface
        :param natural_law: a natural law in concern
        :type natural_law: engine.NaturalLaw
        :return: Nothing
        """
        self.natural_law = natural_law
        self.name_editor.setText(self.natural_law.name)

        if self.natural_law.atom_in is not None:
            self.atom_in_combo_box.setCurrentIndex(self.universe.atoms.index(self.natural_law.atom_in))
        if self.natural_law.atom_out is not None:
            self.atom_out_combo_box.setCurrentIndex(self.universe.atoms.index(self.natural_law.atom_out))
        if self.natural_law.accelerator is not None:
            self.force_combo_box.setCurrentIndex(self.universe.forces.index(self.natural_law.accelerator))

        self.multiplicative_component_double_spinbox.setValue(self.natural_law.multiplicative_component)
        self.additive_component_double_spinbox.setValue(self.natural_law.additive_component)

        self.update_conversion_rate_formula_label()

        self.setEnabled(True)

    def invalidate(self):
        self.switch_to_natural_law(self.natural_law)

    def name_editor_text_changed(self, value):
        self.natural_law.name = value

    def multiplicative_component_value_changed(self, value):
        self.natural_law.multiplicative_component = value
        self.update_conversion_rate_formula_label()

    def additive_component_value_changed(self, value):
        self.natural_law.additive_component = value
        self.update_conversion_rate_formula_label()

    def update_conversion_rate_formula_label(self):
        self.conversion_rate_formula_label.text.set_text(
            "$ f * \upsilon + s = f * {upsilon} + {s} $".format(
                upsilon=self.natural_law.multiplicative_component, s=self.natural_law.additive_component
            )
        )
        self.conversion_rate_formula_label.draw()

    def atom_in_combo_box_current_index_changed(self, index):
        # here we should remove the previous connection.
        pass