class IrradiationPDFTableOptions(BasePDFOptions): status_width = dumpable(Float(0.25)) position_width = dumpable(Float(0.5)) identifier_width = dumpable(Float(0.6)) sample_width = dumpable(Float(1.25)) material_width = dumpable(Float(0.5)) project_width = dumpable(Float(1.25)) _persistence_name = 'irradiation_pdf_table_options' def widths(self, units=inch): return [getattr(self, '{}_width'.format(w)) * units for w in ('status', 'position', 'identifier', 'sample', 'material', 'project')] def traits_view(self): layout_grp = self._get_layout_group() layout_grp.show_border = False width_grp = VGroup(Item('status_width', label='Status (in)'), Item('position_width', label='Pos. (in)'), Item('identifier_width', label='L# (in)'), Item('sample_width', label='Sample (in)'), Item('material_width', label='Material (in)'), Item('project_width', label='Project (in)'), label='Column Widths') v = View(Tabbed(layout_grp, width_grp), kind='livemodal', buttons=['OK', 'Cancel'], title='PDF Save Options', resizable=True) return v
class FigurePDFOptions(BasePDFOptions): fixed_width = dumpable(Float) fixed_height = dumpable(Float) page_type = dumpable(Enum('letter', 'A4')) units = dumpable(Enum('inch', 'cm')) use_column_width = dumpable(Bool(True)) columns = dumpable(Enum('1', '2', '3', '2/3')) fit_to_page = dumpable(Bool) @property def bounds(self): units = UNITS_MAP[self.units] page = PAGE_MAP[self.page_type] if self.use_column_width: if self.orientation == 'landscape': page = landscape(page) width_margins = self.bottom_margin + self.top_margin else: width_margins = self.left_margin + self.right_margin fw = page[0] w = fw - width_margins * units # print 'cw', w, fw, width_margins, width_margins * units, COLUMN_MAP[self.columns] nw = w * COLUMN_MAP[self.columns] b = [nw, nw] elif self.fit_to_page: b = [page[0], page[1]] else: b = [self.fixed_width * units, self.fixed_height * units] return b @property def page_size(self): orientation = 'landscape_' if self.orientation == 'landscape' else '' return '{}{}'.format(orientation, self.page_type) @property def dest_box(self): units = UNITS_MAP[self.units] if self.orientation == 'landscape': w, h = self.bounds lbrt = self.bottom_margin, self.right_margin, h / units, w / units else: w, h = self.bounds lbrt = self.left_margin, self.bottom_margin, w / units, h / units # lbrt = self.left_margin, self.bottom_margin, -self.right_margin, -self.top_margin # print map(lambda x: x*units, lbrt) # print 'lbrt', lbrt return lbrt
class LoadingPDFOptions(BasePDFOptions): _persistence_name = 'load_pdf_options' show_colors = dumpable(Bool) show_identifiers = dumpable(Bool) show_samples = dumpable(Bool) show_weights = dumpable(Bool) show_hole_numbers = dumpable(Bool) view_pdf = dumpable(Bool) use_alternating_background = dumpable(Bool) alternating_background = dumpable(TraitsColor) def _show_colors_changed(self, new): if new: self.use_alternating_background = False def get_alternating_background(self): color = self.alternating_background t = color.red(), color.green(), color.blue() return [x / 255. for x in t] def traits_view(self): layout_grp = VGroup(Item('orientation'), VGroup(Item('left_margin', label='Left'), Item('right_margin', label='Right'), Item('top_margin', label='Top'), Item('bottom_margin', label='Bottom'), show_border=True, label='Margins'), show_border=True, label='layout') grp = VGroup( Item('view_pdf'), Item('show_identifiers'), Item('show_samples'), Item('show_weights'), Item('show_hole_numbers'), Item('show_colors'), Item('use_alternating_background', enabled_when='not show_colors'), Item('alternating_background', enabled_when='use_alternating_background')) v = okcancel_view(VGroup(layout_grp, grp), title='Configure PDF') return v
class LoadingPDFOptions(BasePDFOptions): _persistence_name = 'load_pdf_options' show_colors = dumpable(Bool) show_labnumbers = dumpable(Bool) show_weights = dumpable(Bool) show_hole_numbers = dumpable(Bool) view_pdf = dumpable(Bool) use_alternating_background = dumpable(Bool) alternating_background = dumpable(TraitsColor) def _show_colors_changed(self, new): if new: self.use_alternating_background = False def get_alternating_background(self): t = self.alternating_background.toTuple()[:3] return map(lambda x: x / 255., t) def traits_view(self): layout_grp = VGroup(Item('orientation'), VGroup(Item('left_margin', label='Left'), Item('right_margin', label='Right'), Item('top_margin', label='Top'), Item('bottom_margin', label='Bottom'), show_border=True, label='Margins'), show_border=True, label='layout') grp = VGroup( Item('view_pdf'), Item('show_labnumbers'), Item('show_weights'), Item('show_hole_numbers'), Item('show_colors'), Item('use_alternating_background', enabled_when='not show_colors'), Item('alternating_background', enabled_when='use_alternating_background')) v = View(VGroup(layout_grp, grp), title='Configure PDF', kind='livemodal', buttons=['OK', 'Cancel']) return v
class IrradiationPDFTableOptions(BasePDFOptions): status_width = dumpable(Float(0.25)) position_width = dumpable(Float(0.5)) identifier_width = dumpable(Float(0.6)) sample_width = dumpable(Float(1.25)) material_width = dumpable(Float(0.5)) project_width = dumpable(Float(1.25)) only_selected_level = dumpable(Bool(False)) _persistence_name = 'irradiation_pdf_table_options' def widths(self, units=inch): return [ getattr(self, '{}_width'.format(w)) * units for w in ('status', 'position', 'identifier', 'sample', 'material', 'project') ] def traits_view(self): layout_grp = self._get_layout_group() layout_grp.show_border = False width_grp = VGroup(Item('status_width', label='Status (in)'), Item('position_width', label='Pos. (in)'), Item('identifier_width', label='L# (in)'), Item('sample_width', label='Sample (in)'), Item('material_width', label='Material (in)'), Item('project_width', label='Project (in)'), label='Column Widths') main_grp = VGroup(Item('only_selected_level', label='Only Selected Level'), label='Main') v = okcancel_view(Tabbed(main_grp, layout_grp, width_grp), title='PDF Save Options') return v