Пример #1
0
    def translate(self, sk2_doc, sk_doc):
        sk2model = sk2_doc.model
        self.model = sk_doc.model
        self.skmtds = skmtds = sk_doc.methods
        self.sk_doc = sk_doc
        self.sk2_doc = sk2_doc
        for item in sk2model.childs:
            if item.cid == sk2_model.PAGES:
                layout = skmtds.get_layout_obj()
                fmt, size, ornt = item.childs[0].page_format
                layout.format = fmt
                layout.size = () + tuple(size)
                layout.orientation = ornt
                self.dx = size[0] / 2.0
                self.dy = size[1] / 2.0
                self.page_dx = 0.0
                childs = []
                for page in item.childs:
                    fmt, size, ornt = page.page_format
                    self.page_size = () + tuple(size)
                    childs += self.translate_page(self.model, page)
                    self.dx += self.page_size[0] + 30.0
                    self.page_dx += self.page_size[0] + 30.0
                self.model.childs = [
                    self.model.childs[0],
                ] + childs + self.model.childs[-2:]
            elif item.cid == sk2_model.GRID_LAYER:
                grid = skmtds.get_grid_layer()
                grid.geometry = tuple(item.grid)
                grid.grid_color = get_sk_color(item.style[1][2],
                                               self.sk2_doc.cms)
                grid.visible = item.properties[0]
            elif item.cid == sk2_model.GUIDE_LAYER:
                gl = skmtds.get_guide_layer()
                gl.layer_color = get_sk_color(item.style[1][2],
                                              self.sk2_doc.cms)
                gl.visible = item.properties[0]
                gl.childs = []
                for chld in item.childs:
                    if chld.cid == sk2_model.GUIDE:
                        position = chld.position + self.dx
                        orientation = abs(chld.orientation - 1)
                        if orientation: position = chld.position + self.dy
                        guide = sk_model.SKGuide(position, orientation)
                        gl.childs.append(guide)

        self.model = None
        self.sk2_doc = None
        self.sk_doc = None
        self.skmtds = None
Пример #2
0
 def guide(self, point, orientation):
     self.add_object(sk_model.SKGuide(point, orientation))