Search in sources :

Example 21 with Foundation

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

the class Scene method removeAllSensors.

public void removeAllSensors() {
    final ArrayList<HousePart> sensors = 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 Sensor && part.getTopContainer() == foundation) {
                sensors.add(part);
            }
        }
    } else {
        for (final HousePart part : parts) {
            if (part instanceof Sensor) {
                sensors.add(part);
            }
        }
    }
    if (sensors.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no sensor to remove.", "No Sensor", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + sensors.size() + " sensors" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(sensors);
    for (final HousePart part : sensors) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) Sensor(org.concord.energy3d.model.Sensor) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 22 with Foundation

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

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

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

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

the class Scene method groupFoundations.

/* put overlapping foundations into separate groups */
private void groupFoundations() {
    if (foundationGroups == null) {
        foundationGroups = new ArrayList<List<Foundation>>();
    } else {
        foundationGroups.clear();
    }
    final List<Foundation> foundations = new ArrayList<Foundation>();
    for (final HousePart p : parts) {
        if (p instanceof Foundation) {
            foundations.add((Foundation) p);
        }
    }
    final int n = foundations.size();
    if (n > 1) {
        int count = 0;
        final List<Pair> pairs = new ArrayList<Pair>();
        for (int i = 0; i < n - 1; i++) {
            final Foundation fi = foundations.get(i);
            for (int j = i + 1; j < n; j++) {
                final Foundation fj = foundations.get(j);
                if (fi.overlap(fj)) {
                    final Pair p = new Pair(i, j);
                    if (!pairs.contains(p)) {
                        pairs.add(p);
                    }
                }
            }
        }
        int m = pairs.size();
        while (m > 0) {
            Pair p = pairs.get(0);
            final List<Integer> list = new ArrayList<Integer>();
            list.add(p.i());
            list.add(p.j());
            pairs.remove(p);
            m = pairs.size();
            if (m > 0) {
                final List<Pair> toRemove = new ArrayList<Pair>();
                for (int x = 0; x < m; x++) {
                    p = pairs.get(x);
                    final int i = p.i();
                    final int j = p.j();
                    if (list.contains(i) && list.contains(j)) {
                        if (!toRemove.contains(p)) {
                            toRemove.add(p);
                        }
                    } else if (!list.contains(i) && list.contains(j)) {
                        list.add(i);
                        if (!toRemove.contains(p)) {
                            toRemove.add(p);
                        }
                    } else if (!list.contains(j) && list.contains(i)) {
                        list.add(j);
                        if (!toRemove.contains(p)) {
                            toRemove.add(p);
                        }
                    }
                }
                if (!toRemove.isEmpty()) {
                    pairs.removeAll(toRemove);
                }
            }
            final List<Foundation> group = new ArrayList<Foundation>();
            for (final Integer a : list) {
                group.add(foundations.get(a));
            }
            foundationGroups.add(group);
            count += group.size();
            m = pairs.size();
        }
        if (count < foundations.size()) {
            for (final Foundation f : foundations) {
                boolean linked = false;
                for (final List<Foundation> g : foundationGroups) {
                    if (g.contains(f)) {
                        linked = true;
                        break;
                    }
                }
                if (!linked) {
                    final List<Foundation> g = new ArrayList<Foundation>();
                    g.add(f);
                    foundationGroups.add(g);
                }
            }
        }
    // System.out.println("###" + foundationGroups.size() + "," + (foundations.size() - count));
    } else {
        foundationGroups.add(foundations);
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) Pair(org.concord.energy3d.util.Pair)

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