# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'rajon.ui'
#
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Rajon(object):
    result = (None, None)

    def setupUi(self, Rajon):
        Rajon.setObjectName("Rajon")
        Rajon.resize(585, 415)
        self.buttonBox = QtWidgets.QDialogButtonBox(Rajon)
        self.buttonBox.setGeometry(QtCore.QRect(230, 360, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.label = QtWidgets.QLabel(Rajon)
        self.label.setGeometry(QtCore.QRect(20, 20, 81, 18))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(Rajon)
        self.label_2.setGeometry(QtCore.QRect(100, 20, 58, 18))
        self.label_2.setObjectName("label_2")
        self.label_3 = QtWidgets.QLabel(Rajon)
        self.label_3.setGeometry(QtCore.QRect(100, 50, 58, 18))
        self.label_3.setObjectName("label_3")
        self.y_stanovisko = QtWidgets.QTextEdit(Rajon)
        self.y_stanovisko.setGeometry(QtCore.QRect(130, 10, 81, 31))
        self.y_stanovisko.setObjectName("y_stanovisko")
        self.x_stanovisko = QtWidgets.QTextEdit(Rajon)
        self.x_stanovisko.setGeometry(QtCore.QRect(130, 40, 81, 31))
        self.x_stanovisko.setObjectName("x_stanovisko")
        self.label_7 = QtWidgets.QLabel(Rajon)
        self.label_7.setGeometry(QtCore.QRect(430, 60, 58, 18))
        self.label_7.setObjectName("label_7")
        self.x_orientace = QtWidgets.QTextEdit(Rajon)
        self.x_orientace.setGeometry(QtCore.QRect(460, 50, 81, 31))
        self.x_orientace.setObjectName("x_orientace")
        self.y_orientace = QtWidgets.QTextEdit(Rajon)
        self.y_orientace.setGeometry(QtCore.QRect(460, 20, 81, 31))
        self.y_orientace.setObjectName("y_orientace")
        self.label_8 = QtWidgets.QLabel(Rajon)
        self.label_8.setGeometry(QtCore.QRect(430, 30, 58, 18))
        self.label_8.setObjectName("label_8")
        self.label_9 = QtWidgets.QLabel(Rajon)
        self.label_9.setGeometry(QtCore.QRect(350, 30, 81, 18))
        self.label_9.setObjectName("label_9")
        self.smer_orientace = QtWidgets.QTextEdit(Rajon)
        self.smer_orientace.setGeometry(QtCore.QRect(130, 120, 104, 31))
        self.smer_orientace.setObjectName("smer_orientace")
        self.label_4 = QtWidgets.QLabel(Rajon)
        self.label_4.setGeometry(QtCore.QRect(30, 130, 101, 18))
        self.label_4.setObjectName("label_4")
        self.smer_bod = QtWidgets.QTextEdit(Rajon)
        self.smer_bod.setGeometry(QtCore.QRect(130, 170, 104, 31))
        self.smer_bod.setObjectName("smer_bod")
        self.label_5 = QtWidgets.QLabel(Rajon)
        self.label_5.setGeometry(QtCore.QRect(30, 180, 101, 18))
        self.label_5.setObjectName("label_5")
        self.delka = QtWidgets.QTextEdit(Rajon)
        self.delka.setGeometry(QtCore.QRect(130, 240, 104, 31))
        self.delka.setObjectName("delka")
        self.label_6 = QtWidgets.QLabel(Rajon)
        self.label_6.setGeometry(QtCore.QRect(30, 250, 101, 18))
        self.label_6.setObjectName("label_6")

        self.retranslateUi(Rajon)
        self.buttonBox.accepted.connect(self.set_result) # type: ignore
        self.buttonBox.accepted.connect(Rajon.accept) # type: ignore
        self.buttonBox.rejected.connect(Rajon.reject) # type: ignore
        QtCore.QMetaObject.connectSlotsByName(Rajon)

    def retranslateUi(self, Rajon):
        _translate = QtCore.QCoreApplication.translate
        Rajon.setWindowTitle(_translate("Rajon", "Dialog"))
        self.label.setText(_translate("Rajon", "Stanovisko"))
        self.label_2.setText(_translate("Rajon", "Y"))
        self.label_3.setText(_translate("Rajon", "X"))
        self.y_stanovisko.setHtml(_translate("Rajon", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Noto Sans, \'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">50.09</p></body></html>"))
        self.x_stanovisko.setHtml(_translate("Rajon", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Noto Sans, \'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">14.46</p></body></html>"))
        self.label_7.setText(_translate("Rajon", "X"))
        self.x_orientace.setHtml(_translate("Rajon", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Noto Sans, \'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">14.45</p></body></html>"))
        self.y_orientace.setHtml(_translate("Rajon", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Noto Sans, \'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">50.08</p></body></html>"))
        self.label_8.setText(_translate("Rajon", "Y"))
        self.label_9.setText(_translate("Rajon", "Orientace"))
        self.smer_orientace.setHtml(_translate("Rajon", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Noto Sans, \'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">12.3456</p></body></html>"))
        self.label_4.setText(_translate("Rajon", "Smer orientace"))
        self.smer_bod.setHtml(_translate("Rajon", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Noto Sans, \'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">83.2836</p></body></html>"))
        self.label_5.setText(_translate("Rajon", "Smer bod"))
        self.delka.setHtml(_translate("Rajon", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Noto Sans, \'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">183.2836</p></body></html>"))
        self.label_6.setText(_translate("Rajon", "Delka bod"))

    def set_result(self):
        self.result = self._spocti_rajon()

    def _spocti_rajon(self):
        import math

        dy_ab = float(self.y_orientace.toPlainText()) - float(self.y_stanovisko.toPlainText())
        dx_ab = float(self.x_orientace.toPlainText()) - float(self.x_stanovisko.toPlainText())

        smernik_ori = math.atan2(dy_ab, dx_ab)
        rozdil_uhlu = float(self.smer_bod.toPlainText()) * math.pi / 200 - float(self.smer_orientace.toPlainText()) * math.pi / 200
        smernik_cil = smernik_ori + rozdil_uhlu

        souradnice_x = float(self.x_stanovisko.toPlainText()) + float(self.delka.toPlainText()) * math.cos(smernik_cil)  # zmena zde
        souradnice_y = float(self.y_stanovisko.toPlainText()) + float(self.delka.toPlainText()) * math.sin(smernik_cil)  # zmena zde

        return souradnice_y, souradnice_x
