Search in sources :

Example 21 with HousePart

use of org.concord.energy3d.model.HousePart 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 22 with HousePart

use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.

the class Scene method setFocalLengthForAllParabolicDishes.

public void setFocalLengthForAllParabolicDishes(final double curvatureParameter) {
    for (final HousePart p : parts) {
        if (p instanceof ParabolicDish) {
            ((ParabolicDish) p).setFocalLength(curvatureParameter);
            p.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) HousePart(org.concord.energy3d.model.HousePart)

Example 23 with HousePart

use of org.concord.energy3d.model.HousePart 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 24 with HousePart

use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.

the class Scene method setWindowColorInContainer.

public void setWindowColorInContainer(final HousePart container, final ColorRGBA c, final boolean shutter) {
    for (final HousePart p : parts) {
        if (p instanceof Window && p.getContainer() == container) {
            final Window w = (Window) p;
            if (shutter) {
                w.setShutterColor(c);
            } else {
                w.setColor(c);
            }
            w.draw();
        }
    }
}
Also used : Window(org.concord.energy3d.model.Window) HousePart(org.concord.energy3d.model.HousePart)

Example 25 with HousePart

use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.

the class Scene method pasteToPickedLocationOnLand.

public void pasteToPickedLocationOnLand() {
    if (SceneManager.getInstance().getSolarHeatMap()) {
        EnergyPanel.getInstance().updateRadiationHeatMap();
    }
    if (copyBuffer == null) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    final Vector3 position = SceneManager.getInstance().getPickedLocationOnLand();
    if (position == null) {
        return;
    }
    if (c instanceof Tree || c instanceof Human) {
        c.getPoints().set(0, position);
        add(c, true);
        copyBuffer = c;
        SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
    } else if (c instanceof Foundation) {
        // pasting a foundation also clones the building above it
        final Vector3 shift = position.subtractLocal(c.getAbsCenter()).multiplyLocal(1, 1, 0);
        final int n = c.getPoints().size();
        for (int i = 0; i < n; i++) {
            c.getPoints().get(i).addLocal(shift);
        }
        add(c, true);
        // copy gable info, too
        final Foundation oldFoundation = (Foundation) copyBuffer;
        final Foundation newFoundation = (Foundation) c;
        final List<Roof> oldRoofs = oldFoundation.getRoofs();
        final List<Roof> newRoofs = newFoundation.getRoofs();
        if (!oldRoofs.isEmpty() && !newRoofs.isEmpty()) {
            for (int i = 0; i < newRoofs.size(); i++) {
                final Map<Integer, List<Wall>> oldMap = oldRoofs.get(i).getGableEditPointToWallMap();
                if (oldMap == null || oldMap.isEmpty()) {
                    continue;
                }
                final Map<Integer, List<Wall>> newMap = new HashMap<Integer, List<Wall>>();
                for (final Integer key : oldMap.keySet()) {
                    final List<Wall> oldWalls = oldMap.get(key);
                    final List<Wall> newWalls = new ArrayList<Wall>();
                    for (final Wall w : oldWalls) {
                        newWalls.add(getCopiedWall(w, oldFoundation, newFoundation));
                    }
                    newMap.put(key, newWalls);
                }
                newRoofs.get(i).setGableEditPointToWallMap(newMap);
            }
        }
        copyBuffer = c;
        setIdOfChildren(c);
        SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
    }
    SceneManager.getInstance().setSelectedPart(c);
}
Also used : Human(org.concord.energy3d.model.Human) Wall(org.concord.energy3d.model.Wall) Tree(org.concord.energy3d.model.Tree) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) Foundation(org.concord.energy3d.model.Foundation) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) HousePart(org.concord.energy3d.model.HousePart) PastePartCommand(org.concord.energy3d.undo.PastePartCommand)

Aggregations

HousePart (org.concord.energy3d.model.HousePart)277 Foundation (org.concord.energy3d.model.Foundation)153 Rack (org.concord.energy3d.model.Rack)69 SolarPanel (org.concord.energy3d.model.SolarPanel)60 Roof (org.concord.energy3d.model.Roof)47 Wall (org.concord.energy3d.model.Wall)45 Window (org.concord.energy3d.model.Window)43 ActionEvent (java.awt.event.ActionEvent)42 ActionListener (java.awt.event.ActionListener)42 ArrayList (java.util.ArrayList)41 Mirror (org.concord.energy3d.model.Mirror)38 JMenuItem (javax.swing.JMenuItem)36 JDialog (javax.swing.JDialog)35 FresnelReflector (org.concord.energy3d.model.FresnelReflector)34 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)32 ParabolicDish (org.concord.energy3d.model.ParabolicDish)28 Tree (org.concord.energy3d.model.Tree)26 Door (org.concord.energy3d.model.Door)25 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)21 JPanel (javax.swing.JPanel)21