Search in sources :

Example 11 with PickedHousePart

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

the class SceneManager method getPickedLocationOnFoundation.

public Vector3 getPickedLocationOnFoundation() {
    if (pickMouseState != null) {
        final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
        if (selectedPart instanceof Foundation) {
            final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), selectedPart);
            if (pick != null) {
                return pick.getPoint().clone();
            }
        }
        pickMouseState = null;
    }
    return null;
}
Also used : Foundation(org.concord.energy3d.model.Foundation) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Example 12 with PickedHousePart

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

the class SceneManager method mousePressed.

private void mousePressed(final MouseState mouseState, final KeyboardState keyboardState) {
    refresh = true;
    taskManager.update(new Callable<Object>() {

        @Override
        public Object call() {
            if (zoomLock) {
                return null;
            }
            System.out.println("OPERATION: " + operation);
            try {
                if (operation == Operation.SELECT || operation == Operation.RESIZE || operation == Operation.ROTATE || operation == Operation.DRAW_ROOF_GABLE) {
                    if (selectedPart == null || selectedPart.isDrawCompleted()) {
                        final HousePart previousSelectedPart = selectedPart;
                        final PickedHousePart pickedPart = SelectUtil.selectHousePart(mouseState.getX(), mouseState.getY(), true);
                        final UserData pick = pickedPart == null ? null : pickedPart.getUserData();
                        if (pick == null) {
                            selectedPart = null;
                        } else {
                            selectedPart = pick.getHousePart();
                        }
                        if (selectedPart != null) {
                            // }
                            if (keyboardState.isDown(Key.LMENU) || keyboardState.isDown(Key.RMENU)) {
                                if (selectedPart instanceof SolarPanel && selectedPart.getContainer() instanceof Rack) {
                                    // special case
                                    selectedPart = selectedPart.getContainer();
                                }
                            }
                        }
                        System.out.println("Clicked on: " + pick);
                        if (pick != null && pick.isEditPoint()) {
                            cameraControl.setLeftMouseButtonEnabled(false);
                        }
                        if (operation == Operation.RESIZE) {
                            for (final HousePart p : Scene.getInstance().getParts()) {
                                if (p instanceof Foundation) {
                                    if (p != selectedPart) {
                                        ((Foundation) p).setResizeHouseMode(false);
                                    }
                                }
                            }
                            if (selectedPart != null) {
                                if (selectedPart instanceof Foundation) {
                                    final Foundation foundation = (Foundation) selectedPart;
                                    foundation.setResizeHouseMode(true);
                                } else {
                                    final Foundation foundation = selectedPart.getTopContainer();
                                    if (foundation != null) {
                                        foundation.setResizeHouseMode(true);
                                        setSelectedPart(foundation);
                                    }
                                }
                            }
                        }
                        if (operation == Operation.SELECT || operation == Operation.ROTATE) {
                            if (previousSelectedPart instanceof Foundation) {
                                final Foundation foundation = (Foundation) previousSelectedPart;
                                foundation.updateAzimuthArrowVisibility(false);
                            }
                            if (selectedPart instanceof Foundation) {
                                final Foundation foundation = (Foundation) selectedPart;
                                foundation.drawAzimuthArrow();
                                foundation.pickMesh(mouseState.getX(), mouseState.getY());
                            }
                            if (selectedPart != null) {
                                final Foundation foundationOfSelectedPart = selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer();
                                if (foundationOfSelectedPart != null) {
                                    foundationOfSelectedPart.setMovePointsVisible(true);
                                }
                            }
                        }
                        if (operation == Operation.RESIZE && selectedPart != null) {
                            if (!(selectedPart instanceof Foundation)) {
                                selectedPart.setEditPointsVisible(false);
                                selectedPart = selectedPart.getTopContainer();
                            }
                        }
                        if (selectedPart instanceof Window || selectedPart instanceof Tree || (selectedPart instanceof Foundation && pick.getEditPointIndex() != -1)) {
                            cameraControl.setLeftMouseButtonEnabled(false);
                            objectMoveStartPoint = pickedPart.getPoint().clone();
                            collisionLand.setTranslation(0, 0, objectMoveStartPoint.getZ());
                            final ArrayList<Vector3> points = selectedPart.getPoints();
                            if (objectMovePoints == null) {
                                objectMovePoints = new ArrayList<Vector3>();
                            } else {
                                objectMovePoints.clear();
                            }
                            for (final Vector3 p : points) {
                                objectMovePoints.add(p.clone());
                            }
                            if (selectedPart instanceof Foundation) {
                                final Foundation f = (Foundation) selectedPart;
                                if (f.isGroupMaster()) {
                                    final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
                                    if (!g.isEmpty()) {
                                        if (objectGroupMovePoints == null) {
                                            objectGroupMovePoints = new HashMap<Foundation, ArrayList<Vector3>>();
                                        } else {
                                            objectGroupMovePoints.clear();
                                        }
                                        for (final Foundation a : g) {
                                            final ArrayList<Vector3> b = new ArrayList<Vector3>();
                                            objectGroupMovePoints.put(a, b);
                                            for (final Vector3 p : a.getPoints()) {
                                                b.add(p.clone());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (previousSelectedPart != null && previousSelectedPart != selectedPart && operation != Operation.RESIZE) {
                            previousSelectedPart.setEditPointsVisible(false);
                            previousSelectedPart.setGridsVisible(false);
                            previousSelectedPart.setLinePatternVisible(false);
                            final Foundation foundationOfPreviousSelectedPart = previousSelectedPart instanceof Foundation ? (Foundation) previousSelectedPart : previousSelectedPart.getTopContainer();
                            if (foundationOfPreviousSelectedPart != null) {
                                if (selectedPart == null) {
                                    foundationOfPreviousSelectedPart.setMovePointsVisible(false);
                                } else if (foundationOfPreviousSelectedPart != (selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer())) {
                                    foundationOfPreviousSelectedPart.setMovePointsVisible(false);
                                }
                                foundationOfPreviousSelectedPart.clearSelectedMesh();
                                foundationOfPreviousSelectedPart.setResizeHouseMode(false);
                            }
                        }
                        if (selectedPart != null && !PrintController.getInstance().isPrintPreview()) {
                            selectedPart.setEditPointsVisible(true);
                            if (pick.isEditPoint() && pick.getEditPointIndex() != -1 || operation == Operation.RESIZE || selectedPart instanceof Window || selectedPart instanceof Tree) {
                                if (Scene.getInstance().isSnapToGrids()) {
                                    selectedPart.setGridsVisible(true);
                                } else {
                                    selectedPart.setLinePatternVisible(true);
                                }
                                if (selectedPart instanceof Foundation) {
                                    editPartCommand = new EditFoundationCommand((Foundation) selectedPart, !pick.isEditPoint());
                                } else if (selectedPart instanceof Rack) {
                                    editPartCommand = new EditRackCommand((Rack) selectedPart);
                                } else if (selectedPart instanceof ParabolicTrough) {
                                    editPartCommand = new EditParabolicTroughCommand((ParabolicTrough) selectedPart);
                                } else {
                                    editPartCommand = new EditPartCommand(selectedPart);
                                }
                            }
                        }
                        SelectUtil.nextPickLayer();
                        if (operation == Operation.DRAW_ROOF_GABLE && selectedPart instanceof Roof) {
                            System.out.println("deleting roof #" + pick.getEditPointIndex());
                            final int roofPartIndex = pick.getEditPointIndex();
                            final Roof roof = (Roof) selectedPart;
                            roof.setGable(roofPartIndex, true, undoManager);
                        }
                    }
                } else {
                    if (selectedPart != null) {
                        // selected part can be null in modes other than specified in the if clause
                        selectedPart.addPoint(mouseState.getX(), mouseState.getY());
                    }
                }
            } catch (final Throwable t) {
                t.printStackTrace();
                BugReporter.report(t);
            }
            return null;
        }
    });
}
Also used : Window(org.concord.energy3d.model.Window) EditPartCommand(org.concord.energy3d.undo.EditPartCommand) EditRackCommand(org.concord.energy3d.undo.EditRackCommand) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) UserData(org.concord.energy3d.model.UserData) HashMap(java.util.HashMap) EditParabolicTroughCommand(org.concord.energy3d.undo.EditParabolicTroughCommand) ArrayList(java.util.ArrayList) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) Rack(org.concord.energy3d.model.Rack) EditFoundationCommand(org.concord.energy3d.undo.EditFoundationCommand) 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) SolarPanel(org.concord.energy3d.model.SolarPanel) 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) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Example 13 with PickedHousePart

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

the class SceneManager method getPickedLocationOnRack.

Vector3 getPickedLocationOnRack() {
    if (pickMouseState != null) {
        final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
        if (selectedPart instanceof Rack) {
            final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), selectedPart);
            if (pick != null) {
                return pick.getPoint().clone();
            }
        }
        pickMouseState = null;
    }
    return null;
}
Also used : Rack(org.concord.energy3d.model.Rack) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Example 14 with PickedHousePart

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

