Search in sources :

Example 16 with RemoveMultiplePartsCommand

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

the class Scene method removeAllParabolicTroughs.

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

Example 17 with RemoveMultiplePartsCommand

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

the class Scene method removeAllSolarPanels.

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