|
@@ -10,11 +10,15 @@ import numpy as np
|
10
|
10
|
from tkinter import messagebox
|
11
|
11
|
from tkinter import *
|
12
|
12
|
|
13
|
|
-#region 各种方法
|
|
13
|
+from PySide6.QtWidgets import QMessageBox
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+# region 各种方法
|
14
|
17
|
def to_utf8(text):
|
15
|
18
|
str1 = text.encode('utf-8')
|
16
|
19
|
return str1
|
17
|
20
|
|
|
21
|
+
|
18
|
22
|
def jzys1(listy, zxzby, listx, zxzbx, sf):
|
19
|
23
|
rlist = []
|
20
|
24
|
listlen = len(listy)
|
|
@@ -30,6 +34,7 @@ def jzys1(listy, zxzby, listx, zxzbx, sf):
|
30
|
34
|
ll = ll + 1
|
31
|
35
|
return rlist
|
32
|
36
|
|
|
37
|
+
|
33
|
38
|
def jzys2(listy, zxzby, listx, zxzbx, sf):
|
34
|
39
|
rlist = []
|
35
|
40
|
listlen = len(listy)
|
|
@@ -43,6 +48,7 @@ def jzys2(listy, zxzby, listx, zxzbx, sf):
|
43
|
48
|
ll = ll + 1
|
44
|
49
|
return rlist
|
45
|
50
|
|
|
51
|
+
|
46
|
52
|
def jzys3(listy, aa, bb):
|
47
|
53
|
rlist = []
|
48
|
54
|
listlen = len(listy)
|
|
@@ -56,6 +62,7 @@ def jzys3(listy, aa, bb):
|
56
|
62
|
ll = ll + 1
|
57
|
63
|
return rlist
|
58
|
64
|
|
|
65
|
+
|
59
|
66
|
def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listnewx, zxzbnewx, sf):
|
60
|
67
|
rlist = []
|
61
|
68
|
listlen = len(listnewx)
|
|
@@ -68,6 +75,7 @@ def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listne
|
68
|
75
|
ll = ll + 1
|
69
|
76
|
return rlist
|
70
|
77
|
|
|
78
|
+
|
71
|
79
|
def jzys5(listp, zxzbp, sf):
|
72
|
80
|
rlist = []
|
73
|
81
|
listlen = len(listp)
|
|
@@ -78,6 +86,7 @@ def jzys5(listp, zxzbp, sf):
|
78
|
86
|
ll = ll + 1
|
79
|
87
|
return rlist
|
80
|
88
|
|
|
89
|
+
|
81
|
90
|
def jzys6(listp, num):
|
82
|
91
|
rlist = []
|
83
|
92
|
listlen = len(listp)
|
|
@@ -88,6 +97,7 @@ def jzys6(listp, num):
|
88
|
97
|
ll = ll + 1
|
89
|
98
|
return rlist
|
90
|
99
|
|
|
100
|
+
|
91
|
101
|
def cjh(listp):
|
92
|
102
|
rp = 0
|
93
|
103
|
listlen = len(listp)
|
|
@@ -98,6 +108,7 @@ def cjh(listp):
|
98
|
108
|
ll = ll + 1
|
99
|
109
|
return rp
|
100
|
110
|
|
|
111
|
+
|
101
|
112
|
def cjh2(lista, listb):
|
102
|
113
|
rp = 0
|
103
|
114
|
listlen = len(lista)
|
|
@@ -108,6 +119,7 @@ def cjh2(lista, listb):
|
108
|
119
|
ll = ll + 1
|
109
|
120
|
return rp
|
110
|
121
|
|
|
122
|
+
|
111
|
123
|
def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpastp, ii):
|
112
|
124
|
# 新x+(矩阵[jx1 jy1 lx1 ly1]*矩阵z)*缩放-新重心坐标x+旧重心坐标x
|
113
|
125
|
rlist = []
|
|
@@ -115,7 +127,7 @@ def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpas
|
115
|
127
|
ll = 0
|
116
|
128
|
while ll < listlen:
|
117
|
129
|
arr0 = np.array((jxlist1[ll], jylist1[ll],
|
118
|
|
- lxlist[2*ll+ii], lylist[2*ll+ii]))
|
|
130
|
+ lxlist[2 * ll + ii], lylist[2 * ll + ii]))
|
119
|
131
|
arr1 = np.matmul(arr0, arrz)
|
120
|
132
|
arr3 = sf * arr1
|
121
|
133
|
newp = listnewp[ll] + arr3 - zxzbnewp + zxzbpastp
|
|
@@ -123,6 +135,7 @@ def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpas
|
123
|
135
|
ll = ll + 1
|
124
|
136
|
return rlist
|
125
|
137
|
|
|
138
|
+
|
126
|
139
|
def xcys(newlist, pastlist):
|
127
|
140
|
listlen = len(newlist)
|
128
|
141
|
ll = 0
|
|
@@ -134,40 +147,46 @@ def xcys(newlist, pastlist):
|
134
|
147
|
ll = ll + 1
|
135
|
148
|
return rlist
|
136
|
149
|
|
|
150
|
+
|
137
|
151
|
def takeFirst(elem):
|
138
|
152
|
return elem[0]
|
139
|
|
-#endregion
|
140
|
153
|
|
141
|
|
-def insert_into_database1(database,pastname,newname,beforename,excelname,listname1,listpastx1,listpasty1,listcgcs1,listbex,listbey,sxylist,wypd,gsx,gsy,listcgcs):
|
142
|
|
- #转换下汉字
|
|
154
|
+
|
|
155
|
+# endregion
|
|
156
|
+
|
|
157
|
+def insert_into_database1(database, pastname, newname, beforename, excelname, listname1, listpastx1, listpasty1,
|
|
158
|
+ listcgcs1, listbex, listbey, sxylist, wypd, gsx, gsy, listcgcs):
|
|
159
|
+ # 转换下汉字
|
143
|
160
|
utf_tn = to_utf8(excelname)
|
144
|
161
|
utf_nn = to_utf8(newname)
|
145
|
162
|
utf_pn = to_utf8(pastname)
|
146
|
163
|
utf_bn = to_utf8(beforename)
|
147
|
164
|
utf_bx = to_utf8('变形')
|
148
|
165
|
utf_wd = to_utf8('稳定')
|
149
|
|
- #将结果输出到数据库
|
|
166
|
+ # 将结果输出到数据库
|
150
|
167
|
db1 = sqlite3.connect(database)
|
151
|
|
- #获取游标
|
|
168
|
+ # 获取游标
|
152
|
169
|
cursor1 = db1.cursor()
|
153
|
|
- #先清除已有数据,用来更新
|
|
170
|
+ # 先清除已有数据,用来更新
|
154
|
171
|
try:
|
155
|
172
|
sqlstr3 = 'delete from WD_Result_Param WHERE TableName = ?'
|
156
|
173
|
sqlstr4 = 'delete from WD_Result_Point WHERE TableName = ?'
|
157
|
|
- cursor1.execute(sqlstr3,(utf_tn,))
|
158
|
|
- cursor1.execute(sqlstr4,(utf_tn,))
|
|
174
|
+ cursor1.execute(sqlstr3, (utf_tn,))
|
|
175
|
+ cursor1.execute(sqlstr4, (utf_tn,))
|
159
|
176
|
except:
|
160
|
177
|
pass
|
161
|
|
- cursor1.execute('INSERT INTO WD_Result_Param(TableName,Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3) VALUES(?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pn,utf_nn,sxylist[0],sxylist[1],sxylist[2],sxylist[3],sxylist[4],sxylist[5],))
|
162
|
|
- #WD_Result_Point的输入
|
|
178
|
+ cursor1.execute(
|
|
179
|
+ 'INSERT INTO WD_Result_Param(TableName,Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3) VALUES(?,?,?,?,?,?,?,?,?)',
|
|
180
|
+ (utf_tn, utf_pn, utf_nn, sxylist[0], sxylist[1], sxylist[2], sxylist[3], sxylist[4], sxylist[5],))
|
|
181
|
+ # WD_Result_Point的输入
|
163
|
182
|
kk = -1
|
164
|
183
|
kk1 = -1
|
165
|
184
|
if (-1) in listcgcs:
|
166
|
185
|
kk = 1
|
167
|
|
- #记位移点个数
|
|
186
|
+ # 记位移点个数
|
168
|
187
|
wyd = 0
|
169
|
188
|
for lname in listname1:
|
170
|
|
- #获取对应索引号
|
|
189
|
+ # 获取对应索引号
|
171
|
190
|
index1 = listname1.index(lname)
|
172
|
191
|
PointName = lname
|
173
|
192
|
First_X = listbex[index1]
|
|
@@ -176,38 +195,38 @@ def insert_into_database1(database,pastname,newname,beforename,excelname,listnam
|
176
|
195
|
Last_Y = listpasty1[index1]
|
177
|
196
|
Last_Wight = listcgcs1[index1]
|
178
|
197
|
New_Wight = listcgcs[index1]
|
179
|
|
- #位移点
|
|
198
|
+ # 位移点
|
180
|
199
|
if New_Wight == -1:
|
181
|
200
|
# 获取他原本的坐标和初始改算值进行对比
|
182
|
201
|
for smx in jslist:
|
183
|
202
|
if First_X == smx[0] and First_Y == smx[1]:
|
184
|
203
|
numa3 = sxylist[0] * jslist1[index1][0]
|
185
|
204
|
numa4 = sxylist[1] * jslist1[index1][1]
|
186
|
|
- numa5 = numa3 + numa4+ sxylist[2]
|
|
205
|
+ numa5 = numa3 + numa4 + sxylist[2]
|
187
|
206
|
numa6 = sxylist[3] * jslist1[index1][0]
|
188
|
207
|
numa7 = sxylist[4] * jslist1[index1][1]
|
189
|
|
- numa8 = numa6 + numa7+sxylist[5]
|
|
208
|
+ numa8 = numa6 + numa7 + sxylist[5]
|
190
|
209
|
Result_X = numa5
|
191
|
210
|
Result_Y = numa8
|
192
|
211
|
New_Wight = 1
|
193
|
212
|
numb1 = (numa5 - First_X) * 1000
|
194
|
213
|
numb2 = (numa8 - First_Y) * 1000
|
195
|
|
- numb3 = numb1 *numb1
|
196
|
|
- numb4 = numb2 *numb2
|
|
214
|
+ numb3 = numb1 * numb1
|
|
215
|
+ numb4 = numb2 * numb2
|
197
|
216
|
numb5 = math.sqrt(numb3 + numb4)
|
198
|
217
|
New_FirstX = numb1
|
199
|
218
|
New_FirstY = numb2
|
200
|
219
|
New_FirstP = numb5
|
201
|
|
- #新-首有个位移判定
|
|
220
|
+ # 新-首有个位移判定
|
202
|
221
|
if numb5 > wypd:
|
203
|
222
|
NFDis_Ass = utf_bx
|
204
|
223
|
else:
|
205
|
224
|
NFDis_Ass = utf_wd
|
206
|
|
-
|
|
225
|
+
|
207
|
226
|
numc1 = (numa5 - Last_X) * 1000
|
208
|
227
|
numc2 = (numa8 - Last_Y) * 1000
|
209
|
|
- numc3 = numc1 *numc1
|
210
|
|
- numc4 = numc2 *numc2
|
|
228
|
+ numc3 = numc1 * numc1
|
|
229
|
+ numc4 = numc2 * numc2
|
211
|
230
|
numc5 = math.sqrt(numc3 + numc4)
|
212
|
231
|
New_LastX = numc1
|
213
|
232
|
New_LastY = numc2
|
|
@@ -216,9 +235,9 @@ def insert_into_database1(database,pastname,newname,beforename,excelname,listnam
|
216
|
235
|
kk1 = 1
|
217
|
236
|
wyd = wyd + 1
|
218
|
237
|
break
|
219
|
|
- #不是位移点
|
|
238
|
+ # 不是位移点
|
220
|
239
|
else:
|
221
|
|
- #全部都是稳定点
|
|
240
|
+ # 全部都是稳定点
|
222
|
241
|
if kk == -1:
|
223
|
242
|
num3 = Last_X * Last_Wight
|
224
|
243
|
num4 = num3 + gsx[index1]
|
|
@@ -238,21 +257,21 @@ def insert_into_database1(database,pastname,newname,beforename,excelname,listnam
|
238
|
257
|
New_FirstX = numd1
|
239
|
258
|
New_FirstY = numd2
|
240
|
259
|
New_FirstP = numd5
|
241
|
|
- #新-首有个位移判定
|
|
260
|
+ # 新-首有个位移判定
|
242
|
261
|
if numd5 > wypd:
|
243
|
262
|
NFDis_Ass = utf_bx
|
244
|
263
|
else:
|
245
|
264
|
NFDis_Ass = utf_wd
|
246
|
265
|
nume1 = (num6 - Last_X) * 1000
|
247
|
266
|
nume2 = (num10 - Last_Y) * 1000
|
248
|
|
- nume3 = nume1 *nume1
|
249
|
|
- nume4 = nume2 *nume2
|
|
267
|
+ nume3 = nume1 * nume1
|
|
268
|
+ nume4 = nume2 * nume2
|
250
|
269
|
nume5 = math.sqrt(nume3 + nume4)
|
251
|
270
|
New_LastX = nume1
|
252
|
271
|
New_LastY = nume2
|
253
|
272
|
New_LastP = nume5
|
254
|
273
|
NLDis_Ass = utf_wd
|
255
|
|
- #有位移点,且已经走过了
|
|
274
|
+ # 有位移点,且已经走过了
|
256
|
275
|
if kk == 1 and kk1 == 1:
|
257
|
276
|
num3 = Last_X * Last_Wight
|
258
|
277
|
num4 = num3 + gsx[index1 - wyd]
|
|
@@ -272,21 +291,21 @@ def insert_into_database1(database,pastname,newname,beforename,excelname,listnam
|
272
|
291
|
New_FirstX = numd1
|
273
|
292
|
New_FirstY = numd2
|
274
|
293
|
New_FirstP = numd5
|
275
|
|
- #新-首有个位移判定
|
|
294
|
+ # 新-首有个位移判定
|
276
|
295
|
if numd5 > wypd:
|
277
|
296
|
NFDis_Ass = utf_bx
|
278
|
297
|
else:
|
279
|
298
|
NFDis_Ass = utf_wd
|
280
|
299
|
nume1 = (num6 - Last_X) * 1000
|
281
|
300
|
nume2 = (num10 - Last_Y) * 1000
|
282
|
|
- nume3 = nume1 *nume1
|
283
|
|
- nume4 = nume2 *nume2
|
|
301
|
+ nume3 = nume1 * nume1
|
|
302
|
+ nume4 = nume2 * nume2
|
284
|
303
|
nume5 = math.sqrt(nume3 + nume4)
|
285
|
304
|
New_LastX = nume1
|
286
|
305
|
New_LastY = nume2
|
287
|
306
|
New_LastP = nume5
|
288
|
307
|
NLDis_Ass = utf_wd
|
289
|
|
- #有位移点,但没有走过
|
|
308
|
+ # 有位移点,但没有走过
|
290
|
309
|
if kk == 1 and kk1 == -1:
|
291
|
310
|
num3 = Last_X * Last_Wight
|
292
|
311
|
num4 = num3 + gsx[index1]
|
|
@@ -306,25 +325,30 @@ def insert_into_database1(database,pastname,newname,beforename,excelname,listnam
|
306
|
325
|
New_FirstX = numd1
|
307
|
326
|
New_FirstY = numd2
|
308
|
327
|
New_FirstP = numd5
|
309
|
|
- #新-首有个位移判定
|
|
328
|
+ # 新-首有个位移判定
|
310
|
329
|
if numd5 > wypd:
|
311
|
330
|
NFDis_Ass = utf_bx
|
312
|
331
|
else:
|
313
|
332
|
NFDis_Ass = utf_wd
|
314
|
333
|
nume1 = (num6 - Last_X) * 1000
|
315
|
334
|
nume2 = (num10 - Last_Y) * 1000
|
316
|
|
- nume3 = nume1 *nume1
|
317
|
|
- nume4 = nume2 *nume2
|
|
335
|
+ nume3 = nume1 * nume1
|
|
336
|
+ nume4 = nume2 * nume2
|
318
|
337
|
nume5 = math.sqrt(nume3 + nume4)
|
319
|
338
|
New_LastX = nume1
|
320
|
339
|
New_LastY = nume2
|
321
|
340
|
New_LastP = nume5
|
322
|
341
|
NLDis_Ass = utf_wd
|
323
|
|
- #在这里整体输出
|
324
|
|
- cursor1.execute('INSERT INTO WD_Result_Point(TableName,First_ResultName,Last_ResultName,New_ResultName,First_X,First_Y,Last_X,Last_Y,Result_X,Result_Y,Last_Wight,New_Wight,New_FirstX,New_FirstY,New_FirstP,NFDis_Ass,New_LastX,New_LastY,New_LastP,NLDis_Ass,PointName) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_bn,utf_pn,utf_nn,First_X,First_Y,Last_X,Last_Y,Result_X,Result_Y,Last_Wight,New_Wight,New_FirstX,New_FirstY,New_FirstP,NFDis_Ass,New_LastX,New_LastY,New_LastP,NLDis_Ass,PointName,))
|
325
|
|
- #数据库执行
|
|
342
|
+ # 在这里整体输出
|
|
343
|
+ cursor1.execute(
|
|
344
|
+ 'INSERT INTO WD_Result_Point(TableName,First_ResultName,Last_ResultName,New_ResultName,First_X,First_Y,Last_X,Last_Y,Result_X,Result_Y,Last_Wight,New_Wight,New_FirstX,New_FirstY,New_FirstP,NFDis_Ass,New_LastX,New_LastY,New_LastP,NLDis_Ass,PointName) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
|
|
345
|
+ (
|
|
346
|
+ utf_tn, utf_bn, utf_pn, utf_nn, First_X, First_Y, Last_X, Last_Y, Result_X, Result_Y, Last_Wight,
|
|
347
|
+ New_Wight,
|
|
348
|
+ New_FirstX, New_FirstY, New_FirstP, NFDis_Ass, New_LastX, New_LastY, New_LastP, NLDis_Ass, PointName,))
|
|
349
|
+ # 数据库执行
|
326
|
350
|
db1.commit()
|
327
|
|
- #做完一切后,先关闭游标,再关闭数据库
|
|
351
|
+ # 做完一切后,先关闭游标,再关闭数据库
|
328
|
352
|
cursor1.close()
|
329
|
353
|
db1.close()
|
330
|
354
|
|
|
@@ -333,7 +357,10 @@ gszbx = []
|
333
|
357
|
gszby = []
|
334
|
358
|
jslist = []
|
335
|
359
|
jslist1 = []
|
336
|
|
-def bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js,file_name):
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+def bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx, listpasty, points,
|
|
363
|
+ listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js, file_name):
|
337
|
364
|
np.set_printoptions(suppress=False)
|
338
|
365
|
# pt用于给点数point计数
|
339
|
366
|
# point会随着回递函数而减少
|
|
@@ -372,12 +399,12 @@ def bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx,
|
372
|
399
|
dy2 = cjh(dylist)
|
373
|
400
|
# 这里再创建矩阵1
|
374
|
401
|
arr1 = np.array(((k2, 0, 0, 0), (0, s2, 0, 0),
|
375
|
|
- (0, 0, dx2, 0), (0, 0, 0, dy2)))
|
|
402
|
+ (0, 0, dx2, 0), (0, 0, 0, dy2)))
|
376
|
403
|
# 矩阵1的逆矩阵矩阵2
|
377
|
404
|
arr2 = np.linalg.inv(arr1)
|
378
|
405
|
# 求矩阵l
|
379
|
406
|
llist = jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx,
|
380
|
|
- listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
|
|
407
|
+ listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
|
381
|
408
|
# 得到数列e1,e2,e3,e4
|
382
|
409
|
e1 = cjh2(klist, llist)
|
383
|
410
|
e2 = cjh2(slist, llist)
|
|
@@ -396,9 +423,9 @@ def bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx,
|
396
|
423
|
lylist = jzys3(jylist1, 0, 1)
|
397
|
424
|
# 求改算坐标
|
398
|
425
|
gsx = gsys(listnewx, jxlist1, jylist1, lxlist,
|
399
|
|
- lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
|
|
426
|
+ lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
|
400
|
427
|
gsy = gsys(listnewy, jxlist2, jylist2, lxlist,
|
401
|
|
- lylist, arrz, sf, zxzbnewy, zxzbpasty, 1)
|
|
428
|
+ lylist, arrz, sf, zxzbnewy, zxzbpasty, 1)
|
402
|
429
|
# 还是要先求较差
|
403
|
430
|
xcx = xcys(gsx, listpastx)
|
404
|
431
|
xcy = xcys(gsy, listpasty)
|
|
@@ -447,9 +474,9 @@ def bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx,
|
447
|
474
|
n3 = zxzbpastx - zxzbnewx - s1 - s2 + float(arrz[2])
|
448
|
475
|
n4 = (-1) * float(arrz[1])
|
449
|
476
|
n5 = n1
|
450
|
|
- s3 = (-1)*float(arrz[0])*zxzbnewy
|
451
|
|
- s4 = float(arrz[1])*zxzbnewx
|
452
|
|
- n6 = s3 + s4 + float(arrz[3])+zxzbpasty-zxzbnewy
|
|
477
|
+ s3 = (-1) * float(arrz[0]) * zxzbnewy
|
|
478
|
+ s4 = float(arrz[1]) * zxzbnewx
|
|
479
|
+ n6 = s3 + s4 + float(arrz[3]) + zxzbpasty - zxzbnewy
|
453
|
480
|
sxylist = []
|
454
|
481
|
sxylist.append(n1)
|
455
|
482
|
sxylist.append(n2)
|
|
@@ -466,56 +493,58 @@ def bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx,
|
466
|
493
|
relist1.append(gszbx)
|
467
|
494
|
relist1.append(gszby)
|
468
|
495
|
relist1.append(sxylist)
|
469
|
|
- #存入数据库
|
470
|
|
- insert_into_database1(dbpath,lastname,finalname,befname,file_name,listname1,listpastx1,listpasty1,listcgcs1,listbex,listbey,sxylist,wypd,gsx,gsy,listcgcs)
|
|
496
|
+ # 存入数据库
|
|
497
|
+ insert_into_database1(dbpath, lastname, finalname, befname, file_name, listname1, listpastx1, listpasty1,
|
|
498
|
+ listcgcs1, listbex, listbey, sxylist, wypd, gsx, gsy, listcgcs)
|
471
|
499
|
else:
|
472
|
|
- # 先把所有的合在一起,方便删除
|
473
|
|
- lenlist1 = len(xcx)
|
474
|
|
- ii = 0
|
475
|
|
- relist1 = []
|
476
|
|
- while ii < lenlist1:
|
477
|
|
- smlist1 = []
|
478
|
|
- nn2 = xcx[ii] * xcx[ii]
|
479
|
|
- mm2 = xcy[ii] * xcy[ii]
|
480
|
|
- nm2 = math.sqrt(nn2 + mm2)
|
481
|
|
- smlist1.append(nm2)
|
482
|
|
- smlist1.append(listname[ii])
|
483
|
|
- smlist1.append(listnewx[ii])
|
484
|
|
- smlist1.append(listnewy[ii])
|
485
|
|
- smlist1.append(listpastx[ii])
|
486
|
|
- smlist1.append(listpasty[ii])
|
487
|
|
- relist1.append(smlist1)
|
488
|
|
- ii = ii + 1
|
489
|
|
- # 直接删除最大的那个
|
490
|
|
- relist1.sort(key=takeFirst, reverse=True)
|
491
|
|
- num1 = relist1[0]
|
492
|
|
- # 获取name
|
493
|
|
- num2 = num1[1]
|
494
|
|
- ii2 = 0
|
495
|
|
- mm2 = 0
|
496
|
|
- while ii2 < lenlist1:
|
497
|
|
- if listname[ii2] == num2:
|
498
|
|
- del listname[ii2]
|
499
|
|
- del listnewx[ii2]
|
500
|
|
- del listnewy[ii2]
|
501
|
|
- del listpastx[ii2]
|
502
|
|
- del listpasty[ii2]
|
503
|
|
- points = points - 1
|
504
|
|
- break
|
505
|
|
- else:
|
506
|
|
- ii2 = ii2 + 1
|
507
|
|
- while mm2 < len(listcgcs):
|
508
|
|
- if listname1[mm2] == num2:
|
509
|
|
- listcgcs[mm2] = -1
|
510
|
|
- break
|
511
|
|
- else:
|
512
|
|
- mm2 = mm2 + 1
|
513
|
|
- print(" Finish!")
|
514
|
|
- js1 = 1
|
515
|
|
- bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx,
|
516
|
|
- listpasty, points, listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js1,file_name)
|
|
500
|
+ # 先把所有的合在一起,方便删除
|
|
501
|
+ lenlist1 = len(xcx)
|
|
502
|
+ ii = 0
|
|
503
|
+ relist1 = []
|
|
504
|
+ while ii < lenlist1:
|
|
505
|
+ smlist1 = []
|
|
506
|
+ nn2 = xcx[ii] * xcx[ii]
|
|
507
|
+ mm2 = xcy[ii] * xcy[ii]
|
|
508
|
+ nm2 = math.sqrt(nn2 + mm2)
|
|
509
|
+ smlist1.append(nm2)
|
|
510
|
+ smlist1.append(listname[ii])
|
|
511
|
+ smlist1.append(listnewx[ii])
|
|
512
|
+ smlist1.append(listnewy[ii])
|
|
513
|
+ smlist1.append(listpastx[ii])
|
|
514
|
+ smlist1.append(listpasty[ii])
|
|
515
|
+ relist1.append(smlist1)
|
|
516
|
+ ii = ii + 1
|
|
517
|
+ # 直接删除最大的那个
|
|
518
|
+ relist1.sort(key=takeFirst, reverse=True)
|
|
519
|
+ num1 = relist1[0]
|
|
520
|
+ # 获取name
|
|
521
|
+ num2 = num1[1]
|
|
522
|
+ ii2 = 0
|
|
523
|
+ mm2 = 0
|
|
524
|
+ while ii2 < lenlist1:
|
|
525
|
+ if listname[ii2] == num2:
|
|
526
|
+ del listname[ii2]
|
|
527
|
+ del listnewx[ii2]
|
|
528
|
+ del listnewy[ii2]
|
|
529
|
+ del listpastx[ii2]
|
|
530
|
+ del listpasty[ii2]
|
|
531
|
+ points = points - 1
|
|
532
|
+ break
|
|
533
|
+ else:
|
|
534
|
+ ii2 = ii2 + 1
|
|
535
|
+ while mm2 < len(listcgcs):
|
|
536
|
+ if listname1[mm2] == num2:
|
|
537
|
+ listcgcs[mm2] = -1
|
|
538
|
+ break
|
|
539
|
+ else:
|
|
540
|
+ mm2 = mm2 + 1
|
|
541
|
+ print(" Finish!")
|
|
542
|
+ js1 = 1
|
|
543
|
+ bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx,
|
|
544
|
+ listpasty, points, listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js1, file_name)
|
|
545
|
+
|
517
|
546
|
|
518
|
|
-def tablein(dbpath,file_name):
|
|
547
|
+def tablein(dbpath, file_name):
|
519
|
548
|
# 收集每一列的数据,方便后期计算
|
520
|
549
|
listname1 = []
|
521
|
550
|
listpastx1 = []
|
|
@@ -532,12 +561,12 @@ def tablein(dbpath,file_name):
|
532
|
561
|
listbex = []
|
533
|
562
|
listbey = []
|
534
|
563
|
points = 0
|
535
|
|
- #查询,提取需要的数据
|
|
564
|
+ # 查询,提取需要的数据
|
536
|
565
|
db2 = sqlite3.connect(dbpath)
|
537
|
566
|
cursor2 = db2.cursor()
|
538
|
567
|
utfstr1 = to_utf8(file_name)
|
539
|
568
|
sqlstr1 = 'SELECT * FROM WD_Input_Point WHERE TableName = ?'
|
540
|
|
- cursor2.execute(sqlstr1,(utfstr1,))
|
|
569
|
+ cursor2.execute(sqlstr1, (utfstr1,))
|
541
|
570
|
all_da = cursor2.fetchall()
|
542
|
571
|
for da in all_da:
|
543
|
572
|
listbex.append(da[4])
|
|
@@ -554,11 +583,11 @@ def tablein(dbpath,file_name):
|
554
|
583
|
listname.append(da[11])
|
555
|
584
|
listname1.append(da[11])
|
556
|
585
|
sqlstr2 = 'SELECT * FROM WD_Input_Param WHERE TableName = ?'
|
557
|
|
- cursor2.execute(sqlstr2,(utfstr1,))
|
|
586
|
+ cursor2.execute(sqlstr2, (utfstr1,))
|
558
|
587
|
all_par = cursor2.fetchall()
|
559
|
588
|
befname = all_par[0][0].decode('utf-8')
|
560
|
589
|
lastname = all_par[0][1].decode('utf-8')
|
561
|
|
- finalname = all_par[0][2].decode('utf-8')
|
|
590
|
+ finalname = all_par[0][2].decode('utf-8')
|
562
|
591
|
# pjbc是平均边长
|
563
|
592
|
# fxzwc是方向中误差,zrbzwc是最弱边边长相对中误差,pjbcs是平均边数,pjfxs是平均方向数,sf是缩放值
|
564
|
593
|
# 新增总边数zbs,总方向数zfxs
|
|
@@ -580,14 +609,19 @@ def tablein(dbpath,file_name):
|
580
|
609
|
wypd3 = math.sqrt(wypd1 + wypd2)
|
581
|
610
|
wypd = round((wypd3 * 2 * math.sqrt(2)), 9)
|
582
|
611
|
wypd0 = wypd
|
583
|
|
- js=0
|
584
|
|
- return listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs, listbex, listbey, sf, befname, finalname, lastname, js
|
|
612
|
+ js = 0
|
|
613
|
+ return listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, listbex, listbey, sf, befname, finalname, lastname, js
|
585
|
614
|
|
586
|
615
|
|
587
|
616
|
# 主函数 计算
|
588
|
|
-def main_function(dbpath,file_name):
|
589
|
|
- #从数据库中调用
|
590
|
|
- listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs, listbex, listbey, sf, befname, finalname, lastname, js = tablein(dbpath,file_name)
|
591
|
|
- #计算
|
592
|
|
- bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js,file_name)
|
593
|
|
- messagebox.showinfo("提示",f"文件 '{file_name}' 计算成功!")
|
|
617
|
+def main_function(file_name, dbpath):
|
|
618
|
+ try:
|
|
619
|
+ # 从数据库中调用
|
|
620
|
+ listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, listbex, listbey, sf, befname, finalname, lastname, js = tablein(
|
|
621
|
+ dbpath, file_name)
|
|
622
|
+ # 计算
|
|
623
|
+ bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty,
|
|
624
|
+ points, listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js, file_name)
|
|
625
|
+ QMessageBox.information(None, "提示", f"文件 '{file_name}' 计算成功!")
|
|
626
|
+ except Exception as e:
|
|
627
|
+ QMessageBox.critical(None, "错误", f"文件 '{file_name}' 计算失败!错误信息: {str(e)}")
|