def saveFavorite(self):
     """
     Writes the current favorite (selected in the combobox) to a file, any 
     where in the disk that 
     can be given to another NE1 user (i.e. as an email attachment).
     """
     
     cmd = greenmsg("Save Favorite File: ")
     env.history.message(greenmsg("Save Favorite File:"))
     current_favorite = self.favoritesComboBox.currentText()
     favfilepath = getFavoritePathFromBasename(current_favorite)
     
     formats = \
                 "Favorite (*.txt);;"\
                 "All Files (*.*)"
      
     
     fn = QFileDialog.getSaveFileName(
         self, 
         "Save Favorite As", # caption
         favfilepath, #where to save
         formats, # file format options
         QString("Favorite (*.txt)") # selectedFilter
         )
     if not fn:
         env.history.message(cmd + "Cancelled")
     
     else:
         saveFavoriteFile(str(fn), favfilepath)
     return
    def saveFavorite(self):

        cmd = greenmsg("Save Favorite File: ")
        env.history.message(greenmsg("Save Favorite File:"))
        current_favorite = self.favoritesComboBox.currentText()
        favfilepath = getFavoritePathFromBasename(current_favorite)

        formats = \
                "Favorite (*.txt);;"\
                "All Files (*.*)"

        directory = self.currentWorkingDirectory
        saveLocation = directory + "/" + current_favorite + ".txt"

        fn = QFileDialog.getSaveFileName(
            self,
            "Save Favorite As",  # caption
            favfilepath,  #where to save
            formats,  # file format options
            QString("Favorite (*.txt)")  # selectedFilter
        )
        if not fn:
            env.history.message(cmd + "Cancelled")

        else:
            dir, fil = os.path.split(str(fn))
            self.setCurrentWorkingDirectory(dir)
            saveFavoriteFile(str(fn), favfilepath)
        return
    def saveFavorite(self):
        """
        Writes the current favorite (selected in the combobox) to a file, any 
        where in the disk that 
        can be given to another NE1 user (i.e. as an email attachment).
        """

        cmd = greenmsg("Save Favorite File: ")
        env.history.message(greenmsg("Save Favorite File:"))
        current_favorite = self.favoritesComboBox.currentText()
        favfilepath = getFavoritePathFromBasename(current_favorite)

        formats = \
                    "Favorite (*.txt);;"\
                    "All Files (*.*)"

        fn = QFileDialog.getSaveFileName(
            self,
            "Save Favorite As",  # caption
            favfilepath,  #where to save
            formats,  # file format options
            QString("Favorite (*.txt)")  # selectedFilter
        )
        if not fn:
            env.history.message(cmd + "Cancelled")

        else:
            saveFavoriteFile(str(fn), favfilepath)
        return
Example #4
0
 def saveFavorite(self):
     """
     Save favorite file in a user chosen location
     """
     cmd = greenmsg("Save Favorite File: ")
     env.history.message(greenmsg("Save Favorite File:"))
     current_favorite = self.favoritesComboBox.currentText()
     favfilepath = getFavoritePathFromBasename(current_favorite)
     formats = \
             "Favorite (*.txt);;"\
             "All Files (*.*)"
     directory = self.currentWorkingDirectory
     saveLocation = directory + "/" + current_favorite + ".txt"
     fn = QFileDialog.getSaveFileName(
         self,
         "Save Favorite As", # caption
         favfilepath, #where to save
         formats, # file format options
         QString("Favorite (*.txt)") # selectedFilter
         )
     if not fn:
         env.history.message(cmd + "Cancelled")
     else:
         dir, fil = os.path.split(str(fn))
         self.setCurrentWorkingDirectory(dir)
         saveFavoriteFile(str(fn), favfilepath)
     return
Example #5
0
def editMakeCheckpoint(win):
    """
    This is called from MWsemantics.editMakeCheckpoint,
    which is documented as:

      "Slot for making a checkpoint (only available when
       Automatic Checkpointing is disabled)."
    """
    env.history.message(greenmsg("Make Checkpoint"))
    # do it
    try:
        #REVIEW: Should make sure this is correct with or without
        # auto-checkpointing enabled, and leaves that setting unchanged.
        # (This is not urgent, since in present UI it can't be called
        #  except when auto-checkpointing is disabled.)
        um = win.assy.undo_manager
        if um:
            um.make_manual_checkpoint()
            # no msg needed, was emitted above:
            ## env.history.message(greenmsg("Make Checkpoint"))
            pass
        else:
            # this should never happen
            msg = "Make Checkpoint: error, no undo_manager"
            env.history.message(redmsg(msg))
    except:
        print_compact_traceback("exception caught in editMakeCheckpoint: ")
        msg = "Internal error in Make Checkpoint. " \
              "Undo/Redo might be unsafe until a new file is opened."
        env.history.message(redmsg(msg))
        #e that wording assumes we can't open more than one file at a time...
    return
