コード例 #1
0
    def _create_control(self, parent):
        """ Creates the view and then toolkit-specific control for the widget.
        """
        self.obj_view = ChromatogramModelView(chromatogram_model=self.obj)

        # Setting the kind and the parent allows for the ui to be embedded
        # within the parent UI
        self.traits_ui = self.obj_view.edit_traits(kind="subpanel",
                                                   parent=parent)

        # Grab the Qt widget to return to the editor area
        control = self.traits_ui.control
        return control
 def test_all_uv_on_open(self):
     view = ChromatogramModelView(chromatogram_model=self.chrom_model,
                                  open_uv_on_open=True)
     with temp_bringup_ui_for(view):
         self.assertEqual(view.displayed_log_family_names, [LOG_FAMILY_UV])
         self.assertEqual(view.displayed_log_collection_names,
                          [self.exp_name])
コード例 #3
0
class ChromatogramPlotEditor(PlotEditor):
    """ Editor for viewing and modifying a ChromatogramModel object using the
    TraitsUI view it provides. It invokes the view factories it knows to create
    the control it needs to display.

    This could have been done using pyface.tasks.traits_editor.TraitsEditor.
    Using this custom one because the create method in our case will invoke
    edit_traits on the obj being edited.
    """

    # The object that the editor is editing.
    obj = Instance(ChromatogramModel)

    #: The obj adapter to build a ModelView
    obj_view = Any

    # -------------------------------------------------------------------------
    # Private interface.
    # -------------------------------------------------------------------------

    def _create_control(self, parent):
        """ Creates the view and then toolkit-specific control for the widget.
        """
        self.obj_view = ChromatogramModelView(chromatogram_model=self.obj)

        # Setting the kind and the parent allows for the ui to be embedded
        # within the parent UI
        self.traits_ui = self.obj_view.edit_traits(kind="subpanel",
                                                   parent=parent)

        # Grab the Qt widget to return to the editor area
        control = self.traits_ui.control
        return control
 def test_connected_collections_have_same_color(self):
     # Model with 1 exp and 1 sim from it
     chrom_model = make_sample_chrom_model(exp_name=self.exp_name,
                                           include_sim=True)
     view = ChromatogramModelView(chromatogram_model=chrom_model,
                                  open_uv_on_open=True)
     with temp_bringup_ui_for(view):
         self.assertEqual(view.displayed_log_family_names, [LOG_FAMILY_UV])
         self.assertEqual(view.displayed_log_collection_names,
                          [self.exp_name, "Sim: " + self.exp_name])
class TestChromatogramPlotViewChangeColor(TestCase):
    def setUp(self):
        self.exp_name = 'Run_1'
        self.chrom_model = make_sample_chrom_model(exp_name=self.exp_name)
        self.view = ChromatogramModelView(chromatogram_model=self.chrom_model)

    def test_change_plot_color_exp_plot(self):
        collection = self.chrom_model.log_collections['Run_1']

        # in initial state, color is blue:
        for log in collection.logs.values():
            props = log.renderer_properties
            self.assertEqual(props["color"], "blue")

        new_color = "red"
        self.view.apply_new_colors({'Run_1': new_color})
        # Setting the color changes the chrom model...
        for log in collection.logs.values():
            props = log.renderer_properties
            self.assertEqual(props["color"], new_color)

        # ... as well as all renderers for the experiment
        plot = self.view._chromatogram_plot
        for plot in plot.plot_contexts.values():
            for fam, renderer_list in plot.plots.items():
                for renderer in renderer_list:
                    self.assertEqual(renderer.color, new_color)

    def test_change_plot_colors_wrong_plot(self):
        with self.assertRaises(KeyError):
            self.view.apply_new_colors({"FOO": "red"})

    def test_change_plot_colors_wrong_color(self):
        with self.assertRaises(TraitError):
            self.view.apply_new_colors({"Run_1": "goobar"})
 def setUp(self):
     self.exp_name = 'Run_1'
     self.chrom_model = make_sample_chrom_model(exp_name=self.exp_name)
     self.view = ChromatogramModelView(chromatogram_model=self.chrom_model)
 def test_no_uv_on_open(self):
     view = ChromatogramModelView(chromatogram_model=self.chrom_model,
                                  open_uv_on_open=False)
     with temp_bringup_ui_for(view):
         self.assertEqual(view.displayed_log_family_names, [])
         self.assertEqual(view.displayed_log_collection_names, [])
 def test_open_close(self):
     view = ChromatogramModelView(chromatogram_model=self.chrom_model)
     with temp_bringup_ui_for(view):
         pass