Example #1
0
 def is_number(self, val):
     compilestr = re.compile(r'^([1-9]\d*|0)(\.\d{1,2})?$')
     result = compilestr.match(val)
     if result:
         _create_log_file("数字")
     else:
         _create_log_file("非法字符")
     return result
Example #2
0
 def uploadFile_FUN(self, event):
     fileFilter = "Dicom (*.dcm)|*.dcm|" "All files (*.*)|*.*"
     fileDialog = wx.FileDialog(self,
                                message="选择证书文件",
                                wildcard=fileFilter,
                                style=wx.FD_OPEN)
     dialogResult = fileDialog.ShowModal()
     if dialogResult != wx.ID_OK:
         return
     path = fileDialog.GetPath()
     fileDialog.Destroy()
     _create_log_file("文件地址:" + path)
     isusing = _is_using(path)
     if isusing:
         self.show_message("认证成功,请重新打开", None, False)
     else:
         self.show_message("请确认认证文件是否正确", None, False)
Example #3
0
# -*- coding: utf-8 -*-
from com.win.client.MainWX import MainWX
from com.win.utils.BaseUtils import _is_stoped, _create_log_file
import os

if __name__ == '__main__':
    isstoped = _is_stoped()
    if isstoped:
        app = MainWX()
        app.MainLoop()
    else:
        os.system('TASKKILL /F /IM MainUI.exe')
        _create_log_file("请检查是否打开多个未关闭的PY模型图")
Example #4
0
 def registFunc(self, phonenumber, secretkey):
     _create_log_file(phonenumber)
     _create_log_file(secretkey)
Example #5
0
 def on_window_category_Box_selected(self, event):
     _create_log_file("类型选择")
Example #6
0
 def on_inner_pipe_spec_Box_selected(self, event):
     _create_log_file("内管选择")
Example #7
0
 def on_inner_rod_spec_Box_selected(self, event):
     _create_log_file("内杆规格")
Example #8
0
 def on_out_line_spec_Box_selected(self, event):
     _create_log_file("外框选择")
