Exemplo n.º 1
0
    def draw_body(self, hcenter, left, right):
        painter = self.painter
        painter.setFont(self.font)

        prefix = 30
        hsect = self.shemetype.base_section_height.get()

        flen = right - left - 2 * prefix
        lsum = self.lsum()
        step = flen / lsum

        cur = left + prefix
        wpnts = [cur]
        for sect in self.sections():
            cur += sect.l * step
            wpnts.append(cur)

        painter.setPen(self.pen)

        for i in range(len(self.bsections())):
            fdown = False
            arrow_size = self.shemetype.arrow_size.get()
            rad = 60

            if self.bsections()[i].M != "Нет":
                fdown = True
                pnt = QPoint(wpnts[i], hcenter)
                if self.bsections()[i].M == "+":
                    paintool.half_moment_arrow_common(painter=painter,
                                                      pnt=pnt,
                                                      rad=rad,
                                                      angle=deg(60),
                                                      angle2=deg(120),
                                                      arrow_size=arrow_size)
                if self.bsections()[i].M == "-":
                    paintool.half_moment_arrow_common(painter=painter,
                                                      pnt=pnt,
                                                      rad=rad,
                                                      angle=deg(120),
                                                      angle2=deg(60),
                                                      arrow_size=arrow_size)

            if self.bsections()[i].F != "Нет":
                apnt = QPoint(wpnts[i], hcenter - rad)
                bpnt = QPoint(wpnts[i], hcenter)
                if fdown:
                    apnt = apnt + QPoint(0, rad + hsect / 2)
                    bpnt = bpnt + QPoint(0, rad + hsect / 2)
                else:
                    apnt = apnt + QPoint(0, -hsect / 2)
                    bpnt = bpnt + QPoint(0, -hsect / 2)
                if self.bsections()[i].F == "-":
                    paintool.common_arrow(painter,
                                          apnt,
                                          bpnt,
                                          arrow_size=arrow_size)
                if self.bsections()[i].F == "+":
                    paintool.common_arrow(
                        painter,
                        bpnt,
                        apnt,
                        arrow_size=self.shemetype.arrow_size.get())

                if self.bsections()[i].F == "влево" or self.bsections(
                )[i].F == "вправо":
                    apnt = QPoint(wpnts[i], hcenter)
                    d = 40

                    if i == 0:
                        paintool.common_arrow(
                            painter,
                            apnt if self.bsections()[i].F == "влево" else
                            apnt + QPointF(-d, 0),
                            apnt + QPointF(-d, 0)
                            if self.bsections()[i].F == "влево" else apnt,
                            arrow_size=self.shemetype.arrow_size.get())
                    elif i == len(self.bsections()) - 1:
                        paintool.common_arrow(
                            painter,
                            apnt + QPointF(d, 0)
                            if self.bsections()[i].F == "влево" else apnt,
                            apnt if self.bsections()[i].F == "влево" else
                            apnt + QPointF(d, 0),
                            arrow_size=self.shemetype.arrow_size.get())
                    else:
                        d = 30
                        bpnt = apnt + QPointF(0, 25)
                        cpnt = apnt - QPointF(0, 25)

                        nnn = QPointF(-d, 0) if self.bsections(
                        )[i].F == "влево" else QPointF(d, 0)

                        paintool.common_arrow(
                            painter,
                            bpnt,
                            bpnt + nnn,
                            arrow_size=self.shemetype.arrow_size.get())
                        paintool.common_arrow(
                            painter,
                            cpnt,
                            cpnt + nnn,
                            arrow_size=self.shemetype.arrow_size.get())
                        self.painter.drawLine(bpnt, cpnt)

            if self.bsections()[i].M != "Нет":
                paintool.draw_text_centered(
                    painter,
                    pnt=QPoint(wpnts[i], hcenter - rad - 5),
                    text=paintool.greek(self.bsections()[i].MT),
                    font=self.font)
            if self.bsections()[i].F != "Нет":
                if (self.bsections()[i].F != "вправо"
                        and self.bsections()[i].F != "влево"):
                    if fdown == False:
                        painter.drawText(
                            QPoint(wpnts[i] + 10, hcenter - rad),
                            paintool.greek(self.bsections()[i].FT))

                    if fdown == True:
                        painter.drawText(
                            QPoint(wpnts[i] + 10, hcenter + 25),
                            paintool.greek(self.bsections()[i].FT))
                else:
                    painter.drawText(QPoint(wpnts[i] + 0, hcenter - 30),
                                     paintool.greek(self.bsections()[i].FT))

            if self.bsections()[i].sectname != "":
                off = 11 if self.bsections()[i].sharn != "" else 5
                painter.drawText(
                    QPoint(
                        wpnts[i] - off - QFontMetrics(self.font).width(
                            self.bsections()[i].sectname), hcenter + 21),
                    self.bsections()[i].sectname)

        rad2 = rad / 2
        step = 10
        # Отрисовка распределённых нагрузок:
        for i in range(len(self.sectforce())):
            #отрисовка распределённой силы.
            if self.sectforce()[i].Fr != "Нет":
                if self.sectforce()[i].Fr == "+":
                    paintool.raspred_force_vertical(
                        painter=painter,
                        apnt=QPoint(wpnts[i], hcenter - 3),
                        bpnt=QPoint(wpnts[i + 1], hcenter - 3),
                        step=step,
                        offset=QPoint(0, -rad2),
                        dim=True,
                        arrow_size=arrow_size / 3 * 2)
                elif self.sectforce()[i].Fr == "-":
                    paintool.raspred_force_vertical(
                        painter=painter,
                        apnt=QPoint(wpnts[i], hcenter - 3),
                        bpnt=QPoint(wpnts[i + 1], hcenter - 3),
                        step=step,
                        offset=QPoint(0, -rad2),
                        dim=False,
                        arrow_size=arrow_size / 3 * 2)

                paintool.draw_text_centered(
                    painter,
                    QPoint((wpnts[i] + wpnts[i + 1]) / 2, hcenter - 8 - rad2),
                    paintool.greek(self.sectforce()[i].FrT),
                    font=self.font)

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

        painter.drawRect(
            QRect(
                QPoint(left + prefix, hcenter - hsect / 2),
                QPoint(right - prefix, hcenter + hsect / 2),
            ))

        #dimlines
        for i in range(len(self.bsections()) - 1):
            paintool.dimlines(painter, QPoint(wpnts[i], hcenter),
                              QPoint(wpnts[i + 1], hcenter), hcenter + 80)
            text = util.text_prepare_ltext(self.sections()[i].l)
            if self.shemetype.postfix.get()[0]:
                text += self.shemetype.postfix.get()[1]
            paintool.draw_text_centered(
                painter, QPoint((wpnts[i] + wpnts[i + 1]) / 2,
                                hcenter + 80 - 5), text, self.font)

        self.draw_terminator(pos=wpnts[0],
                             angle=math.pi,
                             type=self.shemetype.left_node.get())
        self.draw_terminator(pos=wpnts[-1],
                             angle=0,
                             type=self.shemetype.right_node.get())

        for i in range(len(self.bsections())):
            if self.bsections()[i].sharn == "1":
                hoff = 0 if i == 0 or i == len(self.bsections()) - 1 else 8
                ihoff = 8 if i == 0 or i == len(self.bsections()) - 1 else 0
                paintool.draw_sharnir_1dim(painter,
                                           pnt=QPoint(wpnts[i],
                                                      hcenter + hoff),
                                           angle=math.pi / 2,
                                           rad=5.5,
                                           termrad=25 + ihoff,
                                           termx=20,
                                           termy=10,
                                           pen=self.pen,
                                           halfpen=self.halfpen,
                                           doublepen=self.doublepen)

            elif self.bsections()[i].sharn == "2":
                hoff = 0 if i == 0 or i == len(self.bsections()) - 1 else 8
                ihoff = 8 if i == 0 or i == len(self.bsections()) - 1 else 0
                paintool.draw_sharnir_2dim(painter,
                                           pnt=QPoint(wpnts[i],
                                                      hcenter + hoff),
                                           angle=math.pi / 2,
                                           rad=5.5,
                                           termrad=25 + ihoff,
                                           termx=20,
                                           termy=10,
                                           pen=self.pen,
                                           halfpen=self.halfpen)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 4
