def initialize():
    """
    [called during startup]
    """
    register_debug_menu_command("Test: virtual site from selatoms",
                                virtual_site_from_selatoms_command)
    return
Beispiel #2
0
def initialize():  #bruce 071005 added this wrapping function
    if have_pyrex_test:
        register_debug_menu_command("count bonds (pyrex_test)",
                                    count_bonds_cmd)
    else:
        register_debug_menu_command("count bonds (stub)", count_bonds_cmd)
    return
def initialize():
    if (Initialize.startInitialization(__name__)):
        return
    
    # initialization code (note: it's all a kluge, could be cleaned up pretty easily)

    # Note: the global declarations are needed due to the kluge above
    # involving globals()[example_command_classname]
    
    classnames = [ ] # extended below

    global ExampleCommand1
    from prototype.test_commands import ExampleCommand1
    classnames.append("ExampleCommand1")

    global ExampleCommand2
    from prototype.test_commands import ExampleCommand2
    classnames.append("ExampleCommand2")

    global test_connectWithState
    from prototype.test_connectWithState import test_connectWithState
    classnames.append("test_connectWithState")

    global ExampleCommand2E
    from prototype.example_expr_command import ExampleCommand2E
    classnames.append("ExampleCommand2E")

    for classname in classnames:
        cmdname = classname # for now
        register_debug_menu_command( cmdname, (lambda widget, classname = classname: enter_example_command(widget, classname)) )
    
    Initialize.endInitialization(__name__)
    return
Beispiel #4
0
def initialize():  # called from startup_misc.py
    if EndUser.enableDeveloperFeatures():
        register_debug_menu_command("Import all source files",
                                    import_all_modules_cmd)
        register_debug_menu_command("Export command table",
                                    export_command_table_cmd)
    return
def initialize():
    """
    [called during startup]
    """
    register_debug_menu_command( "Test: virtual site from selatoms",
                                 virtual_site_from_selatoms_command )
    return
Beispiel #6
0
    def register_display_mode_class(clas):  # staticmethod
        """
        Register the given subclass of ChunkDisplayMode as a new display mode for whole chunks,
        able to be drawn with, read/written in mmp files, and offered in the UI.

        @warning: The order in which this is called for different display styles
                  must correspond with the order in which disp index constants (diWhatever)
                  are defined for them in constants.py. (This needs cleanup.)
                  [bruce 080212 comment; related code has comments with same signature]
        """
        # Make sure we can read mmp files which refer to it as clas.mmp_code.
        # This also covers statusbar display and writemmp.
        # This works by calling _register_for_readmmp, which also stores clas.disp_label as needed
        # to show this display mode in the statusbar, when it's in use for the entire GLPane.
        # (As of 060608 there is no good reason to go through files_mmp to do this,
        #  but in the future it might need to keep its own record of this use of mmp_code.)
        # (It's probably a kluge that the registering of clas.disp_label goes through files_mmp in any way.
        #  The fault for that lies mainly with the requirement for constants.dispLabel and constants.dispNames
        #  to be lists with corresponding indices. If they were revamped, this could be cleaned up.
        #  But doing so is not trivial, assuming their ordering by bond cylinder radius is required.)

        # bruce 071017 -- remove register_for_readmmp and replace it with what it did,
        # since it's more confusing than worthwhile
        # (but see above comment for the motivation of the old way, which had some legitimacy):
        ## import files_mmp
        ## files_mmp.register_for_readmmp( clas)
        smethod = clas._register_for_readmmp
        smethod(clas)

        # The above also made it possible to draw chunks in this display mode, via _display_mode_handlers
        # and special cases in Chunk draw-related methods.
        ###e highlighting not yet done
        # Now add something to the UI so users can change chunks, or the GLPane, to this display mode.
        # (As a quick hack, just add a debug menu command (always visible) which acts like pressing a toolbutton for this mode.)
        disp_name = clas.mmp_code
        inst = _display_mode_handlers[disp_name]
        register_debug_menu_command(
            "setDisplayStyle_of_selection(%s)" % clas.disp_label,
            inst.setDisplay_command)
        ##e should we do something so users can use it as a prefs value for preferred display mode, too?
        return
    def register_display_mode_class(clas): # staticmethod
        """
        Register the given subclass of ChunkDisplayMode as a new display mode for whole chunks,
        able to be drawn with, read/written in mmp files, and offered in the UI.

        @warning: The order in which this is called for different display styles
                  must correspond with the order in which disp index constants (diWhatever)
                  are defined for them in constants.py. (This needs cleanup.)
                  [bruce 080212 comment; related code has comments with same signature]
        """
        # Make sure we can read mmp files which refer to it as clas.mmp_code.
        # This also covers statusbar display and writemmp.
        # This works by calling _register_for_readmmp, which also stores clas.disp_label as needed
        # to show this display mode in the statusbar, when it's in use for the entire GLPane.
        # (As of 060608 there is no good reason to go through files_mmp to do this,
        #  but in the future it might need to keep its own record of this use of mmp_code.)
        # (It's probably a kluge that the registering of clas.disp_label goes through files_mmp in any way.
        #  The fault for that lies mainly with the requirement for constants.dispLabel and constants.dispNames
        #  to be lists with corresponding indices. If they were revamped, this could be cleaned up.
        #  But doing so is not trivial, assuming their ordering by bond cylinder radius is required.)

        # bruce 071017 -- remove register_for_readmmp and replace it with what it did,
        # since it's more confusing than worthwhile
        # (but see above comment for the motivation of the old way, which had some legitimacy):
        ## import files_mmp
        ## files_mmp.register_for_readmmp( clas)
        smethod = clas._register_for_readmmp
        smethod(clas)

        # The above also made it possible to draw chunks in this display mode, via _display_mode_handlers
        # and special cases in Chunk draw-related methods.
        ###e highlighting not yet done
        # Now add something to the UI so users can change chunks, or the GLPane, to this display mode.
        # (As a quick hack, just add a debug menu command (always visible) which acts like pressing a toolbutton for this mode.)
        disp_name = clas.mmp_code
        inst = _display_mode_handlers[disp_name]
        register_debug_menu_command("setDisplayStyle_of_selection(%s)" % clas.disp_label, inst.setDisplay_command)
        ##e should we do something so users can use it as a prefs value for preferred display mode, too?
        return
