diff --git a/GUI/src/main/java/cz/fidentis/analyst/scene/DrawableCuttingPlane.java b/GUI/src/main/java/cz/fidentis/analyst/scene/DrawableCuttingPlane.java index 2a8dab3ba0bfa2ded1290a884213ada662dcce99..7c0d9d572c693e498aacaf3b239e84dc439f79af 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/scene/DrawableCuttingPlane.java +++ b/GUI/src/main/java/cz/fidentis/analyst/scene/DrawableCuttingPlane.java @@ -21,9 +21,10 @@ public class DrawableCuttingPlane extends DrawablePlane { * * @param plane plane * @param bbox bounding box used to estimate cutting pale shape (rectangle) + * @param showBBox whether to render bounding box */ - public DrawableCuttingPlane(Plane plane, BBox bbox) { - super(plane, bbox); + public DrawableCuttingPlane(Plane plane, BBox bbox, boolean showBBox) { + super(plane, bbox, showBBox); } /** diff --git a/GUI/src/main/java/cz/fidentis/analyst/scene/DrawablePlane.java b/GUI/src/main/java/cz/fidentis/analyst/scene/DrawablePlane.java index 0796f9d7a9c207a60f13d0912333fda836bfb9b9..7a580019f638d89e4b1b37fa27eacbcb8932e671 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/scene/DrawablePlane.java +++ b/GUI/src/main/java/cz/fidentis/analyst/scene/DrawablePlane.java @@ -17,6 +17,7 @@ public class DrawablePlane extends Drawable { private Plane plane; private final BBox bbox; + private boolean showBoundingBox; /** @@ -24,10 +25,12 @@ public class DrawablePlane extends Drawable { * * @param plane plane * @param bbox bounding box used to estimate cutting pale shape (rectangle) + * @param showBBox whether to render bounding box */ - public DrawablePlane(Plane plane, BBox bbox) { + public DrawablePlane(Plane plane, BBox bbox, boolean showBBox) { this.plane = plane; this.bbox = bbox; + this.showBoundingBox = showBBox; } /** @@ -39,12 +42,30 @@ public class DrawablePlane extends Drawable { super(drPlane); this.plane = new Plane(drPlane.getPlane()); this.bbox = drPlane.bbox; + this.showBoundingBox = drPlane.showBoundingBox; } public Plane getPlane() { return plane; } + /** + * Returns {@code true} if the bounding box is to be rendered. + * @return {@code true} if the bounding box is to be rendered. + */ + public boolean isShownBBobx() { + return this.showBoundingBox; + } + + /** + * Switches on/off bounding box rendering. + * + * @param show If {@code true], then the bounding box is rendered as well + */ + public void setShowBBox(boolean show) { + this.showBoundingBox = show; + } + protected void setPlane(Plane plane) { this.plane = plane; } @@ -59,11 +80,56 @@ public class DrawablePlane extends Drawable { // get the normal and tex coords indicies for face i for (int v = 0; v < facet.getCornerTable().getSize(); v++) { Point3d vert = facet.getVertices().get(facet.getCornerTable().getRow(v).getVertexIndex()).getPosition(); - if (v == 0) { - } gl.glVertex3d(vert.x, vert.y, vert.z); } gl.glEnd(); + + if (showBoundingBox) { + Point3d min = bbox.getMinPoint(); + Point3d max = bbox.getMaxPoint(); + gl.glBegin(GL2.GL_LINES); + + // bottom rectangle: + gl.glVertex3d(min.x, min.y, min.z); + gl.glVertex3d(max.x, min.y, min.z); + + gl.glVertex3d(max.x, min.y, min.z); + gl.glVertex3d(max.x, min.y, max.z); + + gl.glVertex3d(max.x, min.y, max.z); + gl.glVertex3d(min.x, min.y, max.z); + + gl.glVertex3d(min.x, min.y, max.z); + gl.glVertex3d(min.x, min.y, min.z); + + // top rectangle: + gl.glVertex3d(min.x, max.y, min.z); + gl.glVertex3d(max.x, max.y, min.z); + + gl.glVertex3d(max.x, max.y, min.z); + gl.glVertex3d(max.x, max.y, max.z); + + gl.glVertex3d(max.x, max.y, max.z); + gl.glVertex3d(min.x, max.y, max.z); + + gl.glVertex3d(min.x, max.y, max.z); + gl.glVertex3d(min.x, max.y, min.z); + + // vertical edges: + gl.glVertex3d(min.x, min.y, min.z); + gl.glVertex3d(min.x, max.y, min.z); + + gl.glVertex3d(max.x, min.y, min.z); + gl.glVertex3d(max.x, max.y, min.z); + + gl.glVertex3d(max.x, min.y, max.z); + gl.glVertex3d(max.x, max.y, max.z); + + gl.glVertex3d(min.x, min.y, max.z); + gl.glVertex3d(min.x, max.y, max.z); + + gl.glEnd(); + } } protected BBox getBBox() { diff --git a/GUI/src/main/java/cz/fidentis/analyst/scene/Scene.java b/GUI/src/main/java/cz/fidentis/analyst/scene/Scene.java index 22fbdc2fd9c2825cda4dcfc3b4da9ca03e6a4225..c8ef2126571a5a71a8fd3e4ba18b960ec5f74149 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/scene/Scene.java +++ b/GUI/src/main/java/cz/fidentis/analyst/scene/Scene.java @@ -221,7 +221,7 @@ public class Scene { } if (drawableSymmetryPlanes.get(slot) == null) { // add new - drawableSymmetryPlanes.set(slot, new DrawablePlane(face.getSymmetryPlane(), face.getBoundingBox())); + drawableSymmetryPlanes.set(slot, new DrawablePlane(face.getSymmetryPlane(), face.getBoundingBox(), false)); } else { // replace existing drawableSymmetryPlanes.get(slot).setPlane(face.getSymmetryPlane()); } diff --git a/GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java b/GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java index e79f9fd1eebc048ff394f0252f1f6390c3a7268c..3534229e31312cadf1650786c9e1870036c26f54 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java @@ -274,7 +274,7 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe protected void computeVerticalCuttingPlanes() { BBox bbox = getCanvas().getPrimaryFace().getBoundingBox(); Plane plane = new Plane(new Vector3d(1,0,0), bbox.getMidPoint().x); - DrawableCuttingPlane cuttingPlane = new DrawableCuttingPlane(plane, bbox); + DrawableCuttingPlane cuttingPlane = new DrawableCuttingPlane(plane, bbox, true); cuttingPlane.setTransparency(0.5f); if (priCuttingPlaneSlot == -1) { priCuttingPlaneSlot = getCanvas().getScene().getFreeSlotForOtherDrawables(); @@ -284,7 +284,7 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe if (getSecondaryDrawableFace() != null) { bbox = getCanvas().getSecondaryFace().getBoundingBox(); plane = new Plane(new Vector3d(1,0,0), bbox.getMidPoint().x); - cuttingPlane = new DrawableCuttingPlane(plane, bbox); + cuttingPlane = new DrawableCuttingPlane(plane, bbox, true); cuttingPlane.setTransparency(0.5f); if (secCuttingPlaneSlot == -1) { secCuttingPlaneSlot = getCanvas().getScene().getFreeSlotForOtherDrawables(); @@ -305,7 +305,8 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe } DrawableCuttingPlane cuttingPlane = new DrawableCuttingPlane( new Plane(symmetryPlane), - getCanvas().getPrimaryFace().getBoundingBox() + getCanvas().getPrimaryFace().getBoundingBox(), + false ); cuttingPlane.setTransparency(0.5f); if (priCuttingPlaneSlot == -1) { @@ -321,7 +322,8 @@ public class ProfilesAction extends ControlPanelAction implements HumanFaceListe } cuttingPlane = new DrawableCuttingPlane( new Plane(symmetryPlane), - getCanvas().getSecondaryFace().getBoundingBox() + getCanvas().getSecondaryFace().getBoundingBox(), + false ); cuttingPlane.setTransparency(0.5f); if (secCuttingPlaneSlot == -1) {