0
    def paintEventImplementation(self, ev):
        assert len(self.sections()) == len(self.bsections())

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

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

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

        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()

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

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

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

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

        left_span = 50
        right_span = 50
        up_span = 100
        down_span = 100 + len(
            self.sections()) * dimlines_step + dimlines_start_step

        if zadelka:
            left_span += base_h + zadelka_len
            right_span += base_h + zadelka_len

        width_span = left_span + right_span
        height_span = up_span + down_span
        center = center + QPoint(left_span - right_span,
                                 (up_span - down_span) / 2)

        maxd = 0
        maxh = 0
        for s in self.sections():
            if s.d > maxd: maxd = s.d
            if s.h > maxh: maxh = s.h

        base_d = (width - width_span) / maxd
        self.labels_width_scale = base_d

        sprev = None
        for s in reversed(self.sections()):
            shtrih = s.shtrih
            w = s.d * base_d
            h = s.h * base_h

            if sprev:
                sprev_d = sprev.d * base_d
                sprev_h = sprev.h * base_h

            if s.intgran:
                self.painter.drawRect(
                    QRect(center.x() - w / 2,
                          center.y() - h / 2, w, h))

            else:
                pen = QPen()
                pen.setWidth(lwidth)
                pen.setColor(Qt.white)
                self.painter.setPen(pen)

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

                self.painter.drawRect(
                    QRect(center.x() - w / 2,
                          center.y() - (maxh * base_h) / 2, w, maxh * base_h))

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

                self.painter.drawLine(
                    QPoint(center.x() - w / 2,
                           center.y() - h / 2),
                    QPoint(center.x() + w / 2,
                           center.y() - h / 2))
                self.painter.drawLine(
                    QPoint(center.x() - w / 2,
                           center.y() + h / 2),
                    QPoint(center.x() + w / 2,
                           center.y() + h / 2))

                if sprev:
                    self.painter.drawLine(
                        QPoint(center.x() - w / 2,
                               center.y() - h / 2),
                        QPoint(center.x() - w / 2,
                               center.y() - sprev_h / 2))
                    self.painter.drawLine(
                        QPoint(center.x() - w / 2,
                               center.y() + h / 2),
                        QPoint(center.x() - w / 2,
                               center.y() + sprev_h / 2))
                    self.painter.drawLine(
                        QPoint(center.x() + w / 2,
                               center.y() - h / 2),
                        QPoint(center.x() + w / 2,
                               center.y() - sprev_h / 2))
                    self.painter.drawLine(
                        QPoint(center.x() + w / 2,
                               center.y() + h / 2),
                        QPoint(center.x() + w / 2,
                               center.y() + sprev_h / 2))

            if shtrih:
                pen = QPen(Qt.NoPen)
                pen.setWidth(lwidth)
                self.painter.setPen(pen)

                brush = QBrush(Qt.BDiagPattern)
                brush.setColor(Qt.black)
                self.painter.setBrush(brush)

                self.painter.drawRect(
                    QRect(center.x() - w / 2 - lwidth / 2,
                          center.y() - h / 2 - lwidth / 2, w + lwidth,
                          h + lwidth))

            self.painter.setPen(default_pen)
            self.painter.setBrush(default_brush)
            sprev = s

        if zadelka:
            fsect = self.sections()[-1]
            h = fsect.h * base_h
            w = zadelka_len
            c = base_h

            lx = center.x() - fsect.d * base_d / 2
            llx = center.x() - fsect.d * base_d / 2 - w
            rx = center.x() + fsect.d * base_d / 2
            rrx = center.x() + fsect.d * base_d / 2 + w

            uy = center.y() - h / 2
            dy = center.y() + h / 2

            pen = QPen(Qt.NoPen)
            pen.setWidth(lwidth)
            self.painter.setPen(pen)

            brush = QBrush(Qt.FDiagPattern)
            brush.setColor(Qt.black)
            self.painter.setBrush(brush)

            self.painter.drawRect(QRect(llx - c, uy - c, w + c, h + 2 * c))
            self.painter.drawRect(QRect(rx, uy - c, w + c, h + 2 * c))

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

            self.painter.drawRect(
                QRect(llx - lwidth / 2, uy - lwidth / 2, w + lwidth,
                      h + lwidth))
            self.painter.drawRect(
                QRect(rx - lwidth / 2, uy - lwidth / 2, w + lwidth,
                      h + lwidth))

            self.painter.setBrush(default_brush)

            brush = QBrush(Qt.BDiagPattern)
            brush.setColor(Qt.black)
            self.painter.setBrush(brush)

            self.painter.drawRect(
                QRect(llx - lwidth / 2, uy - lwidth / 2, w + lwidth,
                      h + lwidth))
            self.painter.drawRect(
                QRect(rx - lwidth / 2, uy - lwidth / 2, w + lwidth,
                      h + lwidth))

            self.painter.setPen(default_pen)

            self.painter.drawLine(QPoint(llx, uy), QPoint(lx, uy))
            self.painter.drawLine(QPoint(llx, uy), QPoint(llx, dy))
            self.painter.drawLine(QPoint(llx, dy), QPoint(lx, dy))

            self.painter.drawLine(QPoint(rx, uy), QPoint(rrx, uy))
            self.painter.drawLine(QPoint(rrx, uy), QPoint(rrx, dy))
            self.painter.drawLine(QPoint(rx, dy), QPoint(rrx, dy))

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

        if axis:
            pen = QPen(Qt.DashDotLine)
            pen.setWidth(lwidth)
            self.painter.setPen(pen)

            self.painter.drawLine(
                QPoint(center.x(),
                       center.y() + (maxh) * base_h / 2 + 10),
                QPoint(center.x(),
                       center.y() - (maxh) * base_h / 2 - 10))

        i = 0
        wprev = 0
        for s in self.sections():
            """Текстовые поля"""

            w = s.d * base_d
            h = s.h * base_h
            c = center

            i += 1

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

            pen = QPen()
            pen.setWidth(lwidth / 2)
            self.painter.setPen(pen)

            if s.dtext_en:
                p0 = QPoint(center.x() - s.d / 2 * base_d,
                            center.y() + s.h / 2 * base_h)
                p1 = QPoint(center.x() + s.d / 2 * base_d,
                            center.y() + s.h / 2 * base_h)
                level = center.y(
                ) + maxh / 2 * base_h + dimlines_start_step + dimlines_step * i

                if s.dtext == "":
                    dtxt = paintool.greek(
                        "\\diam{}d".format(s.d if s.d != 1 else ""))
                else:
                    dtxt = paintool.greek(s.dtext)

                paintool.dimlines(self.painter, p0, p1, level)
                paintool.draw_text_centered(
                    self.painter, QPoint((p0.x() + p1.x()) / 2, level - 5),
                    dtxt, font)

            if s.htext_en:

                if s.htext == "":
                    htxt = paintool.greek(
                        "{}h".format(s.h if s.h != 1 else ""))
                else:
                    htxt = paintool.greek(s.htext)

                paintool.draw_vertical_splashed_dimlines_with_text(
                    self.painter,
                    c + QPoint(wprev / 2 + (w - wprev) / 4, -h / 2),
                    c + QPoint(wprev / 2 + (w - wprev) / 4, h / 2), 10, c,
                    htxt, font)

            wprev = w

        wprev = 0
        for i in range(len(self.sectforce())):
            """ Отрисовываем распределенную нагрузку."""

            s = self.sections()[i]
            sf = self.sectforce()[i]

            distrib_step = 10
            distrib_alen = 20

            w = s.d * base_d
            h = s.h * base_h
            c = center

            if sf.distrib:
                apnt = center + QPointF(w / 2, -h / 2 - lwidth)
                bpnt = center + QPointF(wprev / 2, -h / 2 - lwidth)
                paintool.draw_distribload(self.painter, apnt, bpnt,
                                          distrib_step, arrow_size / 3 * 2,
                                          distrib_alen)

                apnt = center + QPointF(-wprev / 2, -h / 2 - lwidth)
                bpnt = center + QPointF(-w / 2, -h / 2 - lwidth)
                paintool.draw_distribload(self.painter, apnt, bpnt,
                                          distrib_step, arrow_size / 3 * 2,
                                          distrib_alen)

                apnt = center + QPointF(wprev / 2,
                                        -h / 2 - lwidth - distrib_alen)
                bpnt = center + QPointF(-wprev / 2,
                                        -h / 2 - lwidth - distrib_alen)
                self.painter.drawLine(apnt, bpnt)

            wprev = w

        for i in range(len(self.bsections())):
            b = self.bsections()[i]
            s = self.sections()[i]

            w = s.d * base_d
            h = s.h * base_h
            c = center

            alen = 40
            moment_radius = 40

            if b.fen != "нет":
                apnt0 = center + QPoint(w / 2, -h / 2 - lwidth)
                apnt1 = center + QPoint(-w / 2, -h / 2 - lwidth)

                if b.fen == "-":
                    paintool.common_arrow(self.painter,
                                          apnt0 + QPoint(0, -alen), apnt0,
                                          arrow_size)
                    paintool.common_arrow(self.painter,
                                          apnt1 + QPoint(0, -alen), apnt1,
                                          arrow_size)

                if b.fen == "+":
                    paintool.common_arrow(self.painter, apnt0,
                                          apnt0 + QPoint(0, -alen), arrow_size)
                    paintool.common_arrow(self.painter, apnt1,
                                          apnt1 + QPoint(0, -alen), arrow_size)

                self.painter.drawLine(apnt0 + QPoint(0, -alen),
                                      apnt1 + QPoint(0, -alen))

            if b.men != "нет":
                direction = b.men == "+"

                arrow_size_pair = (arrow_size, 4)
                for apnt, direction in [
                    (center + QPoint(w / 2, 0), not direction),
                    (center + QPoint(-w / 2, 0), direction)
                ]:
                    self.common_scene.addItem(
                        SquareMomentItem(apnt,
                                         moment_radius / 2,
                                         h / 2 + 32,
                                         inverse=direction,
                                         arrow_size=arrow_size_pair,
                                         brush=Qt.black))

            if b.sharn != "нет":
                termrad = 20
                for w in [w, -w]:
                    if self.bsections()[i].sharn == "1":
                        paintool.draw_sharnir_1dim(self.painter,
                                                   pnt=center +
                                                   QPoint(w / 2, h / 2 + 3),
                                                   angle=math.pi / 2,
                                                   rad=3.5,
                                                   termrad=termrad,
                                                   termx=15,
                                                   termy=10,
                                                   pen=self.pen,
                                                   halfpen=self.halfpen,
                                                   doublepen=self.doublepen)

                    elif self.bsections()[i].sharn == "2":
                        paintool.draw_sharnir_2dim(self.painter,
                                                   pnt=center +
                                                   QPoint(w / 2, h / 2 + 3),
                                                   angle=math.pi / 2,
                                                   rad=3.5,
                                                   termrad=termrad,
                                                   termx=15,
                                                   termy=10,
                                                   pen=self.pen,
                                                   halfpen=self.halfpen)

        self.draw_labels()
Exemplo n.º 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)