use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SceneManager method getPickedLocationOnFoundation.
public Vector3 getPickedLocationOnFoundation() {
if (pickMouseState != null) {
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Foundation) {
final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), selectedPart);
if (pick != null) {
return pick.getPoint().clone();
}
}
pickMouseState = null;
}
return null;
}
use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SceneManager method mousePressed.
private void mousePressed(final MouseState mouseState, final KeyboardState keyboardState) {
refresh = true;
taskManager.update(new Callable<Object>() {
@Override
public Object call() {
if (zoomLock) {
return null;
}
System.out.println("OPERATION: " + operation);
try {
if (operation == Operation.SELECT || operation == Operation.RESIZE || operation == Operation.ROTATE || operation == Operation.DRAW_ROOF_GABLE) {
if (selectedPart == null || selectedPart.isDrawCompleted()) {
final HousePart previousSelectedPart = selectedPart;
final PickedHousePart pickedPart = SelectUtil.selectHousePart(mouseState.getX(), mouseState.getY(), true);
final UserData pick = pickedPart == null ? null : pickedPart.getUserData();
if (pick == null) {
selectedPart = null;
} else {
selectedPart = pick.getHousePart();
}
if (selectedPart != null) {
// }
if (keyboardState.isDown(Key.LMENU) || keyboardState.isDown(Key.RMENU)) {
if (selectedPart instanceof SolarPanel && selectedPart.getContainer() instanceof Rack) {
// special case
selectedPart = selectedPart.getContainer();
}
}
}
System.out.println("Clicked on: " + pick);
if (pick != null && pick.isEditPoint()) {
cameraControl.setLeftMouseButtonEnabled(false);
}
if (operation == Operation.RESIZE) {
for (final HousePart p : Scene.getInstance().getParts()) {
if (p instanceof Foundation) {
if (p != selectedPart) {
((Foundation) p).setResizeHouseMode(false);
}
}
}
if (selectedPart != null) {
if (selectedPart instanceof Foundation) {
final Foundation foundation = (Foundation) selectedPart;
foundation.setResizeHouseMode(true);
} else {
final Foundation foundation = selectedPart.getTopContainer();
if (foundation != null) {
foundation.setResizeHouseMode(true);
setSelectedPart(foundation);
}
}
}
}
if (operation == Operation.SELECT || operation == Operation.ROTATE) {
if (previousSelectedPart instanceof Foundation) {
final Foundation foundation = (Foundation) previousSelectedPart;
foundation.updateAzimuthArrowVisibility(false);
}
if (selectedPart instanceof Foundation) {
final Foundation foundation = (Foundation) selectedPart;
foundation.drawAzimuthArrow();
foundation.pickMesh(mouseState.getX(), mouseState.getY());
}
if (selectedPart != null) {
final Foundation foundationOfSelectedPart = selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer();
if (foundationOfSelectedPart != null) {
foundationOfSelectedPart.setMovePointsVisible(true);
}
}
}
if (operation == Operation.RESIZE && selectedPart != null) {
if (!(selectedPart instanceof Foundation)) {
selectedPart.setEditPointsVisible(false);
selectedPart = selectedPart.getTopContainer();
}
}
if (selectedPart instanceof Window || selectedPart instanceof Tree || (selectedPart instanceof Foundation && pick.getEditPointIndex() != -1)) {
cameraControl.setLeftMouseButtonEnabled(false);
objectMoveStartPoint = pickedPart.getPoint().clone();
collisionLand.setTranslation(0, 0, objectMoveStartPoint.getZ());
final ArrayList<Vector3> points = selectedPart.getPoints();
if (objectMovePoints == null) {
objectMovePoints = new ArrayList<Vector3>();
} else {
objectMovePoints.clear();
}
for (final Vector3 p : points) {
objectMovePoints.add(p.clone());
}
if (selectedPart instanceof Foundation) {
final Foundation f = (Foundation) selectedPart;
if (f.isGroupMaster()) {
final List<Foundation> g = Scene.getInstance().getFoundationGroup(f);
if (!g.isEmpty()) {
if (objectGroupMovePoints == null) {
objectGroupMovePoints = new HashMap<Foundation, ArrayList<Vector3>>();
} else {
objectGroupMovePoints.clear();
}
for (final Foundation a : g) {
final ArrayList<Vector3> b = new ArrayList<Vector3>();
objectGroupMovePoints.put(a, b);
for (final Vector3 p : a.getPoints()) {
b.add(p.clone());
}
}
}
}
}
}
if (previousSelectedPart != null && previousSelectedPart != selectedPart && operation != Operation.RESIZE) {
previousSelectedPart.setEditPointsVisible(false);
previousSelectedPart.setGridsVisible(false);
previousSelectedPart.setLinePatternVisible(false);
final Foundation foundationOfPreviousSelectedPart = previousSelectedPart instanceof Foundation ? (Foundation) previousSelectedPart : previousSelectedPart.getTopContainer();
if (foundationOfPreviousSelectedPart != null) {
if (selectedPart == null) {
foundationOfPreviousSelectedPart.setMovePointsVisible(false);
} else if (foundationOfPreviousSelectedPart != (selectedPart instanceof Foundation ? (Foundation) selectedPart : selectedPart.getTopContainer())) {
foundationOfPreviousSelectedPart.setMovePointsVisible(false);
}
foundationOfPreviousSelectedPart.clearSelectedMesh();
foundationOfPreviousSelectedPart.setResizeHouseMode(false);
}
}
if (selectedPart != null && !PrintController.getInstance().isPrintPreview()) {
selectedPart.setEditPointsVisible(true);
if (pick.isEditPoint() && pick.getEditPointIndex() != -1 || operation == Operation.RESIZE || selectedPart instanceof Window || selectedPart instanceof Tree) {
if (Scene.getInstance().isSnapToGrids()) {
selectedPart.setGridsVisible(true);
} else {
selectedPart.setLinePatternVisible(true);
}
if (selectedPart instanceof Foundation) {
editPartCommand = new EditFoundationCommand((Foundation) selectedPart, !pick.isEditPoint());
} else if (selectedPart instanceof Rack) {
editPartCommand = new EditRackCommand((Rack) selectedPart);
} else if (selectedPart instanceof ParabolicTrough) {
editPartCommand = new EditParabolicTroughCommand((ParabolicTrough) selectedPart);
} else {
editPartCommand = new EditPartCommand(selectedPart);
}
}
}
SelectUtil.nextPickLayer();
if (operation == Operation.DRAW_ROOF_GABLE && selectedPart instanceof Roof) {
System.out.println("deleting roof #" + pick.getEditPointIndex());
final int roofPartIndex = pick.getEditPointIndex();
final Roof roof = (Roof) selectedPart;
roof.setGable(roofPartIndex, true, undoManager);
}
}
} else {
if (selectedPart != null) {
// selected part can be null in modes other than specified in the if clause
selectedPart.addPoint(mouseState.getX(), mouseState.getY());
}
}
} catch (final Throwable t) {
t.printStackTrace();
BugReporter.report(t);
}
return null;
}
});
}
use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SceneManager method getPickedLocationOnRack.
Vector3 getPickedLocationOnRack() {
if (pickMouseState != null) {
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Rack) {
final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), selectedPart);
if (pick != null) {
return pick.getPoint().clone();
}
}
pickMouseState = null;
}
return null;
}
use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SceneManager method getPickedLocationOnRoof.
Vector3 getPickedLocationOnRoof() {
if (pickMouseState != null) {
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Roof) {
final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), selectedPart);
if (pick != null) {
return pick.getPoint().clone();
}
}
pickMouseState = null;
}
return null;
}
use of org.concord.energy3d.model.PickedHousePart in project energy3d by concord-consortium.
the class SceneManager method getPickedLocationOnWall.
Vector3 getPickedLocationOnWall() {
if (pickMouseState != null) {
final HousePart selectedPart = SceneManager.getInstance().getSelectedPart();
if (selectedPart instanceof Wall) {
final PickedHousePart pick = SelectUtil.pickPart(pickMouseState.getX(), pickMouseState.getY(), selectedPart);
if (pick != null) {
return pick.getPoint().clone();
}
}
pickMouseState = null;
}
return null;
}
Aggregations