Search in sources :

Example 11 with SolarPanel

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

the class Scene method pasteToPickedLocationOnWall.

public void pasteToPickedLocationOnWall() {
    EnergyPanel.getInstance().updateRadiationHeatMap();
    final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
    if (!(selectedPart instanceof Wall)) {
        return;
    }
    if (copyBuffer == null) {
        return;
    }
    if (copyBuffer instanceof Foundation) {
        return;
    }
    final HousePart c = copyBuffer.copy(false);
    if (c == null) {
        return;
    }
    Vector3 position = SceneManager.getInstance().getPickedLocationOnWall();
    if (position == null) {
        return;
    }
    final Wall wall = (Wall) selectedPart;
    if (wall != c.getContainer()) {
        // windows and solar panels can be pasted to a different wall
        if (c instanceof Window) {
            ((Window) c).moveTo(wall);
        } else if (c instanceof SolarPanel) {
            ((SolarPanel) c).moveTo(wall);
        }
    }
    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);
    }
    // out of boundary check
    final List<Vector3> polygon = wall.getWallPolygonPoints();
    final List<Vector3> relativePolygon = new ArrayList<Vector3>();
    for (final Vector3 p : polygon) {
        relativePolygon.add(c.toRelative(p));
    }
    for (final Vector3 p : relativePolygon) {
        final double y = p.getY();
        p.setY(p.getZ());
        p.setZ(y);
    }
    for (int i = 0; i < n; i++) {
        final Vector3 v = c.getPoints().get(i);
        if (!Util.insidePolygon(new Vector3(v.getX(), v.getZ(), v.getY()), relativePolygon)) {
            return;
        }
    }
    add(c, true);
    copyBuffer = c;
    SceneManager.getInstance().setSelectedPart(c);
    SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
Also used : Window(org.concord.energy3d.model.Window) Wall(org.concord.energy3d.model.Wall) SolarPanel(org.concord.energy3d.model.SolarPanel) ArrayList(java.util.ArrayList) 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 12 with SolarPanel

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

the class SceneManager method newPart.