the class SceneManager method getPickedLocationOnRoof.

Vector3 getPickedLocationOnRoof() {
    if (pickMouseState != null) {
        final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
        if (selectedPart instanceof Roof) {
            final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), selectedPart);
            if (pick != null) {
                return pick.getPoint().clone();
            }
        }
        pickMouseState = null;
    }
    return null;
}
Also used : 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) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Example 15 with PickedHousePart

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

the class SceneManager method getPickedLocationOnWall.

Vector3 getPickedLocationOnWall() {
    if (pickMouseState != null) {
        final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
        if (selectedPart instanceof Wall) {
            final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), selectedPart);
            if (pick != null) {
                return pick.getPoint().clone();
            }
        }
        pickMouseState = null;
    }
    return null;
}
Also used : Wall(org.concord.energy3d.model.Wall) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) PickedHousePart(org.concord.energy3d.model.PickedHousePart)

Aggregations

PickedHousePart (org.concord.energy3d.model.PickedHousePart)18 HousePart (org.concord.energy3d.model.HousePart)12 Foundation (org.concord.energy3d.model.Foundation)8 Ray3 (com.ardor3d.math.Ray3)5 Vector2 (com.ardor3d.math.Vector2)5 UserData (org.concord.energy3d.model.UserData)5 Vector3 (com.ardor3d.math.Vector3)4 Window (org.concord.energy3d.model.Window)4 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)3 Roof (org.concord.energy3d.model.Roof)3 MouseState (com.ardor3d.input.MouseState)2 PickData (com.ardor3d.intersection.PickData)2 Mesh (com.ardor3d.scenegraph.Mesh)2 CullHint (com.ardor3d.scenegraph.hint.CullHint)2 Component (java.awt.Component)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CustomRoof (org.concord.energy3d.model.CustomRoof)2 GambrelRoof (org.concord.energy3d.model.GambrelRoof)2 HipRoof (org.concord.energy3d.model.HipRoof)2