Search in sources :

Example 6 with RemoveMultiplePartsCommand

use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.

the class Scene method removeAllRoofs.

public void removeAllRoofs() {
    final ArrayList<HousePart> roofs = new ArrayList<HousePart>();
    for (final HousePart part : parts) {
        if (part instanceof Roof && !part.getLockEdit()) {
            roofs.add(part);
        }
    }
    if (roofs.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no roof to remove.", "No Roof", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + roofs.size() + " roofs?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(roofs);
    for (final HousePart part : roofs) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : Roof(org.concord.energy3d.model.Roof) ArrayList(java.util.ArrayList) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 7 with RemoveMultiplePartsCommand

use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.

the class Scene method removeAllFoundations.

public void removeAllFoundations() {
    final ArrayList<HousePart> foundations = new ArrayList<HousePart>();
    for (final HousePart part : parts) {
        if (part instanceof Foundation && !part.getLockEdit()) {
            foundations.add(part);
        }
    }
    if (foundations.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no activated foundation to remove.", "No Foundation", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + foundations.size() + " foundations?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(foundations);
    for (final HousePart part : foundations) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 8 with RemoveMultiplePartsCommand

use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.

the class Scene method removeAllParabolicDishes.

public void removeAllParabolicDishes() {
    final ArrayList<HousePart> dishes = new ArrayList<HousePart>();
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart != null) {
        final Foundation foundation = selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer();
        for (final HousePart part : parts) {
            if (part instanceof ParabolicDish && part.getTopContainer() == foundation) {
                dishes.add(part);
            }
        }
    } else {
        for (final HousePart part : parts) {
            if (part instanceof ParabolicDish) {
                dishes.add(part);
            }
        }
    }
    if (dishes.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no parabolic dish to remove.", "No Parabolic Dish", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + dishes.size() + " parabolic dishes" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(dishes);
    for (final HousePart part : dishes) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 9 with RemoveMultiplePartsCommand

use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.

the class Scene method deleteAllConnectedWalls.

public void deleteAllConnectedWalls(final Wall w) {
    final List<HousePart> copy = new ArrayList<HousePart>();
    w.visitNeighbors(new WallVisitor() {

        @Override
        public void visit(final Wall currentWall, final Snap prev, final Snap next) {
            copy.add(currentWall);
        }
    });
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(copy);
    for (final HousePart p : copy) {
        remove(p, false);
    }
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
    SceneManager.getInstance().refresh();
}
Also used : WallVisitor(org.concord.energy3d.util.WallVisitor) Wall(org.concord.energy3d.model.Wall) ArrayList(java.util.ArrayList) Snap(org.concord.energy3d.model.Snap) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 10 with RemoveMultiplePartsCommand

use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.

the class Scene method removeAllChildren.

public void removeAllChildren(final HousePart parent) {
    final List<HousePart> children = parent.getChildren();
    final String s = parent.getClass().getSimpleName();
    // make a copy to avoid ConcurrentModificationException
    final List<HousePart> copy = new ArrayList<HousePart>();
    for (final HousePart p : children) {
        if (p instanceof Roof) {
            // make an exception of roof (it is a child of a wall)
            continue;
        }
        copy.add(p);
    }
    if (copy.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no element to remove from " + s + ".", "No Element", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + copy.size() + " elements of " + s + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(copy);
    for (final HousePart p : copy) {
        remove(p, false);
    }
    parent.draw();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
    SceneManager.getInstance().refresh();
}
Also used : Roof(org.concord.energy3d.model.Roof) ArrayList(java.util.ArrayList) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Aggregations

RemoveMultiplePartsCommand (org.concord.energy3d.undo.RemoveMultiplePartsCommand)17 ArrayList (java.util.ArrayList)16 HousePart (org.concord.energy3d.model.HousePart)16 Foundation (org.concord.energy3d.model.Foundation)10 Rack (org.concord.energy3d.model.Rack)2 Roof (org.concord.energy3d.model.Roof)2 Wall (org.concord.energy3d.model.Wall)2 Vector3 (com.ardor3d.math.Vector3)1 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)1 CullHint (com.ardor3d.scenegraph.hint.CullHint)1 Path2D (java.awt.geom.Path2D)1 Floor (org.concord.energy3d.model.Floor)1 FresnelReflector (org.concord.energy3d.model.FresnelReflector)1 Human (org.concord.energy3d.model.Human)1 Mirror (org.concord.energy3d.model.Mirror)1 ParabolicDish (org.concord.energy3d.model.ParabolicDish)1 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)1 Sensor (org.concord.energy3d.model.Sensor)1 Snap (org.concord.energy3d.model.Snap)1 SolarPanel (org.concord.energy3d.model.SolarPanel)1