예제 #1
0
 def modifyAdjustAll(self):
     """
     Adjust all atoms.
     """
     if debug_flags.atom_debug:
         print "debug: reloading sim_commandruns on each use, for development"
         import simulation.sim_commandruns as sim_commandruns
         reload_once_per_event(sim_commandruns)
     from simulation.sim_commandruns import Minimize_CommandRun
     cmdrun = Minimize_CommandRun( self, 'All', type = 'Adjust')
     cmdrun.run()
     return
예제 #2
0
 def modifyAdjustAll(self):
     """
     Adjust all atoms.
     """
     if debug_flags.atom_debug:
         print "debug: reloading sim_commandruns on each use, for development"
         import simulation.sim_commandruns as sim_commandruns
         reload_once_per_event(sim_commandruns)
     from simulation.sim_commandruns import Minimize_CommandRun
     cmdrun = Minimize_CommandRun( self, 'All', type = 'Adjust')
     cmdrun.run()
     return
예제 #3
0
def reload_once(module):
    """
    This function is used to support automatic runtime reloading of modules
    within this package, for developer convenience. To use it, add this code
    before any import of symbols from a module (or use this code in place of
    any direct import of a module):

    #  import module
    #  reload_once(module)

    Warning: not all modules support runtime reload. Those that don't should
    say so in their docstrings.
    
    Warning: this system does not yet properly handle indirect imports, when
    only the inner module has been modified. See code comments for details,
    especially the docstring of debug.reload_once_per_event(). As a workaround,
    if A imports B and you edit B.py, also edit A.py in order to trigger the
    desired runtime reload of B.py.
    """

    # this comment become obsolete when exprs.basic was split into separate files:
    ##Note: this function's module (exprs.basic itself) is fast and harmless enough to reload that it can be
    ##reloaded on every use, without bothering to use reload_once. Therefore, external callers of anything
    ##in the exprs package can always "import basic;reload(basic)" first, and if they do, all modules within
    ##exprs can just start with "from basic import *". But for clarity, some of them call reload_once on basic too.

    if (
            not EndUser.enableDeveloperFeatures()
    ):  #070627 precaution; should improve by making this only affect default value of a debug_pref ###TODO
        return

    if not ENABLE_RELOAD:

        def printfyi(
            msg
        ):  # WARNING: dup code, inlining py_utils version since not yet imported
            msg = "fyi (printonce): " + msg
            from foundation.env import seen_before
            if not seen_before(msg):
                print msg

        if 1:
            ## printfyi( "exprs modules won't be reloaded during this session" ) # 070627 removed this
            return
    reload_once_per_event(module,
                          always_print=True,
                          never_again=False,
                          counter=exprs_globals.reload_counter,
                          check_modtime=True)
    return
예제 #4
0
 def localmin(self, atom, nlayers): #bruce 051207 #e might generalize to 
                                    #take a list or pair of atoms, other 
                                    #options
     if debug_flags.atom_debug:
         print "debug: reloading sim_commandruns on each use, for development"\
               "[localmin %s, %d]" % (atom, nlayers)
         import simulation.sim_commandruns as sim_commandruns
         reload_once_per_event(sim_commandruns) #bruce 060705 revised this
     if 1:
         # this does not work, 
         #I don't know why, should fix sometime: [bruce 060705]
         self.set_cmdname("Adjust Atoms") # for Undo (should we be more 
                                          #specific, like the menu text was? 
                                          #why didn't that get used?)
     from simulation.sim_commandruns import LocalMinimize_function # should not be toplevel
     LocalMinimize_function( [atom], nlayers )
     return
 def localmin(self, atom, nlayers): #bruce 051207 #e might generalize to 
                                    #take a list or pair of atoms, other 
                                    #options
     if debug_flags.atom_debug:
         print "debug: reloading sim_commandruns on each use, for development"\
               "[localmin %s, %d]" % (atom, nlayers)
         import simulation.sim_commandruns as sim_commandruns
         reload_once_per_event(sim_commandruns) #bruce 060705 revised this
     if 1:
         # this does not work, 
         #I don't know why, should fix sometime: [bruce 060705]
         self.set_cmdname("Adjust Atoms") # for Undo (should we be more 
                                          #specific, like the menu text was? 
                                          #why didn't that get used?)
     from simulation.sim_commandruns import LocalMinimize_function # should not be toplevel
     LocalMinimize_function( [atom], nlayers )
     return
