| | |
| | | layout.addWidget(self.canvas) |
| | | self.ui.plotBox.setLayout(layout) |
| | | self.ui.plotBtn.clicked.connect(self._update_plot) |
| | | self.ui.breakMethod.buttonClicked.connect(self._activate_break_rule) |
| | | self.ui.numberOfSectionsMethod.click() |
| | | |
| | | def _update_plot(self): |
| | | fn_expr = self.ui.function.text() |
| | | self.fn_expr = fn_expr |
| | | start = self.ui.startValue.text() |
| | | end = self.ui.endValue.text() |
| | | epsilon = self.ui.espilon.text() |
| | | |
| | | try: |
| | | f = parse_function(fn_expr) |
| | | (a, b) = (parse_value(start), parse_value(end)) |
| | | if epsilon is not None and len(epsilon.strip()) > 0: |
| | | eps = parse_value(epsilon) |
| | | method_id = self.ui.breakMethod.checkedId() |
| | | if method_id == self.ui.breakMethod.id(self.ui.minEpsilonMethod): |
| | | epsilon = self.ui.espilon.text() |
| | | eps = abs(parse_value(epsilon)) |
| | | self.ui.espilon.setText(f"{eps}") |
| | | print(f"plot f(x) = {fn_expr}, {a}, {b}, epsilon = {eps}") |
| | | (self.x, self.y, self.left, self.right, self.num_of_iterations, *_) = numint_epsilon(f, a, b, eps) |
| | | self._update_plot_eps() |
| | | else: |
| | | elif method_id == self.ui.breakMethod.id(self.ui.numberOfSectionsMethod): |
| | | section = self.ui.section.text() |
| | | sec = parse_value(section) |
| | | sec = int(abs(parse_value(section))) |
| | | self.ui.section.setText(f"{sec}") |
| | | print(f"plot f(x) = {fn_expr}, {a}, {b}, section = {sec}") |
| | | (self.x, self.y, self.left, self.right, self.num_of_iterations, *_) = numint_section(f, a, b, sec) |
| | | self._update_plot_eps() |
| | |
| | | self.ui.rightSum.setText(f"{self.right}") |
| | | self.ui.numOfSections.setText(f"{self.num_of_iterations}") |
| | | |
| | | def _activate_break_rule(self): |
| | | method_id = self.ui.breakMethod.checkedId() |
| | | print(method_id) |
| | | if method_id == self.ui.breakMethod.id(self.ui.numberOfSectionsMethod): |
| | | print("activate num of sec") |
| | | self.ui.section.setEnabled(True) |
| | | self.ui.section.setFocus() |
| | | self.ui.espilon.setEnabled(False) |
| | | |
| | | elif method_id == self.ui.breakMethod.id(self.ui.minEpsilonMethod): |
| | | print("activate minimum epsilon method") |
| | | self.ui.section.setEnabled(False) |
| | | self.ui.espilon.setEnabled(True) |
| | | self.ui.espilon.setFocus() |
| | | |
| | | |
| | | |
| | | |
| | | def main(): |
| | | app = QApplication(sys.argv) |