Example #1
0
    def draw_rad_dims(self, ctx):

        """
        Draw the radius dimensions of the bend.

        Arguments:
        ctx -- a Pycairo context
        """

        # The angle at which the radius dimension lines are drawn
        # depends on the bend angle for pipe bends, but is always
        # vertical for pipe straights. Since this will be called
        # from a subclass, check whether we have a pipe bend by
        # verifying whether the "bend_arc" instance attribute is set.

        if hasattr(self, "bend_arc"):
            b_arc = self.bend_arc       # pylint: disable=E1101
        else:
            b_arc = 0

        pts = {}

        ctx.save()

        for scale, comp in zip(range(4, 0, -1), ["co", "ci", "lo", "li"]):

            # pylint: disable=E1101

            dll = self.dim_line_length * scale

            for i in ["out", "in"]:
                point = self.pc_pts[i][comp][-1 if i == "out" else 0]
                pts[i] = ptoc(b_arc + pi / 2, dll, point)
                ctx.move_to(*point.t())
                ctx.line_to(*pts[i].t())

            # pylint: enable=E1101

            ctx.stroke()
            draw_dim_line(ctx, pts["out"], pts["in"],
                          self.diameters[comp], self.scale, 0)

        ctx.restore()
Example #2
0
    def draw_len_dim(self, ctx):

        """
        Draws the length dimension line for a straight.

        Arguments:
        ctx -- a Pycairo context
        """

        ldm = self.len_dim_line_length
        lom = self.len_dim_line_length_offset_m
        lwm = self.len_dim_line_length_width_m
        lem = lom + lwm
        lcm = lom + lwm / 2

        pts = []
        for end in [0, -1]:
            pts.append(self.pc_pts["ctr"][end])

        ctx.save()

        # Draw the bounding lines

        for num in range(2):
            ctx.move_to(self.p_rad["fo"] + ldm * lom, pts[num].y)
            ctx.line_to(self.p_rad["fo"] + ldm * lem, pts[num].y)
            ctx.stroke()

        # Draw the dimension line itself

        for num in range(2):
            pts[num] = Point(self.p_rad["fo"] + ldm * lcm, pts[num].y)

        draw_dim_line(ctx, pts[0], pts[1], self.length, self.scale, 0, "")

        ctx.restore()
Example #3
0
    def draw_seg_dims(self, ctx):

        """
        Draw segment extrados and intrados dimensions.

        Arguments:
        ctx -- a Pycairo context
        """

        segs = self.num_segments
        s_ang = self.segment_angle
        cld = self.p_rad["co"] - self.p_rad["lo"]
        dpt = self.dos_dim_dp
        ddll = self.dos_dim_line_length

        idx = [0, 0]
        pts = [0, 0]

        ctx.save()

        if segs >= 3:

            # Draw extrados dimensions

            idx[0] = segs // 2 + (segs % 2)
            idx[1] = idx[0] + 1

            for comp, dim in zip(["co", "lo"],
                           [self.segdims[k].value for k in ["cex", "lex"]]):
                if comp == "co" and self.casing_type == "onepiece":
                    continue
                for line in range(2):
                    stp = self.pc_pts["out"][comp][idx[line]]
                    lnl = ddll * 1.7 if comp == "co" else cld + ddll * 0.7
                    pts[line] = ptoc(s_ang * idx[0], lnl, stp)

                    ctx.move_to(*stp.t())
                    ctx.line_to(*pts[line].t())

                ctx.stroke()
                draw_dim_line(ctx, pts[1], pts[0], dim, self.scale, dpt)

            # Draw intrados dimensions

            idx[0] += 1 - (segs % 2)
            idx[1] = idx[0] + 1

            for comp, dim in zip(["co", "lo"],
                            [self.segdims[k].value for k in ["cin", "lin"]]):
                if comp == "co" and self.casing_type == "onepiece":
                    continue
                for line in range(2):
                    if self.casing_type == "onepiece":
                        mult = 0.7
                    else:
                        mult = 1.7
                    stp = self.pc_pts["in"][comp][idx[line]]
                    lnl = ddll * 0.7 if comp == "co" else cld + ddll * mult
                    pts[line] = ptoc(s_ang * (idx[0] - 2 + segs % 2) +
                                     pi, lnl, stp)

                    ctx.move_to(*stp.t())
                    ctx.line_to(*pts[line].t())

                ctx.stroke()
                draw_dim_line(ctx, pts[1], pts[0], dim, self.scale, dpt)

        ctx.restore()