Search in sources :

Example 26 with Foundation

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

the class SceneManager method autoSelectBuilding.

public Foundation autoSelectBuilding(final boolean ask) {
    Foundation foundation = null;
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart == null || selectedPart instanceof Tree || selectedPart instanceof Human) {
        SceneManager.getInstance().setSelectedPart(null);
        int count = 0;
        HousePart hp = null;
        for (final HousePart x : Scene.getInstance().getParts()) {
            if (x instanceof Foundation) {
                count++;
                hp = x;
            }
        }
        if (count == 1) {
            SceneManager.getInstance().setSelectedPart(hp);
            foundation = (Foundation) hp;
        } else {
            if (ask) {
                if (count > 1) {
                    JOptionPane.showMessageDialog(MainFrame.getInstance(), "There are multiple buildings. You must select a building first.", "No Selection", JOptionPane.WARNING_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no building.", "No Building", JOptionPane.WARNING_MESSAGE);
                }
            }
        }
    } else {
        final HousePart topContainer = selectedPart.getTopContainer();
        if (selectedPart instanceof Foundation) {
            foundation = (Foundation) selectedPart;
        } else if (topContainer instanceof Foundation) {
            selectedPart.setEditPointsVisible(false);
            SceneManager.getInstance().setSelectedPart(topContainer);
            foundation = (Foundation) topContainer;
        } else {
            if (ask) {
                JOptionPane.showMessageDialog(MainFrame.getInstance(), "You must select a building first.", "No Selection", JOptionPane.WARNING_MESSAGE);
            }
        }
    }
    return foundation;
}
Also used : Human(org.concord.energy3d.model.Human) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 27 with Foundation

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

the class SceneManager method newPart.

private HousePart newPart() {
    final HousePart drawn;
    setGridsVisible(false);
    if (operation == Operation.DRAW_WALL) {
        drawn = new Wall();
        drawn.setColor(Scene.getInstance().getWallColor());
    } else if (operation == Operation.DRAW_DOOR) {
        drawn = new Door();
        drawn.setColor(Scene.getInstance().getDoorColor());
    } else if (operation == Operation.DRAW_WINDOW) {
        drawn = new Window();
    } else if (operation == Operation.DRAW_ROOF_PYRAMID) {
        drawn = new PyramidRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_HIP) {
        drawn = new HipRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_SHED) {
        drawn = new ShedRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_GAMBREL) {
        drawn = new GambrelRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_CUSTOM) {
        drawn = new CustomRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_FLOOR) {
        drawn = new Floor();
        drawn.setColor(Scene.getInstance().getFloorColor());
    } else if (operation == Operation.DRAW_SOLAR_PANEL) {
        drawn = new SolarPanel();
    } else if (operation == Operation.DRAW_RACK) {
        drawn = new Rack();
    } else if (operation == Operation.DRAW_MIRROR) {
        drawn = new Mirror();
    } else if (operation == Operation.DRAW_PARABOLIC_TROUGH) {
        drawn = new ParabolicTrough();
    } else if (operation == Operation.DRAW_PARABOLIC_DISH) {
        drawn = new ParabolicDish();
    } else if (operation == Operation.DRAW_FRESNEL_REFLECTOR) {
        drawn = new FresnelReflector();
    } else if (operation == Operation.DRAW_SENSOR) {
        drawn = new Sensor();
    } else if (operation == Operation.DRAW_FOUNDATION) {
        drawn = new Foundation();
        setGridsVisible(Scene.getInstance().isSnapToGrids());
        drawn.setColor(Scene.getInstance().getFoundationColor());
    } else if (operation == Operation.DRAW_DOGWOOD) {
        drawn = new Tree(Tree.DOGWOOD);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_ELM) {
        drawn = new Tree(Tree.ELM);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_OAK) {
        drawn = new Tree(Tree.OAK);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_LINDEN) {
        drawn = new Tree(Tree.LINDEN);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_COTTONWOOD) {
        drawn = new Tree(Tree.COTTONWOOD);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_MAPLE) {
        drawn = new Tree(Tree.MAPLE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_PINE) {
        drawn = new Tree(Tree.PINE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JANE) {
        drawn = new Human(Human.JANE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JENI) {
        drawn = new Human(Human.JENI);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JILL) {
        drawn = new Human(Human.JILL);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JACK) {
        drawn = new Human(Human.JACK);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JOHN) {
        drawn = new Human(Human.JOHN);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JOSE) {
        drawn = new Human(Human.JOSE);
        setGridsVisible(true);
    } else {
        return null;
    }
    Scene.getInstance().add(drawn, false);
    addPartCommand = new AddPartCommand(drawn);
    return drawn;
}
Also used : Window(org.concord.energy3d.model.Window) Human(org.concord.energy3d.model.Human) Floor(org.concord.energy3d.model.Floor) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) ShedRoof(org.concord.energy3d.model.ShedRoof) Door(org.concord.energy3d.model.Door) GambrelRoof(org.concord.energy3d.model.GambrelRoof) CustomRoof(org.concord.energy3d.model.CustomRoof) ParabolicDish(org.concord.energy3d.model.ParabolicDish) PyramidRoof(org.concord.energy3d.model.PyramidRoof) Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) AddPartCommand(org.concord.energy3d.undo.AddPartCommand) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HipRoof(org.concord.energy3d.model.HipRoof) Mirror(org.concord.energy3d.model.Mirror) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) Sensor(org.concord.energy3d.model.Sensor)