private HousePart newPart() {
    final HousePart drawn;
    setGridsVisible(false);
    if (operation == Operation.DRAW_WALL) {
        drawn = new Wall();
        drawn.setColor(Scene.getInstance().getWallColor());
    } else if (operation == Operation.DRAW_DOOR) {
        drawn = new Door();
        drawn.setColor(Scene.getInstance().getDoorColor());
    } else if (operation == Operation.DRAW_WINDOW) {
        drawn = new Window();
    } else if (operation == Operation.DRAW_ROOF_PYRAMID) {
        drawn = new PyramidRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_HIP) {
        drawn = new HipRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_SHED) {
        drawn = new ShedRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_GAMBREL) {
        drawn = new GambrelRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_ROOF_CUSTOM) {
        drawn = new CustomRoof();
        drawn.setColor(Scene.getInstance().getRoofColor());
    } else if (operation == Operation.DRAW_FLOOR) {
        drawn = new Floor();
        drawn.setColor(Scene.getInstance().getFloorColor());
    } else if (operation == Operation.DRAW_SOLAR_PANEL) {
        drawn = new SolarPanel();
    } else if (operation == Operation.DRAW_RACK) {
        drawn = new Rack();
    } else if (operation == Operation.DRAW_MIRROR) {
        drawn = new Mirror();
    } else if (operation == Operation.DRAW_PARABOLIC_TROUGH) {
        drawn = new ParabolicTrough();
    } else if (operation == Operation.DRAW_PARABOLIC_DISH) {
        drawn = new ParabolicDish();
    } else if (operation == Operation.DRAW_FRESNEL_REFLECTOR) {
        drawn = new FresnelReflector();
    } else if (operation == Operation.DRAW_SENSOR) {
        drawn = new Sensor();
    } else if (operation == Operation.DRAW_FOUNDATION) {
        drawn = new Foundation();
        setGridsVisible(Scene.getInstance().isSnapToGrids());
        drawn.setColor(Scene.getInstance().getFoundationColor());
    } else if (operation == Operation.DRAW_DOGWOOD) {
        drawn = new Tree(Tree.DOGWOOD);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_ELM) {
        drawn = new Tree(Tree.ELM);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_OAK) {
        drawn = new Tree(Tree.OAK);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_LINDEN) {
        drawn = new Tree(Tree.LINDEN);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_COTTONWOOD) {
        drawn = new Tree(Tree.COTTONWOOD);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_MAPLE) {
        drawn = new Tree(Tree.MAPLE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_PINE) {
        drawn = new Tree(Tree.PINE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JANE) {
        drawn = new Human(Human.JANE);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JENI) {
        drawn = new Human(Human.JENI);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JILL) {
        drawn = new Human(Human.JILL);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JACK) {
        drawn = new Human(Human.JACK);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JOHN) {
        drawn = new Human(Human.JOHN);
        setGridsVisible(true);
    } else if (operation == Operation.DRAW_JOSE) {
        drawn = new Human(Human.JOSE);
        setGridsVisible(true);
    } else {
        return null;
    }
    Scene.getInstance().add(drawn, false);
    addPartCommand = new AddPartCommand(drawn);
    return drawn;
}
Also used : Window(org.concord.energy3d.model.Window) Human(org.concord.energy3d.model.Human) Floor(org.concord.energy3d.model.Floor) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) ShedRoof(org.concord.energy3d.model.ShedRoof) Door(org.concord.energy3d.model.Door) GambrelRoof(org.concord.energy3d.model.GambrelRoof) CustomRoof(org.concord.energy3d.model.CustomRoof) ParabolicDish(org.concord.energy3d.model.ParabolicDish) PyramidRoof(org.concord.energy3d.model.PyramidRoof) Rack(org.concord.energy3d.model.Rack) SolarPanel(org.concord.energy3d.model.SolarPanel) AddPartCommand(org.concord.energy3d.undo.AddPartCommand) Tree(org.concord.energy3d.model.Tree) Foundation(org.concord.energy3d.model.Foundation) HipRoof(org.concord.energy3d.model.HipRoof) Mirror(org.concord.energy3d.model.Mirror) PickedHousePart(org.concord.energy3d.model.PickedHousePart) HousePart(org.concord.energy3d.model.HousePart) Sensor(org.concord.energy3d.model.Sensor)

Example 13 with SolarPanel

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

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

the class SceneManager method mouseRightClicked.

// the x and y coordinates come from MouseEvent, not MouseState.
private void mouseRightClicked(final MouseEvent e) {
    final JPanel cp = MainPanel.getInstance().getCanvasPanel();
    final int x = e.getX();
    final int y = cp.getHeight() - e.getY();
    mouseState = new MouseState(x, y, 0, 0, 0, null, null);
    pickMouseState = mouseState;
    refresh = true;
    taskManager.update(new Callable<Object>() {

        @Override
        public Object call() {
            try {
                if (operation == Operation.SELECT || operation == Operation.RESIZE) {
                    final HousePart previousSelectedHousePart = selectedPart;
                    if (mouseState == null) {
                        mouseState = new MouseState(x, y, 0, 0, 0, null, null);
                    }
                    final PickedHousePart pickedHousePart = SelectUtil.selectHousePart(mouseState.getX(), mouseState.getY(), true);
                    final UserData pick = pickedHousePart == null ? null : pickedHousePart.getUserData();
                    selectedPart = pick == null ? null : pick.getHousePart();
                    if (selectedPart instanceof Foundation) {
                        final Foundation foundation = (Foundation) selectedPart;
                        if (foundation.getImportedNodes() != null) {
                            // if this foundation contains any imported node, pick a mesh
                            foundation.pickMesh(x, y);
                        }
                    } else {
                        if (e.isAltDown()) {
                            if (selectedPart instanceof SolarPanel && selectedPart.getContainer() instanceof Rack) {
                                // special case (to be removed later)
                                selectedPart = selectedPart.getContainer();
                            }
                        }
                    }
                    System.out.println("Right-clicked on: (" + mouseState.getX() + ", " + mouseState.getY() + ") " + pick);
                    if (previousSelectedHousePart != null && previousSelectedHousePart != selectedPart) {
                        previousSelectedHousePart.setEditPointsVisible(false);
                        previousSelectedHousePart.setGridsVisible(false);
                        previousSelectedHousePart.setLinePatternVisible(false);
                    }
                    if (selectedPart != null) {
                        // to undo edit flag set by SelectUtil above. FIXME: This taints the wall's heat map texture
                        selectedPart.complete();
                        if (!PrintController.getInstance().isPrintPreview()) {
                            selectedPart.setEditPointsVisible(true);
                        }
                        EnergyPanel.getInstance().update();
                    }
                    EnergyPanel.getInstance().updateGraphs();
                    EnergyPanel.getInstance().updateProperties();
                    final int mouseStateX = mouseState.getX();
                    final int mouseStateY = mouseState.getY();
                    final boolean pickOnLand = onLand(pickMouseState.getX(), pickMouseState.getY());
                    EventQueue.invokeLater(new // seriously, our error log on 6/14/2017 showed that this caused deadlock if not invoked later!
                    Runnable() {

                        @Override
                        public void run() {
                            final JPopupMenu popup = PopupMenuFactory.getPopupMenu(e, pickOnLand);
                            if (popup != null) {
                                final JPanel cp = MainPanel.getInstance().getCanvasPanel();
                                popup.show(cp, mouseStateX, cp.getHeight() - mouseStateY);
                            }
                        }
                    });
                }
            } catch (final Throwable t) {
                t.printStackTrace();
                BugReporter.report(t);
            }
            return null;
        }
    });
}
Also used : JPanel(javax.swing.JPanel) UserData(org.concord.energy3d.model.UserData) CullHint(com.ardor3d.scenegraph.hint.CullHint) JPopupMenu(javax.swing.JPopupMenu) Rack(org.concord.energy3d.model.Rack) MouseState(com.ardor3d.input.MouseState) SolarPanel(org.concord.energy3d.model.SolarPanel) 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 15 with SolarPanel

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

the class DataViewer method viewRawData.

static void viewRawData(final java.awt.Window parent, final Graph graph, final boolean selectAll) {
    String[] header = null;
    if (graph instanceof BuildingEnergyDailyGraph) {
        header = new String[] { "Hour", "Windows", "Solar Panels", "Heater", "AC", "Net" };
    } else if (graph instanceof BuildingEnergyAnnualGraph) {
        header = new String[] { "Month", "Windows", "Solar Panels", "Heater", "AC", "Net" };
    } else if (graph instanceof PartEnergyDailyGraph) {
        final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
        if (selectAll || selectedPart instanceof SolarPanel || selectedPart instanceof Rack || selectedPart instanceof Mirror || selectedPart instanceof Foundation) {
            header = new String[] { "Hour", "Solar" };
        } else if (selectedPart instanceof Wall || selectedPart instanceof Roof || selectedPart instanceof Door) {
            header = new String[] { "Hour", "Heat Gain" };
        } else if (selectedPart instanceof Window) {
            header = new String[] { "Hour", "Solar", "Heat Gain" };
        }
        if (graph.instrumentType == Graph.SENSOR) {
            final List<HousePart> parts = Scene.getInstance().getParts();
            final List<String> sensorList = new ArrayList<String>();
            for (final HousePart p : parts) {
                if (p instanceof Sensor) {
                    final Sensor sensor = (Sensor) p;
                    sensorList.add("Light: #" + sensor.getId());
                    sensorList.add("Heat Flux: #" + sensor.getId());
                }
            }
            if (!sensorList.isEmpty()) {
                header = new String[1 + sensorList.size()];
                header[0] = "Hour";
                for (int i = 1; i < header.length; i++) {
                    header[i] = sensorList.get(i - 1);
                }
            }
        }
    } else if (graph instanceof PartEnergyAnnualGraph) {
        final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
        if (selectAll || selectedPart instanceof SolarPanel || selectedPart instanceof Rack || selectedPart instanceof Mirror || selectedPart instanceof Foundation) {
            header = new String[] { "Month", "Solar" };
        } else if (selectedPart instanceof Wall || selectedPart instanceof Roof || selectedPart instanceof Door) {
            header = new String[] { "Month", "Heat Gain" };
        } else if (selectedPart instanceof Window) {
            header = new String[] { "Month", "Solar", "Heat Gain" };
        }
        if (graph.instrumentType == Graph.SENSOR) {
            final List<HousePart> parts = Scene.getInstance().getParts();
            final List<String> sensorList = new ArrayList<String>();
            for (final HousePart p : parts) {
                if (p instanceof Sensor) {
                    final Sensor sensor = (Sensor) p;
                    sensorList.add("Light: #" + sensor.getId());
                    sensorList.add("Heat Flux: #" + sensor.getId());
                }
            }
            if (!sensorList.isEmpty()) {
                header = new String[1 + sensorList.size()];
                header[0] = "Month";
                for (int i = 1; i < header.length; i++) {
                    header[i] = sensorList.get(i - 1);
                }
            }
        }
    } else if (graph instanceof BuildingEnergyAngularGraph) {
        header = new String[] { "Degree", "Windows", "Solar Panels", "Heater", "AC", "Net" };
    } else if (graph instanceof PartEnergyAngularGraph) {
        final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
        if (selectedPart instanceof SolarPanel || selectedPart instanceof Rack || selectedPart instanceof Mirror || selectedPart instanceof Foundation) {
            header = new String[] { "Degree", "Solar" };
        } else if (selectedPart instanceof Wall || selectedPart instanceof Roof || selectedPart instanceof Door) {
            header = new String[] { "Degree", "Heat Gain" };
        } else if (selectedPart instanceof Window) {
            header = new String[] { "Degree", "Solar", "Heat Gain" };
        }
    }
    if (header == null) {
        JOptionPane.showMessageDialog(MainFrame.getInstance(), "Problem in finding data.", "Error", JOptionPane.ERROR_MESSAGE);
        return;
    }
    final int m = header.length;
    final int n = graph.getLength();
    final Object[][] column = new Object[n][m + 1];
    for (int i = 0; i < n; i++) {
        column[i][0] = header[0].equals("Hour") ? i : (i + 1);
    }
    for (int j = 1; j < m; j++) {
        final List<Double> list = graph.getData(header[j]);
        for (int i = 0; i < n; i++) {
            column[i][j] = list.get(i);
        }
    }
    showDataWindow("Data", column, header, parent);
}
Also used : Wall(org.concord.energy3d.model.Wall) ArrayList(java.util.ArrayList) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) Foundation(org.concord.energy3d.model.Foundation) ArrayList(java.util.ArrayList) List(java.util.List) HousePart(org.concord.energy3d.model.HousePart) Window(org.concord.energy3d.model.Window) Door(org.concord.energy3d.model.Door) SolarPanel(org.concord.energy3d.model.SolarPanel) Mirror(org.concord.energy3d.model.Mirror) Sensor(org.concord.energy3d.model.Sensor)

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