Example #9
0
    def on_clacu_click(self, event):
        is_show_model = True
        w_val = self.w_input.GetValue()  #测量长
        h_val = self.h_input.GetValue()  #测量宽
        h_is_number = self.is_number(h_val)
        w_is_number = self.is_number(w_val)
        out_line_spec_val = self.out_line_spec_Box.GetValue()  #外框规格25 x 25
        inner_rod_spec_val = self.inner_rod_spec_Box.GetValue()  #内杆规格25 x 25
        inner_pipe_spec_val = self.inner_pipe_spec_Box.GetValue(
        )  #内管规格 19 x 19
        inner_pipe_spec_num = self.base_configs['set']['inner_width']  #19
        window_category = self.window_category_Box.GetValue()  #款式 横 竖

        if h_is_number is None:
            self.show_message("非法字符,请输入正确的高度,是否清除?", self.h_input, True)
            return
        if w_is_number is None:
            self.show_message("非法字符,请输入正确的宽度,是否清除?", self.w_input, True)
            return

        if window_category == "":
            self.show_message("请选择管款式", None, False)
            return

        measure_w_float = float(w_val)  #测量长
        measure_h_float = float(h_val)  #测量宽

        if out_line_spec_val == "":
            self.show_message("请选择外框规格", None, False)
            return
        if measure_w_float > 3200 or measure_h_float > 3200 or measure_w_float < 500 or measure_h_float < 500:
            is_show_model = False
            self.show_message("在试用版测量长、宽大于3500不显示效果图", None, False)
        # 外边框规格
        start_index_out_line_spec = out_line_spec_val.index("X")
        end_index_out_line_spec = len(out_line_spec_val)
        out_line_spec_num_show = float(
            out_line_spec_val[0:start_index_out_line_spec])  #可视宽度 计算
        out_line_spec_num_hidden = float(
            out_line_spec_val[start_index_out_line_spec +
                              2:end_index_out_line_spec])  #不可视宽度
        # 内杆规格
        start_index_inner_rod_spec = inner_rod_spec_val.index("X")
        end_index_inner_rod_spec = len(inner_rod_spec_val)
        inner_rod_spec_num_show = float(
            inner_rod_spec_val[0:start_index_inner_rod_spec])  #可视宽度 计算
        inner_rod_spec_num_hidden = float(
            inner_rod_spec_val[start_index_inner_rod_spec +
                               2:end_index_inner_rod_spec])  #不可视宽度 计算

        if inner_rod_spec_num_hidden > out_line_spec_num_hidden:
            self.show_message("所选内杆参数大于边框参数", None, False)
            return
        if inner_pipe_spec_num > inner_rod_spec_num_hidden:
            self.show_message("所选内管参数大于内杆参数", None, False)
            return

        if window_category == "横式":
            #总长 1500 内管19x19 间距 100
            space_width = self.base_configs['set']['width_range'][0][
                'max']  #间距100
            inner_pipe_count = self.on_calcute_result(measure_h_float,
                                                      out_line_spec_num_show,
                                                      space_width,
                                                      inner_pipe_spec_num)
            _create_log_file("内管" + str(inner_pipe_count))
            #总长2000 内杆25x25 间距 400
            space_width = self.base_configs['set']['length_range'][0][
                'max']  # 间距400
            inner_rod_count = self.on_calcute_result(measure_w_float,
                                                     out_line_spec_num_show,
                                                     space_width,
                                                     inner_rod_spec_num_show)
            _create_log_file("内杆" + str(inner_rod_count))
            #竖着多处一点20
            measure_h_float_result_extend = measure_h_float + self.base_configs[
                'set']['vertical_extend_max']  # 垂直方向多处20mm
            measure_h_rod_float_result = measure_h_float - 2 * out_line_spec_num_show  # 内杆
            measure_w_pipe_float_result = measure_w_float - 2 * out_line_spec_num_show + self.base_configs[
                'set']['inner_error_max']  # 内管
            self.fill_rich_txt(out_line_spec_val,
                               measure_h_float_result_extend, measure_w_float,
                               inner_rod_spec_val, measure_h_rod_float_result,
                               inner_rod_count, inner_pipe_spec_val,
                               measure_w_pipe_float_result, inner_pipe_count)
            #画图
            if is_show_model:
                pass
            input_width = measure_w_float / 1000
            input_height = measure_h_float / 1000
            horizontal_num = math.ceil(inner_pipe_count) + 2  # 19x19
            vertical_num = math.ceil(inner_rod_count) + 2  # 25x25
            main_pipe_w = out_line_spec_num_show / 1000  # 主管宽 换算成m
            inner_rod_w = inner_rod_spec_num_show / 1000  #内杆 25
            inner_pipe_w = inner_pipe_spec_num / 1000  # 内管宽19 换算成m

            extend_w = self.base_configs['set']['vertical_extend_max'] / 1000
            self.graphTool.draw_graph(input_width, input_height,
                                      horizontal_num, vertical_num,
                                      main_pipe_w, inner_rod_w, inner_pipe_w,
                                      extend_w, "横式", out_line_spec_val,
                                      inner_rod_spec_val, inner_pipe_spec_val)

        elif window_category == "竖式":
            #总长 1500 内杆 25x25 间距 400
            space_width = self.base_configs['set']['length_range'][0][
                'max']  # 间距400
            inner_rod_count = self.on_calcute_result(measure_h_float,
                                                     out_line_spec_num_show,
                                                     space_width,
                                                     inner_rod_spec_num_show)
            _create_log_file("内杆" + str(inner_rod_count))
            #总长 2000 内管19 x 19 间距100
            space_width = self.base_configs['set']['width_range'][0][
                'max']  #间距100
            inner_pipe_count = self.on_calcute_result(measure_w_float,
                                                      out_line_spec_num_show,
                                                      space_width,
                                                      inner_pipe_spec_num)
            _create_log_file("内管" + str(inner_pipe_count))
            measure_h_float_result_extend = measure_h_float + self.base_configs[
                'set']['vertical_extend_max']  # 垂直方向多处20mm
            measure_w_rod_float_result = measure_w_float - 2 * out_line_spec_num_show  #内杆
            measure_h_pipe_float_result = measure_h_float - 2 * out_line_spec_num_show + self.base_configs[
                'set']['inner_error_max']  # 内管

            self.fill_rich_txt(out_line_spec_val,
                               measure_h_float_result_extend, measure_w_float,
                               inner_rod_spec_val, measure_w_rod_float_result,
                               inner_rod_count, inner_pipe_spec_val,
                               measure_h_pipe_float_result, inner_pipe_count)

            if is_show_model:
                pass
            input_width = measure_w_float / 1000
            input_height = measure_h_float / 1000
            horizontal_num = math.ceil(inner_rod_count) + 2  # 19x19
            vertical_num = math.ceil(inner_pipe_count) + 2  # 25x25
            main_pipe_w = out_line_spec_num_show / 1000  # 主管宽 换算成m
            inner_rod_w = inner_rod_spec_num_show / 1000  # 内管宽25 换算成m
            inner_pipe_w = inner_pipe_spec_num / 1000  # 内管 19

            extend_w = self.base_configs['set']['vertical_extend_max'] / 1000
            self.graphTool.draw_graph(input_width, input_height,
                                      horizontal_num, vertical_num,
                                      main_pipe_w, inner_rod_w, inner_pipe_w,
                                      extend_w, "竖式", out_line_spec_val,
                                      inner_rod_spec_val, inner_pipe_spec_val)