예제 #6
0
def reload_once(module):
    """
    This function is used to support automatic runtime reloading of modules
    within this package, for developer convenience. To use it, add this code
    before any import of symbols from a module (or use this code in place of
    any direct import of a module):

    #  import module
    #  reload_once(module)

    Warning: not all modules support runtime reload. Those that don't should
    say so in their docstrings.
    
    Warning: this system does not yet properly handle indirect imports, when
    only the inner module has been modified. See code comments for details,
    especially the docstring of debug.reload_once_per_event(). As a workaround,
    if A imports B and you edit B.py, also edit A.py in order to trigger the
    desired runtime reload of B.py.
    """

    # this comment become obsolete when exprs.basic was split into separate files:    
    ##Note: this function's module (exprs.basic itself) is fast and harmless enough to reload that it can be
    ##reloaded on every use, without bothering to use reload_once. Therefore, external callers of anything
    ##in the exprs package can always "import basic;reload(basic)" first, and if they do, all modules within
    ##exprs can just start with "from basic import *". But for clarity, some of them call reload_once on basic too.
    
    if (not EndUser.enableDeveloperFeatures()): #070627 precaution; should improve by making this only affect default value of a debug_pref ###TODO
        return
    
    if not ENABLE_RELOAD:
        def printfyi(msg): # WARNING: dup code, inlining py_utils version since not yet imported
            msg = "fyi (printonce): " + msg
            from foundation.env import seen_before
            if not seen_before(msg):
                print msg
        if 1:
            ## printfyi( "exprs modules won't be reloaded during this session" ) # 070627 removed this
            return
    reload_once_per_event(module,
                          always_print = True,
                          never_again = False,
                          counter = exprs_globals.reload_counter,
                          check_modtime = True)
    return
예제 #7
0
    def ok_btn_clicked(self):
        """
        Slot for OK button
        """
        QDialog.accept(self)
        if env.debug():
            print "ok"
        self.gather_parameters()
        ### kluge: has side effect on env.prefs
        # (should we pass these as arg to Minimize_CommandRun rather than thru env.prefs??)
        if debug_flags.atom_debug:
            print "debug: reloading runSim & sim_commandruns on each use, for development"
            import simulation.runSim as runSim
            reload_once_per_event(runSim)
            # bug: only works some of the times runSim.py is modified,
            # don't know why; might be that sim_commandruns.py
            # also needs to be modified, but touching them both
            # doesn't seem to work consistently either.
            # [bruce 080520]
            import simulation.sim_commandruns as sim_commandruns
            reload_once_per_event(sim_commandruns)
        from simulation.sim_commandruns import Minimize_CommandRun
        # do this in gather?
        if self.minimize_all_rbtn.isChecked():
            self.seltype = 'All'
            seltype_name = "All"
        else:
            self.seltype = 'Sel'
            seltype_name = "Selection"
        self.win.assy.current_command_info(
            cmdname=self.plain_cmdname +
            " (%s)" % seltype_name)  # cmdname for Undo

        update_cond = self.ruc.get_update_cond_from_widgets()
        engine = self.minimize_engine_combobox.currentIndex()
        env.prefs[Minimize_minimizationEngine_prefs_key] = engine
        cmdrun = Minimize_CommandRun(self.win,
                                     self.seltype,
                                     type='Minimize',
                                     update_cond=update_cond,
                                     engine=engine)
        cmdrun.run()
        return
예제 #8
0
    def ok_btn_clicked(self):
        """
        Slot for OK button
        """
        QDialog.accept(self)
        if env.debug():
            print "ok"
        self.gather_parameters()
        ### kluge: has side effect on env.prefs
        # (should we pass these as arg to Minimize_CommandRun rather than thru env.prefs??)
        if debug_flags.atom_debug:
            print "debug: reloading runSim & sim_commandruns on each use, for development"
            import simulation.runSim as runSim
            reload_once_per_event(runSim)
                # bug: only works some of the times runSim.py is modified,
                # don't know why; might be that sim_commandruns.py
                # also needs to be modified, but touching them both
                # doesn't seem to work consistently either.
                # [bruce 080520]
            import simulation.sim_commandruns as sim_commandruns
            reload_once_per_event(sim_commandruns)
        from simulation.sim_commandruns import Minimize_CommandRun
        # do this in gather?
        if self.minimize_all_rbtn.isChecked():
            self.seltype = 'All'
            seltype_name = "All"
        else:
            self.seltype = 'Sel'
            seltype_name = "Selection"
        self.win.assy.current_command_info(cmdname = self.plain_cmdname + " (%s)" % seltype_name) # cmdname for Undo

        update_cond = self.ruc.get_update_cond_from_widgets()
        engine = self.minimize_engine_combobox.currentIndex()
        env.prefs[Minimize_minimizationEngine_prefs_key] = engine
        cmdrun = Minimize_CommandRun( self.win, self.seltype, type = 'Minimize', update_cond = update_cond, engine = engine)
        cmdrun.run()
        return