Exemplo 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')
                logger.info('... aid=%r' % aid)
                if event.button == 3:  # right-click
                    from wbia import guitool
                    from wbia.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()
Exemplo n.º 2
0
    def _on_image_click(event):
        print('[inter] clicked image')
        if ih.clicked_outside_axis(event):
            # Toggle draw lbls
            kwargs['draw_lbls'] = not kwargs.get('draw_lbls', True)
            _image_view(**kwargs)
        else:
            ax = event.inaxes
            viztype = vh.get_ibsdat(ax, 'viztype')
            annotation_centers = vh.get_ibsdat(ax,
                                               'annotation_centers',
                                               default=[])
            print(' annotation_centers=%r' % annotation_centers)
            print(' viztype=%r' % viztype)
            if len(annotation_centers) == 0:
                print(' ...no chips exist to click')
                return
            x, y = event.xdata, event.ydata
            # Find ANNOTATION center nearest to the clicked point
            aid_list = vh.get_ibsdat(ax, 'aid_list', default=[])
            import vtool as vt

            centx, _dist = vt.nearest_point(x, y, annotation_centers)
            aid = aid_list[centx]
            print(' ...clicked aid=%r' % aid)
            if select_callback is not None:
                # HACK, should just implement this correctly here
                select_callback(gid, sel_aids=[aid], fnum=self.fnum)
            else:
                _image_view(sel_aids=[aid])

        viz.draw()
Exemplo n.º 3
0
    def figure_clicked(self, event=None):
        ax = event.inaxes
        if ih.clicked_inside_axis(event):
            viztype = vh.get_ibsdat(ax, 'viztype')
            if viztype == 'chip':
                aid = vh.get_ibsdat(ax, 'aid')
                # logger.info('... aid=%r' % aid)
                if event.button == 3:  # right-click
                    # import wbia.guitool
                    # height = self.fig.canvas.geometry().height()
                    # qpoint = guitool.newQPoint(event.x, height - event.y)
                    # ibs = self.ibs
                    # is_exemplar = ibs.get_annot_exemplar_flags(aid)
                    # def context_func():
                    #    ibs.set_annot_exemplar_flags(aid, not is_exemplar)
                    #    self.show_page()
                    # guitool.popup_menu(self.fig.canvas, pt, [
                    #    ('unset as exemplar' if is_exemplar else 'set as exemplar', context_func),
                    # ])
                    # TODO USE ABSTRACT INTERACTION
                    from wbia.viz.interact import interact_chip

                    options = interact_chip.build_annot_context_options(
                        self.ibs, aid, refresh_func=self.show_page)
                    self.show_popup_menu(options, event)
                    # interact_chip.show_annot_context_menu(
                    #    self.ibs, aid, self.fig.canvas, qpoint, refresh_func=self.show_page)
                    # ibs.print_annotation_table()
                # logger.info(ut.repr2(event.__dict__))
            elif viztype == 'matches':
                self.cm.ishow_single_annotmatch(self.qreq_,
                                                self.aid2,
                                                fnum=None,
                                                mode=0)
Exemplo n.º 4
0
    def figure_clicked(self, event=None):
        from wbia.viz import viz_helpers as vh
        import wbia.guitool as gt

        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
                    from wbia.viz.interact import interact_chip

                    height = self.fig.canvas.geometry().height()
                    qpoint = gt.newQPoint(event.x, height - event.y)
                    if self.qreq_ is None:
                        config2_ = None
                    else:
                        if aid in self.qreq_.qaids:
                            config2_ = self.qreq_.query_config2_
                        else:
                            config2_ = self.qreq_.data_config2_
                    callback_list = interact_chip.build_annot_context_options(
                        self.ibs, aid, refresh_func=self.show_page, config2_=config2_
                    )
                    gt.popup_menu(self.fig.canvas, qpoint, callback_list)
                    # interact_chip.show_annot_context_menu(
                    #    self.ibs, aid, self.fig.canvas, qpoint, refresh_func=self.show_page)
                    # self.show_page()
                    # ibs.print_annotation_table()
                print(ut.repr2(event.__dict__))
