use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method setTargetForAllHeliostats.
public void setTargetForAllHeliostats(final Foundation target) {
final List<Foundation> oldTargets = new ArrayList<Foundation>();
for (final HousePart p : parts) {
if (p instanceof Mirror) {
final Mirror m = (Mirror) p;
final Foundation t = m.getReceiver();
if (t != null && !oldTargets.contains(t)) {
oldTargets.add(t);
}
m.setReceiver(target);
p.draw();
}
}
if (target != null) {
target.drawSolarReceiver();
}
if (!oldTargets.isEmpty()) {
for (final Foundation t : oldTargets) {
t.drawSolarReceiver();
}
}
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method removeAllWindowShutters.
public void removeAllWindowShutters() {
final ArrayList<Window> windows = new ArrayList<Window>();
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 Window && !part.getLockEdit() && part.getTopContainer() == foundation) {
final Window w = (Window) part;
if (w.getLeftShutter() || w.getRightShutter()) {
windows.add(w);
}
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof Window && !part.getLockEdit()) {
final Window w = (Window) part;
if (w.getLeftShutter() || w.getRightShutter()) {
windows.add(w);
}
}
}
}
if (windows.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no window shutter to remove.", "No Shutter", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + windows.size() + " window shutters" + (selectedPart != null ? " of the selected building" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultipleShuttersCommand c = new RemoveMultipleShuttersCommand(windows);
for (final HousePart part : windows) {
final Window w = (Window) part;
w.setLeftShutter(false);
w.setRightShutter(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 newFile.
private static void newFile(final double xLength, final double yLength) {
try {
open(null);
first = false;
} catch (final Exception e) {
e.printStackTrace();
}
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() throws Exception {
instance.add(new Human(Human.JACK, 1));
final Foundation f = new Foundation(xLength, yLength);
f.setColor(instance.getFoundationColor());
instance.add(f, true);
return null;
}
});
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method countMeshes.
public int countMeshes() {
int count = 0;
final List<Foundation> foundations = getAllFoundations();
for (final Foundation f : foundations) {
if (f.getImportedNodes() != null) {
for (final Node n : f.getImportedNodes()) {
count += n.getNumberOfChildren();
}
}
}
return count;
}
use of org.concord.energy3d.model.Foundation in project energy3d by concord-consortium.
the class Scene method getFoundationBounds.
public Rectangle2D getFoundationBounds(final boolean excludeSelectedPart) {
Rectangle2D bounds = new Rectangle2D.Double(-0.1, -0.1, 0.2, 0.2);
if (excludeSelectedPart) {
for (final HousePart p : parts) {
if (p instanceof Foundation && p != SceneManager.getInstance().getSelectedPart()) {
final Foundation f = (Foundation) p;
final Vector3 v0 = f.getAbsPoint(0);
final Vector3 v1 = f.getAbsPoint(1);
final Vector3 v2 = f.getAbsPoint(2);
final Vector3 v3 = f.getAbsPoint(3);
final double cx = 0.25 * (v0.getX() + v1.getX() + v2.getX() + v3.getX());
final double cy = 0.25 * (v0.getY() + v1.getY() + v2.getY() + v3.getY());
final double lx = v0.distance(v2);
final double ly = v0.distance(v1);
bounds = bounds.createUnion(new Rectangle2D.Double(cx - lx * 0.5, cy - ly * 0.5, lx, ly));
}
}
} else {
for (final HousePart p : parts) {
if (p instanceof Foundation) {
final Foundation f = (Foundation) p;
final Vector3 v0 = f.getAbsPoint(0);
final Vector3 v1 = f.getAbsPoint(1);
final Vector3 v2 = f.getAbsPoint(2);
final Vector3 v3 = f.getAbsPoint(3);
final double cx = 0.25 * (v0.getX() + v1.getX() + v2.getX() + v3.getX());
final double cy = 0.25 * (v0.getY() + v1.getY() + v2.getY() + v3.getY());
final double lx = v0.distance(v2);
final double ly = v0.distance(v1);
bounds = bounds.createUnion(new Rectangle2D.Double(cx - lx * 0.5, cy - ly * 0.5, lx, ly));
}
}
}
return bounds;
}
Aggregations