Search in sources :

Example 6 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class GraphicsPicking method updateScene.

/**
 * {@inheritDoc}
 *
 * Called by Java3D when an atom is picked
 */
public void updateScene(int xpos, int ypos) {
    if (picking == false) {
        return;
    }
    // Determine what FNode was picked
    pickCanvas.setShapeLocation(xpos, ypos);
    PickResult result = pickCanvas.pickClosest();
    if (result != null) {
        SceneGraphPath sceneGraphPath = result.getSceneGraphPath();
        Node node = sceneGraphPath.getObject();
        if (!(node instanceof Shape3D)) {
            return;
        }
        Shape3D pickedShape3D = (Shape3D) node;
        Object userData = pickedShape3D.getUserData();
        if (userData instanceof MolecularAssembly) {
            FFXSystem sys = (FFXSystem) userData;
            if (result.numIntersections() > 0) {
                PickIntersection pickIntersection = result.getIntersection(0);
                int[] coords = pickIntersection.getPrimitiveCoordinateIndices();
                userData = sys.getAtomFromWireVertex(coords[0]);
            } else {
                return;
            }
        }
        if (userData instanceof Atom) {
            Atom a = (Atom) userData;
            // Check to see if the pickLevel has changed
            if (!(pickLevel == newPickLevel)) {
                pickLevel = newPickLevel;
                pickNumber = 0;
            }
            // Clear selections between measurements
            String pickLevelString = pickLevel.toString();
            boolean measure = pickLevelString.startsWith("MEASURE");
            if (!measure || count == 0) {
                for (Atom matom : atomCache) {
                    matom.setSelected(false);
                    matom.setColor(RendererCache.ColorModel.SELECT, null, null);
                }
                atomCache.clear();
                count = 0;
            }
            // If measuring, select the current atom and add it to the cache
            if (measure && !atomCache.contains(a)) {
                atomCache.add(0, a);
                a.setSelected(true);
                a.setColor(RendererCache.ColorModel.PICK, null, null);
                count++;
                measure();
            }
            if (!measure) {
                // This allows iteration through the atom's terms
                if (a == previousAtom) {
                    pickNumber++;
                } else {
                    previousAtom = a;
                    pickNumber = 0;
                }
                MSNode currentPick = null;
                switch(pickLevel) {
                    case PICKATOM:
                        currentPick = a;
                        break;
                    case PICKBOND:
                    case PICKANGLE:
                    case PICKDIHEDRAL:
                        ArrayList terms = null;
                        if (pickLevel == PickLevel.PICKBOND) {
                            terms = a.getBonds();
                        } else if (pickLevel == PickLevel.PICKANGLE) {
                            terms = a.getAngles();
                        } else if (pickLevel == PickLevel.PICKDIHEDRAL) {
                            terms = a.getTorsions();
                        }
                        if (terms == null) {
                            return;
                        }
                        int num = terms.size();
                        if (pickNumber >= num) {
                            pickNumber = 0;
                        }
                        currentPick = (BondedTerm) terms.get(pickNumber);
                        break;
                    case PICKRESIDUE:
                    case PICKPOLYMER:
                    case PICKMOLECULE:
                    case PICKSYSTEM:
                        MSNode dataNode = null;
                        if (pickLevel == PickLevel.PICKRESIDUE) {
                            dataNode = (MSNode) a.getMSNode(Residue.class);
                        } else if (pickLevel == PickLevel.PICKPOLYMER) {
                            dataNode = (MSNode) a.getMSNode(Polymer.class);
                        } else if (pickLevel == PickLevel.PICKSYSTEM) {
                            dataNode = (MSNode) a.getMSNode(MolecularAssembly.class);
                        } else if (pickLevel == PickLevel.PICKMOLECULE) {
                            dataNode = (MSNode) a.getMSNode(Molecule.class);
                            if (dataNode == null) {
                                dataNode = (MSNode) a.getMSNode(Polymer.class);
                            }
                        }
                        currentPick = dataNode;
                        break;
                    case MEASUREANGLE:
                    case MEASUREDIHEDRAL:
                    case MEASUREDISTANCE:
                        break;
                }
                // Add the selected node to the Tree View
                if (currentPick != null) {
                    if (controlButton) {
                        mainPanel.getHierarchy().toggleSelection(currentPick);
                    } else if (currentPick != previousPick) {
                        mainPanel.getHierarchy().onlySelection(currentPick);
                    }
                    // Color the Current Pick by Picking Color
                    mainPanel.getGraphics3D().updateScene(currentPick, false, false, null, true, RendererCache.ColorModel.PICK);
                }
                // Remove picking color from the previousPick
                if (previousPick != null && previousPick != currentPick) {
                    previousPick.setColor(RendererCache.ColorModel.REVERT, null, null);
                }
                previousPick = currentPick;
            }
        }
    }
}
Also used : SceneGraphPath(javax.media.j3d.SceneGraphPath) MSNode(ffx.potential.bonded.MSNode) Node(javax.media.j3d.Node) ArrayList(java.util.ArrayList) Polymer(ffx.potential.bonded.Polymer) PickIntersection(com.sun.j3d.utils.picking.PickIntersection) Atom(ffx.potential.bonded.Atom) Molecule(ffx.potential.bonded.Molecule) MolecularAssembly(ffx.potential.MolecularAssembly) MSNode(ffx.potential.bonded.MSNode) PickResult(com.sun.j3d.utils.picking.PickResult) Shape3D(javax.media.j3d.Shape3D)

