控制网复测平面基准归算程序(包含控制网复测平面基准计算,平面控制网稳定性计算,水准测段高差稳定计算三个程序功能)
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

GSshow.py 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import sqlite3
  2. from PySide6.QtGui import QStandardItemModel
  3. from Back.Program_Run.data_show import *
  4. from PySide6.QtCore import QItemSelectionModel
  5. def main_function(ui, db_path, utf_en):
  6. # 就用已有的选项卡
  7. ui.tabWidget.setTabVisible(0, True)
  8. ui.tabWidget.setTabVisible(1, True)
  9. ui.tabWidget.setTabVisible(2, True)
  10. # 重新设置文字名称
  11. ui.tabWidget.setTabText(0, '复测成果表')
  12. ui.tabWidget.setTabText(1, '基准归算模型')
  13. ui.tabWidget.setTabText(2, '复测基准归算表')
  14. # 连接到数据库
  15. db1 = sqlite3.connect(db_path)
  16. db1.text_factory = lambda x: str(x, 'utf-8')
  17. cursor1 = db1.cursor()
  18. # 隐藏 QLabel
  19. ui.default_remind.hide()
  20. # 查询表内符合的所有数据(分成两个结果分别显示)
  21. # 注意查询中的tablename,数据库中如果没有相同的表名,会报错,所以需要先判断一下
  22. # 复测成果表
  23. 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 = ?'
  24. cursor1.execute(sqlstr1, (utf_en,))
  25. result1 = cursor1.fetchall()
  26. # 基准归算表
  27. sqlstr11 = 'select PointName,Cal_X,Cal_Y,Last_CalX,Last_CalY,Last_CalP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
  28. cursor1.execute(sqlstr11, (utf_en,))
  29. result2 = cursor1.fetchall()
  30. # 对结果集进行处理,把汉字转换过来, 添加表头部分
  31. nlist1, plist1 = Arrange_Data1(result1)
  32. nlist2, plist2 = Arrange_Data2(result2)
  33. model1 = Data_in_Cell1(plist1)
  34. model1.setHorizontalHeaderLabels(
  35. ['点名', '前期X', '前期Y', '本期X', '本期Y', '前期-本期X', '前期-本期Y', '前期-本期P', '位移判定'])
  36. model1.setVerticalHeaderLabels(nlist1)
  37. # 展示表格
  38. ui.resultTableView.setModel(model1)
  39. ui.resultTableView.show()
  40. # 隐藏 QLabel
  41. ui.default_remind.hide()
  42. model2 = Data_in_Cell2(plist2)
  43. model2.setHorizontalHeaderLabels(
  44. ['点名', '基准归算X', '基准归算Y', '前期-归算X', '前期-归算Y', '前期-归算P', '位移判定'])
  45. model2.setVerticalHeaderLabels(nlist2)
  46. # 展示表格
  47. ui.reconTableView.setModel(model2)
  48. ui.reconTableView.show()
  49. # 富文本的html
  50. sqlstr2 = 'select Last_ResultName, New_ResultName, Formula_X1, Formula_X2, Formula_X3, Formula_Y1, Formula_Y2, Formula_Y3 from GS_Trans_Param WHERE TableName = ?'
  51. cursor1.execute(sqlstr2, (utf_en,))
  52. result3 = cursor1.fetchone()
  53. # 检查 result3 是否为 None
  54. if result3 is None:
  55. str0 = "<p>未找到相关数据。</p>"
  56. else:
  57. str1 = result3[0].decode('utf-8') if isinstance(result3[0], bytes) else result3[0]
  58. str2 = result3[1].decode('utf-8') if isinstance(result3[1], bytes) else result3[1]
  59. n1, n2, n3, n4, n5, n6 = result3[2], result3[3], result3[4], result3[5], result3[6], result3[7]
  60. str0 = f"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
  61. <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
  62. p, li {{ white-space: pre-wrap; }}
  63. hr {{ height: 1px; border-width: 0; }}
  64. li.unchecked::marker {{ content: "\\2610"; }}
  65. li.checked::marker {{ content: "\\2612"; }}
  66. </style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
  67. <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>
  68. <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;">=({n1})</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+({n2})</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+({n3})</span></p>
  69. <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;">=({n4})</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+({n5})</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+({n6})</span></p>
  70. <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;">为{str2}坐标;</span></p>
  71. <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>"""
  72. ui.printTableView.setHtml(str0)
  73. # 关闭数据库连接
  74. cursor1.close()
  75. db1.close()
  76. def search_show_function(ui, db_path, utf_en):
  77. # 就用已有的选项卡
  78. ui.View.setTabVisible(0, True)
  79. ui.View.setTabVisible(1, True)
  80. ui.View.setTabVisible(2, True)
  81. ui.View.setTabVisible(3, True)
  82. # 重新设置文字名称
  83. ui.View.setTabText(0, '输入数据')
  84. ui.View.setTabText(1, '复测基准归算表')
  85. ui.View.setTabText(2, '基准归算模型')
  86. ui.View.setTabText(3, '复测成果表')
  87. # 连接到数据库
  88. db1 = sqlite3.connect(db_path)
  89. db1.text_factory = lambda x: str(x, 'utf-8')
  90. cursor1 = db1.cursor()
  91. # 输入数据
  92. sqlstr00 = 'select PointName,Last_X,Last_Y,New_X,New_Y,cgcs from GS_Input_Point WHERE TableName = ?'
  93. sqlstr10 = 'select Last_ResultName,New_ResultName,Avg_SL,Ms_Dir,Ms_WSL,SL_Count,Dir_Count,Scale_Value from GS_Input_Param WHERE TableName = ?'
  94. cursor1.execute(sqlstr00, (utf_en,))
  95. result00 = cursor1.fetchall()
  96. cursor1.execute(sqlstr10, (utf_en,))
  97. result10 = cursor1.fetchall()
  98. model0, nlist0 = GS_In_Data(result00, result10[0])
  99. model0.setHorizontalHeaderLabels(
  100. ['点名', '前期X', '前期Y', '本期X', '本期Y', '成果次数', '上期成果名', '本期成果名', '平均边长', '方向值中误差',
  101. '最弱边边长相对中误差', '总测边数', '总方向观测数', '缩放值'])
  102. model0.setVerticalHeaderLabels(nlist0)
  103. # 展示表格
  104. ui.resultTableView1.setModel(model0)
  105. ui.resultTableView1.show()
  106. # 隐藏 QLabel
  107. ui.default_remind1.hide()
  108. # 查询表内符合的所有数据(分成两个结果分别显示)
  109. # 注意查询中的tablename,数据库中如果没有相同的表名,会报错,所以需要先判断一下
  110. # 复测成果表
  111. 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 = ?'
  112. cursor1.execute(sqlstr1, (utf_en,))
  113. result1 = cursor1.fetchall()
  114. # 基准归算表
  115. sqlstr11 = 'select PointName,Cal_X,Cal_Y,Last_CalX,Last_CalY,Last_CalP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
  116. cursor1.execute(sqlstr11, (utf_en,))
  117. result2 = cursor1.fetchall()
  118. # 对结果集进行处理,把汉字转换过来, 添加表头部分
  119. nlist1, plist1 = Arrange_Data1(result1)
  120. nlist2, plist2 = Arrange_Data2(result2)
  121. model1 = Data_in_Cell1(plist1)
  122. model1.setHorizontalHeaderLabels(
  123. ['点名', '前期X', '前期Y', '本期X', '本期Y', '前期-本期X', '前期-本期Y', '前期-本期P', '位移判定'])
  124. model1.setVerticalHeaderLabels(nlist1)
  125. # 展示表格
  126. ui.inputTableView1.setModel(model1)
  127. ui.inputTableView1.show()
  128. # 隐藏 QLabel
  129. ui.default_remind1.hide()
  130. model2 = Data_in_Cell2(plist2)
  131. model2.setHorizontalHeaderLabels(
  132. ['点名', '基准归算X', '基准归算Y', '前期-归算X', '前期-归算Y', '前期-归算P', '位移判定'])
  133. model2.setVerticalHeaderLabels(nlist2)
  134. # 展示表格
  135. ui.reconTableView1.setModel(model2)
  136. ui.reconTableView1.show()
  137. # 富文本的html
  138. sqlstr2 = 'select Last_ResultName, New_ResultName, Formula_X1, Formula_X2, Formula_X3, Formula_Y1, Formula_Y2, Formula_Y3 from GS_Trans_Param WHERE TableName = ?'
  139. cursor1.execute(sqlstr2, (utf_en,))
  140. result3 = cursor1.fetchone()
  141. # 检查 result3 是否为 None
  142. if result3 is None:
  143. str0 = "<p>未找到相关数据。</p>"
  144. else:
  145. str1 = result3[0].decode('utf-8') if isinstance(result3[0], bytes) else result3[0]
  146. str2 = result3[1].decode('utf-8') if isinstance(result3[1], bytes) else result3[1]
  147. n1, n2, n3, n4, n5, n6 = result3[2], result3[3], result3[4], result3[5], result3[6], result3[7]
  148. str0 = f"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
  149. <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
  150. p, li {{ white-space: pre-wrap; }}
  151. hr {{ height: 1px; border-width: 0; }}
  152. li.unchecked::marker {{ content: "\\2610"; }}
  153. li.checked::marker {{ content: "\\2612"; }}
  154. </style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
  155. <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>
  156. <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;">=({n1})</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+({n2})</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+({n3})</span></p>
  157. <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;">=({n4})</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+({n5})</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+({n6})</span></p>
  158. <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;">为{str2}坐标;</span></p>
  159. <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>"""
  160. ui.printTableView1.setHtml(str0)
  161. # 关闭数据库连接
  162. cursor1.close()
  163. db1.close()
  164. # 返回一个选择模型
  165. selectionModel = QItemSelectionModel(model0) # Item选择模型
  166. ui.resultTableView1.setSelectionModel(selectionModel)
  167. return selectionModel