Search in sources :

Example 16 with HousePart

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

the class Scene method setColorForAllSolarPanels.

public void setColorForAllSolarPanels(final int colorOption) {
    for (final HousePart p : parts) {
        if (p instanceof SolarPanel) {
            ((SolarPanel) p).setColorOption(colorOption);
            p.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : SolarPanel(org.concord.energy3d.model.SolarPanel) HousePart(org.concord.energy3d.model.HousePart)

Example 17 with HousePart

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

the class Scene method setShutterLengthInContainer.

public void setShutterLengthInContainer(final HousePart container, final double length) {
    for (final HousePart p : parts) {
        if (p instanceof Window && p.getContainer() == container) {
            final Window w = (Window) p;
            w.setShutterLength(length);
            w.draw();
        }
    }
}
Also used : Window(org.concord.energy3d.model.Window) HousePart(org.concord.energy3d.model.HousePart)

Example 18 with HousePart

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

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

the class Scene method redrawFoundationNow.

// special case for redrawing the specified foundation (this is needed when we deal with a lot of solar collectors or a lot of foundations)
public void redrawFoundationNow(final Foundation foundation) {
    System.out.println("redrawFoundationNow()");
    foundation.connectWalls();
    List<Roof> roofs = null;
    for (final HousePart part : parts) {
        if (part instanceof Roof) {
            if (part.getTopContainer() == foundation) {
                if (roofs == null) {
                    roofs = new ArrayList<Roof>();
                }
                roofs.add((Roof) part);
                part.draw();
            }
        }
    }
    for (final HousePart part : parts) {
        if (!(part instanceof Roof)) {
            if (part.getTopContainer() == foundation || part == foundation) {
                part.draw();
            }
        }
    }
    if (roofs != null && !roofs.isEmpty()) {
        // need to draw roof again because roof holes depend on drawn windows
        for (final Roof r : roofs) {
            r.draw();
        }
        roofs.clear();
    }
    SceneManager.getInstance().refresh();
}
Also used : Roof(org.concord.energy3d.model.Roof) HousePart(org.concord.energy3d.model.HousePart)

Example 20 with HousePart

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

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