Example #6
0
    def dispShowInvisAtoms(self):
        """
        Resets the display setting for each invisible atom in the selected
        chunks or atoms to Default display mode.
        """

        cmd = greenmsg("Show Invisible Atoms: ")

        if not self.assy.selmols and not self.assy.selatoms:
            msg = "No atoms or chunks selected."
            env.history.message(cmd + msg)
            return

        nia = 0 # nia = Number of Invisible Atoms

        if self.assy.selmols:
            nia = self.assy.showInvisibleAtoms()

        if self.assy.selectionContainsInvisibleAtoms():
            for a in self.assy.selatoms.itervalues(): #bruce 060707 itervalues
                if a.display == diINVISIBLE: 
                    a.setDisplay(diDEFAULT)
                    nia += 1

        msg = cmd + str(nia) + " invisible atoms found."
        env.history.message(msg)
Example #7
0
    def makeESPImage(self):
        cmd = greenmsg("ESP Image: ")

        atoms = self.assy.selatoms_list()

        if len(atoms) < 3:
            msg = "You must select at least 3 atoms to create an ESP Image."
            env.history.message(cmd + redmsg(msg))
            return

        from analysis.ESP.ESPImage import ESPImage
        m = ESPImage(self.assy, atoms)
        m.edit()
        if m.cancelled:  # User hit 'Cancel' button in the jig dialog.
            env.history.message(cmd + "Cancelled")
            return

        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        # After placing the jig, remove the atom list from the jig.
        m.atoms = []

        env.history.message(cmd + "ESP Image created.")
        self.assy.w.win_update()
        return
Example #8
0
    def makeGridPlane(self):
        cmd = greenmsg("Grid Plane: ")

        atoms = self.assy.selatoms_list()

        if not atoms:
            msg = "You must select 3 or more atoms to create a Grid Plane."
            env.history.message(cmd + redmsg(msg))
            return

        # Make sure only one atom is selected.
        if len(atoms) < 3:
            msg = "To create a Grid Plane, at least 3 atoms must be selected."
            env.history.message(cmd + redmsg(msg))
            return

        from model.jigs_planes import GridPlane
        m = GridPlane(self.assy, atoms)
        m.edit()
        if m.cancelled:  # User hit 'Cancel' button in the jig dialog.
            env.history.message(cmd + "Cancelled")
            return

        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        #After placing the jig, remove the atom list from the jig.
        m.atoms = []

        env.history.message(cmd + "Grid Plane created")
        self.assy.w.win_update()
        return
Example #9
0
    def makethermo(self):
        """
        Attaches a thermometer to the single atom selected.
        """
        cmd = greenmsg("Thermometer: ")

        atoms = self.assy.selatoms_list()

        if not atoms:
            msg = "You must select an atom on the chunk you want to " \
                  "associate with a Thermometer."
            env.history.message(cmd + redmsg(msg))
            return

        # Make sure only one atom is selected.
        if len(atoms) != 1:
            msg = "To create a Thermometer, only one atom may be selected."
            env.history.message(cmd + redmsg(msg))
            return

        m = Thermo(self.assy, atoms)
        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        env.history.message(cmd + "Thermometer created")
        self.assy.w.win_update()
Example #10
0
    def makeAnchor(self):
        """
        Anchors the selected atoms so that they will not move
        during a minimization or simulation run.
        """
        cmd = greenmsg("Anchor: ")

        atoms = self.assy.selatoms_list()

        if not atoms:
            msg = "You must select at least one atom to create an Anchor."
            env.history.message(cmd + redmsg(msg))
            return

        # Print warning if over 200 atoms are selected.
        if atom_limit_exceeded_and_confirmed(self.assy.w,
                                             len(atoms),
                                             limit=200):
            return

        m = Anchor(self.assy, atoms)
        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        env.history.message(cmd + "Anchor created")
        self.assy.w.win_update()
Example #11
0
 def setDisplayStyle_of_selection(
         self, display_style):  #bruce 080910 revised this
     """
     Set the display style of the selection to I{display_style}.
     
     @param display_style: desired display style code
     @type  display_style: int   
     """
     if self.assy and self.assy.selatoms:
         for ob in self.assy.selatoms.itervalues():
             ob.setDisplayStyle(display_style)
     elif self.assy and self.assy.selmols:
         for ob in self.assy.selmols:
             ob.setDisplayStyle(display_style)
     elif 0:  # Keep in case we decide to offer a user preference. --Mark 2008-03-16
         # Nothing is selected, so change the global display style.
         self.glpane.setGlobalDisplayStyle(display_style)
     else:
         cmd = greenmsg("Set display style: ")
         msg = "No atoms or chunks selected. Nothing changed."
         env.history.message(cmd + msg)
         return
     self.win_update(
     )  # bruce 041206, needed for model tree display mode icons, as well as glpane
     return
