def add_analysis_inspector(scatter, items, add_selection=True, value_format=None, convert_index=None):
    from chaco.tools.broadcaster import BroadcasterTool
    from pychron.graph.tools.rect_selection_tool import RectSelectionTool
    from pychron.graph.tools.rect_selection_tool import RectSelectionOverlay
    from pychron.graph.tools.point_inspector import PointInspectorOverlay

    broadcaster = BroadcasterTool()
    scatter.tools.append(broadcaster)
    if add_selection:
        rect_tool = RectSelectionTool(scatter)
        rect_overlay = RectSelectionOverlay(component=scatter,
                                            tool=rect_tool)

        scatter.overlays.append(rect_overlay)
        broadcaster.tools.append(rect_tool)

    if value_format is None:
        value_format = lambda x: '{:0.5f}'.format(x)

    if convert_index is None:
        convert_index = lambda x: '{:0.3f}'.format(x)

    point_inspector = AnalysisPointInspector(scatter,
                                             analyses=items,
                                             convert_index=convert_index,
                                             # index_tag=index_tag,
                                             # index_attr=index_attr,
                                             value_format=value_format)
    # additional_info=additional_info)

    pinspector_overlay = PointInspectorOverlay(component=scatter,
                                               tool=point_inspector)

    scatter.overlays.append(pinspector_overlay)
    broadcaster.tools.append(point_inspector)
示例#2
0
    def add_tools(self,
                  plot,
                  scatter,
                  line=None,
                  convert_index=None,
                  add_inspector=True):

        # add a regression inspector tool to the line
        if line:
            tool = RegressionInspectorTool(component=line)
            overlay = RegressionInspectorOverlay(component=line, tool=tool)
            line.tools.append(tool)
            line.overlays.append(overlay)

        broadcaster = BroadcasterTool()
        scatter.tools.append(broadcaster)

        if add_inspector:
            point_inspector = PointInspector(scatter,
                                             convert_index=convert_index
                                             or self.convert_index_func)
            pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                       tool=point_inspector)

            scatter.overlays.append(pinspector_overlay)
            broadcaster.tools.append(point_inspector)

        rect_tool = RectSelectionTool(scatter)
        rect_overlay = RectSelectionOverlay(tool=rect_tool)

        scatter.overlays.append(rect_overlay)
        broadcaster.tools.append(rect_tool)
示例#3
0
    def _add_scatter_inspector(
            self,
            # container,
            scatter,
            add_tool=True,
            value_format=None,
            additional_info=None):
        if add_tool:
            broadcaster = BroadcasterTool()
            scatter.tools.append(broadcaster)

            rect_tool = RectSelectionTool(scatter)
            rect_overlay = RectSelectionOverlay(component=scatter,
                                                tool=rect_tool)

            scatter.overlays.append(rect_overlay)
            broadcaster.tools.append(rect_tool)

            if value_format is None:
                value_format = lambda x: '{:0.5f}'.format(x)
            point_inspector = AnalysisPointInspector(
                scatter,
                analyses=self.sorted_analyses,
                convert_index=lambda x: '{:0.3f}'.format(x),
                value_format=value_format,
                additional_info=additional_info)

            pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                       tool=point_inspector)

            scatter.overlays.append(pinspector_overlay)
            broadcaster.tools.append(point_inspector)

            u = lambda a, b, c, d: self.update_graph_metadata(a, b, c, d)
            scatter.index.on_trait_change(u, 'metadata_changed')
    def _add_inspector(self, scatter, ans):
        broadcaster = BroadcasterTool()
        scatter.tools.append(broadcaster)

        rect_tool = RectSelectionTool(scatter)
        rect_overlay = RectSelectionOverlay(component=scatter, tool=rect_tool)

        scatter.overlays.append(rect_overlay)
        broadcaster.tools.append(rect_tool)

        point_inspector = AnalysisPointInspector(
            scatter,
            value_format=floatfmt,
            analyses=ans,
            convert_index=lambda x: '{:0.3f}'.format(x))

        pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                   tool=point_inspector)

        scatter.overlays.append(pinspector_overlay)
        scatter.tools.append(point_inspector)
        broadcaster.tools.append(point_inspector)

        scatter.index.on_trait_change(self._update_metadata(ans),
                                      'metadata_changed')
