Search in sources :

Example 86 with Foundation

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

the class Scene method removeAllFresnelReflectors.

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

Example 87 with Foundation

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

the class Scene method removeAllWindows.

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

Example 88 with Foundation

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

the class Scene method pasteToPickedLocationOnFloor.

public void pasteToPickedLocationOnFloor() {
    EnergyPanel.getInstance().updateRadiationHeatMap();
    if (copyBuffer == null) {
        return;
    }
    if (copyBuffer instanceof Foundation) {
        return;
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Floor)) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnFloor();
    if (position == null) {
        return;
    }
    if (selectedPart != c.getContainer()) {
        // solar panels and racks can be pasted to a different parent
        if (c instanceof SolarPanel) {
            ((SolarPanel) c).moveTo(selectedPart);
        } else if (c instanceof Rack) {
            ((Rack) c).moveTo(selectedPart);
        }
    }
    position = c.toRelative(position.subtractLocal(c.getContainer().getAbsPoint(0)));
    final Vector3 center = c.toRelative(c.getAbsCenter().subtractLocal(c.getContainer().getAbsPoint(0)));
    position = position.subtractLocal(center);
    final int n = c.getPoints().size();
    for (int i = 0; i < n; i++) {
        final Vector3 v = c.getPoints().get(i);
        v.addLocal(position);
    }
    if (c instanceof Rack) {
        ((Rack) c).moveSolarPanels(position);
        setIdOfChildren(c);
    }
    add(c, true);
    copyBuffer = c;
    SceneManager.getInstance().setSelectedPart(c);
    SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
Also used : Floor(org.concord.energy3d.model.Floor) Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) HousePart(org.concord.energy3d.model.HousePart) PastePartCommand(org.concord.energy3d.undo.PastePartCommand)

Example 89 with Foundation

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

the class Scene method removeAllHeliostats.

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

Example 90 with Foundation

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

the class Scene method pasteToPickedLocationOnMesh.

public void pasteToPickedLocationOnMesh(final Mesh mesh) {
    EnergyPanel.getInstance().updateRadiationHeatMap();
    if (copyBuffer == null) {
        return;
    }
    if (copyBuffer instanceof Foundation) {
        return;
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Foundation)) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnMesh(mesh);
    if (position == null) {
        return;
    }
    position = c.toRelative(position.subtractLocal(c.getContainer().getAbsPoint(0)));
    final Vector3 center = c.toRelative(c.getAbsCenter().subtractLocal(c.getContainer().getAbsPoint(0)));
    position = position.subtractLocal(center);
    final int n = c.getPoints().size();
    for (int i = 0; i < n; i++) {
        final Vector3 v = c.getPoints().get(i);
        v.addLocal(position);
    }
    if (copyBuffer instanceof Rack) {
        final Rack rack = (Rack) c;
        rack.moveSolarPanels(position);
        setIdOfChildren(c);
        final MeshLocator originalMeshLocator = ((Rack) copyBuffer).getMeshLocator();
        if (originalMeshLocator != null) {
            final UserData ud = (UserData) mesh.getUserData();
            rack.setMeshLocator(new MeshLocator((Foundation) ud.getHousePart(), ud.getNodeIndex(), ud.getMeshIndex()));
        }
    } else if (copyBuffer instanceof SolarPanel) {
        final SolarPanel panel = (SolarPanel) c;
        final MeshLocator originalMeshLocator = ((SolarPanel) copyBuffer).getMeshLocator();
        if (originalMeshLocator != null) {
            final UserData ud = (UserData) mesh.getUserData();
            panel.setMeshLocator(new MeshLocator((Foundation) ud.getHousePart(), ud.getNodeIndex(), ud.getMeshIndex()));
        }
    }
    add(c, true);
    copyBuffer = c;
    SceneManager.getInstance().setSelectedPart(c);
    SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
Also used : Rack(org.concord.energy3d.model.Rack) UserData(org.concord.energy3d.model.UserData) MeshLocator(org.concord.energy3d.model.MeshLocator) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) HousePart(org.concord.energy3d.model.HousePart) PastePartCommand(org.concord.energy3d.undo.PastePartCommand)

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