use of org.concord.energy3d.model.Human in project energy3d by concord-consortium.
the class Scene method init.
private void init() {
root.detachAllChildren();
originalHouseRoot.detachAllChildren();
notReceivingShadowRoot.detachAllChildren();
root.attachChild(originalHouseRoot);
root.attachChild(notReceivingShadowRoot);
if (url != null) {
for (final HousePart p : parts) {
final boolean b = p instanceof Tree || p instanceof Human;
(b ? notReceivingShadowRoot : originalHouseRoot).attachChild(p.getRoot());
}
System.out.println("initSceneNow done");
}
root.updateWorldBound(true);
SceneManager.getInstance().updateHeliodonAndAnnotationSize();
SceneManager.getInstance().setAxesVisible(!hideAxes);
SceneManager.getInstance().getSolarLand().setVisible(solarMapForLand);
setTheme(theme);
SceneManager.getInstance().getLand().setDefaultColor(landColor != null ? landColor : new ColorRGBA(0, 1, 0, 0.5f));
PvModulesData.getInstance();
final EnergyPanel energyPanel = EnergyPanel.getInstance();
if (calendar != null) {
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (url == null) {
// if a new file is created, its default time is always set to noon so that the user does not get a dark night scene
calendar.set(Calendar.HOUR_OF_DAY, 12);
calendar.set(Calendar.MINUTE, 0);
}
final Date time = calendar.getTime();
Heliodon.getInstance().setDate(time);
Heliodon.getInstance().setTime(time);
Util.setSilently(energyPanel.getDateSpinner(), time);
Util.setSilently(energyPanel.getTimeSpinner(), time);
if ("Boston".equals(city) || city == null || "".equals(city)) {
city = "Boston, MA";
latitude = 42;
}
// already silent
energyPanel.setLatitude(latitude);
Util.selectSilently(energyPanel.getCityComboBox(), city);
final LocationData ld = LocationData.getInstance();
if (ld.getLatitudes().get(city) != null) {
energyPanel.getCityComboBox().setToolTipText("<html>(" + ld.getLatitudes().get(city) + "°, " + ld.getLongitudes().get(city) + "°), elevation " + ld.getAltitudes().get(city).intValue() + "m<br>Use Edit>Set Region... to select country and region.</html>");
} else {
JOptionPane.showMessageDialog(MainFrame.getInstance(), city + " not supported. Please upgrade your Energy3D to the latest.", "Missing City", JOptionPane.ERROR_MESSAGE);
}
Scene.getInstance().updateTreeLeaves();
SceneManager.getInstance().changeSkyTexture();
if (!first) {
SceneManager.getInstance().setHeliodonVisible(isHeliodonVisible);
Util.selectSilently(MainPanel.getInstance().getHeliodonButton(), isHeliodonVisible);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
MainPanel.getInstance().getSunAnimationButton().setEnabled(isHeliodonVisible);
}
});
}
Heliodon.getInstance().drawSun();
SceneManager.getInstance().setShading(Heliodon.getInstance().isNightTime());
}
// previous versions do not have the following classes
if (designSpecs == null) {
designSpecs = new DesignSpecs();
} else {
designSpecs.setDefaultValues();
}
if (pvDesignSpecs == null) {
pvDesignSpecs = new PvDesignSpecs();
} else {
pvDesignSpecs.setDefaultValues();
}
if (cspDesignSpecs == null) {
cspDesignSpecs = new CspDesignSpecs();
} else {
cspDesignSpecs.setDefaultValues();
}
if (pvCustomPrice == null) {
pvCustomPrice = new PvCustomPrice();
} else {
pvCustomPrice.setDefaultValues();
}
if (cspCustomPrice == null) {
cspCustomPrice = new CspCustomPrice();
} else {
cspCustomPrice.setDefaultValues();
}
if (ground == null) {
ground = new Ground();
}
if (atmosphere == null) {
atmosphere = new Atmosphere();
}
if (unit == null) {
unit = Unit.InternationalSystemOfUnits;
}
// restore the default values
if (Util.isZero(heatVectorLength)) {
heatVectorLength = 5000;
}
if (Util.isZero(heatFluxGridSize)) {
heatFluxGridSize = 2;
}
if (Util.isZero(solarStep)) {
solarStep = 2;
}
if (Util.isZero(timeStep)) {
timeStep = 15;
}
if (Util.isZero(solarPanelNx)) {
solarPanelNx = 4;
}
if (Util.isZero(solarPanelNy)) {
solarPanelNy = 4;
}
if (Util.isZero(rackNx)) {
rackNx = 8;
}
if (Util.isZero(rackNy)) {
rackNy = 8;
}
if (Util.isZero(mirrorNx)) {
mirrorNx = 4;
}
if (Util.isZero(mirrorNy)) {
mirrorNy = 4;
}
if (Util.isZero(parabolicDishN)) {
parabolicDishN = 4;
}
if (Util.isZero(rackCellSize)) {
rackCellSize = 1;
}
if (Util.isZero(solarContrast)) {
solarContrast = 50;
}
// in case we need to have more instruction sheets
if (instructionSheetText != null) {
if (instructionSheetText.length < INSTRUCTION_SHEET_NUMBER) {
final String[] tmp = new String[INSTRUCTION_SHEET_NUMBER];
System.arraycopy(instructionSheetText, 0, tmp, 0, instructionSheetText.length);
instructionSheetText = tmp;
}
}
if (instructionSheetTextType != null) {
if (instructionSheetTextType.length < INSTRUCTION_SHEET_NUMBER) {
final String[] tmp = new String[INSTRUCTION_SHEET_NUMBER];
System.arraycopy(instructionSheetTextType, 0, tmp, 0, instructionSheetTextType.length);
instructionSheetTextType = tmp;
}
}
setEdited(false);
setCopyBuffer(null);
Util.setSilently(energyPanel.getColorMapSlider(), solarContrast);
// need to do this to avoid logging
Util.setSilently(MainPanel.getInstance().getNoteTextArea(), note == null ? "" : note);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
energyPanel.updateThermostat();
// necessary for the scroll bars to show up appropriately
MainPanel.getInstance().setNoteVisible(MainPanel.getInstance().isNoteVisible());
// moved from OpenNow to here to avoid triggering EnergyComputer -> RedrawAllNow before open is completed
MainPanel.getInstance().getEnergyButton().setSelected(false);
SceneManager.getInstance().getUndoManager().discardAllEdits();
MainApplication.getEventLog().clear();
}
});
}
use of org.concord.energy3d.model.Human in project energy3d by concord-consortium.
the class SceneManager method autoSelectBuilding.
public Foundation autoSelectBuilding(final boolean ask) {
Foundation foundation = null;
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart == null || selectedPart instanceof Tree || selectedPart instanceof Human) {
SceneManager.getInstance().setSelectedPart(null);
int count = 0;
HousePart hp = null;
for (final HousePart x : Scene.getInstance().getParts()) {
if (x instanceof Foundation) {
count++;
hp = x;
}
}
if (count == 1) {
SceneManager.getInstance().setSelectedPart(hp);
foundation = (Foundation) hp;
} else {
if (ask) {
if (count > 1) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There are multiple buildings. You must select a building first.", "No Selection", JOptionPane.WARNING_MESSAGE);
} else {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no building.", "No Building", JOptionPane.WARNING_MESSAGE);
}
}
}
} else {
final HousePart topContainer = selectedPart.getTopContainer();
if (selectedPart instanceof Foundation) {
foundation = (Foundation) selectedPart;
} else if (topContainer instanceof Foundation) {
selectedPart.setEditPointsVisible(false);
SceneManager.getInstance().setSelectedPart(topContainer);
foundation = (Foundation) topContainer;
} else {
if (ask) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "You must select a building first.", "No Selection", JOptionPane.WARNING_MESSAGE);
}
}
}
return foundation;
}
use of org.concord.energy3d.model.Human in project energy3d by concord-consortium.
the class SceneManager method newPart.
private HousePart newPart() {
final HousePart drawn;
setGridsVisible(false);
if (operation == Operation.DRAW_WALL) {
drawn = new Wall();
drawn.setColor(Scene.getInstance().getWallColor());
} else if (operation == Operation.DRAW_DOOR) {
drawn = new Door();
drawn.setColor(Scene.getInstance().getDoorColor());
} else if (operation == Operation.DRAW_WINDOW) {
drawn = new Window();
} else if (operation == Operation.DRAW_ROOF_PYRAMID) {
drawn = new PyramidRoof();
drawn.setColor(Scene.getInstance().getRoofColor());
} else if (operation == Operation.DRAW_ROOF_HIP) {
drawn = new HipRoof();
drawn.setColor(Scene.getInstance().getRoofColor());
} else if (operation == Operation.DRAW_ROOF_SHED) {
drawn = new ShedRoof();
drawn.setColor(Scene.getInstance().getRoofColor());
} else if (operation == Operation.DRAW_ROOF_GAMBREL) {
drawn = new GambrelRoof();
drawn.setColor(Scene.getInstance().getRoofColor());
} else if (operation == Operation.DRAW_ROOF_CUSTOM) {
drawn = new CustomRoof();
drawn.setColor(Scene.getInstance().getRoofColor());
} else if (operation == Operation.DRAW_FLOOR) {
drawn = new Floor();
drawn.setColor(Scene.getInstance().getFloorColor());
} else if (operation == Operation.DRAW_SOLAR_PANEL) {
drawn = new SolarPanel();
} else if (operation == Operation.DRAW_RACK) {
drawn = new Rack();
} else if (operation == Operation.DRAW_MIRROR) {
drawn = new Mirror();
} else if (operation == Operation.DRAW_PARABOLIC_TROUGH) {
drawn = new ParabolicTrough();
} else if (operation == Operation.DRAW_PARABOLIC_DISH) {
drawn = new ParabolicDish();
} else if (operation == Operation.DRAW_FRESNEL_REFLECTOR) {
drawn = new FresnelReflector();
} else if (operation == Operation.DRAW_SENSOR) {
drawn = new Sensor();
} else if (operation == Operation.DRAW_FOUNDATION) {
drawn = new Foundation();
setGridsVisible(Scene.getInstance().isSnapToGrids());
drawn.setColor(Scene.getInstance().getFoundationColor());
} else if (operation == Operation.DRAW_DOGWOOD) {
drawn = new Tree(Tree.DOGWOOD);
setGridsVisible(true);
} else if (operation == Operation.DRAW_ELM) {
drawn = new Tree(Tree.ELM);
setGridsVisible(true);
} else if (operation == Operation.DRAW_OAK) {
drawn = new Tree(Tree.OAK);
setGridsVisible(true);
} else if (operation == Operation.DRAW_LINDEN) {
drawn = new Tree(Tree.LINDEN);
setGridsVisible(true);
} else if (operation == Operation.DRAW_COTTONWOOD) {
drawn = new Tree(Tree.COTTONWOOD);
setGridsVisible(true);
} else if (operation == Operation.DRAW_MAPLE) {
drawn = new Tree(Tree.MAPLE);
setGridsVisible(true);
} else if (operation == Operation.DRAW_PINE) {
drawn = new Tree(Tree.PINE);
setGridsVisible(true);
} else if (operation == Operation.DRAW_JANE) {
drawn = new Human(Human.JANE);
setGridsVisible(true);
} else if (operation == Operation.DRAW_JENI) {
drawn = new Human(Human.JENI);
setGridsVisible(true);
} else if (operation == Operation.DRAW_JILL) {
drawn = new Human(Human.JILL);
setGridsVisible(true);
} else if (operation == Operation.DRAW_JACK) {
drawn = new Human(Human.JACK);
setGridsVisible(true);
} else if (operation == Operation.DRAW_JOHN) {
drawn = new Human(Human.JOHN);
setGridsVisible(true);
} else if (operation == Operation.DRAW_JOSE) {
drawn = new Human(Human.JOSE);
setGridsVisible(true);
} else {
return null;
}
Scene.getInstance().add(drawn, false);
addPartCommand = new AddPartCommand(drawn);
return drawn;
}
use of org.concord.energy3d.model.Human in project energy3d by concord-consortium.
the class SceneManager method move.
public void move(final Vector3 v) {
if (SceneManager.getInstance().getSolarHeatMap()) {
EnergyPanel.getInstance().updateRadiationHeatMap();
}
final MovePartCommand c = new MovePartCommand(selectedPart, v);
if (selectedPart == null) {
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof Foundation) {
((Foundation) p).move(v, p.getGridSize());
}
}
Scene.getInstance().redrawAll();
} else if (selectedPart instanceof Foundation) {
final Foundation f = (Foundation) selectedPart;
if (f.isGroupMaster()) {
final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
for (final Foundation x : g) {
x.move(v, selectedPart.getGridSize());
}
} else {
f.move(v, selectedPart.getGridSize());
}
} else if (selectedPart instanceof FoundationPolygon) {
((Foundation) selectedPart.getContainer()).moveAllWithinPolygon(v);
} else if (selectedPart instanceof Roof) {
if (viewMode == ViewMode.TOP_VIEW) {
final Foundation f = selectedPart.getTopContainer();
if (f.isGroupMaster()) {
final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
for (final Foundation x : g) {
x.move(v, selectedPart.getGridSize());
}
} else {
f.move(v, selectedPart.getGridSize());
}
}
} else if (selectedPart instanceof Window) {
final Window w = (Window) selectedPart;
w.move(v);
w.draw();
} else if (selectedPart instanceof SolarCollector) {
final SolarCollector sc = (SolarCollector) selectedPart;
sc.move(v, selectedPart.getGridSize());
selectedPart.draw();
} else if (selectedPart instanceof Tree) {
final Tree t = (Tree) selectedPart;
t.move(v, selectedPart.getGridSize());
t.draw();
} else if (selectedPart instanceof Human) {
final Human h = (Human) selectedPart;
h.move(v, selectedPart.getGridSize());
h.draw();
}
undoManager.addEdit(c);
SceneManager.getInstance().refresh();
Scene.getInstance().setEdited(true);
}
use of org.concord.energy3d.model.Human in project energy3d by concord-consortium.
the class SceneManager method mouseMoved.
private void mouseMoved() {
if (!mouseControlEnabled) {
return;
}
final int x = mouseState.getX();
final int y = mouseState.getY();
if (Scene.getInstance().getDisableShadowInAction()) {
if (mouseState.getButtonState(MouseButton.LEFT) == ButtonState.DOWN || mouseState.getButtonState(MouseButton.RIGHT) == ButtonState.DOWN) {
if (MainPanel.getInstance().getShadowButton().isSelected()) {
shadowPass.setEnabled(false);
}
} else {
if (MainPanel.getInstance().getShadowButton().isSelected()) {
shadowPass.setEnabled(true);
}
}
}
try {
if (selectedPart != null) {
if (!selectedPart.isDrawCompleted()) {
selectedPart.setPreviewPoint(x, y);
if (selectedPart instanceof Meshable) {
// don't draw grid if it sits on an imported mesh
selectedPart.setGridsVisible(((Meshable) selectedPart).getMeshLocator() == null);
}
} else if (objectMoveStartPoint != null) {
if ((operation == Operation.RESIZE || selectedPart instanceof Foundation)) {
final PickedHousePart pick = SelectUtil.pickPart(x, y, collisionLand);
if (pick != null) {
if (selectedPart instanceof Foundation) {
final Foundation foundation = (Foundation) selectedPart;
final Vector3 pickPoint = pick.getPoint().clone();
// if (!foundation.insideBuilding(pickPoint.getX(), pickPoint.getY(), true)) { // only move the building when clicking outside
final Vector3 d = pickPoint.multiply(1, 1, 0, null).subtractLocal(objectMoveStartPoint.multiply(1, 1, 0, null));
if (foundation.isGroupMaster()) {
final List<Foundation> g = Scene.getInstance().getFoundationGroup(foundation);
for (final Foundation f : g) {
final ArrayList<Vector3> movePoints = objectGroupMovePoints.get(f);
if (movePoints != null) {
// just in case this foundation's move point hasn't been included yet
f.move(d, movePoints);
}
}
} else {
foundation.move(d, objectMovePoints);
}
}
}
} else if (selectedPart instanceof Tree) {
final PickedHousePart pick = SelectUtil.pickPart(x, y, collisionLand);
if (pick != null) {
final Vector3 d = pick.getPoint().multiply(1, 1, 0, null).subtractLocal(objectMoveStartPoint.multiply(1, 1, 0, null));
((Tree) selectedPart).move(d, objectMovePoints);
}
} else if (selectedPart instanceof Window) {
final PickedHousePart pick = SelectUtil.pickPart(x, y, selectedPart.getContainer());
if (pick != null) {
final Vector3 d = pick.getPoint().subtract(objectMoveStartPoint, null);
((Window) selectedPart).move(d, objectMovePoints);
}
}
}
}
hoveredPart = null;
if ((operation == Operation.SELECT || operation == Operation.RESIZE) && mouseState.getButtonState(MouseButton.LEFT) == ButtonState.UP && mouseState.getButtonState(MouseButton.MIDDLE) == ButtonState.UP && mouseState.getButtonState(MouseButton.RIGHT) == ButtonState.UP) {
final PickedHousePart pickedPart = SelectUtil.selectHousePart(x, y, false);
pick = pickedPart == null ? null : pickedPart.getUserData();
final HousePart housePart = pick == null ? null : pick.getHousePart();
if (pick != null) {
hoveredPart = housePart;
if (pick.getEditPointIndex() != -1) {
lastSelectedEditPointMouseState = mouseState;
}
}
}
mouseState = null;
} catch (final Throwable t) {
t.printStackTrace();
BugReporter.report(t);
}
EventQueue.invokeLater(new // this method is run by the main Energy3D thread, so invoke the Swing code later
Runnable() {
@Override
public void run() {
final Component canvasComponent = (Component) canvas;
canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
if (!zoomLock && (operation == Operation.SELECT || operation == Operation.RESIZE) && hoveredPart != null) {
if (hoveredPart instanceof Tree || hoveredPart instanceof Human) {
canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else if (hoveredPart instanceof SolarCollector) {
if (pick.getEditPointIndex() >= 0) {
canvasComponent.setCursor(Cursor.getPredefinedCursor(pick.getEditPointIndex() == 0 ? Cursor.MOVE_CURSOR : Cursor.HAND_CURSOR));
}
} else {
if (pick.getEditPointIndex() == -1) {
if (hoveredPart instanceof Window) {
// for windows, there is no apparent move point
canvasComponent.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
}
}
}
}
}
});
}
Aggregations