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

# Form implementation generated from reading ui file 'CoordinateDialogue.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# 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 CoordinateDialogue(QtWidgets.QDialog):
    def __init__(self):
        self.row = 0
        self.col = 3
        super().__init__()
        self.setupUi(self)
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.setEnabled(True)
        Dialog.resize(600, 400)
        Dialog.setMinimumSize(QtCore.QSize(600, 400))
        Dialog.setMaximumSize(QtCore.QSize(600, 400))
        Dialog.setSizeGripEnabled(False)
        self.gridLayout = QtWidgets.QGridLayout(Dialog)
        self.gridLayout.setObjectName("gridLayout")
        self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1)
        self.pointTableWidget = QtWidgets.QTableWidget(Dialog)
        self.pointTableWidget.setAlternatingRowColors(True)
        self.pointTableWidget.setColumnCount(3)
        self.pointTableWidget.setObjectName("pointTableWidget")
        self.pointTableWidget.setRowCount(0)
        item = QtWidgets.QTableWidgetItem()
        self.pointTableWidget.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.pointTableWidget.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.pointTableWidget.setHorizontalHeaderItem(2, item)
        self.pointTableWidget.horizontalHeader().setDefaultSectionSize(170)
        self.pointTableWidget.horizontalHeader().setMinimumSectionSize(19)
        self.pointTableWidget.verticalHeader().setCascadingSectionResizes(True)
        self.pointTableWidget.verticalHeader().setMinimumSectionSize(21)
        self.pointTableWidget.verticalHeader().setSortIndicatorShown(False)
        self.pointTableWidget.verticalHeader().setStretchLastSection(False)
        self.gridLayout.addWidget(self.pointTableWidget, 0, 0, 1, 1)

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(self.OnOkButtonClick)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Coordinate Node Dialogue"))
        item = self.pointTableWidget.horizontalHeaderItem(0)
        item.setText(_translate("Dialog", "X"))
        item = self.pointTableWidget.horizontalHeaderItem(1)
        item.setText(_translate("Dialog", "Y"))
        item = self.pointTableWidget.horizontalHeaderItem(2)
        item.setText(_translate("Dialog", "Z"))

    def InitData(self, point):
        self.row = len(point) // 3
        self.pointTableWidget.setRowCount(self.row)
        for idx in range(len(point) // 3):
            for jdx in range(3):
                item = QtWidgets.QTableWidgetItem()
                item.setText(str(point[idx * 3 + jdx]))
                self.pointTableWidget.setItem(idx, jdx, item)

    def OnOkButtonClick(self):
        data = []
        for idx in range(self.row):
            for jdx in range(self.col):
                data.append(float(self.pointTableWidget.item(idx, jdx).text()))

        self.values = {
            "Point" : data
        }
        self.accept()


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())
