def make_hud(self): """ Creates heads up display """ import plottool as pt if not self.draw_hud: return # Button positioning #w, h = .08, .04 #w, h = .14, .08 w, h = .14, .07 hl_slot, hr_slot = pt.make_bbox_positioners(y=.02, w=w, h=h, xpad=.05, startx=0, stopx=1) prev_rect = hl_slot(0) next_rect = hr_slot(0) #print('prev_rect = %r' % (prev_rect,)) #print('next_rect = %r' % (next_rect,)) # Create buttons prev_callback = None if self.current_pagenum == 0 else self.prev_page next_callback = None if self.current_pagenum == self.nPages - 1 else self.next_page prev_text = 'prev\n' + pretty_hotkey_map(self.PREV_PAGE_HOTKEYS) next_text = 'next\n' + pretty_hotkey_map(self.NEXT_PAGE_HOTKEYS) self.append_button(prev_text, callback=prev_callback, rect=prev_rect) self.append_button(next_text, callback=next_callback, rect=next_rect)
def make_hud(self): """ Creates heads up display """ import plottool as pt hl_slot, hr_slot = pt.make_bbox_positioners(y=.02, w=.10, h=.03, xpad=.05, startx=0, stopx=1) # Create buttons self.append_button('Auto Infer', callback=self.make_inference, rect=hl_slot(0)) self.append_button('Break', callback=self.break_links, rect=hl_slot(1)) self.append_button('Link', callback=self.make_links, rect=hl_slot(2)) self.append_button('Accept', callback=self.confirm, rect=hr_slot(0)) self.append_button('Deselect', callback=self.unselect_all, rect=hr_slot(1)) self.append_button('Show', callback=self.show_selected, rect=hr_slot(2))
def make_hud(self): """ Creates heads up display """ import plottool as pt hl_slot, hr_slot = pt.make_bbox_positioners( y=.02, w=.10, h=.03, xpad=.05, startx=0, stopx=1) # Create buttons self.append_button('Auto Infer', callback=self.make_inference, rect=hl_slot(0)) self.append_button('Break', callback=self.break_links, rect=hl_slot(1)) self.append_button('Link', callback=self.make_links, rect=hl_slot(2)) self.append_button('Accept', callback=self.confirm, rect=hr_slot(0)) self.append_button('Deselect', callback=self.unselect_all, rect=hr_slot(1)) self.append_button('Show', callback=self.show_selected, rect=hr_slot(2))
def show_hud(self): """ Creates heads up display """ # Button positioners hl_slot, hr_slot = pt.make_bbox_positioners(y=.02, w=.16, h=3 * ut.PHI_B ** 4, xpad=.05, startx=0, stopx=1) select_none_text = 'None of these' if self.suggest_aids is not None and len(self.suggest_aids) == 0: select_none_text += '\n(SUGGESTED BY IBEIS)' none_tup = self.append_button(select_none_text, callback=partial(self.select_none), rect=hl_slot(0)) #Draw boarder around the None of these button none_button_axis = none_tup[1] if self.other_checkbox_states['none']: pt.draw_border(none_button_axis, color=(0, 1, 0), lw=4, adjust=False) else: pt.draw_border(none_button_axis, color=(.7, .7, .7), lw=4, adjust=False) select_junk_text = 'Junk Query Image' junk_tup = self.append_button(select_junk_text, callback=partial(self.select_junk), rect=hl_slot(1)) #Draw boarder around the None of these button junk_button_axis = junk_tup[1] if self.other_checkbox_states['junk']: pt.draw_border(junk_button_axis, color=(0, 1, 0), lw=4, adjust=False) else: pt.draw_border(junk_button_axis, color=(.7, .7, .7), lw=4, adjust=False) #Add other HUD buttons self.append_button('Quit', callback=partial(self.quit), rect=hr_slot(0)) self.append_button('Confirm Selection', callback=partial(self.confirm), rect=hr_slot(1)) if self.progress_current is not None and self.progress_total is not None: self.progress_string = str(self.progress_current) + '/' + str(self.progress_total) else: self.progress_string = '' figtitle_fmt = ''' Animal Identification {progress_string} ''' figtitle = figtitle_fmt.format(**self.__dict__) # sexy: using obj dict as fmtkw pt.set_figtitle(figtitle)
def show_hud(self): """ Creates heads up display button bar on bottom and title string Example: >>> # DISABLE_DOCTEST >>> from ibeis.viz.interact.interact_name import * # NOQA >>> # build test data >>> self = testsdata_match_verification('PZ_MTEST', 30, 32) >>> # execute function >>> result = self.show_hud() >>> # verify results >>> print(result) >>> ut.quit_if_noshow(): >>> self.show_page() >>> pt.show_if_requested() """ # Button positioners hl_slot, hr_slot = pt.make_bbox_positioners(y=.02, w=.15, h=.063, xpad=.02, startx=0, stopx=1) # hack make a second bbox positioner to get different sized buttons on # # the left hl_slot2, hr_slot2 = pt.make_bbox_positioners(y=.02, w=.08, h=.05, xpad=.015, startx=0, stopx=1) def next_rect(accum=[-1]): accum[0] += 1 return hr_slot(accum[0]) def next_rect2(accum=[-1]): accum[0] += 1 return hl_slot2(accum[0]) ibs = self.ibs name1, name2 = self.name1, self.name2 nid1_is_known = not ibs.is_nid_unknown(self.nid1) nid2_is_known = not ibs.is_nid_unknown(self.nid2) all_nid_list = ibs.get_annot_name_rowids(self.all_aid_list) is_unknown = ibs.is_nid_unknown(all_nid_list) is_name1 = [nid == self.nid1 for nid in all_nid_list] is_name2 = [nid == self.nid2 for nid in all_nid_list] # option to remove all names only if at least one name exists if not all(is_unknown): unname_all_text = 'remove all names' self.append_button(unname_all_text, callback=self.unname_all, rect=next_rect()) # option to merge all into a new name if all are unknown if all(is_unknown) and not nid1_is_known and not nid2_is_known: joinnew_text = 'match all (nonjunk)\n to a new name' self.append_button(joinnew_text, callback=self.merge_nonjunk_into_new_name, rect=next_rect()) # option dismiss all and give new names to all nonjunk images if any(is_unknown): self.append_button('mark all unknowns\nas not matching', callback=self.dismiss_all, rect=next_rect()) # merges all into the first name if nid1_is_known and not all(is_name1): join1_text = 'match all to name1:\n{name1}'.format(name1=name1) callback = functools.partial(self.merge_all_into_nid, self.nid1) self.append_button(join1_text, callback=callback, rect=next_rect()) # merges all into the seoncd name if name1 != name2 and nid2_is_known and not all(is_name2): join2_text = 'match all to name2:\n{name2}'.format(name2=name2) callback = functools.partial(self.merge_all_into_nid, self.nid2) self.append_button(join2_text, callback=callback, rect=next_rect()) ### self.append_button('close', callback=self.close_, rect=next_rect2()) if self.qres_callback is not None: self.append_button('review', callback=self.review, rect=next_rect2()) self.append_button('reset', callback=self.reset_all_names, rect=next_rect2()) self.dbname = ibs.get_dbname() self.vsstr = ibsfuncs.vsstr(self.aid1, self.aid2) figtitle_fmt = ''' Match Review Interface - {dbname} {match_text}: {vsstr} ''' figtitle = figtitle_fmt.format(**self.__dict__) # sexy: using obj dict as fmtkw pt.set_figtitle(figtitle)
def make_hud(self): """ Creates heads up display """ import plottool as pt hl_slot, hr_slot = pt.make_bbox_positioners(y=.01, w=.10, h=.03, xpad=.01, startx=0, stopx=1) hl_slot2, hr_slot2 = pt.make_bbox_positioners(y=.05, w=.10, h=.03, xpad=.01, startx=0, stopx=1) hl_slot3, hr_slot3 = pt.make_bbox_positioners(y=.09, w=.10, h=.03, xpad=.01, startx=0, stopx=1) def make_position_gen(slot_): gen_ = (slot_(x) for x in itertools.count(0)) def gennext_(): return six.next(gen_) return gennext_ hl_next = make_position_gen(hl_slot) hr_next = make_position_gen(hr_slot) hl_next2 = make_position_gen(hl_slot2) hr_next2 = make_position_gen(hr_slot2) hl_next3 = make_position_gen(hl_slot3) hr_next3 = make_position_gen(hr_slot3) def _add_button(text, callback, rect): self.append_button(text, callback=callback, rect=rect) def _debug_button(func, r_next, refresh=True): def _simple_onevent(event): func() if refresh: self.show_page() _add_button(ut.get_funcname(func), _simple_onevent, r_next()) def _toggle_args(states, varname, r_next): state = getattr(self, varname) def _simple_onevent(event): setattr(self, varname, not getattr(self, varname)) self.show_page() text = states[0] if state else states[1] return text, _simple_onevent, r_next() # Create buttons r_next = hl_next _add_button('Mark: Match', self.mark_match, r_next()) _add_button('Mark: Match', self.mark_match, r_next()) _add_button('Mark: Non-Match', self.mark_nomatch, r_next()) _add_button('Mark: Not-Comp', self.mark_notcomp, r_next()) r_next = hr_next _add_button('Accept', self.confirm, r_next()) _add_button('Cut', self.cut, r_next()) r_next = hr_next2 _add_button('Params', self.edit_config, r_next()) r_next = hl_next2 _add_button('Deselect', self.unselect_all, r_next()) _add_button('Show Annots', self.show_selected, r_next()) _add_button( *_toggle_args(['Hide Cuts', 'Show Cuts'], 'show_cuts', r_next)) #_add_button(*_toggle_args(['Hide Imgs', 'Show Imgs'], 'use_image', r_next)) _add_button(['Hide Imgs', 'Show Imgs'][self.use_image], self.toggle_imgs, r_next()) _add_button('Reset', self.reset, r_next()) r_next = hl_next3 #Debug row _debug_button(self.infr.apply_scores, r_next) # _debug_button(self.infr.apply_feedback, r_next) _debug_button(self.infr.apply_weights, r_next) _debug_button(self.infr.apply_all, r_next) r_next = hr_next3 _debug_button(self.plot_weights, r_next, 0) _debug_button(self.print_weights, r_next, 0)
def show_hud(self): """ Creates heads up display button bar on bottom and title string Example: >>> # DISABLE_DOCTEST >>> from ibeis.viz.interact.interact_name import * # NOQA >>> # build test data >>> self = testsdata_match_verification('PZ_MTEST', 30, 32) >>> # execute function >>> result = self.show_hud() >>> # verify results >>> print(result) >>> ut.quit_if_noshow(): >>> self.show_page() >>> pt.show_if_requested() """ # Button positioners hl_slot, hr_slot = pt.make_bbox_positioners(y=.02, w=.15, h=.063, xpad=.02, startx=0, stopx=1) # hack make a second bbox positioner to get different sized buttons on # # the left hl_slot2, hr_slot2 = pt.make_bbox_positioners(y=.02, w=.08, h=.05, xpad=.015, startx=0, stopx=1) def next_rect(accum=[-1]): accum[0] += 1 return hr_slot(accum[0]) def next_rect2(accum=[-1]): accum[0] += 1 return hl_slot2(accum[0]) ibs = self.ibs name1, name2 = self.name1, self.name2 nid1_is_known = not ibs.is_nid_unknown(self.nid1) nid2_is_known = not ibs.is_nid_unknown(self.nid2) all_nid_list = ibs.get_annot_name_rowids(self.all_aid_list) is_unknown = ibs.is_nid_unknown(all_nid_list) is_name1 = [nid == self.nid1 for nid in all_nid_list] is_name2 = [nid == self.nid2 for nid in all_nid_list] # option to remove all names only if at least one name exists if not all(is_unknown): unname_all_text = 'remove all names' self.append_button(unname_all_text, callback=self.unname_all, rect=next_rect()) # option to merge all into a new name if all are unknown if all(is_unknown) and not nid1_is_known and not nid2_is_known: joinnew_text = 'match all (nonjunk)\n to a new name' self.append_button(joinnew_text, callback=self.merge_nonjunk_into_new_name, rect=next_rect()) # option dismiss all and give new names to all nonjunk images if any(is_unknown): self.append_button('mark all unknowns\nas not matching', callback=self.dismiss_all, rect=next_rect()) # merges all into the first name if nid1_is_known and not all(is_name1): join1_text = 'match all to name1:\n{name1}'.format(name1=name1) callback = functools.partial(self.merge_all_into_nid, self.nid1) self.append_button(join1_text, callback=callback, rect=next_rect()) # merges all into the seoncd name if name1 != name2 and nid2_is_known and not all(is_name2): join2_text = 'match all to name2:\n{name2}'.format(name2=name2) callback = functools.partial(self.merge_all_into_nid, self.nid2) self.append_button(join2_text, callback=callback, rect=next_rect()) ### self.append_button('close', callback=self.close_, rect=next_rect2()) if self.qres_callback is not None: self.append_button('review', callback=self.review, rect=next_rect2()) self.append_button('reset', callback=self.reset_all_names, rect=next_rect2()) self.dbname = ibs.get_dbname() self.vsstr = 'qaid%d-vs-aid%d' % (self.aid1, self.aid2) figtitle_fmt = ''' Match Review Interface - {dbname} {match_text}: {vsstr} ''' figtitle = figtitle_fmt.format( **self.__dict__) # sexy: using obj dict as fmtkw pt.set_figtitle(figtitle)
def show_hud(self): """ Creates heads up display """ # Button positioners hl_slot, hr_slot = pt.make_bbox_positioners(y=.02, w=.16, h=3 * ut.PHI_B**4, xpad=.05, startx=0, stopx=1) select_none_text = 'None of these' if self.suggest_aids is not None and len(self.suggest_aids) == 0: select_none_text += '\n(SUGGESTED BY IBEIS)' none_tup = self.append_button(select_none_text, callback=partial(self.select_none), rect=hl_slot(0)) #Draw boarder around the None of these button none_button_axis = none_tup[1] if self.other_checkbox_states['none']: pt.draw_border(none_button_axis, color=(0, 1, 0), lw=4, adjust=False) else: pt.draw_border(none_button_axis, color=(.7, .7, .7), lw=4, adjust=False) select_junk_text = 'Junk Query Image' junk_tup = self.append_button(select_junk_text, callback=partial(self.select_junk), rect=hl_slot(1)) #Draw boarder around the None of these button junk_button_axis = junk_tup[1] if self.other_checkbox_states['junk']: pt.draw_border(junk_button_axis, color=(0, 1, 0), lw=4, adjust=False) else: pt.draw_border(junk_button_axis, color=(.7, .7, .7), lw=4, adjust=False) #Add other HUD buttons self.append_button('Quit', callback=partial(self.quit), rect=hr_slot(0)) self.append_button('Confirm Selection', callback=partial(self.confirm), rect=hr_slot(1)) if self.progress_current is not None and self.progress_total is not None: self.progress_string = str(self.progress_current) + '/' + str( self.progress_total) else: self.progress_string = '' figtitle_fmt = ''' Animal Identification {progress_string} ''' figtitle = figtitle_fmt.format( **self.__dict__) # sexy: using obj dict as fmtkw pt.set_figtitle(figtitle)