控制网复测平面基准归算程序(包含控制网复测平面基准计算,平面控制网稳定性计算,水准测段高差稳定计算三个程序功能)
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ui_functions.py 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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 QMessageBox
  17. # MAIN FILE
  18. # ///////////////////////////////////////////////////////////////
  19. from Front.main import *
  20. import importlib
  21. import sqlite3
  22. from select import select
  23. from Front.back.GC import GC, GCExport
  24. from Front.back.GS import GS, GSExport
  25. from Front.back.WD import WD, WDExport
  26. from Front.back.GC import GCcompute
  27. from Front.back.GS import GScompute
  28. from Front.back.WD import WDcompute
  29. from Front.back.GC import GCshow
  30. from Front.back.GS import GSshow
  31. from Front.back.WD import WDshow
  32. import os
  33. from Front.main import MainWindow
  34. from Front.modules import Settings
  35. # GLOBALS
  36. # ///////////////////////////////////////////////////////////////
  37. GLOBAL_STATE = False
  38. GLOBAL_TITLE_BAR = True
  39. class UIFunctions(MainWindow):
  40. # MAXIMIZE/RESTORE
  41. # ///////////////////////////////////////////////////////////////
  42. def maximize_restore(self):
  43. global GLOBAL_STATE
  44. status = GLOBAL_STATE
  45. if status == False:
  46. self.showMaximized()
  47. GLOBAL_STATE = True
  48. self.ui.appMargins.setContentsMargins(0, 0, 0, 0)
  49. self.ui.maximizeRestoreAppBtn.setToolTip("Restore")
  50. self.ui.maximizeRestoreAppBtn.setIcon(QIcon(u":/icons/images/icons/icon_restore.png"))
  51. self.ui.frame_size_grip.hide()
  52. self.left_grip.hide()
  53. self.right_grip.hide()
  54. self.top_grip.hide()
  55. self.bottom_grip.hide()
  56. else:
  57. GLOBAL_STATE = False
  58. self.showNormal()
  59. self.resize(self.width() + 1, self.height() + 1)
  60. self.ui.appMargins.setContentsMargins(10, 10, 10, 10)
  61. self.ui.maximizeRestoreAppBtn.setToolTip("Maximize")
  62. self.ui.maximizeRestoreAppBtn.setIcon(QIcon(u":/icons/images/icons/icon_maximize.png"))
  63. self.ui.frame_size_grip.show()
  64. self.left_grip.show()
  65. self.right_grip.show()
  66. self.top_grip.show()
  67. self.bottom_grip.show()
  68. # RETURN STATUS
  69. # ///////////////////////////////////////////////////////////////
  70. def returStatus(self):
  71. return GLOBAL_STATE
  72. # SET STATUS
  73. # ///////////////////////////////////////////////////////////////
  74. def setStatus(self, status):
  75. global GLOBAL_STATE
  76. GLOBAL_STATE = status
  77. # TOGGLE MENU
  78. # ///////////////////////////////////////////////////////////////
  79. def toggleMenu(self, enable):
  80. if enable:
  81. # GET WIDTH
  82. width = self.ui.leftMenuBg.width()
  83. maxExtend = Settings.MENU_WIDTH
  84. standard = 60
  85. # SET MAX WIDTH
  86. if width == 60:
  87. widthExtended = maxExtend
  88. else:
  89. widthExtended = standard
  90. # ANIMATION
  91. self.animation = QPropertyAnimation(self.ui.leftMenuBg, b"minimumWidth")
  92. self.animation.setDuration(Settings.TIME_ANIMATION)
  93. self.animation.setStartValue(width)
  94. self.animation.setEndValue(widthExtended)
  95. self.animation.setEasingCurve(QEasingCurve.InOutQuart)
  96. self.animation.start()
  97. # TOGGLE LEFT BOX
  98. # ///////////////////////////////////////////////////////////////
  99. def toggleLeftBox(self, enable):
  100. if enable:
  101. # GET WIDTH
  102. width = self.ui.extraLeftBox.width()
  103. widthRightBox = self.ui.extraRightBox.width()
  104. maxExtend = Settings.LEFT_BOX_WIDTH
  105. color = Settings.BTN_LEFT_BOX_COLOR
  106. standard = 0
  107. # GET BTN STYLE
  108. style = self.ui.toggleLeftBox.styleSheet()
  109. # SET MAX WIDTH
  110. if width == 0:
  111. widthExtended = maxExtend
  112. # SELECT BTN
  113. self.ui.toggleLeftBox.setStyleSheet(style + color)
  114. if widthRightBox != 0:
  115. style = self.ui.settingsTopBtn.styleSheet()
  116. self.ui.settingsTopBtn.setStyleSheet(style.replace(Settings.BTN_RIGHT_BOX_COLOR, ''))
  117. else:
  118. widthExtended = standard
  119. # RESET BTN
  120. self.ui.toggleLeftBox.setStyleSheet(style.replace(color, ''))
  121. UIFunctions.start_box_animation(self, width, widthRightBox, "left")
  122. # TOGGLE RIGHT BOX
  123. # ///////////////////////////////////////////////////////////////
  124. def toggleRightBox(self, enable):
  125. if enable:
  126. # GET WIDTH
  127. width = self.ui.extraRightBox.width()
  128. widthLeftBox = self.ui.extraLeftBox.width()
  129. maxExtend = Settings.RIGHT_BOX_WIDTH
  130. color = Settings.BTN_RIGHT_BOX_COLOR
  131. standard = 0
  132. # GET BTN STYLE
  133. style = self.ui.settingsTopBtn.styleSheet()
  134. # SET MAX WIDTH
  135. if width == 0:
  136. widthExtended = maxExtend
  137. # SELECT BTN
  138. self.ui.settingsTopBtn.setStyleSheet(style + color)
  139. if widthLeftBox != 0:
  140. style = self.ui.toggleLeftBox.styleSheet()
  141. self.ui.toggleLeftBox.setStyleSheet(style.replace(Settings.BTN_LEFT_BOX_COLOR, ''))
  142. else:
  143. widthExtended = standard
  144. # RESET BTN
  145. self.ui.settingsTopBtn.setStyleSheet(style.replace(color, ''))
  146. UIFunctions.start_box_animation(self, widthLeftBox, width, "right")
  147. def start_box_animation(self, left_box_width, right_box_width, direction):
  148. right_width = 0
  149. left_width = 0
  150. # Check values
  151. if left_box_width == 0 and direction == "left":
  152. left_width = 240
  153. else:
  154. left_width = 0
  155. # Check values
  156. if right_box_width == 0 and direction == "right":
  157. right_width = 240
  158. else:
  159. right_width = 0
  160. # ANIMATION LEFT BOX
  161. self.left_box = QPropertyAnimation(self.ui.extraLeftBox, b"minimumWidth")
  162. self.left_box.setDuration(Settings.TIME_ANIMATION)
  163. self.left_box.setStartValue(left_box_width)
  164. self.left_box.setEndValue(left_width)
  165. self.left_box.setEasingCurve(QEasingCurve.InOutQuart)
  166. # ANIMATION RIGHT BOX
  167. self.right_box = QPropertyAnimation(self.ui.extraRightBox, b"minimumWidth")
  168. self.right_box.setDuration(Settings.TIME_ANIMATION)
  169. self.right_box.setStartValue(right_box_width)
  170. self.right_box.setEndValue(right_width)
  171. self.right_box.setEasingCurve(QEasingCurve.InOutQuart)
  172. # GROUP ANIMATION
  173. self.group = QParallelAnimationGroup()
  174. self.group.addAnimation(self.left_box)
  175. self.group.addAnimation(self.right_box)
  176. self.group.start()
  177. # SELECT/DESELECT MENU
  178. # ///////////////////////////////////////////////////////////////
  179. # SELECT
  180. def selectMenu(getStyle):
  181. select = getStyle + Settings.MENU_SELECTED_STYLESHEET
  182. return select
  183. # DESELECT
  184. def deselectMenu(getStyle):
  185. deselect = getStyle.replace(Settings.MENU_SELECTED_STYLESHEET, "")
  186. return deselect
  187. # START SELECTION
  188. def selectStandardMenu(self, widget):
  189. for w in self.ui.topMenu.findChildren(QPushButton):
  190. if w.objectName() == widget:
  191. w.setStyleSheet(UIFunctions.selectMenu(w.styleSheet()))
  192. # RESET SELECTION
  193. def resetStyle(self, widget):
  194. for w in self.ui.topMenu.findChildren(QPushButton):
  195. if w.objectName() != widget:
  196. w.setStyleSheet(UIFunctions.deselectMenu(w.styleSheet()))
  197. # IMPORT THEMES FILES QSS/CSS
  198. # ///////////////////////////////////////////////////////////////
  199. def theme(self, file, useCustomTheme):
  200. if useCustomTheme:
  201. str = open(file, 'r').read()
  202. self.ui.styleSheet.setStyleSheet(str)
  203. # START - GUI DEFINITIONS
  204. # ///////////////////////////////////////////////////////////////
  205. def uiDefinitions(self):
  206. def dobleClickMaximizeRestore(event):
  207. # IF DOUBLE CLICK CHANGE STATUS
  208. if event.type() == QEvent.MouseButtonDblClick:
  209. QTimer.singleShot(250, lambda: UIFunctions.maximize_restore(self))
  210. self.ui.titleRightInfo.mouseDoubleClickEvent = dobleClickMaximizeRestore
  211. if Settings.ENABLE_CUSTOM_TITLE_BAR:
  212. # STANDARD TITLE BAR
  213. self.setWindowFlags(Qt.FramelessWindowHint)
  214. self.setAttribute(Qt.WA_TranslucentBackground)
  215. # MOVE WINDOW / MAXIMIZE / RESTORE
  216. def moveWindow(event):
  217. # IF MAXIMIZED CHANGE TO NORMAL
  218. if UIFunctions.returStatus(self):
  219. UIFunctions.maximize_restore(self)
  220. # MOVE WINDOW
  221. if event.buttons() == Qt.LeftButton:
  222. self.move(self.pos() + event.globalPos() - self.dragPos)
  223. self.dragPos = event.globalPos()
  224. event.accept()
  225. self.ui.titleRightInfo.mouseMoveEvent = moveWindow
  226. # CUSTOM GRIPS
  227. self.left_grip = CustomGrip(self, Qt.LeftEdge, True)
  228. self.right_grip = CustomGrip(self, Qt.RightEdge, True)
  229. self.top_grip = CustomGrip(self, Qt.TopEdge, True)
  230. self.bottom_grip = CustomGrip(self, Qt.BottomEdge, True)
  231. else:
  232. self.ui.appMargins.setContentsMargins(0, 0, 0, 0)
  233. self.ui.minimizeAppBtn.hide()
  234. self.ui.maximizeRestoreAppBtn.hide()
  235. self.ui.closeAppBtn.hide()
  236. self.ui.frame_size_grip.hide()
  237. # DROP SHADOW
  238. self.shadow = QGraphicsDropShadowEffect(self)
  239. self.shadow.setBlurRadius(17)
  240. self.shadow.setXOffset(0)
  241. self.shadow.setYOffset(0)
  242. self.shadow.setColor(QColor(0, 0, 0, 150))
  243. self.ui.bgApp.setGraphicsEffect(self.shadow)
  244. # RESIZE WINDOW
  245. self.sizegrip = QSizeGrip(self.ui.frame_size_grip)
  246. self.sizegrip.setStyleSheet("width: 20px; height: 20px; margin 0px; padding: 0px;")
  247. # MINIMIZE
  248. self.ui.minimizeAppBtn.clicked.connect(lambda: self.showMinimized())
  249. # MAXIMIZE/RESTORE
  250. self.ui.maximizeRestoreAppBtn.clicked.connect(lambda: UIFunctions.maximize_restore(self))
  251. # CLOSE APPLICATION
  252. self.ui.closeAppBtn.clicked.connect(lambda: self.close())
  253. def resize_grips(self):
  254. if Settings.ENABLE_CUSTOM_TITLE_BAR:
  255. self.left_grip.setGeometry(0, 10, 10, self.height())
  256. self.right_grip.setGeometry(self.width() - 10, 10, 10, self.height())
  257. self.top_grip.setGeometry(0, 0, self.width(), 10)
  258. self.bottom_grip.setGeometry(0, self.height() - 10, self.width(), 10)
  259. # 上传文件的方法
  260. def execute_script_based_on_selection(self, file_path):
  261. current_text = self.ui.comboBox_2.currentText()
  262. # db_path = r"D:/Code/ControlNetwork/UI/SQL/DataBase.db"
  263. # 获取当前脚本所在的目录
  264. current_dir = os.getcwd()
  265. # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
  266. sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
  267. # 将相对路径转换为绝对路径
  268. sql_folder = os.path.abspath(sql_folder)
  269. db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
  270. file_path = file_path
  271. if current_text == "水准测段高差稳定计算":
  272. GC.main_function(file_path, db_path)
  273. # 添加水准执行代码
  274. elif current_text == "控制网复测平面基准计算":
  275. GS.main_function(file_path, db_path)
  276. # 添加控制网执行代码
  277. elif current_text == "平面控制网稳定性计算":
  278. WD.main_function(file_path, db_path)
  279. # 添加平面控制网执行代码
  280. # 计算与展示文件的方法
  281. def compute_show_process_excel_file(self, file_path):
  282. current_text = self.ui.comboBox_2.currentText()
  283. # 获取当前脚本所在的目录
  284. current_dir = os.getcwd()
  285. # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
  286. sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
  287. # 将相对路径转换为绝对路径
  288. sql_folder = os.path.abspath(sql_folder)
  289. db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
  290. # 转换为utf-8
  291. excelname = os.path.basename(file_path) # 文件名
  292. utf_en = excelname.encode('utf-8') # 转换文件名为utf-8编码形式
  293. if current_text == "水准测段高差稳定计算":
  294. GCcompute.main_function(file_path, db_path)
  295. GCshow.main_function(self.ui, db_path, utf_en)
  296. elif current_text == "控制网复测平面基准计算":
  297. GScompute.main_function(excelname, db_path)
  298. GSshow.main_function(self.ui, db_path, utf_en)
  299. elif current_text == "平面控制网稳定性计算":
  300. WDcompute.main_function(excelname, db_path)
  301. WDshow.main_function(self.ui, db_path, utf_en)
  302. # 文件导出的方法
  303. def export_database_to_excel(self, file_path):
  304. current_text = self.ui.comboBox_2.currentText()
  305. # 获取当前脚本所在的目录
  306. current_dir = os.getcwd()
  307. # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
  308. sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
  309. # 将相对路径转换为绝对路径
  310. sql_folder = os.path.abspath(sql_folder)
  311. db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
  312. # 转换为utf-8
  313. excelname = os.path.basename(file_path) # 文件名
  314. utf_en = excelname.encode('utf-8') # 转换文件名为utf-8编码形式
  315. if current_text == "水准测段高差稳定计算":
  316. GCExport.main_function_result(self, utf_en, db_path)
  317. elif current_text == "控制网复测平面基准计算":
  318. GSExport.main_function(self, db_path, excelname)
  319. elif current_text == "平面控制网稳定性计算":
  320. WDExport.main_function(self, db_path, excelname)
  321. else:
  322. QMessageBox.warning(self, '警告', '请选择有效的计算类型')
  323. # 数据一览,点击查询
  324. def search_data_to_show(self, file_path, current_text, tablename):
  325. utf_en = tablename.encode('utf-8') # 转换文件名为utf-8编码形式
  326. if current_text == "水准测段高差稳定计算":
  327. selectModel = GCshow.search_show_function(self.ui, file_path, utf_en)
  328. return selectModel
  329. elif current_text == "控制网复测平面基准计算":
  330. selectModel = GSshow.search_show_function(self.ui, file_path, utf_en)
  331. return selectModel
  332. elif current_text == "平面控制网稳定性计算":
  333. selectModel = WDshow.search_show_function(self.ui, file_path, utf_en)
  334. return selectModel
  335. # 删除行数据
  336. def del_row_from_db(self, row, methodName, tableName_utf8, dbPath):
  337. db1 = sqlite3.connect(dbPath)
  338. cursor1 = db1.cursor()
  339. # 通过行锁定对应的字段
  340. if methodName == '水准测段高差稳定计算':
  341. sqlstr1 = """SELECT * FROM GC_Input_Point WHERE TableName = ? LIMIT 1 OFFSET ?"""
  342. cursor1.execute(sqlstr1, (tableName_utf8, row,))
  343. result1 = cursor1.fetchall()
  344. list1 = result1[0]
  345. # 100%准确查询
  346. # sqlstr3 = """SELECT * FROM GC_Input_Point WHERE TableName = ? and New_SPName = ? and New_EPName = ? and New_HDiff = ? and New_RLen = ?"""
  347. # cursor1.execute(sqlstr3, (tableName_utf8, list1[7], list1[8], list1[11], list1[12],))
  348. # result3 = cursor1.fetchall()
  349. sqlstr2 = """DELETE FROM GC_Input_Point WHERE TableName = ? and New_SPName = ? and New_EPName = ? and New_HDiff = ? and New_RLen = ?"""
  350. cursor1.execute(sqlstr2, (tableName_utf8, list1[7], list1[8], list1[11], list1[12],))
  351. # # 获取删除的记录数量
  352. # deleted_count = cursor1.rowcount
  353. # 直接使用计算方式
  354. tableName = tableName_utf8.decode('utf-8')
  355. # 先把结果相关的点数据删一下
  356. sqlstr3 = """DELETE FROM GC_Output_Point WHERE TableName = ?"""
  357. cursor1.execute(sqlstr3, (tableName_utf8,))
  358. # 提交事务
  359. db1.commit()
  360. # 关闭db
  361. db1.close()
  362. GCcompute.main_function(tableName, dbPath)
  363. GCshow.main_function(self.ui, dbPath, tableName_utf8)
  364. elif methodName == '控制网复测平面基准计算':
  365. sqlstr1 = """SELECT * FROM GS_Input_Point WHERE TableName = ? LIMIT 1 OFFSET ?"""
  366. cursor1.execute(sqlstr1, (tableName_utf8, row,))
  367. result1 = cursor1.fetchall()
  368. list1 = result1[0]
  369. # 100%准确查询
  370. # sqlstr3 = """SELECT * FROM GC_Input_Point WHERE TableName = ? and New_SPName = ? and New_EPName = ? and New_HDiff = ? and New_RLen = ?"""
  371. # cursor1.execute(sqlstr3, (tableName_utf8, list1[7], list1[8], list1[11], list1[12],))
  372. # result3 = cursor1.fetchall()
  373. sqlstr2 = """DELETE FROM GS_Input_Point WHERE TableName = ? and PointName = ? and New_X = ? and New_Y = ?"""
  374. cursor1.execute(sqlstr2, (tableName_utf8, list1[7], list1[5], list1[6],))
  375. # # 获取删除的记录数量
  376. # deleted_count = cursor1.rowcount
  377. # 直接使用计算方式
  378. tableName = tableName_utf8.decode('utf-8')
  379. # 先把结果相关的点和参数删一下
  380. sqlstr3 = """DELETE FROM GS_Result_Point WHERE TableName = ?"""
  381. cursor1.execute(sqlstr3, (tableName_utf8,))
  382. sqlstr4 = """DELETE FROM GS_Trans_Point WHERE TableName = ?"""
  383. cursor1.execute(sqlstr4, (tableName_utf8,))
  384. sqlstr5 = """DELETE FROM GS_Trans_Param WHERE TableName = ?"""
  385. cursor1.execute(sqlstr5, (tableName_utf8,))
  386. # 提交事务
  387. db1.commit()
  388. # 关闭db
  389. db1.close()
  390. GScompute.main_function(tableName, dbPath)
  391. GSshow.main_function(self.ui, dbPath, tableName_utf8)
  392. else:
  393. # 平面控制网稳定性计算
  394. sqlstr1 = """SELECT * FROM WD_Input_Point WHERE TableName = ? LIMIT 1 OFFSET ?"""
  395. cursor1.execute(sqlstr1, (tableName_utf8, row,))
  396. result1 = cursor1.fetchall()
  397. list1 = result1[0]
  398. # 100%准确查询
  399. # sqlstr3 = """SELECT * FROM GC_Input_Point WHERE TableName = ? and New_SPName = ? and New_EPName = ? and New_HDiff = ? and New_RLen = ?"""
  400. # cursor1.execute(sqlstr3, (tableName_utf8, list1[7], list1[8], list1[11], list1[12],))
  401. # result3 = cursor1.fetchall()
  402. sqlstr2 = """DELETE FROM WD_Input_Point WHERE TableName = ? and PointName = ? and New_X = ? and New_Y = ?"""
  403. cursor1.execute(sqlstr2, (tableName_utf8, list1[11], list1[8], list1[9],))
  404. # # 获取删除的记录数量
  405. # deleted_count = cursor1.rowcount
  406. # 直接使用计算方式
  407. tableName = tableName_utf8.decode('utf-8')
  408. # 先把结果相关的点和参数删一下
  409. sqlstr3 = """DELETE FROM WD_Result_Point WHERE TableName = ?"""
  410. cursor1.execute(sqlstr3, (tableName_utf8,))
  411. sqlstr4 = """DELETE FROM WD_Result_Param WHERE TableName = ?"""
  412. cursor1.execute(sqlstr4, (tableName_utf8,))
  413. # 提交事务
  414. db1.commit()
  415. # 关闭db
  416. db1.close()
  417. WDcompute.main_function(tableName, dbPath)
  418. WDshow.main_function(self.ui, dbPath, tableName_utf8)
  419. #编辑完后的数据更新
  420. #输入模型,方法,表名utf8,数据库
  421. def update_to_db(self,model1,methodName, tableName_utf8, dbPath):
  422. db1 = sqlite3.connect(dbPath)
  423. cursor1 = db1.cursor()
  424. # 通过行锁定对应的字段
  425. if methodName == '水准测段高差稳定计算':
  426. #读取有用的数据,按格式录入
  427. data = GC.get_data_from_excel1(model1)
  428. cell_values = GC.read_cells_from_excel1(model1)
  429. ms_station = float(model1[0][12])
  430. last_station_count = GC.get_last_numeric_cell_value1(model1, 2)
  431. new_station_count = GC.get_last_numeric_cell_value1(model1, 7)
  432. last_sum_hdiff = GC.calculate_column_sum1(model1, 4)
  433. last_sum_rlen = GC.calculate_column_sum1(model1, 5)
  434. new_sum_hdiff = GC.calculate_column_sum1(model1, 9)
  435. new_sum_rlen = GC.calculate_column_sum1(model1, 10)
  436. # 把所有相关的表都删除
  437. sqlstr1 = """DELETE FROM GC_Input_Point WHERE TableName = ? """
  438. cursor1.execute(sqlstr1, (tableName_utf8,))
  439. sqlstr2 = """DELETE FROM GC_Input_Param WHERE TableName = ? """
  440. cursor1.execute(sqlstr2, (tableName_utf8,))
  441. # 先把结果相关的点和参数删一下
  442. sqlstr3 = """DELETE FROM GC_Output_Point WHERE TableName = ?"""
  443. cursor1.execute(sqlstr3, (tableName_utf8,))
  444. # 提交事务
  445. db1.commit()
  446. # 关闭db
  447. db1.close()
  448. # 直接使用计算方式
  449. tableName = tableName_utf8.decode('utf-8')
  450. # 重新更新数据库
  451. GC.insert_into_database(tableName, cell_values, ms_station, last_station_count, new_station_count,
  452. last_sum_hdiff,
  453. new_sum_hdiff, last_sum_rlen, new_sum_rlen, dbPath, tableName_utf8)
  454. GC.insert_data_into_database(data, tableName, cell_values, dbPath, tableName_utf8)
  455. GCcompute.main_function(tableName, dbPath)
  456. GCshow.main_function(self.ui, dbPath, tableName_utf8)
  457. elif methodName == '控制网复测平面基准计算':
  458. #读取模型
  459. ii = 0
  460. pastname = model1[0][6]
  461. newname = model1[0][7]
  462. pjbc = float(model1[0][8])
  463. fxzwc = float(model1[0][9])
  464. zrbzwc = float(model1[0][10])
  465. points = len(model1)
  466. zbs = float(model1[0][11])
  467. zfxs = float(model1[0][12])
  468. sf = float(model1[0][13])
  469. pjbcs = zbs / points
  470. pjfxs = zfxs / points
  471. listname1 = []
  472. listpastx1 = []
  473. listpasty1 = []
  474. listcgcs1 = []
  475. listnewx1 = []
  476. listnewy1 = []
  477. while ii < len(model1):
  478. if model1[ii][0] == '' or model1[ii][0] == None:
  479. ii = ii + 1
  480. else:
  481. listname1.append(model1[ii][0])
  482. listpastx1.append(model1[ii][1])
  483. listpasty1.append(model1[ii][2])
  484. listnewx1.append(model1[ii][3])
  485. listnewy1.append(model1[ii][4])
  486. listcgcs1.append(model1[ii][5])
  487. ii = ii + 1
  488. #把所有相关的表都删除
  489. sqlstr1 = """DELETE FROM GS_Input_Point WHERE TableName = ? """
  490. cursor1.execute(sqlstr1, (tableName_utf8, ))
  491. sqlstr2 = """DELETE FROM GS_Input_Param WHERE TableName = ? """
  492. cursor1.execute(sqlstr2, (tableName_utf8,))
  493. # 先把结果相关的点和参数删一下
  494. sqlstr3 = """DELETE FROM GS_Result_Point WHERE TableName = ?"""
  495. cursor1.execute(sqlstr3, (tableName_utf8,))
  496. sqlstr4 = """DELETE FROM GS_Trans_Point WHERE TableName = ?"""
  497. cursor1.execute(sqlstr4, (tableName_utf8,))
  498. sqlstr5 = """DELETE FROM GS_Trans_Param WHERE TableName = ?"""
  499. cursor1.execute(sqlstr5, (tableName_utf8,))
  500. # 提交事务
  501. db1.commit()
  502. # 关闭db
  503. db1.close()
  504. # 直接使用计算方式
  505. tableName = tableName_utf8.decode('utf-8')
  506. #重新更新数据库
  507. GS.insert_into_database(dbPath, pastname, newname, tableName, listname1, listpastx1, listpasty1, listcgcs1, listnewx1,
  508. listnewy1, pjbc, fxzwc, zrbzwc, points, zbs, zfxs, sf, pjbcs, pjfxs)
  509. GScompute.main_function(tableName, dbPath)
  510. GSshow.main_function(self.ui, dbPath, tableName_utf8)
  511. else:
  512. # 读取模型
  513. ii = 0
  514. bename = model1[0][8]
  515. pastname = model1[0][9]
  516. newname = model1[0][10]
  517. pjbc = float(model1[0][11])
  518. fxzwc = float(model1[0][12])
  519. points = len(model1)
  520. zbs = float(model1[0][13])
  521. zfxs = float(model1[0][14])
  522. sf = float(model1[0][15])
  523. pjbcs = zbs / points
  524. pjfxs = zfxs / points
  525. listbex1 = []
  526. listbey1 = []
  527. listname1 = []
  528. listpastx1 = []
  529. listpasty1 = []
  530. listcgcs1 = []
  531. listnewx1 = []
  532. listnewy1 = []
  533. while ii < len(model1):
  534. if model1[ii][0] == '' or model1[ii][0] == None:
  535. ii = ii + 1
  536. else:
  537. listname1.append(model1[ii][0])
  538. listbex1.append(model1[ii][1])
  539. listbey1.append(model1[ii][2])
  540. listpastx1.append(model1[ii][3])
  541. listpasty1.append(model1[ii][4])
  542. listcgcs1.append(model1[ii][5])
  543. listnewx1.append(model1[ii][6])
  544. listnewy1.append(model1[ii][7])
  545. ii = ii + 1
  546. # 平面控制网稳定性计算
  547. sqlstr1 = """DELETE FROM WD_Input_Point WHERE TableName = ?"""
  548. cursor1.execute(sqlstr1, (tableName_utf8, ))
  549. sqlstr2 = """DELETE FROM WD_Input_Param WHERE TableName = ?"""
  550. cursor1.execute(sqlstr2, (tableName_utf8,))
  551. # 先把结果相关的点和参数删一下
  552. sqlstr3 = """DELETE FROM WD_Result_Point WHERE TableName = ?"""
  553. cursor1.execute(sqlstr3, (tableName_utf8,))
  554. sqlstr4 = """DELETE FROM WD_Result_Param WHERE TableName = ?"""
  555. cursor1.execute(sqlstr4, (tableName_utf8,))
  556. # 提交事务
  557. db1.commit()
  558. # 关闭db
  559. db1.close()
  560. # 直接使用计算方式
  561. tableName = tableName_utf8.decode('utf-8')
  562. WD.insert_into_database(dbPath, pastname, newname, bename, tableName, listname1, listpastx1, listpasty1,
  563. listcgcs1, pjbc, fxzwc, points, zbs, zfxs, sf, pjbcs, pjfxs, listbex1, listbey1,
  564. listnewx1, listnewy1)
  565. WDcompute.main_function(tableName, dbPath)
  566. WDshow.main_function(self.ui, dbPath, tableName_utf8)
  567. # END - GUI DEFINITIONS