示例#5
0
    def _add_scatter_inspector(self, scatter, ans, value_format=None):
        broadcaster = BroadcasterTool()
        scatter.tools.append(broadcaster)

        rect_tool = RectSelectionTool(scatter)
        rect_overlay = RectSelectionOverlay(component=scatter, tool=rect_tool)

        scatter.overlays.append(rect_overlay)
        broadcaster.tools.append(rect_tool)

        if value_format is None:
            value_format = lambda x: '{:0.5f}'.format(x)

        # value_format=self._value_info()
        additional_info = self._index_info()
        point_inspector = AnalysisPointInspector(
            scatter,
            analyses=ans,
            convert_index=lambda x: '{:0.3f}'.format(x),
            value_format=value_format,
            additional_info=additional_info)

        pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                   tool=point_inspector)

        scatter.overlays.append(pinspector_overlay)
        broadcaster.tools.append(point_inspector)
示例#6
0
    def _add_scatter_inspector(self,
                               # container,
                               scatter,
                               inspector=None,
                               add_tool=True,
                               add_selection=True,
                               value_format=None,
                               additional_info=None,
                               index_tag=None,
                               index_attr=None,
                               convert_index=None,
                               items=None,
                               update_meta_func=None):
        if add_tool:
            broadcaster = BroadcasterTool()
            scatter.tools.append(broadcaster)
            if add_selection:
                rect_tool = RectSelectionTool(scatter)
                rect_overlay = RectSelectionOverlay(component=scatter,
                                                    tool=rect_tool)

                scatter.overlays.append(rect_overlay)
                broadcaster.tools.append(rect_tool)

            if inspector is None:
                if value_format is None:
                    value_format = lambda x: '{:0.5f}'.format(x)

                if convert_index is None:
                    convert_index = lambda x: '{:0.3f}'.format(x)
                if items is None:
                    items = self.sorted_analyses
                inspector = AnalysisPointInspector(scatter,
                                                   use_pane=True,
                                                   analyses=items,
                                                   convert_index=convert_index,
                                                   index_tag=index_tag,
                                                   index_attr=index_attr,
                                                   value_format=value_format,
                                                   additional_info=additional_info)

            if not isinstance(inspector, (list, tuple)):
                inspector = (inspector,)

            # pinspector_overlay = PointInspectorOverlay(component=scatter,
            #                                            tool=point_inspector)
            # print 'fff', inspector

            event_queue = {}
            for i in inspector:
                i.event_queue = event_queue
                i.on_trait_change(self._handle_inspection, 'inspector_item')
                # scatter.overlays.append(pinspector_overlay)
                broadcaster.tools.append(i)

            if update_meta_func is None:
                update_meta_func = self.update_graph_metadata
            # u = lambda a, b, c, d: self.update_graph_metadata(a, b, c, d)
            scatter.index.on_trait_change(update_meta_func, 'metadata_changed')