Beispiel #8
0
def initialize(): #bruce 071005 added this wrapping function
    if have_pyrex_test:
        register_debug_menu_command("count bonds (pyrex_test)", count_bonds_cmd)
    else:
        register_debug_menu_command("count bonds (stub)", count_bonds_cmd)
    return
Beispiel #9
0
    #e more updates?
    return

def mark_atom_by_name_command(glpane):
    # review: is this really what the arg always is? i bet it's whatever widget this appeared in...
    ok, text = grab_text_using_dialog( default = "Ss3-564",
                                       title = "Mark atom by name",
                                       label = "atom name or number:" )
    if ok:
        name = text
        assy = glpane.assy
        mark_atom_by_name(assy, name)
    return

# todo: should do this in an initialize function!
register_debug_menu_command( "Mark atom by name...", mark_atom_by_name_command )

#e could also: select multiple atoms by list of names

def select_atoms_with_errors_command(glpane):
    """
    current part only...
    """
    count = 0
    assy = glpane.win.assy
    for mol in assy.molecules: # current part only
        for atom in mol.atoms.itervalues():
            if atom._dna_updater__error:
                count += 1 # whether or not already selected
                atom.pick() # should be safe inside itervalues
                    ### REVIEW: selection filter effect not considered
Beispiel #10
0
def debug_make_BorrowerChunk_raw(do_addmol = True):
    win = env.mainwindow()
    atomset = win.assy.selatoms
    if not atomset:
        env.history.message(redmsg("Need selected atoms to make a BorrowerChunk (for debugging only)"))
    else:
        atomset = dict(atomset) # copy it, since we shouldn't really add singlets to assy.selatoms...
        for atom in atomset.values(): # not itervalues, we're changing it in the loop!
            # BTW Python is nicer about this than I expected:
            # exceptions.RuntimeError: dictionary changed size during iteration
            for bp in atom.singNeighbors(): # likely bugs if these are not added into the set!
                atomset[bp.key] = bp
            assy = atom.molecule.assy # these are all the same, and we do this at least once
        chunk = BorrowerChunk(assy, atomset)
        if do_addmol:
            win.assy.addmol(chunk)
        import __main__
        __main__._bc = chunk
        env.history.message(orangemsg("__main__._bc = %s (for debugging only)" % quote_html(safe_repr(chunk))))
    win.win_update() #k is this done by caller?
    return

# ==

register_debug_menu_command("make BorrowerChunk", debug_make_BorrowerChunk)
register_debug_menu_command("make BorrowerChunk (no addmol)", debug_make_BorrowerChunk_no_addmol)

# end

    #e more updates?
    return

