Search in sources :

Example 51 with SolarPanel

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

the class Scene method removeAllSolarPanels.

public void removeAllSolarPanels(List<SolarPanel> panels) {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (panels == null) {
        panels = new ArrayList<SolarPanel>();
        if (selectedPart != null) {
            if (selectedPart instanceof Rack) {
                for (final HousePart part : selectedPart.getChildren()) {
                    if (part instanceof SolarPanel) {
                        panels.add((SolarPanel) part);
                    }
                }
            } else {
                final Foundation foundation = selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer();
                for (final HousePart part : parts) {
                    if (part instanceof SolarPanel && part.getTopContainer() == foundation) {
                        panels.add((SolarPanel) part);
                    }
                }
            }
        } else {
            for (final HousePart part : parts) {
                if (part instanceof SolarPanel) {
                    panels.add((SolarPanel) part);
                }
            }
        }
    }
    if (panels.isEmpty()) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no solar panel to remove.", "No Solar Panel", JOptionPane.INFORMATION_MESSAGE);
        return;
    }
    if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + panels.size() + " solar panels" + (selectedPart != null ? " of the selected building" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }
    final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(new ArrayList<HousePart>(panels));
    for (final HousePart part : panels) {
        remove(part, false);
    }
    redrawAll();
    SceneManager.getInstance().getUndoManager().addEdit(c);
    edited = true;
}
Also used : Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 52 with SolarPanel

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

the class Scene method setSolarPanelSizeForAllRacks.

public void setSolarPanelSizeForAllRacks(final double width, final double height, final int numberOfCellsInX, final int numberOfCellsInY) {
    for (final HousePart p : parts) {
        if (p instanceof Rack) {
            final Rack rack = (Rack) p;
            final SolarPanel s = rack.getSolarPanel();
            s.setPanelWidth(width);
            s.setPanelHeight(height);
            s.setNumberOfCellsInX(numberOfCellsInX);
            s.setNumberOfCellsInY(numberOfCellsInY);
            rack.ensureFullSolarPanels(false);
            rack.draw();
        }
    }
    SceneManager.getInstance().refresh();
}
Also used : Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) HousePart(org.concord.energy3d.model.HousePart)

Example 53 with SolarPanel

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

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

Example 55 with SolarPanel

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

the class PvDailyAnalysis method show.

public void show() {
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    String s = null;
    int cost = -1;
    String title = "Daily Yield of All Solar Panels (" + Scene.getInstance().countSolarPanels() + " Panels)";
    if (selectedPart != null) {
        if (selectedPart instanceof SolarPanel) {
            cost = (int) ProjectCost.getCost(selectedPart);
            s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
            title = "Daily Yield";
        } else if (selectedPart instanceof Rack) {
            final Rack rack = (Rack) selectedPart;
            cost = (int) ProjectCost.getCost(rack);
            s = selectedPart.toString().substring(0, selectedPart.toString().indexOf(')') + 1);
            title = "Daily Yield (" + rack.getNumberOfSolarPanels() + " Solar Panels)";
        } else if (selectedPart instanceof Foundation) {
            title = "Daily Yield on Selected Foundation (" + ((Foundation) selectedPart).getNumberOfSolarPanels() + " Solar Panels)";
        } else if (selectedPart.getTopContainer() != null) {
            title = "Daily Yield on Selected Foundation (" + selectedPart.getTopContainer().getNumberOfSolarPanels() + " Solar Panels)";
        }
    }
    final JDialog dialog = createDialog(s == null ? title : title + ": " + s + " (Cost: $" + cost + ")");
    final JMenuBar menuBar = new JMenuBar();
    dialog.setJMenuBar(menuBar);
    menuBar.add(createOptionsMenu(dialog, null, true));
    menuBar.add(createRunsMenu());
    dialog.setVisible(true);
}
Also used : Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) HousePart(org.concord.energy3d.model.HousePart) JDialog(javax.swing.JDialog) JMenuBar(javax.swing.JMenuBar)

Aggregations

SolarPanel (org.concord.energy3d.model.SolarPanel)109 Rack (org.concord.energy3d.model.Rack)66 HousePart (org.concord.energy3d.model.HousePart)58 Foundation (org.concord.energy3d.model.Foundation)43 Window (org.concord.energy3d.model.Window)25 Roof (org.concord.energy3d.model.Roof)24 Wall (org.concord.energy3d.model.Wall)23 Mirror (org.concord.energy3d.model.Mirror)20 Door (org.concord.energy3d.model.Door)17 FresnelReflector (org.concord.energy3d.model.FresnelReflector)14 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)14 ActionEvent (java.awt.event.ActionEvent)13 ActionListener (java.awt.event.ActionListener)13 ParabolicDish (org.concord.energy3d.model.ParabolicDish)13 Vector3 (com.ardor3d.math.Vector3)11 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)11 JMenuItem (javax.swing.JMenuItem)10 JDialog (javax.swing.JDialog)9 JPanel (javax.swing.JPanel)9 Tree (org.concord.energy3d.model.Tree)9