Example 28 with Foundation

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

the class SceneManager method rotate.

public void rotate(final double angle) {
    if (SceneManager.getInstance().getSolarHeatMap()) {
        EnergyPanel.getInstance().updateRadiationHeatMap();
    }
    taskManager.update(new Callable<Object>() {

        @Override
        public Object call() {
            final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
            if (selectedPart instanceof Foundation) {
                final RotateBuildingCommand c = new RotateBuildingCommand((Foundation) selectedPart, angle);
                SceneManager.getInstance().rotateFoundation(angle, true);
                SceneManager.getInstance().getUndoManager().addEdit(c);
            } else if (selectedPart instanceof SolarPanel) {
                final SolarPanel solarPanel = (SolarPanel) selectedPart;
                final ChangeAzimuthCommand c = new ChangeAzimuthCommand(solarPanel);
                solarPanel.setRelativeAzimuth(solarPanel.getRelativeAzimuth() + Math.toDegrees(angle));
                solarPanel.draw();
                SceneManager.getInstance().getUndoManager().addEdit(c);
            } else if (selectedPart instanceof Rack) {
                final Rack rack = (Rack) selectedPart;
                final ChangeAzimuthCommand c = new ChangeAzimuthCommand(rack);
                rack.setRelativeAzimuth(rack.getRelativeAzimuth() + Math.toDegrees(angle));
                rack.draw();
                SceneManager.getInstance().getUndoManager().addEdit(c);
            } else if (selectedPart instanceof Mirror) {
                final Mirror mirror = (Mirror) selectedPart;
                final ChangeAzimuthCommand c = new ChangeAzimuthCommand(mirror);
                mirror.setRelativeAzimuth(mirror.getRelativeAzimuth() + Math.toDegrees(angle));
                mirror.draw();
                SceneManager.getInstance().getUndoManager().addEdit(c);
            } else if (selectedPart == null) {
                final RotateBuildingCommand c = new RotateBuildingCommand(null, angle);
                rotateAllFoundations(angle);
                SceneManager.getInstance().getUndoManager().addEdit(c);
            }
            EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    EnergyPanel.getInstance().updateProperties();
                }
            });
            return null;
        }
    });
}
Also used : RotateBuildingCommand(org.concord.energy3d.undo.RotateBuildingCommand) Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) ChangeAzimuthCommand(org.concord.energy3d.undo.ChangeAzimuthCommand) Mirror(org.concord.energy3d.model.Mirror) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart)

