Search in sources :

Example 91 with Foundation

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

the class Scene method setTargetForAllHeliostats.

public void setTargetForAllHeliostats(final Foundation target) {
    final List<Foundation> oldTargets = new ArrayList<Foundation>();
    for (final HousePart p : parts) {
        if (p instanceof Mirror) {
            final Mirror m = (Mirror) p;
            final Foundation t = m.getReceiver();
            if (t != null && !oldTargets.contains(t)) {
                oldTargets.add(t);
            }
            m.setReceiver(target);
            p.draw();
        }
    }
    if (target != null) {
        target.drawSolarReceiver();
    }
    if (!oldTargets.isEmpty()) {
        for (final Foundation t : oldTargets) {
            t.drawSolarReceiver();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 92 with Foundation

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

the class Scene method removeAllWindowShutters.

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

Example 93 with Foundation

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

the class Scene method newFile.

private static void newFile(final double xLength, final double yLength) {
    try {
        open(null);
        first = false;
    } catch (final Exception e) {
        e.printStackTrace();
    }
    SceneManager.getTaskManager().update(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            instance.add(new Human(Human.JACK, 1));
            final Foundation f = new Foundation(xLength, yLength);
            f.setColor(instance.getFoundationColor());
            instance.add(f, true);
            return null;
        }
    });
}
Also used : Human(org.concord.energy3d.model.Human) Foundation(org.concord.energy3d.model.Foundation) IOException(java.io.IOException)

Example 94 with Foundation

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

the class Scene method countMeshes.

public int countMeshes() {
    int count = 0;
    final List<Foundation> foundations = getAllFoundations();
    for (final Foundation f : foundations) {
        if (f.getImportedNodes() != null) {
            for (final Node n : f.getImportedNodes()) {
                count += n.getNumberOfChildren();
            }
        }
    }
    return count;
}
Also used : Node(com.ardor3d.scenegraph.Node) Foundation(org.concord.energy3d.model.Foundation)

Example 95 with Foundation

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

the class Scene method getFoundationBounds.

public Rectangle2D getFoundationBounds(final boolean excludeSelectedPart) {
    Rectangle2D bounds = new Rectangle2D.Double(-0.1, -0.1, 0.2, 0.2);
    if (excludeSelectedPart) {
        for (final HousePart p : parts) {
            if (p instanceof Foundation && p != SceneManager.getInstance().getSelectedPart()) {
                final Foundation f = (Foundation) p;
                final Vector3 v0 = f.getAbsPoint(0);
                final Vector3 v1 = f.getAbsPoint(1);
                final Vector3 v2 = f.getAbsPoint(2);
                final Vector3 v3 = f.getAbsPoint(3);
                final double cx = 0.25 * (v0.getX() + v1.getX() + v2.getX() + v3.getX());
                final double cy = 0.25 * (v0.getY() + v1.getY() + v2.getY() + v3.getY());
                final double lx = v0.distance(v2);
                final double ly = v0.distance(v1);
                bounds = bounds.createUnion(new Rectangle2D.Double(cx - lx * 0.5, cy - ly * 0.5, lx, ly));
            }
        }
    } else {
        for (final HousePart p : parts) {
            if (p instanceof Foundation) {
                final Foundation f = (Foundation) p;
                final Vector3 v0 = f.getAbsPoint(0);
                final Vector3 v1 = f.getAbsPoint(1);
                final Vector3 v2 = f.getAbsPoint(2);
                final Vector3 v3 = f.getAbsPoint(3);
                final double cx = 0.25 * (v0.getX() + v1.getX() + v2.getX() + v3.getX());
                final double cy = 0.25 * (v0.getY() + v1.getY() + v2.getY() + v3.getY());
                final double lx = v0.distance(v2);
                final double ly = v0.distance(v1);
                bounds = bounds.createUnion(new Rectangle2D.Double(cx - lx * 0.5, cy - ly * 0.5, lx, ly));
            }
        }
    }
    return bounds;
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) Foundation(org.concord.energy3d.model.Foundation) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) 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