-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.py
204 lines (195 loc) · 9.22 KB
/
table.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
from PyQt5 import QtCore, QtGui, QtWidgets
import numpy as np
import copy
class Ui_Form(object):
def setupUi(self, Form):
self.x = 0
self.y = 0
Form.setObjectName("Form")
Form.resize(663, 831)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(180, 35, 71, 21))
font = QtGui.QFont()
font.setPointSize(10)
self.label.setFont(font)
self.label.setObjectName("label")
self.unit = QtWidgets.QLineEdit(Form)
self.unit.setGeometry(QtCore.QRect(40, 30, 131, 31))
self.unit.setObjectName("unit")
self.perunit = QtWidgets.QLineEdit(Form)
self.perunit.setGeometry(QtCore.QRect(270, 30, 131, 31))
self.perunit.setObjectName("perunit")
self.label_2 = QtWidgets.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(410, 35, 71, 21))
font = QtGui.QFont()
font.setPointSize(10)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.tableWidget = QtWidgets.QTableWidget(Form)
self.tableWidget.setGeometry(QtCore.QRect(10, 80, 641, 741))
self.tableWidget.setMouseTracking(False)
self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.tableWidget.setObjectName("tableWidget")
# Form.setObjectName("Form")
# Form.resize(663, 831)
# self.label = QtWidgets.QLabel(Form)
# self.label.setGeometry(QtCore.QRect(10, 35, 111, 21))
# font = QtGui.QFont()
# font.setPointSize(10)
# self.label.setFont(font)
# self.label.setObjectName("label")
# self.unit = QtWidgets.QLineEdit(Form)
# self.unit.setGeometry(QtCore.QRect(120, 30, 131, 31))
# self.unit.setObjectName("unit")
# self.perunit = QtWidgets.QLineEdit(Form)
# self.perunit.setGeometry(QtCore.QRect(360, 30, 131, 31))
# self.perunit.setObjectName("perunit")
# self.label_2 = QtWidgets.QLabel(Form)
# self.label_2.setGeometry(QtCore.QRect(290, 35, 71, 21))
# font = QtGui.QFont()
# font.setPointSize(10)
# self.label_2.setFont(font)
# self.label_2.setObjectName("label_2")
# self.tableWidget = QtWidgets.QTableWidget(Form)
# self.tableWidget.setGeometry(QtCore.QRect(10, 80, 641, 741))
# self.tableWidget.setMouseTracking(False)
# self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
# self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setColumnCount(3)
self.tableWidget.setRowCount(19)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(5, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(6, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(7, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(8, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(9, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(10, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(11, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(12, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(13, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(14, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(15, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(16, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(17, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setVerticalHeaderItem(18, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
self.tableWidget.setItem(0, 0, item)
self.tableWidget.horizontalHeader().setDefaultSectionSize(195)
self.tableWidget.verticalHeader().setDefaultSectionSize(37)
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(530, 30, 93, 28))
self.pushButton.setObjectName("pushButton")
self.initUI()
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def initUI(self):
self.pushButton.clicked.connect(self.change)
def change(self):
try:
unit = float(self.unit.text())
perunit = float(self.perunit.text())
except ValueError:
unit = 0
perunit = 0
if unit != 0 and perunit != 0:
for i in range(0, len(self.x), 2):
item = QtWidgets.QTableWidgetItem()
k = unit/perunit
spx = round(self.x[i] * k, 4)
spy = round(self.y[i] * k, 4)
item.setText('(' + str(spx) + ', ' + str(spy) + ')')
self.tableWidget.setItem(i/2, 0, item)
item = QtWidgets.QTableWidgetItem()
epx = round(self.x[i + 1] * k, 4)
epy = round(self.y[i + 1] * k, 4)
item.setText('(' + str(epx) + ', ' + str(epy) + ')')
self.tableWidget.setItem(i/2, 1, item)
length = np.sqrt((epx - spx)**2 + (epy - spy)**2)
item = QtWidgets.QTableWidgetItem()
item.setText(str(round(length, 4)) + " " + 'cm')
self.tableWidget.setItem(i/2, 2, item)
def passValues(self, x, y):
self.x = copy.copy(x)
self.y = copy.copy(y)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Scale Table"))
self.label.setText(_translate("Form", "cm"))
self.label_2.setText(_translate("Form", "p.u."))
item = self.tableWidget.verticalHeaderItem(0)
item.setText(_translate("Form", "I"))
item = self.tableWidget.verticalHeaderItem(1)
item.setText(_translate("Form", "Iq"))
item = self.tableWidget.verticalHeaderItem(2)
item.setText(_translate("Form", "Id"))
item = self.tableWidget.verticalHeaderItem(3)
item.setText(_translate("Form", "U"))
item = self.tableWidget.verticalHeaderItem(4)
item.setText(_translate("Form", "Uq"))
item = self.tableWidget.verticalHeaderItem(5)
item.setText(_translate("Form", "Ud"))
item = self.tableWidget.verticalHeaderItem(6)
item.setText(_translate("Form", "AC"))
item = self.tableWidget.verticalHeaderItem(7)
item.setText(_translate("Form", "IX(d)"))
item = self.tableWidget.verticalHeaderItem(8)
item.setText(_translate("Form", "IX\'(d)"))
item = self.tableWidget.verticalHeaderItem(9)
item.setText(_translate("Form", "IX\"(d)"))
item = self.tableWidget.verticalHeaderItem(10)
item.setText(_translate("Form", "IX(q)"))
item = self.tableWidget.verticalHeaderItem(11)
item.setText(_translate("Form", "IX\'(q)"))
item = self.tableWidget.verticalHeaderItem(12)
item.setText(_translate("Form", "IX\"(q)"))
item = self.tableWidget.verticalHeaderItem(13)
item.setText(_translate("Form", "ΔE"))
item = self.tableWidget.verticalHeaderItem(14)
item.setText(_translate("Form", "ΔE\'"))
item = self.tableWidget.verticalHeaderItem(15)
item.setText(_translate("Form", "ΔE\""))
item = self.tableWidget.verticalHeaderItem(16)
item.setText(_translate("Form", "E"))
item = self.tableWidget.verticalHeaderItem(17)
item.setText(_translate("Form", "E\'"))
item = self.tableWidget.verticalHeaderItem(18)
item.setText(_translate("Form", "E\""))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("Form", "Starting Point"))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("Form", "Ending Point"))
item = self.tableWidget.horizontalHeaderItem(2)
item.setText(_translate("Form", "Length"))
__sortingEnabled = self.tableWidget.isSortingEnabled()
self.tableWidget.setSortingEnabled(False)
self.tableWidget.setSortingEnabled(__sortingEnabled)
self.pushButton.setText(_translate("Form", "Change"))