def _guitool_loop(main_locals, ipy=False): import guitool import utool from ibeis.dev import params print('[main] guitool loop') back = main_locals.get('back', None) if back is not None: loop_freq = params.args.loop_freq guitool.qtapp_loop(qwin=back.mainwin, ipy=ipy or params.args.cmd, frequency=loop_freq) back.refresh_state() else: if not utool.QUIET and utool.VERBOSE: print('WARNING: back was not expected to be None')
def _guitool_loop(main_locals, ipy=False): import guitool from ibeis import params print('[main] guitool loop') back = main_locals.get('back', None) if back is not None: loop_freq = params.args.loop_freq ipy = ipy or params.args.cmd guitool.qtapp_loop(qwin=back.mainwin, ipy=ipy, frequency=loop_freq, init_signals=False) if ipy: # If we're in IPython, the qtapp loop won't block, so we need to refresh back.refresh_state() else: if NOT_QUIET: print('WARNING: back was not expected to be None')
def start_qt_interface(infr, loop=True): import guitool as gt from ibeis.viz.viz_graph2 import AnnotGraphWidget from plottool import abstract_interaction import plottool as pt pt.qtensure() gt.ensure_qtapp() # win = AnnotGraphWidget(infr=infr, use_image=False, init_mode='review') win = AnnotGraphWidget(infr=infr, use_image=False, init_mode=None) abstract_interaction.register_interaction(win) if loop: gt.qtapp_loop(qwin=win, freq=10) else: win.show() return win
def setup_dummy_menus(): r""" CommandLine: python -m ibeis.gui.guimenus --test-setup_dummy_menus Example: >>> # DISABLE_DOCTEST >>> from ibeis.gui.guimenus import * # NOQA >>> result = setup_dummy_menus() >>> print(result) """ #import unittest import guitool as gt gt.ensure_qapp() # must be ensured before any embeding mainwin = gt.QtWidgets.QMainWindow() back = DummyBack() import mock mainwin.expand_names_tree = mock.Mock setup_menus(mainwin, back) mainwin.show() mainwin.resize(600, 100) #ut.embed() gt.qtapp_loop(mainwin, frequency=100)
def setup_dummy_menus(): r""" CommandLine: python -m ibeis.gui.guimenus --test-setup_dummy_menus Example: >>> # DISABLE_DOCTEST >>> from ibeis.gui.guimenus import * # NOQA >>> result = setup_dummy_menus() >>> print(result) """ #import unittest import guitool guitool.ensure_qapp() # must be ensured before any embeding mainwin = guitool.QtGui.QMainWindow() back = DummyBack() import mock mainwin.expand_names_tree = mock.Mock setup_menus(mainwin, back) mainwin.show() mainwin.resize(600, 100) #ut.embed() guitool.qtapp_loop(mainwin, frequency=100)
# eid = model.eid gid = id_ print("SINGLE CLICKED ID: %r" % gid) @slot_(QtCore.QModelIndex) def on_doubleclick(ibswgt, qtindex): printDBG('on_doubleclick') model = qtindex.model() id_ = model._get_row_id(qtindex) if model.name == NAMES_TREE: # eid = model.eid gid = id_ #ibswgt.annotation_interact = interact_annotations2.ANNOTATION_Interaction2(ibswgt.ibs, gid) print("DOUBLECLICKED ID: %r" % gid) if __name__ == '__main__': import ibeis import sys ibeis._preload(mpl=False, par=False) guitool.ensure_qtapp() dbdir = ibeis.sysres.get_args_dbdir(defaultdb='cache') ibs = IBEISControl.IBEISController(dbdir=dbdir) ibswgt = IBEISGuiWidget(ibs=ibs) ibswgt.resize(900, 600) if '--cmd' in sys.argv: guitool.qtapp_loop(qwin=ibswgt, ipy=True) exec(utool.ipython_execstr()) else: guitool.qtapp_loop(qwin=ibswgt)
def test_inc_query(ibs_gt, num_initial=0): """ entry point for interactive query tests test_interactive_incremental_queries Args: ibs (list) : IBEISController object qaid_list (list) : list of annotation-ids to query CommandLine: python dev.py -t inc --db PZ_MTEST --qaid 1:30:3 --cmd python dev.py --db PZ_MTEST --allgt --cmd python dev.py --db PZ_MTEST --allgt -t inc python dev.py --db PZ_MTEST --allgt -t inc CommandLine: python -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:0 --interact-after 444440 --noqcache python -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:1 --interact-after 444440 --noqcache python -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:0 python -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:1 python -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:2 python -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:3 utprof.py -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:3 --ninit 5000 utprof.py -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:0 # Writes out test script python -c "import utool as ut; ut.write_modscript_alias('Tinc.sh', 'ibeis.algo.hots.qt_inc_automatch')" sh Tinc.sh --test-test_inc_query:0 sh Tinc.sh --test-test_inc_query:1 sh Tinc.sh --test-test_inc_query:2 sh Tinc.sh --test-test_inc_query:3 utprof.py -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:3 --num-init 5000 sh Tinc.sh --test-test_inc_query:0 --ninit 10 sh Tinc.sh --test-test_inc_query:0 --ninit 10 --verbose-debug --verbose-helpful python -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:0 --ia 10 # Runs into a merge case python -m ibeis.algo.hots.qt_inc_automatch --test-test_inc_query:0 --ia 30 Example0: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.automated_matcher import * # NOQA >>> ibs_gt = ibeis.opendb('testdb1') >>> test_inc_query(ibs_gt) Example1: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.automated_matcher import * # NOQA >>> ibs_gt = ibeis.opendb('PZ_MTEST') >>> test_inc_query(ibs_gt) Example2: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.automated_matcher import * # NOQA >>> ibs_gt = ibeis.opendb('GZ_ALL') >>> test_inc_query(ibs_gt) Example3: >>> # DISABLE_DOCTEST >>> from ibeis.algo.hots.automated_matcher import * # NOQA >>> ibs_gt = ibeis.opendb('PZ_Master0') >>> test_inc_query(ibs_gt) """ from ibeis import main_module main_module._preload() guitool.ensure_qtapp() num_initial self = IncQueryHarness() num_initial = ut.get_argval(('--num-initial', '--num-init', '--ninit'), int, 0) interactive_after = ut.get_argval(('--interactive-after', '--ia'), type_=int, default=None) # Add information to an empty database from a groundtruth database ibs, aid_list1, aid1_to_aid2 = ah.setup_incremental_test(ibs_gt) if True or interactive_after is not None: back = main_module._init_gui() back.connect_ibeis_control(ibs) else: back = None interactive = self.test_incremental_query( ibs_gt, ibs, aid_list1, aid1_to_aid2, interactive_after=interactive_after, num_initial=num_initial, back=back) if back is None and interactive_after is None and interactive: # need to startup backend back = main_module._init_gui() back.connect_ibeis_control(ibs) if interactive or interactive_after is not None: guitool.qtapp_loop()
def draw_results(ibs, testres): r""" Draws results from an experiment harness run. Rows store different qaids (query annotation ids) Cols store different configurations (algorithm parameters) Args: testres (TestResult): CommandLine: python dev.py -t custom:rrvsone_on=True,constrained_coeff=0 custom --qaid 12 --db PZ_MTEST --show --va python dev.py -t custom:rrvsone_on=True,constrained_coeff=.3 custom --qaid 12 --db PZ_MTEST --show --va --noqcache python dev.py -t custom:rrvsone_on=True custom --qaid 4 --db PZ_MTEST --show --va --noqcache python dev.py -t custom:rrvsone_on=True,grid_scale_factor=1 custom --qaid 12 --db PZ_MTEST --show --va --noqcache python dev.py -t custom:rrvsone_on=True,grid_scale_factor=1,grid_steps=1 custom --qaid 12 --db PZ_MTEST --show --va --noqcache CommandLine: python dev.py -t best --db seals2 --allgt --vz --fig-dname query_analysis_easy --show python dev.py -t best --db seals2 --allgt --vh --fig-dname query_analysis_hard --show python dev.py -t pyrscale --db PZ_MTEST --allgt --vn --fig-dname query_analysis_interesting --show python dev.py -t pyrscale --db testdb3 --allgt --vn --fig-dname query_analysis_interesting --vf python dev.py -t pyrscale --db testdb3 --allgt --vn --fig-dname query_analysis_interesting --vf --quality python -m ibeis.expt.experiment_drawing --test-draw_results --show --vn python -m ibeis.expt.experiment_drawing --test-draw_results --show --vn --db PZ_MTEST python -m ibeis.expt.old_storage --test-draw_results --show --db PZ_MTEST --gv Example: >>> # DISABLE_DOCTEST >>> from ibeis.expt.old_storage import * # NOQA >>> from ibeis.init import main_helpers >>> ibs, testres = main_helpers.testdata_expts('PZ_MTEST') >>> result = draw_results(ibs, testres) >>> # verify results >>> print(result) """ print(' --- DRAW RESULTS ---') # It is very inefficient to turn off caching when view_all is true figdir = ibs.get_fig_dir() ut.ensuredir(figdir) if ut.get_argflag(('--view-fig-directory', '--vf')): ut.view_directory(figdir) figdir_suffix = ut.get_argval('--fig-dname', type_=str, default=None) from os.path import join if figdir_suffix is not None: figdir = join(figdir, figdir_suffix) ut.ensuredir(figdir) #gx2_gt_timedelta # cfgres_info['qx2_gf_timedelta'] = qx2_gf_timedelta metadata_fpath = join(figdir, 'result_metadata.shelf') metadata = ResultMetadata(metadata_fpath) #metadata.rrr() metadata.connect() metadata.sync_test_results(testres) #cfgstr = qreq_.get_cfgstr() #cfg_metadata = ensure_item(metadata, cfgstr, {}) #avuuids = ibs.get_annot_visual_uuids(qaids) #avuuid2_ax = ensure_item(cfg_metadata, 'avuuid2_ax', {}) #cfg_columns = ensure_item(cfg_metadata, 'columns', {}) #import guitool # ut.argv_flag_dec(draw_rank_cdf)(ibs, testres) # VIZ_INDIVIDUAL_RESULTS = True # if VIZ_INDIVIDUAL_RESULTS: # draw_match_cases(ibs, testres, metadata=metadata) metadata.write() if ut.get_argflag(('--guiview', '--gv')): import guitool guitool.ensure_qapp() #wgt = make_test_result_custom_api(ibs, testres) wgt = make_metadata_custom_api(metadata) wgt.show() wgt.raise_() guitool.qtapp_loop(wgt, frequency=100) metadata.close() if ut.NOT_QUIET: print('[DRAW_RESULT] EXIT EXPERIMENT HARNESS')
print("on double click") printDBG('on_doubleclick') model = qtindex.model() id_ = model._get_row_id(qtindex) print('dblclick (%r,%r)' % (qtindex.row(), qtindex.column())) if model.name == THUMB_TABLE: # imgsetid = model.imgsetid gid = id_ if gid is None: return ibswgt.roi_interact = interact_annotations2.ANNOTATION_Interaction2( ibswgt.ibs, gid) print("DOUBLECLICKED ID: %r" % gid) if __name__ == '__main__': import ibeis import sys ibeis._preload(mpl=False, par=False) guitool.ensure_qtapp() dbdir = ibeis.sysres.get_args_dbdir(defaultdb='cache') ibs = IBEISControl.IBEISController(dbdir=dbdir) ibswgt = IBEISGuiWidget(ibs=ibs) ibswgt.resize(900, 600) if '--cmd' in sys.argv: guitool.qtapp_loop(qwin=ibswgt, ipy=True) exec(utool.ipython_execstr()) else: guitool.qtapp_loop(qwin=ibswgt)