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)
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 on_click_inside(self, event, ax): ax = event.inaxes viztype = ph.get_plotdat(ax, 'viztype', '') # if verbose: # logger.info(str(event.__dict__)) logger.info('viztype=%r' % viztype) # Clicked a specific matches logger.info('plodat_dict = ' + ut.repr2(ph.get_plotdat_dict(ax))) if viztype.startswith('chip'): from wbia.viz.interact import interact_chip options = interact_chip.build_annot_context_options( self.ibs, self.cm.qaid, refresh_func=self._analysis_view, with_interact_chip=False, ) self.show_popup_menu(options, event) if viztype.startswith( 'matches') or viztype == 'multi_match': # why startswith? aid2 = ph.get_plotdat(ax, 'aid2', None) aid_list = ph.get_plotdat(ax, 'aid_list', None) if event.button == 3: # right-click # TODO; this functionality should be in viz.interact from wbia.gui import inspect_gui logger.info('right click') logger.info('qreq_ = %r' % (self.qreq_, )) options = inspect_gui.get_aidpair_context_menu_options( self.ibs, self.cm.qaid, aid2, self.cm, qreq_=self.qreq_, update_callback=self.show_page, backend_callback=None, aid_list=aid_list, ) self.show_popup_menu(options, event) else: # Ctrl-Click key = '' if event.key is None else event.key logger.info('key = %r' % key) if key.find('control') == 0: logger.info('[viz] result control clicked') self.show_sver_process_to_aid(aid2) # Left-Click else: logger.info('[viz] result clicked') self.show_matches_to_aid(aid2) self.draw()
def make_annotpair_context_options(ibs, aid1, aid2, qreq_): from wbia.viz.interact import interact_chip aid_list2 = [aid1, aid2] if qreq_ is None: config2_list_ = [None, None] else: config2_list_ = [qreq_.extern_query_config2, qreq_.extern_data_config2] chip_contex_options = [] logger.info('config2_list_ = %r' % (config2_list_, )) logger.info('aid_list2 = %r' % (aid_list2, )) for count, (aid, config2_) in enumerate(zip(aid_list2, config2_list_), start=1): chip_contex_options += [( 'Annot&%d Options (aid=%r)' % ( count, aid, ), interact_chip.build_annot_context_options(ibs, aid, refresh_func=None, config2_=config2_), )] # interact_chip_options = [] # for count, (aid, config2_) in enumerate(zip(aid_list2, # config2_list_), # start=1): # interact_chip_options += [ # ('Interact Annot&%d' % (count,), # partial(interact_chip.ishow_chip, ibs, aid, config2_=config2_, # fnum=None, **kwargs)), # ] # interact_chip_actions = ut.get_list_column(interact_chip_options, 1) # interact_chip_options.append( # ('Interact &All Annots', lambda: [func() for func in # interact_chip_actions]), # ) # options += [ # #('Interact Annots', interact_chip_options), # #('Annot Conte&xt Options', chip_contex_options), # ] # if len(chip_contex_options) > 2: # return [ # ('Annot Conte&xt Options', chip_contex_options), # ] # else: return chip_contex_options
def on_click_inside(self, event, ax): self.ax = ax self.event = event event = self.event # logger.info(ax) # logger.info(event.x) # logger.info(event.y) pos = self.plotinfo['node']['pos'] nodes = list(pos.keys()) pos_list = ut.dict_take(pos, nodes) # TODO: FIXME # x = 10 # y = 10 import numpy as np # NOQA x, y = event.xdata, event.ydata point = np.array([x, y]) pos_list = np.array(pos_list) index, dist = vt.closest_point(point, pos_list, distfunc=vt.L2) # logger.info('dist = %r' % (dist,)) node = nodes[index] aid = self.node2_aid[node] context_shown = False CHECK_PAIR = True if CHECK_PAIR: if self.event.button == 3 and not context_shown: if len(self.selected_aids) != 2: logger.info( 'This funciton only work if exactly 2 are selected') else: from wbia.gui import inspect_gui context_shown = True aid1, aid2 = self.selected_aids qres = None qreq_ = None options = inspect_gui.get_aidpair_context_menu_options( self.infr.ibs, aid1, aid2, qres, qreq_=qreq_) self.show_popup_menu(options, event) bbox = vt.bbox_from_center_wh(self.plotinfo['node']['pos'][node], self.plotinfo['node']['size'][node]) SELECT_ANNOT = vt.point_inside_bbox(point, bbox) # SELECT_ANNOT = dist < 35 if SELECT_ANNOT: # logger.info(ut.obj_str(ibs.get_annot_info(aid, default=True, # name=False, gname=False))) if self.event.button == 1: self.toggle_selected_aid(aid) if self.event.button == 3 and not context_shown: # right click from wbia.viz.interact import interact_chip context_shown = True # refresh_func = functools.partial(viz.show_name, ibs, nid, # fnum=fnum, sel_aids=sel_aids) refresh_func = None config2_ = None options = interact_chip.build_annot_context_options( self.infr.ibs, aid, refresh_func=refresh_func, with_interact_name=False, config2_=config2_, ) self.show_popup_menu(options, event) else: if self.event.button == 3: options = [ ('Toggle images', self.toggle_imgs), ] self.show_popup_menu(options, event)