Example #12
0
    def __init__(self, win):
        """
        @param win: the main window object
        """
        self.win = win
        self.pw = None  # pw = part window. Its subclasses will create their
        # partwindow objects (and destroy them after Done)
        ###REVIEW: I think this (assignment or use of self.pw) does not
        # belong in this class [bruce 070615 comment]

        self.struct = None
        self.previousParams = None
        #bruce 060616 added the following kluge to make sure both cmdname and
        # cmd are set properly.
        if not self.cmdname and not self.cmd:
            self.cmdname = "Generate something"
        if self.cmd and not self.cmdname:
            # deprecated but common, as of 060616
            self.cmdname = self.cmd  # fallback value; usually reassigned below
            try:
                cmdname = self.cmd.split('>')[1]
                cmdname = cmdname.split('<')[0]
                cmdname = cmdname.split(':')[0]
                self.cmdname = cmdname
            except:
                if debug_flags.atom_debug:
                    print "fyi: %r guessed wrong about format of self.cmd == %r" \
                          % (self, self.cmd,)
                pass
        elif self.cmdname and not self.cmd:
            # this is intended to be the usual situation, but isn't yet, as of
            # 060616
            self.cmd = greenmsg(self.cmdname + ": ")
        self.change_random_seed()
        return
Example #13
0
 def unselectConnected(self, atomlist=None):
     """
     Unselect any atom that can be reached from any currently
     selected atom through a sequence of bonds.
     If <atomlist> is supplied, use it instead of the currently selected atoms.
     """
     cmd = greenmsg("Unselect Connected: ")
     
     if atomlist is None and not self.selatoms:
         msg = redmsg("No atoms selected")
         env.history.message(cmd + msg)
         return
     
     if atomlist is None: # test for None since atomlist can be an empty list.
         atomlist = self.selatoms.values()
         
     catoms = self.getConnectedAtoms(atomlist)
     if not len(catoms): return
     
     natoms = 0
     for atom in catoms[:]:
         if atom.picked:
             atom.unpick()
             if not atom.picked:
                 # Just in case a selection filter was applied to this atom.
                 natoms += 1 
     
     from platform_dependent.PlatformDependent import fix_plurals
     info = fix_plurals( "%d atom(s) unselected." % natoms)
     env.history.message( cmd + info)
     self.o.gl_update()
    def selectDoubly(self):
        """
        Select any atom that can be reached from any currently
        selected atom through two or more non-overlapping sequences of
        bonds. Also select atoms that are connected to this group by
        one bond and have no other bonds.
        """
        ###@@@ same comment about interspace bonds as in selectConnected

        cmd = greenmsg("Select Doubly: ")

        if not self.selatoms:
            msg = redmsg("No atoms selected")
            env.history.message(cmd + msg)
            return

        alreadySelected = len(self.selatoms.values())
        from operations.op_select_doubly import select_doubly # new code, bruce 050520
        #e could also reload it now to speed devel!
        select_doubly(self.selatoms.values()) #e optim
        totalSelected = len(self.selatoms.values())

        from platform_dependent.PlatformDependent import fix_plurals
        info = fix_plurals("%d new atom(s) selected (besides the %d initially selected)." % \
                               (totalSelected - alreadySelected, alreadySelected) )
        env.history.message( cmd + info)

        if totalSelected > alreadySelected:
            ## otherwise, means nothing new selected. Am I right? ---Huaicai, not analyze the markdouble() algorithm yet
            #self.w.win_update()
            self.o.gl_update()
        return
Example #15
0
    def viewParallelTo(self):
        """
        Set view parallel to the vector defined by 2 selected atoms.
        """
        cmd = greenmsg("Set View Parallel To: ")

        atoms = self.assy.selatoms_list()

        if len(atoms) != 2:
            msg = redmsg("You must select 2 atoms.")
            env.history.message(cmd + msg)
            return

        v = norm(atoms[0].posn()-atoms[1].posn())

        if vlen(v) < 0.0001: # Atoms are on top of each other.
            info = 'The selected atoms are on top of each other.  No change in view.'
            env.history.message(cmd + info)
            return

        # If vec is pointing into the screen, negate (reverse) vec.
        if dot(v, self.glpane.lineOfSight) > 0:
            v = -v

        # Compute the destination quat (q2).
        q2 = Q(V(0,0,1), v)
        q2 = q2.conj()

        self.glpane.rotateView(q2)

        info = 'View set parallel to the vector defined by the 2 selected atoms.'
        env.history.message(cmd + info)
Example #16
0
 def __init__(self, win):
     """
     @param win: the main window object
     """
     self.win = win
     self.pw = None # pw = part window. Its subclasses will create their
         # partwindow objects (and destroy them after Done)
         ###REVIEW: I think this (assignment or use of self.pw) does not
         # belong in this class [bruce 070615 comment]
         
     self.struct = None
     self.previousParams = None
     #bruce 060616 added the following kluge to make sure both cmdname and
     # cmd are set properly.
     if not self.cmdname and not self.cmd:
         self.cmdname = "Generate something"
     if self.cmd and not self.cmdname:
         # deprecated but common, as of 060616
         self.cmdname = self.cmd # fallback value; usually reassigned below
         try:
             cmdname = self.cmd.split('>')[1]
             cmdname = cmdname.split('<')[0]
             cmdname = cmdname.split(':')[0]
             self.cmdname = cmdname
         except:
             if debug_flags.atom_debug:
                 print "fyi: %r guessed wrong about format of self.cmd == %r" \
                       % (self, self.cmd,)
             pass
     elif self.cmdname and not self.cmd:
         # this is intended to be the usual situation, but isn't yet, as of
         # 060616
         self.cmd = greenmsg(self.cmdname + ": ")
     self.change_random_seed()
     return
