Ejemplo n.º 1
0
class BasePDFOptions(BasePersistenceOptions):
    orientation = dumpable(Enum('landscape', 'portrait'))
    left_margin = dumpable(Float(1.5))
    right_margin = dumpable(Float(1))
    top_margin = dumpable(Float(1))
    bottom_margin = dumpable(Float(1))
    show_page_numbers = dumpable(Bool(False))

    _persistence_name = 'base_pdf_options'

    page_number_format = None
    fixed_width = dumpable(Float)
    fixed_height = dumpable(Float)

    page_type = dumpable(Enum('letter', 'A4', 'A2', 'A0', 'custom'))
    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]
        if self.page_type == 'custom':
            page = [self.fixed_width * units, self.fixed_height * units]
        else:
            page = PAGE_MAP[self.page_type]

        if self.fit_to_page:
            if self.orientation == 'landscape':
                b = [page[1], page[0]]
            else:
                b = [page[0], page[1]]

            b[0] -= (self.left_margin + self.right_margin) * units
            b[1] -= (self.top_margin + self.bottom_margin) * units

        elif 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]
        else:
            b = [self.fixed_width * units, self.fixed_height * units]

        return b

    @property
    def page_size(self):
        if self.page_type == 'custom':
            units = UNITS_MAP[self.units]
            ps = self.fixed_width * units, self.fixed_height * units
        else:
            orientation = 'landscape_' if self.orientation == 'landscape' else ''
            ps = '{}{}'.format(orientation, self.page_type)
        return ps

    @property
    def dest_box(self):
        units = UNITS_MAP[self.units]
        w, h = self.bounds
        w /= units
        h /= units
        return self.left_margin, self.bottom_margin, w, h

    def _get_layout_group(self):
        return PDFLayoutGroup
Ejemplo n.º 2
0
class JErrorMixin(HasTraits):
    include_j_position_error = dumpable(Bool(False))
    include_j_error_in_mean = dumpable(Bool(True))
