示例#1
0
    def paintEventImplementation(self, ev):
        assert len(self.sections()) == len(self.bsections())

        width = self.width()
        height = self.height()

        center = QPoint(width / 2, self.hcenter)

        font_size = self.shemetype.font_size.get()
        lwidth = self.shemetype.line_width.get()

        fini_width = width
        hpostfix = 0

        base_length = self.shemetype.base_length.get()
        distrib_step = 10
        distrib_alen = 20
        #base_h = self.shemetype.base_h.get()
        #zadelka = self.shemetype.zadelka.get()
        #axis = self.shemetype.axis.get()
        #zadelka_len = self.shemetype.zadelka_len.get()
        #dimlines_step = self.shemetype.dimlines_step.get()
        #dimlines_start_step = self.shemetype.dimlines_start_step.get()
        arrow_size = self.shemetype.arrow_size.get()

        painter = self.painter
        painter.setPen(self.pen)
        painter.setBrush(Qt.white)
        section_width = sections.draw_section_routine(
            self,
            hcenter=(self.height() - hpostfix) / 2,
            right=self.width() - 10) - 10
        #section_width= 0

        painter.setPen(self.pen)
        painter.setBrush(Qt.white)

        # Расчитываем смещения
        coordes = []
        raw_coordes = []
        xmin = 0
        ymin = 0
        xmax = 0
        ymax = 0

        last = None
        for i, s in enumerate(self.sections()):
            if i == 0:
                if s.xstrt == "": s.xstrt = 0
                if s.ystrt == "": s.ystrt = 0
            xstrt = float(s.xstrt) if s.xstrt != "" else float(last.xfini)
            ystrt = float(s.ystrt) if s.ystrt != "" else float(last.yfini)
            xfini = float(s.xfini)
            yfini = float(s.yfini)

            xmin = min(xmin, xstrt, xfini)
            xmax = max(xmax, xstrt, xfini)
            ymin = min(ymin, ystrt, yfini)
            ymax = max(ymax, ystrt, yfini)

            last = s

        xshift = -(xmin + xmax) / 2 * base_length - section_width / 2
        yshift = (ymin + ymax) / 2 * base_length

        last = None
        for s in self.sections():
            xstrt = float(s.xstrt) if s.xstrt != "" else float(last.xfini)
            ystrt = float(s.ystrt) if s.ystrt != "" else float(last.yfini)
            xfini = float(s.xfini)
            yfini = float(s.yfini)

            raw_coordes.append(((xstrt, ystrt), (xfini, yfini)))

            coordes.append(
                (QPoint(xstrt * base_length + center.x() + xshift,
                        -ystrt * base_length + center.y() + yshift),
                 QPoint(xfini * base_length + center.x() + xshift,
                        -yfini * base_length + center.y() + yshift)))

            last = s

        # Начинаем рисовать
        for i in range(len(self.sections())):
            strt, fini = coordes[i]
            rstrt, rfini = raw_coordes[i]
            painter.setPen(self.doublepen)
            painter.drawLine(strt, fini)
            sect = self.sections()[i]

            txt = self.sections()[i].txt
            alttxt = self.sections()[i].alttxt

            if txt == "":
                dist = math.sqrt((rfini[0] - rstrt[0])**2 +
                                 (rfini[1] - rstrt[1])**2)
                txt = util.text_prepare_ltext(
                    dist) + self.shemetype.postfix.get()

            elements.draw_text_by_points(self, strt, fini, txt, alttxt)

            elements.draw_element_label(
                self,
                pnt=strt,
                txt=self.shemetype.task["label"][i].smaker,
                type=self.shemetype.task["label"][i].smaker_pos)
            elements.draw_element_label(
                self,
                pnt=fini,
                txt=self.shemetype.task["label"][i].fmaker,
                type=self.shemetype.task["label"][i].fmaker_pos)

        # Распределённая нагрузка
        for i in range(len(self.sections())):
            strt, fini = coordes[i]
            sect = self.sections()[i]
            bsect = self.sectforce()[i]
            angle = common.angle(strt, fini)

            elements.draw_element_distribload(self,
                                              bsect.distrib,
                                              strt,
                                              fini,
                                              distrib_step,
                                              arrow_size / 3 * 2,
                                              20,
                                              txt=bsect.txt)

        # Шарниры и заделки
        for i in range(len(self.sections())):
            strt, fini = coordes[i]
            sect = self.sections()[i]
            bsect = self.sectforce()[i]
            angle = common.angle(strt, fini)

            if sect.lsharn != "clean":
                termrad = 15 if not "шарн1" in sect.lsharn else 25
                elements.draw_element_sharn(self,
                                            strt,
                                            sect.lsharn,
                                            inangle=angle + deg(180),
                                            termrad=termrad)

            if sect.rsharn != "clean":
                termrad = 15 if not "шарн1" in sect.rsharn else 25
                elements.draw_element_sharn(self,
                                            fini,
                                            sect.rsharn,
                                            inangle=angle,
                                            termrad=termrad)

        # Силы и моменты
        for i in range(len(self.sections())):
            rad = 40
            strt, fini = coordes[i]
            sect = self.sections()[i]
            sectforce = self.sectforce()[i]
            bsect = self.bsections()[i]
            angle = common.angle(strt, fini)

            painter.setPen(self.pen)
            painter.setBrush(Qt.black)

            elements.draw_element_torque(self,
                                         strt,
                                         bsect.menl,
                                         rad,
                                         arrow_size,
                                         txt=bsect.ml_txt)
            elements.draw_element_torque(self,
                                         fini,
                                         bsect.menr,
                                         rad,
                                         arrow_size,
                                         txt=bsect.mr_txt)
            elements.draw_element_force(self,
                                        strt,
                                        bsect.fenl,
                                        rad,
                                        arrow_size,
                                        txt=bsect.fl_txt,
                                        alt=bsect.fl_txt_alt)
            elements.draw_element_force(self,
                                        fini,
                                        bsect.fenr,
                                        rad,
                                        arrow_size,
                                        txt=bsect.fr_txt,
                                        alt=bsect.fr_txt_alt)

        if self.grid_enabled:
            #if len(coordes) == 0:
            self.draw_grid(center + QPointF(xshift, yshift), base_length)

        if self.mouse_pressed:
            painter.drawLine(self.pressed_point, self.hovered_point)

        if self.highlited_element is not None:
            hint = self.highlited_element[0]
            row = self.highlited_element[1]

            if hint == "N0":
                pen = QPen()
                pen.setColor(Qt.blue)
                pen.setWidth(5)
                self.painter.setPen(pen)
                self.painter.drawLine(coordes[row][0], coordes[row][1])
                self.painter.setPen(self.pen)
                self.circle(coordes[row][0], rad=5, color=Qt.green)

            if hint == "N1":
                pen = QPen()
                pen.setColor(Qt.blue)
                pen.setWidth(5)
                self.painter.setPen(pen)
                self.painter.drawLine(coordes[row][0], coordes[row][1])
                self.painter.setPen(self.pen)
                self.circle(coordes[row][1], rad=5, color=Qt.green)

            if hint == "S":
                pen = QPen()
                pen.setColor(Qt.green)
                pen.setWidth(5)
                self.painter.setPen(pen)
                self.painter.drawLine(coordes[row][0], coordes[row][1])
                self.painter.setPen(self.pen)
