use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method removeAllSensors.
public void removeAllSensors() {
final ArrayList<HousePart> sensors = 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 Sensor && part.getTopContainer() == foundation) {
sensors.add(part);
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof Sensor) {
sensors.add(part);
}
}
}
if (sensors.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no sensor to remove.", "No Sensor", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + sensors.size() + " sensors" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(sensors);
for (final HousePart part : sensors) {
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 setShutterLengthOfBuilding.
public void setShutterLengthOfBuilding(final HousePart part, final double length) {
if (part instanceof Foundation) {
return;
}
for (final HousePart p : parts) {
if (p instanceof Window && p.getTopContainer() == part.getTopContainer()) {
final Window w = (Window) p;
w.setShutterLength(length);
w.draw();
}
}
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method setHeightOfConnectedWalls.
public void setHeightOfConnectedWalls(final Wall w, final double height) {
w.visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall w, final Snap prev, final Snap next) {
w.setHeight(height, true);
}
});
redrawAllWallsNow();
final Foundation foundation = w.getTopContainer();
if (foundation.hasSolarReceiver()) {
foundation.drawSolarReceiver();
for (final HousePart x : Scene.getInstance().getParts()) {
if (x instanceof FresnelReflector) {
final FresnelReflector reflector = (FresnelReflector) x;
if (foundation == reflector.getReceiver() && reflector.isSunBeamVisible()) {
reflector.drawSunBeam();
}
} else if (x instanceof Mirror) {
final Mirror heliostat = (Mirror) x;
if (foundation == heliostat.getReceiver() && heliostat.isSunBeamVisible()) {
heliostat.drawSunBeam();
}
}
}
}
}
use of org.concord.energy3d.model.Foundation 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));
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method groupFoundations.
/* put overlapping foundations into separate groups */
private void groupFoundations() {
if (foundationGroups == null) {
foundationGroups = new ArrayList<List<Foundation>>();
} else {
foundationGroups.clear();
}
final List<Foundation> foundations = new ArrayList<Foundation>();
for (final HousePart p : parts) {
if (p instanceof Foundation) {
foundations.add((Foundation) p);
}
}
final int n = foundations.size();
if (n > 1) {
int count = 0;
final List<Pair> pairs = new ArrayList<Pair>();
for (int i = 0; i < n - 1; i++) {
final Foundation fi = foundations.get(i);
for (int j = i + 1; j < n; j++) {
final Foundation fj = foundations.get(j);
if (fi.overlap(fj)) {
final Pair p = new Pair(i, j);
if (!pairs.contains(p)) {
pairs.add(p);
}
}
}
}
int m = pairs.size();
while (m > 0) {
Pair p = pairs.get(0);
final List<Integer> list = new ArrayList<Integer>();
list.add(p.i());
list.add(p.j());
pairs.remove(p);
m = pairs.size();
if (m > 0) {
final List<Pair> toRemove = new ArrayList<Pair>();
for (int x = 0; x < m; x++) {
p = pairs.get(x);
final int i = p.i();
final int j = p.j();
if (list.contains(i) && list.contains(j)) {
if (!toRemove.contains(p)) {
toRemove.add(p);
}
} else if (!list.contains(i) && list.contains(j)) {
list.add(i);
if (!toRemove.contains(p)) {
toRemove.add(p);
}
} else if (!list.contains(j) && list.contains(i)) {
list.add(j);
if (!toRemove.contains(p)) {
toRemove.add(p);
}
}
}
if (!toRemove.isEmpty()) {
pairs.removeAll(toRemove);
}
}
final List<Foundation> group = new ArrayList<Foundation>();
for (final Integer a : list) {
group.add(foundations.get(a));
}
foundationGroups.add(group);
count += group.size();
m = pairs.size();
}
if (count < foundations.size()) {
for (final Foundation f : foundations) {
boolean linked = false;
for (final List<Foundation> g : foundationGroups) {
if (g.contains(f)) {
linked = true;
break;
}
}
if (!linked) {
final List<Foundation> g = new ArrayList<Foundation>();
g.add(f);
foundationGroups.add(g);
}
}
}
// System.out.println("###" + foundationGroups.size() + "," + (foundations.size() - count));
} else {
foundationGroups.add(foundations);
}
}
Aggregations