class XLSXTableWriterOptions(BasePersistenceOptions):
    power_units = dumpable(Enum('W', 'C'))
    age_units = dumpable(Enum('Ma', 'Ga', 'ka', 'a'))
    hide_gridlines = dumpable(Bool(False))
    include_F = dumpable(Bool(True))
    include_radiogenic_yield = dumpable(Bool(True))
    include_production_ratios = dumpable(Bool(True))
    include_plateau_age = dumpable(Bool(True))
    include_integrated_age = dumpable(Bool(True))
    include_isochron_age = dumpable(Bool(True))
    include_kca = dumpable(Bool(True))
    include_rundate = dumpable(Bool(True))
    include_time_delta = dumpable(Bool(True))
    include_k2o = dumpable(Bool(True))
    include_isochron_ratios = dumpable(Bool(False))
    include_blanks = dumpable(Bool(True))
    include_intercepts = dumpable(Bool(True))

    use_weighted_kca = dumpable(Bool(True))
    repeat_header = dumpable(Bool(False))

    name = dumpable(Str('Untitled'))
    auto_view = dumpable(Bool(False))
    unknown_notes = dumpable(
        Str('''Errors quoted for individual analyses include analytical error only, without interfering reaction or J uncertainties.
Integrated age calculated by summing isotopic measurements of all steps.
Plateau age is inverse-variance-weighted mean of selected steps.
Plateau age error is inverse-variance-weighted mean error (Taylor, 1982) times root MSWD where MSWD>1.
Plateau error is weighted error of Taylor (1982).
Decay constants and isotopic abundances after {decay_ref:}
Ages calculated relative to FC-2 Fish Canyon Tuff sanidine interlaboratory standard at {monitor_age:} Ma'''
            ))

    unknown_title = dumpable(Str('Ar/Ar analytical data.'))
    air_notes = dumpable(Str(''''''))
    air_title = dumpable(Str(''''''))
    blank_notes = dumpable(Str(''''''))
    blank_title = dumpable(Str(''''''))
    monitor_notes = dumpable(Str(''''''))
    monitor_title = dumpable(Str(''''''))

    include_summary_sheet = dumpable(Bool(True))
    include_summary_age = dumpable(Bool(True))
    include_summary_age_type = dumpable(Bool(True))
    include_summary_material = dumpable(Bool(True))
    include_summary_sample = dumpable(Bool(True))

    include_summary_identifier = dumpable(Bool(True))
    include_summary_unit = dumpable(Bool(True))
    include_summary_location = dumpable(Bool(True))
    include_summary_irradiation = dumpable(Bool(True))
    include_summary_n = dumpable(Bool(True))
    include_summary_percent_ar39 = dumpable(Bool(True))
    include_summary_mswd = dumpable(Bool(True))
    include_summary_kca = dumpable(Bool(True))
    include_summary_comments = dumpable(Bool(True))

    _persistence_name = 'xlsx_table_options'

    @property
    def path(self):
        name = self.name
        if not name or name == 'Untitled':
            path, _ = unique_path2(paths.table_dir,
                                   'Untitled',
                                   extension='.xlsx')
        else:
            path = os.path.join(paths.table_dir,
                                add_extension(name, ext='.xlsx'))
        return path

    def traits_view(self):
        unknown_grp = VGroup(Item('unknown_title', label='Table Heading'),
                             VGroup(UItem('unknown_notes', style='custom'),
                                    show_border=True,
                                    label='Notes'),
                             label='Unknowns')

        air_grp = VGroup(Item('air_title', label='Table Heading'),
                         VGroup(UItem('air_notes', style='custom'),
                                show_border=True,
                                label='Notes'),
                         label='Airs')
        blank_grp = VGroup(Item('blank_title', label='Table Heading'),
                           VGroup(UItem('blank_notes', style='custom'),
                                  show_border=True,
                                  label='Notes'),
                           label='Blanks')
        monitor_grp = VGroup(Item('monitor_title', label='Table Heading'),
                             VGroup(UItem('monitor_notes', style='custom'),
                                    show_border=True,
                                    label='Notes'),
                             label='Monitors')

        grp = VGroup(Item('name', label='Filename'),
                     Item('auto_view', label='Open in Excel'),
                     show_border=True)

        appearence_grp = VGroup(Item('hide_gridlines', label='Hide Gridlines'),
                                Item('power_units', label='Power Units'),
                                Item('age_units', label='Age Units'),
                                Item('repeat_header', label='Repeat Header'),
                                show_border=True,
                                label='Appearance')

        arar_col_grp = VGroup(Item('include_F', label='40Ar*/39ArK'),
                              Item('include_radiogenic_yield', label='%40Ar*'),
                              Item('include_kca', label='K/Ca'),
                              Item('use_weighted_kca',
                                   label='K/Ca Weighted Mean',
                                   enabled_when='include_kca'),
                              Item('include_k2o', label='K2O wt. %'),
                              Item('include_production_ratios',
                                   label='Production Ratios'),
                              Item('include_plateau_age', label='Plateau'),
                              Item('include_integrated_age',
                                   label='Integrated'),
                              Item('include_isochron_age', label='Isochron'),
                              Item('include_isochron_ratios',
                                   label='Isochron Ratios'),
                              Item('include_time_delta',
                                   label='Time since Irradiation'),
                              label='Ar/Ar')

        general_col_grp = VGroup(Item('include_rundate',
                                      label='Analysis RunDate'),
                                 Item('include_blanks', label='Applied Blank'),
                                 Item('include_intercepts',
                                      label='Intercepts'),
                                 label='General')
        columns_grp = HGroup(general_col_grp,
                             arar_col_grp,
                             label='Columns',
                             show_border=True)
        g1 = VGroup(grp, columns_grp, appearence_grp, label='Main')

        summary_grp = VGroup(Item('include_summary_sheet',
                                  label='Summary Sheet'),
                             VGroup(Item('include_summary_sample',
                                         label='Sample'),
                                    Item('include_summary_identifier',
                                         label='Identifier'),
                                    Item('include_summary_unit', label='Unit'),
                                    Item('include_summary_location',
                                         label='Location'),
                                    Item('include_summary_material',
                                         label='Material'),
                                    Item('include_summary_irradiation',
                                         label='Irradiation'),
                                    Item('include_summary_age_type',
                                         label='Age Type'),
                                    Item('include_summary_n', label='N'),
                                    Item('include_summary_percent_ar39',
                                         label='%39Ar'),
                                    Item('include_summary_mswd', label='MSWD'),
                                    Item('include_summary_kca', label='KCA'),
                                    Item('include_summary_age', label='Age'),
                                    Item('include_summary_comments',
                                         label='Comments'),
                                    enabled_when='include_summary_sheet',
                                    label='Columns',
                                    show_border=True),
                             label='Summary')

        v = View(Tabbed(g1, unknown_grp, blank_grp, air_grp, monitor_grp,
                        summary_grp),
                 resizable=True,
                 width=750,
                 title='XLSX Analysis Table Options',
                 buttons=['OK', 'Cancel'])
        return v