示例#2
0
    def paintEventImplementation(self, ev):
        bsects = self.bsections()
        moff = 40
        """Рисуем сцену согласно объекта задания"""
        self.axonom = deg(self.shemetype.axonom.get())
        self.axonom_deg = deg(self.shemetype.axonom_deg.get())
        self.zrot = deg(self.shemetype.zrot.get())
        self.xrot = deg(self.shemetype.xrot.get())
        stlen = self.shemetype.L.get()
        offdown = self.shemetype.offdown.get()
        arrlen = self.shemetype.arrlen.get()
        marrlen = arrlen / 2
        arrow_size = 18

        fini_width = self.width() - 20
        hcenter = self.height() / 2

        lwidth = self.shemetype.lwidth.get()

        section_width = sections.draw_section_routine(self,
                                                      hcenter=hcenter,
                                                      right=fini_width)

        right_zone = fini_width - section_width + self.shemetype.xoffset.get()

        if not self.axonom or not self.axonom_deg:
            SIN = math.sin(self.zrot)
        else:
            SIN = self.AXDEG

        self.base_x = right_zone / 2 + SIN * stlen / 2
        self.base_y = 40 + 40
        self.init_trans_matrix()

        self.painter.setPen(self.pen)
        trans = self.trans

        w = 50
        L = 20
        w2 = 8
        L2 = L + stlen

        lsum = 0
        for s in self.sections():
            lsum += s.l

        lkoeff = stlen / lsum

        def coord(sectno):
            l = 0
            for i in range(sectno):
                l += self.sections()[i].l

            return L + lkoeff * l

        off = QPoint(0, offdown)
        for i in range(len(self.sections())):
            paintool.draw_dimlines(painter=self.painter,
                                   apnt=trans(0, coord(i), 0),
                                   bpnt=trans(0, coord(i + 1), 0),
                                   offset=off,
                                   textoff=QPoint(0, 0),
                                   text="",
                                   arrow_size=10,
                                   splashed=False,
                                   textline_from=None)

            elements.draw_text_by_points(self,
                                         strt=trans(0, coord(i), 0) + off,
                                         fini=trans(0, coord(i + 1), 0) + off,
                                         txt=util.text_prepare_ltext(
                                             self.sections()[i].l, suffix="l"),
                                         alttxt=True,
                                         off=10)

        for i in range(len(self.sections())):
            self.painter.setPen(self.doublepen)
            if bsects[i].xF != "нет":
                if bsects[i].xF == "+":
                    paintool.common_arrow(self.painter,
                                          trans(-w2 - arrlen, coord(i + 1), 0),
                                          trans(-w2, coord(i + 1), 0),
                                          arrow_size=arrow_size)

                    self.painter.setPen(self.pen)
                    elements.draw_text_by_points(self,
                                                 trans(-w2 - arrlen,
                                                       coord(i + 1), 0),
                                                 trans(-w2 - arrlen / 2,
                                                       coord(i + 1), 0),
                                                 txt=bsects[i].xFtxt,
                                                 alttxt=False,
                                                 off=14,
                                                 polka=None)

            self.painter.setPen(self.doublepen)
            if bsects[i].yF != "нет":
                if bsects[i].yF == "+":
                    paintool.common_arrow(self.painter,
                                          trans(0, coord(i + 1), -w2 - arrlen),
                                          trans(0, coord(i + 1), -w2),
                                          arrow_size=arrow_size)

                    self.painter.setPen(self.pen)
                    elements.draw_text_by_points(self,
                                                 trans(0, coord(i + 1),
                                                       -w2 - arrlen),
                                                 trans(0, coord(i + 1),
                                                       -w2 - arrlen / 2),
                                                 txt=bsects[i].yFtxt,
                                                 alttxt=False,
                                                 off=10,
                                                 polka=None)

            self.painter.setPen(self.doublepen)
            if bsects[i].yM != "нет":
                if bsects[i].yM == "-":
                    off = -moff
                    alttxt = True
                else:
                    off = moff
                    alttxt = False

                if i == len(bsects) - 1:
                    ws = 0
                else:
                    ws = -w2

                self.painter.drawLine(trans(ws, coord(i + 1), 0),
                                      trans(-w2 - marrlen, coord(i + 1), 0))
                paintool.common_arrow(
                    self.painter,
                    trans(-w2 - marrlen, coord(i + 1), 0),
                    trans(-w2 - marrlen,
                          coord(i + 1) + off, 0),
                    arrow_size=arrow_size,
                )
                self.painter.setPen(self.pen)
                elements.draw_text_by_points(self,
                                             trans(-w2 - marrlen, coord(i + 1),
                                                   0),
                                             trans(-w2 - marrlen,
                                                   coord(i + 1) + off, 0),
                                             txt=bsects[i].yMtxt,
                                             alttxt=alttxt,
                                             off=14,
                                             polka=None)

            self.painter.setPen(self.doublepen)
            if bsects[i].xM != "нет":
                if bsects[i].xM == "-":
                    off = moff
                    alttxt = True
                else:
                    off = -moff
                    alttxt = False

                if i == len(bsects) - 1:
                    ws = 0
                else:
                    ws = w2

                self.painter.drawLine(trans(0, coord(i + 1), -ws),
                                      trans(0, coord(i + 1), -w2 - marrlen))
                paintool.common_arrow(
                    self.painter,
                    trans(0, coord(i + 1), -w2 - marrlen),
                    trans(0,
                          coord(i + 1) + off, -w2 - marrlen),
                    arrow_size=arrow_size,
                )
                self.painter.setPen(self.pen)
                elements.draw_text_by_points(self,
                                             trans(0, coord(i + 1),
                                                   w2 + marrlen),
                                             trans(0,
                                                   coord(i + 1) - off,
                                                   +w2 + marrlen),
                                             txt=bsects[i].xMtxt,
                                             alttxt=alttxt,
                                             off=14,
                                             polka=None)

        self.painter.setPen(self.pen)

        self.painter.setBrush(QColor(220, 220, 220))
        self.painter.drawPolygon(
            QPolygon([
                trans(w, L, -w),
                trans(w, L, w),
                trans(w, 0, w),
                trans(w, 0, -w),
            ]))
        self.painter.setBrush(Qt.white)

        self.painter.setPen(self.axpen)
        S = 20
        self.painter.drawLine(self.trans(-w - S, L, 0),
                              self.trans(w + S, L, 0))
        self.painter.drawLine(self.trans(0, L, -w - S),
                              self.trans(0, L, w + S))

        self.painter.setPen(self.pen)
        #self.painter.drawLine(self.trans(-w,0,-w), self.trans(-w,0,w))
        self.painter.drawLine(self.trans(-w, 0, w), self.trans(w, 0, w))
        self.painter.drawLine(self.trans(w, 0, w), self.trans(w, 0, -w))
        #self.painter.drawLine(self.trans(w,0,-w), self.trans(-w,0,-w))

        self.painter.drawLine(self.trans(-w, L, -w), self.trans(-w, L, w))
        self.painter.drawLine(self.trans(-w, L, w), self.trans(w, L, w))
        self.painter.drawLine(self.trans(w, L, w), self.trans(w, L, -w))
        self.painter.drawLine(self.trans(w, L, -w), self.trans(-w, L, -w))

        #self.painter.drawLine(self.trans(-w,L,-w), self.trans(-w,0,-w))
        self.painter.drawLine(self.trans(-w, L, w), self.trans(-w, 0, w))
        self.painter.drawLine(self.trans(w, L, w), self.trans(w, 0, w))
        self.painter.drawLine(self.trans(w, L, -w), self.trans(w, 0, -w))

        #self.painter.drawLine(self.trans(-w2,L,-w2), self.trans(-w2,L,w2))
        self.painter.drawLine(self.trans(-w2, L, w2), self.trans(w2, L, w2))
        self.painter.drawLine(self.trans(w2, L, w2), self.trans(w2, L, -w2))
        #self.painter.drawLine(self.trans(w2,L,-w2), self.trans(-w2,L,-w2))

        self.painter.drawLine(self.trans(-w2, L2, -w2),
                              self.trans(-w2, L2, w2))
        self.painter.drawLine(self.trans(-w2, L2, w2), self.trans(w2, L2, w2))
        self.painter.drawLine(self.trans(w2, L2, w2), self.trans(w2, L2, -w2))
        self.painter.drawLine(self.trans(w2, L2, -w2),
                              self.trans(-w2, L2, -w2))

        #self.painter.drawLine(self.trans(-w2,L2,-w2), self.trans(-w2,L,-w2))
        self.painter.drawLine(self.trans(-w2, L2, w2), self.trans(-w2, L, w2))
        self.painter.drawLine(self.trans(w2, L2, w2), self.trans(w2, L, w2))
        self.painter.drawLine(self.trans(w2, L2, -w2), self.trans(w2, L, -w2))

        self.painter.setBrush(Qt.white)
        self.painter.drawPolygon(
            QPolygon([
                trans(-w2, L2, w2),
                trans(w2, L2, w2),
                trans(w2, L, w2),
                trans(-w2, L, w2),
            ]))

        self.painter.setBrush(QColor(220, 220, 220))
        self.painter.drawPolygon(
            QPolygon([
                trans(w2, L2, -w2),
                trans(w2, L2, w2),
                trans(w2, L, w2),
                trans(w2, L, -w2),
            ]))

        for i in range(len(self.sections())):
            c = coord(i)

            self.painter.drawLine(self.trans(w2, c, -w2),
                                  self.trans(w2, c, w2))
            self.painter.drawLine(self.trans(-w2, c, w2),
                                  self.trans(w2, c, w2))

        for i in range(len(self.sections())):
            self.painter.setPen(self.doublepen)
            if bsects[i].xF != "нет":
                if bsects[i].xF == "-":
                    paintool.common_arrow(
                        self.painter,
                        trans(w2 + arrlen, coord(i + 1), 0),
                        trans(w2, coord(i + 1), 0),
                        arrow_size=arrow_size,
                    )

                    self.painter.setPen(self.pen)
                    elements.draw_text_by_points(self,
                                                 trans(w2 + arrlen,
                                                       coord(i + 1), 0),
                                                 trans(w2 + arrlen / 2,
                                                       coord(i + 1), 0),
                                                 txt=bsects[i].xFtxt,
                                                 alttxt=False,
                                                 off=14,
                                                 polka=None)

            self.painter.setPen(self.doublepen)
            if bsects[i].yF != "нет":
                if bsects[i].yF == "-":
                    paintool.common_arrow(self.painter,
                                          trans(0, coord(i + 1), w2 + arrlen),
                                          trans(0, coord(i + 1), w2),
                                          arrow_size=arrow_size)

                    self.painter.setPen(self.pen)
                    elements.draw_text_by_points(self,
                                                 trans(0, coord(i + 1),
                                                       w2 + arrlen),
                                                 trans(0, coord(i + 1),
                                                       w2 + arrlen / 2),
                                                 txt=bsects[i].yFtxt,
                                                 alttxt=False,
                                                 off=14,
                                                 polka=None)

            self.painter.setPen(self.doublepen)
            if bsects[i].yM != "нет":
                if bsects[i].yM == "-":
                    off = moff
                else:
                    off = -moff

                if i == len(bsects) - 1:
                    ws = 0
                else:
                    ws = w2

                self.painter.drawLine(trans(ws, coord(i + 1), 0),
                                      trans(w2 + marrlen, coord(i + 1), 0))
                paintool.common_arrow(
                    self.painter,
                    trans(w2 + marrlen, coord(i + 1), 0),
                    trans(w2 + marrlen,
                          coord(i + 1) + off, 0),
                    arrow_size=arrow_size,
                )

            self.painter.setPen(self.doublepen)
            if bsects[i].xM != "нет":
                if bsects[i].xM == "-":
                    off = -moff
                else:
                    off = moff

                if i == len(bsects) - 1:
                    ws = 0
                else:
                    ws = w2

                self.painter.drawLine(trans(0, coord(i + 1), ws),
                                      trans(0, coord(i + 1), w2 + marrlen))
                paintool.common_arrow(
                    self.painter,
                    trans(0, coord(i + 1), w2 + marrlen),
                    trans(0,
                          coord(i + 1) + off, w2 + marrlen),
                    arrow_size=arrow_size,
                )
                self.painter.setPen(self.pen)
