Exemplo n.º 1
0
    def __init__(self, layout: QtWidgets.QLayout, simulation: springModule, window: "Window"):
        super().__init__()
        layout.addWidget(self)
        self.mysim = simulation
        self.window = window
        self.signal = window.simulation_changed
        layout = QtWidgets.QVBoxLayout(self)
        self.list = MyList(layout)
        self.updateList()
        self.list.currentItemChanged.connect(self.selected)
        self.input_properties = {}
        for name, widget in [["Spring", PropertiesSpring], ["Dashpot", PropertiesDashpot], ["Force", PropertiesForce], ["SinForce", PropertiesSinForce]]:
            self.input_properties[name] = widget(layout, window.simulation_changed)
            self.input_properties[name].setVisible(False)

        self.input_remove = QtWidgets.QPushButton("remove")
        self.input_remove.clicked.connect(self.remove)
        layout.addWidget(self.input_remove)
        layout = QtWidgets.QHBoxLayout()
        self.layout().addLayout(layout)
        self.input_type = QInputChoice(layout, "Type", Spring, [Spring, Dashpot, Force, SinForce], ["Spring", "Dashpot", "Force", "SinForce"])
        self.input_add = QtWidgets.QPushButton("add")
        self.input_add.clicked.connect(self.add)
        layout.addWidget(self.input_add)

        window.simulation_changed.connect(self.updateList)
Exemplo n.º 2
0
 def __init__(self, layout: QtWidgets.QLayout, signal: QtCore.Signal):
     super().__init__(layout, signal)
     self.properties = {
         "start": QInputChoice(self.layout(), "node 1", 0, [0], ["0"]),
         "end": QInputChoice(self.layout(), "node 2", 0, [0], ["0"]),
         "strength": QInputNumber(self.layout(), "eta"),
     }
     self.initSignals()
Exemplo n.º 3
0
 def __init__(self, layout: QtWidgets.QLayout, signal: QtCore.Signal):
     super().__init__(layout, signal)
     self.properties = {
         0: QInputChoice(self.layout(), "fixed", 0, [0, 1], ["fixed", "free"]),
         1: QInputNumber(self.layout(), "x"),
     }
     self.initSignals()
Exemplo n.º 4
0
 def __init__(self, layout: QtWidgets.QLayout, simulation: springModule, signal: QtCore.Signal):
     super().__init__(layout, signal)
     self.properties = {
         "end_time": QInputNumber(self.layout(), "Time", value=10),
         "h": QInputNumber(self.layout(), "Delta T", value=0.1),
         "plot_point": QInputChoice(self.layout(), "Plot Node", 0, [0], ["0"]),
     }
     self.initSignals()
     self.setTarget(simulation)
     signal.connect(self.setTarget)
Exemplo n.º 5
0
class ListElements(QtWidgets.QWidget):
    def __init__(self, layout: QtWidgets.QLayout, simulation: springModule, window: "Window"):
        super().__init__()
        layout.addWidget(self)
        self.mysim = simulation
        self.window = window
        self.signal = window.simulation_changed
        layout = QtWidgets.QVBoxLayout(self)
        self.list = MyList(layout)
        self.updateList()
        self.list.currentItemChanged.connect(self.selected)
        self.input_properties = {}
        for name, widget in [["Spring", PropertiesSpring], ["Dashpot", PropertiesDashpot], ["Force", PropertiesForce], ["SinForce", PropertiesSinForce]]:
            self.input_properties[name] = widget(layout, window.simulation_changed)
            self.input_properties[name].setVisible(False)

        self.input_remove = QtWidgets.QPushButton("remove")
        self.input_remove.clicked.connect(self.remove)
        layout.addWidget(self.input_remove)
        layout = QtWidgets.QHBoxLayout()
        self.layout().addLayout(layout)
        self.input_type = QInputChoice(layout, "Type", Spring, [Spring, Dashpot, Force, SinForce], ["Spring", "Dashpot", "Force", "SinForce"])
        self.input_add = QtWidgets.QPushButton("add")
        self.input_add.clicked.connect(self.add)
        layout.addWidget(self.input_add)

        window.simulation_changed.connect(self.updateList)

    def remove(self):
        self.mysim.elements.pop(self.list.currentRow())
        self.signal.emit()

    def add(self):
        self.mysim.elements.append(self.input_type.value()())
        self.signal.emit()

    def selected(self, item):
        element = self.mysim.elements[self.list.currentRow()]
        for key, value in self.input_properties.items():
            value.setVisible(False)
        input = self.input_properties[type(element).__name__]
        input.properties["start"].setChoices(np.arange(self.mysim.big_point_array_movable.shape[0]))
        if "end" in input.properties:
            input.properties["end"].setChoices(np.arange(self.mysim.big_point_array_movable.shape[0]))
        input.setVisible(True)
        input.setTarget(element)

    def updateList(self):
        self.list.setData([str(e) for e in self.mysim.elements])