Example #17
0
def editMakeCheckpoint(win):
    """
    This is called from MWsemantics.editMakeCheckpoint,
    which is documented as:

      "Slot for making a checkpoint (only available when
       Automatic Checkpointing is disabled)."
    """
    env.history.message( greenmsg("Make Checkpoint")) 
    # do it
    try:
        #REVIEW: Should make sure this is correct with or without
        # auto-checkpointing enabled, and leaves that setting unchanged.
        # (This is not urgent, since in present UI it can't be called
        #  except when auto-checkpointing is disabled.)
        um = win.assy.undo_manager 
        if um:
            um.make_manual_checkpoint()
            # no msg needed, was emitted above:
            ## env.history.message(greenmsg("Make Checkpoint"))
            pass
        else:
            # this should never happen
            msg = "Make Checkpoint: error, no undo_manager"
            env.history.message(redmsg(msg))
    except:
        print_compact_traceback("exception caught in editMakeCheckpoint: ")
        msg = "Internal error in Make Checkpoint. " \
              "Undo/Redo might be unsafe until a new file is opened."
        env.history.message(redmsg(msg))
            #e that wording assumes we can't open more than one file at a time...
    return
    def __CM_Align_to_chunk(self):
        """
        Rotary or Linear Motor context menu command: "Align to chunk"
        This uses the chunk connected to the first atom of the motor.
        """
        # I needed this when attempting to simulate the rotation of a long, skinny
        # chunk.  The axis computed from the attached atoms was not close to the axis
        # of the chunk.  I figured this would be a common feature that was easy to add.
        # 
        ##e it might be nice to dim this menu item if the chunk's axis hasn't moved since this motor was made or recentered;
        # first we'd need to extend the __CM_ API to make that possible. [mark 050717]

        cmd = greenmsg("Align to Chunk: ")

        chunk = self.atoms[0].molecule # Get the chunk attached to the motor's first atom.
        # wware 060116 bug 1330
        # The chunk's axis could have its direction exactly reversed and be equally valid.
        # We should choose between those two options for which one has the positive dot
        # product with the old axis, to avoid reversals of motor direction when going
        # between "align to chunk" and "recenter on atoms".
        #bruce 060116 modified this fix to avoid setting axis to V(0,0,0) if it's perpendicular to old axis.
        newAxis = chunk.getaxis()
        if dot(self.axis,newAxis) < 0:
            newAxis = - newAxis
        self.axis = newAxis
        self.assy.changed()   # wware 060116 bug 1331 - assembly changed when axis changed

        info = "Aligned motor [%s] on chunk [%s]" % (self.name, chunk.name) 
        env.history.message( cmd + info ) 
        self.assy.w.win_update()

        return
Example #19
0
    def calculate_energy(self):
        """
        Calculate energy.
        """

        cmd = greenmsg("Calculate Energy: ")

        errmsgs = ["GAMESS job aborted.", "Error: GAMESS job failed."]

        pset = self.pset
        runtyp = pset.ui.runtyp  # Save runtyp (Calculate) setting to restore it later.
        pset.ui.runtyp = 0  # Energy calculation
        origCalType = self.gmsjob.Calculation
        self.gmsjob.Calculation = 'Energy'

        self.update_gamess_parms()

        # Run GAMESS job.  Return value r:
        # 0 = success
        # 1 = job aborted
        # 2 = job failed.
        r = self.gmsjob.launch()

        pset.ui.runtyp = runtyp  # Restore to original value
        self.gmsjob.Calculation = origCalType

        if r:  # Job was aborted or an error occurred.
            msg = redmsg(errmsgs[r - 1])
            env.history.message(cmd + msg)
            return

        self.print_energy()
