Search in sources :

Example 71 with HousePart

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

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

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

Example 74 with HousePart

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

the class SceneManager method hideAllEditPoints.

public void hideAllEditPoints() {
    for (final HousePart part : Scene.getInstance().getParts()) {
        part.setEditPointsVisible(false);
        part.setGridsVisible(false);
        part.setLinePatternVisible(false);
    }
    selectedPart = null;
    refresh = true;
}
Also used : PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart)

Example 75 with HousePart

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

the class SceneManager method mouseMoved.

private void mouseMoved() {
    if (!mouseControlEnabled) {
        return;
    }
    final int x = mouseState.getX();
    final int y = mouseState.getY();
    if (Scene.getInstance().getDisableShadowInAction()) {
        if (mouseState.getButtonState(MouseButton.LEFT) == ButtonState.DOWN || mouseState.getButtonState(MouseButton.RIGHT) == ButtonState.DOWN) {
            if (MainPanel.getInstance().getShadowButton().isSelected()) {
                shadowPass.setEnabled(false);
            }
        } else {
            if (MainPanel.getInstance().getShadowButton().isSelected()) {
                shadowPass.setEnabled(true);
            }
        }
    }
    try {
        if (selectedPart != null) {
            if (!selectedPart.isDrawCompleted()) {
                selectedPart.setPreviewPoint(x, y);
                if (selectedPart instanceof Meshable) {
                    // don't draw grid if it sits on an imported mesh
                    selectedPart.setGridsVisible(((Meshable) selectedPart).getMeshLocator() == null);
                }
            } else if (objectMoveStartPoint != null) {
                if ((operation == Operation.RESIZE || selectedPart instanceof Foundation)) {
                    final PickedHousePart pick = SelectUtil.pickPart(x, y, collisionLand);
                    if (pick != null) {
                        if (selectedPart instanceof Foundation) {
                            final Foundation foundation = (Foundation) selectedPart;
                            final Vector3 pickPoint = pick.getPoint().clone();
                            // if (!foundation.insideBuilding(pickPoint.getX(), pickPoint.getY(), true)) { // only move the building when clicking outside
                            final Vector3 d = pickPoint.multiply(1, 1, 0, null).subtractLocal(objectMoveStartPoint.multiply(1, 1, 0, null));
                            if (foundation.isGroupMaster()) {
                                final List<Foundation> g = Scene.getInstance().getFoundationGroup(foundation);
                                for (final Foundation f : g) {
                                    final ArrayList<Vector3> movePoints = objectGroupMovePoints.get(f);
                                    if (movePoints != null) {
                                        // just in case this foundation's move point hasn't been included yet
                                        f.move(d, movePoints);
                                    }
                                }
                            } else {
                                foundation.move(d, objectMovePoints);
                            }
                        }
                    }
                } else if (selectedPart instanceof Tree) {
                    final PickedHousePart pick = SelectUtil.pickPart(x, y, collisionLand);
                    if (pick != null) {
                        final Vector3 d = pick.getPoint().multiply(1, 1, 0, null).subtractLocal(objectMoveStartPoint.multiply(1, 1, 0, null));
                        ((Tree) selectedPart).move(d, objectMovePoints);
                    }
                } else if (selectedPart instanceof Window) {
                    final PickedHousePart pick = SelectUtil.pickPart(x, y, selectedPart.getContainer());
                    if (pick != null) {
                        final Vector3 d = pick.getPoint().subtract(objectMoveStartPoint, null);
                        ((Window) selectedPart).move(d, objectMovePoints);
                    }
                }
            }
        }
        hoveredPart = null;
        if ((operation == Operation.SELECT || operation == Operation.RESIZE) && mouseState.getButtonState(MouseButton.LEFT) == ButtonState.UP && mouseState.getButtonState(MouseButton.MIDDLE) == ButtonState.UP && mouseState.getButtonState(MouseButton.RIGHT) == ButtonState.UP) {
            final PickedHousePart pickedPart = SelectUtil.selectHousePart(x, y, false);
            pick = pickedPart == null ? null : pickedPart.getUserData();
            final HousePart housePart = pick == null ? null : pick.getHousePart();
            if (pick != null) {
                hoveredPart = housePart;
                if (pick.getEditPointIndex() != -1) {
                    lastSelectedEditPointMouseState = mouseState;
                }
            }
        }
        mouseState = null;
    } catch (final Throwable t) {
        t.printStackTrace();
        BugReporter.report(t);
    }
    EventQueue.invokeLater(new // this method is run by the main Energy3D thread, so invoke the Swing code later
    Runnable() {

        @Override
        public void run() {
            final Component canvasComponent = (Component) canvas;
            canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            if (!zoomLock && (operation == Operation.SELECT || operation == Operation.RESIZE) && hoveredPart != null) {
                if (hoveredPart instanceof Tree || hoveredPart instanceof Human) {
                    canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
                } else if (hoveredPart instanceof SolarCollector) {
                    if (pick.getEditPointIndex() >= 0) {
                        canvasComponent.setCursor(Cursor.getPredefinedCursor(pick.getEditPointIndex() == 0 ? Cursor.MOVE_CURSOR : Cursor.HAND_CURSOR));
                    }
                } else {
                    if (pick.getEditPointIndex() == -1) {
                        if (hoveredPart instanceof Window) {
                            // for windows, there is no apparent move point
                            canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
                        }
                    }
                }
            }
        }
    });
}
Also used : Window(org.concord.energy3d.model.Window) Human(org.concord.energy3d.model.Human) ArrayList(java.util.ArrayList) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) Meshable(org.concord.energy3d.model.Meshable) 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) Component(java.awt.Component) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

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