Example 29 with Foundation

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

the class SceneManager method executeOperation.

public void executeOperation() {
    operationFlag = false;
    if (operation == Operation.RESIZE) {
        if (selectedPart instanceof Foundation) {
            ((Foundation) selectedPart).setResizeHouseMode(true);
        }
    } else {
        for (final HousePart part : Scene.getInstance().getParts()) {
            if (part instanceof Foundation) {
                ((Foundation) part).setResizeHouseMode(false);
            }
        }
    }
    if (viewMode != ViewMode.PRINT_PREVIEW) {
        Scene.getInstance().drawResizeBounds();
    }
    selectedPart = newPart();
    if (selectedPart != null) {
        cameraControl.setLeftMouseButtonEnabled(false);
    }
}
Also used : Foundation(org.concord.energy3d.model.Foundation) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart)

Example 30 with Foundation

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

the class SceneManager method move.

public void move(final Vector3 v) {
    if (SceneManager.getInstance().getSolarHeatMap()) {
        EnergyPanel.getInstance().updateRadiationHeatMap();
    }
    final MovePartCommand c = new MovePartCommand(selectedPart, v);
    if (selectedPart == null) {
        for (final HousePart p : Scene.getInstance().getParts()) {
            if (p instanceof Foundation) {
                ((Foundation) p).move(v, p.getGridSize());
            }
        }
        Scene.getInstance().redrawAll();
    } else if (selectedPart instanceof Foundation) {
        final Foundation f = (Foundation) selectedPart;
        if (f.isGroupMaster()) {
            final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
            for (final Foundation x : g) {
                x.move(v, selectedPart.getGridSize());
            }
        } else {
            f.move(v, selectedPart.getGridSize());
        }
    } else if (selectedPart instanceof FoundationPolygon) {
        ((Foundation) selectedPart.getContainer()).moveAllWithinPolygon(v);
    } else if (selectedPart instanceof Roof) {
        if (viewMode == ViewMode.TOP_VIEW) {
            final Foundation f = selectedPart.getTopContainer();
            if (f.isGroupMaster()) {
                final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
                for (final Foundation x : g) {
                    x.move(v, selectedPart.getGridSize());
                }
            } else {
                f.move(v, selectedPart.getGridSize());
            }
        }
    } else if (selectedPart instanceof Window) {
        final Window w = (Window) selectedPart;
        w.move(v);
        w.draw();
    } else if (selectedPart instanceof SolarCollector) {
        final SolarCollector sc = (SolarCollector) selectedPart;
        sc.move(v, selectedPart.getGridSize());
        selectedPart.draw();
    } else if (selectedPart instanceof Tree) {
        final Tree t = (Tree) selectedPart;
        t.move(v, selectedPart.getGridSize());
        t.draw();
    } else if (selectedPart instanceof Human) {
        final Human h = (Human) selectedPart;
        h.move(v, selectedPart.getGridSize());
        h.draw();
    }
    undoManager.addEdit(c);
    SceneManager.getInstance().refresh();
    Scene.getInstance().setEdited(true);
}
Also used : Window(org.concord.energy3d.model.Window) Human(org.concord.energy3d.model.Human) Roof(org.concord.energy3d.model.Roof) GambrelRoof(org.concord.energy3d.model.GambrelRoof) ShedRoof(org.concord.energy3d.model.ShedRoof) PyramidRoof(org.concord.energy3d.model.PyramidRoof) HipRoof(org.concord.energy3d.model.HipRoof) CustomRoof(org.concord.energy3d.model.CustomRoof) MovePartCommand(org.concord.energy3d.undo.MovePartCommand) SolarCollector(org.concord.energy3d.model.SolarCollector) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) ArrayList(java.util.ArrayList) List(java.util.List) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) FoundationPolygon(org.concord.energy3d.model.FoundationPolygon)

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