예제 #1
0
    def read_header(self, loader):
        if loader.version >= 3.0:
            if loader.startswith_line('land'):
                self.orientation = fig_const.LANDSCAPE
            else:
                self.orientation = fig_const.PORTRAIT

            if loader.startswith_line('cent'):
                self.justification = fig_const.CENTER_JUSTIFIED
            else:
                self.justification = fig_const.FLUSH_LEFT_JUSTIFIED

            if loader.startswith_line('metric'):
                self.units = fig_const.METRIC
            else:
                self.units = fig_const.INCHES

        if loader.version >= 3.2:
            self.paper_size, = figlib.unpack('s', loader.get_line())
            self.magnification, = figlib.unpack('f', loader.get_line())
            if loader.startswith_line('multiple'):
                self.multiple_page = fig_const.MULTIPLE
            else:
                self.multiple_page = fig_const.SINGLE
            self.transparent_color, = figlib.unpack('i', loader.get_line())

        data = figlib.unpack('ii', loader.get_line())
        self.resolution, self.coord_system = data
        self.comment = loader.pop_comment()
예제 #2
0
    def parse(self, loader, chunk=None):
        chunk = FIGModelObject.parse(self, loader, chunk)
        s = figlib.unpack(self._frm32, chunk)
        data = dict(zip(self._names32, s))
        self.__dict__.update(data)

        if self.forward_arrow:
            fa = FIGFArrow()
            fa.parse(loader)
            self.childs.append(fa)
        if self.backward_arrow:
            fb = FIGBArrow()
            fb.parse(loader)
            self.childs.append(fb)
        if self.sub_type == fig_const.T_PIC_BOX:
            picture = FIGPicture()
            picture.parse(loader)
            self.childs.append(picture)

        self.points = []
        while len(self.points) < self.npoints:
            line = loader.readln()
            if line is None:
                raise Exception('Line is corrupted')
            data = line.split()
            items = ([int(x), int(y)] for x, y in figlib.list_chunks(data, 2))
            self.points.extend(items)
예제 #3
0
    def parse(self, loader, chunk=None):
        chunk = FIGModelObject.parse(self, loader, chunk)
        s = figlib.unpack(self._frm32, chunk)
        data = dict(zip(self._names32, s))
        text = data.pop('string').rstrip()
        self.__dict__.update(data)

        while not text.endswith(STR_TERMINATOR):
            line = loader.readln(strip=False).rstrip()
            if not line:
                raise Exception('Premature end of string')
            text += line

        self.string = text[:-len(STR_TERMINATOR)]
예제 #4
0
    def parse(self, loader, chunk=None):
        chunk = FIGModelObject.parse(self, loader, chunk)
        s = figlib.unpack(self._frm32, chunk)
        data = dict(zip(self._names32, s))
        self.__dict__.update(data)

        if self.forward_arrow:
            fa = FIGFArrow()
            fa.parse(loader)
            self.childs.append(fa)
        if self.backward_arrow:
            fb = FIGBArrow()
            fb.parse(loader)
            self.childs.append(fb)
예제 #5
0
    def parse(self, loader, chunk=None):
        chunk = FIGModelObject.parse(self, loader, chunk)
        s = figlib.unpack(self._frm32, chunk)
        data = dict(zip(self._names32, s))
        self.__dict__.update(data)
        self.sub_type = figlib.spline_sub_type(self.sub_type, loader.version)

        if self.forward_arrow:
            fa = FIGFArrow()
            fa.parse(loader)
            self.childs.append(fa)
        if self.backward_arrow:
            fb = FIGBArrow()
            fb.parse(loader)
            self.childs.append(fb)

        self.points = []
        while len(self.points) < self.npoints:
            line = loader.readln()
            if line is None:
                raise Exception('Line is corrupted')
            data = line.split()
            items = ([int(x), int(y)] for x, y in figlib.list_chunks(data, 2))
            self.points.extend(items)

        if self.sub_type in fig_const.T_INTERPOLATED:
            self.control_points = []
            ncontrols = self.npoints * 2
            while len(self.control_points) < ncontrols:
                line = loader.readln()
                if line is None:
                    raise Exception('Line is corrupted')
                data = line.split()
                items = ([float(x), float(y)]
                         for x, y in figlib.list_chunks(data, 2))
                self.control_points.extend(items)
        elif self.sub_type in fig_const.T_XSPLINE:
            self.control_points = []
            while len(self.control_points) < self.npoints:
                line = loader.readln()
                if line is None:
                    raise Exception('Line is corrupted')
                items = map(float, line.split())
                self.control_points.extend(items)
예제 #6
0
 def parse(self, loader, chunk=None):
     chunk = FIGModelObject.parse(self, loader, chunk)
     s = figlib.unpack(self._frm32, chunk)
     data = dict(zip(self._names32, s))
     self.__dict__.update(data)
예제 #7
0
 def parse(self, loader, chunk=None):
     chunk = chunk or loader.readln()
     s = figlib.unpack(self._frm32, chunk.strip())
     data = dict(zip(self._names32, s))
     self.__dict__.update(data)