def filletEvent4(self, event = None, pd = None): if pd: R = self.par.n_coordinator(pd) self.par.old_fillet_R = R else: self.par.comOrKill() if self.par.com != None: R = float(self.par.com) self.par.old_fillet_R = R else: R = self.par.old_fillet_R R = self.par.coordinator2(R) fill1, width1, sloy1, stipple1, c1, factor_stip1 = get_line_conf(self.par.collection[0], self.par) fill2, width2, sloy2, stipple2, c2, factor_stip2 = get_line_conf(self.par.collection[1], self.par) xc, yc, xe1, ye1, xe2, ye2, cord = filet_point(c1[0], c1[1], c1[2], c1[3], c2[0], c2[1], c2[2], c2[3], R) if xc: c_arc(self.par, xc, yc, xe1, ye1, xe2, ye2) c_line(self.par, cord[0], cord[1], cord[2], cord[3], fill=fill1, width=width1, sloy=sloy1, stipple=stipple1, factor_stip=factor_stip1) c_line(self.par, cord[4], cord[5], cord[6], cord[7], fill=fill2, width=width2, sloy=sloy2, stipple=stipple2, factor_stip=factor_stip2) self.par.delete(elements = self.par.collection) self.par.collection = [] self.par.changeFlag = True self.par.enumerator_p() self.filletEvent()
def copyer(collection, par, d): #Копирует объекты for content in collection: if content[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_line_conf(content, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate(coord)] _line.c_line(par, coord[0], coord[1], coord[2], coord[3], width, sloy, fill, stipple, factor_stip) elif content[0] == 't': fill, text, sloy, angle, anchor, size, line, coord, s_s, w_text, font = get_text_conf(content, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate(coord[0:2])] text_line.c_text(par, coord[0], coord[1], text, anchor, sloy, fill, angle, size, s_s, w_text, font) elif content[0] == 'd': x1, y1, x2, y2, x3, y3, ort, size, fill, text, sloy, text_change, text_place, s, vr_s, vv_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim = get_dim_conf(content, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((x1, y1, x2, y2, x3, y3))] if text_place: text_place[0] += d[0] text_place[1] += d[1] dimension.c_dim(par, coord[0],coord[1],coord[2],coord[3],coord[4],coord[5],text, sloy, fill, size, ort, text_change, text_place, s, vv_s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim) elif content[0] == 'r': xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R = get_dimR_conf(content, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((xc, yc, x1, y1))] dimension.c_dimR(par,coord[0],coord[1],coord[2],coord[3], text, sloy, fill, size, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R) elif content[0] == 'c': x0, y0, R, fill, width, sloy = get_circle_conf(content, par) x0 += d[0] y0 += d[1] circle.c_circle(par, x0, y0, width = width, sloy = sloy, fill = fill, R = R) elif content[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, start, extent, R, fill, width, sloy = get_arc_conf(content, par, 1) xc += d[0] yc += d[1] arc.c_arc(par,xc,yc, width = width, sloy = sloy, fill = fill, R = R, start = start, extent = extent)
def filletEvent4(self, event=None, pd=None): if pd: R = self.par.n_coordinator(pd) self.par.old_fillet_R = R else: self.par.comOrKill() if self.par.com != None: R = float(self.par.com) self.par.old_fillet_R = R else: R = self.par.old_fillet_R R = self.par.coordinator2(R) fill1, width1, sloy1, stipple1, c1, factor_stip1 = get_line_conf( self.par.collection[0], self.par) fill2, width2, sloy2, stipple2, c2, factor_stip2 = get_line_conf( self.par.collection[1], self.par) xc, yc, xe1, ye1, xe2, ye2, cord = filet_point(c1[0], c1[1], c1[2], c1[3], c2[0], c2[1], c2[2], c2[3], R) if xc: c_arc(self.par, xc, yc, xe1, ye1, xe2, ye2) c_line(self.par, cord[0], cord[1], cord[2], cord[3], fill=fill1, width=width1, sloy=sloy1, stipple=stipple1, factor_stip=factor_stip1) c_line(self.par, cord[4], cord[5], cord[6], cord[7], fill=fill2, width=width2, sloy=sloy2, stipple=stipple2, factor_stip=factor_stip2) self.par.delete(elements=self.par.collection) self.par.collection = [] self.par.changeFlag = True self.par.enumerator_p() self.filletEvent()
def editEvent2(self, event=None): delete_list = [] self.par.ex2 = self.par.priv_coord[0] self.par.ey2 = self.par.priv_coord[1] self.par.ex, self.par.ey = self.par.coordinator( self.par.ex, self.par.ey) self.par.set_coord() self.par.ex3 = None self.par.ey3 = None if self.par.ortoFlag == True and self.par.com == None: self.par.ex2, self.par.ey2 = self.par.orto(self.par.ex, self.par.ey, self.par.ex2, self.par.ey2) for content in self.par.collection: if content[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_conf.get_line_conf( content, self.par) if coord[0] != coord[2]: if abs(coord[0] - self.par.ex) < self.par.min_e: if abs(coord[1] - self.par.ey) < self.par.min_e: coord[0] = self.par.ex2 coord[1] = self.par.ey2 self.par.ex3 = coord[2] self.par.ey3 = coord[3] elif abs(coord[2] - self.par.ex) < self.par.min_e: if abs(coord[3] - self.par.ey) < self.par.min_e: coord[2] = self.par.ex2 coord[3] = self.par.ey2 self.par.ex3 = coord[0] self.par.ey3 = coord[1] else: if abs(coord[1] - self.par.ey) < self.par.min_e: coord[0] = self.par.ex2 coord[1] = self.par.ey2 self.par.ex3 = coord[2] self.par.ey3 = coord[3] if abs(coord[3] - self.par.ey) < self.par.min_e: coord[2] = self.par.ex2 coord[3] = self.par.ey2 self.par.ex3 = coord[0] self.par.ey3 = coord[1] delete_list.append(content) if event: line.c_line(self.par, coord[0], coord[1], coord[2], coord[3], width=width, stipple=stipple, factor_stip=factor_stip, fill=fill, sloy=sloy) else: line.c_line(self.par, coord[0], coord[1], coord[2], coord[3], width=width, stipple=stipple, factor_stip=factor_stip, fill=fill, sloy=sloy, temp='Yes') if content[0] == 'd': text_prov = False fill = self.par.ALLOBJECT[content]['fill'] sloy = self.par.ALLOBJECT[content]['sloy'] text = self.par.ALLOBJECT[content]['text'] line1 = self.par.get_snap_line(content)[0] line2 = self.par.get_snap_line(content)[1] line3 = self.par.get_snap_line(content)[2] ort = self.par.ALLOBJECT[content]['ort'] size = self.par.ALLOBJECT[content]['size'] s = self.par.ALLOBJECT[content]['s'] vr_s = self.par.ALLOBJECT[content]['vr_s'] vv_s = self.par.ALLOBJECT[content]['vv_s'] arrow_s = self.par.ALLOBJECT[content]['arrow_s'] type_arrow = self.par.ALLOBJECT[content]['type_arrow'] s_s = self.par.ALLOBJECT[content]['s_s_dim'] w_text = self.par.ALLOBJECT[content]['w_text_dim'] font = self.par.ALLOBJECT[content]['font_dim'] coord_list = map(lambda i: self.par.c.coords(i), [line1, line2, line3]) if abs(coord_list[0][0] - self.par.ex) < self.par.min_e: if abs(coord_list[0][1] - self.par.ey) < self.par.min_e: coord_list[0] = [self.par.ex2, self.par.ey2] elif abs(coord_list[1][0] - self.par.ex) < self.par.min_e: if abs(coord_list[1][1] - self.par.ey) < self.par.min_e: coord_list[1] = [self.par.ex2, self.par.ey2] elif abs(coord_list[2][0] - self.par.ex) < self.par.min_e: coord_list[2] = [self.par.ex2, self.par.ey2] text_prov = True elif abs(coord_list[2][1] - self.par.ey) < self.par.min_e: coord_list[2] = [self.par.ex2, self.par.ey2] text_prov = True delete_list.append(content) if text_prov == True: text_change = self.par.ALLOBJECT[content]['text_change'] text_lines, priv_line, text_place = self.par.dim_text_place( content) if text_place[2] == 'hor': text_place[1] = self.par.ey + (self.par.ey2 - self.par.ey) else: text_place[0] = self.par.ex + (self.par.ex2 - self.par.ex) else: text_change = 'unchange' text_place = None if event: dimension.c_dim(self.par, coord_list[0][0], coord_list[0][1], coord_list[1][0], coord_list[1][1], coord_list[2][0], coord_list[2][1], text=text, sloy=sloy, fill=fill, size=size, ort=ort, text_change=text_change, text_place=text_place, s=s, vr_s=vr_s, vv_s=vv_s, arrow_s=arrow_s, type_arrow=type_arrow, s_s=s_s, w_text=w_text, font=font) else: dimension.c_dim(self.par, coord_list[0][0], coord_list[0][1], coord_list[1][0], coord_list[1][1], coord_list[2][0], coord_list[2][1], text=text, sloy=sloy, fill=fill, size=size, ort=ort, text_change=text_change, text_place=text_place, s=s, vr_s=vr_s, vv_s=vv_s, arrow_s=arrow_s, type_arrow=type_arrow, s_s=s_s, w_text=w_text, font=font, temp='Yes') if content[0] == 'r': xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim, R = self.par.get_dimR_conf( content) x1 = self.par.ex2 y1 = self.par.ey2 delete_list.append(content) if event: dimension.c_dimR(self.par, xc, yc, x1, y1, Rn=R, text=text, sloy=sloy, fill=fill, size=size, s=s, vr_s=vr_s, arrow_s=arrow_s, type_arrow=type_arrow, s_s=s_s_dim, w_text=w_text_dim, font=font_dim) else: dimension.c_dimR(self.par, xc, yc, x1, y1, Rn=R, text=text, sloy=sloy, fill=fill, size=size, s=s, vr_s=vr_s, arrow_s=arrow_s, type_arrow=type_arrow, s_s=s_s_dim, w_text=w_text_dim, font=font_dim, temp='Yes') if content[0] == 'c': e = self.par.get_conf(content) x0 = e[1] y0 = e[2] R = sqrt((self.par.ex2 - x0)**2 + (self.par.ey2 - y0)**2) fill = e[4] width = e[5] sloy = e[6] delete_list.append(content) if event: circle.c_circle(self.par, x0, y0, fill=fill, width=width, sloy=sloy, R=R) else: circle.c_circle(self.par, x0, y0, fill=fill, width=width, sloy=sloy, R=R, temp='Yes') elif content[0] == 'a': find = self.par.ALLOBJECT[content]['id'] for i in find: tag = self.par.ALLOBJECT[content]['id'][i] if 'a' in tag: coord = self.par.c.coords(i) xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf( content, self.par) ''' e = self.par.get_arc_conf(content) xc = e[1] yc = e[2] dx1 = e[3] dy1 = e[4] dx2 = e[5] dy2 = e[6] fill = e[7] width = e[8] sloy = e[9] ''' R = sqrt((dx1 - xc)**2 + (dy1 - yc)**2) if abs(self.par.ex - dx1) < self.par.min_e: if abs(self.par.ey - dy1) < self.par.min_e: dx1 = self.par.ex2 dy1 = self.par.ey2 elif abs(self.par.ex - dx2) < self.par.min_e: if abs(self.par.ey - dy2) < self.par.min_e: dx2 = self.par.ex2 dy2 = self.par.ey2 self.par.ex3 = xc self.par.ey3 = yc aa = degrees(calc_angle(xc, yc, coord[2], yc, dx1, dy1)) bb = degrees(calc_angle(xc, yc, dx1, dy1, dx2, dy2)) delete_list.append(content) if event: arc.c_arc(self.par, xc, yc, R=R, start=aa, extent=bb, fill=fill, width=width, sloy=sloy) else: arc.c_arc(self.par, xc, yc, R=R, start=aa, extent=bb, fill=fill, width=width, sloy=sloy, temp='Yes') if self.par.tracingFlag and self.par.ex3 != None: self.par.trace_on = True self.par.trace_x1, self.par.trace_y1 = self.par.ex3, self.par.ey3 self.par.trace_x2, self.par.trace_y2 = self.par.ex2, self.par.ey2 if event: if delete_list: self.par.delete(elements=delete_list) self.par.edit_clone = False self.par.c.delete('temp') self.par.changeFlag = True self.par.enumerator_p() self.par.collection = [] self.par.kill()
def editEvent2(self, event = None): delete_list = [] self.par.ex2=self.par.priv_coord[0] self.par.ey2=self.par.priv_coord[1] self.par.ex,self.par.ey = self.par.coordinator(self.par.ex,self.par.ey) self.par.set_coord() self.par.ex3 = None self.par.ey3 = None if self.par.ortoFlag == True and self.par.com == None: self.par.ex2,self.par.ey2 = self.par.orto(self.par.ex,self.par.ey,self.par.ex2,self.par.ey2) for content in self.par.collection: if content[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_conf.get_line_conf(content, self.par) if coord[0] != coord[2]: if abs(coord[0] - self.par.ex) < self.par.min_e: if abs(coord[1] - self.par.ey) < self.par.min_e: coord[0] = self.par.ex2 coord[1] = self.par.ey2 self.par.ex3 = coord[2] self.par.ey3 = coord[3] elif abs(coord[2] - self.par.ex) < self.par.min_e: if abs(coord[3] - self.par.ey) < self.par.min_e: coord[2] = self.par.ex2 coord[3] = self.par.ey2 self.par.ex3 = coord[0] self.par.ey3 = coord[1] else: if abs(coord[1] - self.par.ey) < self.par.min_e: coord[0] = self.par.ex2 coord[1] = self.par.ey2 self.par.ex3 = coord[2] self.par.ey3 = coord[3] if abs(coord[3] - self.par.ey) < self.par.min_e: coord[2] = self.par.ex2 coord[3] = self.par.ey2 self.par.ex3 = coord[0] self.par.ey3 = coord[1] delete_list.append(content) if event: line.c_line(self.par, coord[0],coord[1],coord[2],coord[3],width = width, stipple = stipple, factor_stip = factor_stip, fill = fill, sloy = sloy) else: line.c_line(self.par, coord[0],coord[1],coord[2],coord[3],width = width, stipple = stipple, factor_stip = factor_stip, fill = fill, sloy = sloy, temp = 'Yes') if content[0] == 'd': text_prov = False fill = self.par.ALLOBJECT[content]['fill'] sloy = self.par.ALLOBJECT[content]['sloy'] text = self.par.ALLOBJECT[content]['text'] line1 = self.par.get_snap_line(content)[0] line2 = self.par.get_snap_line(content)[1] line3 = self.par.get_snap_line(content)[2] ort = self.par.ALLOBJECT[content]['ort'] size = self.par.ALLOBJECT[content]['size'] s = self.par.ALLOBJECT[content]['s'] vr_s = self.par.ALLOBJECT[content]['vr_s'] vv_s = self.par.ALLOBJECT[content]['vv_s'] arrow_s = self.par.ALLOBJECT[content]['arrow_s'] type_arrow = self.par.ALLOBJECT[content]['type_arrow'] s_s = self.par.ALLOBJECT[content]['s_s_dim'] w_text = self.par.ALLOBJECT[content]['w_text_dim'] font = self.par.ALLOBJECT[content]['font_dim'] coord_list = map(lambda i: self.par.c.coords(i), [line1, line2, line3]) if abs(coord_list[0][0] - self.par.ex) < self.par.min_e: if abs(coord_list[0][1] - self.par.ey) < self.par.min_e: coord_list[0] = [self.par.ex2, self.par.ey2] elif abs(coord_list[1][0] - self.par.ex) < self.par.min_e: if abs(coord_list[1][1] - self.par.ey) < self.par.min_e: coord_list[1] = [self.par.ex2, self.par.ey2] elif abs(coord_list[2][0] - self.par.ex) < self.par.min_e: coord_list[2] = [self.par.ex2, self.par.ey2] text_prov = True elif abs(coord_list[2][1] - self.par.ey) < self.par.min_e: coord_list[2] = [self.par.ex2, self.par.ey2] text_prov = True delete_list.append(content) if text_prov == True: text_change = self.par.ALLOBJECT[content]['text_change'] text_lines, priv_line, text_place = self.par.dim_text_place(content) if text_place[2] == 'hor': text_place[1] = self.par.ey + (self.par.ey2-self.par.ey) else: text_place[0] = self.par.ex + (self.par.ex2-self.par.ex) else: text_change = 'unchange' text_place = None if event: dimension.c_dim(self.par, coord_list[0][0], coord_list[0][1], coord_list[1][0], coord_list[1][1], coord_list[2][0], coord_list[2][1], text = text, sloy = sloy, fill = fill, size = size, ort = ort, text_change = text_change, text_place = text_place, s = s, vr_s = vr_s, vv_s = vv_s, arrow_s = arrow_s, type_arrow = type_arrow, s_s = s_s, w_text = w_text, font = font) else: dimension.c_dim(self.par, coord_list[0][0], coord_list[0][1], coord_list[1][0], coord_list[1][1], coord_list[2][0], coord_list[2][1], text = text, sloy = sloy, fill = fill, size = size, ort = ort, text_change = text_change, text_place = text_place, s = s, vr_s = vr_s, vv_s = vv_s, arrow_s = arrow_s, type_arrow = type_arrow, s_s = s_s, w_text = w_text, font = font, temp = 'Yes') if content[0] == 'r': xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim, R = self.par.get_dimR_conf(content) x1 = self.par.ex2 y1 = self.par.ey2 delete_list.append(content) if event: dimension.c_dimR(self.par, xc,yc,x1,y1, Rn = R, text = text, sloy = sloy, fill = fill, size = size, s = s, vr_s = vr_s, arrow_s = arrow_s, type_arrow = type_arrow, s_s = s_s_dim, w_text = w_text_dim, font = font_dim) else: dimension.c_dimR(self.par, xc,yc,x1,y1, Rn = R, text = text, sloy = sloy, fill = fill, size = size, s = s, vr_s = vr_s, arrow_s = arrow_s, type_arrow = type_arrow, s_s = s_s_dim, w_text = w_text_dim, font = font_dim, temp = 'Yes') if content[0] == 'c': e = self.par.get_conf(content) x0 = e[1] y0 = e[2] R = sqrt((self.par.ex2-x0)**2 + (self.par.ey2-y0)**2) fill = e[4] width = e[5] sloy = e[6] delete_list.append(content) if event: circle.c_circle(self.par, x0,y0,fill = fill, width = width, sloy = sloy, R = R) else: circle.c_circle(self.par, x0,y0,fill = fill, width = width, sloy = sloy, R = R, temp = 'Yes') elif content[0] == 'a': find = self.par.ALLOBJECT[content]['id'] for i in find: tag = self.par.ALLOBJECT[content]['id'][i] if 'a' in tag: coord = self.par.c.coords(i) xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf(content, self.par) ''' e = self.par.get_arc_conf(content) xc = e[1] yc = e[2] dx1 = e[3] dy1 = e[4] dx2 = e[5] dy2 = e[6] fill = e[7] width = e[8] sloy = e[9] ''' R = sqrt((dx1-xc)**2 + (dy1-yc)**2) if abs(self.par.ex-dx1)<self.par.min_e: if abs(self.par.ey-dy1)<self.par.min_e: dx1 = self.par.ex2 dy1 = self.par.ey2 elif abs(self.par.ex-dx2)<self.par.min_e: if abs(self.par.ey-dy2)<self.par.min_e: dx2 = self.par.ex2 dy2 = self.par.ey2 self.par.ex3 = xc self.par.ey3 = yc aa = degrees(calc_angle(xc, yc, coord[2], yc, dx1, dy1)) bb = degrees(calc_angle(xc, yc, dx1, dy1, dx2, dy2)) delete_list.append(content) if event: arc.c_arc(self.par, xc, yc, R = R, start = aa, extent = bb, fill = fill, width = width, sloy = sloy) else: arc.c_arc(self.par, xc, yc, R = R, start = aa, extent = bb, fill = fill, width = width, sloy = sloy, temp = 'Yes') if self.par.tracingFlag and self.par.ex3 != None: self.par.trace_on = True self.par.trace_x1, self.par.trace_y1 = self.par.ex3,self.par.ey3 self.par.trace_x2, self.par.trace_y2 = self.par.ex2,self.par.ey2 if event: if delete_list: self.par.delete(elements = delete_list) self.par.edit_clone = False self.par.c.delete('temp') self.par.changeFlag = True self.par.enumerator_p() self.par.collection = [] self.par.kill()
def mirror(px1,py1,px2,py2, par, delOld='No', content = None, temp = None): a = px2 - px1 b = py2 - py1 cos=a/sqrt(a*a+b*b) sin=b/sqrt(a*a+b*b) if not temp: if delOld == 'No': for c in content: if c[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_line_conf(c, par) coord = mirror_lines(px1,py1, [coord,], sin, cos)[0] _line.c_line(par, coord[0], coord[1], coord[2], coord[3], width, sloy, fill, stipple, factor_stip) elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) coord = mirror_points(px1,py1, [[xc, yc],], sin, cos)[0] circle.c_circle(par, coord[0], coord[1], width = width, sloy = sloy, fill = fill, R = R) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf(c, par) coord = mirror_points(px1,py1, [[xc, yc], [dx1, dy1], [dx2, dy2]], sin, cos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width = width, sloy = sloy, fill = fill) else: for c in content: if c[0] == 'L': find = par.ALLOBJECT[c]['id'] for i in find: coord = par.c.coords(i) coord = tuple(mirror_lines(px1,py1, [coord,], sin, cos)[0]) par.c.coords(i, coord) elif c[0] == 'd': pass ''' x1, y1, x2, y2, x3, y3, ort, size, fill, text, sloy, text_change, text_place, s, vr_s, vv_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim = get_dim_conf(c, par) #coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((x1, y1, x2, y2, x3, y3))] if text_change == None: text_change = [0, 0] coord = rotate_lines(x0, y0, [x1, y1, x2, y2, x3, y3, text_change[0], text_change[1]], msin = msin, mcos = mcos) dimension.c_dim(par, coord[0],coord[1],coord[2],coord[3],coord[4],coord[5],text, sloy, fill, size, ort, text_change, [coord[6], coord[7]], s, vv_s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim) ''' elif c[0] == 'r': pass ''' xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R = get_dimR_conf(c, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((xc, yc, x1, y1))] dimension.c_dimR(par,coord[0],coord[1],coord[2],coord[3], text, sloy, fill, size, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R) ''' elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) par.c.delete(c) coord = mirror_points(px1,py1, [[xc, yc],], sin, cos)[0] circle.c_circle(par, coord[0], coord[1], width = width, sloy = sloy, fill = fill, R = R, ID = c) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf(c, par) par.c.delete(c) coord = mirror_points(px1,py1, [[xc, yc], [dx1, dy1], [dx2, dy2]], sin, cos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width = width, sloy = sloy, fill = fill, ID = c) else: _line.c_line(par, px1,py1,px2,py2, temp = temp) for c in content: if c[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_line_conf(c, par) coord = mirror_lines(px1,py1, [coord,], sin, cos)[0] _line.c_line(par, coord[0], coord[1], coord[2], coord[3], width, sloy, fill, stipple, factor_stip, temp = temp) elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) coord = mirror_points(px1,py1, [[xc, yc],], sin, cos)[0] circle.c_circle(par, coord[0], coord[1], width = width, sloy = sloy, fill = fill, R = R, temp = temp) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf(c, par) coord = mirror_points(px1,py1, [[xc, yc], [dx1, dy1], [dx2, dy2]], sin, cos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width = width, sloy = sloy, fill = fill, temp = temp)
def rotate(par, x0 = None, y0 = None, px1 = None, py1 = None, px2 = None, py2 = None, delOld = 'Yes', content = None, angle = None, temp = None): if angle == None: #Если угол поворота не указан - считать по координатам angle = calc_angle(x0, y0, px1, py1, px2, py2) #Если угол указан - считать сразу msin = sin(angle) mcos = cos(angle) if not temp: if delOld == 'No': for c in content: if c[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_line_conf(c, par) coord = rotate_lines(x0, y0, [coord,], msin = msin, mcos = mcos)[0] _line.c_line(par, coord[0], coord[1], coord[2], coord[3], width, sloy, fill, stipple, factor_stip) elif c[0] == 't': fill, text, sloy, _angle, anchor, size, line, coord, s_s, w_text, font = get_text_conf(c, par) coord = rotate_lines(x0, y0, [coord,], msin = msin, mcos = mcos)[0] text_line.c_text(par, coord[0], coord[1], text, anchor, sloy, fill, angle+_angle, size, s_s, w_text, font) elif c[0] == 'd': pass ''' x1, y1, x2, y2, x3, y3, ort, size, fill, text, sloy, text_change, text_place, s, vr_s, vv_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim = get_dim_conf(c, par) #coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((x1, y1, x2, y2, x3, y3))] if text_change == None: text_change = [0, 0] coord = rotate_lines(x0, y0, [x1, y1, x2, y2, x3, y3, text_change[0], text_change[1]], msin = msin, mcos = mcos) dimension.c_dim(par, coord[0],coord[1],coord[2],coord[3],coord[4],coord[5],text, sloy, fill, size, ort, text_change, [coord[6], coord[7]], s, vv_s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim) ''' elif c[0] == 'r': pass ''' xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R = get_dimR_conf(c, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((xc, yc, x1, y1))] dimension.c_dimR(par,coord[0],coord[1],coord[2],coord[3], text, sloy, fill, size, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R) ''' elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) coord = rotate_points(x0, y0, [[xc, yc],], msin = msin, mcos = mcos)[0] circle.c_circle(par, coord[0], coord[1], width = width, sloy = sloy, fill = fill, R = R) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf(c, par) coord = rotate_points(x0, y0, [[xc, yc], [dx1, dy1], [dx2, dy2]], msin = msin, mcos = mcos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width = width, sloy = sloy, fill = fill) else: for c in content: if c[0] in ('L', 't'): if c[0] == 't': par.ALLOBJECT[c]['angle'] += angle find = par.ALLOBJECT[c]['id'] for i in find: coord = par.c.coords(i) coord = tuple(rotate_lines(x0, y0, [coord,], msin = msin, mcos = mcos)[0]) par.c.coords(i, coord) elif c[0] == 'd': pass ''' x1, y1, x2, y2, x3, y3, ort, size, fill, text, sloy, text_change, text_place, s, vr_s, vv_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim = get_dim_conf(c, par) #coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((x1, y1, x2, y2, x3, y3))] if text_change == None: text_change = [0, 0] coord = rotate_lines(x0, y0, [x1, y1, x2, y2, x3, y3, text_change[0], text_change[1]], msin = msin, mcos = mcos) dimension.c_dim(par, coord[0],coord[1],coord[2],coord[3],coord[4],coord[5],text, sloy, fill, size, ort, text_change, [coord[6], coord[7]], s, vv_s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim) ''' elif c[0] == 'r': pass ''' xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R = get_dimR_conf(c, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((xc, yc, x1, y1))] dimension.c_dimR(par,coord[0],coord[1],coord[2],coord[3], text, sloy, fill, size, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R) ''' elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) par.c.delete(c) coord = rotate_points(x0, y0, [[xc, yc],], msin = msin, mcos = mcos)[0] circle.c_circle(par, coord[0], coord[1], width = width, sloy = sloy, fill = fill, R = R, ID = c) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf(c, par) par.c.delete(c) coord = rotate_points(x0, y0, [[xc, yc], [dx1, dy1], [dx2, dy2]], msin = msin, mcos = mcos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width = width, sloy = sloy, fill = fill, ID = c) else: for c in content: if c[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_line_conf(c, par) coord = rotate_lines(x0, y0, [coord,], msin = msin, mcos = mcos)[0] _line.c_line(par, coord[0], coord[1], coord[2], coord[3], width, sloy, fill, stipple, factor_stip, temp = temp) elif c[0] == 't': fill, text, sloy, _angle, anchor, size, line, coord, s_s, w_text, font = get_text_conf(c, par) coord = rotate_lines(x0, y0, [coord,], msin = msin, mcos = mcos)[0] text_line.c_text(par, coord[0], coord[1], text, anchor, sloy, fill, angle+_angle, size, s_s, w_text, font, temp = temp) elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) coord = rotate_points(x0, y0, [[xc, yc],], msin = msin, mcos = mcos)[0] circle.c_circle(par, coord[0], coord[1], width = width, sloy = sloy, fill = fill, R = R, temp = temp) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf(c, par) coord = rotate_points(x0, y0, [[xc, yc], [dx1, dy1], [dx2, dy2]], msin = msin, mcos = mcos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width = width, sloy = sloy, fill = fill, temp = temp)
def rotate(par, x0=None, y0=None, px1=None, py1=None, px2=None, py2=None, delOld='Yes', content=None, angle=None, temp=None): if angle == None: #Если угол поворота не указан - считать по координатам angle = calc_angle(x0, y0, px1, py1, px2, py2) #Если угол указан - считать сразу msin = sin(angle) mcos = cos(angle) if not temp: if delOld == 'No': for c in content: if c[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_line_conf( c, par) coord = rotate_lines(x0, y0, [ coord, ], msin=msin, mcos=mcos)[0] _line.c_line(par, coord[0], coord[1], coord[2], coord[3], width, sloy, fill, stipple, factor_stip) elif c[0] == 't': fill, text, sloy, _angle, anchor, size, line, coord, s_s, w_text, font = get_text_conf( c, par) coord = rotate_lines(x0, y0, [ coord, ], msin=msin, mcos=mcos)[0] text_line.c_text(par, coord[0], coord[1], text, anchor, sloy, fill, angle + _angle, size, s_s, w_text, font) elif c[0] == 'd': pass ''' x1, y1, x2, y2, x3, y3, ort, size, fill, text, sloy, text_change, text_place, s, vr_s, vv_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim = get_dim_conf(c, par) #coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((x1, y1, x2, y2, x3, y3))] if text_change == None: text_change = [0, 0] coord = rotate_lines(x0, y0, [x1, y1, x2, y2, x3, y3, text_change[0], text_change[1]], msin = msin, mcos = mcos) dimension.c_dim(par, coord[0],coord[1],coord[2],coord[3],coord[4],coord[5],text, sloy, fill, size, ort, text_change, [coord[6], coord[7]], s, vv_s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim) ''' elif c[0] == 'r': pass ''' xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R = get_dimR_conf(c, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((xc, yc, x1, y1))] dimension.c_dimR(par,coord[0],coord[1],coord[2],coord[3], text, sloy, fill, size, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R) ''' elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) coord = rotate_points(x0, y0, [ [xc, yc], ], msin=msin, mcos=mcos)[0] circle.c_circle(par, coord[0], coord[1], width=width, sloy=sloy, fill=fill, R=R) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf( c, par) coord = rotate_points(x0, y0, [[xc, yc], [dx1, dy1], [dx2, dy2]], msin=msin, mcos=mcos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width=width, sloy=sloy, fill=fill) else: for c in content: if c[0] in ('L', 't'): if c[0] == 't': par.ALLOBJECT[c]['angle'] += angle find = par.ALLOBJECT[c]['id'] for i in find: coord = par.c.coords(i) coord = tuple( rotate_lines(x0, y0, [ coord, ], msin=msin, mcos=mcos)[0]) par.c.coords(i, coord) elif c[0] == 'd': pass ''' x1, y1, x2, y2, x3, y3, ort, size, fill, text, sloy, text_change, text_place, s, vr_s, vv_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim = get_dim_conf(c, par) #coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((x1, y1, x2, y2, x3, y3))] if text_change == None: text_change = [0, 0] coord = rotate_lines(x0, y0, [x1, y1, x2, y2, x3, y3, text_change[0], text_change[1]], msin = msin, mcos = mcos) dimension.c_dim(par, coord[0],coord[1],coord[2],coord[3],coord[4],coord[5],text, sloy, fill, size, ort, text_change, [coord[6], coord[7]], s, vv_s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim) ''' elif c[0] == 'r': pass ''' xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R = get_dimR_conf(c, par) coord = [y+d[0] if ind%2 == 0 else y+d[1] for ind, y in enumerate((xc, yc, x1, y1))] dimension.c_dimR(par,coord[0],coord[1],coord[2],coord[3], text, sloy, fill, size, s, vr_s, arrow_s, type_arrow, s_s, w_text, font, R) ''' elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) par.c.delete(c) coord = rotate_points(x0, y0, [ [xc, yc], ], msin=msin, mcos=mcos)[0] circle.c_circle(par, coord[0], coord[1], width=width, sloy=sloy, fill=fill, R=R, ID=c) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf( c, par) par.c.delete(c) coord = rotate_points(x0, y0, [[xc, yc], [dx1, dy1], [dx2, dy2]], msin=msin, mcos=mcos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width=width, sloy=sloy, fill=fill, ID=c) else: for c in content: if c[0] == 'L': fill, width, sloy, stipple, coord, factor_stip = get_line_conf( c, par) coord = rotate_lines(x0, y0, [ coord, ], msin=msin, mcos=mcos)[0] _line.c_line(par, coord[0], coord[1], coord[2], coord[3], width, sloy, fill, stipple, factor_stip, temp=temp) elif c[0] == 't': fill, text, sloy, _angle, anchor, size, line, coord, s_s, w_text, font = get_text_conf( c, par) coord = rotate_lines(x0, y0, [ coord, ], msin=msin, mcos=mcos)[0] text_line.c_text(par, coord[0], coord[1], text, anchor, sloy, fill, angle + _angle, size, s_s, w_text, font, temp=temp) elif c[0] == 'c': xc, yc, R, fill, width, sloy = get_circle_conf(c, par) coord = rotate_points(x0, y0, [ [xc, yc], ], msin=msin, mcos=mcos)[0] circle.c_circle(par, coord[0], coord[1], width=width, sloy=sloy, fill=fill, R=R, temp=temp) elif c[0] == 'a': xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = get_arc_conf( c, par) coord = rotate_points(x0, y0, [[xc, yc], [dx1, dy1], [dx2, dy2]], msin=msin, mcos=mcos) arc.c_arc(par, coord[0][0], coord[0][1], coord[1][0], coord[1][1], coord[2][0], coord[2][1], width=width, sloy=sloy, fill=fill, temp=temp)
def param_edit(self, params): if self.par.collection: remove_list = [] st = lambda x: x str_float_text = { 'text': (2, st), 'anchor': (3, st), 'fill': (5, st), 'angle': (6, float), 'size': (7, float), 's_s': (8, float), 'w_text': (9, float), 'font': (10, st) } str_float_dimr = { 'size': (4, float), 'fill': (5, st), 'text': (6, st), 's': (8, float), 'vr_s': (9, float), 'arrow_s': (10, float), 'type_arrow': (11, st), 's_s_dim': (12, float), 'w_text_dim': (13, float), 'font_dim': (14, st), 'R': (15, float) } str_float_dim = { 'size': (9, float), 'fill': (8, st), 'text': (6, st), 's': (13, float), 'vr_s': (14, float), 'vv_s': (15, float), 'arrow_s': (16, float), 'type_arrow': (17, st), 's_s_dim': (18, float), 'w_text_dim': (19, float), 'font_dim': (20, st) } for i in self.par.collection: args = None obj = None for param in params: if param in self.par.ALLOBJECT[i]: arg = params[param] self.par.ALLOBJECT[i][param] = arg self.par.changeFlag = True if i[0] == 't': if args: if param in str_float_text: j, f = str_float_text[param] args[j] = f(arg) else: fill, text, sloy, angle, anchor, size, line, coord, s_s, w_text, font = self.par.get_text_conf( i) if param == 'size': size = float(arg) elif param == 'fill': fill = arg elif param == 'angle': angle = arg elif param == 's_s': s_s = float(arg) elif param == 'w_text': w_text = float(arg) elif param == 'font': font = arg elif param == 'text': text = arg args = [ coord[0], coord[1], text, anchor, sloy, fill, angle, size, s_s, w_text, font ] obj = 'ltext' elif i[0] == 'd': if args: if param in str_float_dim: j, f = str_float_dim[param] args[j] = f(arg) else: x1, y1, x2, y2, x3, y3, ort, size, fill, text, sloy, text_change, text_place, s, vr_s, vv_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim = self.par.get_dim_conf( i) if param == 'size': size = float(arg) elif param == 'fill': fill = arg elif param == 'text': text = arg elif param == 's': s = float(arg) elif param == 'vr_s': vr_s = float(arg) elif param == 'vv_s': vv_s = float(arg) elif param == 'arrow_s': arrow_s = float(arg) elif param == 'type_arrow': type_arrow = arg elif param == 's_s_dim': s_s_dim = float(arg) elif param == 'w_text_dim': w_text_dim = arg elif param == 'font_dim': font_dim = arg args = [ x1, y1, x2, y2, x3, y3, text, sloy, fill, size, ort, text_change, text_place, s, vr_s, vv_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim ] obj = 'dim' elif i[0] == 'r': if args: if param in str_float_dimr: j, f = str_float_dimr[param] args[j] = f(arg) else: xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim, R = self.par.get_dimR_conf( i) if param == 'size': size = float(arg) elif param == 'fill': fill = arg elif param == 'text': text = arg elif param == 's': s = float(arg) elif param == 'vr_s': vr_s = float(arg) elif param == 'arrow_s': arrow_s = float(arg) elif param == 'type_arrow': type_arrow = arg elif param == 's_s_dim': s_s_dim = float(arg) elif param == 'w_text_dim': w_text_dim = arg elif param == 'font_dim': font_dim = arg elif param == 'R': R = arg args = [ xc, yc, x1, y1, size, fill, text, sloy, s, vr_s, arrow_s, type_arrow, s_s_dim, w_text_dim, font_dim, R ] obj = 'dimr' elif i[0] == 'L': if args: if param == 'width': args[4] = int(arg) elif param == 'stipple': if arg: args[7] = map(lambda x: float(x), arg) else: args[7] = arg elif param == 'fill': args[6] = arg elif param == 'factor_stip': args[8] = arg else: fill, width, sloy, stipple, coord, factor_stip = self.par.get_line_conf( i) if param == 'width': width = int(arg) elif param == 'stipple': if arg: stipple = map(lambda x: float(x), arg) elif param == 'fill': fill = arg elif param == 'factor_stip': factor_stip = arg args = [ coord[0], coord[1], coord[2], coord[3], width, sloy, fill, stipple, factor_stip ] obj = 'line' elif i[0] == 'c': if args: if param == 'R': args[2] = float(arg) elif param == 'width': args[4] = int(arg) elif param == 'fill': args[3] = arg else: x0, y0, R, fill, width, sloy = self.par.get_circle_conf( i) if param == 'width': width = int(arg) elif param == 'fill': fill = arg elif param == 'R': R = arg args = [x0, y0, R, fill, width, sloy] obj = 'circle' elif i[0] == 'a': if args: if param == 'width': args[7] = int(arg) elif param == 'fill': args[6] = arg else: xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy = self.par.get_arc_conf( i) if param == 'width': width = int(arg) elif param == 'fill': fill = arg args = [ xc, yc, dx1, dy1, dx2, dy2, fill, width, sloy ] obj = 'arc' if args: if obj == 'ltext': text_line.c_text(self.par, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]) remove_list.append((i, self.par.Ntext)) elif obj == 'dim': dimension.c_dim(self.par, args[0], args[1], args[2], args[3], args[4], args[5], text=args[6], sloy=args[7], fill=args[8], size=args[9], ort=args[10], text_change=args[11], text_place=args[12], s=args[13], vr_s=args[14], vv_s=args[15], arrow_s=args[16], type_arrow=args[17], s_s=args[18], w_text=args[19], font=args[20]) remove_list.append((i, self.par.Ndim)) elif obj == 'dimr': dimension.c_dimR(self.par, args[0], args[1], args[2], args[3], text=args[6], sloy=args[7], fill=args[5], size=args[4], s=args[8], vr_s=args[9], arrow_s=args[10], type_arrow=args[11], s_s=args[12], w_text=args[13], font=args[14], Rn=args[15]) remove_list.append((i, self.par.Ndimr)) elif obj == 'line': _line.c_line(self.par, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) remove_list.append((i, self.par.Nline)) elif obj == 'circle': circle.c_circle(self.par, args[0], args[1], R=args[2], fill=args[3], width=args[4], sloy=args[5]) remove_list.append((i, self.par.Ncircle)) elif obj == 'arc': arc.c_arc(self.par, args[0], args[1], args[2], args[3], args[4], args[5], fill=args[6], width=args[7], sloy=args[8]) remove_list.append((i, self.par.Narc)) if remove_list: del_list = [x[0] for x in remove_list] self.par.delete(elements=del_list) for r in remove_list: self.par.collection.remove(r[0]) self.par.collection.append(r[1])