Search in sources :

Example 56 with HousePart

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

the class Scene method setShutterLengthOfBuilding.

public void setShutterLengthOfBuilding(final HousePart part, final double length) {
    if (part instanceof Foundation) {
        return;
    }
    for (final HousePart p : parts) {
        if (p instanceof Window && p.getTopContainer() == part.getTopContainer()) {
            final Window w = (Window) p;
            w.setShutterLength(length);
            w.draw();
        }
    }
}
Also used : Window(org.concord.energy3d.model.Window) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart)

Example 57 with HousePart

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

the class Scene method setHeightOfConnectedWalls.

public void setHeightOfConnectedWalls(final Wall w, final double height) {
    w.visitNeighbors(new WallVisitor() {

        @Override
        public void visit(final Wall w, final Snap prev, final Snap next) {
            w.setHeight(height, true);
        }
    });
    redrawAllWallsNow();
    final Foundation foundation = w.getTopContainer();
    if (foundation.hasSolarReceiver()) {
        foundation.drawSolarReceiver();
        for (final HousePart x : Scene.getInstance().getParts()) {
            if (x instanceof FresnelReflector) {
                final FresnelReflector reflector = (FresnelReflector) x;
                if (foundation == reflector.getReceiver() && reflector.isSunBeamVisible()) {
                    reflector.drawSunBeam();
                }
            } else if (x instanceof Mirror) {
                final Mirror heliostat = (Mirror) x;
                if (foundation == heliostat.getReceiver() && heliostat.isSunBeamVisible()) {
                    heliostat.drawSunBeam();
                }
            }
        }
    }
}
Also used : WallVisitor(org.concord.energy3d.util.WallVisitor) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) Foundation(org.concord.energy3d.model.Foundation) Snap(org.concord.energy3d.model.Snap) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 58 with HousePart

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

the class Scene method pasteToPickedLocationOnWall.

public void pasteToPickedLocationOnWall() {
    EnergyPanel.getInstance().updateRadiationHeatMap();
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Wall)) {
        return;
    }
    if (copyBuffer == null) {
        return;
    }
    if (copyBuffer instanceof Foundation) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnWall();
    if (position == null) {
        return;
    }
    final Wall wall = (Wall) selectedPart;
    if (wall != c.getContainer()) {
        // windows and solar panels can be pasted to a different wall
        if (c instanceof Window) {
            ((Window) c).moveTo(wall);
        } else if (c instanceof SolarPanel) {
            ((SolarPanel) c).moveTo(wall);
        }
    }
    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);
    }
    // out of boundary check
    final List<Vector3> polygon = wall.getWallPolygonPoints();
    final List<Vector3> relativePolygon = new ArrayList<Vector3>();
    for (final Vector3 p : polygon) {
        relativePolygon.add(c.toRelative(p));
    }
    for (final Vector3 p : relativePolygon) {
        final double y = p.getY();
        p.setY(p.getZ());
        p.setZ(y);
    }
    for (int i = 0; i < n; i++) {
        final Vector3 v = c.getPoints().get(i);
        if (!Util.insidePolygon(new Vector3(v.getX(), v.getZ(), v.getY()), relativePolygon)) {
            return;
        }
    }
    add(c, true);
    copyBuffer = c;
    SceneManager.getInstance().setSelectedPart(c);
    SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
Also used : Window(org.concord.energy3d.model.Window) Wall(org.concord.energy3d.model.Wall) SolarPanel(org.concord.energy3d.model.SolarPanel) ArrayList(java.util.ArrayList) 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 59 with HousePart

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

the class Scene method setSectionsForAllParabolicDishes.

public void setSectionsForAllParabolicDishes(final int nParabola, final int nAxis) {
    for (final HousePart p : parts) {
        if (p instanceof ParabolicDish) {
            final ParabolicDish d = (ParabolicDish) p;
            d.setNRadialSections(nParabola);
            d.setNAxialSections(nAxis);
            d.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) HousePart(org.concord.energy3d.model.HousePart)

Example 60 with HousePart

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

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