1.增加了画档距的功能。

This commit is contained in:
n3040 2022-07-26 18:22:28 +08:00
parent 3f1560402a
commit 8ae1499114
3 changed files with 20 additions and 9 deletions

View File

@ -1,7 +1,6 @@
import os.path
from collections import OrderedDict
import re
import attrs
import pandas as pd
from attrs import define
@ -111,6 +110,7 @@ class ColorEnume:
wire_color_rgb = [122, 219, 245]
tree_color_rgb = [240, 226, 81]
ground_color_rgb = [82, 79, 254]
span_text_color_rgb=[140,245,236]
# 读取Z文件找到Z断面第一个点的坐标
@ -170,9 +170,12 @@ class StringImpactExcel:
return (x, y)
def set_true_color(object, r, g, b):
def set_true_color(object, r_or_rgb_list, g, b):
true_color = object.TrueColor
true_color.SetRGB(r, g, b)
if type(r_or_rgb_list)==List:
true_color.SetRGB(*r_or_rgb_list)
else:
true_color.SetRGB(r_or_rgb_list, g, b)
object.TrueColor = true_color
@ -342,7 +345,6 @@ class ContinuousPlate:
create_if_not_exists=True, visible=False, auto_close=False
) as cad:
self.cad = cad
# self._end_tower_name='sdfsd'
doc = cad.app.Documents.Open(dwg_file_path)
sleep(1)
tower_dict = s_file.tower_dic
@ -501,6 +503,10 @@ class ContinuousPlate:
)[0]
)
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
#画档距
span_text_insert_point=np.array([(accu_mileage-span/2)/5+50,6])
added_span_text=cad.model.AddText(f'{span:.0f}',APoint(*span_text_insert_point.tolist()),3)
set_true_color(added_span_text,*ColorEnume.span_text_color_rgb)
is_first_tower = False
last_tower_info = tower_info
@ -523,9 +529,7 @@ class ControlFile:
_dir_prefix: str = ""
_z_file_name: str = ""
_close_cad_document: bool = attrs.field(init=True, kw_only=False, default=True)
# def __init__(self, z_excel_file_path):
def __attrs_post_init__(self):
# self._close_cad_document=close_cad_document
z_excel_file_path = self._z_excel_file_path
excel_pf = pd.read_excel(z_excel_file_path)
pf_dict = excel_pf.to_dict("records")[0]

10
gui.py
View File

@ -29,7 +29,7 @@ class MainWindow(QMainWindow, Ui_mainWindow):
)[0]
for z_control_file_path in z_control_file_paths:
if z_control_file_path != "":
cf = ControlFile(z_control_file_path,close_cad_document=False)
cf = ControlFile(z_control_file_path,close_cad_document=self.cBCloseCadDoc.isChecked())
if self._test_if_file_occupied(cf.get_zt_dwg_file_path()):
QMessageBox.warning(
self, "注意", f"{cf.get_zt_dwg_file_path()}被占用,请先关闭。"
@ -43,10 +43,16 @@ class MainWindow(QMainWindow, Ui_mainWindow):
self._setting.setValue(
"last_working_directory", file_info.absoluteDir().absolutePath()
)
def _cBCloseCadDocClicked(self):
self._setting.setValue('close_cad',self.cBCloseCadDoc.isChecked())
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
self.pBOpenControlZFile.clicked.connect(self.open_dialog)
self._setting = QSettings("NWEPDI", "Plate", self)
if not self._setting.value('close_cad'):
self.cBCloseCadDoc.setChecked(False)
else:
self.cBCloseCadDoc.setChecked(self._setting.value('close_cad',type=bool))
self.cBCloseCadDoc.clicked.connect(self._cBCloseCadDocClicked)
pass

View File

@ -1,5 +1,6 @@
import sys
# sys.path.append(r'd:/工程/金上线/code/')
sys.path.append(r'./../')
from PWFile import ControlFile
from gui import MainWindow
from PyQt6.QtWidgets import QApplication