Example #10
0
    def draw_graph(self, input_width, input_height, horizontal_num,
                   vertical_num, main_pipe_w, inner_rod_w, inner_pipe_w,
                   extend_w, category, out_line_spec, inner_rod_spec,
                   inner_pipe_spec):

        if category == "竖式":
            self.horizontal_pipe_bold = 7.0
            self.vertical_pipe_bold = 1.0
            self.vertical_pipe_color = "blue"
            self.horizontal_pipe_color = "red"
            self.dashed_color_h = "red"
            self.dashed_color_v = "blue"
            self.pipe_horizontal = inner_rod_w
            self.pipe_vertical = inner_pipe_w
            self.inner_rod_count = horizontal_num
            self.inner_pipe_count = vertical_num

        elif category == "横式":
            self.horizontal_pipe_bold = 1.0
            self.vertical_pipe_bold = 7.0
            self.vertical_pipe_color = "red"
            self.horizontal_pipe_color = "blue"
            self.dashed_color_h = "blue"
            self.dashed_color_v = "red"
            self.pipe_horizontal = inner_pipe_w
            self.pipe_vertical = inner_rod_w
            self.inner_rod_count = vertical_num
            self.inner_pipe_count = horizontal_num

        plt.figure(figsize=(20, 20))  #设置显示图大小
        ax = plt.subplot(111)  #注意 ax设置不再试用plot中设置
        ##############开始画图#################
        #间距
        h_num_extend_h = input_height + extend_w
        mm_h_num_extend_h = h_num_extend_h * 1000
        h_num = horizontal_num - 1
        v_num = vertical_num - 1

        # 坐标轴 垂直线间距
        vertical_space = input_height / h_num
        # 坐标轴 水平线间距
        horizontal_space = input_width / v_num

        # 真实值 垂直线间距
        vertical_length = self.get_space_length(input_width, main_pipe_w,
                                                v_num, self.pipe_vertical)
        # 真是值 水平线间距
        horizontal_length = self.get_space_length(input_height, main_pipe_w,
                                                  h_num, self.pipe_horizontal)

        # 画垂直线
        for i in range(0, vertical_num):
            point_x = i * horizontal_space
            mm_point_x = point_x * 1000
            if i == 0:
                plt.plot([mm_point_x, mm_point_x], [0, mm_h_num_extend_h],
                         color=self.mian_pipe_color,
                         linewidth=self.main_pipe_bold,
                         linestyle="-",
                         label='规格:S= ' + out_line_spec + "; Number = 4")
                #垂直虚线
                plt.plot([mm_point_x - self.w_min, mm_point_x - self.w_min],
                         [0 - 2 * self.w_min, -450],
                         color=self.dashed_color,
                         linewidth=0.5,
                         linestyle="--")  # 垂直 第一根延长虚线 黑线
                # plt.plot([mm_point_x, mm_point_x ], [0, -0.3], color="red", linewidth=0.5,linestyle="--")  # 垂直 第一根延长虚线
                # plt.plot([mm_point_x + self.w_min, mm_point_x + self.w_min], [0, -0.15], color="red", linewidth=0.5,linestyle="--")  # 垂直 第一根延长虚线

                # 垂直红线
                plt.plot([-100, -100], [0, vertical_space * 1000 - self.w_min],
                         color=self.dashed_color_v,
                         linewidth=0.5,
                         linestyle="-")  # y=0.1      画垂直线 水平间距

                plt.plot([-200, -200], [0 - self.w_min, input_height * 1000],
                         color=self.dashed_color_v,
                         linewidth=0.5,
                         linestyle="-")  # y=0.1      画垂直线 水平间距
                plt.plot([-400, -400],
                         [0 - 1.5 * self.w_min, mm_h_num_extend_h],
                         color=self.mian_pipe_color,
                         linewidth=0.5,
                         linestyle="-")  #y=长度+延长 画垂直线 总长度
                #  标识单个间隔
                plt.text(-150,
                         0,
                         "L=" + str(round(horizontal_length, 2)) + "mm",
                         ha='left',
                         va='bottom',
                         fontdict=self.font_style,
                         rotation=self.v_rotation)
                # 标识延长长度
                plt.text(-450,
                         mm_h_num_extend_h / 2,
                         "L=" + str(round(mm_h_num_extend_h, 2)) + "mm",
                         ha='left',
                         va='bottom',
                         fontdict=self.font_style,
                         rotation=self.v_rotation)
                #  标识标准长度
                plt.text(-250,
                         mm_h_num_extend_h / 2 - 100,
                         "L=" + str(round(input_height * 1000, 2)) + "mm",
                         ha='left',
                         va='bottom',
                         fontdict=self.font_style,
                         rotation=self.v_rotation)  # 标识总长

            elif i == 1:
                if category == "竖式":
                    plt.plot([mm_point_x, mm_point_x],
                             [0, input_height * 1000],
                             color=self.vertical_pipe_color,
                             linewidth=self.vertical_pipe_bold,
                             linestyle="-",
                             label='规格:S= ' + inner_pipe_spec + "; Number = " +
                             str(self.inner_pipe_count - 2))
                elif category == "横式":
                    plt.plot([mm_point_x, mm_point_x],
                             [0, input_height * 1000],
                             color=self.vertical_pipe_color,
                             linewidth=self.vertical_pipe_bold,
                             linestyle="-",
                             label='规格:S= ' + inner_rod_spec + '; Number = ' +
                             str(self.inner_rod_count - 2))
                plt.plot([mm_point_x, mm_point_x], [0 - self.w_min, -150],
                         color=self.dashed_color,
                         linewidth=0.5,
                         linestyle="--")  # 垂直 第二条线延长
            elif i == v_num:
                #  延长最后一根线
                plt.plot([mm_point_x, mm_point_x], [0, mm_h_num_extend_h],
                         color=self.mian_pipe_color,
                         linewidth=self.main_pipe_bold,
                         linestyle="-")  #

                #  y=3虚线
                plt.plot([0, -250], [
                    input_height * 1000 + self.w_min,
                    input_height * 1000 + self.w_min
                ],
                         color=self.dashed_color,
                         linewidth=0.5,
                         linestyle="--")
                #  y=3.02虚线
                plt.plot([0, -450], [
                    mm_h_num_extend_h + self.w_min,
                    mm_h_num_extend_h + self.w_min
                ],
                         color=self.dashed_color,
                         linewidth=0.5,
                         linestyle="--")  # 延长水平方向
            else:
                plt.plot([mm_point_x, mm_point_x], [0, input_height * 1000],
                         color=self.vertical_pipe_color,
                         linewidth=self.vertical_pipe_bold,
                         linestyle="-")

        #画水平线
        for i in range(0, horizontal_num):
            ponit_y = i * vertical_space
            mm_point_y = ponit_y * 1000
            if i == 0:
                plt.plot([0, input_width * 1000],
                         [mm_point_y - self.w_min, mm_point_y - self.w_min],
                         color=self.mian_pipe_color,
                         linewidth=self.main_pipe_bold,
                         linestyle="-")
                #水平蓝虚线
                plt.plot([0, horizontal_space * 1000 - self.w_min],
                         [-100, -100],
                         color=self.dashed_color_h,
                         linewidth=0.5,
                         linestyle="-")  # 画水平线
                plt.text(horizontal_space * 1000 / 2,
                         -100,
                         "L=" + str(round(vertical_length, 2)) + "mm",
                         ha='center',
                         va='bottom',
                         fontdict=self.font_style,
                         rotation=self.h_rotation)

                plt.plot([0, input_width * 1000 - 1.5 * self.w_min],
                         [-200, -200],
                         color=self.dashed_color_h,
                         linewidth=0.5,
                         linestyle="-")
                plt.text(input_width * 1000 / 2,
                         -400,
                         "L=" + str(round(input_width * 1000, 2)) + "mm",
                         ha='center',
                         va='bottom',
                         fontdict=self.font_style,
                         rotation=self.h_rotation)

                plt.plot([0, input_width * 1000], [-400, -400],
                         color=self.mian_pipe_color,
                         linewidth=0.5,
                         linestyle="-")
                plt.text(input_width * 1000 / 2 - 100,
                         -200,
                         "L=" + str(round(input_width * 1000 - 20, 2)) + "mm",
                         ha='center',
                         va='bottom',
                         fontdict=self.font_style,
                         rotation=self.h_rotation)

                # 水平方向第一根虚线
                plt.plot([-450, 0 - self.w_min],
                         [0 - 2 * self.w_min, 0 - 2 * self.w_min],
                         color=self.dashed_color,
                         linewidth=0.5,
                         linestyle="--")  # 水平第条延长虚线

            elif i == 1:
                if category == "竖式":
                    plt.plot([0, input_width * 1000], [mm_point_y, mm_point_y],
                             color=self.horizontal_pipe_color,
                             linewidth=self.horizontal_pipe_bold,
                             linestyle="-",
                             label='规格:S= ' + inner_rod_spec + '; Number = ' +
                             str(self.inner_rod_count - 2))
                elif category == "横式":
                    plt.plot([0, input_width * 1000], [mm_point_y, mm_point_y],
                             color=self.horizontal_pipe_color,
                             linewidth=self.horizontal_pipe_bold,
                             linestyle="-",
                             label='规格:S= ' + inner_pipe_spec + '; Number = ' +
                             str(self.inner_pipe_count - 2))
                plt.plot([-150, 0], [mm_point_y, mm_point_y],
                         color=self.dashed_color,
                         linewidth=0.5,
                         linestyle="--")  # 延长垂直方向线
            elif i == h_num:
                # 正常最后一根线
                plt.plot([0, input_width * 1000], [mm_point_y, mm_point_y],
                         color=self.mian_pipe_color,
                         linewidth=self.main_pipe_bold,
                         linestyle="-")
                # 垂直延长线

                plt.plot([
                    input_width * 1000 + self.w_min,
                    input_width * 1000 + self.w_min
                ], [-450, 0 - self.w_min],
                         color=self.dashed_color,
                         linewidth=0.5,
                         linestyle="--")  # 延长垂直方向线
                plt.plot([
                    input_width * 1000 - self.w_min,
                    input_width * 1000 - self.w_min
                ], [-300, 0 - self.w_min],
                         color=self.dashed_color,
                         linewidth=0.5,
                         linestyle="--")  # 延长垂直方向线

            else:
                plt.plot([0, input_width * 1000], [mm_point_y, mm_point_y],
                         color=self.horizontal_pipe_color,
                         linewidth=self.horizontal_pipe_bold,
                         linestyle="-")

        # #############结束画图#################

        #设置主刻度标签的位置 ,标签文本的格式
        ax.xaxis.set_major_locator(self.x_majorLoc)
        ax.xaxis.set_major_formatter(self.x_majorFor)

        ax.yaxis.set_major_locator(self.y_majorLoc)
        ax.yaxis.set_major_formatter(self.y_majorFor)

        # 显示次刻度标签的位置,没有标签文本
        ax.xaxis.set_minor_locator(self.x_minorLoc)
        ax.yaxis.set_minor_locator(self.y_minorLoc)

        #设置x y轴边界值y
        plt.ylim(self.y_min, self.y_max)
        plt.xlim(self.x_min, self.x_max)

        plt.legend(loc=0)
        plt.xlabel('长(mm)')
        plt.ylabel('宽(mm)')
        plt.title('模型图 S:横截面面积;Number:根数;L:间距',
                  fontsize='20',
                  fontweight='bold')
        # plt.show()

        # 保存图片位置
        img_save_file_url = self.project_dir + "\\images\\"
        filename = self.get_filename(input_width, input_height)
        path = img_save_file_url + filename
        _create_log_file(path)

        plt.axis('off')
        fig = plt.gcf()

        plt.gca().xaxis.set_major_locator(plt.NullLocator())
        plt.gca().yaxis.set_major_locator(plt.NullLocator())
        plt.subplots_adjust(top=1,
                            bottom=0,
                            right=1,
                            left=0,
                            hspace=0,
                            wspace=0)
        plt.margins(0, 0)
        fig.savefig(path,
                    format='jpg',
                    transparent=True,
                    dpi=300,
                    pad_inches=0)

        # plt.savefig(path, format='jpg', bbox_inches='tight', transparent=True, dpi=300)

        os.system(path)