Esempio n. 1
0
    def show_page(self, bring_to_front=False):
        """ Plots all subaxes on a page """
        print('[querydec] show_page()')
        self.prepare_page()
        # Variables we will work with to paint a pretty picture
        #ibs = self.ibs
        nRows = self.nRows
        nCols = self.nCols

        #Plot the Comparisions
        for count, c_aid in enumerate(self.comp_aids):
            if c_aid is not None:
                px = nCols + count + 1
                title_suffix = ''
                if self.suggest_aids is not None and c_aid in self.suggest_aids:
                    title_suffix = 'SUGGESTED BY IBEIS'
                self.plot_chip(c_aid, nRows, nCols, px, title_suffix=title_suffix)
            else:
                pt.imshow_null(fnum=self.fnum, pnum=(nRows, nCols, nCols + count + 1), title='NO RESULT')

        #Plot the Query Chip last
        with ut.EmbedOnException():
            query_title = 'Identify This Animal'
            self.plot_chip(self.query_aid, nRows, 1, 1, title_suffix=query_title)

        self.show_hud()
        pt.adjust_subplots_safe(top=0.88, hspace=0.12)
        self.draw()
        self.show()
        if bring_to_front:
            self.bring_to_front()
Esempio n. 2
0
    def show_page(self, bring_to_front=False):
        """ Plots all subaxes on a page """
        print('[querydec] show_page()')
        self.prepare_page()
        # Variables we will work with to paint a pretty picture
        #ibs = self.ibs
        nRows = self.nRows
        nCols = self.nCols

        #Plot the Comparisions
        for count, c_aid in enumerate(self.comp_aids):
            if c_aid is not None:
                px = nCols + count + 1
                title_suffix = ''
                if self.suggest_aids is not None and c_aid in self.suggest_aids:
                    title_suffix = 'SUGGESTED BY IBEIS'
                self.plot_chip(c_aid,
                               nRows,
                               nCols,
                               px,
                               title_suffix=title_suffix)
            else:
                pt.imshow_null(fnum=self.fnum,
                               pnum=(nRows, nCols, nCols + count + 1),
                               title='NO RESULT')

        #Plot the Query Chip last
        with ut.EmbedOnException():
            query_title = 'Identify This Animal'
            self.plot_chip(self.query_aid,
                           nRows,
                           1,
                           1,
                           title_suffix=query_title)

        self.show_hud()
        pt.adjust_subplots_safe(top=0.88, hspace=0.12)
        self.draw()
        self.show()
        if bring_to_front:
            self.bring_to_front()
Esempio n. 3
0
    def show_page(self, bring_to_front=False, onlyrows=None, fulldraw=True):
        """ Plots all subaxes on a page

        onlyrows is a hack to only draw a subset of the data again
        """
        if ut.VERBOSE:
            if not fulldraw:
                print('[matchver] show_page(fulldraw=%r, onlyrows=%r)' % (fulldraw, onlyrows))
            else:
                print('[matchver] show_page(fulldraw=%r)' % (fulldraw))
        self.prepare_page(fulldraw=fulldraw)
        # Variables we will work with to paint a pretty picture
        ibs = self.ibs
        nRows = self.nRows
        colpad = 1 if  self.cm is not None else 0
        nCols = self.nCols + colpad

        # Distinct color for every unique name
        unique_nids = ut.unique_ordered(ibs.get_annot_name_rowids(self.all_aid_list, distinguish_unknowns=False))
        unique_colors = pt.distinct_colors(len(unique_nids), brightness=.7, hue_range=(.05, .95))
        self.nid2_color = dict(zip(unique_nids, unique_colors))

        row_aids_list = self.get_row_aids_list()

        if self.cm is not None:
            print("DRAWING QRES")
            pnum = (1, nCols, 1)
            if not fulldraw:
                # not doing full draw so we have to clear any axes
                # that are here already manually
                ax = self.fig.add_subplot(*pnum)
                self.clear_parent_axes(ax)
            self.cm.show_single_annotmatch(self.qreq_, self.aid2, fnum=self.fnum, pnum=pnum, draw_fmatch=True, colorbar_=False)

        # For each row
        for rowx, aid_list in enumerate(row_aids_list):
            offset = rowx * nCols + 1
            if onlyrows is not None and rowx not in onlyrows:
                continue
            #ibsfuncs.assert_valid_aids(ibs, groundtruth)
            # For each column
            for colx, aid in enumerate(aid_list, start=colpad):
                if colx >= nCols:
                    break
                try:
                    nid = ibs.get_annot_name_rowids(aid)
                    if ibsfuncs.is_nid_unknown(ibs, [nid])[0]:
                        color = const.UNKNOWN_PURPLE_RGBA01
                    else:
                        color = self.nid2_color[nid]
                except Exception as ex:
                    ut.printex(ex)
                    print('nid = %r' % (nid,))
                    print('self.nid2_color = %s' % (ut.dict_str(self.nid2_color),))
                    raise
                px = colx + offset
                ax = self.plot_chip(int(aid), nRows, nCols, px, color=color, fulldraw=fulldraw)
                # If there are still more in this row to display
                if colx + 1 < len(aid_list) and colx + 1 >= nCols:
                    total_indices = len(aid_list)
                    current_index = self.col_offset_list[rowx] + 1
                    next_text = 'next\n%d/%d' % (current_index, total_indices)
                    next_func = functools.partial(self.rotate_row, rowx=rowx)
                    self.append_button(next_text, callback=next_func,
                                       location='right', size='33%', ax=ax)

        if fulldraw:
            self.show_hud()
            #pt.adjust_subplots_safe(top=0.85, hspace=0.03)
            hspace = .05 if (self.nCols) > 1 else .1
            pt.adjust_subplots_safe(top=0.85, hspace=hspace)
        self.draw()
        self.show()
        if bring_to_front:
            self.bring_to_front()
