Search in sources :

Example 26 with ParabolicTrough

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

the class Scene method setLengthForAllParabolicTroughs.

public void setLengthForAllParabolicTroughs(final double length) {
    for (final HousePart p : parts) {
        if (p instanceof ParabolicTrough) {
            final ParabolicTrough t = (ParabolicTrough) p;
            t.setTroughLength(length);
            t.ensureFullModules(false);
            t.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) HousePart(org.concord.energy3d.model.HousePart)

Example 27 with ParabolicTrough

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

the class Scene method setBaseHeightForAllParabolicTroughs.

public void setBaseHeightForAllParabolicTroughs(final double baseHeight) {
    for (final HousePart p : parts) {
        if (p instanceof ParabolicTrough) {
            ((ParabolicTrough) p).setBaseHeight(baseHeight);
            p.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) HousePart(org.concord.energy3d.model.HousePart)

Example 28 with ParabolicTrough

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

the class Scene method removeAllParabolicTroughs.

public void removeAllParabolicTroughs() {
    final ArrayList<HousePart> troughs = new ArrayList<HousePart>();
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (selectedPart != null) {
        final Foundation foundation = selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer();
        for (final HousePart part : parts) {
            if (part instanceof ParabolicTrough && part.getTopContainer() == foundation) {
                troughs.add(part);
            }
        }
    } else {
        for (final HousePart part : parts) {
            if (part instanceof ParabolicTrough) {
                troughs.add(part);
            }
        }
    }
    if (troughs.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no parabolic trough to remove.", "No Parabolic Trough", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + troughs.size() + " parabolic troughs" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(troughs);
    for (final HousePart part : troughs) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) ArrayList(java.util.ArrayList) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 29 with ParabolicTrough

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

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

the class SceneManager method update.

@Override
public void update(final ReadOnlyTimer timer) {
    final double tpf = timer.getTimePerFrame();
    passManager.updatePasses(tpf);
    taskManager.getQueue(GameTaskQueue.UPDATE).setExecuteMultiple(executeAllTask);
    taskManager.getQueue(GameTaskQueue.UPDATE).execute(canvas.getCanvasRenderer().getRenderer());
    if (operationFlag) {
        executeOperation();
    }
    if (mouseState != null) {
        mouseMoved();
    }
    if (Scene.isRedrawAll()) {
        Scene.getInstance().redrawAllNow();
    }
    if (rotAnim && viewMode == ViewMode.NORMAL && canvas.getCanvasRenderer() != null) {
        final Matrix3 rotate = new Matrix3();
        rotate.fromAngleNormalAxis(45 * tpf * MathUtils.DEG_TO_RAD, Vector3.UNIT_Z);
        final Camera camera = getCamera();
        camera.setLocation(rotate.applyPre(camera.getLocation(), null));
        camera.lookAt(0, 0, 1, Vector3.UNIT_Z);
        getCameraNode().updateFromCamera();
        Scene.getInstance().updateEditShapes();
    }
    final Heliodon heliodon = Heliodon.getInstance();
    if (heliodon != null) {
        if (sunAnim) {
            heliodon.setHourAngle(heliodon.getHourAngle() + tpf * 0.5, true, true, false);
            SceneManager.getInstance().changeSkyTexture();
            SceneManager.getInstance().setShading(heliodon.isNightTime());
            final boolean night = Heliodon.getInstance().isNightTime();
            for (final HousePart part : Scene.getInstance().getParts()) {
                if (part instanceof Mirror) {
                    final Mirror m = (Mirror) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        m.drawSunBeam();
                    } else {
                        if (m.getReceiver() != null) {
                            m.draw();
                        }
                    }
                } else if (part instanceof ParabolicTrough) {
                    final ParabolicTrough t = (ParabolicTrough) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        t.drawSunBeam();
                    } else {
                        t.draw();
                    }
                } else if (part instanceof ParabolicDish) {
                    final ParabolicDish d = (ParabolicDish) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        d.drawSunBeam();
                    } else {
                        d.draw();
                    }
                } else if (part instanceof FresnelReflector) {
                    final FresnelReflector f = (FresnelReflector) part;
                    if (night) {
                        // call this so that the light beams can be set invisible
                        f.drawSunBeam();
                    } else {
                        f.draw();
                    }
                } else if (part instanceof SolarPanel) {
                    final SolarPanel sp = (SolarPanel) part;
                    if (!night && sp.getTracker() != Trackable.NO_TRACKER) {
                        sp.draw();
                    }
                    if (sp.isSunBeamVisible()) {
                        sp.drawSunBeam();
                    }
                } else if (part instanceof Rack) {
                    final Rack rack = (Rack) part;
                    if (!night && rack.getTracker() != Trackable.NO_TRACKER) {
                        rack.draw();
                    }
                    if (rack.isSunBeamVisible()) {
                        rack.drawSunBeam();
                    }
                }
            }
        }
        heliodon.update();
    }
    if (cameraControl != null && cameraControl.isAnimating()) {
        cameraControl.animate();
    }
    root.updateGeometricState(tpf);
}
Also used : ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) SolarPanel(org.concord.energy3d.model.SolarPanel) Camera(com.ardor3d.renderer.Camera) Mirror(org.concord.energy3d.model.Mirror) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) Matrix3(com.ardor3d.math.Matrix3) Heliodon(org.concord.energy3d.shapes.Heliodon)

Aggregations

ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)44 HousePart (org.concord.energy3d.model.HousePart)30 Foundation (org.concord.energy3d.model.Foundation)22 FresnelReflector (org.concord.energy3d.model.FresnelReflector)18 Mirror (org.concord.energy3d.model.Mirror)17 ParabolicDish (org.concord.energy3d.model.ParabolicDish)17 Rack (org.concord.energy3d.model.Rack)16 SolarPanel (org.concord.energy3d.model.SolarPanel)14 Window (org.concord.energy3d.model.Window)14 Roof (org.concord.energy3d.model.Roof)10 Wall (org.concord.energy3d.model.Wall)10 Door (org.concord.energy3d.model.Door)9 ArrayList (java.util.ArrayList)6 Calendar (java.util.Calendar)5 List (java.util.List)5 JDialog (javax.swing.JDialog)4 Tree (org.concord.energy3d.model.Tree)4 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)3 Human (org.concord.energy3d.model.Human)3 UserData (org.concord.energy3d.model.UserData)3