Ejemplo n.º 1
0
 def _on_name_click(event):
     ax = event.inaxes
     if ih.clicked_inside_axis(event):
         viztype = vh.get_ibsdat(ax, 'viztype')
         if viztype == 'chip':
             aid = vh.get_ibsdat(ax, 'aid')
             print('... aid=%r' % aid)
             if event.button == 3:  # right-click
                 import guitool
                 from ibeis.viz.interact import interact_chip
                 height = fig.canvas.geometry().height()
                 qpoint = guitool.newQPoint(event.x, height - event.y)
                 refresh_func = functools.partial(viz.show_name,
                                                  ibs,
                                                  nid,
                                                  fnum=fnum,
                                                  sel_aids=sel_aids)
                 interact_chip.show_annot_context_menu(
                     ibs,
                     aid,
                     fig.canvas,
                     qpoint,
                     refresh_func=refresh_func,
                     with_interact_name=False)
             else:
                 viz.show_name(ibs,
                               nid,
                               fnum=fnum,
                               sel_aids=[aid],
                               in_image=True)
                 if select_aid_callback is not None:
                     select_aid_callback(aid)
     viz.draw()
Ejemplo n.º 2
0
 def _on_name_click(event):
     print_('[inter] clicked name')
     ax = event.inaxes
     if ih.clicked_inside_axis(event):
         viztype = vh.get_ibsdat(ax, 'viztype')
         print_(' viztype=%r' % viztype)
         if viztype == 'chip':
             aid = vh.get_ibsdat(ax, 'aid')
             print('... aid=%r' % aid)
             if event.button == 3:   # right-click
                 import guitool
                 from ibeis.viz.interact import interact_chip
                 height = fig.canvas.geometry().height()
                 qpoint = guitool.newQPoint(event.x, height - event.y)
                 refresh_func = functools.partial(viz.show_name, ibs, nid, fnum=fnum, sel_aids=sel_aids)
                 interact_chip.show_annot_context_menu(
                     ibs, aid, fig.canvas, qpoint, refresh_func=refresh_func,
                     with_interact_name=False)
             else:
                 viz.show_name(ibs, nid, fnum=fnum, sel_aids=[aid], in_image=True)
                 if select_aid_callback is not None:
                     select_aid_callback(aid)
     viz.draw()
Ejemplo n.º 3
0
def ishow_name(ibs, nid, sel_aids=[], select_aid_callback=None, fnum=5, dodraw=True, **kwargs):
    r"""
    Args:
        ibs (IBEISController):  ibeis controller object
        nid (?):
        sel_aids (list):
        select_aid_callback (None):
        fnum (int):  figure number

    CommandLine:
        python -m ibeis.viz.interact.interact_name --test-ishow_name --show

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.viz.interact.interact_name import *  # NOQA
        >>> import ibeis
        >>> # build test data
        >>> ibs = ibeis.opendb('testdb1')
        >>> nid = ut.get_argval('--nid', int, default=1)
        >>> sel_aids = []
        >>> select_aid_callback = None
        >>> fnum = 5
        >>> dodraw = ut.show_was_requested()
        >>> # execute function
        >>> result = ishow_name(ibs, nid, sel_aids, select_aid_callback, fnum, dodraw)
        >>> # verify results
        >>> pt.show_if_requested()
        >>> print(result)
    """
    if fnum is None:
        fnum = pt.next_fnum()
    fig = ih.begin_interaction('name', fnum)

    def _on_name_click(event):
        print_('[inter] clicked name')
        ax = event.inaxes
        if ih.clicked_inside_axis(event):
            viztype = vh.get_ibsdat(ax, 'viztype')
            print_(' viztype=%r' % viztype)
            if viztype == 'chip':
                aid = vh.get_ibsdat(ax, 'aid')
                print('... aid=%r' % aid)
                if event.button == 3:   # right-click
                    import guitool
                    from ibeis.viz.interact import interact_chip
                    height = fig.canvas.geometry().height()
                    qpoint = guitool.newQPoint(event.x, height - event.y)
                    refresh_func = functools.partial(viz.show_name, ibs, nid, fnum=fnum, sel_aids=sel_aids)
                    interact_chip.show_annot_context_menu(
                        ibs, aid, fig.canvas, qpoint, refresh_func=refresh_func,
                        with_interact_name=False)
                else:
                    viz.show_name(ibs, nid, fnum=fnum, sel_aids=[aid], in_image=True)
                    if select_aid_callback is not None:
                        select_aid_callback(aid)
        viz.draw()

    viz.show_name(ibs, nid, fnum=fnum, sel_aids=sel_aids, in_image=True)
    if dodraw:
        viz.draw()
    ih.connect_callback(fig, 'button_press_event', _on_name_click)
    pass
Ejemplo n.º 4
0
def ishow_name(ibs,
               nid,
               sel_aids=[],
               select_aid_callback=None,
               fnum=5,
               dodraw=True,
               **kwargs):
    r"""
    Args:
        ibs (IBEISController):  ibeis controller object
        nid (?):
        sel_aids (list):
        select_aid_callback (None):
        fnum (int):  figure number

    CommandLine:
        python -m ibeis.viz.interact.interact_name --test-ishow_name --show

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.viz.interact.interact_name import *  # NOQA
        >>> import ibeis
        >>> # build test data
        >>> ibs = ibeis.opendb('testdb1')
        >>> nid = ut.get_argval('--nid', int, default=1)
        >>> sel_aids = []
        >>> select_aid_callback = None
        >>> fnum = 5
        >>> dodraw = ut.show_was_requested()
        >>> # execute function
        >>> result = ishow_name(ibs, nid, sel_aids, select_aid_callback, fnum, dodraw)
        >>> # verify results
        >>> pt.show_if_requested()
        >>> print(result)
    """
    if fnum is None:
        fnum = pt.next_fnum()
    fig = ih.begin_interaction('name', fnum)

    def _on_name_click(event):
        ax = event.inaxes
        if ih.clicked_inside_axis(event):
            viztype = vh.get_ibsdat(ax, 'viztype')
            if viztype == 'chip':
                aid = vh.get_ibsdat(ax, 'aid')
                print('... aid=%r' % aid)
                if event.button == 3:  # right-click
                    import guitool
                    from ibeis.viz.interact import interact_chip
                    height = fig.canvas.geometry().height()
                    qpoint = guitool.newQPoint(event.x, height - event.y)
                    refresh_func = functools.partial(viz.show_name,
                                                     ibs,
                                                     nid,
                                                     fnum=fnum,
                                                     sel_aids=sel_aids)
                    interact_chip.show_annot_context_menu(
                        ibs,
                        aid,
                        fig.canvas,
                        qpoint,
                        refresh_func=refresh_func,
                        with_interact_name=False)
                else:
                    viz.show_name(ibs,
                                  nid,
                                  fnum=fnum,
                                  sel_aids=[aid],
                                  in_image=True)
                    if select_aid_callback is not None:
                        select_aid_callback(aid)
        viz.draw()

    viz.show_name(ibs, nid, fnum=fnum, sel_aids=sel_aids, in_image=True)
    if dodraw:
        viz.draw()
    ih.connect_callback(fig, 'button_press_event', _on_name_click)
    pass