diff --git a/GUI/src/main/java/cz/fidentis/analyst/registration/PostRegistrationListener.java b/GUI/src/main/java/cz/fidentis/analyst/registration/PostRegistrationListener.java deleted file mode 100644 index 23ab93649361a4d6b3dc7405b50e71e663991b15..0000000000000000000000000000000000000000 --- a/GUI/src/main/java/cz/fidentis/analyst/registration/PostRegistrationListener.java +++ /dev/null @@ -1,604 +0,0 @@ -package cz.fidentis.analyst.registration; - -import com.jogamp.opengl.GL2; -import cz.fidentis.analyst.feature.FeaturePoint; -import cz.fidentis.analyst.canvas.Canvas; -import cz.fidentis.analyst.scene.DrawableFace; -import cz.fidentis.analyst.scene.DrawableMesh; -import cz.fidentis.analyst.mesh.core.MeshFacet; -import cz.fidentis.analyst.mesh.core.MeshPoint; -import cz.fidentis.analyst.visitors.mesh.BoundingBox; -import java.awt.Color; -import java.util.ArrayList; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3d; - -/** - * Updates primary resp. secondary {@link DrawableMesh}. - * - * @author Richard Pajersky - */ - -public class PostRegistrationListener { - - /** - * Transformation shift is higher - */ - public static final double HIGH_SHIFT_QUOTIENT = 1; - - /** - * Transformation shift is lower - */ - public static final double LOW_SHIFT_QUOTIENT = 0.1; - - /** - * Quotient which determines translation and scale amount - */ - private static final double CHANGE_QUOTIENT = 500d; - - /** - * Color used as default color of primary face - */ - public static final Color DEFAULT_PRIMARY_COLOR = new Color(101, 119, 179); - - /** - * Color used as default color of secondary face - */ - public static final Color DEFAULT_SECONDARY_COLOR = new Color(237, 217, 76); - - /** - * Range of transparency - */ - public static final int TRANSPARENCY_RANGE = 10; - - /** - * Canvas which contains faces - */ - private final Canvas canvas; - - /** - * Move amount on X-axis - */ - private final double moveX; - - /** - * Move amount on Y-axis - */ - private final double moveY; - - /** - * Move amount on Z-axis - */ - private final double moveZ; - - /** - * Scale amount in all axis - */ - private final double scaleXYZ; - - /** - * Primary face used for visualization - */ - private final DrawableFace primaryFace; - - /** - * Secondary face used for visualization and transformation - */ - private final DrawableFace secondaryFace; - - /** - * Transformation amount - */ - private double moveModifier = LOW_SHIFT_QUOTIENT; - - /** - * Threshold of feature points showing too far away - */ - private double featurePointsThreshold = LOW_SHIFT_QUOTIENT; - - /** - * Constructor - * First initialize {@link #canvas} then - * {@link #primaryFace} and {@link #secondaryFace} - * Then computes movement amounts based on - * {@link BoundingBox} of secondary face - * - * @param canvas Canvas with two faces - * @throws IllegalArgumentException if the canvas is {@code null} - */ - public PostRegistrationListener(Canvas canvas) { - if (canvas == null) { - throw new IllegalArgumentException("canvas is null"); - } - this.canvas = canvas; - - //List<DrawableFace> drawables = new ArrayList<>(canvas.getScene().getDrawables()); - //if (drawables.size() < 2) { - // throw new IllegalArgumentException("canvas doesn't contains at least 2 models"); - //} - this.primaryFace = canvas.getScene().getDrawableFace(0); - this.secondaryFace = canvas.getScene().getDrawableFace(1); - setDeafultColor(); - - // set move amounts - BoundingBox visitor = new BoundingBox(); - this.secondaryFace.getModel().compute(visitor); - Point3d maxPoint = visitor.getBoundingBox().getMaxPoint(); - Point3d minPoint = visitor.getBoundingBox().getMinPoint(); - moveX = (maxPoint.x - minPoint.x) / CHANGE_QUOTIENT; - moveY = (maxPoint.y - minPoint.y) / CHANGE_QUOTIENT; - moveZ = (maxPoint.z - minPoint.z) / CHANGE_QUOTIENT; - scaleXYZ = (visitor.getBoundingBox().getMaxDiag() / (10 * CHANGE_QUOTIENT)); - } - - /** - * Calculates feature points which are too far away - * and changes their color to red - * otherwise set color to default - */ - private void calculateFeaturePoints() { - if (!primaryFace.isRenderFeaturePoints()) { - return; - } - ArrayList<Color> color = (ArrayList)secondaryFace.getFeaturePointsColor(); - for (int i = 0; i < primaryFace.getFeaturePoints().size(); i++) { - FeaturePoint primary = primaryFace.getFeaturePoints().get(i); - FeaturePoint secondary = secondaryFace.getFeaturePoints().get(i); - Point3d transformed = new Point3d(secondary.getX(), secondary.getY(), secondary.getZ()); - transformPoint(transformed); - double distance = Math.sqrt( - Math.pow(transformed.x - primary.getX(), 2) + - Math.pow(transformed.y - primary.getY(), 2) + - Math.pow(transformed.z - primary.getZ(), 2)); - if (distance > featurePointsThreshold) { - color.set(i, Color.RED); - } else { - color.set(i, DEFAULT_SECONDARY_COLOR); - } - } - } - - /** - * Applies carried out transformations - * first on {@link #secondaryFace} - * and then on {@link #secondaryFace} feature points - */ - public void transformFace() { - for (MeshFacet transformedFacet : secondaryFace.getFacets()) { - for (MeshPoint comparedPoint : transformedFacet.getVertices()) { - transformPoint(comparedPoint.getPosition()); - } - } - for (int i = 0; i < secondaryFace.getFeaturePoints().size(); i++) { - FeaturePoint point = secondaryFace.getFeaturePoints().get(i); - Point3d transformed = new Point3d(point.getX(), point.getY(), point.getZ()); - transformPoint(transformed); - point = new FeaturePoint(transformed.x, transformed.y, - transformed.z, point.getFeaturePointType()); - secondaryFace.getFeaturePoints().set(i, point); - } - } - - /** - * Transforms point based on transformation info from {@link #secondaryFace} - * - * @param point Point to transform - */ - public void transformPoint(Point3d point) { - if (point == null) { - throw new IllegalArgumentException("point is null"); - } - - Point3d newPoint = new Point3d(0, 0, 0); - double quotient; - - // rotate around X - quotient = Math.toRadians(secondaryFace.getRotation().x); - if (!Double.isNaN(quotient)) { - double cos = Math.cos(quotient); - double sin = Math.sin(quotient); - newPoint.y = point.y * cos - point.z * sin; - newPoint.z = point.z * cos + point.y * sin; - point.y = newPoint.y; - point.z = newPoint.z; - } - - // rotate around Y - quotient = Math.toRadians(secondaryFace.getRotation().y); - if (!Double.isNaN(quotient)) { - double cos = Math.cos(quotient); - double sin = Math.sin(quotient); - newPoint.x = point.x * cos + point.z * sin; - newPoint.z = point.z * cos - point.x * sin; - point.x = newPoint.x; - point.z = newPoint.z; - } - - // rotate around Z - quotient = Math.toRadians(secondaryFace.getRotation().z); - if (!Double.isNaN(quotient)) { - double cos = Math.cos(quotient); - double sin = Math.sin(quotient); - newPoint.x = point.x * cos - point.y * sin; - newPoint.y = point.y * cos + point.x * sin; - point.x = newPoint.x; - point.y = newPoint.y; - } - - // translate - point.x += secondaryFace.getTranslation().x; - point.y += secondaryFace.getTranslation().y; - point.z += secondaryFace.getTranslation().z; - - // scale - point.x *= 1 + secondaryFace.getScale().x; - point.y *= 1 + secondaryFace.getScale().y; - point.z *= 1 + secondaryFace.getScale().z; - } - - /** - * Sets {@link #primaryFace} to {@link #DEFAULT_PRIMARY_COLOR} and - * {@link #secondaryFace} to {@link #DEFAULT_SECONDARY_COLOR} - */ - public final void setDeafultColor() { - primaryFace.setColor(DEFAULT_PRIMARY_COLOR); - secondaryFace.setColor(DEFAULT_SECONDARY_COLOR); - canvas.renderScene(); - } - - /** - * Sets the color of {@link #primaryFace} - * @param color Color - */ - public void setPrimaryColor(Color color) { - primaryFace.setColor(color); - canvas.renderScene(); - } - - /** - * Sets the color of {@link #secondaryFace} - * @param color Color - */ - public void setSecondaryColor(Color color) { - secondaryFace.setColor(color); - canvas.renderScene(); - } - - /** - * @return {@link Color} of {@link #primaryFace} - */ - public Color getPrimaryColor() { - return primaryFace.getColor(); - } - - /** - * @return {@link Color} of {@link #secondaryFace} - */ - public Color getSecondaryColor() { - return secondaryFace.getColor(); - } - - /** - * Sets the transparency of {@link #primaryFace} or {@link #secondaryFace} - * based on the inputed value and {@link #TRANSPARENCY_RANGE} - * @param value Value - */ - public void setTransparency(int value) { - - if (value == TRANSPARENCY_RANGE) { - setPrimaryTransparency(1); - setSecondaryTransparency(1); - } - if (value < TRANSPARENCY_RANGE) { - setPrimaryTransparency(value / 10f); - setSecondaryTransparency(1); - } - if (value > TRANSPARENCY_RANGE) { - setSecondaryTransparency((2 * TRANSPARENCY_RANGE - value) / 10f); - setPrimaryTransparency(1); - } - canvas.renderScene(); - } - - /** - * Sets transparency of {@link #primaryFace} - * - * @param transparency Transparency value - */ - public void setPrimaryTransparency(float transparency) { - primaryFace.setTransparency(transparency); - } - - /** - * Sets transparency of {@link #secondaryFace} - * - */ - public void setSecondaryTransparency(float transparency) { - secondaryFace.setTransparency(transparency); - } - - /** - * @return Transparency of {@link #primaryFace} - */ - public double getPrimaryTransparency() { - return primaryFace.getTransparency(); - } - - /** - * @return Transparency of {@link #secondaryFace} - */ - public double getSecondaryTransparency() { - return secondaryFace.getTransparency(); - } - - /** - * Sets camera to show face from the front - */ - public void setFrontFacing() { - canvas.getCamera().initLocation(); - canvas.renderScene(); - } - - /** - * Sets camera to show face from the side - */ - public void setSideFacing() { - canvas.getCamera().initLocation(); - canvas.getCamera().rotate(0, 90); - canvas.renderScene(); - } - - /** - * Resets translation of {@link #secondaryFace} - */ - public void resetTranslation() { - secondaryFace.setTranslation(new Vector3d(0, 0, 0)); - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Resets rotation of {@link #secondaryFace} - */ - public void resetRotation() { - secondaryFace.setRotation(new Vector3d(0, 0, 0)); - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Resets scale of {@link #secondaryFace} - */ - public void resetScale() { - secondaryFace.setScale(new Vector3d(0, 0, 0)); - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Sets translation of {@link #secondaryFace} on X-axis - * @param value Translation amount - */ - public void setXTranslation(double value) { - secondaryFace.getTranslation().x = value * moveX; - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Sets translation of {@link #secondaryFace} on Y-axis - * @param value Translation amount - */ - public void setYTranslation(double value) { - secondaryFace.getTranslation().y = value * moveY; - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Sets translation of {@link #secondaryFace} on Z-axis - * @param value Translation amount - */ - public void setZTranslation(double value) { - secondaryFace.getTranslation().z = value * moveZ; - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Sets rotation of {@link #secondaryFace} around X-axis - * @param value Translation amount - */ - public void setXRotation(double value) { - secondaryFace.getRotation().x = value * moveX; - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Sets rotation of {@link #secondaryFace} around Y-axis - * @param value Translation amount - */ - public void setYRotation(double value) { - secondaryFace.getRotation().y = value * moveY; - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Sets rotation of {@link #secondaryFace} around Z-axis - * @param value Translation amount - */ - public void setZRotation(double value) { - secondaryFace.getRotation().z = value * moveZ; - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Sets scale of {@link #secondaryFace} - * @param value Translation amount - */ - public void setScale(double value) { - secondaryFace.getScale().x = value * scaleXYZ; - secondaryFace.getScale().y = value * scaleXYZ; - secondaryFace.getScale().z = value * scaleXYZ; - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * Sets color of {@link #primaryFace} highlights to white - */ - public void setPrimaryHighlights() { - primaryFace.setHighlights(new Color(1, 1, 1)); - canvas.renderScene(); - } - - /** - * Sets color of {@link #secondaryFace} highlights to white - */ - public void setSecondaryHighlights() { - secondaryFace.setHighlights(new Color(1, 1, 1)); - canvas.renderScene(); - } - - /** - * Sets color of {@link #primaryFace} highlights to black - */ - public void removePrimaryHighlights() { - primaryFace.setHighlights(new Color(0, 0, 0)); - canvas.renderScene(); - } - - /** - * Sets color of {@link #secondaryFace} highlights to black - */ - public void removeSecondaryHighlights() { - secondaryFace.setHighlights(new Color(0, 0, 0)); - canvas.renderScene(); - } - - /** - * Sets {@link #primaryFace} to be rendered as lines - */ - public void setPrimaryLines() { - primaryFace.setRenderMode(GL2.GL_LINE); - canvas.renderScene(); - } - - /** - * Sets {@link #secondaryFace} to be rendered as lines - */ - public void setSecondaryLines() { - secondaryFace.setRenderMode(GL2.GL_LINE); - canvas.renderScene(); - } - - /** - * Sets {@link #primaryFace} to be rendered as points - */ - public void setPrimaryPoints() { - primaryFace.setRenderMode(GL2.GL_POINT); - canvas.renderScene(); - } - - /** - * Sets {@link #secondaryFace} to be rendered as points - */ - public void setSecondaryPoints() { - secondaryFace.setRenderMode(GL2.GL_POINT); - canvas.renderScene(); - } - - /** - * Sets {@link #primaryFace} to be rendered solid - */ - public void setPrimaryFill() { - primaryFace.setRenderMode(GL2.GL_FILL); - canvas.renderScene(); - } - - /** - * Sets {@link #secondaryFace} to be rendered solid - */ - public void setSecondaryFill() { - secondaryFace.setRenderMode(GL2.GL_FILL); - canvas.renderScene(); - } - - /** - * @return {@code true} if feature points are being rendered - */ - public boolean areFeaturePointsActive() { - return primaryFace.isRenderFeaturePoints(); - } - - /** - * Sets feature points of {@link #primaryFace} and {@link #secondaryFace} - * to given state - * @param state State - */ - public void setFeaturePointsActive(boolean state) { - primaryFace.setRenderFeaturePoints(state); - secondaryFace.setRenderFeaturePoints(state); - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * @return Value of {@link #featurePointsThreshold} - */ - public double getFeaturePointsThreshold() { - return featurePointsThreshold; - } - - /** - * Sets {@link #featurePointsThreshold} to given value - * @param featurePointsThreshold Threshold - */ - public void setFeaturePointsThreshold(double featurePointsThreshold) { - this.featurePointsThreshold = featurePointsThreshold; - calculateFeaturePoints(); - canvas.renderScene(); - } - - /** - * @return Value of {@link #moveModifier} - */ - public double getMoveModifier() { - return moveModifier; - } - - /** - * Sets {@link #moveModifier} to given value - * @param moveModifier Modifier - */ - public void setMoveModifier(double moveModifier) { - this.moveModifier = moveModifier; - } - - /** - * @return {@link #canvas} - */ - public Canvas getCanvas() { - return canvas; - } - - /** - * @return {@code true} if back face is being shown - */ - public boolean isShowBackfaceActive() { - return primaryFace.isShowBackface(); - } - - /** - * Sets backface to be rendered or not based on the given state - * @param state State - */ - public void setShowBackfaceActive(boolean state) { - primaryFace.setShowBackface(state); - secondaryFace.setShowBackface(state); - canvas.renderScene(); - } -} diff --git a/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationAction.java b/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationAction.java index c730c6c412a56699e4c5806e8fb87503a66f44a6..b6d6778f9ca284beb656374c78becea05b3717e4 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationAction.java +++ b/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationAction.java @@ -10,14 +10,12 @@ import cz.fidentis.analyst.icp.UndersamplingStrategy; import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.mesh.core.MeshPoint; import cz.fidentis.analyst.scene.DrawableFace; -import cz.fidentis.analyst.visitors.mesh.BoundingBox; import java.awt.Color; import java.awt.event.ActionEvent; import java.util.List; import javax.swing.JFormattedTextField; import javax.swing.JSlider; import javax.swing.JTabbedPane; -import javax.swing.JTextField; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; @@ -60,35 +58,15 @@ public class RegistrationAction extends ControlPanelAction { private UndersamplingStrategy undersampling = new RandomStrategy(200); - /** - * Transformation shift is higher - */ - public static final double HIGH_SHIFT_QUOTIENT = 1; - - /** - * Transformation shift is lower - */ - public static final double LOW_SHIFT_QUOTIENT = 0.1; - - /** - * Quotient which determines translation and scale amount - */ - private static final double CHANGE_QUOTIENT = 500d; - /** * Range of transparency */ public static final int TRANSPARENCY_RANGE = 10; - /** - * Transformation amount - */ - //private double moveModifier = LOW_SHIFT_QUOTIENT; - /** * Threshold of feature points showing too far away */ - private double featurePointsThreshold = LOW_SHIFT_QUOTIENT; + private double featurePointsThreshold = 0.1; private final RegistrationPanel controlPanel; @@ -346,97 +324,6 @@ public class RegistrationAction extends ControlPanelAction { ///////////////////////////// - protected final void setDeafultColor() { - getPrimaryDrawableFace().setColor(DrawableFace.SKIN_COLOR_PRIMARY); - getSecondaryDrawableFace().setColor(DrawableFace.SKIN_COLOR_SECONDARY); - renderScene(); - } - - protected void setPrimaryColor(Color color) { - getPrimaryDrawableFace().setColor(color); - renderScene(); - } - - protected void setSecondaryColor(Color color) { - getSecondaryDrawableFace().setColor(color); - renderScene(); - } - - protected Color getPrimaryColor() { - return getPrimaryDrawableFace().getColor(); - } - - protected Color getSecondaryColor() { - return getSecondaryDrawableFace().getColor(); - } - - protected double getPrimaryTransparency() { - return getPrimaryDrawableFace().getTransparency(); - } - - protected double getSecondaryTransparency() { - return getSecondaryDrawableFace().getTransparency(); - } - - protected void setPrimaryHighlights() { - if (!haveFaces()) { - return; - } - getPrimaryDrawableFace().setHighlights(new Color(1, 1, 1)); - renderScene(); - } - - protected void setSecondaryHighlights() { - if (!haveFaces()) { - return; - } - getSecondaryDrawableFace().setHighlights(new Color(1, 1, 1)); - renderScene(); - } - - protected void removePrimaryHighlights() { - if (!haveFaces()) { - return; - } - getPrimaryDrawableFace().setHighlights(new Color(0, 0, 0)); - renderScene(); - } - - protected void removeSecondaryHighlights() { - getSecondaryDrawableFace().setHighlights(new Color(0, 0, 0)); - renderScene(); - } - - protected void setPrimaryLines() { - getPrimaryDrawableFace().setRenderMode(GL2.GL_LINE); - renderScene(); - } - - protected void setSecondaryLines() { - getSecondaryDrawableFace().setRenderMode(GL2.GL_LINE); - renderScene(); - } - - protected void setPrimaryPoints() { - getPrimaryDrawableFace().setRenderMode(GL2.GL_POINT); - renderScene(); - } - - protected void setSecondaryPoints() { - getSecondaryDrawableFace().setRenderMode(GL2.GL_POINT); - renderScene(); - } - - protected void setPrimaryFill() { - getPrimaryDrawableFace().setRenderMode(GL2.GL_FILL); - renderScene(); - } - - protected void setSecondaryFill() { - getSecondaryDrawableFace().setRenderMode(GL2.GL_FILL); - renderScene(); - } - protected boolean areFeaturePointsActive() { return getPrimaryDrawableFace().isRenderFeaturePoints(); } @@ -457,8 +344,4 @@ public class RegistrationAction extends ControlPanelAction { getSecondaryDrawableFace().setShowBackface(state); renderScene(); } - - private boolean haveFaces() { - return getPrimaryDrawableFace() != null; - } } diff --git a/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationPanel.form b/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationPanel.form index ae47fde915f59aebed75360f69d0d661af8ce52a..3be976a6ac05fc000d774fffe7661c1de978d5aa 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationPanel.form +++ b/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationPanel.form @@ -123,20 +123,18 @@ <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0"> - <Group type="103" groupAlignment="0" attributes="0"> - <Group type="103" groupAlignment="1" attributes="0"> - <Group type="102" attributes="0"> - <EmptySpace max="-2" attributes="0"/> - <Component id="transparencySlider" min="-2" max="-2" attributes="0"/> - </Group> - <Group type="102" alignment="0" attributes="0"> - <EmptySpace min="-2" pref="27" max="-2" attributes="0"/> - <Component id="visualizationLabel" min="-2" max="-2" attributes="0"/> - </Group> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="transparencySlider" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="27" max="-2" attributes="0"/> + <Component id="visualizationLabel" min="-2" max="-2" attributes="0"/> </Group> <Group type="102" alignment="0" attributes="0"> <EmptySpace min="-2" pref="24" max="-2" attributes="0"/> - <Component id="transparencyButton" max="-2" attributes="0"/> + <Component id="transparencyButton" min="-2" pref="30" max="-2" attributes="0"/> </Group> </Group> <EmptySpace min="-2" pref="34" max="-2" attributes="0"/> @@ -286,14 +284,22 @@ </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> - <Group type="103" alignment="0" groupAlignment="3" attributes="0"> - <Component id="featurePointsLabel" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="featurePointsButton" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="thersholdButton" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="thersholdFTF" alignment="3" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="thersholdFTF" pref="0" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="featurePointsLabel" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="featurePointsButton" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="thersholdButton" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="thersholdUpButton" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="thresholdDownButton" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="0" pref="11" max="32767" attributes="0"/> </Group> - <Component id="thersholdUpButton" alignment="0" min="-2" max="-2" attributes="0"/> - <Component id="thresholdDownButton" alignment="0" min="-2" max="-2" attributes="0"/> </Group> </DimensionLayout> </Layout> @@ -999,10 +1005,8 @@ <Group type="102" alignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0"> <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/> - <Group type="103" alignment="1" groupAlignment="3" attributes="0"> - <Component id="rotatZLabel" alignment="1" min="-2" max="-2" attributes="0"/> - <Component id="rotatYLabel" alignment="1" min="-2" max="-2" attributes="0"/> - </Group> + <Component id="rotatZLabel" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="rotatYLabel" alignment="1" min="-2" max="-2" attributes="0"/> <Component id="rotatXLabel" alignment="1" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> diff --git a/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationPanel.java b/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationPanel.java index 97bf55c477befabab039419844c42aefa3925053..5a27891c313f267295a26459348858d78ee69e0e 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationPanel.java +++ b/GUI/src/main/java/cz/fidentis/analyst/registration/RegistrationPanel.java @@ -2,18 +2,11 @@ package cz.fidentis.analyst.registration; import cz.fidentis.analyst.canvas.Direction; import cz.fidentis.analyst.core.ControlPanel; -import cz.fidentis.analyst.core.ControlPanelBuilder; -import cz.fidentis.analyst.scene.DrawableFace; -import cz.fidentis.analyst.visitors.mesh.BoundingBox; -import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.AbstractAction; import javax.swing.ImageIcon; -import javax.swing.JColorChooser; import javax.swing.JFormattedTextField; -import javax.swing.JSlider; -import javax.vecmath.Point3d; /** * Panel used to interactively visualize two face and adjust their registration. @@ -30,6 +23,17 @@ public class RegistrationPanel extends ControlPanel { public static final double TRANSFORMATION_FINESS = 1.0; + /** + * Transformation shift is higher + */ + public static final double HIGH_SHIFT_QUOTIENT = 1.0; + + /** + * Transformation shift is lower + */ + public static final double LOW_SHIFT_QUOTIENT = 0.1; + + /** * Listener which translates executed actions * into {@link cz.fidentis.analyst.gui.scene.DrawableMesh} @@ -41,7 +45,7 @@ public class RegistrationPanel extends ControlPanel { */ private final ModelRotationAnimator animator = new ModelRotationAnimator(); - private double moveModifier = RegistrationAction.LOW_SHIFT_QUOTIENT; + private double moveModifier = LOW_SHIFT_QUOTIENT; /** * Constructor. @@ -398,13 +402,18 @@ public class RegistrationPanel extends ControlPanel { ); featurePointsPanelLayout.setVerticalGroup( featurePointsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(featurePointsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(featurePointsLabel) - .addComponent(featurePointsButton) - .addComponent(thersholdButton) - .addComponent(thersholdFTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(thersholdUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(thresholdDownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(featurePointsPanelLayout.createSequentialGroup() + .addComponent(thersholdFTF, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addContainerGap()) + .addGroup(featurePointsPanelLayout.createSequentialGroup() + .addGroup(featurePointsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(featurePointsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(featurePointsLabel) + .addComponent(featurePointsButton) + .addComponent(thersholdButton)) + .addComponent(thersholdUpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(thresholdDownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 11, Short.MAX_VALUE)) ); transparencySlider.setMajorTickSpacing(5); @@ -453,17 +462,16 @@ public class RegistrationPanel extends ControlPanel { visualizationPanelLayout.setVerticalGroup( visualizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, visualizationPanelLayout.createSequentialGroup() - .addGroup(visualizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(visualizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(visualizationPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(transparencySlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, visualizationPanelLayout.createSequentialGroup() - .addGap(27, 27, 27) - .addComponent(visualizationLabel))) + .addGroup(visualizationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(visualizationPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(transparencySlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, visualizationPanelLayout.createSequentialGroup() + .addGap(27, 27, 27) + .addComponent(visualizationLabel)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, visualizationPanelLayout.createSequentialGroup() .addGap(24, 24, 24) - .addComponent(transparencyButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(transparencyButton, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(34, 34, 34) .addComponent(viewPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(22, 22, 22) @@ -844,9 +852,8 @@ public class RegistrationPanel extends ControlPanel { .addGroup(rotationPanelLayout.createSequentialGroup() .addGroup(rotationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, rotationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(rotatZLabel) - .addComponent(rotatYLabel)) + .addComponent(rotatZLabel, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(rotatYLabel, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(rotatXLabel, javax.swing.GroupLayout.Alignment.TRAILING)) .addGap(6, 6, 6) .addGroup(rotationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) @@ -1145,7 +1152,7 @@ public class RegistrationPanel extends ControlPanel { * @param evt */ private void transparencyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_transparencyButtonActionPerformed - transparencySlider.setValue(PostRegistrationListener.TRANSPARENCY_RANGE); + transparencySlider.setValue(RegistrationAction.TRANSPARENCY_RANGE); transparencySlider.repaint(); //listener.setTransparency(PostRegistrationListener.TRANSPARENCY_RANGE); }//GEN-LAST:event_transparencyButtonActionPerformed @@ -1304,15 +1311,15 @@ public class RegistrationPanel extends ControlPanel { }//GEN-LAST:event_thersholdUpButtonActionPerformed private void thersholdButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_thersholdButtonActionPerformed - thersholdFTF.setValue(PostRegistrationListener.LOW_SHIFT_QUOTIENT); + thersholdFTF.setValue(LOW_SHIFT_QUOTIENT); }//GEN-LAST:event_thersholdButtonActionPerformed private void lowShiftRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lowShiftRBActionPerformed - this.moveModifier = RegistrationAction.LOW_SHIFT_QUOTIENT; + this.moveModifier = LOW_SHIFT_QUOTIENT; }//GEN-LAST:event_lowShiftRBActionPerformed private void highShiftRBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_highShiftRBActionPerformed - this.moveModifier = RegistrationAction.HIGH_SHIFT_QUOTIENT; + this.moveModifier = HIGH_SHIFT_QUOTIENT; }//GEN-LAST:event_highShiftRBActionPerformed private void backfaceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backfaceButtonActionPerformed