def mark_atom_by_name_command(glpane):
    # review: is this really what the arg always is? i bet it's whatever widget this appeared in...
    ok, text = grab_text_using_dialog( default = "Ss3-564",
                                       title = "Mark atom by name",
                                       label = "atom name or number:" )
    if ok:
        name = text
        assy = glpane.assy
        mark_atom_by_name(assy, name)
    return

# todo: should do this in an initialize function!
register_debug_menu_command( "Mark atom by name...", mark_atom_by_name_command )

#e could also: select multiple atoms by list of names

def select_atoms_with_errors_command(glpane):
    """
    current part only...
    """
    count = 0
    assy = glpane.win.assy
    for mol in assy.molecules: # current part only
        for atom in mol.atoms.itervalues():
            if atom._dna_updater__error:
                count += 1 # whether or not already selected
                atom.pick() # should be safe inside itervalues
                    ### REVIEW: selection filter effect not considered
def _register_our_debug_menu_commands():
    register_debug_menu_command( "DNA: rescan all atoms", rescan_all_atoms )
    register_debug_menu_command( "DNA: rescan selected atoms", rescan_selected_atoms )
    register_debug_menu_command( "DNA: add basepair handles", add_basepair_handles_to_selected_atoms )
# ==


def reload_undo(target=None):
    # does this work at all, now that undo_UI was split out of undo_manager? [bruce 071217 Q]
    import foundation.undo_archive as undo_archive
    reload(undo_archive)
    import foundation.undo_manager as undo_manager
    reload(undo_manager)
    import foundation.undo_internals as undo_internals
    reload(undo_internals)
    print "\nreloaded 3 out of 4 undo_*.py files; open a new file and we'll use them\n"  #e (works, but should make reopen automatic)


register_debug_menu_command("reload undo", reload_undo)

# ==


def keep_under_key(thing, key, obj, attr):
    """
    obj.attr[key] = thing, creating obj.attr dict if necessary
    """
    if DEBUG_PRINT_UNDO and 0:
        print "keepkey:", key, "keepon_obj:", obj  # also print attr to be complete
        # This shows unique keys, but just barely (name is deleg for lots of QActions)
        # so we'll have to worry about it, and maybe force all keys unique during init.
        # If some keys are not unique, result might be that some user actions
        # (or for worse bugs, internal signals) silently stop working. [bruce 050921]
    if not hasattr(obj, attr):
Beispiel #14
0
            # count them all before changing them or destroying any bonds,
            # in case some atomtypes weren't initialized yet
            # (since their getattr method looks at number of bonds)
    for atm in atmlist:
        for b in atm.bonds[:]:
            atm2 = b.other(atm)
            if atm2.key in atmdict:
                ###e to also zap singlets we'd need "or atm2.element is Singlet" and to prevent b.bust from remaking them!
                # (singlets can't be selected)
                b.bust()
                n_bonds_destroyed += 1 # (count real bonds only)
        atm.set_atomtype(atm.element.atomtypes[0]) ###k this might remake singlets if it changes atomtype
        #e future optim: revise above to also destroy singlets and bonds to them
        # (btw I think make_bonds doesn't make any singlets as it runs)
    n_bonds_made = make_bonds(atmlist)
        #e it would be nice to figure out how many of these are the same as the ones we destroyed, etc
    for atm in atmlist:
        atm.remake_bondpoints()
    env.history.message(
        "on %d selected atoms, replaced %d old bond(s) with %d new (or same) bond(s); changed %d atomtype(s) to default" %
        (n_atoms, n_bonds_destroyed, n_bonds_made, n_atomtypes_changed)
     )
    #e note, present implem marks lots of atoms as changed (from destroying and remaking bonds) which did not change;
    # this only matters much for redrawing speed (of unchanged chunks) and since file is always marked as changed
    # even if nothing changed at all.
    return

register_debug_menu_command( "Remake Bonds", remake_bonds_in_selection )

#end
if EndUser.enableDeveloperFeatures():
    print "DISABLE_SLOT_ARGCOUNT_RETRY =", DISABLE_SLOT_ARGCOUNT_RETRY

# ==

def reload_undo(target = None):
    # does this work at all, now that undo_UI was split out of undo_manager? [bruce 071217 Q]
    import foundation.undo_archive as undo_archive
    reload(undo_archive)
    import foundation.undo_manager as undo_manager
    reload(undo_manager)
    import foundation.undo_internals as undo_internals
    reload(undo_internals)
    print "\nreloaded 3 out of 4 undo_*.py files; open a new file and we'll use them\n" #e (works, but should make reopen automatic)

register_debug_menu_command("reload undo", reload_undo)

# ==

