Search in sources :

Example 6 with Roof

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

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

the class Scene method removeAllRoofs.

public void removeAllRoofs() {
    final ArrayList<HousePart> roofs = new ArrayList<HousePart>();
    for (final HousePart part : parts) {
        if (part instanceof Roof && !part.getLockEdit()) {
            roofs.add(part);
        }
    }
    if (roofs.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no roof to remove.", "No Roof", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + roofs.size() + " roofs?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(roofs);
    for (final HousePart part : roofs) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : Roof(org.concord.energy3d.model.Roof) ArrayList(java.util.ArrayList) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 8 with Roof

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

the class Scene method removeAllChildren.

public void removeAllChildren(final HousePart parent) {
    final List<HousePart> children = parent.getChildren();
    final String s = parent.getClass().getSimpleName();
    // make a copy to avoid ConcurrentModificationException
    final List<HousePart> copy = new ArrayList<HousePart>();
    for (final HousePart p : children) {
        if (p instanceof Roof) {
            // make an exception of roof (it is a child of a wall)
            continue;
        }
        copy.add(p);
    }
    if (copy.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no element to remove from " + s + ".", "No Element", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + copy.size() + " elements of " + s + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(copy);
    for (final HousePart p : copy) {
        remove(p, false);
    }
    parent.draw();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
    SceneManager.getInstance().refresh();
}
Also used : Roof(org.concord.energy3d.model.Roof) ArrayList(java.util.ArrayList) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 9 with Roof

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

the class Scene method redrawAllNow.

public void redrawAllNow() {
    System.out.println("redrawAllNow()");
    final int n = parts.size();
    final boolean showProgress = n > 1000;
    if (showProgress) {
        SceneManager.getInstance().cursorWait(true);
    }
    final long t = System.nanoTime();
    if (cleanup) {
        cleanup();
        cleanup = false;
    }
    connectWalls();
    Snap.clearAnnotationDrawn();
    List<Roof> roofs = null;
    for (final HousePart part : parts) {
        if (part instanceof Roof) {
            if (roofs == null) {
                roofs = new ArrayList<Roof>();
            }
            roofs.add((Roof) part);
            part.draw();
        }
    }
    int i = 0;
    for (final HousePart part : parts) {
        if (!(part instanceof Roof)) {
            part.draw();
            if (showProgress) {
                final int index = i++;
                EventQueue.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        EnergyPanel.getInstance().progress((int) Math.round(100.0 * index / n));
                    }
                });
            }
        }
    }
    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();
    }
    if (Heliodon.getInstance().isVisible()) {
        Heliodon.getInstance().updateSize();
    }
    System.out.println("Scene rendering time: " + (System.nanoTime() - t) / 1000000000.0);
    // no need for redrawing print parts because they will be regenerated from original parts anyways
    redrawAll = false;
    if (showProgress) {
        SceneManager.getInstance().cursorWait(false);
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                EnergyPanel.getInstance().progress(0);
            }
        });
    }
}
Also used : Roof(org.concord.energy3d.model.Roof) HousePart(org.concord.energy3d.model.HousePart)

Example 10 with Roof

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

the class Scene method redrawAllWallsNow.

// special case for redrawing walls and roofs that are interconnected (this is needed when we deal with a lot of solar collectors)
public void redrawAllWallsNow() {
    System.out.println("redrawAllWallsNow()");
    connectWalls();
    List<Roof> roofs = null;
    for (final HousePart part : parts) {
        if (part instanceof Roof) {
            if (roofs == null) {
                roofs = new ArrayList<Roof>();
            }
            roofs.add((Roof) part);
            part.draw();
        }
    }
    for (final HousePart part : parts) {
        if (part instanceof Wall) {
            part.draw();
            part.drawChildren();
        }
    }
    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) Wall(org.concord.energy3d.model.Wall) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

Roof (org.concord.energy3d.model.Roof)51 HousePart (org.concord.energy3d.model.HousePart)47 Foundation (org.concord.energy3d.model.Foundation)38 Wall (org.concord.energy3d.model.Wall)31 Window (org.concord.energy3d.model.Window)28 Rack (org.concord.energy3d.model.Rack)25 SolarPanel (org.concord.energy3d.model.SolarPanel)24 Door (org.concord.energy3d.model.Door)21 ArrayList (java.util.ArrayList)15 List (java.util.List)12 Floor (org.concord.energy3d.model.Floor)11 Mirror (org.concord.energy3d.model.Mirror)11 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)10 Spatial (com.ardor3d.scenegraph.Spatial)9 FresnelReflector (org.concord.energy3d.model.FresnelReflector)9 ParabolicDish (org.concord.energy3d.model.ParabolicDish)9 Tree (org.concord.energy3d.model.Tree)9 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)8 CullHint (com.ardor3d.scenegraph.hint.CullHint)8 ActionEvent (java.awt.event.ActionEvent)8