示例#3
0
    def paintEventImplementation(self, ev):
        sects = self.shemetype.task["sections"]

        #firstdir = self.shemetype.first_dir.get()
        #angle = deg(180) if firstdir else deg(90)
        sharnrad = self.shemetype.sharnrad.get()

        width = self.width()
        height = self.height()

        font_size = self.shemetype.font_size.get()
        lwidth = self.shemetype.line_width.get()

        base_length = self.shemetype.base_length.get()
        self.base_length = base_length

        # Расчитываем центр.
        xmin, ymin = 0, 0
        xmax, ymax = 0, 0

        self.make_off_lists()

        for i in range(len(sects)):
            length = 0
            sect = self.sections()[i]
            if sects[i].body == True:
                length = sect.l

            elif sects[i].body == False and (sects[i].force == "к"
                                             or sects[i].force == "от"):
                length = 40 / base_length

            elif sects[i].body == False and (sects[i].force == "нет"
                                             or sects[i].force == "вдоль"):
                continue

            angle = deg(sect.angle)

            point = (
                math.cos(angle) * (length) + self.xoff(i),
                math.sin(angle) * (length) + self.yoff(i),
            )

            xmin, xmax = min(xmin, point[0]), max(xmax, point[0])
            ymin, ymax = min(ymin, point[1]), max(ymax, point[1])

        center = QPointF(width/2, self.hcenter) + \
         QPointF(-(xmax + xmin)* base_length, (ymax + ymin)* base_length)/2
        self.c = center

        def get_coord(i):
            sect = self.sections()[i]
            angle = sect.angle
            length = sect.l * base_length
            strt = center + QPointF(base_length * self.xoff(i),
                                    base_length * self.yoff(i))
            pnt = strt + QPoint(
                math.cos(angle) * length, -math.sin(angle) * length)
            return pnt

        def hasnode(pnt):
            jpnt = center
            diff = math.sqrt((pnt.x() - jpnt.x())**2 + (pnt.y() - jpnt.y())**2)
            if diff < 0.1:
                return True

            for i in range(len(self.sections())):
                if self.sections()[i].body == False or self.sections(
                )[i].sharn == "нет":
                    continue
                jpnt = get_coord(i)
                diff = math.sqrt((pnt.x() - jpnt.x())**2 +
                                 (pnt.y() - jpnt.y())**2)
                if diff < 0.1:
                    return True

            return False

        rad = 50
        rad2 = 60
        rad3 = 70

        # Рисуем доб угол
        for i in range(len(sects)):
            sect = self.sections()[i]
            angle = sects[i].angle
            #strt = center + QPointF(base_length * sect.xoff, base_length * sect.yoff)
            strt = self.get_node_coordinate(sect.start_from)

            if sect.addangle != 0:
                tgtangle = sect.angle + sect.addangle

                if self.highlited_sect is not None and self.highlited_sect[
                        1] == i:
                    pen = self.dashgreen
                else:
                    pen = QPen(Qt.DashDotLine)

                pen.setWidth(2)
                self.painter.setPen(pen)

                pnt1 = strt + rad2 * QPointF(math.cos(deg(angle)),
                                             -math.sin(deg(angle)))
                pnt2 = strt + rad2 * QPointF(math.cos(deg(tgtangle)),
                                             -math.sin(deg(tgtangle)))
                cpnt = strt + rad3 * QPointF(
                    math.cos(deg(tgtangle + angle) / 2),
                    -math.sin(deg(tgtangle + angle) / 2))

                self.painter.drawLine(strt, pnt1)
                self.painter.drawLine(strt, pnt2)

                if self.highlited_sect is not None and self.highlited_sect[
                        1] == i:
                    pen = self.halfgreen
                else:
                    pen = self.halfpen

                self.painter.setPen(pen)
                self.painter.drawArc(paintool.radrect(strt, rad), angle * 16,
                                     sect.addangle * 16)

                paintool.draw_text_centered(
                    painter=self.painter,
                    pnt=cpnt + QPointF(0,
                                       QFontMetrics(self.font).height() / 4),
                    text=paintool.greek(str(abs(sect.addangle)) + "\\degree"),
                    font=self.font)

        # Рисуем тело
        for i in range(len(sects)):
            sect = self.sections()[i]
            angle = deg(sect.angle)
            self.painter.setPen(self.pen)

            if self.highlited_sect is not None and self.highlited_sect[1] == i:
                self.painter.setPen(self.widegreen)
            else:
                self.painter.setPen(self.doublepen)

            if sect.body:
                length = sect.l * base_length
                strt = self.c + self.coordinate_of_start(i)

                if hasnode(strt):
                    spnt = strt + QPoint(
                        math.cos(angle) * 7, -math.sin(angle) * 7)
                else:
                    spnt = strt

                pnt = self.c + self.coordinate_of_finish(i)

                if not sect.wide:
                    self.painter.drawLine(strt, pnt)
                else:
                    self.painter.drawLine(strt, pnt)
                    self.painter.drawLine(strt + QPointF(0, 8),
                                          pnt + QPointF(0, 8))
                    self.painter.drawLine(strt, strt + QPointF(0, 8))
                    self.painter.drawLine(pnt, pnt + QPointF(0, 8))

                if self.highlited_sect is not None and self.highlited_sect[
                        1] == i:
                    self.painter.setPen(self.green)
                else:
                    self.painter.setPen(self.pen)

                self.painter.setBrush(Qt.white)
                if sect.sharn == "шарн+заделка":
                    paintool.zadelka_sharnir(self.painter, pnt, -angle, 30, 10,
                                             sharnrad)
                elif sect.sharn == "шарн":
                    self.painter.setBrush(Qt.white)
                    self.painter.drawEllipse(paintool.radrect(pnt, sharnrad))

                if sect.start_from != -1:
                    if self.sections()[sect.start_from].sharn != "нет":
                        self.painter.drawEllipse(
                            paintool.radrect(strt, sharnrad))

                ltxt = util.text_prepare_ltext(sect.l, suffix="l")
                Atxt = util.text_prepare_ltext(sect.A, suffix="A")
                txt = "{},{},E".format(ltxt, Atxt)

                elements.draw_text_by_points_angled(self,
                                                    strt,
                                                    pnt,
                                                    off=14,
                                                    txt=txt,
                                                    alttxt=sect.alttxt)

            self.painter.setPen(self.default_pen)

        # риуем силы
        for i in range(len(sects)):
            sect = self.sections()[i]
            angle = deg(sect.angle)
            rad = 50
            circrad = 0

            strt = self.c + self.coordinate_of_start(i)

            for j in range(len(sects)):
                jsect = self.sections()[j]
                #length = jsect.l * base_length
                #pnt = strt + QPoint(math.cos(jsect.angle) * length, -math.sin(jsect.angle) * length)

                if hasnode(strt):
                    circrad = 6
                    break
                else:
                    circrad = 0

            if self.highlited_sect is not None and self.highlited_sect[1] == i:
                self.painter.setPen(self.green)
                self.painter.setBrush(Qt.green)
                pen = self.green
                brush = Qt.green
            else:
                self.painter.setPen(self.pen)
                self.painter.setBrush(Qt.black)
                pen = None
                brush = Qt.black

            if sect.force != "нет":
                apnt = strt + QPointF(
                    math.cos(angle) * circrad, -math.sin(angle) * circrad)
                bpnt = strt + QPointF(
                    math.cos(angle) * rad, -math.sin(angle) * rad)
                cpnt = strt + QPointF(
                    math.cos(angle) * rad / 2, -math.sin(angle) * rad / 2)

                if sect.force == "к":
                    paintool.common_arrow(self.painter,
                                          bpnt,
                                          apnt,
                                          arrow_size=15,
                                          pen=pen,
                                          brush=brush)
                elif sect.force == "от":
                    paintool.common_arrow(self.painter,
                                          apnt,
                                          bpnt,
                                          arrow_size=15,
                                          pen=pen,
                                          brush=brush)
                elif sect.force == "вдоль":
                    rad = 20
                    vec = QPointF(
                        math.cos(angle) * rad, -math.sin(angle) * rad)
                    norm = QPointF(vec.y(), -vec.x())

                    apnt1 = strt + norm
                    bpnt1 = strt - norm
                    apnt2 = strt + norm + vec
                    bpnt2 = strt - norm + vec
                    cpnt1 = strt
                    cpnt2 = strt + vec

                    paintool.common_arrow(self.painter,
                                          apnt1,
                                          apnt2,
                                          arrow_size=10)
                    paintool.common_arrow(self.painter,
                                          bpnt1,
                                          bpnt2,
                                          arrow_size=10,
                                          pen=pen,
                                          brush=brush)

                    self.painter.drawLine(apnt1, bpnt1)

                if sect.force != "вдоль":
                    elements.draw_text_by_points(self,
                                                 cpnt,
                                                 bpnt,
                                                 paintool.greek(sect.ftxt),
                                                 alttxt=sect.alttxt,
                                                 off=12,
                                                 polka=None)

                else:
                    elements.draw_text_by_points(self,
                                                 cpnt1,
                                                 cpnt2,
                                                 paintool.greek(sect.ftxt),
                                                 alttxt=sect.alttxt,
                                                 off=12 + 15,
                                                 polka=None)

        self.c = center

        self.painter.setPen(self.pen)
        self.painter.setBrush(Qt.white)
        self.painter.drawEllipse(
            QRectF(center - QPointF(sharnrad, sharnrad),
                   center + QPointF(sharnrad, sharnrad)))

        if self.grid_enabled:
            self.painter.setPen(self.pen)
            self.painter.setBrush(Qt.green)

            if self.mouse_pressed:
                i = self.pressed_point_index

            else:
                i = self.hovered_point_index

            if i is not None:
                if i > 0 and len(sects) > i and sects[i - 1].body:
                    self.painter.drawEllipse(
                        QRectF(-QPointF(5, 5) + self.nodes_numered()[i],
                               +QPointF(5, 5) + self.nodes_numered()[i]))
                if i == 0:
                    self.painter.drawEllipse(
                        QRectF(-QPointF(5, 5) + self.nodes_numered()[0],
                               +QPointF(5, 5) + self.nodes_numered()[0]))

            self.painter.setPen(self.pen)
            self.painter.setBrush(Qt.white)

        if self.mouse_pressed:
            strt = self.nodes_numered()[self.pressed_point_index]
            tgt = self.target_point

            xs = strt.x()
            ys = strt.y()
            xf = tgt.x()
            yf = tgt.y()
            ang = math.atan2(ys - yf, xf - xs)

            ang = ang * 180 / math.pi
            l = math.sqrt((xf - xs)**2 + (yf - ys)**2) / self.base_length

            ang = round((ang + 7.5) / 15) * 15
            l = round((l + 0.25) / 0.5) * 0.5

            angtxt = ang
            ang = ang * math.pi / 180
            ltxt = str(l)
            l = l * self.base_length

            if self.pressed_point_index <= len(
                    self.shemetype.task["sections"]):
                fini = strt + QPointF(math.cos(ang) * l, -math.sin(ang) * l)
                self.painter.drawLine(strt, fini)
                elements.draw_text_by_points_angled(self,
                                                    strt,
                                                    fini,
                                                    off=14,
                                                    txt=ltxt + "l",
                                                    alttxt=False)

                self.painter.drawArc(paintool.radrect(strt, rad), 0 * 16,
                                     angtxt * 16)

                pnt1 = strt + rad2 * QPointF(math.cos(deg(0)),
                                             -math.sin(deg(0)))
                pnt2 = strt + rad2 * QPointF(math.cos(deg(angtxt)),
                                             -math.sin(deg(angtxt)))
                cpnt = strt + rad3 * QPointF(math.cos(deg(angtxt) / 2),
                                             -math.sin(deg(angtxt) / 2))

                paintool.draw_text_centered(
                    painter=self.painter,
                    pnt=cpnt + QPointF(0,
                                       QFontMetrics(self.font).height() / 4),
                    text=paintool.greek(str(abs(angtxt)) + "\\degree"),
                    font=self.font)
