Search in sources :

Example 1 with RemoveMultiplePartsCommand

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

the class Foundation method removeAllWithinPolygon.

public void removeAllWithinPolygon() {
    if (foundationPolygon == null || !foundationPolygon.isVisible()) {
        return;
    }
    final Path2D.Double path = new Path2D.Double();
    final int n = foundationPolygon.points.size();
    Vector3 v = foundationPolygon.getAbsPoint(0);
    path.moveTo(v.getX(), v.getY());
    for (int i = 1; i < n / 2; i++) {
        // use only the first half of the vertices from the polygon
        v = foundationPolygon.getAbsPoint(i);
        path.lineTo(v.getX(), v.getY());
    }
    path.closePath();
    final List<HousePart> selectedParts = new ArrayList<HousePart>();
    for (final HousePart child : children) {
        final Vector3 center = child.getAbsCenter();
        if (path.contains(center.getX(), center.getY())) {
            selectedParts.add(child);
        }
    }
    if (selectedParts.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no object to remove.", "No Object", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "<html>Do you really want to remove all " + selectedParts.size() + " objects<br>within the white border line of the selected foundation?</html>", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(selectedParts);
    for (final HousePart part : selectedParts) {
        Scene.getInstance().remove(part, false);
    }
    draw();
    SceneManager.getInstance().getUndoManager().addEdit(c);
}
Also used : Path2D(java.awt.geom.Path2D) ArrayList(java.util.ArrayList) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 2 with RemoveMultiplePartsCommand

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

the class Scene method removeAllWalls.

public void removeAllWalls() {
    final ArrayList<HousePart> walls = 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 Wall && !part.getLockEdit() && part.getTopContainer() == foundation) {
                walls.add(part);
            }
        }
    } else {
        for (final HousePart part : parts) {
            if (part instanceof Wall && !part.getLockEdit()) {
                walls.add(part);
            }
        }
    }
    if (walls.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no wall to remove.", "No Wall", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + walls.size() + " walls" + (selectedPart != null ? " of the selected building" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(walls);
    for (final HousePart part : walls) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : Wall(org.concord.energy3d.model.Wall) ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 3 with RemoveMultiplePartsCommand

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

the class Scene method removeAllRacks.

public void removeAllRacks() {
    final ArrayList<HousePart> racks = 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 Rack && part.getTopContainer() == foundation) {
                racks.add(part);
            }
        }
    } else {
        for (final HousePart part : parts) {
            if (part instanceof Rack) {
                racks.add(part);
            }
        }
    }
    if (racks.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no rack to remove.", "No Rack", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + racks.size() + " solar panel racks" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(racks);
    for (final HousePart part : racks) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : Rack(org.concord.energy3d.model.Rack) ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 4 with RemoveMultiplePartsCommand

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

the class Scene method removeAllFloors.

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

Example 5 with RemoveMultiplePartsCommand

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

the class Scene method removeAllHumans.

public void removeAllHumans() {
    final ArrayList<HousePart> humans = new ArrayList<HousePart>();
    for (final HousePart part : parts) {
        if (part instanceof Human) {
            humans.add(part);
        }
    }
    if (humans.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no human to remove.", "No Human", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + humans.size() + " humans?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(humans);
    for (final HousePart part : humans) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : Human(org.concord.energy3d.model.Human) 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