示例#7
0
    def setup(self, x, y, ans):
        from pychron.pipeline.plot.plotter.ticks import tick_formatter, StaticTickGenerator, TICKS

        p = self.new_plot()
        p.padding_left = 60
        p.y_axis.tick_label_formatter = tick_formatter
        p.y_axis.tick_generator = StaticTickGenerator()
        p.y_axis.title = 'Analysis Type'

        # p.y_grid.line_style='solid'
        # p.y_grid.line_color='green'
        # p.y_grid.line_weight = 1.5

        self.set_y_limits(min_=-1, max_=len(TICKS))

        p.index_range.tight_bounds = False
        p.x_axis.tick_generator = ScalesTickGenerator(
            scale=CalendarScaleSystem())
        p.x_grid.tick_generator = p.x_axis.tick_generator
        p.x_axis.title = 'Time'

        scatter, _ = self.new_series(x,
                                     y,
                                     type='scatter',
                                     marker_size=1.5,
                                     selection_color='red',
                                     selection_marker='circle',
                                     selection_marker_size=2.5)

        broadcaster = BroadcasterTool()
        scatter.tools.append(broadcaster)

        point_inspector = AnalysisPointInspector(
            scatter,
            analyses=ans,
            value_format=get_analysis_type,
            additional_info=lambda i, x, y, ai:
            ('Time={}'.format(ai.rundate), 'Project={}'.format(ai.project)))

        pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                   tool=point_inspector)

        rect_tool = RectSelectionTool(scatter)
        rect_overlay = RectSelectionOverlay(component=scatter, tool=rect_tool)

        broadcaster.tools.append(rect_tool)
        broadcaster.tools.append(point_inspector)

        # range_selector = RangeSelection(scatter, left_button_selects=True)
        # broadcaster.tools.append(range_selector)

        # scatter.overlays.append(RangeSelectionOverlay(component=scatter))
        scatter.overlays.append(pinspector_overlay)
        scatter.overlays.append(rect_overlay)

        self.scatter = scatter
示例#8
0
    def setup(self, x, y, ans, atypes, mapping):
        from pychron.pipeline.plot.plotter.ticks import StaticTickGenerator

        def get_analysis_type(x):
            x = int(math.floor(x))
            return next((k for k, v in mapping.items() if v == x))

        p = self.new_plot()
        p.padding_left = 200

        def tickformatter(x):
            return atypes[int(x)]

        p.y_axis.tick_label_rotate_angle = 60
        p.y_axis.tick_label_formatter = tickformatter
        p.y_axis.tick_generator = StaticTickGenerator(_nticks=len(atypes))
        p.y_axis.title = 'Analysis Type'
        p.y_axis.title_font = 'modern 18'
        p.y_axis.tick_label_font = 'modern 14'

        self.add_axis_tool(p, p.x_axis)
        self.add_axis_tool(p, p.y_axis)
        self.add_limit_tool(p, 'x')
        self.add_limit_tool(p, 'y')

        self.set_y_limits(min_=-1, max_=len(atypes))

        p.index_range.tight_bounds = False
        p.x_axis.tick_generator = ScalesTickGenerator(
            scale=CalendarScaleSystem())
        p.x_grid.tick_generator = p.x_axis.tick_generator
        p.x_axis.title = 'Time'
        p.x_axis.title_font = 'modern 18'
        p.x_axis.tick_label_font = 'modern 14'

        t = GroupingTool(component=p)
        p.tools.append(t)
        o = GroupingOverlay(component=p, tool=t)
        p.overlays.append(o)

        self.grouping_tool = t

        scatter, _ = self.new_series(x,
                                     y,
                                     type='scatter',
                                     marker_size=1.5,
                                     selection_color='red',
                                     selection_marker='circle',
                                     selection_marker_size=2.5)

        broadcaster = BroadcasterTool()
        scatter.tools.append(broadcaster)

        point_inspector = AnalysisPointInspector(
            scatter,
            analyses=ans,
            value_format=get_analysis_type,
            additional_info=lambda i, x, y, ai:
            ('Time={}'.format(ai.rundate), 'Project={}'.format(ai.project)))

        pinspector_overlay = PointInspectorOverlay(component=scatter,
                                                   tool=point_inspector)

        rect_tool = RectSelectionTool(scatter)
        rect_overlay = RectSelectionOverlay(component=scatter, tool=rect_tool)

        broadcaster.tools.append(rect_tool)
        broadcaster.tools.append(point_inspector)

        scatter.overlays.append(pinspector_overlay)
        scatter.overlays.append(rect_overlay)

        self.scatter = scatter