use of org.concord.energy3d.model.HousePart 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.HousePart 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.HousePart 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.HousePart in project energy3d by concord-consortium.
the class Scene method setSectionsForAllParabolicDishes.
public void setSectionsForAllParabolicDishes(final int nParabola, final int nAxis) {
for (final HousePart p : parts) {
if (p instanceof ParabolicDish) {
final ParabolicDish d = (ParabolicDish) p;
d.setNRadialSections(nParabola);
d.setNAxialSections(nAxis);
d.draw();
}
}
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.HousePart in project energy3d by concord-consortium.
the class Scene method redrawAllNow.
public void redrawAllNow() {
System.out.println("redrawAllNow()");
final int n = parts.size();
final boolean showProgress = n > 1000;
if (showProgress) {
SceneManager.getInstance().cursorWait(true);
}
final long t = System.nanoTime();
if (cleanup) {
cleanup();
cleanup = false;
}
connectWalls();
Snap.clearAnnotationDrawn();
List<Roof> roofs = null;
for (final HousePart part : parts) {
if (part instanceof Roof) {
if (roofs == null) {
roofs = new ArrayList<Roof>();
}
roofs.add((Roof) part);
part.draw();
}
}
int i = 0;
for (final HousePart part : parts) {
if (!(part instanceof Roof)) {
part.draw();
if (showProgress) {
final int index = i++;
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
EnergyPanel.getInstance().progress((int) Math.round(100.0 * index / n));
}
});
}
}
}
if (roofs != null && !roofs.isEmpty()) {
// need to draw roof again because roof holes depend on drawn windows
for (final Roof r : roofs) {
r.draw();
}
roofs.clear();
}
if (Heliodon.getInstance().isVisible()) {
Heliodon.getInstance().updateSize();
}
System.out.println("Scene rendering time: " + (System.nanoTime() - t) / 1000000000.0);
// no need for redrawing print parts because they will be regenerated from original parts anyways
redrawAll = false;
if (showProgress) {
SceneManager.getInstance().cursorWait(false);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
EnergyPanel.getInstance().progress(0);
}
});
}
}
Aggregations