Search in sources :

Example 16 with Foundation

use of org.concord.energy3d.model.Foundation 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)

Example 17 with Foundation

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

the class Scene method add.

public void add(final HousePart part, final boolean redraw) {
    final HousePart container = part.getContainer();
    if (container != null) {
        container.getChildren().add(part);
    }
    add(part);
    if (redraw) {
        if (part instanceof SolarCollector || part instanceof Tree || part instanceof Human) {
            // add these objects will not affect the rendering of other objects
            part.draw();
        } else if (part instanceof Foundation) {
            redrawFoundationNow((Foundation) part);
        } else if (part instanceof Window || part instanceof Door) {
            part.draw();
            part.getContainer().draw();
        } else {
            // what will fall through here?
            System.out.println("*** Warning: potential performance drag: " + part);
            redrawAll();
        }
    }
}
Also used : Human(org.concord.energy3d.model.Human) Window(org.concord.energy3d.model.Window) SolarCollector(org.concord.energy3d.model.SolarCollector) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) Door(org.concord.energy3d.model.Door)

Example 18 with Foundation

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

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

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

the class Scene method setShutterColorOfBuilding.

public void setShutterColorOfBuilding(final HousePart part, final ReadOnlyColorRGBA color) {
    if (part instanceof Foundation) {
        return;
    }
    for (final HousePart p : parts) {
        if (p instanceof Window && p.getTopContainer() == part.getTopContainer()) {
            final Window w = (Window) p;
            w.setShutterColor(color);
            w.draw();
        }
    }
}
Also used : Window(org.concord.energy3d.model.Window) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

Foundation (org.concord.energy3d.model.Foundation)174 HousePart (org.concord.energy3d.model.HousePart)153 Rack (org.concord.energy3d.model.Rack)47 SolarPanel (org.concord.energy3d.model.SolarPanel)45 Window (org.concord.energy3d.model.Window)39 ActionEvent (java.awt.event.ActionEvent)38 ActionListener (java.awt.event.ActionListener)38 Roof (org.concord.energy3d.model.Roof)38 Wall (org.concord.energy3d.model.Wall)37 ArrayList (java.util.ArrayList)35 JDialog (javax.swing.JDialog)35 JMenuItem (javax.swing.JMenuItem)33 Mirror (org.concord.energy3d.model.Mirror)32 FresnelReflector (org.concord.energy3d.model.FresnelReflector)27 Door (org.concord.energy3d.model.Door)24 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)24 Tree (org.concord.energy3d.model.Tree)24 Vector3 (com.ardor3d.math.Vector3)22 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)22 ParabolicDish (org.concord.energy3d.model.ParabolicDish)22