def __is_ok(self) -> None: """Check and show the final position.""" mode = self.tab_widget.currentIndex() if mode == 0: x = self.plap_p1x_box.value() y = self.plap_p1y_box.value() c = plap( Coordinate(x, y), self.plap_distance_box.value(), radians(self.plap_angle_box.value()) ) elif mode == 1: x1 = self.pllp_p1x_box.value() y1 = self.pllp_p1y_box.value() x2 = self.pllp_p2x_box.value() y2 = self.pllp_p2y_box.value() c = pllp( Coordinate(x1, y1), self.pllp_distance1_box.value(), self.pllp_distance2_box.value(), Coordinate(x2, y2), self.pllp_inversed_box.isChecked() ) else: raise ValueError("invalid option") self.preview_label.setText(f"({c.x}, {c.y})") self.__x = c.x self.__y = c.y ok_button = self.button_box.button(QDialogButtonBox.Ok) ok_button.setEnabled(not (isnan(c.x) or isnan(c.y)))
def test_plap(self): """Test for plap function.""" coord = plap(Coord(0, 0), 50 * sqrt(2), radians(45), Coord(50, 0)) self.assertAlmostEqual(50, coord.x) self.assertAlmostEqual(50, coord.y)