def figure_clicked(self, event=None): #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 #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 ibeis.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() #print(ut.dict_str(event.__dict__)) elif viztype == 'matches': self.cm.ishow_single_annotmatch(self.qreq_, self.aid2, fnum=None, mode=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') #print('... aid=%r' % aid) if event.button == 3: # right-click #import 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 ibeis.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() #print(ut.repr2(event.__dict__)) elif viztype == 'matches': self.cm.ishow_single_annotmatch(self.qreq_, self.aid2, fnum=None, mode=0)
def on_click_inside(self, event, ax): self.ax = ax self.event = event event = self.event #print(ax) #print(event.x) #print(event.y) aids = list(self.pos.keys()) pos_list = ut.dict_take(self.pos, aids) #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) print('dist = %r' % (dist,)) aid = aids[index] context_shown = False CHECK_PAIR = True if CHECK_PAIR: if self.event.button == 3 and not context_shown: if len(self.selected_aids) != 2: print('This funciton only work if exactly 2 are selected') else: from ibeis.gui import inspect_gui context_shown = True aid1, aid2 = (self.selected_aids) qres = None qreq_ = None options = inspect_gui.get_aidpair_context_menu_options(ibs, aid1, aid2, qres, qreq_=qreq_) self.show_popup_menu(options, event) SELECT_ANNOT = dist < 35 if SELECT_ANNOT: print(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 ibeis.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( 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_images), ] self.show_popup_menu(options, event)
def figure_clicked(self, event=None): from ibeis.viz import viz_helpers as vh 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 ibeis.viz.interact import interact_chip import guitool height = self.fig.canvas.geometry().height() qpoint = guitool.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_) guitool.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.dict_str(event.__dict__))
def make_annotpair_context_options(ibs, aid1, aid2, qreq_): from ibeis.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 = [] print('config2_list_ = %r' % (config2_list_, )) print('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): ax = event.inaxes viztype = ph.get_plotdat(ax, 'viztype', '') #if verbose: # print(str(event.__dict__)) print('viztype=%r' % viztype) # Clicked a specific matches print('plodat_dict = ' + ut.repr2(ph.get_plotdat_dict(ax))) if viztype.startswith('chip'): from ibeis.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 ibeis.gui import inspect_gui print('right click') print('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 print('key = %r' % key) if key.find('control') == 0: print('[viz] result control clicked') self.show_sver_process_to_aid(aid2) # Left-Click else: print('[viz] result clicked') self.show_matches_to_aid(aid2) self.draw()
def on_click_inside(self, event, ax): ax = event.inaxes viztype = ph.get_plotdat(ax, 'viztype', '') #if verbose: # print(str(event.__dict__)) print('viztype=%r' % viztype) # Clicked a specific matches print('plodat_dict = ' + ut.dict_str(ph.get_plotdat_dict(ax))) if viztype.startswith('chip'): from ibeis.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 ibeis.gui import inspect_gui print('right click') print('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 print('key = %r' % key) if key.find('control') == 0: print('[viz] result control clicked') self.show_sver_process_to_aid(aid2) # Left-Click else: print('[viz] result clicked') self.show_matches_to_aid(aid2) self.draw()
def on_click_inside(self, event, ax): self.ax = ax self.event = event event = self.event #print(ax) #print(event.x) #print(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) #print('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: print( 'This funciton only work if exactly 2 are selected' ) else: from ibeis.gui import inspect_gui context_shown = True aid1, aid2 = (self.selected_aids) qres = None qreq_ = None options = inspect_gui.get_aidpair_context_menu_options( ibs, aid1, aid2, qres, qreq_=qreq_) self.show_popup_menu(options, event) SELECT_ANNOT = dist < 35 if SELECT_ANNOT: #print(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 ibeis.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( 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_images), ] self.show_popup_menu(options, event)