Example 7 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class GraphicsPicking method clear.

/**
 * Clear currently selected nodes
 */
public void clear() {
    if (previousPick != null) {
        mainPanel.getHierarchy().collapsePath(new TreePath(previousPick.getPath()));
        previousPick.setSelected(false);
        previousPick.setColor(RendererCache.ColorModel.SELECT, null, null);
        previousPick = null;
        pickNumber = 0;
    }
    for (Atom a : atomCache) {
        a.setSelected(false);
        a.setColor(RendererCache.ColorModel.SELECT, null, null);
    }
    atomCache.clear();
}
Also used : TreePath(javax.swing.tree.TreePath) Atom(ffx.potential.bonded.Atom)

Example 8 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class DiffractionData method printStats.

/**
 * print all statistics for all datasets associated with the model
 */
public void printStats() {
    int nat = 0;
    int nnonh = 0;
    /**
     * Note - we are including inactive and/or un-used atoms in the
     * following loop.
     */
    for (Atom a : refinementModel.getTotalAtomList()) {
        if (a.getOccupancy() == 0.0) {
            continue;
        }
        nat++;
        if (a.getAtomicNumber() == 1) {
            continue;
        }
        nnonh++;
    }
    for (int i = 0; i < n; i++) {
        if (!scaled[i]) {
            scaleBulkFit(i);
        }
        StringBuilder sb = new StringBuilder();
        sb.append(String.format(" Statistics for Data Set %d of %d\n\n" + "  Weight:     %6.2f\n  Neutron data: %4s\n" + "  Model:        %s\n  Data file:    %s\n", i + 1, n, dataFiles[i].getWeight(), dataFiles[i].isNeutron(), modelName, dataFiles[i].getFilename()));
        logger.info(sb.toString());
        crystalStats[i].printScaleStats();
        crystalStats[i].printDPIStats(nnonh, nat);
        crystalStats[i].printHKLStats();
        crystalStats[i].printSNStats();
        crystalStats[i].printRStats();
    }
}
Also used : Atom(ffx.potential.bonded.Atom)

Example 9 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class RealSpaceEnergy method setPreviousAcceleration.

@Override
public void setPreviousAcceleration(double[] previousAcceleration) {
    if (previousAcceleration == null) {
        return;
    }
    int index = 0;
    double[] prev = new double[3];
    for (Atom a : refinementModel.getTotalAtomArray()) {
        if (a.isActive()) {
            prev[0] = previousAcceleration[index++];
            prev[1] = previousAcceleration[index++];
            prev[2] = previousAcceleration[index++];
            a.setPreviousAcceleration(prev);
        }
    }
}
Also used : Atom(ffx.potential.bonded.Atom)

Example 10 with Atom

use of ffx.potential.bonded.Atom in project ffx by mjschnie.

the class RealSpaceEnergy method getVariableTypes.

/**
 * Return a reference to each variables type.
 *
 * @return the type of each variable.
 */
@Override
public VARIABLE_TYPE[] getVariableTypes() {
    int nActive = 0;
    for (Atom a : refinementModel.getTotalAtomArray()) {
        if (a.isActive()) {
            nActive++;
        }
    }
    VARIABLE_TYPE[] type = new VARIABLE_TYPE[nActive * 3];
    int index = 0;
    for (int i = 0; i < nActive; i++) {
        type[index++] = VARIABLE_TYPE.X;
        type[index++] = VARIABLE_TYPE.Y;
        type[index++] = VARIABLE_TYPE.Z;
    }
    return type;
}
Also used : Atom(ffx.potential.bonded.Atom)

Aggregations

Atom (ffx.potential.bonded.Atom)206 Residue (ffx.potential.bonded.Residue)42 Bond (ffx.potential.bonded.Bond)37 CoordRestraint (ffx.potential.nonbonded.CoordRestraint)34 ArrayList (java.util.ArrayList)33 OpenMM_System_addConstraint (simtk.openmm.OpenMMLibrary.OpenMM_System_addConstraint)23 Polymer (ffx.potential.bonded.Polymer)22 IOException (java.io.IOException)22 MSNode (ffx.potential.bonded.MSNode)21 Crystal (ffx.crystal.Crystal)20 Molecule (ffx.potential.bonded.Molecule)19 File (java.io.File)19 MultiResidue (ffx.potential.bonded.MultiResidue)17 MultipoleType (ffx.potential.parameters.MultipoleType)13 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)12 PointerByReference (com.sun.jna.ptr.PointerByReference)11 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)11 AtomType (ffx.potential.parameters.AtomType)11 List (java.util.List)11 MolecularAssembly (ffx.potential.MolecularAssembly)10