Search in sources :

Example 1 with MolecularAssembly

use of ffx.potential.MolecularAssembly in project ffx by mjschnie.

the class GraphicsCanvas method postRender.

/**
 * {@inheritDoc}
 *
 * Labels are drawn in postRender.
 */
@Override
public void postRender() {
    if (RendererCache.labelAtoms || RendererCache.labelResidues) {
        J3DGraphics2D g2D = getGraphics2D();
        synchronized (mainPanel.getHierarchy()) {
            ArrayList<MSNode> nodes = mainPanel.getHierarchy().getActiveNodes();
            if (nodes != null && nodes.size() > 0) {
                for (MSNode node : nodes) {
                    MolecularAssembly sys = (MolecularAssembly) node.getMSNode(MolecularAssembly.class);
                    if (sys != null) {
                        node.drawLabel(this, g2D, sys.getWireFrame());
                    }
                }
            } else {
                return;
            }
        }
        g2D.flush(true);
    }
}
Also used : MSNode(ffx.potential.bonded.MSNode) MolecularAssembly(ffx.potential.MolecularAssembly) J3DGraphics2D(javax.media.j3d.J3DGraphics2D)

Example 2 with MolecularAssembly

use of ffx.potential.MolecularAssembly in project ffx by mjschnie.

the class GraphicsCanvas method rotateAboutPick.

/**
 * <p>
 * rotateAboutPick</p>
 */
public void rotateAboutPick() {
    MSNode node = rendererPicking.getPick();
    if (node != null) {
        double[] center = node.getCenter(false);
        MolecularAssembly m = (MolecularAssembly) node.getMSNode(MolecularAssembly.class);
        m.rotateAbout(new Vector3d(center));
    }
}
Also used : MSNode(ffx.potential.bonded.MSNode) MolecularAssembly(ffx.potential.MolecularAssembly) Vector3d(javax.vecmath.Vector3d)

Example 3 with MolecularAssembly

use of ffx.potential.MolecularAssembly in project ffx by mjschnie.

the class GraphicsCanvas method captureGraphics.

private void captureGraphics() {
    MolecularAssembly active = mainPanel.getHierarchy().getActive();
    if (active == null) {
        return;
    }
    imageName = null;
    String name = active.getName();
    JFileChooser fileChooser = MainPanel.resetFileChooser();
    fileChooser.setAcceptAllFileFilterUsed(true);
    if (mainPanel.getHierarchy().getActive() != null) {
        imageName = mainPanel.getHierarchy().getActive().getFile();
    } else {
        imageName = null;
    }
    if (imageName != null) {
        if (name.indexOf(".") > 0) {
            name = name.substring(0, name.indexOf("."));
        }
        imageName = new File(imageName.getParentFile() + File.separator + name + "." + imageFormat);
        fileChooser.setSelectedFile(imageName);
    }
    fileChooser.setDialogTitle("Select Name for Screen Capture " + "(" + imageFormat + ")");
    fileChooser.setCurrentDirectory(MainPanel.getPWD());
    int result = fileChooser.showSaveDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
        imageName = fileChooser.getSelectedFile();
        mainPanel.setCWD(fileChooser.getCurrentDirectory());
        imageCapture = true;
        repaint();
    }
}
Also used : MolecularAssembly(ffx.potential.MolecularAssembly) JFileChooser(javax.swing.JFileChooser) File(java.io.File)

Example 4 with MolecularAssembly

use of ffx.potential.MolecularAssembly in project ffx by mjschnie.

the class GraphicsCanvas method rotateAboutCenter.

/**
 * <p>
 * rotateAboutCenter</p>
 */
public void rotateAboutCenter() {
    MolecularAssembly sys = mainPanel.getHierarchy().getActive();
    double[] center = sys.getMultiScaleCenter(false);
    sys.rotateAbout(new Vector3d(center));
}
Also used : MolecularAssembly(ffx.potential.MolecularAssembly) Vector3d(javax.vecmath.Vector3d)

Example 5 with MolecularAssembly

use of ffx.potential.MolecularAssembly 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)

Aggregations

MolecularAssembly (ffx.potential.MolecularAssembly)34 File (java.io.File)13 ForceFieldEnergy (ffx.potential.ForceFieldEnergy)11 Atom (ffx.potential.bonded.Atom)10 Crystal (ffx.crystal.Crystal)7 MSNode (ffx.potential.bonded.MSNode)7 IOException (java.io.IOException)7 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)7 MissingAtomTypeException (ffx.potential.bonded.BondedUtils.MissingAtomTypeException)5 MissingHeavyAtomException (ffx.potential.bonded.BondedUtils.MissingHeavyAtomException)5 Molecule (ffx.potential.bonded.Molecule)5 Polymer (ffx.potential.bonded.Polymer)5 Residue (ffx.potential.bonded.Residue)5 PDBFilter (ffx.potential.parsers.PDBFilter)5 ParallelTeam (edu.rit.pj.ParallelTeam)4 Bond (ffx.potential.bonded.Bond)4 ExtendedSystem (ffx.potential.extended.ExtendedSystem)4 ForceField (ffx.potential.parameters.ForceField)4 ForceFieldFilter (ffx.potential.parsers.ForceFieldFilter)4 BufferedWriter (java.io.BufferedWriter)4