Exemplo n.º 5
0
    def _on_chip_click(event):
        logger.info('[inter] clicked chip')
        ax, x, y = event.inaxes, event.xdata, event.ydata
        if ih.clicked_outside_axis(event):
            if not ischild:
                logger.info('... out of axis')
                mode_ptr[0] = (mode_ptr[0] + 1) % 3
                _chip_view(**kwargs)
        else:
            if event.button == 3:  # right-click
                import wbia.guitool as gt

                # from wbia.viz.interact import interact_chip
                height = fig.canvas.geometry().height()
                qpoint = gt.newQPoint(event.x, height - event.y)
                refresh_func = partial(_chip_view, **kwargs)

                callback_list = build_annot_context_options(
                    ibs,
                    aid,
                    refresh_func=refresh_func,
                    with_interact_chip=False,
                    config2_=config2_,
                )
                qwin = fig.canvas
                gt.popup_menu(qwin, qpoint, callback_list)
                # interact_chip.show_annot_context_menu(
                #    ibs, aid, fig.canvas, qpoint, refresh_func=refresh_func,
                #    with_interact_chip=False, config2_=config2_)
            else:
                viztype = vh.get_ibsdat(ax, 'viztype')
                logger.info('[ic] viztype=%r' % viztype)
                if viztype == 'chip' and event.key == 'shift':
                    _chip_view(**kwargs)
                    ih.disconnect_callback(fig, 'button_press_event')
                elif viztype == 'chip':
                    kpts = ibs.get_annot_kpts(aid, config2_=config2_)
                    if len(kpts) > 0:
                        fx = vt.nearest_point(x, y, kpts,
                                              conflict_mode='next')[0]
                        logger.info('... clicked fx=%r' % fx)
                        _select_fxth_kpt(fx)
                    else:
                        logger.info('... len(kpts) == 0')
                elif viztype in ['warped', 'unwarped']:
                    fx = vh.get_ibsdat(ax, 'fx')
                    if fx is not None and viztype == 'warped':
                        viz.show_keypoint_gradient_orientations(
                            ibs, aid, fx, fnum=pt.next_fnum())
                else:
                    logger.info('...Unknown viztype: %r' % viztype)

        viz.draw()
Exemplo n.º 6
0
    def on_click_inside(self, event, ax):
        from wbia.plottool import plot_helpers as ph

        ibs = self.ibs
        viztype = ph.get_plotdat(ax, 'viztype', '')
        is_match_type = viztype in ['matches', 'multi_match']

        key = '' if event.key is None else event.key
        logger.info('key=%r ' % key)
        ctrl_down = key.find('control') == 0
        # Click in match axes
        if event.button == 3:
            return super(MatchInteraction, self).on_click_inside(event, ax)
        if is_match_type and ctrl_down:
            # Ctrl-Click
            logger.info('.. control click')
            return self.sv_view()
        elif viztype in ['warped', 'unwarped']:
            logger.info('clicked at patch')
            ut.print_dict(ph.get_plotdat_dict(ax))
            hs_aid = {
                'aid1': self.qaid,
                'aid2': self.daid
            }[vh.get_ibsdat(ax, 'aid', None)]
            hs_fx = vh.get_ibsdat(ax, 'fx', None)
            logger.info('hs_fx = %r' % (hs_fx, ))
            logger.info('hs_aid = %r' % (hs_aid, ))
            if hs_aid is not None and viztype == 'unwarped':
                ishow_chip(ibs, hs_aid, fx=hs_fx, fnum=pt.next_fnum())
            elif hs_aid is not None and viztype == 'warped':
                viz.show_keypoint_gradient_orientations(ibs,
                                                        hs_aid,
                                                        hs_fx,
                                                        fnum=pt.next_fnum())
        else:
            return super(MatchInteraction, self).on_click_inside(event, ax)
        self.draw()
Exemplo n.º 7
0
 def _on_sv_click(event):
     ax = event.inaxes
     if ih.clicked_outside_axis(event):
         logger.info('... out of axis')
         mode_ptr[0] = (mode_ptr[0] + 1) % 3
         kwargs['show_kpts'] = mode_ptr[0] == 2
         kwargs['show_lines'] = mode_ptr[0] >= 1
         _sv_view(**kwargs)
     else:
         viztype = vh.get_ibsdat(ax, 'viztype')
         if viztype in ['homogblend', 'affblend', 'source', 'dest']:
             pass
         else:
             logger.info('...Unknown viztype: %r' % viztype)
     viz.draw()