Ejemplo n.º 4
0
class XLSXAnalysisTableWriterOptions(BasePersistenceOptions, JErrorMixin):
    sig_figs = dumpable(Int(6))
    j_sig_figs = dumpable(Int(6))
    ic_sig_figs = dumpable(Int(6))
    disc_sig_figs = dumpable(Int(6))

    age_sig_figs = dumpable(Int(6))
    summary_age_sig_figs = dumpable(Int(6))

    kca_sig_figs = dumpable(Int(6))
    summary_kca_sig_figs = dumpable(Int(6))

    radiogenic_yield_sig_figs = dumpable(Int(6))
    cumulative_ar39_sig_figs = dumpable(Int(6))

    signal_sig_figs = dumpable(Int(6))
    decay_sig_figs = dumpable(Int(6))
    correction_sig_figs = dumpable(Int(6))
    sens_sig_figs = dumpable(Int(2))
    k2o_sig_figs = dumpable(Int(3))

    ensure_trailing_zeros = dumpable(Bool(False))

    power_units = dumpable(Enum('W', 'C', '%'))
    intensity_units = dumpable(Enum('fA', 'cps'))
    age_units = dumpable(Enum('Ma', 'Ga', 'ka', 'a'))
    hide_gridlines = dumpable(Bool(False))
    include_F = dumpable(Bool(True))
    include_radiogenic_yield = dumpable(Bool(True))
    include_production_ratios = dumpable(Bool(True))
    include_plateau_age = dumpable(Bool(True))
    include_integrated_age = dumpable(Bool(True))
    include_isochron_age = dumpable(Bool(True))
    include_trapped_ratio = dumpable(Bool(True))

    include_kca = dumpable(Bool(True))
    include_kcl = dumpable(Bool(True))
    invert_kca_kcl = dumpable(Bool(False))
    include_rundate = dumpable(Bool(True))
    include_time_delta = dumpable(Bool(True))
    include_k2o = dumpable(Bool(True))
    include_isochron_ratios = dumpable(Bool(False))
    include_sensitivity = dumpable(Bool(True))
    sensitivity_units = dumpable(Str('mol/fA'))

    include_blanks = dumpable(Bool(True))
    include_intercepts = dumpable(Bool(True))
    include_percent_ar39 = dumpable(Bool(True))
    include_icfactors = dumpable(Bool(True))
    include_discrimination = dumpable(Bool(True))
    include_lambda_k = dumpable(Bool(True))
    include_monitor_age = dumpable(Bool(True))
    include_monitor_name = dumpable(Bool(True))
    include_monitor_material = dumpable(Bool(True))
    # use_weighted_kca = dumpable(Bool(True))
    # kca_error_kind = dumpable(Enum(*ERROR_TYPES))
    repeat_header = dumpable(Bool(False))
    highlight_non_plateau = Bool(True)
    highlight_color = dumpable(Color)

    root_name = Str
    root_names = List
    root_directory = Directory
    name = dumpable(Str('Untitled'))
    auto_view = dumpable(Bool(False))

    unknown_note_name = dumpable(Str('Default'))
    available_unknown_note_names = List

    unknown_notes = dumpable(
        Str('''Errors quoted for individual analyses include analytical error only, without interfering reaction or J uncertainties.
Integrated age calculated by summing isotopic measurements of all steps.
Plateau age is inverse-variance-weighted mean of selected steps.
Plateau age error is inverse-variance-weighted mean error (Taylor, 1982) times root MSWD where MSWD>1.
Plateau error is weighted error of Taylor (1982).
Decay constants and isotopic abundances after {decay_ref:}
Ages calculated relative to FC-2 Fish Canyon Tuff sanidine interlaboratory standard at {monitor_age:} Ma'''
            ))

    unknown_corrected_note = dumpable(
        Str('''Corrected: Isotopic intensities corrected for blank, baseline, 
    radioactivity decay and detector intercalibration, not for interfering reactions.'''
            ))
    unknown_intercept_note = dumpable(
        Str('''Intercepts: t-zero intercept corrected for detector baseline.'''
            ))
    unknown_time_note = dumpable(
        Str('''Time interval (days) between end of irradiation and beginning of analysis.'''
            ))

    unknown_x_note = dumpable(
        Str('''X symbol preceding sample ID denotes analyses 
    excluded from weighted-mean age calculations.'''))
    unknown_px_note = dumpable(
        Str('''pX symbol preceding sample ID denotes analyses
    excluded plateau age calculations.'''))

    unknown_title = dumpable(Str('Ar/Ar analytical data.'))
    air_notes = dumpable(Str(''))
    air_title = dumpable(Str(''))
    blank_notes = dumpable(Str(''))
    blank_title = dumpable(Str(''))
    monitor_notes = dumpable(Str(''))
    monitor_title = dumpable(Str(''))
    summary_notes = dumpable(Str(''))

    include_summary_sheet = dumpable(Bool(True))
    include_summary_age = dumpable(Bool(True))
    include_summary_age_type = dumpable(Bool(True))
    include_summary_material = dumpable(Bool(True))
    include_summary_sample = dumpable(Bool(True))

    include_summary_identifier = dumpable(Bool(True))
    include_summary_unit = dumpable(Bool(True))
    include_summary_location = dumpable(Bool(True))
    include_summary_irradiation = dumpable(Bool(True))
    include_summary_n = dumpable(Bool(True))
    include_summary_percent_ar39 = dumpable(Bool(True))
    include_summary_mswd = dumpable(Bool(True))
    include_summary_kca = dumpable(Bool(True))
    include_summary_comments = dumpable(Bool(True))

    summary_age_nsigma = dumpable(Enum(1, 2, 3))
    summary_kca_nsigma = dumpable(Enum(1, 2, 3))

    asummary_kca_nsigma = dumpable(Enum(1, 2, 3))
    asummary_age_nsigma = dumpable(Enum(1, 2, 3))
    asummary_trapped_ratio_nsigma = dumpable(Enum(1, 2, 3))

    plateau_nsteps = dumpable(Int(3))
    plateau_gas_fraction = dumpable(Float(50))
    fixed_step_low = dumpable(SingleStr)
    fixed_step_high = dumpable(SingleStr)

    group_age_sorting = dumpable(Enum(*AGE_SORT_KEYS))
    subgroup_age_sorting = dumpable(Enum(*AGE_SORT_KEYS))
    individual_age_sorting = dumpable(Enum(*AGE_SORT_KEYS))

    status_enabled = dumpable(Bool(True))
    tag_enabled = dumpable(Bool(True))
    analysis_label_enabled = dumpable(Bool(True))

    _persistence_name = 'xlsx_table_options'

    # include_j_error_in_individual_analyses = dumpable(Bool(False))
    # include_j_error_in_mean = dumpable(Bool(True))
    # _suppress = False

    def __init__(self, *args, **kw):
        super(XLSXAnalysisTableWriterOptions, self).__init__(*args, **kw)
        # self.load_notes()
        # self._load_note_names()

        self._load_notes()
        self._unknown_note_name_changed(self.unknown_note_name)

    def _load_notes(self):
        p = os.path.join(paths.user_pipeline_dir, 'table_notes.yaml')
        if os.path.isfile(p):
            with open(p, 'r') as rf:
                obj = yaml.load(rf)

                setattr(self, 'summary_notes', obj.get('summary_notes', ''))

                for grpname in ('unknown', ):
                    grp = obj.get('{}_notes'.format(grpname))
                    if grp:
                        try:
                            setattr(self,
                                    'available_{}_note_names'.format(grpname),
                                    list(grp.keys()))
                        except AttributeError:
                            pass

    def _unknown_note_name_changed(self, new):
        grp = self._load_note('unknown_notes')
        if grp is not None:
            sgrp = grp.get(new)
            if sgrp:
                self.unknown_notes = sgrp.get('main', '')
                for k in ('corrected', 'x', 'px', 'intercept', 'time'):
                    v = sgrp.get(k)
                    if v is not None:
                        setattr(self, 'unknown_{}_note'.format(k), v)

    def _load_note(self, group):
        p = os.path.join(paths.user_pipeline_dir, 'table_notes.yaml')
        if os.path.isfile(p):
            with open(p, 'r') as rf:
                obj = yaml.load(rf)
                return obj.get(group)

    # @property
    # def age_scalar(self):
    #     return AGE_MA_SCALARS[self.age_units]

    @property
    def path(self):
        name = self.name
        root = paths.table_dir

        if self.root_directory:
            root = self.root_directory
        elif self.root_name:
            root = os.path.join(root, self.root_name)

        if not name or name == 'Untitled':
            path, _ = unique_path2(root, 'Untitled', extension='.xlsx')
        else:
            path = os.path.join(root, add_extension(name, ext='.xlsx'))

        return path

    def traits_view(self):
        class VBorder(VGroup):
            show_border = True

        class UUItem(UCustom):
            height = -50

        unknown_grp = VGroup(
            Item('unknown_title', label='Table Heading', springy=True),
            VBorder(VBorder(UItem(
                'unknown_note_name',
                editor=EnumEditor(name='available_unknown_note_names')),
                            UItem('unknown_notes', style='custom'),
                            label='Main'),
                    VBorder(UUItem('unknown_corrected_note'),
                            label='Corrected'),
                    VBorder(UUItem('unknown_intercept_note'),
                            label='Intercept'),
                    VBorder(UUItem('unknown_time_note'), label='Time'),
                    VBorder(UUItem('unknown_x_note'), label='X'),
                    VBorder(UUItem('unknown_px_note'), label='pX'),
                    label='Notes'),
            label='Unknowns Cont.')

        def note(name):
            tag = '{}s'.format(name.capitalize())
            return VGroup(Item('{}_title'.format(name), label='Table Heading'),
                          VBorder(UItem('{}_notes'.format(name),
                                        style='custom'),
                                  label='Notes'),
                          label=tag)

        air_grp = note('air')
        blank_grp = note('blank')
        monitor_grp = note('monitor')

        grp = BorderVGroup(Item('name', label='Filename'),
                           Item('root_directory'),
                           Item('root_name',
                                editor=ComboboxEditor(name='root_names'),
                                enabled_when='not root_directory'),
                           Item('auto_view', label='Open in Excel'),
                           label='Save')

        units_grp = BorderVGroup(
            HGroup(Item('power_units', label='Power Units'),
                   Item('age_units', label='Age Units')),
            HGroup(Item('intensity_units', label='Intensity Units'),
                   Item('sensitivity_units', label='Sensitivity Units')),
            label='Units')
        sigma_grp = BorderHGroup(Item('asummary_kca_nsigma', label='K/Ca'),
                                 Item('asummary_age_nsigma', label='Age'),
                                 Item('asummary_trapped_ratio_nsigma',
                                      label='Trapped'),
                                 label='N. Sigma')
        sort_grp = BorderVGroup(HGroup(
            Item('group_age_sorting', label='Group'),
            Item('subgroup_age_sorting', label='SubGroup')),
                                Item('individual_age_sorting',
                                     label='Individual'),
                                label='Sorting')
        appearence_grp = BorderVGroup(
            HGroup(Item('hide_gridlines', label='Hide Gridlines'),
                   Item('repeat_header', label='Repeat Header')),
            units_grp,
            sigma_grp,
            sort_grp,
            HGroup(
                Item('highlight_non_plateau'),
                UItem('highlight_color',
                      enabled_when='highlight_non_plateau')),
            label='Appearance')

        def sigfig(k):
            return '{}_sig_figs'.format(k)

        def isigfig(k, label, **kw):
            return Item(sigfig(k), width=-40, label=label, **kw)

        sig_figs_grp = BorderVGroup(
            Item('sig_figs', label='Default'),
            HGroup(isigfig('age', 'Age'), isigfig('summary_age',
                                                  'Summary Age')),
            HGroup(isigfig('kca', 'K/Ca'),
                   isigfig('summary_kca', 'Summary K/Ca')),
            HGroup(isigfig('radiogenic_yield', '%40Ar*'),
                   isigfig('cumulative_ar39', 'Cum. %39Ar')),
            HGroup(isigfig('signal', 'Signal'), isigfig('j', 'Flux')),
            HGroup(isigfig('ic', 'IC'), isigfig('disc', 'Disc.')),
            HGroup(isigfig('decay', 'Decay'),
                   isigfig('correction', 'Correction Factors')),
            HGroup(isigfig('sens', 'Sensitivity'), isigfig('k2o', 'K2O')),
            Item('ensure_trailing_zeros', label='Ensure Trailing Zeros'),
            label='Significant Figures')

        def inc(k):
            return 'include_{}'.format(k)

        def iinc(k, label, **kw):
            return Item(inc(k), label=label, **kw)

        arar_col_grp = VGroup(iinc('F', '40Ar*/39ArK'),
                              iinc('percent_ar39', 'Cumulative %39Ar'),
                              iinc('radiogenic_yield', '%40Ar*'),
                              iinc('sensitivity', 'Sensitivity'),
                              iinc('k2o', 'K2O wt. %'),
                              iinc('production_ratios', 'Production Ratios'),
                              iinc('isochron_ratios', 'Isochron Ratios'),
                              iinc('time_delta', 'Time since Irradiation'),
                              iinc('kca', 'K/Ca'),
                              iinc('kcl', 'K/Cl'),
                              Item('invert_kca_kcl', label='Invert K/Ca,K/Cl'),
                              VGroup(iinc('lambda_k', 'Lambda K'),
                                     iinc('monitor_age', 'Age'),
                                     iinc('monitor_name', 'Name'),
                                     iinc('monitor_material', 'Material'),
                                     label='Flux Monitor'),
                              label='Ar/Ar')

        general_col_grp = VGroup(Item('status_enabled', label='Status'),
                                 Item('analysis_label_enabled',
                                      label='Analysis Label'),
                                 Item('tag_enabled', label='Tag'),
                                 iinc('rundate', 'Analysis RunDate'),
                                 iinc('blanks', 'Applied Blank'),
                                 iinc('intercepts', 'Intercepts'),
                                 iinc('icfactors', 'ICFactors'),
                                 iinc('discrimination', 'Discrimination'),
                                 label='General')

        summary_rows_grp = BorderVGroup(iinc('summary_kca', 'Integrated K/Ca'),
                                        iinc('plateau_age', 'Plateau Age'),
                                        iinc('integrated_age',
                                             'Total Integrated Age'),
                                        iinc('isochron_age', 'Isochron Age'),
                                        iinc('trapped_ratio',
                                             'Trapped (40/36)atm'),
                                        label='Summary Rows')
        columns_grp = BorderHGroup(general_col_grp,
                                   arar_col_grp,
                                   label='Columns')
        unk_columns_grp = VGroup(HGroup(columns_grp, sig_figs_grp),
                                 summary_rows_grp,
                                 label='Unknowns')
        g1 = VGroup(HGroup(grp, appearence_grp), label='Main')

        def isum(k):
            return inc('summary_{}'.format(k))

        def iisum(k, label, **kw):
            return Item(isum(k), label=label, **kw)

        summary_grp = VGroup(
            iisum('sheet', 'Summary Sheet'),
            VGroup(iisum('sample', 'Sample'),
                   iisum('identifier', 'Identifier'),
                   iisum('unit', 'Unit'),
                   iisum('location', 'Location'),
                   iisum('material', 'Material'),
                   iisum('irradiation', 'Irradiation'),
                   iisum('age_type', 'Age Type'),
                   iisum('n', 'N'),
                   iisum('percent_ar39', '%39Ar'),
                   iisum('mswd', 'MSWD'),
                   HGroup(iisum('kca', 'KCA'),
                          Item('summary_kca_nsigma', label=SIGMA)),
                   HGroup(iisum('age', 'Age'),
                          Item('summary_age_nsigma', label=SIGMA)),
                   iisum('comments', 'Comments'),
                   enabled_when=isum('sheet'),
                   label='Columns',
                   show_border=True),
            VGroup(UItem('summary_notes', style='custom'),
                   show_border=True,
                   label='Notes'),
            label='Summary')

        calc_grp = VGroup(J_ERROR_GROUP, label='Calc.')

        v = okcancel_view(Tabbed(g1, unk_columns_grp, unknown_grp, calc_grp,
                                 blank_grp, air_grp, monitor_grp, summary_grp),
                          resizable=True,
                          width=775,
                          height=0.75,
                          title='XLSX Analysis Table Options',
                          scrollable=True)
        return v
