控制网复测平面基准归算程序(包含控制网复测平面基准计算,平面控制网稳定性计算,水准测段高差稳定计算三个程序功能)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main_new.py 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. # ///////////////////////////////////////////////////////////////
  2. #
  3. # BY: WANDERSON M.PIMENTA
  4. # PROJECT MADE WITH: Qt Designer and PySide6
  5. # V: 1.0.0
  6. #
  7. # This project can be used freely for all uses, as long as they maintain the
  8. # respective credits only in the Python scripts, any information in the visual
  9. # interface (GUI) can be modified without any implication.
  10. #
  11. # There are limitations on Qt licenses if you want to use your products
  12. # commercially, I recommend reading them on the official website:
  13. # https://doc.qt.io/qtforpython/licenses.html
  14. #
  15. # ///////////////////////////////////////////////////////////////
  16. from PySide6.QtWidgets import QFileDialog
  17. from PySide6.QtCore import Signal, Slot
  18. from PySide6.QtSql import QSqlTableModel,QSqlDatabase
  19. import sqlite3
  20. import sys
  21. import os
  22. import platform
  23. from tkinter import messagebox
  24. # IMPORT / GUI AND MODULES AND WIDGETS
  25. # ///////////////////////////////////////////////////////////////
  26. from modules import *
  27. from widgets import *
  28. os.environ["QT_FONT_DPI"] = "96" # FIX Problem for High DPI and Scale above 100%
  29. # SET AS GLOBAL WIDGETS
  30. # ///////////////////////////////////////////////////////////////
  31. widgets = None
  32. excelname = ''
  33. # 获取项目根目录
  34. project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
  35. # 将项目根目录添加到 sys.path
  36. sys.path.append(project_root)
  37. # 表格的模型
  38. class MyTableModel(QAbstractTableModel):
  39. def __init__(self, data):
  40. super().__init__()
  41. self._data = data
  42. # 重新定义行数
  43. def rowCount(self, parent=QModelIndex()):
  44. return len(self._data)
  45. # 重新定义列数
  46. def columnCount(self, parent=QModelIndex()):
  47. return len(self._data[0]) if self._data else 0
  48. # 重新定义数据
  49. def data(self, index, role=Qt.DisplayRole):
  50. if not index.isValid():
  51. return None
  52. if role == Qt.DisplayRole:
  53. return self._data[index.row()][index.column()]
  54. return None
  55. class MainWindow(QMainWindow):
  56. def __init__(self):
  57. QMainWindow.__init__(self)
  58. # super().__init__()
  59. # SET AS GLOBAL WIDGETS
  60. # ///////////////////////////////////////////////////////////////
  61. self.ui = Ui_MainWindow()
  62. self.ui.setupUi(self)
  63. # self.comboBox_2 = QComboBox(self)
  64. # ...此处为省略代码...
  65. global widgets
  66. widgets = self.ui
  67. # 是否使用系统自带标题栏 True是不使用,False使用
  68. # ///////////////////////////////////////////////////////////////
  69. Settings.ENABLE_CUSTOM_TITLE_BAR = True
  70. # APP名称
  71. # ///////////////////////////////////////////////////////////////
  72. title = "控制网复测平面基准归算程序"
  73. description = "控制网复测平面基准归算程序"
  74. # APPLY TEXTS
  75. self.setWindowTitle(title)
  76. widgets.titleRightInfo.setText(description)
  77. # TOGGLE MENU
  78. # ///////////////////////////////////////////////////////////////
  79. widgets.toggleButton.clicked.connect(lambda: UIFunctions.toggleMenu(self, True))
  80. # SET UI DEFINITIONS
  81. # ///////////////////////////////////////////////////////////////
  82. UIFunctions.uiDefinitions(self)
  83. # QTableWidget PARAMETERS
  84. # ///////////////////////////////////////////////////////////////
  85. # widgets.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
  86. # 点击事件
  87. # ///////////////////////////////////////////////////////////////
  88. # 左边菜单
  89. # 首页
  90. widgets.btn_home.clicked.connect(self.buttonClick)
  91. # 输入表格
  92. widgets.btn_widgets.clicked.connect(self.buttonClick)
  93. # 成果预览
  94. widgets.btn_new.clicked.connect(self.buttonClick)
  95. # 数据一览
  96. widgets.btn_data.clicked.connect(self.buttonClick)
  97. # 皮肤切换
  98. widgets.btn_message.clicked.connect(self.buttonClick)
  99. # 打开上传文件夹
  100. widgets.upload.clicked.connect(self.buttonClick)
  101. # 拓展左侧栏
  102. # def openCloseLeftBox():
  103. # UIFunctions.toggleLeftBox(self, True)
  104. # widgets.toggleLeftBox.clicked.connect(openCloseLeftBox)
  105. # widgets.extraCloseColumnBtn.clicked.connect(openCloseLeftBox)
  106. # EXTRA RIGHT BOX
  107. def openCloseRightBox():
  108. UIFunctions.toggleRightBox(self, True)
  109. widgets.settingsTopBtn.clicked.connect(openCloseRightBox)
  110. # 展示APP
  111. # ///////////////////////////////////////////////////////////////
  112. self.show()
  113. # 设置主题
  114. # ///////////////////////////////////////////////////////////////
  115. if getattr(sys, 'frozen', False):
  116. absPath = os.path.dirname(os.path.abspath(sys.executable))
  117. elif __file__:
  118. absPath = os.path.dirname(os.path.abspath(__file__))
  119. useCustomTheme = True
  120. self.useCustomTheme = useCustomTheme
  121. self.absPath = absPath
  122. themeFile = r"Front\themes\py_dracula_light.qss"
  123. # 设置主题和HACKS
  124. if useCustomTheme:
  125. # LOAD AND APPLY STYLE
  126. UIFunctions.theme(self, themeFile, True)
  127. # SET HACKS
  128. AppFunctions.setThemeHack(self)
  129. # 设置主页和选择菜单
  130. # ///////////////////////////////////////////////////////////////
  131. widgets.stackedWidget.setCurrentWidget(widgets.home)
  132. widgets.btn_home.setStyleSheet(UIFunctions.selectMenu(widgets.btn_home.styleSheet()))
  133. self.bind()
  134. #绑定组件
  135. def bind(self):
  136. # 计算
  137. widgets.compute.clicked.connect(self.computeClick)
  138. #删除tableview
  139. def delete_table_view(table_view):
  140. table_view.setParent(None)
  141. table_view.deleteLater()
  142. #默认第一个参数是self,所以使用时只有一个参数
  143. #稳定性成果表
  144. def Arrange_Data(self,list1):
  145. #最终return的
  146. list2 = []
  147. #点号部分
  148. nlist = []
  149. for data1 in list1:
  150. #点名
  151. #存每一行的数据
  152. resultlist = []
  153. pn = data1[0].decode('utf-8')
  154. resultlist.append(pn)
  155. nlist.append(pn)
  156. resultlist.append(data1[1])
  157. resultlist.append(data1[2])
  158. resultlist.append(data1[3])
  159. resultlist.append(data1[4])
  160. resultlist.append(data1[5])
  161. resultlist.append(data1[6])
  162. resultlist.append(data1[7])
  163. resultlist.append(data1[8])
  164. resultlist.append(data1[9])
  165. resultlist.append(data1[10])
  166. resultlist.append(data1[11])
  167. #判定1
  168. an1 = data1[12].decode('utf-8')
  169. resultlist.append(an1)
  170. resultlist.append(data1[13])
  171. resultlist.append(data1[14])
  172. resultlist.append(data1[15])
  173. #判定2
  174. an2 = data1[16].decode('utf-8')
  175. resultlist.append(an2)
  176. list2.append(resultlist)
  177. return nlist,list2
  178. #复测成果表
  179. def Arrange_Data1(self,list1):
  180. #最终return的
  181. list2 = []
  182. #点号部分
  183. nlist = []
  184. for data1 in list1:
  185. #点名
  186. #存每一行的数据
  187. resultlist = []
  188. pn = data1[0].decode('utf-8')
  189. resultlist.append(pn)
  190. nlist.append(pn)
  191. resultlist.append(data1[1])
  192. resultlist.append(data1[2])
  193. resultlist.append(data1[3])
  194. resultlist.append(data1[4])
  195. resultlist.append(data1[5])
  196. resultlist.append(data1[6])
  197. resultlist.append(data1[7])
  198. #判定
  199. an1 = data1[8].decode('utf-8')
  200. resultlist.append(an1)
  201. list2.append(resultlist)
  202. return nlist,list2
  203. #基准归算表
  204. def Arrange_Data2(self,list1):
  205. #最终return的
  206. list2 = []
  207. #点号部分
  208. nlist = []
  209. for data1 in list1:
  210. #点名
  211. #存每一行的数据
  212. resultlist = []
  213. pn = data1[0].decode('utf-8')
  214. resultlist.append(pn)
  215. nlist.append(pn)
  216. resultlist.append(data1[1])
  217. resultlist.append(data1[2])
  218. resultlist.append(data1[3])
  219. resultlist.append(data1[4])
  220. resultlist.append(data1[5])
  221. #判定
  222. an1 = data1[6].decode('utf-8')
  223. resultlist.append(an1)
  224. list2.append(resultlist)
  225. return nlist,list2
  226. #稳定性成果表
  227. def Data_in_Cell(self,list1):
  228. model = QStandardItemModel()
  229. xx = 0
  230. while xx < len(list1):
  231. data1 = list1[xx]
  232. #点号
  233. cell1 = str(data1[0])
  234. item = QStandardItem(cell1)
  235. model.setItem(xx, 0, item)
  236. #首期
  237. cell1 = str(round(data1[1],4))
  238. item = QStandardItem(cell1)
  239. model.setItem(xx, 1, item)
  240. cell1 = str(round(data1[2],4))
  241. item = QStandardItem(cell1)
  242. model.setItem(xx, 2, item)
  243. #上期
  244. cell1 = str(round(data1[3],4))
  245. item = QStandardItem(cell1)
  246. model.setItem(xx, 3, item)
  247. cell1 = str(round(data1[4],4))
  248. item = QStandardItem(cell1)
  249. model.setItem(xx, 4, item)
  250. #权
  251. cell1 = str(int(data1[5]))
  252. item = QStandardItem(cell1)
  253. model.setItem(xx, 5, item)
  254. #本期
  255. cell1 = str(round(data1[6],4))
  256. item = QStandardItem(cell1)
  257. model.setItem(xx, 6, item)
  258. cell1 = str(round(data1[7],4))
  259. item = QStandardItem(cell1)
  260. model.setItem(xx, 7, item)
  261. #权
  262. cell1 = str(int(data1[8]))
  263. item = QStandardItem(cell1)
  264. model.setItem(xx, 8, item)
  265. #本-首
  266. cell1 = str(round(data1[9],1))
  267. item = QStandardItem(cell1)
  268. model.setItem(xx, 9, item)
  269. cell1 = str(round(data1[10],1))
  270. item = QStandardItem(cell1)
  271. model.setItem(xx, 10, item)
  272. cell1 = str(round(data1[11],1))
  273. item = QStandardItem(cell1)
  274. model.setItem(xx, 11, item)
  275. #判定(如果是稳定则不显示)
  276. cell1 = str(data1[12])
  277. if cell1 == '稳定':
  278. cell1 = ''
  279. item = QStandardItem(cell1)
  280. model.setItem(xx, 12, item)
  281. #本-上
  282. cell1 = str(round(data1[13],1))
  283. item = QStandardItem(cell1)
  284. model.setItem(xx, 13, item)
  285. cell1 = str(round(data1[14],1))
  286. item = QStandardItem(cell1)
  287. model.setItem(xx, 14, item)
  288. cell1 = str(round(data1[15],1))
  289. item = QStandardItem(cell1)
  290. model.setItem(xx, 15, item)
  291. #判定
  292. cell1 = str(data1[16])
  293. if cell1 == '稳定':
  294. cell1 = ''
  295. item = QStandardItem(cell1)
  296. model.setItem(xx, 16, item)
  297. xx = xx + 1
  298. return model
  299. #复测成果表
  300. def Data_in_Cell1(self,list1):
  301. model = QStandardItemModel()
  302. xx = 0
  303. while xx < len(list1):
  304. data1 = list1[xx]
  305. #点号
  306. cell1 = str(data1[0])
  307. item = QStandardItem(cell1)
  308. model.setItem(xx, 0, item)
  309. #上期
  310. cell1 = str(round(data1[1],4))
  311. item = QStandardItem(cell1)
  312. model.setItem(xx, 1, item)
  313. cell1 = str(round(data1[2],4))
  314. item = QStandardItem(cell1)
  315. model.setItem(xx, 2, item)
  316. #本期
  317. cell1 = str(round(data1[3],4))
  318. item = QStandardItem(cell1)
  319. model.setItem(xx, 3, item)
  320. cell1 = str(round(data1[4],4))
  321. item = QStandardItem(cell1)
  322. model.setItem(xx, 4, item)
  323. #上-本
  324. cell1 = str(round(data1[5],1))
  325. item = QStandardItem(cell1)
  326. model.setItem(xx, 5, item)
  327. cell1 = str(round(data1[6],1))
  328. item = QStandardItem(cell1)
  329. model.setItem(xx, 6, item)
  330. cell1 = str(round(data1[7],1))
  331. item = QStandardItem(cell1)
  332. model.setItem(xx, 7, item)
  333. #判定(如果是稳定则不显示)
  334. cell1 = str(data1[8])
  335. if cell1 == '稳定':
  336. cell1 = ''
  337. item = QStandardItem(cell1)
  338. model.setItem(xx, 8, item)
  339. xx = xx + 1
  340. return model
  341. #基准归算表
  342. def Data_in_Cell2(self,list1):
  343. model = QStandardItemModel()
  344. xx = 0
  345. while xx < len(list1):
  346. data1 = list1[xx]
  347. #点号
  348. cell1 = str(data1[0])
  349. item = QStandardItem(cell1)
  350. model.setItem(xx, 0, item)
  351. #计算
  352. cell1 = str(round(data1[1],4))
  353. item = QStandardItem(cell1)
  354. model.setItem(xx, 1, item)
  355. cell1 = str(round(data1[2],4))
  356. item = QStandardItem(cell1)
  357. model.setItem(xx, 2, item)
  358. #上-计
  359. cell1 = str(round(data1[3],1))
  360. item = QStandardItem(cell1)
  361. model.setItem(xx, 3, item)
  362. cell1 = str(round(data1[4],1))
  363. item = QStandardItem(cell1)
  364. model.setItem(xx, 4, item)
  365. cell1 = str(round(data1[5],1))
  366. item = QStandardItem(cell1)
  367. model.setItem(xx, 5, item)
  368. #判定(如果是稳定则不显示)
  369. cell1 = str(data1[6])
  370. if cell1 == '稳定':
  371. cell1 = ''
  372. item = QStandardItem(cell1)
  373. model.setItem(xx, 6, item)
  374. xx = xx + 1
  375. return model
  376. def computeClick(self):
  377. # GET BUTTON CLICKED
  378. btn = self.sender()
  379. btnName = btn.objectName()
  380. #处理选中的文件
  381. # print(file_path)
  382. UIFunctions.compute_show_process_excel_file(self, file_path)
  383. current_text = self.ui.comboBox_2.currentText()
  384. db_path = r"D:\4work_now\20240819GS\ControlNetwork\ControlNetwork\UI\SQL\DataBase.db"
  385. #转换下
  386. excelname = os.path.basename(file_path)
  387. utf_en = excelname.encode('utf-8')
  388. # file_path = file_path
  389. if current_text == "水准测段高差稳定计算":
  390. #只显示一个tab
  391. self.ui.tabWidget.setTabVisible(0,True)
  392. self.ui.tabWidget.setTabVisible(1,False)
  393. self.ui.tabWidget.setTabVisible(2,False)
  394. #重新设置文字名称
  395. self.ui.tabWidget.setTabText(0,'测段高差计算表')
  396. # 计算结束自动跳转结果页面,并保留查询内容,以便输出
  397. widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
  398. UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
  399. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
  400. elif current_text == "控制网复测平面基准计算":
  401. #就用已有的选项卡
  402. self.ui.tabWidget.setTabVisible(0,True)
  403. self.ui.tabWidget.setTabVisible(1,True)
  404. self.ui.tabWidget.setTabVisible(2,True)
  405. #重新设置文字名称
  406. self.ui.tabWidget.setTabText(0,'复测成果表')
  407. self.ui.tabWidget.setTabText(1,'基准归算模型')
  408. self.ui.tabWidget.setTabText(2,'复测基准归算表')
  409. #链接数据库并显示
  410. # 连接到数据库
  411. #将结果输出到数据库
  412. db1 = sqlite3.connect(db_path)
  413. #获取游标
  414. cursor1 = db1.cursor()
  415. #查询表内符合的所有数据(分成两个结果分别显示)
  416. #复测成果表
  417. sqlstr1 = 'select PointName,Last_X,Last_Y,Result_X,Result_Y,Last_ResultX,Last_ResultY,Last_ResultP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
  418. cursor1.execute(sqlstr1,(utf_en,))
  419. #获取结果集
  420. result1 = cursor1.fetchall()
  421. #基准归算表
  422. sqlstr11 = 'select PointName,Cal_X,Cal_Y,Last_CalX,Last_CalY,Last_CalP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
  423. cursor1.execute(sqlstr11,(utf_en,))
  424. #获取结果集
  425. result2 = cursor1.fetchall()
  426. #对结果集进行处理,把汉字转换过来,添加表头部分
  427. nlist1,plist1 = self.Arrange_Data1(result1)
  428. nlist2,plist2 = self.Arrange_Data2(result2)
  429. # 创建一个数据模型(复测成果表)
  430. self.model1 = QStandardItemModel()
  431. #把数据放进去
  432. model1 = self.Data_in_Cell1(plist1)
  433. model2 = self.Data_in_Cell2(plist2)
  434. #设置表头
  435. model1.setHorizontalHeaderLabels(['点名', '前期X','前期Y','本期X', '本期Y','前期-本期X','前期-本期Y','前期-本期P','位移判定'])
  436. model1.setVerticalHeaderLabels(nlist1)
  437. #QTableView并将数据模型与之关联
  438. self.ui.resultTableView.setModel(model1)
  439. self.ui.resultTableView.show()
  440. #设置表头
  441. model2.setHorizontalHeaderLabels(['点名', '基准归算X','基准归算Y','前期-归算X','前期-归算Y','前期-归算P','位移判定'])
  442. model2.setVerticalHeaderLabels(nlist2)
  443. #QTableView并将数据模型与之关联
  444. self.ui.reconTableView.setModel(model2)
  445. self.ui.reconTableView.show()
  446. #富文本的html
  447. sqlstr2 = 'select Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3 from GS_Trans_Param WHERE TableName = ?'
  448. cursor1.execute(sqlstr2,(utf_en,))
  449. #获取结果集
  450. result1 = cursor1.fetchall()
  451. str1 = result1[0][0].decode('utf-8')
  452. str2 = result1[0][1].decode('utf-8')
  453. n1 = result1[0][2]
  454. n2 = result1[0][3]
  455. n3 = result1[0][4]
  456. n4 = result1[0][5]
  457. n5 = result1[0][6]
  458. n6 = result1[0][7]
  459. str0 = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
  460. <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
  461. p, li { white-space: pre-wrap; }
  462. hr { height: 1px; border-width: 0; }
  463. li.unchecked::marker { content: "\2610"; }
  464. li.checked::marker { content: "\2612"; }
  465. </style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
  466. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; color:#000000;">"""+str2+"""--"""+str1+"""</span><span style=" font-size:14pt;">已知系统转换公式:</span></p>
  467. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">X</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n1)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n2)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n3)+"""</span><span style=" font-size:14pt;">)</span></p>
  468. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">Y</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n4)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n5)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n6)+"""</span><span style=" font-size:14pt;">)</span></p>
  469. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">式中:</span><span style=" font-size:14pt; font-weight:700; color:#000000;">x、y</span><span style=" font-size:14pt;">为</span><span style=" font-size:14pt; color:#000000;">"""+str2+"""</span><span style=" font-size:14pt;">坐标;</span></p>
  470. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;"> </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为"""+str1+"""已知系统的"""+str2+"""归算坐标。</span></p></body></html>"""
  471. self.ui.printTableView.setHtml(str0)
  472. # 计算结束自动跳转结果页面,并保留查询内容,以便输出
  473. widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
  474. UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
  475. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
  476. # GS.main_function(file_path, db_path)
  477. # 添加控制网执行代码
  478. elif current_text=="平面控制网稳定性计算":
  479. #只显示头两个tab
  480. self.ui.tabWidget.setTabVisible(0,True)
  481. self.ui.tabWidget.setTabVisible(1,True)
  482. self.ui.tabWidget.setTabVisible(2,False)
  483. #重新设置文字名称
  484. self.ui.tabWidget.setTabText(0,'稳定性分析成果表')
  485. self.ui.tabWidget.setTabText(1,'自由网成果归算模型')
  486. #链接数据库并显示
  487. # 连接到数据库
  488. #将结果输出到数据库
  489. db1 = sqlite3.connect(db_path)
  490. #获取游标
  491. cursor1 = db1.cursor()
  492. #查询表内符合的所有数据
  493. sqlstr1 = 'select PointName,First_X,First_Y,Last_X,Last_Y,Last_Wight,Result_X,Result_Y,New_Wight,New_FirstX,New_FirstY,New_FirstP,NFDis_Ass,New_LastX,New_LastY,New_LastP,NLDis_Ass from WD_Result_Point WHERE TableName = ?'
  494. cursor1.execute(sqlstr1,(utf_en,))
  495. #获取结果集
  496. result = cursor1.fetchall()
  497. #对结果集进行处理,把汉字转换过来,添加表头部分
  498. nlist,plist = self.Arrange_Data(result)
  499. # 创建一个数据模型
  500. self.model = QStandardItemModel()
  501. #把数据放进去
  502. model1 = self.Data_in_Cell(plist)
  503. #设置表头
  504. model1.setHorizontalHeaderLabels(['点名', '首期X','首期Y','上期X', '上期Y','权','本期X','本期Y','权','本期-首期X','本期-首期Y','本期-首期P','位移判定', '本期-上期X','本期-上期Y','本期-上期P','位移判定'])
  505. model1.setVerticalHeaderLabels(nlist)
  506. #QTableView并将数据模型与之关联
  507. self.ui.resultTableView.setModel(model1)
  508. self.ui.resultTableView.show()
  509. #富文本的html
  510. sqlstr2 = 'select Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3 from WD_Result_Param WHERE TableName = ?'
  511. cursor1.execute(sqlstr2,(utf_en,))
  512. #获取结果集
  513. result1 = cursor1.fetchall()
  514. str1 = result1[0][0].decode('utf-8')
  515. str2 = result1[0][1].decode('utf-8')
  516. n1 = result1[0][2]
  517. n2 = result1[0][3]
  518. n3 = result1[0][4]
  519. n4 = result1[0][5]
  520. n5 = result1[0][6]
  521. n6 = result1[0][7]
  522. str0 = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
  523. <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
  524. p, li { white-space: pre-wrap; }
  525. hr { height: 1px; border-width: 0; }
  526. li.unchecked::marker { content: "\2610"; }
  527. li.checked::marker { content: "\2612"; }
  528. </style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
  529. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; color:#000000;">"""+str2+"""--"""+str1+"""</span><span style=" font-size:14pt;">已知系统转换公式:</span></p>
  530. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">X</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n1)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n2)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n3)+"""</span><span style=" font-size:14pt;">)</span></p>
  531. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">Y</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n4)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n5)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n6)+"""</span><span style=" font-size:14pt;">)</span></p>
  532. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">式中:</span><span style=" font-size:14pt; font-weight:700; color:#000000;">x、y</span><span style=" font-size:14pt;">为</span><span style=" font-size:14pt; color:#000000;">"""+str2+"""</span><span style=" font-size:14pt;">坐标;</span></p>
  533. <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;"> </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为"""+str1+"""已知系统的"""+str2+"""归算坐标。</span></p></body></html>"""
  534. self.ui.printTableView.setHtml(str0)
  535. #----------------------------------------------------------
  536. # 计算结束自动跳转结果页面,并保留查询内容,以便输出
  537. widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
  538. UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
  539. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
  540. # 点击事件
  541. # 在这里添加点击事件的方法
  542. # ///////////////////////////////////////////////////////////////
  543. def buttonClick(self):
  544. # GET BUTTON CLICKED
  545. btn = self.sender()
  546. btnName = btn.objectName()
  547. # 首页
  548. if btnName == "btn_home":
  549. widgets.stackedWidget.setCurrentWidget(widgets.home)
  550. UIFunctions.resetStyle(self, btnName)
  551. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
  552. # 输入表格
  553. if btnName == "btn_widgets":
  554. widgets.stackedWidget.setCurrentWidget(widgets.widgets)
  555. UIFunctions.resetStyle(self, btnName)
  556. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
  557. # 成果预览
  558. if btnName == "btn_new":
  559. widgets.stackedWidget.setCurrentWidget(widgets.new_page) # SET PAGE
  560. UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
  561. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
  562. # 数据一览
  563. if btnName == "btn_data":
  564. widgets.stackedWidget.setCurrentWidget(widgets.datainfo) # SET PAGE
  565. UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
  566. btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet())) # SELECT MENU
  567. # 皮肤切换
  568. if btnName == "btn_message":
  569. if self.useCustomTheme:
  570. themeFile = os.path.abspath(os.path.join(self.absPath, "themes/py_dracula_dark.qss"))
  571. UIFunctions.theme(self, themeFile, True)
  572. # SET HACKS
  573. AppFunctions.setThemeHack(self)
  574. self.useCustomTheme = False
  575. else:
  576. themeFile = os.path.abspath(os.path.join(self.absPath, "themes/py_dracula_light.qss"))
  577. UIFunctions.theme(self, themeFile, True)
  578. # SET HACKS
  579. AppFunctions.setThemeHack(self)
  580. self.useCustomTheme = True
  581. # 文件上传
  582. if btnName == "upload":
  583. global file_path
  584. # options = QFileDialog.Options()
  585. # 使用 QFileDialog 获取文件路径
  586. file_path, _ = QFileDialog.getOpenFileName(
  587. self,
  588. "选择文件",
  589. "",
  590. "表格文件 (*.xls *.xlsx)"
  591. )
  592. if file_path:
  593. # 处理选中的文件
  594. # print(file_path)
  595. UIFunctions.execute_script_based_on_selection(self, file_path)
  596. # messagebox.showinfo("提示",f"文件 '{file_name}' 跳转成功!")
  597. # 输出点击回馈
  598. print(f'Button "{btnName}" pressed!')
  599. # RESIZE EVENTS
  600. # ///////////////////////////////////////////////////////////////
  601. def resizeEvent(self, event):
  602. # Update Size Grips
  603. UIFunctions.resize_grips(self)
  604. # 鼠标点击事件
  605. # ///////////////////////////////////////////////////////////////
  606. def mousePressEvent(self, event):
  607. # SET DRAG POS WINDOW
  608. self.dragPos = event.globalPos()
  609. # 输出鼠标事件
  610. if event.buttons() == Qt.LeftButton:
  611. print('Mouse click: LEFT CLICK')
  612. if event.buttons() == Qt.RightButton:
  613. print('Mouse click: RIGHT CLICK')
  614. if __name__ == "__main__":
  615. app = QApplication(sys.argv)
  616. app.setWindowIcon(QIcon("icon.ico"))
  617. window = MainWindow()
  618. # window.resize(1440, 960) # 高宽
  619. sys.exit(app.exec())