Search in sources :

Example 11 with Foundation

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

the class Scene method setPartColorOfBuilding.

public void setPartColorOfBuilding(final HousePart part, final ReadOnlyColorRGBA color) {
    if (part instanceof Foundation) {
        part.setColor(color);
        part.draw();
    } else {
        for (final HousePart p : parts) {
            if (p.getTopContainer() == part.getTopContainer() && p.getClass().equals(part.getClass())) {
                p.setColor(color);
                p.draw();
            }
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Example 12 with Foundation

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

the class Scene method pasteToPickedLocationOnRoof.

public void pasteToPickedLocationOnRoof() {
    EnergyPanel.getInstance().updateRadiationHeatMap();
    if (copyBuffer == null) {
        return;
    }
    if (copyBuffer instanceof Foundation) {
        return;
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Roof)) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnRoof();
    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 : Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) 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 13 with Foundation

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

the class Scene method pasteToPickedLocationOnFoundation.

public void pasteToPickedLocationOnFoundation() {
    if (SceneManager.getInstance().getSolarHeatMap()) {
        EnergyPanel.getInstance().updateRadiationHeatMap();
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Foundation)) {
        return;
    }
    final Foundation foundation = (Foundation) selectedPart;
    if (copyNode != null) {
        final Vector3 position = SceneManager.getInstance().getPickedLocationOnFoundation();
        if (position == null) {
            return;
        }
        copyNodeState.setAbsolutePosition(position.clone());
        Node newNode = null;
        try {
            newNode = foundation.importCollada(copyNodeState.getSourceURL(), position);
        } catch (final Throwable t) {
            t.printStackTrace();
        }
        if (newNode != null) {
            // copy the attributes that aren't copied by import
            final NodeState s = foundation.getNodeState(newNode);
            s.setDefaultColor(copyNodeState.getDefaultColor());
            s.setName(copyNodeState.getName());
            if (copyNodeState.getMeshesWithReversedNormal() != null) {
                for (final Integer i : copyNodeState.getMeshesWithReversedNormal()) {
                    s.reverseNormalOfMesh(i);
                    Util.reverseFace(Util.getMesh(newNode, i));
                }
            }
            if (copyNodeState.getDeletedMeshes() != null) {
                for (final Integer i : copyNodeState.getDeletedMeshes()) {
                    foundation.deleteMesh(Util.getMesh(newNode, i));
                }
            }
            final HashMap<Integer, ReadOnlyColorRGBA> meshColors = copyNodeState.getMeshColors();
            if (meshColors != null) {
                for (final Integer i : meshColors.keySet()) {
                    s.setMeshColor(i, meshColors.get(i));
                    Util.getMesh(newNode, i).setDefaultColor(s.getMeshColor(i));
                }
            }
        }
    } else {
        if (copyBuffer != null) {
            final HousePart c = copyBuffer.copy(false);
            if (c == null) {
                return;
            }
            Vector3 position = SceneManager.getInstance().getPickedLocationOnFoundation();
            if (position == null) {
                return;
            }
            // move to this foundation
            c.setContainer(foundation);
            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 : ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) Rack(org.concord.energy3d.model.Rack) NodeState(org.concord.energy3d.model.NodeState) Node(com.ardor3d.scenegraph.Node) 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 14 with Foundation

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

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

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