use of org.concord.energy3d.model.Window in project energy3d by concord-consortium.
the class SetSizeForWindowsOnFoundationCommand method redo.
@Override
public void redo() throws CannotRedoException {
super.redo();
final int n = windows.size();
for (int i = 0; i < n; i++) {
final Window w = windows.get(i);
w.setWindowWidth(newWidths[i]);
w.setWindowHeight(newHeights[i]);
w.draw();
w.getContainer().draw();
}
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.Window in project energy3d by concord-consortium.
the class SetPartSizeCommand method redo.
@Override
public void redo() throws CannotRedoException {
super.redo();
if (part instanceof Mirror) {
final Mirror m = (Mirror) part;
m.setMirrorWidth(newWidth);
m.setMirrorHeight(newHeight);
} else if (part instanceof ParabolicTrough) {
final ParabolicTrough t = (ParabolicTrough) part;
t.setApertureWidth(newWidth);
t.setTroughLength(newHeight);
t.setModuleLength(newModuleLength);
} else if (part instanceof ParabolicDish) {
final ParabolicDish d = (ParabolicDish) part;
d.setRimRadius(newWidth);
} else if (part instanceof FresnelReflector) {
final FresnelReflector t = (FresnelReflector) part;
t.setModuleWidth(newWidth);
t.setLength(newHeight);
t.setModuleLength(newModuleLength);
} else if (part instanceof Rack) {
final Rack r = (Rack) part;
r.setRackWidth(newWidth);
r.setRackHeight(newHeight);
} else if (part instanceof Window) {
final Window w = (Window) part;
w.setWindowWidth(newWidth);
w.setWindowHeight(newHeight);
w.getContainer().draw();
} else if (part instanceof Door) {
final Door d = (Door) part;
d.setDoorWidth(newWidth);
d.setDoorHeight(newHeight);
d.getContainer().draw();
}
part.draw();
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.model.Window in project energy3d by concord-consortium.
the class RemoveMultipleShuttersCommand method undo.
@Override
public void undo() throws CannotUndoException {
super.undo();
for (int i = 0; i < windows.size(); i++) {
final Window w = windows.get(i);
if (w.isDrawable()) {
// as an extra defense of potential invisible ghost part
w.setLeftShutter(leftShutters[i]);
w.setRightShutter(rightShutters[i]);
w.draw();
}
}
if (SceneManager.getInstance().getSolarHeatMap()) {
EnergyPanel.getInstance().updateRadiationHeatMap();
}
}
use of org.concord.energy3d.model.Window in project energy3d by concord-consortium.
the class RemoveMultipleShuttersCommand method redo.
@Override
public void redo() throws CannotRedoException {
super.redo();
for (final Window w : windows) {
if (w.isDrawable()) {
// as an extra defense of potential invisible ghost part
w.setLeftShutter(false);
w.setRightShutter(false);
w.draw();
}
}
if (SceneManager.getInstance().getSolarHeatMap()) {
EnergyPanel.getInstance().updateRadiationHeatMap();
}
}
use of org.concord.energy3d.model.Window in project energy3d by concord-consortium.
the class SelectUtil method getPickResult.
private static PickedHousePart getPickResult(final Ray3 pickRay) {
PickedHousePart pickedHousePart = null;
double polyDist = Double.MAX_VALUE;
double pointDist = Double.MAX_VALUE;
int objCounter = 0;
HousePart prevHousePart = null;
final long pickLayer = SelectUtil.pickLayer == -1 ? -1 : SelectUtil.pickLayer % Math.max(1, pickResults.getNumber());
for (int i = 0; i < pickResults.getNumber(); i++) {
final PickData pick = pickResults.getPickData(i);
if (pick.getIntersectionRecord().getNumberOfIntersections() == 0) {
continue;
}
final Object obj = ((Mesh) pick.getTarget()).getUserData();
UserData userData = null;
if (obj instanceof UserData) {
// FIXME: Note that userData can be null if the pick is the land
userData = (UserData) obj;
if (userData.getHousePart() != prevHousePart) {
objCounter++;
prevHousePart = userData.getHousePart();
}
} else if (pickLayer != -1) {
continue;
}
if (pickLayer != -1 && objCounter - 1 != pickLayer) {
continue;
}
final Vector3 intersectionPoint = pick.getIntersectionRecord().getIntersectionPoint(0);
final PickedHousePart picked_i = new PickedHousePart(userData, intersectionPoint, pick.getIntersectionRecord().getIntersectionNormal(0));
double polyDist_i = pick.getIntersectionRecord().getClosestDistance();
if (userData != null && userData.getHousePart() instanceof Window) {
// give more priority to window (especially skylight)
polyDist_i -= 0.2;
}
double pointDist_i = Double.MAX_VALUE;
if (userData != null && polyDist_i - polyDist < 0.1) {
for (int j = 0; j < userData.getHousePart().getPoints().size(); j++) {
final Vector3 p = userData.getHousePart().getAbsPoint(j);
pointDist_i = p.distance(intersectionPoint);
double adjust = 0;
if (userData.getHousePart().isFirstPointInserted()) {
// to avoid IndexOutOfBoundsException: Index: 2, Size: 2
if (userData.getHousePart().getNormal() != null) {
adjust -= Math.abs(userData.getHousePart().getNormal().negate(null).dot(pickRay.getDirection()) / 10.0);
}
}
if (userData.getHousePart() == SceneManager.getInstance().getSelectedPart()) {
// give more priority because the object is selected
adjust -= 0.1;
}
if (userData.isEditPoint()) {
// give more priority because this is an edit point
adjust -= 0.1;
}
if (userData.isEditPoint() && userData.getHousePart() instanceof Foundation && ((Foundation) userData.getHousePart()).isResizeHouseMode()) {
adjust -= 0.1;
}
pointDist_i += adjust;
if (pointDist_i < pointDist && (userData.getEditPointIndex() != -1 || pickedHousePart == null || pickedHousePart.getUserData() == null || pickedHousePart.getUserData().getEditPointIndex() == -1)) {
pickedHousePart = picked_i;
polyDist = polyDist_i;
pointDist = pointDist_i;
}
}
}
if (pickedHousePart == null || polyDist_i < polyDist) {
pickedHousePart = picked_i;
polyDist = polyDist_i;
pointDist = pointDist_i;
}
}
return pickedHousePart;
}
Aggregations