Exemple #1
0
    def _make_table(self, positions):
        data = [
            Row(items=[
                RowItem('L#'),
                RowItem('Irradiation'),
                RowItem('Sample'),
                RowItem('Positions')
            ]),
        ]

        ts = self._new_style(header_line_idx=0)

        ts.add('FONTSIZE', (0, 1), (-1, -1), 8)
        # ts.add('VALIGN', (-3, 1), (-1, -1), 'MIDDLE')

        for idx, pi in enumerate(positions):
            # row = (pi.labnumber, pi.irradiation_str, pi.sample,
            # pi.position_str)

            items = [
                RowItem(i) for i in (pi.labnumber, pi.irradiation_str,
                                     pi.sample, pi.position_str)
            ]
            row = Row(items=items)

            data.append(row)
            c = colors.white
            if self.options.show_colors:
                cc = pi.color
                if sum(cc) < 1.5:
                    ts.add('TEXTCOLOR', (0, idx + 1), (-1, idx + 1),
                           colors.white)

                c = Color(*cc)
            elif self.options.use_alternating_background:
                if idx % 2 == 0:
                    c = self.options.get_alternating_background()

                    if sum(c) < 1.5:
                        ts.add('TEXTCOLOR', (0, idx + 1), (-1, idx + 1),
                               colors.white)

            ts.add('BACKGROUND', (0, idx + 1), (-1, idx + 1), c)

        cw = map(lambda x: mm * x, [13, 21, 22, 38])

        rh = [mm * 5 for _ in xrange(len(data))]

        t = self._new_table(ts, data, colWidths=cw, rowHeights=rh)
        return t
Exemple #2
0
    def _make_meta_table(self, meta):
        ts = self._new_style()
        items = '<b>Load:</b> {load_name}|<b>Loader</b>: {username}|<b>Date</b>: {load_date}'.format(
            **meta).split('|')
        row1 = [self._new_paragraph(ti) for ti in items]
        row1 = Row(items=[RowItem(value=v) for v in row1])

        items = '<b>Projects</b>: {projects} | | '.format(**meta).split('|')
        row2 = [self._new_paragraph(ti) for ti in items]
        row2 = Row(items=[RowItem(value=v) for v in row2])

        table = self._new_table(ts, (row1, row2))

        return table
    def _make_notes_table(self, positions):
        data = [
            Row(items=[
                RowItem('L#'),
                RowItem('Irradiation'),
                RowItem('Sample'),
                RowItem('Hole'),
                RowItem('Weight'),
                RowItem('N. Xtals'),
                RowItem('Note')
            ]),
        ]

        ts = self._new_style()
        ts.add('LINEBELOW', (0, 0), (-1, 0), 1, colors.black)

        ts.add('FONTSIZE', (0, 1), (-1, -1), 8)
        # ts.add('VALIGN', (-3, 1), (-1, -1), 'MIDDLE')

        idx = 0
        prev_id = None
        for pi in positions:
            if pi.identifier == prev_id:
                items = ('', '', '', pi.position, pi.weight, pi.nxtals,
                         pi.note)
            else:
                items = (pi.identifier, pi.irradiation_str, pi.sample,
                         pi.position, pi.weight, pi.note)

            prev_id = pi.identifier
            data.append(Row(items=[RowItem(ri) for ri in items]))
            if idx % 2 != 0:
                ts.add('BACKGROUND', (0, idx + 1), (-1, idx + 1),
                       colors.lightgrey)
            idx += 1

        cw = [mm * x for x in [13, 30, 40, 15, 16, 17, 58]]

        rh = [mm * 5 for _ in range(len(data))]

        t = self._new_table(ts, data, colWidths=cw, rowHeights=rh)
        return t
Exemple #4
0
    def _make_notes_table(self, canvas):
        data = [
            Row(items=[
                RowItem('L#'),
                RowItem('Irradiation'),
                RowItem('Sample'),
                RowItem('Hole'),
                RowItem('Weight'),
                RowItem('Note')
            ]),
        ]

        ts = self._new_style()
        ts.add('LINEBELOW', (0, 0), (-1, 0), 1, colors.black)

        ts.add('FONTSIZE', (0, 1), (-1, -1), 8)
        # ts.add('VALIGN', (-3, 1), (-1, -1), 'MIDDLE')

        idx = 0
        prev_irrad = None
        for pi in sorted(canvas.scene.get_items(LoadIndicator),
                         key=lambda x: int(x.name)):
            if pi.irradiation:
                if pi.irradiation == prev_irrad:
                    items = (pi.labnumber_label.text, '', '', pi.name,
                             pi.weight or '', pi.note or '')
                else:
                    items = (pi.labnumber_label.text, pi.irradiation,
                             pi.sample, pi.name, pi.weight, pi.note)

                prev_irrad = pi.irradiation

                data.append(Row(items=[RowItem(ri) for ri in items]))
                if idx % 2 == 0:
                    ts.add('BACKGROUND', (0, idx + 1), (-1, idx + 1),
                           colors.lightgrey)
                idx += 1

        cw = map(lambda x: mm * x, [15, 22, 22, 22, 22, 80])

        rh = [mm * 5 for _ in xrange(len(data))]

        t = self._new_table(ts, data, colWidths=cw, rowHeights=rh)
        return t