Search in sources :

Example 6 with PastePartCommand

use of org.concord.energy3d.undo.PastePartCommand in project energy3d by concord-consortium.

the class Scene method pasteToPickedLocationOnFloor.

public void pasteToPickedLocationOnFloor() {
    EnergyPanel.getInstance().updateRadiationHeatMap();
    if (copyBuffer == null) {
        return;
    }
    if (copyBuffer instanceof Foundation) {
        return;
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Floor)) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnFloor();
    if (position == null) {
        return;
    }
    if (selectedPart != c.getContainer()) {
        // solar panels and racks can be pasted to a different parent
        if (c instanceof SolarPanel) {
            ((SolarPanel) c).moveTo(selectedPart);
        } else if (c instanceof Rack) {
            ((Rack) c).moveTo(selectedPart);
        }
    }
    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);
    }
    if (c instanceof Rack) {
        ((Rack) c).moveSolarPanels(position);
        setIdOfChildren(c);
    }
    add(c, true);
    copyBuffer = c;
    SceneManager.getInstance().setSelectedPart(c);
    SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
Also used : Floor(org.concord.energy3d.model.Floor) Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) 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 7 with PastePartCommand

use of org.concord.energy3d.undo.PastePartCommand in project energy3d by concord-consortium.

the class Scene method pasteToPickedLocationOnMesh.

public void pasteToPickedLocationOnMesh(final Mesh mesh) {
    EnergyPanel.getInstance().updateRadiationHeatMap();
    if (copyBuffer == null) {
        return;
    }
    if (copyBuffer instanceof Foundation) {
        return;
    }
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Foundation)) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnMesh(mesh);
    if (position == null) {
        return;
    }
    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);
    }
    if (copyBuffer instanceof Rack) {
        final Rack rack = (Rack) c;
        rack.moveSolarPanels(position);
        setIdOfChildren(c);
        final MeshLocator originalMeshLocator = ((Rack) copyBuffer).getMeshLocator();
        if (originalMeshLocator != null) {
            final UserData ud = (UserData) mesh.getUserData();
            rack.setMeshLocator(new MeshLocator((Foundation) ud.getHousePart(), ud.getNodeIndex(), ud.getMeshIndex()));
        }
    } else if (copyBuffer instanceof SolarPanel) {
        final SolarPanel panel = (SolarPanel) c;
        final MeshLocator originalMeshLocator = ((SolarPanel) copyBuffer).getMeshLocator();
        if (originalMeshLocator != null) {
            final UserData ud = (UserData) mesh.getUserData();
            panel.setMeshLocator(new MeshLocator((Foundation) ud.getHousePart(), ud.getNodeIndex(), ud.getMeshIndex()));
        }
    }
    add(c, true);
    copyBuffer = c;
    SceneManager.getInstance().setSelectedPart(c);
    SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
Also used : Rack(org.concord.energy3d.model.Rack) UserData(org.concord.energy3d.model.UserData) MeshLocator(org.concord.energy3d.model.MeshLocator) SolarPanel(org.concord.energy3d.model.SolarPanel) 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 8 with PastePartCommand

use of org.concord.energy3d.undo.PastePartCommand in project energy3d by concord-consortium.

the class Scene method pasteToPickedLocationOnRack.

public void pasteToPickedLocationOnRack() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Rack)) {
        return;
    }
    if (!(copyBuffer instanceof SolarPanel)) {
        return;
    }
    EnergyPanel.getInstance().updateRadiationHeatMap();
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnRack();
    if (position == null) {
        return;
    }
    if (selectedPart != c.getContainer()) {
        ((SolarPanel) c).moveTo(selectedPart);
    }
    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);
    }
    add(c, true);
    copyBuffer = c;
    SceneManager.getInstance().setSelectedPart(c);
    SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
Also used : Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) HousePart(org.concord.energy3d.model.HousePart) PastePartCommand(org.concord.energy3d.undo.PastePartCommand)

Aggregations

HousePart (org.concord.energy3d.model.HousePart)8 PastePartCommand (org.concord.energy3d.undo.PastePartCommand)8 Vector3 (com.ardor3d.math.Vector3)7 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)7 Foundation (org.concord.energy3d.model.Foundation)7 Rack (org.concord.energy3d.model.Rack)5 SolarPanel (org.concord.energy3d.model.SolarPanel)5 ArrayList (java.util.ArrayList)2 Wall (org.concord.energy3d.model.Wall)2 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)1 Node (com.ardor3d.scenegraph.Node)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Floor (org.concord.energy3d.model.Floor)1 Human (org.concord.energy3d.model.Human)1 MeshLocator (org.concord.energy3d.model.MeshLocator)1 NodeState (org.concord.energy3d.model.NodeState)1 Roof (org.concord.energy3d.model.Roof)1 Tree (org.concord.energy3d.model.Tree)1