Ejemplo n.º 5
0
class ReportOptions(BasePDFOptions):
    _persistence_name = 'report_options'

    blank_unknowns_enabled = dumpable(Bool(True))
    airs_enabled = dumpable(Bool(True))
    cocktails_enabled = dumpable(Bool(True))
    blank_unknowns_enabled = dumpable(Bool(True))
    unknowns_enabled = dumpable(Bool(True))

    blank_unknowns_table_enabled = dumpable(Bool(True))
    airs_table_enabled = dumpable(Bool(True))
    cocktails_table_enabled = dumpable(Bool(True))
    blank_unknowns_table_enabled = dumpable(Bool(True))
    cocktail_ideogram_enabled = dumpable(Bool(True))
    unknowns_ideogram_enabled = dumpable(Bool(True))
    unknowns_table_enabled = dumpable(Bool(True))

    blank_unknowns_series_options_manager = Instance(
        BUReportSeriesOptionsManager, ())
    blank_unknowns_series_options_controller = Instance(OptionsController)

    airs_series_options_manager = Instance(AirReportSeriesOptionsManager, ())
    airs_series_options_controller = Instance(OptionsController)

    cocktails_series_options_manager = Instance(
        CocktailReportSeriesOptionsManager, ())
    cocktails_series_options_controller = Instance(OptionsController)

    cocktails_ideogram_options_manager = Instance(
        CocktailReportIdeogramOptionsManager, ())
    cocktails_ideogram_options_controller = Instance(OptionsController)

    unknowns_series_options_manager = Instance(
        UnknownsReportSeriesOptionsManager, ())
    unknowns_series_options_controller = Instance(OptionsController)

    unknowns_ideogram_options_manager = Instance(
        UnknownsReportIdeogramOptionsManager, ())
    unknowns_ideogram_options_controller = Instance(OptionsController)

    email_enabled = dumpable(Bool(True))

    def set_names(self, names):
        for a in ('blank_unknowns', 'airs', 'cocktails', 'unknowns'):
            m = getattr(self, '{}_series_options_manager'.format(a))
            m.set_names(names, clear_missing=False)

    @property
    def path(self):
        p, _ = unique_path(paths.report_dir, 'report', extension='.pdf')
        return p

    def traits_view(self):
        grps = []
        for at, name in (
            ('blank_unknowns', 'Blank Unknowns'),
            ('airs', 'Airs'),
        ):
            grp = VGroup(Item('{}_enabled'.format(at), label='Enabled'),
                         Item('{}_table_enabled'.format(at), label='Table'),
                         UItem('{}_series_options_controller'.format(at),
                               style='custom',
                               enabled_when='{}_enabled'.format(at),
                               editor=InstanceEditor(view=view(name))),
                         label=name)
            grps.append(grp)

        sog = UItem('cocktails_series_options_controller',
                    style='custom',
                    enabled_when='cocktails_enabled',
                    editor=InstanceEditor(view=view(name)),
                    label='Series')
        iog = UItem('cocktails_ideogram_options_controller',
                    style='custom',
                    enabled_when='cocktails_enabled',
                    editor=InstanceEditor(view=view(name)),
                    label='Ideogram')

        cocktail_grp = VGroup(Item('cocktails_enabled', label='Enabled'),
                              Item('cocktails_table_enabled', label='Table'),
                              Tabbed(sog, iog),
                              label='Cocktails')

        grps.append(cocktail_grp)

        sog = UItem('unknowns_series_options_controller',
                    style='custom',
                    enabled_when='unknowns_enabled',
                    editor=InstanceEditor(view=view(name)),
                    label='Series')
        iog = UItem('unknowns_ideogram_options_controller',
                    style='custom',
                    enabled_when='unknowns_enabled',
                    editor=InstanceEditor(view=view(name)),
                    label='Ideogram')

        unk_grp = VGroup(Item('unknowns_enabled', label='Enabled'),
                         Item('unknowns_table_enabled', label='Table'),
                         Tabbed(sog, iog),
                         label='Unknowns')

        grps.append(unk_grp)

        layout_grp = self._get_layout_group()
        grps.append(layout_grp)

        v = okcancel_view(Tabbed(*grps), title='Configure Report')
        return v

    def _blank_unknowns_series_options_controller_default(self):
        o = OptionsController(model=self.blank_unknowns_series_options_manager)
        return o

    def _airs_series_options_controller_default(self):
        o = OptionsController(model=self.airs_series_options_manager)
        return o

    def _cocktails_series_options_controller_default(self):
        o = OptionsController(model=self.cocktails_series_options_manager)
        return o

    def _cocktails_ideogram_options_controller_default(self):
        o = OptionsController(model=self.cocktails_ideogram_options_manager)
        return o

    def _unknowns_series_options_controller_default(self):
        o = OptionsController(model=self.unknowns_series_options_manager)
        return o

    def _unknowns_ideogram_options_controller_default(self):
        o = OptionsController(model=self.unknowns_ideogram_options_manager)
        return o