Esempio n. 4
0
    def show_page(self, bring_to_front=False, onlyrows=None, fulldraw=True):
        """ Plots all subaxes on a page

        onlyrows is a hack to only draw a subset of the data again
        """
        if ut.VERBOSE:
            if not fulldraw:
                print('[matchver] show_page(fulldraw=%r, onlyrows=%r)' %
                      (fulldraw, onlyrows))
            else:
                print('[matchver] show_page(fulldraw=%r)' % (fulldraw))
        self.prepare_page(fulldraw=fulldraw)
        # Variables we will work with to paint a pretty picture
        ibs = self.ibs
        nRows = self.nRows
        colpad = 1 if self.cm is not None else 0
        nCols = self.nCols + colpad

        # Distinct color for every unique name
        unique_nids = ut.unique_ordered(
            ibs.get_annot_name_rowids(self.all_aid_list,
                                      distinguish_unknowns=False))
        unique_colors = pt.distinct_colors(len(unique_nids),
                                           brightness=.7,
                                           hue_range=(.05, .95))
        self.nid2_color = dict(zip(unique_nids, unique_colors))

        row_aids_list = self.get_row_aids_list()

        if self.cm is not None:
            print("DRAWING QRES")
            pnum = (1, nCols, 1)
            if not fulldraw:
                # not doing full draw so we have to clear any axes
                # that are here already manually
                ax = self.fig.add_subplot(*pnum)
                self.clear_parent_axes(ax)
            self.cm.show_single_annotmatch(self.qreq_,
                                           self.aid2,
                                           fnum=self.fnum,
                                           pnum=pnum,
                                           draw_fmatch=True,
                                           colorbar_=False)

        # For each row
        for rowx, aid_list in enumerate(row_aids_list):
            offset = rowx * nCols + 1
            if onlyrows is not None and rowx not in onlyrows:
                continue
            #ibsfuncs.assert_valid_aids(ibs, groundtruth)
            # For each column
            for colx, aid in enumerate(aid_list, start=colpad):
                if colx >= nCols:
                    break
                try:
                    nid = ibs.get_annot_name_rowids(aid)
                    if ibsfuncs.is_nid_unknown(ibs, [nid])[0]:
                        color = const.UNKNOWN_PURPLE_RGBA01
                    else:
                        color = self.nid2_color[nid]
                except Exception as ex:
                    ut.printex(ex)
                    print('nid = %r' % (nid, ))
                    print('self.nid2_color = %s' %
                          (ut.dict_str(self.nid2_color), ))
                    raise
                px = colx + offset
                ax = self.plot_chip(int(aid),
                                    nRows,
                                    nCols,
                                    px,
                                    color=color,
                                    fulldraw=fulldraw)
                # If there are still more in this row to display
                if colx + 1 < len(aid_list) and colx + 1 >= nCols:
                    total_indices = len(aid_list)
                    current_index = self.col_offset_list[rowx] + 1
                    next_text = 'next\n%d/%d' % (current_index, total_indices)
                    next_func = functools.partial(self.rotate_row, rowx=rowx)
                    self.append_button(next_text,
                                       callback=next_func,
                                       location='right',
                                       size='33%',
                                       ax=ax)

        if fulldraw:
            self.show_hud()
            #pt.adjust_subplots_safe(top=0.85, hspace=0.03)
            hspace = .05 if (self.nCols) > 1 else .1
            pt.adjust_subplots_safe(top=0.85, hspace=hspace)
        self.draw()
        self.show()
        if bring_to_front:
            self.bring_to_front()