Example #20
0
    def merge(self):
        """
        Merges selected atoms into a single chunk, or merges the selected
        chunks into a single chunk.
        
        @note: If the selected atoms belong to the same chunk, nothing happens.
        """
        #mark 050411 changed name from weld to merge (Bug 515)
        #bruce 050131 comment: might now be safe for clipboard items
        # since all selection is now forced to be in the same one;
        # this is mostly academic since there's no pleasing way to use it on them,
        # though it's theoretically possible (since Groups can be cut and maybe copied).

        cmd = greenmsg("Combine Chunks: ")

        if self.selatoms:
            self.makeChunkFromSelectedAtoms()
            return

        if len(self.selmols) < 2:
            msg = redmsg("Need two or more selected chunks to merge")
            env.history.message(cmd + msg)
            return
        self.changed()  #bruce 050131 bugfix or precaution
        mol = self.selmols[0]
        for m in self.selmols[1:]:
            mol.merge(m)
    def makeESPImage(self):
        cmd = greenmsg("ESP Image: ")

        atoms = self.assy.selatoms_list()

        if len(atoms) < 3:
            msg = "You must select at least 3 atoms to create an ESP Image."
            env.history.message(cmd + redmsg(msg))
            return

        from analysis.ESP.ESPImage import ESPImage
        m = ESPImage(self.assy, atoms)
        m.edit()
        if m.cancelled: # User hit 'Cancel' button in the jig dialog.
            env.history.message(cmd + "Cancelled")
            return

        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        # After placing the jig, remove the atom list from the jig.
        m.atoms = []

        env.history.message(cmd + "ESP Image created.")
        self.assy.w.win_update()
        return
    def unselectConnected(self, atomlist=None):
        """
        Unselect any atom that can be reached from any currently
        selected atom through a sequence of bonds.
        If <atomlist> is supplied, use it instead of the currently selected atoms.
        """
        cmd = greenmsg("Unselect Connected: ")

        if atomlist is None and not self.selatoms:
            msg = redmsg("No atoms selected")
            env.history.message(cmd + msg)
            return

        if atomlist is None: # test for None since atomlist can be an empty list.
            atomlist = self.selatoms.values()

        catoms = self.getConnectedAtoms(atomlist)
        if not len(catoms): return

        natoms = 0
        for atom in catoms[:]:
            if atom.picked:
                atom.unpick()
                if not atom.picked:
                    # Just in case a selection filter was applied to this atom.
                    natoms += 1

        from platform_dependent.PlatformDependent import fix_plurals
        info = fix_plurals( "%d atom(s) unselected." % natoms)
        env.history.message( cmd + info)
        self.o.gl_update()
    def makethermo(self):
        """
        Attaches a thermometer to the single atom selected.
        """
        cmd = greenmsg("Thermometer: ")

        atoms = self.assy.selatoms_list()

        if not atoms:
            msg = "You must select an atom on the chunk you want to " \
                  "associate with a Thermometer."
            env.history.message(cmd + redmsg(msg))
            return

        # Make sure only one atom is selected.
        if len(atoms) != 1:
            msg = "To create a Thermometer, only one atom may be selected."
            env.history.message(cmd + redmsg(msg))
            return

        m = Thermo(self.assy, atoms)
        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        env.history.message(cmd + "Thermometer created")
        self.assy.w.win_update()
    def makeGridPlane(self):
        cmd = greenmsg("Grid Plane: ")

        atoms = self.assy.selatoms_list()

        if not atoms:
            msg = "You must select 3 or more atoms to create a Grid Plane."
            env.history.message(cmd + redmsg(msg))
            return

        # Make sure only one atom is selected.
        if len(atoms) < 3:
            msg = "To create a Grid Plane, at least 3 atoms must be selected."
            env.history.message(cmd + redmsg(msg))
            return

        from model.jigs_planes import GridPlane
        m = GridPlane(self.assy, atoms)
        m.edit()
        if m.cancelled: # User hit 'Cancel' button in the jig dialog.
            env.history.message(cmd + "Cancelled")
            return

        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        #After placing the jig, remove the atom list from the jig.
        m.atoms = []

        env.history.message(cmd + "Grid Plane created")
        self.assy.w.win_update()
        return
Example #25
0
 def selectDoubly(self):
     """
     Select any atom that can be reached from any currently
     selected atom through two or more non-overlapping sequences of
     bonds. Also select atoms that are connected to this group by
     one bond and have no other bonds.
     """
     ###@@@ same comment about interspace bonds as in selectConnected
     
     cmd = greenmsg("Select Doubly: ")
     
     if not self.selatoms:
         msg = redmsg("No atoms selected")
         env.history.message(cmd + msg)
         return
     
     alreadySelected = len(self.selatoms.values())
     from operations.op_select_doubly import select_doubly # new code, bruce 050520
     #e could also reload it now to speed devel!
     select_doubly(self.selatoms.values()) #e optim
     totalSelected = len(self.selatoms.values())
     
     from platform_dependent.PlatformDependent import fix_plurals
     info = fix_plurals("%d new atom(s) selected (besides the %d initially selected)." % \
                            (totalSelected - alreadySelected, alreadySelected) )
     env.history.message( cmd + info)
             
     if totalSelected > alreadySelected:
         ## otherwise, means nothing new selected. Am I right? ---Huaicai, not analyze the markdouble() algorithm yet 
         #self.w.win_update()
         self.o.gl_update()
     return
    def makeAnchor(self):
        """
        Anchors the selected atoms so that they will not move
        during a minimization or simulation run.
        """
        cmd = greenmsg("Anchor: ")

        atoms = self.assy.selatoms_list()

        if not atoms:
            msg = "You must select at least one atom to create an Anchor."
            env.history.message(cmd + redmsg(msg))
            return

        # Print warning if over 200 atoms are selected.
        if atom_limit_exceeded_and_confirmed(self.assy.w,
                                             len(atoms),
                                             limit=200):
            return

        m = Anchor(self.assy, atoms)
        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        env.history.message(cmd + "Anchor created")
        self.assy.w.win_update()
