Exemple #1
0
    def set_scale(self, ctx, page_w, page_h):

        """
        Automatically sets a scale factor for the drawing.

        This will normally be called after the set_scale()
        function of a subclass has set the scale factor.
        'page_h' and 'page_w' should already have been up-scaled
        by the time this happens.

        Arguments:
        ctx -- a Pycairo context
        page_w, page_h -- height and width of the drawing area
        """

        # Upscale lines

        # Note that self.dim_line_length is used to calculate
        # the lengths of radius dimension lines. These lengths
        # can differ for individual subclasses, and so
        # self.dim_line_length should be set in the subclass's
        # own set_scale() function, but the dimension is common
        # to all Pipe subclasses, and so we upscale it here.

        self.dim_line_length /= self.scale     # pylint: disable=E1101

        # Call parent function

        DrawnComponent.set_scale(self, ctx, page_w, page_h)
Exemple #2
0
    def __init__(self, casingod, casingid, liningod, liningid, flange):

        """
        Initializes a Pipe instance.

        Subclasses should call this at the beginning of their own
        constructor function.

        Arguments:
        casingod -- outside diameter of casing, in mm
        casingid -- inside diameter of casing, in mm
        liningod -- outside diameter of lining, in mm
        liningid -- inside diameter of lining, in mm
        flange -- name of flange
        """

        # Call superclass constructor

        DrawnComponent.__init__(self)

        # Properties common to all pipe components

        self.flange = Flange(flange)

        # Bend diameters and radii common to all pipe components

        self.diameters = {"co": casingod,
                          "ci": casingid,
                          "lo": liningod,
                          "li": liningid,
                          "fi": self.flange.hole_diameter,
                          "fo": self.flange.flange_diameter}

        self.p_rad = {"co": casingod / 2.0,
                      "ci": casingid / 2.0,
                      "lo": liningod / 2.0,
                      "li": liningid / 2.0,
                      "fi": self.flange.hole_diameter / 2.0,
                      "fo": self.flange.flange_diameter / 2.0}

        # Colors common to all pipe components

        comp_col = {"co": (0.8, 0.8, 0.8), "ci": (0.9, 0.9, 0.9),
                    "lo": (0.6, 0.6, 0.6), "li": (1.0, 1.0, 1.0)}
        self.colors = {"comp": comp_col}