def keep_under_key(thing, key, obj, attr):
    """
    obj.attr[key] = thing, creating obj.attr dict if necessary
    """
    if DEBUG_PRINT_UNDO and 0:
        print "keepkey:",key,"keepon_obj:",obj # also print attr to be complete
            # This shows unique keys, but just barely (name is deleg for lots of QActions)
            # so we'll have to worry about it, and maybe force all keys unique during init.
            # If some keys are not unique, result might be that some user actions
            # (or for worse bugs, internal signals) silently stop working. [bruce 050921]
    if not hasattr(obj, attr):
        setattr(obj, attr, {})
Beispiel #16
0
def initialize():
    debug.register_debug_menu_command("%s" % cmdname, select_bad_atoms_cmd)
Beispiel #17
0
        atomset = dict(
            atomset
        )  # copy it, since we shouldn't really add singlets to assy.selatoms...
        for atom in atomset.values(
        ):  # not itervalues, we're changing it in the loop!
            # BTW Python is nicer about this than I expected:
            # exceptions.RuntimeError: dictionary changed size during iteration
            for bp in atom.singNeighbors(
            ):  # likely bugs if these are not added into the set!
                atomset[bp.key] = bp
            assy = atom.molecule.assy  # these are all the same, and we do this at least once
        chunk = BorrowerChunk(assy, atomset)
        if do_addmol:
            win.assy.addmol(chunk)
        import __main__
        __main__._bc = chunk
        env.history.message(
            orangemsg("__main__._bc = %s (for debugging only)" %
                      quote_html(safe_repr(chunk))))
    win.win_update()  #k is this done by caller?
    return


# ==

register_debug_menu_command("make BorrowerChunk", debug_make_BorrowerChunk)
register_debug_menu_command("make BorrowerChunk (no addmol)",
                            debug_make_BorrowerChunk_no_addmol)

# end
def _register_our_debug_menu_commands():
    register_debug_menu_command("DNA: rescan all atoms", rescan_all_atoms)
    register_debug_menu_command("DNA: rescan selected atoms",
                                rescan_selected_atoms)
    register_debug_menu_command("DNA: add basepair handles",
                                add_basepair_handles_to_selected_atoms)
        # otherwise, explicit gl_update iight be needed.
        return

    detailLevel = property( _get_detailLevel,
                             _set_detailLevel,
                             doc = "detail level of spheres (when made of triangles)"
                            )

    pass

# == UI for entering this command

def _enter_test_graphics_command(glpane):
    glpane.assy.w.enterOrExitTemporaryCommand('TEST_GRAPHICS')

register_debug_menu_command( "Test Graphics Performance ...", _enter_test_graphics_command )

# or for entering at startup due to debug_pref:

def enter_TestGraphics_Command_at_startup(win):
    """
    Meant to be called only from startup_misc.just_before_event_loop().
    To cause this to be called then (in current code as of 081006),
    set the debug_pref "startup in Test Graphics command (next session)?".
    """
    # set properties the way we want them (from globals in test_drawing module).
    # KLUGE: this has to be done before entering command, so UI in
    # command.propMgr is set up properly.
    from prototype import test_drawing
    cached_command_instance = win.commandSequencer._find_command_instance( 'TEST_GRAPHICS')
    cached_command_instance.bypass_paintgl = True
    detailLevel = property(
        _get_detailLevel,
        _set_detailLevel,
        doc="detail level of spheres (when made of triangles)")

    pass


# == UI for entering this command


def _enter_test_graphics_command(glpane):
    glpane.assy.w.enterOrExitTemporaryCommand('TEST_GRAPHICS')


register_debug_menu_command("Test Graphics Performance ...",
                            _enter_test_graphics_command)

# or for entering at startup due to debug_pref:


def enter_TestGraphics_Command_at_startup(win):
    """
    Meant to be called only from startup_misc.just_before_event_loop().
    To cause this to be called then (in current code as of 081006),
    set the debug_pref "startup in Test Graphics command (next session)?".
    """
    # set properties the way we want them (from globals in test_drawing module).
    # KLUGE: this has to be done before entering command, so UI in
    # command.propMgr is set up properly.
    from prototype import test_drawing
    cached_command_instance = win.commandSequencer._find_command_instance(
Beispiel #21
0
def initialize():
    debug.register_debug_menu_command("%s" % cmdname, select_bad_atoms_cmd)
Beispiel #22
0
def initialize(): # called from startup_misc.py
    if EndUser.enableDeveloperFeatures():
        register_debug_menu_command( "Import all source files", import_all_modules_cmd )
        register_debug_menu_command( "Export command table", export_command_table_cmd )
    return