Exemplo n.º 1
0
 def on_contextMenuRequested(qres_wgt, qtindex, qpoint):
     """
     popup context menu
     """
     # selected_qtindex_list = qres_wgt.view.selectedIndexes()
     selected_qtindex_list = qres_wgt.selectedRows()
     if len(selected_qtindex_list) == 1:
         qwin = qres_wgt
         aid1, aid2 = qres_wgt.get_aidpair_from_qtindex(qtindex)
         tup = qres_wgt.get_widget_review_vars(aid1)
         ibs, cm, qreq_, update_callback, backend_callback = tup
         options = get_aidpair_context_menu_options(
             ibs,
             aid1,
             aid2,
             cm,
             qreq_=qreq_,
             logger=qres_wgt.logger,
             update_callback=update_callback,
             backend_callback=backend_callback,
         )
         gt.popup_menu(qwin, qpoint, options)
     else:
         logger.info('[context] Multiple %d selection' %
                     (len(selected_qtindex_list), ))
Exemplo n.º 2
0
def show_annot_context_menu(
    ibs,
    aid,
    qwin,
    qpoint,
    refresh_func=None,
    with_interact_name=True,
    with_interact_chip=True,
    with_interact_image=True,
    config2_=None,
):
    """
    Defines logic for poping up a context menu when viewing an annotation.
    Used in other interactions like name_interaction and interact_query_decision

    CommandLine:
        python -m wbia.viz.interact.interact_chip --test-ishow_chip --show

    """
    import wbia.guitool as gt

    callback_list = build_annot_context_options(
        ibs,
        aid,
        refresh_func=refresh_func,
        with_interact_name=with_interact_name,
        with_interact_chip=with_interact_chip,
        with_interact_image=with_interact_image,
        config2_=config2_,
    )
    gt.popup_menu(qwin, qpoint, callback_list)
Exemplo n.º 3
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__))
    def show_popup_menu(self, options, event):
        """
        context menu
        """
        import wbia.guitool as gt

        height = self.fig.canvas.geometry().height()
        qpoint = gt.newQPoint(event.x, height - event.y)
        qwin = self.fig.canvas
        gt.popup_menu(qwin, qpoint, options)
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()