use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.
the class Foundation method removeAllWithinPolygon.
public void removeAllWithinPolygon() {
if (foundationPolygon == null || !foundationPolygon.isVisible()) {
return;
}
final Path2D.Double path = new Path2D.Double();
final int n = foundationPolygon.points.size();
Vector3 v = foundationPolygon.getAbsPoint(0);
path.moveTo(v.getX(), v.getY());
for (int i = 1; i < n / 2; i++) {
// use only the first half of the vertices from the polygon
v = foundationPolygon.getAbsPoint(i);
path.lineTo(v.getX(), v.getY());
}
path.closePath();
final List<HousePart> selectedParts = new ArrayList<HousePart>();
for (final HousePart child : children) {
final Vector3 center = child.getAbsCenter();
if (path.contains(center.getX(), center.getY())) {
selectedParts.add(child);
}
}
if (selectedParts.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no object to remove.", "No Object", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "<html>Do you really want to remove all " + selectedParts.size() + " objects<br>within the white border line of the selected foundation?</html>", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(selectedParts);
for (final HousePart part : selectedParts) {
Scene.getInstance().remove(part, false);
}
draw();
SceneManager.getInstance().getUndoManager().addEdit(c);
}
use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.
the class Scene method removeAllWalls.
public void removeAllWalls() {
final ArrayList<HousePart> walls = new ArrayList<HousePart>();
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 Wall && !part.getLockEdit() && part.getTopContainer() == foundation) {
walls.add(part);
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof Wall && !part.getLockEdit()) {
walls.add(part);
}
}
}
if (walls.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no wall to remove.", "No Wall", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + walls.size() + " walls" + (selectedPart != null ? " of the selected building" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(walls);
for (final HousePart part : walls) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.
the class Scene method removeAllRacks.
public void removeAllRacks() {
final ArrayList<HousePart> racks = new ArrayList<HousePart>();
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 Rack && part.getTopContainer() == foundation) {
racks.add(part);
}
}
} else {
for (final HousePart part : parts) {
if (part instanceof Rack) {
racks.add(part);
}
}
}
if (racks.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no rack to remove.", "No Rack", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + racks.size() + " solar panel racks" + (selectedPart != null ? " on the selected foundation" : "") + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(racks);
for (final HousePart part : racks) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.
the class Scene method removeAllFloors.
public void removeAllFloors() {
final ArrayList<HousePart> floors = new ArrayList<HousePart>();
for (final HousePart part : parts) {
if (part instanceof Floor && !part.getLockEdit()) {
floors.add(part);
}
}
if (floors.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no floor to remove.", "No Floor", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + floors.size() + " floors?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(floors);
for (final HousePart part : floors) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
use of org.concord.energy3d.undo.RemoveMultiplePartsCommand in project energy3d by concord-consortium.
the class Scene method removeAllHumans.
public void removeAllHumans() {
final ArrayList<HousePart> humans = new ArrayList<HousePart>();
for (final HousePart part : parts) {
if (part instanceof Human) {
humans.add(part);
}
}
if (humans.isEmpty()) {
JOptionPane.showMessageDialog(MainFrame.getInstance(), "There is no human to remove.", "No Human", JOptionPane.INFORMATION_MESSAGE);
return;
}
if (JOptionPane.showConfirmDialog(MainFrame.getInstance(), "Do you really want to remove all " + humans.size() + " humans?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
return;
}
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(humans);
for (final HousePart part : humans) {
remove(part, false);
}
redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
}
Aggregations