Search in sources :

Example 1 with MovePartCommand

use of org.concord.energy3d.undo.MovePartCommand 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

ArrayList (java.util.ArrayList)1 List (java.util.List)1 CustomRoof (org.concord.energy3d.model.CustomRoof)1 Foundation (org.concord.energy3d.model.Foundation)1 FoundationPolygon (org.concord.energy3d.model.FoundationPolygon)1 GambrelRoof (org.concord.energy3d.model.GambrelRoof)1 HipRoof (org.concord.energy3d.model.HipRoof)1 HousePart (org.concord.energy3d.model.HousePart)1 Human (org.concord.energy3d.model.Human)1 PickedHousePart (org.concord.energy3d.model.PickedHousePart)1 PyramidRoof (org.concord.energy3d.model.PyramidRoof)1 Roof (org.concord.energy3d.model.Roof)1 ShedRoof (org.concord.energy3d.model.ShedRoof)1 SolarCollector (org.concord.energy3d.model.SolarCollector)1 Tree (org.concord.energy3d.model.Tree)1 Window (org.concord.energy3d.model.Window)1 MovePartCommand (org.concord.energy3d.undo.MovePartCommand)1