Example #27
0
 def calculate_energy(self):
     """
     Calculate energy.
     """
     
     cmd = greenmsg("Calculate Energy: ")
     
     errmsgs = ["GAMESS job aborted.",
                         "Error: GAMESS job failed."]
                         
     pset = self.pset
     runtyp = pset.ui.runtyp # Save runtyp (Calculate) setting to restore it later.
     pset.ui.runtyp = 0 # Energy calculation
     origCalType = self.gmsjob.Calculation
     self.gmsjob.Calculation = 'Energy'
     
     self.update_gamess_parms()
     
     # Run GAMESS job.  Return value r:
     # 0 = success
     # 1 = job aborted
     # 2 = job failed.
     r = self.gmsjob.launch()
     
     pset.ui.runtyp = runtyp # Restore to original value
     self.gmsjob.Calculation = origCalType
     
     if r: # Job was aborted or an error occurred.
         msg = redmsg(errmsgs[r-1])
         env.history.message( cmd + msg )
         return
         
     self.print_energy()
Example #28
0
    def merge(self):
        """
        Merges selected atoms into a single chunk, or merges the selected
        chunks into a single chunk.

        @note: If the selected atoms belong to the same chunk, nothing happens.
        """
        #mark 050411 changed name from weld to merge (Bug 515)
        #bruce 050131 comment: might now be safe for clipboard items
        # since all selection is now forced to be in the same one;
        # this is mostly academic since there's no pleasing way to use it on them,
        # though it's theoretically possible (since Groups can be cut and maybe copied).

        cmd = greenmsg("Combine Chunks: ")

        if self.selatoms:
            self.makeChunkFromSelectedAtoms()
            return

        if len(self.selmols) < 2:
            msg = redmsg("Need two or more selected chunks to merge")
            env.history.message(cmd + msg)
            return
        self.changed() #bruce 050131 bugfix or precaution
        mol = self.selmols[0]
        for m in self.selmols[1:]:
            mol.merge(m)
Example #29
0
    def modifyHydrogenate(self):
        """
        Add hydrogen atoms to bondpoints on selected chunks/atoms.
        """
        cmd = greenmsg("Hydrogenate: ")
        
        fixmols = {} # helps count modified mols for statusbar
        if self.selmols:
            counta = countm = 0
            for m in self.selmols:
                changed = m.Hydrogenate()
                if changed:
                    counta += changed
                    countm += 1
                    fixmols[id(m)] = m
            if counta:
                didwhat = "Added %d atom(s) to %d chunk(s)" \
                          % (counta, countm)
                if len(self.selmols) > countm:
                    didwhat += \
                        " (%d selected chunk(s) had no bondpoints)" \
                        % (len(self.selmols) - countm)
                didwhat = fix_plurals(didwhat)
            else:
                didwhat = "Selected chunks contain no bondpoints"    

        elif self.selatoms:
            count = 0
            for a in self.selatoms.values():
                ma = a.molecule
                for atm in a.neighbors():
                    matm = atm.molecule
                    changed = atm.Hydrogenate()
                    if changed:
                        count += 1
                        fixmols[id(ma)] = ma
                        fixmols[id(matm)] = matm
            if fixmols:
                didwhat = \
                    "Added %d atom(s) to %d chunk(s)" \
                    % (count, len(fixmols))
                didwhat = fix_plurals(didwhat)
                # Technically, we *should* say ", affected" instead of "from"
                # since the count includes mols of neighbors of
                # atoms we removed, not always only mols of atoms we removed.
                # Since that's rare, we word this assuming it didn't happen.
                # [#e needs low-pri fix to be accurate in that rare case;
                #  might as well deliver that as a warning, since that case is
                #  also "dangerous" in some sense.]
            else:
                didwhat = "No bondpoints on selected atoms"
        else:
            didwhat = redmsg("Nothing selected")

        if fixmols:
            self.changed()
            self.w.win_update()
        env.history.message(cmd + didwhat)
        return
Example #30
0
 def setViewHomeToCurrent(self):
     """
     Changes Home view of the model to the current view in the glpane.
     """
     cmd = greenmsg("Set Home View to Current View: ")
     info = 'Home'
     env.history.message(cmd + info)
     self.glpane.setViewHomeToCurrent()
Example #31
0
 def viewRotateMinus90(self): # Added by Mark. 051013.
     """
     Decrement the current view by 90 degrees around the vertical axis.
     """
     cmd = greenmsg("Rotate View -90 : ")
     info = 'View decremented by 90 degrees'
     env.history.message(cmd + info)
     self.glpane.rotateView(self.glpane.quat + Q(V(0,1,0), -math.pi/2))