示例#4
0
    def paintEventImplementation(self, ev):
        """Рисуем сцену согласно объекта задания"""
        subtype = self.shemetype.task_subtype.get()
        self.subtype = subtype

        font_size = self.shemetype.font_size.get()
        font = self.painter.font()
        font.setItalic(True)
        font.setPointSize(font_size)
        self.painter.setFont(font)
        self.font = font

        lwidth = self.shemetype.lwidth.get()

        axis = self.shemetype.axis.get()
        zleft = self.shemetype.zleft.get()
        self.zleft = zleft
        zright = self.shemetype.zright.get()
        self.zright = zright

        base_section_height = self.shemetype.base_section_height.get()

        arrow_size = self.shemetype.arrow_size.get()
        self.arrow_size = arrow_size

        arrow_head_size = self.shemetype.arrow_size.get()
        self.arrow_head_size = arrow_head_size

        razm = self.shemetype.razm.get()
        self.razm = razm

        task = self.shemetype.task
        self.task = task
        size = self.size()

        width = size.width()
        height = size.height()
        #kruch_flag = self.shemetype.kruch_flag.get()

        kruch_flag = False if subtype == SUBTYPE_RASTYAZHENIE_SJATIE else True

        addtext = self.shemetype.texteditor.toPlainText()

        arrow_line_size = 50
        self.arrow_line_size = arrow_line_size

        hcenter = self.hcenter

        height_zone = base_section_height
        self.height_zone = height_zone

        self.strt_width = self.shemetype.left_zone.get()
        self.fini_width = width - self.shemetype.right_zone.get()

        if subtype == SUBTYPE_RASTYAZHENIE_SJATIE:
            if self.bsections()[0].Fstyle != "к узлу":
                if self.bsections()[0].F == "-":
                    self.strt_width = self.strt_width + arrow_line_size

            if self.bsections()[-1].Fstyle != "к узлу":
                if self.bsections()[-1].F == "+":
                    self.fini_width = self.fini_width - arrow_line_size

            if self.bsections()[0].Fstyle == "к узлу":
                if self.bsections()[0].F == "+":
                    self.strt_width = self.strt_width + arrow_line_size

            if self.bsections()[-1].Fstyle == "к узлу":
                if self.bsections()[-1].F == "-":
                    self.fini_width = self.fini_width - arrow_line_size

        br = QPen()
        br.setWidth(lwidth)
        self.painter.setPen(br)

        maxl = 0
        maxA = 0
        for s in self.sections():
            if s.l > maxl: maxl = s.l
            if s.A > maxA: maxA = s.A

        dimlines_level = hcenter + base_section_height * math.sqrt(
            maxA) / 2 + self.shemetype.dimlines_start_step.get()
        self.dimlines_level = dimlines_level

        if razm is True:
            hcenter -= self.shemetype.dimlines_start_step.get() / 2

        self.hcenter = hcenter

        if razm is False:
            pass

        # Длины и дистанции
        self.summary_length = 0
        self.ll = [0]
        for i in range(len(task["sections"])):
            self.summary_length += task["sections"][i].l
            self.ll.append(self.ll[i] + task["sections"][i].l)

        # Отрисовка секций
        for i in range(len(task["sections"])):
            hkoeff = self.sectrad_koeff(i)

            strt_height = hcenter - height_zone * hkoeff / 2
            fini_height = hcenter + height_zone * hkoeff / 2

            self.draw_section(i, strt_height, fini_height)
            self.draw_dimlines(i, strt_height, fini_height)

            self.painter.setBrush(self.default_brush)
            self.painter.setPen(self.default_pen)

        if axis:
            pen = QPen(Qt.CustomDashLine)
            pen.setDashPattern([10, 3, 1, 3])
            self.painter.setPen(pen)
            self.painter.drawLine(QPointF(5, hcenter),
                                  QPointF(width - 5, hcenter))
            pen = QPen()
            self.painter.setPen(pen)

        # отрисовка сил
        if subtype == SUBTYPE_RASTYAZHENIE_SJATIE:
            self.force_drawing()
        else:
            self.torsion_drawing()

        for i in range(len(task["sections"])):
            hkoeff = self.sectrad_koeff(i)

            strt_height = hcenter - height_zone * hkoeff / 2
            fini_height = hcenter + height_zone * hkoeff / 2

            if self.subtype == SUBTYPE_KRUCHENIE_2:
                self.draw_diameters(i, strt_height, fini_height)

            self.painter.setBrush(self.default_brush)
            self.painter.setPen(self.default_pen)

        for i in range(len(task["betsect"])):
            if task["betsect"][i].label != "":
                self.painter.setPen(self.halfpen)

                if task["betsect"][i].label_off == "справа-сверху":

                    elements.draw_text_by_points(
                        self,
                        strt=QPointF(self.wsect(i),
                                     hcenter - self.msectrad(i)),
                        fini=QPointF(self.wsect(i),
                                     hcenter - self.msectrad(i) - 40),
                        txt=task["betsect"][i].label,
                        alttxt=False,
                        off=14,
                        polka=QPointF(self.wsect(i), hcenter))
                elif task["betsect"][i].label_off == "справа":
                    txt = task["betsect"][i].label
                    self.painter.setPen(Qt.NoPen)
                    self.painter.drawRect(
                        QRectF(
                            QPointF(
                                self.wsect(i) - 3 + 6, hcenter -
                                QFontMetrics(self.font).height() / 2),
                            QPointF(
                                self.wsect(i) + 3 + 6 +
                                QFontMetrics(self.font).width(txt), hcenter +
                                QFontMetrics(self.font).height() / 2)))

                    self.painter.setPen(self.default_pen)
                    elements.draw_text_by_points(
                        self,
                        strt=QPointF(self.wsect(i),
                                     hcenter + self.msectrad(i)),
                        fini=QPointF(self.wsect(i),
                                     hcenter - self.msectrad(i)),
                        txt=task["betsect"][i].label,
                        alttxt=False,
                        off=6,
                        polka=None)

                elif task["betsect"][i].label_off == "слева-снизу":
                    elements.draw_text_by_points(
                        self,
                        strt=QPointF(self.wsect(i),
                                     hcenter + self.msectrad(i)),
                        fini=QPointF(self.wsect(i),
                                     hcenter + self.msectrad(i) + 40),
                        txt=task["betsect"][i].label,
                        alttxt=True,
                        off=-24,
                        polka=QPointF(self.wsect(i), hcenter))

        # подсветка узла
        if self.highlited_node is not None:
            row = self.highlited_node[1]

            pen = QPen()
            pen.setColor(Qt.blue)
            pen.setWidth(5)
            p = QPoint(self.wsect(row), self.hcenter)
            self.painter.setBrush(Qt.green)
            self.painter.drawEllipse(QRect(p - QPoint(5, 5), p + QPoint(5, 5)))
            self.painter.setBrush(Qt.black)

        if zleft:
            y = self.sectrad(0) + 20
            paintool.zadelka(self.painter,
                             self.wsect(0) - 10,
                             self.wsect(0),
                             hcenter - y,
                             hcenter + y,
                             left_border=False,
                             right_border=True)

        if zright:
            y = self.sectrad(-1) + 20
            paintool.zadelka(self.painter,
                             self.wsect(-1),
                             self.wsect(-1) + 10,
                             hcenter - y,
                             hcenter + y,
                             left_border=True,
                             right_border=False)

        sects = task["sections"]
        for i in range(len(sects)):
            self.painter.setPen(self.halfpen)
            if sects[i].label != "":
                elements.draw_text_by_points(
                    self,
                    QPoint(self.wsect(i), hcenter - self.sectrad(i)),
                    QPoint(self.wsect(i + 1), hcenter - self.sectrad(i)),
                    txt=paintool.greek(sects[i].label) +
                    ("" if sects[i].label_height > -20 else "  "),
                    alttxt=True,
                    polka=QPointF((self.wsect(i + 1) + self.wsect(i)) / 2,
                                  hcenter))
