use of org.concord.energy3d.model.Foundation 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);
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method add.
public void add(final HousePart part, final boolean redraw) {
final HousePart container = part.getContainer();
if (container != null) {
container.getChildren().add(part);
}
add(part);
if (redraw) {
if (part instanceof SolarCollector || part instanceof Tree || part instanceof Human) {
// add these objects will not affect the rendering of other objects
part.draw();
} else if (part instanceof Foundation) {
redrawFoundationNow((Foundation) part);
} else if (part instanceof Window || part instanceof Door) {
part.draw();
part.getContainer().draw();
} else {
// what will fall through here?
System.out.println("*** Warning: potential performance drag: " + part);
redrawAll();
}
}
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method removeAllFoundations.
public void removeAllFoundations() {
final ArrayList<HousePart> foundations = new ArrayList<HousePart>();
for (final HousePart part : parts) {
if (part instanceof Foundation && !part.getLockEdit()) {
foundations.add(part);
}
}
if (foundations.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no activated foundation to remove.", "No Foundation", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + foundations.size() + " foundations?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(foundations);
for (final HousePart part : foundations) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method removeAllParabolicDishes.
public void removeAllParabolicDishes() {
final ArrayList<HousePart> dishes = 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 ParabolicDish && part.getTopContainer() == foundation) {
dishes.add(part);
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof ParabolicDish) {
dishes.add(part);
}
}
}
if (dishes.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no parabolic dish to remove.", "No Parabolic Dish", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + dishes.size() + " parabolic dishes" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(dishes);
for (final HousePart part : dishes) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method setShutterColorOfBuilding.
public void setShutterColorOfBuilding(final HousePart part, final ReadOnlyColorRGBA color) {
if (part instanceof Foundation) {
return;
}
for (final HousePart p : parts) {
if (p instanceof Window && p.getTopContainer() == part.getTopContainer()) {
final Window w = (Window) p;
w.setShutterColor(color);
w.draw();
}
}
}
Aggregations