use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class Scene method removeAllWalls.
public void removeAllWalls() {
final ArrayList<HousePart> walls = 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 Wall && !part.getLockEdit() && part.getTopContainer() == foundation) {
walls.add(part);
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof Wall && !part.getLockEdit()) {
walls.add(part);
}
}
}
if (walls.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no wall to remove.", "No Wall", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + walls.size() + " walls" + (selectedPart != null ? " of the selected building" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(walls);
for (final HousePart part : walls) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class Scene method setFocalLengthForAllParabolicDishes.
public void setFocalLengthForAllParabolicDishes(final double curvatureParameter) {
for (final HousePart p : parts) {
if (p instanceof ParabolicDish) {
((ParabolicDish) p).setFocalLength(curvatureParameter);
p.draw();
}
}
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class Scene method removeAllRacks.
public void removeAllRacks() {
final ArrayList<HousePart> racks = 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 Rack && part.getTopContainer() == foundation) {
racks.add(part);
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof Rack) {
racks.add(part);
}
}
}
if (racks.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no rack to remove.", "No Rack", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + racks.size() + " solar panel racks" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(racks);
for (final HousePart part : racks) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class Scene method setWindowColorInContainer.
public void setWindowColorInContainer(final HousePart container, final ColorRGBA c, final boolean shutter) {
for (final HousePart p : parts) {
if (p instanceof Window && p.getContainer() == container) {
final Window w = (Window) p;
if (shutter) {
w.setShutterColor(c);
} else {
w.setColor(c);
}
w.draw();
}
}
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class Scene method pasteToPickedLocationOnLand.
public void pasteToPickedLocationOnLand() {
if (SceneManager.getInstance().getSolarHeatMap()) {
EnergyPanel.getInstance().updateRadiationHeatMap();
}
if (copyBuffer == null) {
return;
}
final HousePart c = copyBuffer.copy(false);
if (c == null) {
return;
}
final Vector3 position = SceneManager.getInstance().getPickedLocationOnLand();
if (position == null) {
return;
}
if (c instanceof Tree || c instanceof Human) {
c.getPoints().set(0, position);
add(c, true);
copyBuffer = c;
SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
} else if (c instanceof Foundation) {
// pasting a foundation also clones the building above it
final Vector3 shift = position.subtractLocal(c.getAbsCenter()).multiplyLocal(1, 1, 0);
final int n = c.getPoints().size();
for (int i = 0; i < n; i++) {
c.getPoints().get(i).addLocal(shift);
}
add(c, true);
// copy gable info, too
final Foundation oldFoundation = (Foundation) copyBuffer;
final Foundation newFoundation = (Foundation) c;
final List<Roof> oldRoofs = oldFoundation.getRoofs();
final List<Roof> newRoofs = newFoundation.getRoofs();
if (!oldRoofs.isEmpty() && !newRoofs.isEmpty()) {
for (int i = 0; i < newRoofs.size(); i++) {
final Map<Integer, List<Wall>> oldMap = oldRoofs.get(i).getGableEditPointToWallMap();
if (oldMap == null || oldMap.isEmpty()) {
continue;
}
final Map<Integer, List<Wall>> newMap = new HashMap<Integer, List<Wall>>();
for (final Integer key : oldMap.keySet()) {
final List<Wall> oldWalls = oldMap.get(key);
final List<Wall> newWalls = new ArrayList<Wall>();
for (final Wall w : oldWalls) {
newWalls.add(getCopiedWall(w, oldFoundation, newFoundation));
}
newMap.put(key, newWalls);
}
newRoofs.get(i).setGableEditPointToWallMap(newMap);
}
}
copyBuffer = c;
setIdOfChildren(c);
SceneManager.getInstance().getUndoManager().addEdit(new PastePartCommand(c));
}
SceneManager.getInstance().setSelectedPart(c);
}
Aggregations