Example #32
0
 def setViewHome(self):
     """
     Reset view to Home view
     """
     cmd = greenmsg("Current View: ")
     info = 'Home'
     env.history.message(cmd + info)
     self.glpane.setViewHome()
Example #33
0
 def activateDnaOrigamiEditCommand(self):
     """
     Slot for B{Origami} action.
     """
     msg1 = greenmsg("DNA Origami: ")
     msg2 = "Not implemented yet."
     final_msg = msg1 + msg2
     env.history.message(final_msg)
 def movieInfo(self):
     """
     Prints information about the current movie to the history widget.
     """
     if not self.w.assy.current_movie:
         return
     env.history.message(greenmsg("Movie Information"))
     self.w.assy.current_movie._info()
 def movieInfo(self):
     """
     Prints information about the current movie to the history widget.
     """
     if not self.w.assy.current_movie:
         return
     env.history.message(greenmsg("Movie Information"))
     self.w.assy.current_movie._info()
Example #36
0
 def viewRotate180(self):
     """
     Set view to the opposite of current view.
     """
     cmd = greenmsg("Opposite View: ")
     info = 'Current view opposite to the previous view'
     env.history.message(cmd + info)
     self.glpane.rotateView(self.glpane.quat + Q(V(0,1,0), math.pi))
Example #37
0
 def setViewZoomToSelection(self):
     """
     Zoom to selection (Implemented for only selected jigs and chunks
     """
     cmd = greenmsg("Zoom To Selection:")
     info = ''
     env.history.message(cmd + info)
     self.glpane.setViewZoomToSelection()
Example #38
0
 def setViewFitToWindow(self):
     """
     Fit to Window
     """
     cmd = greenmsg("Fit to Window: ")
     info = ''
     env.history.message(cmd + info)
     self.glpane.setViewFitToWindow()
Example #39
0
 def setViewRecenter(self):
     """
     Recenter the view around the origin of modeling space.
     """
     cmd = greenmsg("Recenter View: ")
     info = 'View Recentered'
     env.history.message(cmd + info)
     self.glpane.setViewRecenter()
Example #40
0
 def activateDnaOrigamiEditCommand(self):
     """
     Slot for B{Origami} action.
     """
     msg1 = greenmsg("DNA Origami: ")
     msg2 = "Not implemented yet."
     final_msg = msg1 + msg2
     env.history.message(final_msg)
Example #41
0
 def change_view(self): #mark 060122
     """
     Change the view to self.
     """
     self.assy.o.animateToView(self.quat, self.scale, self.pov, self.zoomFactor, animate=True)
     
     cmd = greenmsg("Change View: ")
     msg = 'Current view is "%s".' % (self.name)
     env.history.message( cmd + msg )
    def makegamess(self):
        """
        Makes a GAMESS jig from the selected chunks or atoms.
        """
        # [mark 2007-05-07 modified docstring]

        if sys.platform == "win32":
            gms_str = "PC GAMESS"
        else:
            gms_str = "GAMESS"

        cmd = greenmsg(gms_str + ": ")

        atoms = []

        # Get a list of atoms from the selected chunks or atoms.
        atoms = self.assy.selected_atoms_list(
            include_atoms_in_selected_chunks = True)

        if not atoms:
            msg = "At least one atom must be selected to create a " + \
                  gms_str + " jig."
            env.history.message(cmd + redmsg(msg))
            return

        # Make sure that no more than 200 atoms are selected.
        nsa = len(atoms)
        if nsa > 200:
            msg = str(nsa) + " atoms selected.  The limit is 200."
            env.history.message(cmd + redmsg(msg))
            return

        # Bug 742.    Mark 050731.
        if nsa > 50:
            ret = QMessageBox.warning( self.assy.w, "Too many atoms?",
                gms_str + " jigs with more than 50 atoms may take an\n"
                "excessively long time to compute (days or weeks).\n"
                "Are you sure you want to continue?",
                "&Continue", "Cancel", "",
                0, 1 )

            if ret == 1: # Cancel
                return

        from analysis.GAMESS.jig_Gamess import Gamess
        m = Gamess(self.assy, atoms)
        m.edit()
            #bruce 050701 split edit method out of the constructor, so the
            # dialog doesn't show up when the jig is read from an mmp file
        if m.cancelled: # User hit 'Cancel' button in the jig dialog.
            env.history.message(cmd + "Cancelled")
            return
        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        env.history.message(cmd + gms_str + " jig created")
        self.assy.w.win_update()