示例#5
0
	def paintEventImplementation(self, ev):
		sects = self.shemetype.task["sections"]
		bsects = self.shemetype.task["betsect"]

		assert len(sects) + 1 == len(bsects)

		width = self.width()
		height = self.height()

		center = QPoint(width/2, self.hcenter)

		font_size = self.shemetype.font_size.get()
		lwidth = self.shemetype.line_width.get()

		base_height = self.shemetype.base_height.get()
		arrow_size = self.shemetype.arrow_size.get()
		dimlines_level = self.shemetype.dimlines_level.get()
		dimlines_level2 = self.shemetype.dimlines_level2.get()
		sterzn_off = self.shemetype.sterzn_off.get()

		font = self.painter.font()
		font.setItalic(True)
		font.setPointSize(font_size)
		self.painter.setFont(font)

		br = QPen()
		br.setWidth(lwidth)
		self.painter.setPen(br)

		br = QBrush(Qt.SolidPattern)
		br.setColor(Qt.white)
		self.painter.setBrush(br)

		hasnegative = False
		for b in bsects:
			if b.l < 0:
				hasnegative = True

		hasright = bsects[-1].l != 0  

		left_span = 60
		right_span = 30 if not hasright else 10 + dimlines_level2
		up_span = 30
		down_span = 30 if hasnegative else 10 + dimlines_level
		down_span += self.text_height

		smax = 0
		smin = 0
		for b in bsects:
			if b.l > smax: smax = b.l
			if b.l < smin: smin = b.l

		fheight = height - up_span - down_span
		#hsum = 0
		#for s in bsects: hsum += s.l 

		if smax != smin:
			hkoeff = float(fheight) / (smax - smin)
		else:
			hkoeff = float(fheight)
		hbase = hkoeff * smax + up_span

		lu = QPoint(left_span, hbase)
		ru = QPoint(width - right_span, hbase)
		ld = QPoint(left_span, hbase+base_height)
		rd = QPoint(width - right_span, hbase+base_height)

		fsize = width - right_span - left_span
		lsum = 0
		for s in sects: lsum += s.l 
		lkoeff = float(fsize) / lsum


		def xnode(n):
			if n==-1:
				n = len(sects)

			x = 0
			for i in range(n): x += sects[i].l * lkoeff
			return left_span + x


		# Размерные линии горизонтальные.
		for i in range(len(self.sections())):
			xl = xnode(i)
			xr = xnode(i+1)

			if sects[i].dims:

				paintool.dimlines(self.painter, 
					QPoint(xl, hbase), 
					QPoint(xr, hbase), 
					hbase+dimlines_level)

				elements.draw_text_by_points(
							self,
							QPoint(xl, hbase+dimlines_level), 
							QPoint(xr, hbase+dimlines_level), 
							txt=util.text_prepare_ltext(self.sections()[i].l, "a"),
							alttxt=True,
							off = 8
						)

		self.painter.setBrush(Qt.white)

		self.painter.drawLine(lu, ru)
		self.painter.drawLine(lu, ld)
		self.painter.drawLine(ld, rd)
		self.painter.drawLine(rd, ru)

		self.painter.setPen(self.halfpen)
		for i in range(len(sects)):
			if sects[i].label != "":
				elements.draw_text_by_points(
					self,
					QPoint(xnode(i), hbase-sects[i].label_height), 
					QPoint(xnode(i+1), hbase-sects[i].label_height), 
					txt=paintool.greek(sects[i].label) + ("" if sects[i].label_height > -20 else "  "),
					alttxt=True,
					polka=QPointF((xnode(i+1) + xnode(i)) / 2, hbase+base_height/2)
				)

		self.painter.setPen(self.pen)


		#Рисуем стержни
		for i in range(len(bsects)):
			#Доп. Шарниры
			if bsects[i].sharn != "нет":
				if bsects[i].sharn == "1":
					sharn_type = "снизу врез1"
				elif bsects[i].sharn == "2":
					sharn_type = "снизу шарн2"
				elements.draw_element_sharn(self,
					pnt=QPoint(xnode(i), hbase+base_height),
					type=sharn_type,
					termrad=25,
					termx=25,
					termy=10,
					rad=4
				)

			# Рисуем стержень
			if bsects[i].l != 0:
				if bsects[i].l > 0:
					strt = QPointF(xnode(i), hbase)
					strt_z = QPointF(xnode(i), hbase - 20)
					fini = QPointF(xnode(i), hbase - bsects[i].l*hkoeff)
				else:
					strt = QPoint(xnode(i), hbase + base_height)
					strt_z = QPointF(xnode(i), hbase + base_height + 20)
					fini = QPointF(xnode(i), hbase - bsects[i].l*hkoeff)
				
				if bsects[i].zazor is False:
					self.painter.setPen(self.doublepen)
					if self.highlited_node and self.highlited_node[1] == i:
						self.painter.setPen(self.widegreen)

					self.painter.drawLine(strt, fini)
				
					self.painter.setPen(self.pen)
					if self.highlited_node and self.highlited_node[1] == i:
						self.painter.setPen(self.green)
					self.painter.drawEllipse(paintool.radrect(strt, 4))

				else:
					self.painter.setPen(self.doublepen)
				
					if self.highlited_node and self.highlited_node[1] == i:
						self.painter.setPen(self.widegreen)

					self.painter.drawLine(strt_z, fini)				
					self.painter.setPen(self.pen)					

					self.painter.setPen(self.halfpen)
		
					if self.highlited_node and self.highlited_node[1] == i:
						self.painter.setPen(self.green)

					paintool.draw_dimlines(
						painter=self.painter, 
						apnt=strt, 
						bpnt=strt_z, 
						offset=QPoint(-20,0), 
						textoff=QPoint(-10-QFontMetrics(self.font).width(paintool.greek(bsects[i].zazor_txt))/2,0), 
						text=paintool.greek(bsects[i].zazor_txt), 
						arrow_size=10, 
						splashed=True, 
						textline_from=None)
					self.painter.setPen(self.pen)


				if (bsects[i].l < 0):
					angle = deg(90)
				else:
					angle = deg(-90)
				
				upnt = bsects[i].l*hkoeff
				paintool.zadelka_sharnir(self.painter, QPoint(xnode(i), hbase - upnt), angle, 30, 10, 5)

				ap = -upnt if bsects[i].l < 0 else 0
				bp = 0 if bsects[i].l < 0 else -upnt

				txt = util.text_prepare_ltext(abs(bsects[i].l))
				txt_var2 = util.text_prepare_ltext(abs(bsects[i].l/2))
				txt2 = util.text_prepare_ltext(abs(bsects[i].A), "A")
				txt2 = txt2 + ",E"

				txt = txt+","+txt2
				txt_var2 = txt_var2+","+txt2
				txt_var1 = txt_var2

				if bsects[i].sterzn_text1:
					txt = bsects[i].sterzn_text1
					txt_var1 = txt

				if bsects[i].sterzn_text2:
					txt_var2 = bsects[i].sterzn_text2

				dimlines_level2=0


				center= QPointF(xnode(i)+dimlines_level2, hbase)
				alttxt = False

				if bsects[i].l < 0:
					ap = ap + base_height
	
				cp = (ap+bp)/2
				
				offset = QPointF(0, -bsects[i].sterzn_text_off)
				if bsects[i].sterzn_text_horizontal:
					offfff = 10
					if bsects[i].sterzn_text_alt:
						a = center + QPointF(0,(ap+bp)/2) + QPointF(-QFontMetrics(self.font).width(txt)-offfff, QFontMetrics(self.font).height()/2) + offset
						b = center + QPointF(0,(ap+bp)/2) + QPointF(0, QFontMetrics(self.font).height()/2) + offset
						a1 = center + QPointF(0,(ap+cp)/2) + QPointF(-QFontMetrics(self.font).width(txt_var1)-offfff, QFontMetrics(self.font).height()/2)
						b1 = center + QPointF(0,(ap+cp)/2) + QPointF(0, QFontMetrics(self.font).height()/2)
						a2 = center + QPointF(0,(cp+bp)/2) + QPointF(-QFontMetrics(self.font).width(txt_var2)-offfff, QFontMetrics(self.font).height()/2)
						b2 = center + QPointF(0,(cp+bp)/2) + QPointF(0, QFontMetrics(self.font).height()/2)

					else:
						a = center + QPointF(0,(ap+bp)/2) + QPointF(0, QFontMetrics(self.font).height()/2) + offset
						b = center + QPointF(0,(ap+bp)/2) + QPointF(QFontMetrics(self.font).width(txt)+offfff, QFontMetrics(self.font).height()/2) + offset
						a1 = center + QPointF(0,(ap+cp)/2) + QPointF(0, QFontMetrics(self.font).height()/2)
						b1 = center + QPointF(0,(ap+cp)/2) + QPointF(QFontMetrics(self.font).width(txt_var1)+offfff, QFontMetrics(self.font).height()/2)
						a2 = center + QPointF(0,(cp+bp)/2) + QPointF(0, QFontMetrics(self.font).height()/2)
						b2 = center + QPointF(0,(cp+bp)/2) + QPointF(QFontMetrics(self.font).width(txt_var2)+offfff, QFontMetrics(self.font).height()/2)

				else:
					a = center + QPointF(0,ap) + offset
					b = center + QPointF(0,bp) + offset
					a1 = center + QPointF(0,ap)
					b1 = center + QPointF(0,cp)
					a2 = center + QPointF(0,cp)
					b2 = center + QPointF(0,bp)
					alttxt = not bsects[i].sterzn_text_alt


				if bsects[i].F2 == "нет":							
					elements.draw_text_by_points_angled(
						self,
						a,
						b,
						txt=txt,
						alttxt=alttxt,
						off = 15
					)

				else:
					cp = (ap+bp)/2
					elements.draw_text_by_points_angled(
						self,
						a1, b1,
#						QPoint(xnode(i)+dimlines_level2, hbase + ap),
#						QPoint(xnode(i)+dimlines_level2, hbase + cp),
						txt=txt_var1,
						alttxt=alttxt,
						off = 15
					)
					elements.draw_text_by_points_angled(
						self,
						a2, b2,
#						QPoint(xnode(i)+dimlines_level2, hbase + cp),
#						QPoint(xnode(i)+dimlines_level2, hbase + bp),
						txt=txt_var2,
						alttxt=alttxt,
						off = 15
					)

				self.painter.setPen(self.halfpen)
				if bp == 0:
					cp = ap/2
					# рисуем метку
					if bsects[i].lbl != "":
						elements.draw_text_by_points(
							self,
							QPoint(xnode(i), hbase+cp),
							QPoint(xnode(i), hbase+bp),
							txt=paintool.greek(bsects[i].lbl),
							alttxt=False,
							polka=QPointF(xnode(i), hbase+cp/2+5)
						)					
				if ap == 0:
					cp = bp/2
					if bsects[i].lbl != "":
						elements.draw_text_by_points(
							self,
							QPoint(xnode(i), hbase+ap),
							QPoint(xnode(i), hbase+cp),
							txt=paintool.greek(bsects[i].lbl),
							alttxt=False,
							polka=QPointF(xnode(i), hbase+cp/2+5)

						)						

				self.painter.setPen(self.pen)
				self.painter.setBrush(Qt.white)

			if bsects[i].l == 0:
				if bsects[i].lbl != "":
					self.painter.setPen(self.halfpen)
					elements.draw_text_by_points(
						self,
						QPoint(xnode(i), hbase),
						QPoint(xnode(i), hbase-60),
						txt=paintool.greek(bsects[i].lbl),
						alttxt=False,
						polka=QPointF(xnode(i), hbase)
					)						
	
				if self.highlited_node and self.highlited_node[1] == i:
					self.painter.setPen(self.green)
					self.painter.drawEllipse(paintool.radrect(QPoint(xnode(i), hbase), 4))


		self.painter.setPen(self.pen)
		self.painter.setBrush(Qt.white)

		# Рисуем силы
		for i in range(len(bsects)):
			if bsects[i].F != "нет":
				if bsects[i].l > 0:
					type = "снизу к" if bsects[i].F == "+" else "снизу от"
					pnt = QPointF(xnode(i), hbase+base_height) 
					arrow_length = (dimlines_level-base_height)*2/3
				else:
					type = "сверху от" if bsects[i].F == "+" else "сверху к"
					pnt = QPointF(xnode(i), hbase)
					arrow_length = dimlines_level*2/3
					
				elements.draw_element_force(self, 
					pnt, type, 
					arrow_length, arrow_size, bsects[i].Ftxt, 
					True, pen=self.pen)

			if bsects[i].F2 != "нет":
				h = bsects[i].l * hkoeff
				arrow_size_2 = arrow_size
				arrow_size_3 = 28
				if bsects[i].l != 0:
					if bsects[i].F2 == "+":
						paintool.common_arrow(self.painter, 
							QPointF(xnode(i)+sterzn_off, hbase - h/2), 
							QPointF(xnode(i)+sterzn_off, hbase - h/2 - arrow_size_3), 
							arrow_size_2)
	
						paintool.common_arrow(self.painter, 
							QPointF(xnode(i)-sterzn_off, hbase - h/2), 
							QPointF(xnode(i)-sterzn_off, hbase - h/2 - arrow_size_3), 
							arrow_size_2)
	
						self.painter.setPen(self.halfpen)
						self.painter.drawLine(
							QPointF(xnode(i)-sterzn_off, hbase - h/2),
							QPointF(xnode(i)+sterzn_off, hbase - h/2)
						)
					else:
						paintool.common_arrow(self.painter, 
							QPointF(xnode(i)+sterzn_off, hbase - h/2), 
							QPointF(xnode(i)+sterzn_off, hbase - h/2 + arrow_size_3), 
							arrow_size_2)
		
						paintool.common_arrow(self.painter, 
							QPointF(xnode(i)-sterzn_off, hbase - h/2), 
							QPointF(xnode(i)-sterzn_off, hbase - h/2 + arrow_size_3), 
							arrow_size_2)
		
						self.painter.setPen(self.halfpen)
						self.painter.drawLine(
							QPointF(xnode(i)-sterzn_off, hbase - h/2),
							QPointF(xnode(i)+sterzn_off, hbase - h/2)
						)
					if bsects[i].F2txt != "":
						elements.draw_text_by_points(self, 
							QPointF(xnode(i)-sterzn_off, hbase - h/2 - dimlines_level/5), 
							QPointF(xnode(i)-sterzn_off, hbase - h/2 + dimlines_level/5), 
							txt = bsects[i].F2txt,
							alttxt = False,
							off = 10)
						
				

		# Рисуем заделку на левом крае
		self.painter.setPen(self.doublepen)
		if self.shemetype.zadelka1.get() == "2":
			#paintool.zadelka_sharnir_type2(self.painter, QPoint(xnode(0), hbase), deg(0), 30, 10, 5)
			elements.draw_element_sharn(self, 
				pnt=QPoint(xnode(0), hbase+base_height/2), 
				type="слева шарн2", 
				termrad=25,
				termx=25,
				termy=10,
				rad=4)

		elif self.shemetype.zadelka1.get() == "1":
			elements.draw_element_sharn(self, 
				pnt=QPoint(xnode(0), hbase+base_height/2), 
				type="слева врез1", 
				termrad=25,
				termx=25,
				termy=10,
				rad=4)

		if self.shemetype.zadelka2.get() == "2":
			#paintool.zadelka_sharnir_type2(self.painter, QPoint(xnode(0), hbase), deg(0), 30, 10, 5)
			elements.draw_element_sharn(self, 
				pnt=QPoint(xnode(-1), hbase+base_height/2), 
				type="справа шарн2", 
				termrad=25,
				termx=25,
				termy=10,
				rad=4)

		elif self.shemetype.zadelka2.get() == "1":
			elements.draw_element_sharn(self, 
				pnt=QPoint(xnode(-1), hbase+base_height/2), 
				type="справа врез1", 
				termrad=25,
				termx=25,
				termy=10,
				rad=4)