Example #43
0
    def makegamess(self):
        """
        Makes a GAMESS jig from the selected chunks or atoms.
        """
        # [mark 2007-05-07 modified docstring]

        if sys.platform == "win32":
            gms_str = "PC GAMESS"
        else:
            gms_str = "GAMESS"

        cmd = greenmsg(gms_str + ": ")

        atoms = []

        # Get a list of atoms from the selected chunks or atoms.
        atoms = self.assy.selected_atoms_list(
            include_atoms_in_selected_chunks=True)

        if not atoms:
            msg = "At least one atom must be selected to create a " + \
                  gms_str + " jig."
            env.history.message(cmd + redmsg(msg))
            return

        # Make sure that no more than 200 atoms are selected.
        nsa = len(atoms)
        if nsa > 200:
            msg = str(nsa) + " atoms selected.  The limit is 200."
            env.history.message(cmd + redmsg(msg))
            return

        # Bug 742.    Mark 050731.
        if nsa > 50:
            ret = QMessageBox.warning(
                self.assy.w, "Too many atoms?",
                gms_str + " jigs with more than 50 atoms may take an\n"
                "excessively long time to compute (days or weeks).\n"
                "Are you sure you want to continue?", "&Continue", "Cancel",
                "", 0, 1)

            if ret == 1:  # Cancel
                return

        from analysis.GAMESS.jig_Gamess import Gamess
        m = Gamess(self.assy, atoms)
        m.edit()
        #bruce 050701 split edit method out of the constructor, so the
        # dialog doesn't show up when the jig is read from an mmp file
        if m.cancelled:  # User hit 'Cancel' button in the jig dialog.
            env.history.message(cmd + "Cancelled")
            return
        self.unpickall_in_GLPane()
        self.place_new_jig(m)

        env.history.message(cmd + gms_str + " jig created")
        self.assy.w.win_update()
Example #44
0
    def change_view(self): #mark 060122
        """
        Change the view to self.
        """
        self.assy.o.animateToView(self.quat, self.scale, self.pov, self.zoomFactor, animate=True)

        cmd = greenmsg("Change View: ")
        msg = 'Current view is "%s".' % (self.name)
        env.history.message( cmd + msg )
Example #45
0
    def Mirror(self):
        """
        Mirror the selected chunk(s) about a selected grid plane.
        """
        cmd = greenmsg("Mirror: ")
        #ninad060814 this is necessary to fix a bug. Otherwise program will
        #crash if you try to mirror when the top node of the part
        #(main part of clipboard) is selected

        if self.topnode.picked:
            self.topnode.unpick_top()

        self.mirrorJigs = self.getQualifiedMirrorJigs()

        jigCounter = len(self.mirrorJigs)

        if jigCounter < 1:
            msg1 = "No mirror plane selected."
            msg2 = " Please select a Reference Plane or a Grid Plane first."
            msg = redmsg(msg1 + msg2)
            instr1 = "(If it doesn't exist, create it using"
            instr2 = "<b>Insert > Reference Geometry menu </b> )"
            instruction = instr1 + instr2
            env.history.message(cmd + msg + instruction)
            return
        elif jigCounter > 1:
            msg = redmsg(
                "More than one plane selected. Please select only one plane and try again"
            )
            env.history.message(cmd + msg)
            return

        for j in self.mirrorJigs:
            j.unpick()

        copiedObject = self.o.assy.part.copy_sel_in_same_part()

        # ninad060812 Get the axis vector of the Grid Plane. Then you need to
        #rotate the inverted chunk by pi around this axis vector
        self.mirrorAxis = self.mirrorJigs[0].getaxis()

        if isinstance(copiedObject, Chunk):
            copiedObject.name = copiedObject.name + "-Mirror"
            self._mirrorChunk(copiedObject)
            return
        elif isinstance(copiedObject, Group):
            copiedObject.name = "Mirrored Items"

            def mirrorChild(obj):
                if isinstance(obj, Chunk):
                    self._mirrorChunk(obj)
                elif isinstance(obj, Jig):
                    self._mirrorJig(obj)

            copiedObject.apply2all(mirrorChild)
        return
Example #46
0
 def __CM_Reverse_direction(self): #bruce 060116 new feature (experimental)
     """
     Rotary or Linear Motor context menu command: "Reverse direction"
     """
     cmd = greenmsg("Reverse direction: ")
     self.reverse_direction()
     info = "Reversed direction of motor [%s]" % self.name 
     env.history.message( cmd + info ) 
     self.assy.w.win_update() # (glpane might be enough, but the other updates are fast so don't bother figuring it out)
     return
def add_basepair_handles_to_selected_atoms(glpane): #bruce 080515
    assy = glpane.assy
    goodcount, badcount = add_basepair_handles_to_atoms(assy.selatoms.values())
    msg = "adding handles to %d duplex Gv5 atom(s)" % (goodcount,)
    if badcount:
        msg += " (but not %d other selected atom(s))" % (badcount,)
    msg = fix_plurals(msg)
    env.history.message(greenmsg( "Add basepair handles:") + " " + msg)
    assy.w.win_update()
    return
Example #48
0
 def dispDnaCylinder(self):
     """
     Sets the display style of the selection to I{DNA Cylinder}.
     """
     # This code was copied from dispCylinder(). Mark 2008-02-13.
     cmd = greenmsg("Set Display DNA Cylinder: ")
     if self.assy and self.assy.selatoms:
         env.history.message(cmd + "Selected atoms cannot have their display mode set to DNA Cylinder.")
         return
     self.setDisplay(diDNACYLINDER)